diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-07-04 16:50:02 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-07-04 16:50:02 +0000 |
commit | fe2b3e7c006a607c2b9fd9a485a7bda13515a94f (patch) | |
tree | 1c16960253df2c99488fdd8cf81305ff369884d4 /modules/blogapi/blogapi.module | |
parent | 353c05d01536aac26fec7e9cfee0e84838973286 (diff) | |
download | brdo-fe2b3e7c006a607c2b9fd9a485a7bda13515a94f.tar.gz brdo-fe2b3e7c006a607c2b9fd9a485a7bda13515a94f.tar.bz2 |
- Patch by Steven and me: refactored the form handling of nodes. The node system is now using form_set_error() and friends like the rest of Drupal does. This makes for both a consistent user experience and consistent code. It simplifies the forms and validation code, however, it does change the node API slightly:
* The _validate hook and the _nodeapi('validate') hook of the node API (1) no longer take an 'error' parameter and (2) should no longer return an error array. To set an error, call form_set_error().
* The _form hook of the node module no longer takes a form hook and should not worry about displaying errors. Ditto for _nodeapi('form_post') and _nodeapi('form_pre').
Diffstat (limited to 'modules/blogapi/blogapi.module')
-rw-r--r-- | modules/blogapi/blogapi.module | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module index 131d82979..44646e377 100644 --- a/modules/blogapi/blogapi.module +++ b/modules/blogapi/blogapi.module @@ -131,10 +131,10 @@ function blogapi_new_post($req_params) { 'comment' => $comment, 'moderate' => $moderate, 'revision' => $revision - ), $error); + )); - if (count($error) > 0) { - return blogapi_error($error); + if (form_get_errors()) { + return blogapi_error(); } if (!node_access('create', $node)) { @@ -191,10 +191,10 @@ function blogapi_edit_post($req_params) { $node->title = $title; $node->body = $body; $node->status = $params[4]; - $node = node_validate($node, $error); + $node = node_validate($node); - if (count($error) > 0) { - return blogapi_error($error); + if (form_get_errors()) { + return blogapi_error(); } $terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid'); @@ -402,10 +402,16 @@ function blogapi_convert($params) { function blogapi_error($message) { global $xmlrpcusererr; - if (is_array($message)) { - $message = implode('', $message); + if (!is_array($message)) { + $message = array($message); } + if ($errors = form_get_errors()) { + $message = $message + $errors; + } + + $message = implode(' ', $message); + return new xmlrpcresp(0, $xmlrpcusererr + 1, strip_tags($message)); } |