From ff76667fae5329b0a2fb8bbeb652af951ef4cc35 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 20 May 2006 22:22:12 +0000 Subject: [PATCH] r842: - Implementing API_Error_Handler::user_cumulative() - Use add_error() instead of accessing properties for $message --- attachment.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/attachment.php b/attachment.php index 414d27e..ab2dcf1 100755 --- a/attachment.php +++ b/attachment.php @@ -29,9 +29,12 @@ define('SVN', '$Id$'); $focus['showreport'] = 'focus'; require_once('./global.php'); +require_once('./includes/class_api_error.php'); require_once('./includes/api_attachment.php'); require_once('./includes/api_comment.php'); +APIError(array(new API_Error_Handler($message), 'user_cumulative')); + if (isset($bugsys->in['attachmentid'])) { $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . intval($bugsys->in['attachmentid'])); @@ -72,24 +75,24 @@ if ($_POST['do'] == 'insert') switch ($FILE['error']) { case 0: break; - case 1: $message->items[] = $lang->string('PHP said the file you uploaded was too big.'); break; - case 2: $message->items[] = $lang->string('The file exceeds the allowed upload size.'); break; - case 3: $message->items[] = $lang->string('The file was only partially uploaded.'); break; - case 4: $message->items[] = $lang->string('The file was not uploaded at all.'); break; - case 6: $message->items[] = $lang->string('PHP could not find the /tmp directory.'); break; + case 1: $message->add_error($lang->string('PHP said the file you uploaded was too big.')); break; + case 2: $message->add_error($lang->string('The file exceeds the allowed upload size.')); break; + case 3: $message->add_error($lang->string('The file was only partially uploaded.')); break; + case 4: $message->add_error($lang->string('The file was not uploaded at all.')); break; + case 6: $message->add_error($lang->string('PHP could not find the /tmp directory.')); break; } // did it upload? if (!is_uploaded_file($FILE['tmp_name'])) { - $message->items[] = $lang->string('The file you specified did not upload.'); + $message->add_error($lang->string('The file you specified did not upload.')); } // #*# put some MIME-type validation here if (filesize($FILE['tmp_name']) > $var['Value']) { - $message->items[] = $lang->string('The file you specified exceeds MySQL\'s maximum allowed packet.'); + $message->add_error($lang->string('The file you specified exceeds MySQL\'s maximum allowed packet.')); } $attachapi->set('attachment', file_get_contents($FILE['tmp_name'])); -- 2.22.5