Пример #1
0
 /**
  * Update changeset relations to affected bugs.
  */
 function save_bugs($p_user_id = null)
 {
     $t_bug_table = plugin_table('bug', 'Source');
     $this->bugs = array_unique($this->bugs);
     $this->__bugs = array_unique($this->__bugs);
     $t_bugs_added = array_unique(array_diff($this->bugs, $this->__bugs));
     $t_bugs_deleted = array_unique(array_diff($this->__bugs, $this->bugs));
     $this->load_repo();
     $t_vcs = SourceVCS::repo($this->repo);
     $t_user_id = (int) $p_user_id;
     if ($t_user_id < 1) {
         if ($this->committer_id > 0) {
             $t_user_id = $this->committer_id;
         } else {
             if ($this->user_id > 0) {
                 $t_user_id = $this->user_id;
             }
         }
     }
     if (count($t_bugs_deleted)) {
         $t_bugs_deleted_str = join(',', $t_bugs_deleted);
         $t_query = "DELETE FROM {$t_bug_table} WHERE change_id=" . $this->id . " AND bug_id IN ( {$t_bugs_deleted_str} )";
         db_query_bound($t_query);
         foreach ($t_bugs_deleted as $t_bug_id) {
             plugin_history_log($t_bug_id, 'changeset_removed', $this->repo->name . ' ' . $t_vcs->show_changeset($this->repo, $this), '', $t_user_id, 'Source');
             bug_update_date($t_bug_id);
         }
     }
     if (count($t_bugs_added) > 0) {
         $t_query = "INSERT INTO {$t_bug_table} ( change_id, bug_id ) VALUES ";
         $t_count = 0;
         $t_params = array();
         foreach ($t_bugs_added as $t_bug_id) {
             $t_query .= ($t_count == 0 ? '' : ', ') . '(' . db_param() . ', ' . db_param() . ')';
             $t_params[] = $this->id;
             $t_params[] = $t_bug_id;
             $t_count++;
         }
         db_query_bound($t_query, $t_params);
         foreach ($t_bugs_added as $t_bug_id) {
             plugin_history_log($t_bug_id, 'changeset_attached', '', $this->repo->name . ' ' . $t_vcs->show_changeset($this->repo, $this), $t_user_id, 'Source');
             bug_update_date($t_bug_id);
         }
     }
 }
 function delete()
 {
     $t_update_table = plugin_table('update', 'Timecard');
     $t_hours = plugin_lang_get('hours');
     $t_query = "DELETE FROM {$t_update_table} WHERE id=" . db_param();
     db_query_bound($t_query, array($this->id));
     plugin_history_log($this->bug_id, 'time_spent_removed', $this->__spent . $t_hours, '', null, 'Timecard');
     $this->id = 0;
 }