diff options
31 files changed, 168 insertions, 176 deletions
diff --git a/includes/common.inc b/includes/common.inc index bd6b2b15e..142ed37d2 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -961,9 +961,9 @@ function form_set_error($name, $message) { } /** - * Return true when errors have been set. + * Return an associative array of all errors. */ -function form_has_errors() { +function form_get_errors() { if (array_key_exists('form', $GLOBALS)) { return $GLOBALS['form']; } diff --git a/modules/blog.module b/modules/blog.module index 39dfe52b3..23a73071c 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -181,16 +181,14 @@ function blog_page_last() { */ function blog_validate(&$node) { if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_blog_size', 0)) { - $error['body'] = theme('error', t('The body of your blog is too short.')); + form_set_error('body', t('The body of your blog is too short.')); } - - return $error; } /** * Implementation of hook_form(). */ -function blog_form(&$node, &$error) { +function blog_form(&$node) { global $nid; $iid = $_GET['iid']; @@ -214,7 +212,7 @@ function blog_form(&$node, &$error) { $output .= implode('', taxonomy_node_form('blog', $node)); } - $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, $error['body'] ? $error['body'] : filter_tips_short()); + $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, filter_tips_short()); return $output; } diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 39dfe52b3..23a73071c 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -181,16 +181,14 @@ function blog_page_last() { */ function blog_validate(&$node) { if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_blog_size', 0)) { - $error['body'] = theme('error', t('The body of your blog is too short.')); + form_set_error('body', t('The body of your blog is too short.')); } - - return $error; } /** * Implementation of hook_form(). */ -function blog_form(&$node, &$error) { +function blog_form(&$node) { global $nid; $iid = $_GET['iid']; @@ -214,7 +212,7 @@ function blog_form(&$node, &$error) { $output .= implode('', taxonomy_node_form('blog', $node)); } - $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, $error['body'] ? $error['body'] : filter_tips_short()); + $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, filter_tips_short()); return $output; } diff --git a/modules/blogapi.module b/modules/blogapi.module index 131d82979..44646e377 100644 --- a/modules/blogapi.module +++ b/modules/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)); } 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)); } diff --git a/modules/book.module b/modules/book.module index 979a614bf..d5802fb33 100644 --- a/modules/book.module +++ b/modules/book.module @@ -228,7 +228,7 @@ function book_validate(&$node) { /** * Implementation of hook_form(). */ -function book_form(&$node, &$error) { +function book_form(&$node) { global $user; $op = $_POST['op']; diff --git a/modules/book/book.module b/modules/book/book.module index 979a614bf..d5802fb33 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -228,7 +228,7 @@ function book_validate(&$node) { /** * Implementation of hook_form(). */ -function book_form(&$node, &$error) { +function book_form(&$node) { global $user; $op = $_POST['op']; diff --git a/modules/comment.module b/modules/comment.module index 0c56e9929..cf7771212 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -316,7 +316,7 @@ function comment_post($edit) { $edit['subject'] = truncate_utf8(strip_tags($edit['comment']), 29); } - if (!form_has_errors()) { + if (!form_get_errors()) { // Check for duplicate comments. Note that we have to use the // validated/filtered data to perform such check. @@ -1255,7 +1255,7 @@ function theme_comment_form($edit, $title) { $form .= form_submit(t('Preview comment')); } - if (!form_has_errors()) { + if (!form_get_errors()) { $form .= form_submit(t('Post comment')); } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 0c56e9929..cf7771212 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -316,7 +316,7 @@ function comment_post($edit) { $edit['subject'] = truncate_utf8(strip_tags($edit['comment']), 29); } - if (!form_has_errors()) { + if (!form_get_errors()) { // Check for duplicate comments. Note that we have to use the // validated/filtered data to perform such check. @@ -1255,7 +1255,7 @@ function theme_comment_form($edit, $title) { $form .= form_submit(t('Preview comment')); } - if (!form_has_errors()) { + if (!form_get_errors()) { $form .= form_submit(t('Post comment')); } diff --git a/modules/drupal.module b/modules/drupal.module index 9291f79ef..381192a86 100644 --- a/modules/drupal.module +++ b/modules/drupal.module @@ -29,16 +29,16 @@ function drupal_help($section) { function drupal_settings() { // Check if all required fields are present for the Drupal directory if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == '')) - $error['drupal_directory'] = theme('error', t("You must set your site's name on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's name on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); else if (variable_get('site_mail', ini_get('sendmail_from')) == '') - $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's e-mail address on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); else if (variable_get('site_slogan', '') == '') - $error['drupal_directory'] = theme('error', t("You must set your site's slogan on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's slogan on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); else if (variable_get('site_mission', '') == '') - $error['drupal_directory'] = theme('error', t("You must set your site's mission on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's mission on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); $output = form_textfield(t('Drupal XML-RPC server'), 'drupal_server', variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), 55, 128, t('The URL of your root Drupal XML-RPC server.')); - $output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/sites/")) . $error['drupal_directory']); + $output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/sites/"))); return $output; } diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module index 9291f79ef..381192a86 100644 --- a/modules/drupal/drupal.module +++ b/modules/drupal/drupal.module @@ -29,16 +29,16 @@ function drupal_help($section) { function drupal_settings() { // Check if all required fields are present for the Drupal directory if ((variable_get('site_name', 'drupal') == 'drupal') || (variable_get('site_name', 'drupal') == '')) - $error['drupal_directory'] = theme('error', t("You must set your site's name on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's name on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); else if (variable_get('site_mail', ini_get('sendmail_from')) == '') - $error['drupal_directory'] = theme('error', t("You must set your site's e-mail address on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's e-mail address on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); else if (variable_get('site_slogan', '') == '') - $error['drupal_directory'] = theme('error', t("You must set your site's slogan on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's slogan on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); else if (variable_get('site_mission', '') == '') - $error['drupal_directory'] = theme('error', t("You must set your site's mission on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); + form_set_error('drupal_directory', t("You must set your site's mission on the <a href=\"%url\">administer » settings</a> page.", array('%url' => url('admin/settings')))); $output = form_textfield(t('Drupal XML-RPC server'), 'drupal_server', variable_get('drupal_server', 'http://www.drupal.org/xmlrpc.php'), 55, 128, t('The URL of your root Drupal XML-RPC server.')); - $output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/sites/")) . $error['drupal_directory']); + $output .= form_radios(t('Drupal directory'), 'drupal_directory', variable_get('drupal_directory', 0), array(t('Disabled'), t('Enabled')), t("If enabled, your Drupal site will make itself known to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you must set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"%drupal-xml-rpc\", your web site will get listed on the <a href=\"%drupal-sites\">Drupal sites</a> page. Requires the cron feature to be enabled.", array("%drupal-xml-rpc" => "http://www.drupal.org/xmlrpc.php", "%drupal-sites" => "http://www.drupal.org/sites/"))); return $output; } diff --git a/modules/forum.module b/modules/forum.module index 3b9aa295f..dbd1944e9 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -246,7 +246,7 @@ function forum_validate(&$node) { if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) { if (in_array($term, $containers)) { $term = taxonomy_get_term($term); - $error['taxonomy'] = theme('error', t('The item \'%forum\' is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); + form_set_error('taxonomy', t('The item \'%forum\' is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); } else { $node->tid = $term; @@ -254,19 +254,18 @@ function forum_validate(&$node) { } } } - return $error; } /** * Implementation of hook_form(). */ -function forum_form(&$node, &$error) { +function forum_form(&$node) { if (!$node->nid) { // new topic $node->taxonomy[] = arg(3); } - $output = implode('', taxonomy_node_form('forum', $node, $error)); + $output = implode('', taxonomy_node_form('forum', $node)); if ($node->nid) { // if editing, give option to leave shadows diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 3b9aa295f..dbd1944e9 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -246,7 +246,7 @@ function forum_validate(&$node) { if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) { if (in_array($term, $containers)) { $term = taxonomy_get_term($term); - $error['taxonomy'] = theme('error', t('The item \'%forum\' is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); + form_set_error('taxonomy', t('The item \'%forum\' is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); } else { $node->tid = $term; @@ -254,19 +254,18 @@ function forum_validate(&$node) { } } } - return $error; } /** * Implementation of hook_form(). */ -function forum_form(&$node, &$error) { +function forum_form(&$node) { if (!$node->nid) { // new topic $node->taxonomy[] = arg(3); } - $output = implode('', taxonomy_node_form('forum', $node, $error)); + $output = implode('', taxonomy_node_form('forum', $node)); if ($node->nid) { // if editing, give option to leave shadows diff --git a/modules/node.module b/modules/node.module index 1570b2953..06925d433 100644 --- a/modules/node.module +++ b/modules/node.module @@ -1035,9 +1035,8 @@ function node_feed($nodes = 0, $channel = array()) { /** * Preform validation checks on the given node. */ -function node_validate($node, &$error) { +function node_validate($node) { global $user; - $error = array(); // Convert the node to an object, if necessary. $node = array2object($node); @@ -1046,7 +1045,7 @@ function node_validate($node, &$error) { if (isset($node->title)) { $node->title = strip_tags($node->title); if (!$node->title) { - $error['title'] = theme('error', t('You have to specify a valid title.')); + form_set_error('title', t('You have to specify a valid title.')); } } @@ -1081,7 +1080,7 @@ function node_validate($node, &$error) { $node->uid = $account->uid; } else { - $error['name'] = theme('error', t("The name '%u' does not exist.", array ('%u' => $node->name))); + form_set_error('name', t("The name '%u' does not exist.", array ('%u' => $node->name))); } // Validate the "authored on" field. @@ -1089,7 +1088,7 @@ function node_validate($node, &$error) { $node->created = strtotime($node->date); } else { - $error['date'] = theme('error', t('You have to specifiy a valid date.')); + form_set_error('date', t('You have to specifiy a valid date.')); } } else { @@ -1105,8 +1104,10 @@ function node_validate($node, &$error) { } // Do node-type-specific validation checks. - $result = node_invoke($node, 'validate'); - $error = $error + (is_array($result) ? $result : array()) + node_invoke_nodeapi($node, 'validate'); + node_invoke($node, 'validate'); + node_invoke_nodeapi($node, 'validate'); + + $node->validated = true; return $node; } @@ -1114,24 +1115,24 @@ function node_validate($node, &$error) { /** * Generate the node editing form. */ -function node_form($edit, $error = NULL) { +function node_form($edit) { // Validate the node if we don't already know the errors. - if ($error === NULL) { - $edit = node_validate($edit, $error); + if (!$edit->validated) { + $edit = node_validate($edit); } // Prepend extra node form elements. - $form = implode('', node_invoke_nodeapi($edit, 'form pre', $error)); + $form = implode('', node_invoke_nodeapi($edit, 'form pre')); // Get the node-specific bits. - // We can't use node_invoke() because $error and $param must be passed by reference. + // We can't use node_invoke() because $param must be passed by reference. $function = node_get_module_name($edit) .'_form'; if (function_exists($function)) { - $form .= $function($edit, $error, $param); + $form .= $function($edit, $param); } // Append extra node form elements. - $form .= implode('', node_invoke_nodeapi($edit, 'form post', $error)); + $form .= implode('', node_invoke_nodeapi($edit, 'form post')); $output .= '<div class="node-form">'; @@ -1140,8 +1141,8 @@ function node_form($edit, $error = NULL) { if (user_access('administer nodes')) { $output .= '<div class="admin">'; - $author = form_textfield(t('Authored by'), 'name', $edit->name, 20, 60, $error['name']); - $author .= form_textfield(t('Authored on'), 'date', $edit->date, 20, 25, $error['date']); + $author = form_textfield(t('Authored by'), 'name', $edit->name, 20, 60); + $author .= form_textfield(t('Authored on'), 'date', $edit->date, 20, 25); $output .= '<div class="authored">'; $output .= form_group(t('Authoring information'), $author); @@ -1157,14 +1158,14 @@ function node_form($edit, $error = NULL) { $output .= form_group(t('Options'), $options); $output .= "</div>\n"; - $extras .= implode('</div><div class="extra">', node_invoke_nodeapi($edit, 'form admin', $error)); + $extras .= implode('</div><div class="extra">', node_invoke_nodeapi($edit, 'form admin')); $output .= $extras ? '<div class="extra">'. $extras .'</div></div>' : '</div>'; } // Add the default fields. $output .= '<div class="standard">'; - $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, $error['title']); + $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128); // Add the node-type-specific fields. @@ -1192,7 +1193,7 @@ function node_form($edit, $error = NULL) { $output .= form_submit(t('Preview')); - if (!$error) { + if (!form_get_errors()) { if ($edit->title && $edit->type) { $output .= form_submit(t('Submit')); } @@ -1283,7 +1284,7 @@ function node_edit($id) { /** * Generate a node preview, including a form for further edits. */ -function node_preview($node, $error = NULL) { +function node_preview($node) { // Convert the array to an object: $node = array2object($node); @@ -1325,7 +1326,7 @@ function node_preview($node, $error = NULL) { $output .= node_view($node, 0); } - $output .= node_form($node, $error); + $output .= node_form($node); $name = node_invoke($node, 'node_name'); drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('create content'), 'node/add'), l(t('Submit %name', array('%name' => $name)), 'node/add/'. $node->type))); @@ -1341,11 +1342,11 @@ function node_submit($node) { global $user; // Fix up the node when required: - $node = node_validate($node, $error); + $node = node_validate($node); // If something went wrong, go back to the preview form. - if ($error) { - return node_preview($node, $error); + if (form_get_errors()) { + return node_preview($node); } // Prepare the node's body: @@ -1484,8 +1485,8 @@ function node_page() { } break; case t('Preview'): - $edit = node_validate($edit, $error); - print theme('page', node_preview($edit, $error), t('Preview %name', array('%name' => $name))); + $edit = node_validate($edit); + print theme('page', node_preview($edit), t('Preview %name', array('%name' => $name))); break; case t('Submit'): drupal_set_title(t('Submit %name', array('%name' => $name))); diff --git a/modules/node/node.module b/modules/node/node.module index 1570b2953..06925d433 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1035,9 +1035,8 @@ function node_feed($nodes = 0, $channel = array()) { /** * Preform validation checks on the given node. */ -function node_validate($node, &$error) { +function node_validate($node) { global $user; - $error = array(); // Convert the node to an object, if necessary. $node = array2object($node); @@ -1046,7 +1045,7 @@ function node_validate($node, &$error) { if (isset($node->title)) { $node->title = strip_tags($node->title); if (!$node->title) { - $error['title'] = theme('error', t('You have to specify a valid title.')); + form_set_error('title', t('You have to specify a valid title.')); } } @@ -1081,7 +1080,7 @@ function node_validate($node, &$error) { $node->uid = $account->uid; } else { - $error['name'] = theme('error', t("The name '%u' does not exist.", array ('%u' => $node->name))); + form_set_error('name', t("The name '%u' does not exist.", array ('%u' => $node->name))); } // Validate the "authored on" field. @@ -1089,7 +1088,7 @@ function node_validate($node, &$error) { $node->created = strtotime($node->date); } else { - $error['date'] = theme('error', t('You have to specifiy a valid date.')); + form_set_error('date', t('You have to specifiy a valid date.')); } } else { @@ -1105,8 +1104,10 @@ function node_validate($node, &$error) { } // Do node-type-specific validation checks. - $result = node_invoke($node, 'validate'); - $error = $error + (is_array($result) ? $result : array()) + node_invoke_nodeapi($node, 'validate'); + node_invoke($node, 'validate'); + node_invoke_nodeapi($node, 'validate'); + + $node->validated = true; return $node; } @@ -1114,24 +1115,24 @@ function node_validate($node, &$error) { /** * Generate the node editing form. */ -function node_form($edit, $error = NULL) { +function node_form($edit) { // Validate the node if we don't already know the errors. - if ($error === NULL) { - $edit = node_validate($edit, $error); + if (!$edit->validated) { + $edit = node_validate($edit); } // Prepend extra node form elements. - $form = implode('', node_invoke_nodeapi($edit, 'form pre', $error)); + $form = implode('', node_invoke_nodeapi($edit, 'form pre')); // Get the node-specific bits. - // We can't use node_invoke() because $error and $param must be passed by reference. + // We can't use node_invoke() because $param must be passed by reference. $function = node_get_module_name($edit) .'_form'; if (function_exists($function)) { - $form .= $function($edit, $error, $param); + $form .= $function($edit, $param); } // Append extra node form elements. - $form .= implode('', node_invoke_nodeapi($edit, 'form post', $error)); + $form .= implode('', node_invoke_nodeapi($edit, 'form post')); $output .= '<div class="node-form">'; @@ -1140,8 +1141,8 @@ function node_form($edit, $error = NULL) { if (user_access('administer nodes')) { $output .= '<div class="admin">'; - $author = form_textfield(t('Authored by'), 'name', $edit->name, 20, 60, $error['name']); - $author .= form_textfield(t('Authored on'), 'date', $edit->date, 20, 25, $error['date']); + $author = form_textfield(t('Authored by'), 'name', $edit->name, 20, 60); + $author .= form_textfield(t('Authored on'), 'date', $edit->date, 20, 25); $output .= '<div class="authored">'; $output .= form_group(t('Authoring information'), $author); @@ -1157,14 +1158,14 @@ function node_form($edit, $error = NULL) { $output .= form_group(t('Options'), $options); $output .= "</div>\n"; - $extras .= implode('</div><div class="extra">', node_invoke_nodeapi($edit, 'form admin', $error)); + $extras .= implode('</div><div class="extra">', node_invoke_nodeapi($edit, 'form admin')); $output .= $extras ? '<div class="extra">'. $extras .'</div></div>' : '</div>'; } // Add the default fields. $output .= '<div class="standard">'; - $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, $error['title']); + $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128); // Add the node-type-specific fields. @@ -1192,7 +1193,7 @@ function node_form($edit, $error = NULL) { $output .= form_submit(t('Preview')); - if (!$error) { + if (!form_get_errors()) { if ($edit->title && $edit->type) { $output .= form_submit(t('Submit')); } @@ -1283,7 +1284,7 @@ function node_edit($id) { /** * Generate a node preview, including a form for further edits. */ -function node_preview($node, $error = NULL) { +function node_preview($node) { // Convert the array to an object: $node = array2object($node); @@ -1325,7 +1326,7 @@ function node_preview($node, $error = NULL) { $output .= node_view($node, 0); } - $output .= node_form($node, $error); + $output .= node_form($node); $name = node_invoke($node, 'node_name'); drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('create content'), 'node/add'), l(t('Submit %name', array('%name' => $name)), 'node/add/'. $node->type))); @@ -1341,11 +1342,11 @@ function node_submit($node) { global $user; // Fix up the node when required: - $node = node_validate($node, $error); + $node = node_validate($node); // If something went wrong, go back to the preview form. - if ($error) { - return node_preview($node, $error); + if (form_get_errors()) { + return node_preview($node); } // Prepare the node's body: @@ -1484,8 +1485,8 @@ function node_page() { } break; case t('Preview'): - $edit = node_validate($edit, $error); - print theme('page', node_preview($edit, $error), t('Preview %name', array('%name' => $name))); + $edit = node_validate($edit); + print theme('page', node_preview($edit), t('Preview %name', array('%name' => $name))); break; case t('Submit'): drupal_set_title(t('Submit %name', array('%name' => $name))); diff --git a/modules/page.module b/modules/page.module index 930ef20ab..bdbfa0be3 100644 --- a/modules/page.module +++ b/modules/page.module @@ -129,7 +129,7 @@ function page_view($node, $teaser = FALSE, $page = FALSE) { /** * Implementation of hook_form(). */ -function page_form(&$node, &$error) { +function page_form(&$node) { if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('page', $node)); } diff --git a/modules/page/page.module b/modules/page/page.module index 930ef20ab..bdbfa0be3 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -129,7 +129,7 @@ function page_view($node, $teaser = FALSE, $page = FALSE) { /** * Implementation of hook_form(). */ -function page_form(&$node, &$error) { +function page_form(&$node) { if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('page', $node)); } diff --git a/modules/path.module b/modules/path.module index 7be86e843..38824dba4 100644 --- a/modules/path.module +++ b/modules/path.module @@ -196,12 +196,10 @@ function path_nodeapi(&$node, $op, $arg) { else { $node->path = trim($node->path); if ($node->path && !valid_url($node->path)) { - $error['path'] = t('The path is invalid.'); - return $error; + form_set_error('path', t('The path is invalid.')); } else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) { - $error['path'] = t('The path is already in use.'); - return $error; + form_set_error('path', t('The path is already in use.')); } } break; @@ -304,8 +302,8 @@ function path_save($edit) { form_set_error('dst', t('the alias "%dst" is already in use.', array('%dst' => $dst))); } - if (form_has_errors()) { - return path_form($edit, $error); + if (form_get_errors()) { + return path_form($edit); } else { // Normally, you would use path_set_alias() to update the paths table, diff --git a/modules/path/path.module b/modules/path/path.module index 7be86e843..38824dba4 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -196,12 +196,10 @@ function path_nodeapi(&$node, $op, $arg) { else { $node->path = trim($node->path); if ($node->path && !valid_url($node->path)) { - $error['path'] = t('The path is invalid.'); - return $error; + form_set_error('path', t('The path is invalid.')); } else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) { - $error['path'] = t('The path is already in use.'); - return $error; + form_set_error('path', t('The path is already in use.')); } } break; @@ -304,8 +302,8 @@ function path_save($edit) { form_set_error('dst', t('the alias "%dst" is already in use.', array('%dst' => $dst))); } - if (form_has_errors()) { - return path_form($edit, $error); + if (form_get_errors()) { + return path_form($edit); } else { // Normally, you would use path_set_alias() to update the paths table, diff --git a/modules/poll.module b/modules/poll.module index b405e245f..78b597d79 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -98,24 +98,22 @@ function poll_validate(&$node) { } if ($choice['chvotes'] < 0) { - $error["choice][$i][chvotes"] = theme('error', t("Negative values are not allowed.")); + form_set_error("choice][$i][chvotes", t("Negative values are not allowed.")); } } if ($realchoices < 2) { - $error["choice][0][chtext"] = theme('error', t("You must fill in at least two choices.")); + form_set_error("choice][$realchoices][chtext", t("You must fill in at least two choices.")); } } $node->teaser = poll_teaser($node); - - return $error; } /** * Implementation of hook_form(). */ -function poll_form(&$node, &$error) { +function poll_form(&$node) { $admin = user_access('administer nodes'); if (function_exists('taxonomy_node_form')) { @@ -136,9 +134,9 @@ function poll_form(&$node, &$error) { // Poll choices $opts = drupal_map_assoc(range(2, $node->choices * 2 + 5)); for ($a = 0; $a < $node->choices; $a++) { - $group1 .= form_textfield(t('Choice %n', array('%n' => ($a + 1))), "choice][$a][chtext", $node->choice[$a]['chtext'], 50, 127, $error["choice][$a][chtext"]); + $group1 .= form_textfield(t('Choice %n', array('%n' => ($a + 1))), "choice][$a][chtext", $node->choice[$a]['chtext'], 50, 127); if ($admin) { - $group1 .= form_textfield(t('Votes for choice %n', array('%n' => ($a + 1))), "choice][$a][chvotes", (int)$node->choice[$a]['chvotes'], 7, 7, $error["choice][$a][chvotes"]); + $group1 .= form_textfield(t('Votes for choice %n', array('%n' => ($a + 1))), "choice][$a][chvotes", (int)$node->choice[$a]['chvotes'], 7, 7); } } $group1 .= form_hidden('choices', $node->choices); diff --git a/modules/poll/poll.module b/modules/poll/poll.module index b405e245f..78b597d79 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -98,24 +98,22 @@ function poll_validate(&$node) { } if ($choice['chvotes'] < 0) { - $error["choice][$i][chvotes"] = theme('error', t("Negative values are not allowed.")); + form_set_error("choice][$i][chvotes", t("Negative values are not allowed.")); } } if ($realchoices < 2) { - $error["choice][0][chtext"] = theme('error', t("You must fill in at least two choices.")); + form_set_error("choice][$realchoices][chtext", t("You must fill in at least two choices.")); } } $node->teaser = poll_teaser($node); - - return $error; } /** * Implementation of hook_form(). */ -function poll_form(&$node, &$error) { +function poll_form(&$node) { $admin = user_access('administer nodes'); if (function_exists('taxonomy_node_form')) { @@ -136,9 +134,9 @@ function poll_form(&$node, &$error) { // Poll choices $opts = drupal_map_assoc(range(2, $node->choices * 2 + 5)); for ($a = 0; $a < $node->choices; $a++) { - $group1 .= form_textfield(t('Choice %n', array('%n' => ($a + 1))), "choice][$a][chtext", $node->choice[$a]['chtext'], 50, 127, $error["choice][$a][chtext"]); + $group1 .= form_textfield(t('Choice %n', array('%n' => ($a + 1))), "choice][$a][chtext", $node->choice[$a]['chtext'], 50, 127); if ($admin) { - $group1 .= form_textfield(t('Votes for choice %n', array('%n' => ($a + 1))), "choice][$a][chvotes", (int)$node->choice[$a]['chvotes'], 7, 7, $error["choice][$a][chvotes"]); + $group1 .= form_textfield(t('Votes for choice %n', array('%n' => ($a + 1))), "choice][$a][chvotes", (int)$node->choice[$a]['chvotes'], 7, 7); } } $group1 .= form_hidden('choices', $node->choices); diff --git a/modules/profile.module b/modules/profile.module index ac7bba039..4b961c767 100644 --- a/modules/profile.module +++ b/modules/profile.module @@ -315,7 +315,7 @@ function profile_admin_add($type) { form_set_error('name', t('the specified name is already in use.')); } - if (!form_has_errors()) { + if (!form_get_errors()) { db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, visibility, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s')", $data['title'], $data['name'], $data['explanation'], $data['category'], $type, $data['weight'], $data['required'], $data['visibility'], $data['options'], $data['page']); drupal_set_message(t('the field has been created.')); @@ -340,7 +340,7 @@ function profile_admin_edit($fid) { // Validate form: profile_validate_form($data); - if (!form_has_errors()) { + if (!form_get_errors()) { db_query("UPDATE {profile_fields} SET title = '%s', name = '%s', explanation = '%s', category = '%s', weight = %d, required = %d, visibility = %d, options = '%s', page = '%s' WHERE fid = %d", $data['title'], $data['name'], $data['explanation'], $data['category'], $data['weight'], $data['required'], $data['visibility'], $data['options'], $data['page'], $fid); drupal_set_message(t('the field has been updated.')); diff --git a/modules/profile/profile.module b/modules/profile/profile.module index ac7bba039..4b961c767 100644 --- a/modules/profile/profile.module +++ b/modules/profile/profile.module @@ -315,7 +315,7 @@ function profile_admin_add($type) { form_set_error('name', t('the specified name is already in use.')); } - if (!form_has_errors()) { + if (!form_get_errors()) { db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, visibility, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s')", $data['title'], $data['name'], $data['explanation'], $data['category'], $type, $data['weight'], $data['required'], $data['visibility'], $data['options'], $data['page']); drupal_set_message(t('the field has been created.')); @@ -340,7 +340,7 @@ function profile_admin_edit($fid) { // Validate form: profile_validate_form($data); - if (!form_has_errors()) { + if (!form_get_errors()) { db_query("UPDATE {profile_fields} SET title = '%s', name = '%s', explanation = '%s', category = '%s', weight = %d, required = %d, visibility = %d, options = '%s', page = '%s' WHERE fid = %d", $data['title'], $data['name'], $data['explanation'], $data['category'], $data['weight'], $data['required'], $data['visibility'], $data['options'], $data['page'], $fid); drupal_set_message(t('the field has been updated.')); diff --git a/modules/story.module b/modules/story.module index d4bae4ddc..ffc10f0e0 100644 --- a/modules/story.module +++ b/modules/story.module @@ -105,23 +105,21 @@ function story_menu() { */ function story_validate(&$node) { if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_story_size', 0)) { - $error['body'] = t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0))); + form_set_error('body', t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0)))); } - - return $error; } /** * Implementation of hook_form(). */ -function story_form(&$node, &$error) { +function story_form(&$node) { $output = ''; if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('story', $node)); } - $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, ($error['body'] ? theme('error', $error['body']) : ''). filter_tips_short()); + $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, filter_tips_short()); return $output; } diff --git a/modules/story/story.module b/modules/story/story.module index d4bae4ddc..ffc10f0e0 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -105,23 +105,21 @@ function story_menu() { */ function story_validate(&$node) { if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_story_size', 0)) { - $error['body'] = t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0))); + form_set_error('body', t('The body of your story is too short. You need at least %word_count words to submit your story.', array('%word_count' => variable_get('minimum_story_size', 0)))); } - - return $error; } /** * Implementation of hook_form(). */ -function story_form(&$node, &$error) { +function story_form(&$node) { $output = ''; if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('story', $node)); } - $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, ($error['body'] ? theme('error', $error['body']) : ''). filter_tips_short()); + $output .= form_textarea(t('Body'), 'body', $node->body, 60, 15, filter_tips_short()); return $output; } diff --git a/modules/system.module b/modules/system.module index 5fccde31e..eb0607dc2 100644 --- a/modules/system.module +++ b/modules/system.module @@ -146,13 +146,13 @@ function system_view_general() { // file system: if (!file_check_directory(variable_get('file_directory_path', 'files'))) { - $error['file_directory_path'] = theme('error', t('Directory does not exist, or is not writable.')); + form_set_error('file_directory_path', t('Directory does not exist, or is not writable.')); } if (!file_check_directory(variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')))) { - $error['file_directory_temp'] = theme('error', t('Directory does not exist, or is not writable.')); + form_set_error('file_directory_temp', t('Directory does not exist, or is not writable.')); } - $group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.') . $error['file_directory_path']); - $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.') . $error['file_directory_temp']); + $group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.')); + $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.')); $group .= form_radios(t('Download method'), 'file_downloads', variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC), array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using http directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are be transferred by Drupal.')), t('This setting can be changed at any time, however, all download URLs will change and there may be unexpected problems so it is not recommended.')); $output .= form_group(t('File system'), $group); diff --git a/modules/system/system.module b/modules/system/system.module index 5fccde31e..eb0607dc2 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -146,13 +146,13 @@ function system_view_general() { // file system: if (!file_check_directory(variable_get('file_directory_path', 'files'))) { - $error['file_directory_path'] = theme('error', t('Directory does not exist, or is not writable.')); + form_set_error('file_directory_path', t('Directory does not exist, or is not writable.')); } if (!file_check_directory(variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')))) { - $error['file_directory_temp'] = theme('error', t('Directory does not exist, or is not writable.')); + form_set_error('file_directory_temp', t('Directory does not exist, or is not writable.')); } - $group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.') . $error['file_directory_path']); - $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.') . $error['file_directory_temp']); + $group = form_textfield(t('File system path'), 'file_directory_path', variable_get('file_directory_path', 'files'), 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.')); + $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', variable_get('file_directory_temp', (PHP_OS == 'WINNT' ? 'c:\\windows\\temp' : '/tmp')), 70, 255, t('Location where files can be saved temporarily. This directory should not be accessible from the web.')); $group .= form_radios(t('Download method'), 'file_downloads', variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC), array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using http directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are be transferred by Drupal.')), t('This setting can be changed at any time, however, all download URLs will change and there may be unexpected problems so it is not recommended.')); $output .= form_group(t('File system'), $group); diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 8bd8ba1f1..1f18319d0 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -311,7 +311,7 @@ function taxonomy_overview() { /** * Generate a form element for selecting terms from a vocabulary. */ -function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL, $name = 'taxonomy') { +function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') { $vocabulary = taxonomy_get_vocabulary($vid); $help = ($help) ? $help : $vocabulary->help; if ($vocabulary->required) { @@ -321,8 +321,6 @@ function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL, $name = $blank = '<'. t('none') .'>'; } - $help .= $error['taxonomy']; - return _taxonomy_term_select($vocabulary->name, $name, $value, $vid, $help, intval($vocabulary->multiple), $blank); } @@ -350,7 +348,7 @@ function taxonomy_get_vocabularies($type = '', $key = 'vid') { /** * Generate a form for selecting terms to associate with a node. */ -function taxonomy_node_form($type, $node = '', $error = array(), $help = NULL, $name = 'taxonomy') { +function taxonomy_node_form($type, $node = '', $help = NULL, $name = 'taxonomy') { if (!$node->taxonomy) { if ($node->nid) { $terms = array_keys(taxonomy_node_get_terms($node->nid)); @@ -365,7 +363,7 @@ function taxonomy_node_form($type, $node = '', $error = array(), $help = NULL, $ $c = db_query("SELECT * FROM {vocabulary} WHERE nodes LIKE '%%%s%%' ORDER BY weight, name", $type); while ($vocabulary = db_fetch_object($c)) { - $result[] = taxonomy_form($vocabulary->vid, $terms, $error, $help, $name); + $result[] = taxonomy_form($vocabulary->vid, $terms, $help, $name); } return $result ? $result : array(); } @@ -695,7 +693,7 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti $size = min(12, count($options)); - return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : '') . ($extra ? " $extra" : '') .">$select</select>", $description); + return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : '') . ($extra ? " $extra" : '') .' class="'. _form_get_class('', false, _form_get_error($name)) ."\">$select</select>", $description, NULL, false, _form_get_error($name)); } } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 8bd8ba1f1..1f18319d0 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -311,7 +311,7 @@ function taxonomy_overview() { /** * Generate a form element for selecting terms from a vocabulary. */ -function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL, $name = 'taxonomy') { +function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') { $vocabulary = taxonomy_get_vocabulary($vid); $help = ($help) ? $help : $vocabulary->help; if ($vocabulary->required) { @@ -321,8 +321,6 @@ function taxonomy_form($vid, $value = 0, $error = array(), $help = NULL, $name = $blank = '<'. t('none') .'>'; } - $help .= $error['taxonomy']; - return _taxonomy_term_select($vocabulary->name, $name, $value, $vid, $help, intval($vocabulary->multiple), $blank); } @@ -350,7 +348,7 @@ function taxonomy_get_vocabularies($type = '', $key = 'vid') { /** * Generate a form for selecting terms to associate with a node. */ -function taxonomy_node_form($type, $node = '', $error = array(), $help = NULL, $name = 'taxonomy') { +function taxonomy_node_form($type, $node = '', $help = NULL, $name = 'taxonomy') { if (!$node->taxonomy) { if ($node->nid) { $terms = array_keys(taxonomy_node_get_terms($node->nid)); @@ -365,7 +363,7 @@ function taxonomy_node_form($type, $node = '', $error = array(), $help = NULL, $ $c = db_query("SELECT * FROM {vocabulary} WHERE nodes LIKE '%%%s%%' ORDER BY weight, name", $type); while ($vocabulary = db_fetch_object($c)) { - $result[] = taxonomy_form($vocabulary->vid, $terms, $error, $help, $name); + $result[] = taxonomy_form($vocabulary->vid, $terms, $help, $name); } return $result ? $result : array(); } @@ -695,7 +693,7 @@ function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $descripti $size = min(12, count($options)); - return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : '') . ($extra ? " $extra" : '') .">$select</select>", $description); + return form_item($title, "<select name=\"edit[$name][]\"". ($multiple ? " multiple=\"multiple\" size=\"$size\"" : '') . ($extra ? " $extra" : '') .' class="'. _form_get_class('', false, _form_get_error($name)) ."\">$select</select>", $description, NULL, false, _form_get_error($name)); } } diff --git a/modules/user.module b/modules/user.module index 77f3cc3e9..f6bb5d443 100644 --- a/modules/user.module +++ b/modules/user.module @@ -940,7 +940,7 @@ function user_register($edit = array()) { if ($edit) { user_module_invoke('validate', $edit, $edit, 'account'); - if (!form_has_errors()) { + if (!form_get_errors()) { $from = variable_get('site_mail', ini_get('sendmail_from')); $pass = user_password(); @@ -1078,7 +1078,7 @@ function user_edit($category = 'account') { if ($_POST['op'] == t('Save account')) { user_module_invoke('validate', $edit, $account, $category); - if (!form_has_errors()) { + if (!form_get_errors()) { // Validate input to ensure that non-privileged users can't alter protected data. if (!user_access('administer users') && array_intersect(array_keys($edit), array('uid', 'roles', 'init', 'session'))) { watchdog('warning', 'detected malicious attempt to alter a protected database field'); @@ -1242,11 +1242,11 @@ function user_configure_settings() { // Picture settings. if (!file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')))) { - $error = theme('error', t('The picture directory does not exist, or is not writable.')); + form_set_error('user_picture_path', t('The picture directory does not exist, or is not writable.')); } $group = form_radios(t('Picture support'), 'user_pictures', variable_get('user_pictures', 0), array(t('Disabled'), t('Enabled')), t('Enable picture support.')); - $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error); + $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR))); $group .= form_textfield(t('Default picture'), 'user_picture_default', variable_get('user_picture_default', ''), 45, 255, t('URL of picture to display for users with no custom picture selected. Leave blank for none.')); $group .= form_textfield(t('Picture maximum dimensions'), 'user_picture_dimensions', variable_get('user_picture_dimensions', '85x85'), 10, 10, t('Maximum dimensions for pictures.')); $group .= form_textfield(t('Picture maximum file size'), 'user_picture_file_size', variable_get('user_picture_file_size', '30'), 10, 10, t('Maximum file size for pictures, in kB.')); @@ -1268,7 +1268,7 @@ function user_admin_create($edit = array()) { if ($edit) { user_module_invoke('validate', $edit, $edit, 'account'); - if (!form_has_errors()) { + if (!form_get_errors()) { watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>'); user_save('', array('name' => $edit['name'], 'pass' => $edit['pass'], 'init' => $edit['mail'], 'mail' => $edit['mail'], 'roles' => array(_user_authenticated_id()), 'status' => 1)); diff --git a/modules/user/user.module b/modules/user/user.module index 77f3cc3e9..f6bb5d443 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -940,7 +940,7 @@ function user_register($edit = array()) { if ($edit) { user_module_invoke('validate', $edit, $edit, 'account'); - if (!form_has_errors()) { + if (!form_get_errors()) { $from = variable_get('site_mail', ini_get('sendmail_from')); $pass = user_password(); @@ -1078,7 +1078,7 @@ function user_edit($category = 'account') { if ($_POST['op'] == t('Save account')) { user_module_invoke('validate', $edit, $account, $category); - if (!form_has_errors()) { + if (!form_get_errors()) { // Validate input to ensure that non-privileged users can't alter protected data. if (!user_access('administer users') && array_intersect(array_keys($edit), array('uid', 'roles', 'init', 'session'))) { watchdog('warning', 'detected malicious attempt to alter a protected database field'); @@ -1242,11 +1242,11 @@ function user_configure_settings() { // Picture settings. if (!file_check_directory(file_create_path(variable_get('user_picture_path', 'pictures')))) { - $error = theme('error', t('The picture directory does not exist, or is not writable.')); + form_set_error('user_picture_path', t('The picture directory does not exist, or is not writable.')); } $group = form_radios(t('Picture support'), 'user_pictures', variable_get('user_pictures', 0), array(t('Disabled'), t('Enabled')), t('Enable picture support.')); - $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error); + $group .= form_textfield(t('Picture image path'), 'user_picture_path', variable_get('user_picture_path', 'pictures'), 45, 255, t('Subdirectory in the directory "%dir" where pictures will be stored.', array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR))); $group .= form_textfield(t('Default picture'), 'user_picture_default', variable_get('user_picture_default', ''), 45, 255, t('URL of picture to display for users with no custom picture selected. Leave blank for none.')); $group .= form_textfield(t('Picture maximum dimensions'), 'user_picture_dimensions', variable_get('user_picture_dimensions', '85x85'), 10, 10, t('Maximum dimensions for pictures.')); $group .= form_textfield(t('Picture maximum file size'), 'user_picture_file_size', variable_get('user_picture_file_size', '30'), 10, 10, t('Maximum file size for pictures, in kB.')); @@ -1268,7 +1268,7 @@ function user_admin_create($edit = array()) { if ($edit) { user_module_invoke('validate', $edit, $edit, 'account'); - if (!form_has_errors()) { + if (!form_get_errors()) { watchdog('user', 'new user: "'. $edit['name'] .'" <'. $edit['mail'] .'>'); user_save('', array('name' => $edit['name'], 'pass' => $edit['pass'], 'init' => $edit['mail'], 'mail' => $edit['mail'], 'roles' => array(_user_authenticated_id()), 'status' => 1)); |