} # Not validated by this point gets the boot! 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;
/** * Load/cache repo object. */ function load_repo() { if (is_null($this->repo)) { $t_repos = SourceRepo::load_by_changesets($this); $this->repo = array_shift($t_repos); } }
<?php # Copyright (c) 2012 John Reese # Licensed under the MIT license form_security_validate('plugin_Source_repo_delete'); access_ensure_global_level(plugin_config_get('manage_threshold')); $f_repo_id = gpc_get_string('id'); $t_repo = SourceRepo::load($f_repo_id); helper_ensure_confirmed(sprintf(plugin_lang_get('ensure_delete'), $t_repo->name), plugin_lang_get('delete_repository')); SourceRepo::delete($t_repo->id); form_security_purge('plugin_Source_repo_delete'); print_successful_redirect(plugin_page('index', true));
<?php # Copyright (c) 2012 John Reese # Licensed under the MIT license require_once config_get('plugin_path') . 'Source/Source.ViewAPI.php'; access_ensure_global_level(plugin_config_get('view_threshold')); $f_offset = gpc_get_int('offset', 1); $f_perpage = 25; require_once config_get('plugin_path') . 'Source' . DIRECTORY_SEPARATOR . 'Source.FilterAPI.php'; # Generate listing list($t_filter, $t_permalink) = Source_Generate_Filter(); list($t_changesets, $t_count) = $t_filter->find($f_offset); $t_repos = SourceRepo::load_by_changesets($t_changesets); html_page_top1(plugin_lang_get('title')); html_page_top2(); ?> <br/> <table class="width100" align="center" cellspacing="1"> <tr> <td class="form-title" colspan="2"><?php echo plugin_lang_get('search_changesets'); ?> </td> <td class="right" colspan="2"> <?php print_bracket_link(plugin_page('search') . $t_permalink, plugin_lang_get('permalink')); print_bracket_link(plugin_page('search_page') . $t_permalink, plugin_lang_get('modify_search')); print_bracket_link(plugin_page('search_page'), plugin_lang_get('new_search')); ?>
$t_valid = true; } # Not validated by this point gets the boot! if (!$t_valid) { die(plugin_lang_get('invalid_import_url')); } $f_repo_id = strtolower(gpc_get_string('id')); # Load an array of repositories to be imported if ($f_repo_id == 'all') { $t_repos = SourceRepo::load_all(); } elseif (is_numeric($f_repo_id)) { $t_repo_id = (int) $f_repo_id; $t_repos = array(SourceRepo::load($t_repo_id)); } else { $f_repo_name = $f_repo_id; $t_repos = array(SourceRepo::load_from_name($f_repo_name)); } # Loop through all repos to be imported foreach ($t_repos as $t_repo) { $t_vcs = SourceVCS::repo($t_repo); # keep checking for more changesets to import $t_repo->import_error = false; while (true) { # import the next batch of changesets $t_changesets = $t_vcs->import_latest($t_repo); # check for errors if (!is_array($t_changesets)) { $t_repo->import_error = true; break; } # if no more entries, we're done
<?php # Copyright (c) 2012 John Reese # Licensed under the MIT license form_security_validate('plugin_Source_repo_update_mappings'); access_ensure_global_level(plugin_config_get('manage_threshold')); $f_repo_id = gpc_get_int('id'); $t_repo = SourceRepo::load($f_repo_id); $t_type = SourceType($t_repo->type); $t_mappings = $t_repo->load_mappings(); # start processing the updated form entries for each mapping foreach ($t_mappings as $t_mapping) { $t_posted_branch = str_replace('.', '_', $t_mapping->branch); $f_mapping_delete = gpc_get_bool($t_posted_branch . '_delete', false); if ($f_mapping_delete) { $t_mapping->delete(); continue; } $f_mapping_branch = gpc_get_string($t_posted_branch . '_branch', $t_mapping->branch); $f_mapping_type = gpc_get_int($t_posted_branch . '_type', $t_mapping->type); if (Source_PVM()) { $f_mapping_pvm_version_id = gpc_get_int($t_posted_branch . '_pvm_version_id', $t_mapping->pvm_version_id); } else { $f_mapping_version = gpc_get_string($t_posted_branch . '_version', $t_mapping->version); } $f_mapping_regex = gpc_get_string($t_posted_branch . '_regex', $t_mapping->regex); $t_update = false; # determine changes and if updates need to be made if ($t_mapping->branch != $f_mapping_branch) { $t_mapping->branch = $f_mapping_branch; $t_update = true;
/** * 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 } }
<?php # Copyright (c) 2012 John Reese # Licensed under the MIT license form_security_validate('plugin_Source_repo_create'); access_ensure_global_level(plugin_config_get('manage_threshold')); $f_repo_name = gpc_get_string('repo_name'); $f_repo_type = gpc_get_string('repo_type'); $t_repo = new SourceRepo($f_repo_type, $f_repo_name); $t_repo->save(); form_security_purge('plugin_Source_repo_create'); print_successful_redirect(plugin_page('repo_update_page', true) . '&id=' . $t_repo->id);
<?php # Copyright (c) 2012 John Reese # Licensed under the MIT license helper_begin_long_process(); form_security_validate('plugin_Source_repo_import_latest'); access_ensure_global_level(plugin_config_get('manage_threshold')); helper_ensure_confirmed(plugin_lang_get('ensure_import_latest'), plugin_lang_get('import_latest')); $f_repo_id = strtolower(gpc_get_string('id')); $t_repo_id = (int) $f_repo_id; $t_repos = array(SourceRepo::load($t_repo_id)); $t_repo = array_shift($t_repos); $t_vcs = SourceVCS::repo($t_repo); $t_repo->pre_stats = $t_repo->stats(); html_page_top(); ?> <br/> <table class="width60" align="center"> <tr> <td class="" colspan="2"><?php echo plugin_lang_get('import_results'); ?> </td> </tr> <?php # keep checking for more changesets to import $t_repo->import_error = false; while (true) { # import the next batch of changesets
<?php # Copyright (c) 2012 John Reese # Licensed under the MIT license access_ensure_global_level(plugin_config_get('view_threshold')); $t_can_manage = access_has_global_level(plugin_config_get('manage_threshold')); $t_show_stats = plugin_config_get('show_repo_stats'); $t_class = $t_show_stats ? 'width75' : 'width60'; $t_title_span = $t_show_stats ? 2 : 1; $t_links_span = $t_show_stats ? 4 : 2; $t_repos = SourceRepo::load_all(); html_page_top1(plugin_lang_get('title')); html_page_top2(); ?> <br/> <table class="<?php echo $t_class; ?> " align="center" cellspacing="1"> <tr> <td class="form-title" colspan="<?php echo $t_title_span; ?> "><?php echo plugin_lang_get('repositories'); ?> </td> <td class="right" colspan="<?php echo $t_links_span;
/** * 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 } }