Squash-merging the ISSO3 branch back onto master
[bugdar.git] / editreport.php
index fe2734760dcc59452479afba78d988eb85bb0122..09d941e46e1c4a76a984cab299131140433c990f 100644 (file)
@@ -19,7 +19,6 @@
 || ###################################################################
 \*=====================================================================*/
 
-define('SVN', '$Id$');
 
 $focus['showreport'] = 'focus';
 
@@ -29,15 +28,12 @@ require_once('./includes/class_notification.php');
 require_once('./includes/api_bug.php');
 require_once('./includes/api_comment.php');
 
-require_once('./includes/class_api_error.php');
-APIError(array(new API_Error_Handler($message), 'user_cumulative'));
-
-$bug = $db->query_first("
+$bug = $db->queryFirst("
        SELECT bug.*, user.email, user.displayname, user.showemail
        FROM " . TABLE_PREFIX . "bug AS bug
        LEFT JOIN " . TABLE_PREFIX . "user AS user
                ON (bug.userid = user.userid)
-       WHERE bug.bugid = " . $bugsys->input_clean('bugid', TYPE_UINT)
+       WHERE bug.bugid = " . $input->inputClean('bugid', TYPE_UINT)
 );
 
 if (!$bug)
@@ -52,15 +48,13 @@ if (!check_bug_permissions($bug))
 
 // setup logging
 require_once('./includes/class_logging.php');
-$log = new Logging;
-$log->set_bugid($bug['bugid']);
+$log = new Logging();
+$log->setBugId($bug['bugid']);
 
-$notif = new NotificationCenter;
+$notif = new NotificationCenter();
 
-$bugapi = new BugAPI($bugsys);
-$bugapi->set('bugid',          $bugsys->in['bugid']);
-$bugapi->set_condition();
-$bugapi->dorelations = array();
+$bugapi = new BugAPI();
+$bugapi->set('bugid', $input->in['bugid']);
 $bugapi->fetch();
 
 // ###################################################################
@@ -72,7 +66,7 @@ if ($_POST['do'] == 'kill')
                $message->errorPermission();
        }
        
-       $bugapi->delete();
+       $bugapi->remove();
        
        $message->redirect(T('The entire bug has been deleted.'), 'index.php');
 }
