Updated attachment.php to work, sans NotificationCenter
[bugdar.git] / attachment.php
index 91ea31d2565ac4e7fa7626f68cb4f523a6f6e509..0af8c15c6abc14a5a3b236786ef0bdf3ec9ebb8b 100755 (executable)
@@ -33,8 +33,6 @@ require_once('./includes/class_notification.php');
 require_once('./includes/api_attachment.php');
 require_once('./includes/api_comment.php');
 
-APIError(array(new API_Error_Handler($message), 'user_cumulative'));
-
 if (isset($input->in['attachmentid']))
 {
        $attachment = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . $input->inputClean('attachmentid', TYPE_UINT));
@@ -57,7 +55,7 @@ if (!check_bug_permissions($bug))
 
 require_once('./includes/class_logging.php');
 
-$notif = new NotificationCenter;
+$notif = new NotificationCenter();
 $notif->set_bug_data($bug);
 
 // ###################################################################
@@ -77,7 +75,7 @@ if ($_POST['do'] == 'insert')
        BSApp::debug("max_allowed_packet = $var[Value]");
        
        // create alias
-       $FILE =$_FILES['attachment'];
+       $FILE = &$_FILES['attachment'];
        
        // PHP errors
        switch ($FILE['error'])
@@ -124,7 +122,7 @@ if ($_POST['do'] == 'insert')
                {
                        $db->query("UPDATE " . TABLE_PREFIX . "attachment SET obsolete = 1 WHERE attachmentid IN (" . implode(',', $obsoletes) . ") AND !obsolete AND bugid = $bug[bugid]");
                        
-                       foreach ($obsoletes AS $attachmentid)
+                       foreach ($obsoletes as $attachmentid)
                        {
                                $log = new Logging;
                                $log->set_bugid($bug['bugid']);
@@ -184,7 +182,15 @@ if ($_REQUEST['do'] == 'add')
                $obsoletes .= "<div><input name=\"obsoletes[]\" type=\"checkbox\" value=\"$obsolete[attachmentid]\"" . (is_array($input->in['obsoletes']) AND in_array($obsolete['attachmentid'], $input->in['obsoletes']) ? ' checked="checked"' : '') . " /> $obsolete[filename]" . ($obsolete['description'] ? " [$obsolete[description]]" : '') . "</div>\n";
        }
        
-       eval('$template->flush("' . $template->fetch('newattach') . '");');
+       $tpl = new BSTemplate('newattach');
+       $tpl->vars = array(
+               'bug'                   => $bug,
+               'message'               => $message,
+               'MAXFILESIZE'   => $MAXFILESIZE,
+               'obsoletes'             => $obsoletes,
+               'input'                 => $input
+       );
+       $tpl->evaluate()->flush();
 }
 
 // ###################################################################
@@ -198,8 +204,6 @@ if ($_POST['do'] == 'update')
        
        $attachapi = new AttachmentAPI();
        $attachapi->set('attachmentid', $input->in['attachmentid']);
-       $attachapi->dorelations = array();
-       $attachapi->set_condition();
        
        if ($input->in['__delete__'] != '')
        {
@@ -214,7 +218,7 @@ if ($_POST['do'] == 'update')
        }
        else
        {
-               $log = new Logging;
+               $log = new Logging();
                $log->set_bugid($bug['bugid']);
                $log->set_attachmentid($input->in['attachmentid']);
                
@@ -245,7 +249,12 @@ if ($_REQUEST['do'] == 'edit')
        
        $show['delete'] = (can_perform('caneditattach', $bug['product']) AND can_perform('candeletedata', $bug['productid']));
        
-       eval('$template->flush("' . $template->fetch('editattach') . '");');
+       $tpl = new BSTemplate('editattach');
+       $tpl->vars = array(
+               'attachment'    => $attachment,
+               'bug'                   => $bug
+       );
+       $tpl->evaluate()->flush();
 }
 
 /*=====================================================================*\