From 7fd5635cfd644953b9b2e1d19831a72bf7b0e5dc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 23 Aug 2008 16:25:40 -0400 Subject: [PATCH] Updated attachment.php to work, sans NotificationCenter --- attachment.php | 29 +++++++++++++++++++---------- includes/api_attachment.php | 4 ++-- includes/class_notification.php | 12 ++++++------ templates/editattach.tpl | 4 ++-- templates/newattach.tpl | 8 ++++---- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/attachment.php b/attachment.php index 91ea31d..0af8c15 100755 --- a/attachment.php +++ b/attachment.php @@ -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 .= "
in['obsoletes']) AND in_array($obsolete['attachmentid'], $input->in['obsoletes']) ? ' checked="checked"' : '') . " /> $obsolete[filename]" . ($obsolete['description'] ? " [$obsolete[description]]" : '') . "
\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(); } /*=====================================================================*\ diff --git a/includes/api_attachment.php b/includes/api_attachment.php index e3b6915..d739611 100644 --- a/includes/api_attachment.php +++ b/includes/api_attachment.php @@ -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 diff --git a/includes/class_notification.php b/includes/class_notification.php index 8b6b3c5..31ce4a0 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -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']) diff --git a/templates/editattach.tpl b/templates/editattach.tpl index 3022e2a..fc5fe40 100644 --- a/templates/editattach.tpl +++ b/templates/editattach.tpl @@ -17,7 +17,7 @@
- {@"Attachment #%1$s for Bug #%2$s %3$s"} + <%- sprintf(T('Attachment #%1$s for Bug #%2$s %3$s'), $attachment['attachmentid'], $bug['bugid'], $bug['summary']) %>
@@ -41,4 +41,4 @@ -$footer \ No newline at end of file +<%- $footer %> \ No newline at end of file diff --git a/templates/newattach.tpl b/templates/newattach.tpl index adc081c..e209aa6 100644 --- a/templates/newattach.tpl +++ b/templates/newattach.tpl @@ -8,7 +8,7 @@ -$header +<%- $header %> <% if ($show['errors']): %>
@@ -24,7 +24,7 @@ $header
-
{@"New Attachment for Bug #%1$s %2$s"}
+
<%- sprintf(T('New Attachment for Bug #%1$s %2$s'), $bug['bugid'], $bug['summary']) %>
@@ -55,9 +55,9 @@ $header
" accesskey="s" /> " accesskey="r" /> - +
-$footer \ No newline at end of file +<%- $footer %> \ No newline at end of file -- 2.22.5