From 0a3bd806c521ac803510113e212d6971aad2e483 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 16 Feb 2007 20:16:23 +0000 Subject: [PATCH] r1416: Cleaned up and refactored the MessageReporter class --- attachment.php | 29 ++++---- docs/changes.txt | 1 + editcomment.php | 15 ++-- editreport.php | 8 +-- favorite.php | 6 +- global.php | 2 +- includes/class_api_error.php | 2 +- includes/class_message_reporter.php | 105 +++++++++++----------------- includes/functions.php | 2 +- index.php | 2 +- login.php | 7 +- newreport.php | 5 +- register.php | 7 +- search.php | 17 +++-- showhistory.php | 2 +- showreport.php | 2 +- syndicate.php | 2 +- templates/editcomment.tpl | 2 +- templates/newattach.tpl | 2 +- templates/newreport.tpl | 2 +- templates/passwordreset.tpl | 2 +- templates/register.tpl | 2 +- templates/search_save.tpl | 2 +- templates/std_error.tpl | 2 +- templates/std_message.tpl | 2 +- templates/std_redirect.tpl | 6 +- templates/userctrl.tpl | 2 +- userctrl.php | 22 +++--- viewattachment.php | 4 +- vote.php | 4 +- 30 files changed, 120 insertions(+), 148 deletions(-) diff --git a/attachment.php b/attachment.php index f4d05ee..749adea 100755 --- a/attachment.php +++ b/attachment.php @@ -53,7 +53,7 @@ if (!$bug) if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } require_once('./includes/class_logging.php'); @@ -70,7 +70,7 @@ if ($_POST['do'] == 'insert') if (!can_perform('canputattach', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } // max packet size @@ -84,24 +84,24 @@ if ($_POST['do'] == 'insert') switch ($FILE['error']) { case 0: break; - case 1: $message->add_error(_('PHP said the file you uploaded was too big.')); break; - case 2: $message->add_error(_('The file exceeds the allowed upload size.')); break; - case 3: $message->add_error(_('The file was only partially uploaded.')); break; - case 4: $message->add_error(_('The file was not uploaded at all.')); break; - case 6: $message->add_error(_('PHP could not find the /tmp directory.')); break; + case 1: $message->addError(_('PHP said the file you uploaded was too big.')); break; + case 2: $message->addError(_('The file exceeds the allowed upload size.')); break; + case 3: $message->addError(_('The file was only partially uploaded.')); break; + case 4: $message->addError(_('The file was not uploaded at all.')); break; + case 6: $message->addError(_('PHP could not find the /tmp directory.')); break; } // did it upload? if (!is_uploaded_file($FILE['tmp_name'])) { - $message->add_error(_('The file you specified did not upload.')); + $message->addError(_('The file you specified did not upload.')); } // TODO - put some MIME-type validation here if (filesize($FILE['tmp_name']) > $var['Value']) { - $message->add_error(_('The file you specified exceeds MySQL\'s maximum allowed packet.')); + $message->addError(_('The file you specified exceeds MySQL\'s maximum allowed packet.')); } $attachapi->set('attachment', file_get_contents($FILE['tmp_name'])); @@ -112,7 +112,7 @@ if ($_POST['do'] == 'insert') $attachapi->set('userid', $bugsys->userinfo['userid']); // insert an attachment - if (!$message->items) + if (!$message->hasErrors()) { $attachapi->insert(); @@ -160,7 +160,6 @@ if ($_POST['do'] == 'insert') { $show['errors'] = true; $_REQUEST['do'] = 'add'; - $message->error_list_process(); } } @@ -170,7 +169,7 @@ if ($_REQUEST['do'] == 'add') { if (!can_perform('canputattach', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } $MAXFILESIZE = $funct->fetch_max_attachment_size(); @@ -195,7 +194,7 @@ if ($_POST['do'] == 'update') { if (!(can_perform('caneditattach', $bug['product']) OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach', $bug['product'])))) { - $message->error_permission(); + $message->errorPermission(); } $attachapi = new AttachmentAPI($bugsys); @@ -207,7 +206,7 @@ if ($_POST['do'] == 'update') { if (!(can_perform('caneditattach', $bug['product']) AND can_perform('candeletedata', $bug['productid']))) { - $message->error_permission(); + $message->errorPermission(); } $attachapi->delete(); @@ -242,7 +241,7 @@ if ($_REQUEST['do'] == 'edit') { if (!(can_perform('caneditattach', $bug['product']) OR ($attachment['userid'] == $bugsys->userinfo['userid'] AND can_perform('canputattach', $bug['product'])))) { - $message->error_permission(); + $message->errorPermission(); } $show['delete'] = (can_perform('caneditattach', $bug['product']) AND can_perform('candeletedata', $bug['productid'])); diff --git a/docs/changes.txt b/docs/changes.txt index cdac02c..849fe52 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -20,6 +20,7 @@ - Fixed a bug in the User API that would clear the cached usernames in bug records on a save if the display name wasn't set - Extracted email text to the template system to make it easier to modify them - Improved the admin security system by creating a session system that is much harder to bypass +- Cleaned and refactored up the MessageReporter class 1.1.5 =============================== diff --git a/editcomment.php b/editcomment.php index 7b0354f..bfebca1 100644 --- a/editcomment.php +++ b/editcomment.php @@ -44,7 +44,7 @@ $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $co if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } // ################################################################### @@ -60,7 +60,7 @@ if ($_POST['do'] == 'kill') { if (!can_perform('candeletedata', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } // get the last post (as in prior to deletion) @@ -108,7 +108,7 @@ if ($_REQUEST['do'] == 'delete') { if (!can_perform('candeletedata', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } if ($bug['initialreport'] == $comment['commentid']) @@ -125,7 +125,7 @@ if ($_POST['do'] == 'update') { if (!((can_perform('caneditownreply', $bug['product']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['product']) AND $bugsys->userinfo['userid'] != $comment['userid']))) { - $message->error_permission(); + $message->errorPermission(); } $commentapi->set('comment', $bugsys->in['comment']); @@ -134,10 +134,10 @@ if ($_POST['do'] == 'update') if ($bugsys->in['commentid'] == $bug['initialreport'] AND $bugsys->in['hidden']) { - $message->add_error(_('You cannot hide the first comment/initial report of a bug. Instead, hide the entire bug.')); + $message->addError(_('You cannot hide the first comment/initial report of a bug. Instead, hide the entire bug.')); } - if (!$message->items) + if (!$message->hasErrors()) { $commentapi->update(); @@ -174,7 +174,6 @@ if ($_POST['do'] == 'update') { $show['errors'] = true; $_REQUEST['do'] = 'edit'; - $message->error_list_process(); $comment['comment'] = $bugsys->in['comment']; $comment['hidden'] = $bugsys->in['hidden']; } @@ -186,7 +185,7 @@ if ($_REQUEST['do'] == 'edit') { if (!((can_perform('caneditownreply', $bug['product']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['product']) AND $bugsys->userinfo['userid'] != $comment['userid']))) { - $message->error_permission(); + $message->errorPermission(); } $comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']); diff --git a/editreport.php b/editreport.php index 992a170..8effe31 100644 --- a/editreport.php +++ b/editreport.php @@ -47,7 +47,7 @@ if (!$bug) if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } // setup logging @@ -69,7 +69,7 @@ if ($_POST['do'] == 'kill') { if (!can_perform('candeletedata', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } $bugapi->delete(); @@ -83,7 +83,7 @@ if ($_REQUEST['do'] == 'delete') { if (!can_perform('candeletedata', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } $message->confirm(_('Are you sure you want to delete this bug? Doing so will destroy all associated data, including comments, attachments, and votes. We strongly recommend only deleting span records and nothing else as users may wish to go back and look at any bug to check its status.'), 'editreport.php', 'kill', _('Delete Bug Permanently'), 'showreport.php?bugid=' . $bug['bugid'], array('bugid' => $bug['bugid'])); @@ -95,7 +95,7 @@ if ($_POST['do'] == 'update') { if (!((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } $log->add_data(true, $bugapi->objdata, $log->getCommonFields(), true); diff --git a/favorite.php b/favorite.php index ec7e384..65717f9 100644 --- a/favorite.php +++ b/favorite.php @@ -45,12 +45,12 @@ if ($_REQUEST['do'] == 'handle') $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $bugsys->in['bugid']); if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } if (!can_perform('cansubscribe', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } if ($db->query_first("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . $bugsys->userinfo['userid'] . " AND bugid = " . $bugsys->in['bugid'])) @@ -71,7 +71,7 @@ if ($_REQUEST['do'] == 'manage') { if (!can_perform('canviewbugs')) { - $message->error_permission(); + $message->errorPermission(); } $favorites = $db->query(" diff --git a/global.php b/global.php index ab1c508..6d09d29 100755 --- a/global.php +++ b/global.php @@ -121,7 +121,7 @@ $show = array(); // ################################################################### // create error reporter require_once('./includes/class_message_reporter.php'); -$message = new Message_Reporter(); +$message = new MessageReporter(); $bugsys->message =& $message; /*=====================================================================*\ diff --git a/includes/class_api_error.php b/includes/class_api_error.php index b1aea33..e82230f 100644 --- a/includes/class_api_error.php +++ b/includes/class_api_error.php @@ -69,7 +69,7 @@ class API_Error_Handler */ function user_cumulative($error) { - $this->object->add_error($error); + $this->object->addError($error); } // ################################################################### diff --git a/includes/class_message_reporter.php b/includes/class_message_reporter.php index a28eb2f..4e18979 100755 --- a/includes/class_message_reporter.php +++ b/includes/class_message_reporter.php @@ -19,25 +19,21 @@ || ################################################################### \*=====================================================================*/ -class Message_Reporter +class MessageReporter { - /** - * The URL used for redirect - * @var string - */ - var $url = ''; - /** * Phrase array; null by default * @var array + * @access private */ - var $items = null; + var $errors = array(); /** - * The processed text for a message + * The processed text for a compound error * @var string + * @access private */ - var $process = ''; + var $errorBox = ''; // ################################################################### /** @@ -47,103 +43,99 @@ class Message_Reporter * * @param string Error message */ - function add_error($message) + function addError($message) { - $this->items[] = $message; + $this->errors[] = $message; } + // ################################################################### /** - * Throws a fatal user-end error message + * Returns TRUE if there are any errors from addError(), and FALSE if + * there are not. This also processes all the errors into a message + * block that can then be used in error() * - * @param string The text of a message + * @return bool Whether there are any errors present */ - function error($text = '') + function hasErrors() { - global $bugsys; - global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; - - if (sizeof($this->items) > 0 AND empty($this->process)) + if (sizeof($this->errors) < 1) { - trigger_error('Message_Reporter->items is an array so please use Message_Reporter->error_list_process() to prepare it', E_USER_ERROR); + return false; } - $this->process = ($text ? $text : $this->process); - - $this->check_process(); + $this->errorBox = "\n\n
    "; + foreach ($this->errors AS $err) + { + $this->errorBox .= "\n\t
  1. " . $err . "
  2. "; + } + $this->errorBox .= "\n
"; - eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_error') . '");'); - exit; + return true; } + // ################################################################### /** - * Converts the phrase array into a list for use in error() + * Throws an actual error. If an error text is passed, it takes + * precedence over any processed list errors + * + * @param string Error text */ - function error_list_process() + function error($error = null) { - if (!is_array($this->items) OR sizeof($this->items) < 1) - { - return; - } + global $bugsys; + global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; - $this->process = "\n\n
    "; - foreach ($this->items AS $phrase) + if ($error == null) { - $this->process .= "\n\t
  1. " . $phrase . "
  2. "; + $error = $this->errorBox; } - $this->process .= "\n
"; + + eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_error') . '");'); + exit; } + // ################################################################### /** * Throws a common no-permission error */ - function error_permission() + function errorPermission() { - global $bugsys; - $this->error(_('You do not have permission to access this page. If you think that this is an error, please contact an administrator.')); } + // ################################################################### /** * Performs a front-end redirect by either header or * * @param string Redirect message text * @param string URL to take the user */ - function redirect($text = '', $url = '') + function redirect($message, $url) { global $bugsys; global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; - $this->process = ($text ? $text : $this->process); - $this->url = ($url ? $url : $this->url); - if ($bugsys->options['redirectheaders']) { header("Location: $url"); exit; } - $this->check_process(); - eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_redirect') . '");'); - exit; } + // ################################################################### /** * Displays a fatal warning/notice that is usually not an error * * @param string Warning text */ - function message($text = '') + function message($message) { global $bugsys; global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar; - $this->process = ($text ? $text : $this->process); - - $this->check_process(); - eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message') . '");'); exit; } @@ -168,8 +160,6 @@ class Message_Reporter $show['confirm'] = true; - $this->process = $message; - foreach ($arrextra AS $name => $value) { $extra .= '' . "\n"; @@ -178,17 +168,6 @@ class Message_Reporter eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message') . '");'); exit; } - - /** - * Checks to make sure that there is some text in the processed variable - */ - function check_process() - { - if (empty($this->process)) - { - trigger_error('Message_Reporter requires some text to display a message', E_USER_ERROR); - } - } } /*=====================================================================*\ diff --git a/includes/functions.php b/includes/functions.php index 0604580..3e40132 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -419,7 +419,7 @@ function process_custom_fields(&$bugapi, &$msg, $errorbox = false, $searchMode = { foreach ($errorlist AS $err) { - $msg->add_error($err); + $msg->addError($err); } } else diff --git a/index.php b/index.php index 9da45fe..d501d38 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,7 @@ require_once('./includes/class_sort.php'); if (!can_perform('canviewbugs')) { - $message->error_permission(); + $message->errorPermission(); } $sort = new ListSorter('index'); diff --git a/login.php b/login.php index 31e6b0d..f64e889 100755 --- a/login.php +++ b/login.php @@ -175,16 +175,16 @@ if ($_POST['do'] == 'resetpw') if ($bugsys->in['fix_password'] != $bugsys->in['confirm_password']) { - $message->add_error(_('The passwords you entered do not patch.')); + $message->addError(_('The passwords you entered do not patch.')); } if (empty($bugsys->in['fix_password'])) { - $message->add_error(_('Your new password cannot be empty.')); + $message->addError(_('Your new password cannot be empty.')); } $user->set('password', $bugsys->in['fix_password']); - if (!$message->items) + if (!$message->hasErrors()) { // remove old other activators for this user $db->query("DELETE FROM " . TABLE_PREFIX . "passwordreset WHERE userid = " . $activation['userid']); @@ -196,7 +196,6 @@ if ($_POST['do'] == 'resetpw') { $show['errors'] = true; $_REQUEST['do'] = 'recoverpw'; - $message->error_list_process(); } } diff --git a/newreport.php b/newreport.php index 2ac89be..972846b 100755 --- a/newreport.php +++ b/newreport.php @@ -39,7 +39,7 @@ APIError(array(new API_Error_Handler($message), 'user_cumulative')); $product = explode(',', $bugsys->in['product']); if (!can_perform('cansubmitbugs', $product[0])) { - $message->error_permission(); + $message->errorPermission(); } // ################################################################### @@ -98,7 +98,7 @@ if ($_POST['do'] == 'insert') process_custom_fields($bug, $message, true); - if (!$message->items) + if (!$message->hasErrors()) { $bug->insert(); @@ -132,7 +132,6 @@ if ($_POST['do'] == 'insert') { $show['errors'] = true; $_REQUEST['do'] = 'add'; - $message->error_list_process(); } } diff --git a/register.php b/register.php index 23677d2..04c785f 100755 --- a/register.php +++ b/register.php @@ -49,12 +49,12 @@ if ($_POST['do'] == 'insert') if ($bugsys->in['email'] != $bugsys->in['confirmemail']) { - $message->add_error(_('The emails you entered do not match.')); + $message->addError(_('The emails you entered do not match.')); } if ($bugsys->in['password'] != $bugsys->in['confirmpassword']) { - $message->add_error(_('The passwords you entered did not match.')); + $message->addError(_('The passwords you entered did not match.')); } if ($bugsys->options['verifyemail']) @@ -83,7 +83,7 @@ if ($_POST['do'] == 'insert') $user->set('timezone', $bugsys->options['defaulttimezone']); $user->set('usergroupid', $usergroupid); - if (!$message->items) + if (!$message->hasErrors()) { $user->insert(); @@ -131,7 +131,6 @@ if ($_POST['do'] == 'insert') { $_REQUEST['do'] = ''; $show['errors'] = true; - $message->error_list_process(); } } diff --git a/search.php b/search.php index 82cbfeb..c79c1c5 100644 --- a/search.php +++ b/search.php @@ -45,7 +45,7 @@ APIError(array($message, 'error')); if (!can_perform('cansearch')) { - $message->error_permission(); + $message->errorPermission(); } define('MODE_ANY', 1); @@ -439,7 +439,7 @@ if ($_REQUEST['do'] == 'update') $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']); if (!$search) { - $message->error_permission(); + $message->errorPermission(); } $productSelect = ConstructProductSelect(); @@ -493,7 +493,7 @@ if ($_POST['do'] == 'doupdate') $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']); if (!$search) { - $message->error_permission(); + $message->errorPermission(); } // find all the bugs that we can edit @@ -634,25 +634,24 @@ if ($_POST['do'] == 'dosave') $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']); if (!$search) { - $message->add_error(_('The search does not exist.')); + $message->addError(_('The search does not exist.')); } if ($search['name']) { - $message->add_error(sprintf(_('This search has already been named "%1$s".'), $search['name'])); + $message->addError(sprintf(_('This search has already been named "%1$s".'), $search['name'])); } if (empty($bugsys->in['name'])) { - $message->add_error(_('The name cannot be empty.')); + $message->addError(_('The name cannot be empty.')); } - if (!$message->items) + if (!$message->hasErrors()) { $db->query("UPDATE " . TABLE_PREFIX . "search SET name = '" . $bugsys->input_escape('name') . "' WHERE searchid = " . $bugsys->in['searchid']); $message->redirect(_('Your search has been saved.'), 'search.php?searchid=' . $search['searchid']); } else { - $message->error_list_process(); $_REQUEST['do'] = 'save'; $show['errors'] = true; } @@ -664,7 +663,7 @@ if ($_REQUEST['do'] == 'save') { if (!$bugsys->userinfo['userid']) { - $message->error_permission(); + $message->errorPermission(); } eval('$template->flush("' . $template->fetch('search_save') . '");'); diff --git a/showhistory.php b/showhistory.php index ba70f78..cc3c2db 100644 --- a/showhistory.php +++ b/showhistory.php @@ -39,7 +39,7 @@ if (!$bug) if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } $lookupfields = array( diff --git a/showreport.php b/showreport.php index 2ce7cf0..6ee2b30 100644 --- a/showreport.php +++ b/showreport.php @@ -76,7 +76,7 @@ if (!is_array($bug)) if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } $show['edit'] = ((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid'] AND $bug['userid'] != 0) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid'])); diff --git a/syndicate.php b/syndicate.php index 7ec90ed..b372c01 100644 --- a/syndicate.php +++ b/syndicate.php @@ -25,7 +25,7 @@ require_once('./global.php'); if (!can_perform('canviewbugs')) { - $message->error_permission(); + $message->errorPermission(); } // ################################################################### diff --git a/templates/editcomment.tpl b/templates/editcomment.tpl index 7fc14b3..b03c443 100644 --- a/templates/editcomment.tpl +++ b/templates/editcomment.tpl @@ -13,7 +13,7 @@ $header
{@"The following errors occurred"}: - {$message->process} + {$message->errorBox}
diff --git a/templates/newattach.tpl b/templates/newattach.tpl index aa019c2..0bbac09 100644 --- a/templates/newattach.tpl +++ b/templates/newattach.tpl @@ -13,7 +13,7 @@ $header
{@"The following errors occurred"}: - {$message->process} + {$message->errorBox}
diff --git a/templates/newreport.tpl b/templates/newreport.tpl index 1f417e3..e164226 100644 --- a/templates/newreport.tpl +++ b/templates/newreport.tpl @@ -14,7 +14,7 @@ $header
{@"The following errors occurred"}: - {$message->process} + {$message->errorBox}
diff --git a/templates/passwordreset.tpl b/templates/passwordreset.tpl index 8e4845d..cd02d87 100644 --- a/templates/passwordreset.tpl +++ b/templates/passwordreset.tpl @@ -17,7 +17,7 @@ $header
{@"The following errors occurred"}: - {$message->process} + {$message->errorBox}
diff --git a/templates/register.tpl b/templates/register.tpl index 58c5a96..8fbe81c 100644 --- a/templates/register.tpl +++ b/templates/register.tpl @@ -13,7 +13,7 @@ $header
{@"The following errors occurred"}: - {$message->process} + {$message->errorBox}
diff --git a/templates/search_save.tpl b/templates/search_save.tpl index c781056..54ac134 100644 --- a/templates/search_save.tpl +++ b/templates/search_save.tpl @@ -13,7 +13,7 @@ $header
{@"The following errors occurred"}: - {$message->process} + {$message->errorBox}
diff --git a/templates/std_error.tpl b/templates/std_error.tpl index 98595ce..f6c0d6f 100644 --- a/templates/std_error.tpl +++ b/templates/std_error.tpl @@ -15,7 +15,7 @@ $header
{@"Error"}
- {$this->process} + $error
diff --git a/templates/std_message.tpl b/templates/std_message.tpl index f8d8996..b879169 100644 --- a/templates/std_message.tpl +++ b/templates/std_message.tpl @@ -21,7 +21,7 @@ $extra
{@"Confirm"}{@"Notice"}
- {$this->process} + $message
diff --git a/templates/std_redirect.tpl b/templates/std_redirect.tpl index 33f898f..83dc6f5 100644 --- a/templates/std_redirect.tpl +++ b/templates/std_redirect.tpl @@ -3,7 +3,7 @@ $doctype $headinclude - + {$bugsys->options['trackertitle']} - {@"Redirect..."} @@ -16,12 +16,12 @@ $header
{@"Redirect..."}
diff --git a/templates/userctrl.tpl b/templates/userctrl.tpl index e26fa91..6871109 100644 --- a/templates/userctrl.tpl +++ b/templates/userctrl.tpl @@ -17,7 +17,7 @@ $header
{@"The following errors occurred"}: - {$message->process} + {$message->errorBox}
diff --git a/userctrl.php b/userctrl.php index 69ba66c..223b6db 100644 --- a/userctrl.php +++ b/userctrl.php @@ -37,7 +37,7 @@ APIError(array(new API_Error_Handler($message), 'user_cumulative')); if (!$bugsys->userinfo['userid']) { - $message->error_permission(); + $message->errorPermission(); } $userapi = new UserAPI($bugsys); @@ -60,7 +60,7 @@ if ($_POST['do'] == 'killsearch') $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']); if (!$search) { - $message->error_permission(); + $message->errorPermission(); } $db->query("DELETE FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->in['searchid']); @@ -75,7 +75,7 @@ if ($_REQUEST['do'] == 'deletesearch') $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']); if (!$search) { - $message->error_permission(); + $message->errorPermission(); } $message->confirm(_('Are you sure you want to delete this saved search?'), 'userctrl.php', 'killsearch', _('Delete'), _('Cancel'), array('searchid' => $bugsys->in['searchid'])); @@ -91,13 +91,13 @@ if ($_POST['do'] == 'update') { if (empty($bugsys->in['validate'])) { - $message->add_error(_('You need to enter your current password to change your email or password')); + $message->addError(_('You need to enter your current password to change your email or password')); } else { if (md5(md5($bugsys->in['validate']) . md5($bugsys->userinfo['salt'])) != $bugsys->userinfo['password']) { - $message->add_error(_('Your authentication password does not match the one in our records')); + $message->addError(_('Your authentication password does not match the one in our records')); } } } @@ -108,12 +108,12 @@ if ($_POST['do'] == 'update') { if (!empty($bugsys->in['email_change']) AND empty($bugsys->in['email_confirm'])) { - $message->add_error(_('You need to enter both the email and confirm email fields to change your address')); + $message->addError(_('You need to enter both the email and confirm email fields to change your address')); } if ($bugsys->in['email_change'] != $bugsys->in['email_confirm']) { - $message->add_error(_('Your email and confirm email addresses do not match')); + $message->addError(_('Your email and confirm email addresses do not match')); } $userapi->set('email', $bugsys->in['email_change']); @@ -125,13 +125,13 @@ if ($_POST['do'] == 'update') { if (!empty($bugsys->in['password_change']) AND empty($bugsys->in['password_confirm'])) { - $message->add_error(_('You need to enter both the password and confirm password fields to change your password')); + $message->addError(_('You need to enter both the password and confirm password fields to change your password')); } else { if ($bugsys->in['password_change'] != $bugsys->in['password_confirm']) { - $message->add_error(_('Your password and confirm password do not match')); + $message->addError(_('Your password and confirm password do not match')); } } @@ -167,10 +167,8 @@ if ($_POST['do'] == 'update') // ------------------------------------------------------------------- // error handling - if ($message->items) + if ($message->hasErrors()) { - $message->error_list_process(); - $show['errors'] = true; $_REQUEST['do'] = 'modify'; } diff --git a/viewattachment.php b/viewattachment.php index e7c1cbd..02d4844 100755 --- a/viewattachment.php +++ b/viewattachment.php @@ -36,12 +36,12 @@ if (!$attachment) $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $attachment[bugid]"); if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } if (!can_perform('cangetattach', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } ob_clean(); diff --git a/vote.php b/vote.php index f58a295..3955e46 100644 --- a/vote.php +++ b/vote.php @@ -41,12 +41,12 @@ if ($_REQUEST['do'] == 'vote') if (!check_bug_permissions($bug)) { - $message->error_permission(); + $message->errorPermission(); } if (!can_perform('canvote', $bug['product'])) { - $message->error_permission(); + $message->errorPermission(); } if (!$bug) -- 2.43.5