@@ -93,18 +87,18 @@ if ($_REQUEST['do'] == 'delete')
 
 if ($_POST['do'] == 'update')
 {
-       if (!((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['product']))
+       if (!((can_perform('caneditown', $bug['product']) && bugdar::$userinfo['userid'] == $bug['userid']) || (can_perform('caneditother', $bug['product']) && bugdar::$userinfo['userid'] != $bug['userid'])) && !can_perform('canpostcomments', $bug['product']))
        {
                $message->errorPermission();
        }
        
-       $log->add_data(true, $bugapi->objdata, $log->getCommonFields(), true);
+       $log->addData(true, $bugapi->record, $log->getCommonFields(), true);
        
        // -------------------------------------------------------------------
        // handle automations
-       if ($bugsys->in['automation'])
+       if ($input->in['automation'])
        {
-               $automation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "automation WHERE actionid = " . $bugsys->input_clean('automation', TYPE_UINT));
+               $automation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "automation WHERE actionid = " . $input->inputClean('automation', TYPE_UINT));
                if ($automation)
                {
                        $automation['fields'] = unserialize($automation['fieldchanges']);
@@ -113,7 +107,7 @@ if ($_POST['do'] == 'update')
                        {
                                foreach ($automation['fields']['builtin'] AS $field => $value)
                                {
-                                       $bugsys->in["$field"] = $value;
+                                       $input->in["$field"] = $value;
                                }
                        }
 
@@ -121,7 +115,7 @@ if ($_POST['do'] == 'update')
                        {
                                foreach ($automation['fields']['custom'] AS $field => $value)
                                {
-                                       $bugsys->in["custom$field"] = $value;
+                                       $input->in["custom$field"] = $value;
                                }
                        }
                }
@@ -129,40 +123,40 @@ if ($_POST['do'] == 'update')
 
        // -------------------------------------------------------------------
        // process comment stuff
-       if ($bugsys->in['comment'] OR $automation['comment'])
+       if ($input->in['comment'] OR $automation['comment'])
        {
-               if (!empty($bugsys->in['comment']) AND $automation['comment'])
+               if (!empty($input->in['comment']) AND $automation['comment'])
                {
-                       $commenttext = $bugsys->in['comment'] . "\n\n" . T('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $automation['comment'];
+                       $commenttext = $input->in['comment'] . "\n\n" . T('--------------- AUTOMATIC RESPONSE ---------------') . "\n" . $automation['comment'];
                }
-               else if (empty($bugsys->in['comment']) AND $automation['comment'])
+               else if (empty($input->in['comment']) AND $automation['comment'])
                {
                        $commenttext = $automation['comment'];
                }
                else
                {
-                       $commenttext = $bugsys->in['comment'];
+                       $commenttext = $input->in['comment'];
                }
                
-               $comment = new CommentAPI($bugsys);
-               $comment->set('bugid',          $bugsys->in['bugid']);
-               $comment->set('userid',         $bugsys->userinfo['userid']);
+               $comment = new CommentAPI();
+               $comment->set('bugid',          $input->in['bugid']);
+               $comment->set('userid',         bugdar::$userinfo['userid']);
                $comment->set('comment',        $commenttext);
-               $comment->set('parselinks',     $bugsys->in['parselinks']);
+               $comment->set('parselinks',     $input->in['parselinks']);
                $comment->insert();
                
                // we redefine the bug data later, but it needs to be here in order to generate the user list
-               $notif->set_bug_data($bugapi->objdata);
-               $notif->send_new_comment_notice($comment->values);
+               $notif->setBugData($bugapi->record);
+               $notif->sendNewCommentNotice($comment->values);
                
                $bugapi->set('lastposttime',                    $comment->values['dateline']);
-               $bugapi->set('lastpostby',                              $bugsys->userinfo['userid']);
-               $bugapi->set('lastpostbyname',                  $bugsys->userinfo['displayname']);
+               $bugapi->set('lastpostby',                              bugdar::$userinfo['userid']);
+               $bugapi->set('lastpostbyname',                  bugdar::$userinfo['displayname']);
                $bugapi->set('hiddenlastposttime',              $comment->values['dateline']);
-               $bugapi->set('hiddenlastpostby',                $bugsys->userinfo['userid']);
-               $bugapi->set('hiddenlastpostbyname',    $bugsys->userinfo['displayname']);
+               $bugapi->set('hiddenlastpostby',                bugdar::$userinfo['userid']);
+               $bugapi->set('hiddenlastpostbyname',    bugdar::$userinfo['displayname']);
                
-               if (!((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid'])))
+               if (!((can_perform('caneditown', $bug['product']) AND bugdar::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar::$userinfo['userid'] != $bug['userid'])))
                {
                        $bugapi->update();
                        $notif->finalize();
@@ -172,18 +166,18 @@ if ($_POST['do'] == 'update')
        
        // -------------------------------------------------------------------
        // do update stuff      
-       $dependencies = preg_split('#([^0-9].*?)#', $bugsys->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
+       $dependencies = preg_split('#([^0-9].*?)#', $input->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
        $dependencies = ((sizeof($dependencies) < 1) ? '' : implode(', ', $dependencies));
        
-       if ((can_perform('caneditown', $bug['product']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND $bugsys->userinfo['userid'] != $bug['userid']))
+       if ((can_perform('caneditown', $bug['product']) && bugdar::$userinfo['userid'] == $bug['userid']) || (can_perform('caneditother', $bug['product']) && bugdar::$userinfo['userid'] != $bug['userid']))
        {
-               $bugapi->set('summary',         $bugsys->in['summary']);
-               $bugapi->set('severity',        $bugsys->in['severity']);
-               $bugapi->set('duplicateof',     $bugsys->in['duplicateof']);
+               $bugapi->set('summary',         $input->in['summary']);
+               $bugapi->set('severity',        $input->in['severity']);
+               $bugapi->set('duplicateof',     $input->in['duplicateof']);
                $bugapi->set('dependency',      $dependencies);
-               $bugapi->set('hidden',          $bugsys->in['hidden']);
+               $bugapi->set('hidden',          $input->in['hidden']);
        
-               $product = explode(',',         $bugsys->in['product']);
+               $product = explode(',',         $input->in['product']);
                $bugapi->set('product',         $product[0]);
                $bugapi->set('component',       $product[1]);
                $bugapi->set('version',         $product[2]);
@@ -191,13 +185,13 @@ if ($_POST['do'] == 'update')
        
        if (can_perform('canchangestatus', $bug['product']))
        {
-               $bugapi->set('priority',        $bugsys->in['priority']);
-               $bugapi->set('status',          $bugsys->in['status']);
-               $bugapi->set('resolution',      $bugsys->in['resolution']);
+               $bugapi->set('priority',        $input->in['priority']);
+               $bugapi->set('status',          $input->in['status']);
+               $bugapi->set('resolution',      $input->in['resolution']);
        }
        if (can_perform('canassign', $bug['product']))
        {
-               $bugapi->set('assignedto',      $bugsys->in['assignedto']);
+               $bugapi->set('assignedto',      $input->in['assignedto']);
        }
        
        process_custom_fields($bugapi, $message, false);
@@ -205,8 +199,8 @@ if ($_POST['do'] == 'update')
        // -------------------------------------------------------------------
        // handle logging and perform updates
        
-       $notif->set_bug_data($bugapi->objdata, array_merge($bugapi->objdata, $bugapi->values));
-       $log->add_data(false, $bugapi->values, $log->getCommonFields(), true);
+       $notif->setBugData($bugapi->record, array_merge($bugapi->record, $bugapi->values));
+       $log->addData(false, $bugapi->values, $log->getCommonFields(), true);
        
        if (!$message->hasErrors())
        {
@@ -220,19 +214,13 @@ if ($_POST['do'] == 'update')
        // -------------------------------------------------------------------
        // do diff history
 
-       $log->update_history();
+       $log->updateHistory();
        
-       $notif->send_bug_changes_notice();
+       $notif->sendBugChangeNotice();
        
        $notif->finalize();
        
        $message->redirect(T('Your changes to the bug have been saved.'), "showreport.php?bugid=$bug[bugid]");
 }
 
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
 ?>
\ No newline at end of file