Exemplo n.º 1
0
 /**
  * Closes a task
  * @param integer $task_id
  * @param integer $reason
  * @param string $comment
  * @param bool $mark100
  * @access public
  * @return bool
  * @version 1.0
  */
 public static function close_task($task_id, $reason, $comment, $mark100 = true)
 {
     global $db, $notify, $user, $proj;
     $task = Flyspray::GetTaskDetails($task_id);
     if (!$user->can_close_task($task)) {
         return false;
     }
     if ($task['is_closed']) {
         return false;
     }
     $db->Query('UPDATE  {tasks}
                    SET  date_closed = ?, closed_by = ?, closure_comment = ?,
                         is_closed = 1, resolution_reason = ?, last_edited_time = ?,
                         last_edited_by = ?
                  WHERE  task_id = ?', array(time(), $user->id, $comment, $reason, time(), $user->id, $task_id));
     if ($mark100) {
         $db->Query('UPDATE {tasks} SET percent_complete = 100 WHERE task_id = ?', array($task_id));
         Flyspray::logEvent($task_id, 3, 100, $task['percent_complete'], 'percent_complete');
     }
     $notify->Create(NOTIFY_TASK_CLOSED, $task_id, null, null, NOTIFY_BOTH, $proj->prefs['lang_code']);
     Flyspray::logEvent($task_id, 2, $reason, $comment);
     // If there's an admin request related to this, close it
     $db->Query('UPDATE  {admin_requests}
                    SET  resolved_by = ?, time_resolved = ?
                  WHERE  task_id = ? AND request_type = ?', array($user->id, time(), $task_id, 1));
     // duplicate
     if ($reason == 6) {
         preg_match("/\\b(?:FS#|bug )(\\d+)\\b/", $comment, $dupe_of);
         if (count($dupe_of) >= 2) {
             $existing = $db->Query('SELECT * FROM {related} WHERE this_task = ? AND related_task = ? AND is_duplicate = 1', array($task_id, $dupe_of[1]));
             if ($existing && $db->CountRows($existing) == 0) {
                 $db->Query('INSERT INTO {related} (this_task, related_task, is_duplicate) VALUES(?, ?, 1)', array($task_id, $dupe_of[1]));
             }
             Backend::add_vote($task['opened_by'], $dupe_of[1]);
         }
     }
     return true;
 }
Exemplo n.º 2
0
         break;
     }
     $db->Query('UPDATE  {tasks}
                    SET  mark_private = 0
                  WHERE  task_id = ?', array($task['task_id']));
     Flyspray::logEvent($task['task_id'], 3, 0, 1, 'mark_private');
     $_SESSION['SUCCESS'] = L('taskmadepublicmsg');
     break;
     // ##################
     // Adding a vote for a task
     // ##################
 // ##################
 // Adding a vote for a task
 // ##################
 case 'details.addvote':
     if (Backend::add_vote($user->id, $task['task_id'])) {
         $_SESSION['SUCCESS'] = L('voterecorded');
     } else {
         Flyspray::show_error(L('votefailed'));
         break;
     }
     // TODO: Log event in a later version.
     break;
     // ##################
     // Removing a vote for a task
     // ##################
     # used to remove a vote from myprofile page
 // ##################
 // Removing a vote for a task
 // ##################
 # used to remove a vote from myprofile page
Exemplo n.º 3
0
 /**
  * Closes a task
  * @param integer $task_id
  * @param integer $reason
  * @param string $comment
  * @param bool $mark100
  * @access public
  * @return bool
  * @version 1.0
  */
 function close_task($task_id, $reason, $comment, $mark100 = true)
 {
     global $db, $user, $fs;
     $task = Flyspray::GetTaskDetails($task_id);
     if (!$user->can_close_task($task)) {
         return false;
     }
     if ($task['is_closed']) {
         return false;
     }
     $db->x->autoExecute('{tasks}', array('date_closed' => time(), 'closed_by' => $user->id, 'closure_comment' => $comment, 'is_closed' => 1, 'resolution_reason' => $reason, 'last_edited_time' => time(), 'last_edited_by' => $user->id, 'percent_complete' => (bool) $mark100 * 100), MDB2_AUTOQUERY_UPDATE, sprintf('task_id = %d', $task_id));
     if ($mark100) {
         Flyspray::logEvent($task_id, 3, 100, $task['percent_complete'], 'percent_complete');
     }
     // [RED] Update last changed date
     $db->x->execParam('UPDATE {redundant} SET last_changed_time = ?,
                               last_changed_by_real_name = ?, last_changed_by_user_name = ?,
                               closed_by_real_name = ?, closed_by_user_name = ?
                         WHERE task_id = ?', array(time(), $user->infos['real_name'], $user->infos['user_name'], $user->infos['real_name'], $user->infos['user_name'], $task_id));
     Notifications::send($task_id, ADDRESS_TASK, NOTIFY_TASK_CLOSED);
     Flyspray::logEvent($task_id, 2, $reason, $comment);
     // If there's an admin request related to this, close it
     $db->x->autoExecute('{admin_requests}', array('resolved_by' => $user->id, 'time_resolved' => time()), MDB2_AUTOQUERY_UPDATE, sprintf('task_id = %d AND request_type = 1', $task_id));
     // duplicate
     if ($reason == $fs->prefs['resolution_dupe']) {
         $look = array('FS#', 'bug ');
         foreach ($fs->projects as $project) {
             $look[] = preg_quote($project['project_prefix'] . '#', '/');
         }
         preg_match("/\\b(" . implode('|', $look) . ")(\\d+)\\b/", $comment, $dupe_of);
         if (count($dupe_of) >= 2) {
             $existing = $db->x->getOne('SELECT count(*) FROM {related} WHERE this_task = ? AND related_task = ? AND related_type = 1', null, array($task_id, $dupe_of[1]));
             if (!$existing) {
                 $db->x->autoExecute('{related}', array('this_task' => $task_id, 'related_task' => $dupe_of[1], 'related_type' => 1));
             }
             Backend::add_vote($task['opened_by'], $dupe_of[1]);
         }
     }
     return true;
 }
Exemplo n.º 4
0
 function action_addvote($task)
 {
     global $user, $db, $fs, $proj;
     if (Backend::add_vote($user->id, $task['task_id'])) {
         return array(SUBMIT_OK, L('voterecorded'));
     } else {
         return array(ERROR_RECOVER, L('votefailed'));
     }
 }