function build_number() { $request =& HTTPRequest::instance(); $group_id = $request->get('group_id'); if ($request->exist('build')) { $build_id = $request->get('build'); } else { $build_id = $request->get('build_id'); } $job_dao = new PluginHudsonJobDao(CodendiDataAccess::instance()); if ($request->exist('job_id')) { $job_id = $request->get('job_id'); $dar = $job_dao->searchByJobID($job_id); } elseif ($request->exist('job')) { // used for references (build #MyJob/175 or job #myproject:MyJob/175 where 175 is the build number required) $job_name = $request->get('job'); $dar = $job_dao->searchByJobName($job_name, $group_id); } else { // used for references (build #175 where 175 is the build number required) // If no job or project is specified, we check if there is only one job associated to the current project and we assume it is this job. $dar = $job_dao->searchByGroupID($group_id); if ($dar->rowCount() != 1) { $dar = null; } } if ($dar && $dar->valid()) { $row = $dar->current(); $crossref_fact = new CrossReferenceFactory($row['name'] . '/' . $build_id, 'hudson_build', $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<b> ' . $GLOBALS['Language']->getText('cross_ref_fact_include', 'references') . '</b>'; $crossref_fact->DisplayCrossRefs(); } $this->_display_iframe($row['job_url'] . '/' . $build_id . '/'); } else { echo '<span class="error">' . $GLOBALS['Language']->getText('plugin_hudson', 'error_object_not_found') . '</span>'; } }
function show_commit_details($result) { global $group_id, $commit_id, $Language; /* Accepts a result set from the commits table. Should include all columns from the table, and it should be joined to USER to get the user_name. */ $rows = db_numrows($result); $url = "/cvs/?func=detailcommit&commit_id={$commit_id}&group_id={$group_id}&order="; $list_log = '<pre>' . util_make_links(util_line_wrap(db_result($result, 0, 'description')), $group_id) . '</pre>'; if ($commit_id) { $hdr = '[' . $Language->getText('cvs_commit_utils', 'commit') . $commit_id . '] - '; } else { $hdr = $Language->getText('cvs_commit_utils', 'checkin') . ' '; } echo '<h2>' . $hdr . uniformat_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, 'c_when')) . '</h2></h2>'; echo '<table WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2"><tr class="' . util_get_alt_row_color(0) . '"><td>' . $list_log . '</td></tr></table>'; $crossref_fact = new CrossReferenceFactory($commit_id, ReferenceManager::REFERENCE_NATURE_CVSCOMMIT, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<h3> ' . $Language->getText('cross_ref_fact_include', 'references') . '</h3>'; $crossref_fact->DisplayCrossRefs(); } echo '<h3>' . $Language->getText('cvs_commit_utils', 'impacted_file') . '</h3>'; $title_arr = array(); $title_arr[] = $Language->getText('cvs_commit_utils', 'file'); $title_arr[] = $Language->getText('cvs_commit_utils', 'rev'); $title_arr[] = $Language->getText('cvs_commit_utils', 'branch'); $title_arr[] = $Language->getText('cvs_commit_utils', 'type'); $title_arr[] = $Language->getText('cvs_commit_utils', 'added_line'); $title_arr[] = $Language->getText('cvs_commit_utils', 'removed_line'); $links_arr = array(); $links_arr[] = $url . 'filename'; $links_arr[] = $url . 'revision'; $links_arr[] = $url . 'branch'; $links_arr[] = $url . 'type'; $links_arr[] = $url . 'addedlines'; $links_arr[] = $url . 'removedlines'; echo html_build_list_table_top($title_arr, $links_arr); for ($i = 0; $i < $rows; $i++) { $commit_id = db_result($result, $i, 'id'); $type = db_result($result, $i, 'type'); $added = db_result($result, $i, 'addedlines'); $removed = db_result($result, $i, 'removedlines'); $revision = db_result($result, $i, 'revision'); $filename = db_result($result, $i, 'dir') . '/' . db_result($result, $i, 'file'); $type_text = $Language->getText('cvs_commit_utils', strtolower($type)); if ($type == "Change" && $added == 999 && $removed == 999) { // the default values // back to rcs to complete $repo = db_result($result, $i, 'repository'); $command = "rlog -r" . $revision . " " . $repo . "/" . $filename; $output = array(); exec($command, $output, $ret); $added = 0; $removed = 0; $l = 0; while ($l < count($output)) { // parse the rlog result till getting "state: Exp; lines:" $line = $output[$l]; $l++; if (ereg('state: +Exp; +lines: +\\+([0-9]*) +\\-([0-9]*)$', $line, $na)) { $added = $na[1]; $removed = $na[2]; $sql_up = "UPDATE cvs_checkins SET addedlines=" . $added . ", removedlines=" . $removed . " WHERE repositoryid=" . db_result($result, $i, 'repositoryid') . " AND dirid=" . db_result($result, $i, 'dirid') . " AND fileid=" . db_result($result, $i, 'fileid') . " AND revision=" . $revision; $res = db_query($sql_up); break; } } } if (!$filename) { $filename = ''; } else { if ($type == 'Remove') { $filename = makeCvsDirLink($group_id, db_result($result, $i, 'file'), $filename, db_result($result, $i, 'dir')); $rev_text = ''; } else { // Clean file path to remove duplicate separators $filename = preg_replace('/\\/\\//', '/', $filename); $filename = preg_replace('/\\.\\//', '', $filename); if ($type == 'Change') { // horrible hack to 'guess previous revision' to diff with $prev = explode(".", $revision); $lastIndex = sizeof($prev); $lastIndex = $lastIndex - 1; if ($prev[$lastIndex] != '1') { $prev[$lastIndex] = $prev[$lastIndex] - 1; $previous = join(".", $prev); } else { $index = 0; $new_prev = array(); while ($index <= $lastIndex - 2) { $new_prev[$index] = $prev[$index]; $index++; } $previous = join('.', $new_prev); } $type = makeCvsLink($group_id, $filename, $type_text, '', '&r1=' . $previous . '&r2=' . $revision); } $rev_text = makeCvsLink($group_id, $filename, $revision, $revision, '&view=markup'); $filename = makeCvsLink($group_id, $filename, $filename, '', '&view=log'); } } ##$commits_url = '<A HREF="/commits/download.php/Commits'.$commit_id.'.txt?commit_id='.$id.'">'.$filename.'</a>'; echo ' <TR class="' . util_get_alt_row_color($i) . '">' . '<TD class="small"><b>' . $filename . '</b></TD>' . '<TD class="small">' . $rev_text . '</TD>' . '<TD class="small">' . db_result($result, $i, 'branch') . '</TD>' . '<TD class="small">' . $type . '</TD>' . '<TD class="small">' . $added . '</TD>' . '<TD class="small">' . $removed . '</TD></TR>'; } /* Show extra rows for <-- Prev / Next --> */ echo ' <TR><TD COLSPAN="2" class="small">'; if ($offset > 0) { echo '<A HREF="?func=browse&group_id=' . $group_id . '&set=' . $set . '&offset=' . ($offset - 50) . '"><B>< ' . $Language->getText('global', 'prev') . '</B></A>'; } else { echo ' '; } echo '</TD><TD> </TD><TD COLSPAN="2" class="small">'; if ($rows == 50) { echo '<A HREF="?func=browse&group_id=' . $group_id . '&set=' . $set . '&offset=' . ($offset + 50) . '"><B>' . $Language->getText('global', 'prev') . ' 50 ></B></A>'; } else { echo ' '; } echo '</TD></TR></TABLE>'; }
$pv_param = "&pv=" . $pv; } else { $pv_param = ""; } $ret_val .= '<B><span> <A HREF="/forum/forum.php?max_rows=' . $max_rows . '&style=' . $style . '&offset=' . ($offset + $i) . '&forum_id=' . $forum_id . '' . $pv_param . '"> <B>' . $Language->getText('forum_forum', 'next_msg') . ' <IMG SRC="' . util_get_image_theme("t.png") . '" HEIGHT=15 WIDTH=15 BORDER=0 ALIGN=center></A></span>'; } else { $ret_val .= ' '; } $ret_val .= '</TD></TABLE>'; } } echo $ret_val; $crossref_fact = new CrossReferenceFactory($forum_id, ReferenceManager::REFERENCE_NATURE_FORUM, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>'; $crossref_fact->DisplayCrossRefs(); } if (!isset($pv) || !$pv) { echo '<P> <P>'; echo '<h3>' . $Language->getText('forum_forum', 'start_new_thread') . ':</H3><a name="start_new_thread"></a>'; show_post_form($forum_id); } forum_footer($params); } else { forum_header(array('title' => $Language->getText('global', 'error'))); echo '<H1' . $Language->getText('forum_forum', 'choose_forum_first') . '</H1>'; forum_footer(array()); }
function svn_utils_show_revision_detail($result, $group_id, $group_name, $commit_id) { global $Language; /* Accepts a result set from the svn_checkins table. Should include all columns from the table, and it should be joined to USER to get the user_name. */ $rows = db_numrows($result); $url = "/svn/?func=detailrevision&commit_id={$commit_id}&group_id={$group_id}&order="; $list_log = '<pre>' . util_make_links(util_line_wrap(db_result($result, 0, 'description')), $group_id) . '</pre>'; $revision = db_result($result, 0, 'revision'); $hdr = '[' . $Language->getText('svn_browse_revision', 'rev') . ' #' . $revision . '] - '; echo '<h2>' . $hdr . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, 'date')) . '</h2></h2>'; echo '<table WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2"><tr class="' . util_get_alt_row_color(0) . '"><td>' . $list_log . '</td></tr></table>'; $crossref_fact = new CrossReferenceFactory($revision, ReferenceManager::REFERENCE_NATURE_SVNREVISION, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<h3> ' . $Language->getText('cross_ref_fact_include', 'references') . '</h3>'; $crossref_fact->DisplayCrossRefs(); } echo '<h3> ' . $Language->getText('svn_utils', 'impacted_files') . '</h3>'; $title_arr = array(); $title_arr[] = $Language->getText('svn_utils', 'file'); $title_arr[] = $Language->getText('svn_browse_revision', 'rev'); $title_arr[] = $Language->getText('svn_utils', 'type'); //$title_arr[]='AddedLines'; To be implemented //$title_arr[]='RemovedLines'; To be implemented $links_arr = array(); $links_arr[] = $url . 'filename'; $links_arr[] = $url . ''; $links_arr[] = $url . 'type'; $pm = ProjectManager::instance(); $project = $pm->getProject($group_id); $root = $project->getUnixName(); echo html_build_list_table_top($title_arr, $links_arr); for ($i = 0; $i < $rows; $i++) { $type = db_result($result, $i, 'type'); $dirname = db_result($result, $i, 'dir'); $filename = db_result($result, $i, 'file'); $fullpath = $dirname . $filename; if ($filename) { // It' a file $viewfile_url = svn_utils_make_viewlink($group_name, $fullpath, $fullpath, "&pathrev={$revision}&view=log"); $viewrev_url = svn_utils_make_viewlink($group_name, $fullpath, $revision, "&revision={$revision}&pathrev={$revision}&view=markup"); } else { // It' a directory $viewfile_url = svn_utils_make_viewlink($group_name, $fullpath, $fullpath, "&pathrev={$revision}"); $viewrev_url = svn_utils_make_viewlink($group_name, $fullpath, $revision, "&pathrev={$revision}&view=log"); } if ($type == 'Change') { $viewtype_url = svn_utils_make_viewlink($group_name, $fullpath, $Language->getText('svn_utils', 'change'), "&r1=" . ($revision - 1) . "&r2={$revision}&diff_format=h&pathrev={$revision}"); } else { if ($type == 'Add') { $viewtype_url = $Language->getText('svn_utils', 'add'); } else { if ($type == 'Delete') { $viewtype_url = $Language->getText('svn_utils', 'del'); } } } echo ' <TR class="' . util_get_alt_row_color($i) . '">' . '<TD class="small"><b>' . $viewfile_url . '</b></TD>' . '<TD class="small" width="10%" align="center">' . $viewrev_url . '</TD>' . '<TD class="small" width="10%" align="center">' . $viewtype_url . '</TD>'; //'<TD class="small">'.$added.'</TD>'. // To be done //'<TD class="small">'.$removed.'</TD></TR>'; // To be done } echo '</TD></TR></TABLE>'; }
function forum_header($params) { global $HTML, $group_id, $forum_name, $thread_id, $msg_id, $forum_id, $et, $et_cookie, $Language; $hp = Codendi_HTMLPurifier::instance(); $uh = new UserHelper(); $params['group'] = $group_id; $params['toptab'] = 'forum'; $params['help'] = 'WebForums.html'; /* bastardization for news Show icon bar unless it's a news forum */ if ($group_id == $GLOBALS['sys_news_group']) { //this is a news item, not a regular forum if ($forum_id) { /* Show this news item at the top of the page */ $sql = "SELECT * FROM news_bytes WHERE forum_id=" . db_ei($forum_id); $result = db_query($sql); //backwards shim for all "generic news" that used to be submitted //as of may, "generic news" is not permitted - only project-specific news if (db_result($result, 0, 'group_id') != $GLOBALS['sys_news_group']) { $params['group'] = db_result($result, 0, 'group_id'); $params['toptab'] = 'news'; $group_id = db_result($result, 0, 'group_id'); site_project_header($params); } else { $HTML->header($params); echo ' <H2>' . $GLOBALS['sys_name'] . ' <A HREF="/news/">' . $Language->getText('forum_forum_utils', 'news') . '</A></H2><P>'; } echo '<TABLE><TR><TD VALIGN="TOP">'; if (!$result || db_numrows($result) < 1) { echo ' <h3>' . $Language->getText('forum_forum_utils', 'news_not_found') . '</h3>'; } else { echo ' <B>' . $Language->getText('forum_forum_utils', 'posted_by') . ':</B> ' . $hp->purify($uh->getDisplayNameFromUserId(db_result($result, 0, 'submitted_by')), CODENDI_PURIFIER_CONVERT_HTML) . '<BR> <B>' . $Language->getText('forum_forum', 'date') . ':</B> ' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, 0, 'date')) . '<BR> <B>' . $Language->getText('forum_forum_utils', 'summary') . ':</B><A HREF="/forum/forum.php?forum_id=' . db_result($result, 0, 'forum_id') . '">' . db_result($result, 0, 'summary') . '</A> <P> ' . util_make_links(nl2br(db_result($result, 0, 'details')), $group_id); echo '<P>'; $crossref_fact = new CrossReferenceFactory($forum_id, ReferenceManager::REFERENCE_NATURE_NEWS, $group_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { echo '<b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>'; $crossref_fact->DisplayCrossRefs(); } } echo '</TD><TD VALIGN="TOP" WIDTH="35%">'; echo $HTML->box1_top($Language->getText('forum_forum_utils', 'proj_latest_news'), 0); echo news_show_latest(db_result($result, 0, 'group_id'), 5, false); echo $HTML->box1_bottom(); echo '</TD></TR></TABLE>'; } } else { //this is just a regular forum, not a news item site_project_header($params); } /* Show horizontal forum links */ if ($forum_id && $forum_name) { echo '<P><H3>' . $Language->getText('forum_forum_utils', 'discuss_forum') . ': <A HREF="/forum/forum.php?forum_id=' . $forum_id . '">' . $forum_name . '</A></H3>'; } if (!isset($params['pv']) || isset($params['pv']) && !$params['pv']) { echo '<P><B>'; $request =& HTTPRequest::instance(); if ($forum_id && user_isloggedin() && !$request->exist('delete')) { if (user_monitor_forum($forum_id, user_getid())) { $msg = $Language->getText('forum_forum_utils', 'stop_monitor'); } else { $msg = $Language->getText('forum_forum_utils', 'monitor'); } echo '<A HREF="/forum/monitor.php?forum_id=' . $forum_id . '">'; echo html_image("ic/monitor_forum.png", array()) . ' ' . $msg . '</A> | '; echo '<A HREF="/forum/monitor_thread.php?forum_id=' . $forum_id . '"> ' . html_image("ic/monitor_thread.png", array()) . $Language->getText('forum_forum_utils', 'monitor_thread') . '</A> | '; echo '<A HREF="/forum/save.php?forum_id=' . $forum_id . '">'; echo html_image("ic/save.png", array()) . ' ' . $Language->getText('forum_forum_utils', 'save_place') . '</A> | '; print ' <a href="forum.php?forum_id=' . $forum_id . '#start_new_thread">'; echo html_image("ic/thread.png", array()) . ' ' . $Language->getText('forum_forum_utils', 'start_thread') . '</A> | '; if (isset($msg_id) && $msg_id) { echo "<A HREF='" . $_SERVER['PHP_SELF'] . "?msg_id={$msg_id}&pv=1'><img src='" . util_get_image_theme("msg.png") . "' border='0'> " . $Language->getText('global', 'printer_version') . "</A> | "; } else { echo "<A HREF='" . $_SERVER['PHP_SELF'] . "?forum_id={$forum_id}&pv=1'><img src='" . util_get_image_theme("msg.png") . "' border='0'> " . $Language->getText('global', 'printer_version') . "</A> | "; } } // The forum admin link is only displayed for the forum moderators if (user_ismember($group_id, 'F2')) { echo ' <A HREF="/forum/admin/?group_id=' . $group_id . '">' . $Language->getText('forum_forum_utils', 'admin') . '</A></B>'; if (isset($params['help']) && $params['help']) { echo ' | '; } } if (isset($params['help']) && $params['help']) { echo help_button($params['help'], false, $Language->getText('global', 'help')); } echo '</B><P>'; } }