r842: - Implementing API_Error_Handler::user_cumulative()
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 20 May 2006 22:22:12 +0000 (22:22 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 20 May 2006 22:22:12 +0000 (22:22 +0000)
- Use add_error() instead of accessing properties for $message

attachment.php

index 414d27e9c2565c590cf499b59c61886aad9e6c1a..ab2dcf1aae6b9dfdf10e349114445eff8544c65f 100755 (executable)
@@ -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']));