Updated attachment.php to work, sans NotificationCenter
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 20:25:40 +0000 (16:25 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 23 Aug 2008 20:25:40 +0000 (16:25 -0400)
attachment.php
includes/api_attachment.php
includes/class_notification.php
templates/editattach.tpl
templates/newattach.tpl

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();
 }
 
 /*=====================================================================*\
index e3b69154ddf03d268d1dca0d422675c5466f7cc1..d7396116bd7a489b12437b562ca4c326fa8f5a2e 100644 (file)
@@ -19,7 +19,7 @@
 || ###################################################################
 \*=====================================================================*/
 
-$GLOBALS['isso:callback']->load('api', null);
+require_once ISSO . '/Api.php';
 
 /**
 * API: Attachment
@@ -30,7 +30,7 @@ $GLOBALS['isso:callback']->load('api', null);
 * @package             Bugdar
 * 
 */
-class AttachmentAPI extends API
+class AttachmentAPI extends BSApi
 {
        /**
        * Fields
index 8b6b3c5f39f992e1e7cbe9b2eb94cc1e38ed3b34..31ce4a0148734b4a2d71d48dfe4ac34949713358 100644 (file)
@@ -122,22 +122,22 @@ class NotificationCenter
        */
        function fetch_user_cache()
        {
-               $newbuggers = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "useremail WHERE relation = " . bugdar::$emailOptions['relations']['-notapplicable-'] . " AND mask & " . bugdar::$emailOptions['notifications']['newbug']);
+               $newbuggers = BSApp::$db->query("SELECT userid FROM " . TABLE_PREFIX . "useremail WHERE relation = " . bugdar::$emailOptions['relations']['-notapplicable-'] . " AND mask & " . bugdar::$emailOptions['notifications']['newbug']);
                foreach ($newbuggers as $newbug)
                {
                        $this->roles['-notapplicable-']["$newbug[userid]"] = $newbug['userid'];
                }
                
-               $favorites = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "favorite WHERE bugid = " . $this->registry->clean($this->bug['bugid'], TYPE_UINT));
+               $favorites = BSApp::$db->query("SELECT userid FROM " . TABLE_PREFIX . "favorite WHERE bugid = " . BSApp::$input->clean($this->bug['bugid'], TYPE_UINT));
                foreach ($favorites as $fav)
                {
                        $this->roles['favorite']["$fav[userid]"] = $fav['userid'];
                }
                
-               $voters = $this->registry->db->query_first("SELECT userids FROM " . TABLE_PREFIX . "vote WHERE bugid = " . $this->registry->clean($this->bug['bugid'], TYPE_UINT));
+               $voters = BSApp::$db->queryFirst("SELECT userids FROM " . TABLE_PREFIX . "vote WHERE bugid = " . BSApp::$input->clean($this->bug['bugid'], TYPE_UINT));
                $this->roles['voter'] = preg_split('#,#', $voters['userids'], 0, PREG_SPLIT_NO_EMPTY);
                
-               $commenters = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "comment WHERE bugid = " . $this->registry->clean($this->bug['bugid'], TYPE_UINT));
+               $commenters = BSApp::$db->query("SELECT userid FROM " . TABLE_PREFIX . "comment WHERE bugid = " . BSApp::$input->clean($this->bug['bugid'], TYPE_UINT));
                foreach ($commenters as $comment)
                {
                        $this->roles['commenter']["$comment[userid]"] = $comment['userid'];
@@ -148,7 +148,7 @@ class NotificationCenter
                
                if (is_array($masterids) AND sizeof($masterids) > 0)
                {
-                       $userinfo = $this->registry->db->query("
+                       $userinfo = BSApp::$db->query("
                                SELECT user.*, useremail.*
                                FROM " . TABLE_PREFIX . "useremail AS useremail
                                LEFT JOIN " . TABLE_PREFIX . "user AS user
@@ -541,7 +541,7 @@ class NotificationCenter
        function finalize()
        {
                // get the current bug for permissions checks
-               $bug = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $this->bug['bugid']);
+               $bug = BSApp::$db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $this->bug['bugid']);
                foreach ($this->notices AS $userid => $noticelist)
                {
                        if ($userid == bugdar::$userinfo['userid'])
index 3022e2ae2e1684b687e8253206d68d8f56c37949..fc5fe40dc19457f66ffdb854b613476a46a96352 100644 (file)
@@ -17,7 +17,7 @@
 
 <div class="box">
        <div class="box-head" style="text-align: <%- $stylevar['left'] %>">
-               <lang 1="$attachment[attachmentid]" 2="$bug[bugid]" 3="$bug[summary]">{@"Attachment #%1$s for Bug #%2$s %3$s"}</lang>
+               <%- sprintf(T('Attachment #%1$s for Bug #%2$s %3$s'), $attachment['attachmentid'], $bug['bugid'], $bug['summary']) %>
        </div>
 
        <div class="box-mid box-margmod-bottom" style="text-align: <%- $stylevar['left'] %>">
@@ -41,4 +41,4 @@
 
 </form>
 
-$footer
\ No newline at end of file
+<%- $footer %>
\ No newline at end of file
index adc081c260cda3c3b717ccbdf6503fbd7f2abff0..e209aa65246606edf4e77ab82d086da8aa283793 100644 (file)
@@ -8,7 +8,7 @@
 
 <body>
 
-$header
+<%- $header %>
 
 <% if ($show['errors']): %>
 <div class="error" style="text-align: <%- $stylevar['left'] %>">
@@ -24,7 +24,7 @@ $header
 <input name="MAX_FILE_SIZE" type="hidden" value="<%- $MAXFILESIZE %>" />
 
 <div class="box">
-       <div class="box-head" style="text-align: <%- $stylevar['left'] %>"><lang 1="$bug[bugid]" 2="$bug[summary]">{@"New Attachment for Bug #%1$s %2$s"}</lang></div>
+       <div class="box-head" style="text-align: <%- $stylevar['left'] %>"><%- sprintf(T('New Attachment for Bug #%1$s %2$s'), $bug['bugid'], $bug['summary']) %></div>
 
        <div class="box-mid box-margmod-bottom" style="text-align: <%- $stylevar['left'] %>">
                <div><input name="attachment" type="file" /></div>
@@ -55,9 +55,9 @@ $header
 <div id="submitrow">
        <input name="submit" type="submit" value="  <%-T("Submit")%>  " accesskey="s" />
        <input name="reset" type="reset" value="  <%-T("Reset")%>  " accesskey="r" />
-       <script type="text/javascript"> draw_cancel("showreport.php?bugid=$bug[bugid]"); </script>
+       <script type="text/javascript"> draw_cancel("showreport.php?bugid=<%- $bug['bugid'] %>"); </script>
 </div>
 
 </form>
 
-$footer
\ No newline at end of file
+<%- $footer %>
\ No newline at end of file