/** * 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); } } }
/** * Display a list of changeset objects in tabular format. * Assumes that a table with four columns has already been defined. * @param array Changeset objects * @param array Repository objects */ function Source_View_Changesets($p_changesets, $p_repos = null, $p_show_repos = true) { if (!is_array($p_changesets)) { return; } if (is_null($p_repos) || !is_array($p_repos)) { $t_repos = SourceRepo::load_by_changesets($p_changesets); } else { $t_repos = $p_repos; } $t_use_porting = config_get('plugin_Source_enable_porting'); foreach ($p_changesets as $t_changeset) { $t_repo = $t_repos[$t_changeset->repo_id]; $t_vcs = SourceVCS::repo($t_repo); $t_changeset->load_files(); $t_author = Source_View_Author($t_changeset, false); $t_committer = Source_View_Committer($t_changeset, false); ?> <tr class="row-1"> <td class="category" width="25%" rowspan="<?php echo count($t_changeset->files) + 1; ?> "> <a name="changeset<?php echo $t_changeset->id; ?> "><?php echo string_display(($p_show_repos ? $t_repo->name . ': ' : '') . $t_vcs->show_changeset($t_repo, $t_changeset)); ?> </a> <br/><span class="small"><?php echo plugin_lang_get('timestamp', 'Source'), ': ', string_display_line($t_changeset->timestamp); ?> </span> <br/><span class="small"><?php echo plugin_lang_get('author', 'Source'), ': ', $t_author; ?> </span> <?php if ($t_committer && $t_committer != $t_author) { ?> <br/><span class="small"><?php echo plugin_lang_get('committer', 'Source'), ': ', $t_committer; ?> </span><?php } ?> <?php if ($t_use_porting) { ?> <br/><span class="small"><?php echo plugin_lang_get('ported', 'Source'), ': ', $t_changeset->ported ? string_display_line($t_changeset->ported) : (is_null($t_changeset->ported) ? plugin_lang_get('pending', 'Source') : plugin_lang_get('na', 'Source')); ?> </span> <?php } ?> <br/><span class="small-links"> <?php print_bracket_link(plugin_page('view', false, 'Source') . '&id=' . $t_changeset->id, plugin_lang_get('details', 'Source')); if ($t_url = $t_vcs->url_changeset($t_repo, $t_changeset)) { print_bracket_link($t_url, plugin_lang_get('diff', 'Source')); } ?> </td> <td colspan="3"><?php # The commit message is manually transformed (adding href, bug and bugnote # links + nl2br) instead of calling string_display_links(), which avoids # unwanted html tags processing by the MantisCoreFormatting plugin. # Rationale: commit messages being plain text, any html they may contain # should not be considered as formatting and must be displayed as-is. echo string_nl2br(string_process_bugnote_link(string_process_bug_link(string_insert_hrefs(string_html_specialchars($t_changeset->message))))); ?> </td> </tr> <?php foreach ($t_changeset->files as $t_file) { ?> <tr class="row-2"> <td class="small mono" colspan="2"><?php echo string_display_line($t_vcs->show_file($t_repo, $t_changeset, $t_file)); ?> </td> <td class="center" width="12%"><span class="small-links"> <?php if ($t_url = $t_vcs->url_diff($t_repo, $t_changeset, $t_file)) { print_bracket_link($t_url, plugin_lang_get('diff', 'Source')); } if ($t_url = $t_vcs->url_file($t_repo, $t_changeset, $t_file)) { print_bracket_link($t_url, plugin_lang_get('file', 'Source')); } ?> </span></td> </tr> <?php } ?> <tr><td class="spacer"></td></tr> <?php } }
if (!$t_valid) { die(plugin_lang_get('invalid_checkin_url')); } # Let plugins try to intepret POST data before we do $t_predata = event_signal('EVENT_SOURCE_PRECOMMIT'); # Expect plugin data in form of array( repo_name, data ) if (is_array($t_predata) && count($t_predata) == 2) { $t_repo = $t_predata['repo']; $f_data = $t_predata['data']; } else { $f_repo_name = gpc_get_string('repo_name', ''); $f_data = gpc_get_string('data'); # Try to find the repository by name $t_repo = SourceRepo::load_by_name($f_repo_name); } # Repo not found if (is_null($t_repo)) { die(plugin_lang_get('invalid_repo')); } $t_vcs = SourceVCS::repo($t_repo); # Let the plugins handle commit data $t_changesets = $t_vcs->commit($t_repo, $f_data); # Changesets couldn't be loaded apparently if (!is_array($t_changesets)) { die(plugin_lang_get('invalid_changeset')); } # No more changesets to checkin if (count($t_changesets) < 1) { return; } Source_Process_Changesets($t_changesets);
/** * Display a list of changeset objects in tabular format. * Assumes that a table with four columns has already been defined. * @param array Changeset objects * @param array Repository objects */ function Source_View_Changesets($p_changesets, $p_repos = null, $p_show_repos = true) { if (!is_array($p_changesets)) { return; } if (is_null($p_repos) || !is_array($p_repos)) { $t_repos = SourceRepo::load_by_changesets($p_changesets); } else { $t_repos = $p_repos; } $t_use_porting = config_get('plugin_Source_enable_porting'); foreach ($p_changesets as $t_changeset) { $t_repo = $t_repos[$t_changeset->repo_id]; $t_vcs = SourceVCS::repo($t_repo); $t_changeset->load_files(); $t_author = Source_View_Author($t_changeset, false); $t_committer = Source_View_Committer($t_changeset, false); ?> <tr class="row-1"> <td class="category" width="25%" rowspan="<?php echo count($t_changeset->files) + 1; ?> "> <a name="changeset<?php echo $t_changeset->id; ?> "><?php echo string_display(($p_show_repos ? $t_repo->name . ': ' : '') . $t_vcs->show_changeset($t_repo, $t_changeset)); ?> </a> <br/><span class="small"><?php echo plugin_lang_get('timestamp', 'Source'), ': ', string_display_line($t_changeset->timestamp); ?> </span> <br/><span class="small"><?php echo plugin_lang_get('author', 'Source'), ': ', $t_author; ?> </span> <?php if ($t_committer && $t_committer != $t_author) { ?> <br/><span class="small"><?php echo plugin_lang_get('committer', 'Source'), ': ', $t_committer; ?> </span><?php } ?> <?php if ($t_use_porting) { ?> <br/><span class="small"><?php echo plugin_lang_get('ported', 'Source'), ': ', $t_changeset->ported ? string_display_line($t_changeset->ported) : (is_null($t_changeset->ported) ? plugin_lang_get('pending', 'Source') : plugin_lang_get('na', 'Source')); ?> </span> <?php } ?> <br/><span class="small-links"> <?php print_bracket_link(plugin_page('view', false, 'Source') . '&id=' . $t_changeset->id, plugin_lang_get('details', 'Source')); if ($t_url = $t_vcs->url_changeset($t_repo, $t_changeset)) { print_bracket_link($t_url, plugin_lang_get('diff', 'Source')); } ?> </td> <td colspan="3"><?php echo string_display_links($t_changeset->message); ?> </td> </tr> <?php foreach ($t_changeset->files as $t_file) { ?> <tr class="row-2"> <td class="small mono" colspan="2"><?php echo string_display_line($t_vcs->show_file($t_repo, $t_changeset, $t_file)); ?> </td> <td class="center" width="12%"><span class="small-links"> <?php if ($t_url = $t_vcs->url_diff($t_repo, $t_changeset, $t_file)) { print_bracket_link($t_url, plugin_lang_get('diff', 'Source')); } if ($t_url = $t_vcs->url_file($t_repo, $t_changeset, $t_file)) { print_bracket_link($t_url, plugin_lang_get('file', 'Source')); } ?> </span></td> </tr> <?php } ?> <tr><td class="spacer"></td></tr> <?php } }