function getTable($params) { $this->defaultUrl = $params['default_url']; $content = ''; $content .= html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_docman', 'view_documenttable_title'), $GLOBALS['Language']->getText('plugin_docman', 'view_documenttable_location'), $GLOBALS['Language']->getText('plugin_docman', 'admin_lock_infos_who'), $GLOBALS['Language']->getText('plugin_docman', 'admin_lock_infos_when'))); // Get list of all locked documents in the project. $dPM = Docman_PermissionsManager::instance($params['group_id']); $lockInfos = $dPM->getLockFactory()->getProjectLockInfos($params['group_id']); $uH = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); require_once dirname(__FILE__) . '/../Docman_ItemFactory.class.php'; $dIF = new Docman_ItemFactory($params['group_id']); $altRowClass = 0; foreach ($lockInfos as $row) { $trclass = html_get_alt_row_color($altRowClass++); $item = $dIF->getItemFromDb($row['item_id']); $parent = $dIF->getItemFromDb($item->getParentId()); $content .= '<tr class="' . $trclass . '">'; $content .= '<td>' . '<a href="/plugins/docman/?group_id=' . $params['group_id'] . '&action=details&id=' . $item->getId() . '">' . $item->getTitle() . '</a></td>'; $content .= '<td>'; if ($dIF->isRoot($parent)) { $content .= '</td>'; } else { $content .= '<a href="' . $this->defaultUrl . '&action=show&id=' . $parent->getId() . '">' . $parent->getTitle() . '</a></td>'; } $content .= '<td>' . $hp->purify($uH->getDisplayNameFromUserId($row['user_id'])) . '</td>'; $content .= '<td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $row['lock_date']) . '</td>'; $content .= '</tr>'; } $content .= '</table>'; return $content; }
public function getContent() { $request =& HTTPRequest::instance(); $group_id = $request->get('group_id'); $pm = ProjectManager::instance(); $project = $pm->getProject($group_id); $res_admin = db_query("SELECT user.user_id AS user_id,user.user_name AS user_name, user.realname as realname " . "FROM user,user_group " . "WHERE user_group.user_id=user.user_id AND user_group.group_id=" . db_ei($group_id) . " AND " . "user_group.admin_flags = 'A'"); if (db_numrows($res_admin) > 0) { $user_helper = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); $em = EventManager::instance(); echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_admins') . ':</span><br />'; while ($row_admin = db_fetch_array($res_admin)) { $display_name = ''; $em->processEvent('get_user_display_name', array('user_id' => $row_admin['user_id'], 'user_name' => $row_admin['user_name'], 'realname' => $row_admin['realname'], 'user_display_name' => &$display_name)); if (!$display_name) { $display_name = $hp->purify($user_helper->getDisplayNameFromUserId($row_admin['user_id'])); } echo '<a href="/users/' . $row_admin['user_name'] . '/">' . $display_name . '</a><br />'; } } echo '<span class="develtitle">' . $GLOBALS['Language']->getText('include_project_home', 'proj_members') . ':</span><br />'; // count of developers on this project $res_count = db_query("SELECT user_id FROM user_group WHERE group_id=" . db_ei($group_id)); echo db_numrows($res_count); echo ' <a href="/project/memberlist.php?group_id=' . $group_id . '">[' . $GLOBALS['Language']->getText('include_project_home', 'view_members') . ']</a>'; }
function getContent() { $html = ''; $i = 1; $UH = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); while ($data = db_fetch_array($this->getLatestRevisions())) { $html .= '<div class="' . util_get_alt_row_color($i++) . '" style="border-bottom:1px solid #ddd">'; $html .= '<div style="font-size:0.98em;">'; $html .= '<a href="' . $this->_getLinkToCommit($data) . '">#' . $data['revision'] . '</a>'; $html .= ' by '; if (isset($data['whoid'])) { $name = $UH->getDisplayNameFromUserId($data['whoid']); } else { $name = $UH->getDisplayNameFromUserName($data['who']); } $html .= $hp->purify($name, CODENDI_PURIFIER_CONVERT_HTML) . ' on '; //In the db, svn dates are stored as int whereas cvs dates are stored as timestamp $html .= format_date($GLOBALS['Language']->getText('system', 'datefmt'), is_numeric($data['date']) ? $data['date'] : strtotime($data['date'])); $html .= '</div>'; $html .= '<div style="padding-left:20px; padding-bottom:4px; color:#555">'; $html .= util_make_links(substr($data['description'], 0, 255), $this->group_id); if (strlen($data['description']) > 255) { $html .= ' [...]'; } $html .= '</div>'; $html .= '</div>'; } $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">'; $html .= '<a href="' . $this->_getLinkToMore() . '">[ More ]</a>'; $html .= '</div>'; return $html; }
public function getContent() { $html = ''; $uh = UserHelper::instance(); $request = HTTPRequest::instance(); $hp = Codendi_HTMLPurifier::instance(); $user = UserManager::instance()->getCurrentUser(); $pm = ProjectManager::instance(); $project_ids = $user->getProjects(); foreach ($project_ids as $project_id) { $project = $pm->getProject($project_id); if ($project->usesSVN()) { list($hide_now, $count_diff, $hide_url) = my_hide_url('my_svn_group', $project_id, $request->get('hide_item_id'), count($project_ids), $request->get('hide_my_svn_group')); $html .= $hide_url; $html .= '<strong>' . $project->getPublicName() . '</strong>'; if (!$hide_now) { list($latest_revisions, $nb_revisions) = svn_get_revisions($project, 0, $this->_nb_svn_commits, '', $user->getUserName(), '', '', 0, false); if (db_numrows($latest_revisions) > 0) { $i = 0; while ($data = db_fetch_array($latest_revisions)) { $html .= '<div class="' . util_get_alt_row_color($i++) . '" style="border-bottom:1px solid #ddd">'; $html .= '<div style="font-size:0.98em;">'; $html .= '<a href="' . $this->_getLinkToCommit($project->getGroupId(), $data['revision']) . '">rev #' . $data['revision'] . '</a>'; $html .= ' ' . $GLOBALS['Language']->getText('my_index', 'my_latest_svn_commit_on') . ' '; //In the db, svn dates are stored as int whereas cvs dates are stored as timestamp $html .= format_date($GLOBALS['Language']->getText('system', 'datefmt'), is_numeric($data['date']) ? $data['date'] : strtotime($data['date'])); $html .= ' ' . $GLOBALS['Language']->getText('my_index', 'my_latest_svn_commit_by') . ' '; if (isset($data['whoid'])) { $name = $uh->getDisplayNameFromUserId($data['whoid']); } else { $name = $uh->getDisplayNameFromUserName($data['who']); } $html .= $hp->purify($name, CODENDI_PURIFIER_CONVERT_HTML); $html .= '</div>'; $html .= '<div style="padding-left:20px; padding-bottom:4px; color:#555">'; $html .= util_make_links(substr($data['description'], 0, 255), $project->getGroupId()); if (strlen($data['description']) > 255) { $html .= ' [...]'; } $html .= '</div>'; $html .= '</div>'; } $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">'; $html .= '<a href="' . $this->_getLinkToMore($project->getGroupId(), $user->getUserName()) . '">[ More ]</a>'; $html .= '</div>'; } else { $html .= '<div></div>'; } } else { $html .= '<div></div>'; } } } return $html; }
function getContent() { $content = ''; $uh = UserHelper::instance(); if (is_a($this->item, 'Docman_File')) { $content .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions') . '</h3>'; $version_factory =& new Docman_VersionFactory(); $approvalFactory =& Docman_ApprovalTableFactory::getFromItem($this->item); if ($versions = $version_factory->getAllVersionForItem($this->item)) { if (count($versions)) { $titles = array(); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_version'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_date'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_author'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_label'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_changelog'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_approval'); $titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_delete_version'); $content .= html_build_list_table_top($titles, false, false, false); $odd_even = array('boxitem', 'boxitemalt'); $i = 0; foreach ($versions as $key => $nop) { $download = Docman_View_View::buildUrl($this->url, array('action' => 'show', 'id' => $this->item->getId(), 'version_number' => $versions[$key]->getNumber())); $delete = Docman_View_View::buildUrl($this->url, array('action' => 'confirmDelete', 'id' => $this->item->getId(), 'version' => $versions[$key]->getNumber())); $user = $versions[$key]->getAuthorId() ? $uh->getDisplayNameFromUserId($versions[$key]->getAuthorId()) : $GLOBALS['Language']->getText('plugin_docman', 'details_history_anonymous'); $content .= '<tr class="' . $odd_even[$i++ % count($odd_even)] . '">'; $content .= '<td align="center"><a href="' . $download . '">' . $versions[$key]->getNumber() . '</a></td>'; $content .= '<td>' . html_time_ago($versions[$key]->getDate()) . '</td>'; $content .= '<td>' . $this->hp->purify($user) . '</td>'; $content .= '<td>' . $this->hp->purify($versions[$key]->getLabel()) . '</td>'; $content .= '<td>' . $this->hp->purify($versions[$key]->getChangelog(), CODENDI_PURIFIER_LIGHT) . '</td>'; $table = $approvalFactory->getTableFromVersion($versions[$key]); if ($table != null) { $appTable = Docman_View_View::buildUrl($this->url, array('action' => 'details', 'section' => 'approval', 'id' => $this->item->getId(), 'version' => $versions[$key]->getNumber())); $content .= '<td align="center"><a href="' . $appTable . '">' . ($titles[] = $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_approval_show') . '</a></td>'); } else { $content .= '<td></td>'; } $content .= '<td align="center"><a href="' . $delete . '"><img src="' . util_get_image_theme("ic/trash.png") . '" height="16" width="16" border="0"></a></td>'; $content .= '</tr>'; } $content .= '</table>'; } else { $content .= '<div>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_no') . '</div>'; } } else { $content .= '<div>' . $GLOBALS['Language']->getText('plugin_docman', 'details_history_versions_error') . '</div>'; } } if ($this->logger) { $content .= $this->logger->fetchLogsForItem($this->item->getId(), $this->display_access_logs); } return $content; }
function getContent() { $html = ''; $dwItemFactory = $this->getDocmanWatermarkItemFactory(); $watermarkingIsDisabled = $dwItemFactory->isWatermarkingDisabled($this->item->getId()); // Status if ($watermarkingIsDisabled) { $status = '<strong>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_disabled') . '</strong>'; } else { $status = $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_enabled'); } $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_status', array($status)) . '</p>'; // About section $html .= '<h2>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_about_title') . '</h2>'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_disclamer_pdf') . '</p>'; // Disable/enable section $user = $this->getUserManager()->getCurrentUser(); $dPm = $this->getDocman_PermissionsManager($this->item->getGroupId()); if ($dPm->userCanManage($user, $this->item->getId())) { $html .= '<h2>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_toggle_title') . '</h2>'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_desc') . '</p>'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_clicktoproceed') . '</p>'; $html .= '<form method="post" action="' . $this->url . '&item_id=' . $this->item->getId() . '&action=docmanwatermark_toggle_item">'; if ($watermarkingIsDisabled) { $html .= '<input type="submit" name="enable_watermarking" value="' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_enableit') . '" />'; } else { $html .= '<input type="submit" name="disable_watermarking" value="' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_watermarking_disableit') . '" />'; } $html .= '</form>'; } // History $html .= '<h2>' . $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_title') . '</h2>'; $dwLog = $this->getDocmanWatermark_Log(); $dar = $dwLog->getLog($this->item); if ($dar && $dar->rowCount() > 0) { $uh = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); $titles = array($GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_when'), $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_who'), $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_what')); $html .= html_build_list_table_top($titles, false, false, false); $altColor = 0; foreach ($dar as $logEntry) { $html .= '<tr class="' . html_get_alt_row_color($altColor++) . '">'; $html .= '<td>' . util_timestamp_to_userdateformat($logEntry['time']) . '</td>'; $html .= '<td>' . $hp->purify($uh->getDisplayNameFromUserId($logEntry['who'])) . '</td>'; $html .= '<td>' . ($logEntry['watermarked'] == 0 ? $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_desactivate') : $GLOBALS['Language']->getText('plugin_docmanwatermark', 'details_history_activate')) . '</td>'; $html .= '</tr>'; } $html .= '</table>'; } return $html; }
function snippet_show_package_snippets($version) { global $Language; //show the latest version $sql = "SELECT snippet.snippet_id, snippet_package_item.snippet_version_id, snippet_version.version,snippet.name,user.user_name, snippet_version.filesize " . "FROM snippet,snippet_version,snippet_package_item,user " . "WHERE snippet.snippet_id=snippet_version.snippet_id " . "AND user.user_id=snippet_version.submitted_by " . "AND snippet_version.snippet_version_id=snippet_package_item.snippet_version_id " . "AND snippet_package_item.snippet_package_version_id='{$version}'"; $result = db_query($sql); $rows = db_numrows($result); echo ' <P> <H3>' . $Language->getText('snippet_add_snippet_to_package', 's_in_p') . '</H3> <P>'; $title_arr = array(); $title_arr[] = $Language->getText('snippet_utils', 'version_id'); $title_arr[] = $Language->getText('snippet_details', 's_version'); $title_arr[] = $Language->getText('snippet_browse', 'title'); $title_arr[] = $Language->getText('snippet_details', 'author'); echo html_build_list_table_top($title_arr, $links_arr); if (!$result || $rows < 1) { echo db_error(); echo ' <TR><TD COLSPAN="4"><H3>' . $Language->getText('snippet_add_snippet_to_package', 'no_s_in_p') . '</H3></TD></TR>'; } else { //get the newest version, so we can display it's code $newest_version = db_result($result, 0, 'snippet_version_id'); for ($i = 0; $i < $rows; $i++) { echo ' <TR class="' . util_get_alt_row_color($i) . '"> <TD><A HREF="/snippet/detail.php?type=snippet&id=' . db_result($result, $i, 'snippet_id') . '"><b><center>' . db_result($result, $i, 'snippet_version_id') . '</center></b></A></TD> <TD>'; echo '<A HREF="/snippet/download.php?type=snippet&id=' . db_result($result, $i, 'snippet_version_id') . '"><b><center>' . db_result($result, $i, 'version') . '</b></A>'; // For uploaded files, the user can choose between view or display the code snippet if (db_result($result, $i, 'filesize') != 0) { // View link : the file is forced to be displayed as a text echo ' <a href="/snippet/download.php?mode=view&type=snippet&id=' . db_result($result, $i, 'snippet_version_id') . '">'; echo '<img src="' . util_get_image_theme("ic/view.png") . '" border="0" alt="' . $Language->getText('snippet_details', 'view') . '" title="' . $Language->getText('snippet_details', 'view') . '"></a>'; // Download link : the file is forced to be downloaded echo ' <a href="/snippet/download.php?mode=download&type=snippet&id=' . db_result($result, $i, 'snippet_version_id') . '">'; echo '<img src="' . util_get_image_theme("ic/download.png") . '" border="0" alt="' . $Language->getText('snippet_details', 'download') . '" title="' . $Language->getText('snippet_details', 'download') . '"></a>'; } $user = UserManager::instance()->getUserByUserName(db_result($result, $i, 'user_name')); echo '</center></TD> <TD>' . db_result($result, $i, 'name') . '</TD><TD>' . UserHelper::instance()->getLinkOnUser($user) . '</TD></TR>'; } } echo '</TABLE>'; }
function forum_show_a_nested_message($result, $row = 0) { /* accepts a database result handle to display a single message in the format appropriate for the nested messages second param is which row in that result set to use */ global $Language; $g_id = db_result($result, $row, 'group_id'); if ($g_id == $GLOBALS['sys_news_group']) { $f_id = db_result($result, $row, 'group_forum_id'); $gr = db_query("SELECT group_id FROM news_bytes WHERE forum_id=" . db_ei($f_id)); $g_id = db_result($gr, 0, 'group_id'); } $poster = UserManager::instance()->getUserByUserName(db_result($result, $i, 'user_name')); $ret_val = ' <TABLE BORDER="0" WIDTH="100%"> <TR> <TD class="thread" NOWRAP>' . $Language->getText('forum_forum', 'by') . ': ' . UserHelper::instance()->getLinkOnUser($poster) . '<BR><A HREF="/forum/message.php?msg_id=' . db_result($result, $row, 'msg_id') . '">' . '<IMG SRC="' . util_get_image_theme("msg.png") . '" BORDER=0 HEIGHT=12 WIDTH=10> ' . db_result($result, $row, 'subject') . ' [ ' . $Language->getText('forum_forum', 'reply') . ' ]</A> ' . '<BR>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), db_result($result, $row, 'date')) . ' </TD> </TR> <TR> <TD> ' . util_make_links(nl2br(db_result($result, $row, 'body')), $g_id) . ' </TD> </TR>'; $crossref_fact = new CrossReferenceFactory(db_result($result, $row, 'msg_id'), ReferenceManager::REFERENCE_NATURE_FORUMMESSAGE, $g_id); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { $ret_val .= '<tr>'; $ret_val .= ' <td class="forum_reference_separator">'; $ret_val .= ' <b> ' . $Language->getText('cross_ref_fact_include', 'references') . '</b>'; $ret_val .= $crossref_fact->getHTMLDisplayCrossRefs(); $ret_val .= ' </td>'; $ret_val .= '</tr>'; } $ret_val .= ' <tr> <td> </td> </tr> </TABLE>'; return $ret_val; }
function display_user_result_table($res) { $user_helper = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); $nb_cols = 3; if (db_numrows($res)) { echo '<table><tr>'; $i = 0; while ($data = db_fetch_array($res)) { if ($i++ % $nb_cols == 0) { echo '</tr><tr>'; } $action = 'add'; $background = 'eee'; if ($data['is_on']) { $action = 'remove'; $background = 'dcf7c4'; } echo '<td width="' . round(100 / $nb_cols) . '%">'; echo '<div style="border:1px solid #CCC; background: #' . $background . '; padding:10px 5px; position:relative">'; echo '<table width="100%"><tr><td><a href="/users/' . $hp->purify($data['user_name']) . '/">' . $hp->purify($user_helper->getDisplayName($data['user_name'], $data['realname'])) . '</a></td>'; echo '<td style="text-align:right;">'; project_admin_display_bullet_user($data['user_id'], $action); echo '</td></tr></table>'; echo '<div style="color:#666; ">' . $data['email'] . '</div>'; echo '</div>'; echo '</td>'; } while ($i++ % $nb_cols != 0) { echo '<td width="' . round(100 / $nb_cols) . '%"></td>'; } echo '</tr></table>'; } else { echo 'No user match'; echo db_error(); } }
/** * Get the "order by" statement to retrieve field values */ public function getQueryOrderby() { $uh = UserHelper::instance(); $R1 = 'R1_' . $this->field->id; $R2 = 'R2_' . $this->field->id; return "{$R2}.ugroup_id"; }
/** * Returns the HTML code of this comment * * @return string the HTML code of this comment */ public function fetchFollowUp() { if ($this->hasEmptyBody()) { return null; } $uh = UserHelper::instance(); $html = '<div class="tracker_artifact_followup_comment_edited_by">'; if ($this->parent_id) { $html .= $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'last_edited'); $html .= ' ' . $uh->getLinkOnUserFromUserId($this->submitted_by) . ' '; $html .= DateHelper::timeAgoInWords($this->submitted_on, false, true); } $html .= '</div>'; if (!empty($this->body)) { $html .= '<input type="hidden" id="tracker_artifact_followup_comment_body_format_' . $this->changeset->getId() . '" name="tracker_artifact_followup_comment_body_format_' . $this->changeset->getId() . '" value="' . $this->bodyFormat . '" />'; $html .= '<div class="tracker_artifact_followup_comment_body">'; if ($this->parent_id && !trim($this->body)) { $html .= '<em>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'comment_cleared') . '</em>'; } else { $html .= $this->getPurifiedBodyForHTML(); } $html .= '</div>'; } return $html; }
function getTableHistory() { $html = ''; $uh = UserHelper::instance(); if (is_a($this->table, 'Docman_ApprovalTableVersionned')) { $html .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_history_title') . '</h3>'; $html .= html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_docman', 'details_approval_history_table_version'), $GLOBALS['Language']->getText('plugin_docman', 'details_approval_history_table_owner'), $GLOBALS['Language']->getText('plugin_docman', 'details_approval_history_table_status'), $GLOBALS['Language']->getText('plugin_docman', 'details_approval_history_table_date'))); $allTables = $this->atf->getAllApprovalTable(); $rowColorIdx = 1; foreach ($allTables as $table) { $html .= '<tr class="' . html_get_alt_row_color($rowColorIdx++) . '">'; if ($this->table->getVersionNumber() != $table->getVersionNumber()) { $url = Docman_View_View::buildUrl($this->url, array('action' => 'details', 'section' => 'approval', 'id' => $this->item->getId(), 'version' => $table->getVersionNumber())); $href = '<a href="' . $url . '">' . $table->getVersionNumber() . '</a>'; } else { $href = $table->getVersionNumber(); } $html .= '<td>' . $href . '</td>'; $html .= '<td>' . $this->hp->purify($uh->getDisplayNameFromUserId($table->getOwner())) . '</td>'; $html .= '<td>' . $GLOBALS['Language']->getText('plugin_docman', 'approval_review_state_' . $table->getApprovalState()) . '</td>'; $html .= '<td>' . util_timestamp_to_userdateformat($table->getDate()) . '</td>'; $html .= '</tr>'; } $html .= '</table>'; } return $html; }
/** * Returns the artifact followup for mail rendering * * @param array $recipient * @param string $format, the mail format text or html * @param bool $ignore_perms, indicates if we ignore various permissions * * @return String */ public function fetchMailFollowUp($recipient, $format, $ignore_perms = false) { $uh = UserHelper::instance(); $um = UserManager::instance(); $cs = $this->getChangesets(); $hp = Codendi_HTMLPurifier::instance(); $output = ''; foreach ($cs as $changeset) { $comment = $changeset->getComment(); $changes = $changeset->diffToPrevious($format, $recipient, $ignore_perms); if (empty($comment)) { //do not display empty comment continue; } switch ($format) { case 'html': $followup = $comment->fetchFollowUp($format, true); if (!empty($followup)) { if (!isset($output)) { $output = '<h2>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'follow_ups') . '</h2>'; } $output .= '<div class="tracker_artifact_followup_header">'; $output .= $followup; $output .= '</div>'; } break; case 'text': $user = $um->getUserById($comment->submitted_by); $output .= PHP_EOL; $output .= '----------------------------- '; $output .= PHP_EOL; $output .= $GLOBALS['Language']->getText('plugin_tracker_artifact', 'mail_followup_date') . util_timestamp_to_userdateformat($comment->submitted_on); $output .= "\t" . $GLOBALS['Language']->getText('plugin_tracker_artifact', 'mail_followup_by') . $uh->getDisplayNameFromUser($user); $output .= PHP_EOL; $output .= $comment->getPurifiedBodyForText(); $output .= PHP_EOL; $output .= PHP_EOL; break; default: $output .= '<!-- TODO -->'; break; } } return $output; }
protected function _showProjectAdmins() { $html = ''; $hp = Codendi_HTMLPurifier::instance(); $request = HTTPRequest::instance(); $vFunc = new Valid_WhiteList('plugin_admindelegation_func', array('show_admins')); $vFunc->required(); if ($request->valid($vFunc)) { $func = $request->get('plugin_admindelegation_func'); } else { $func = ''; } $vGroup = new Valid_String('plugin_admindelegation_group'); $vGroup->required(); if ($request->valid($vGroup)) { $pm = ProjectManager::instance(); $project = $pm->getProjectFromAutocompleter($request->get('plugin_admindelegation_group')); if ($project && $project->isActive()) { $groupValue = $project->getPublicName() . ' (' . $project->getUnixName() . ')'; } else { $groupValue = ''; } } else { $project = false; $groupValue = ''; } $html .= '<form method="post" action="?">'; $html .= '<label>' . $GLOBALS['Language']->getText('plugin_admindelegation', 'widget_admins_label') . '</label>'; $html .= '<input type="hidden" name="plugin_admindelegation_func" value="show_admins" />'; $html .= '<input type="text" name="plugin_admindelegation_group" value="' . $groupValue . '" size ="40" id="plugin_admindelegation_group" />'; $html .= ' '; $html .= '<input type="submit" value="' . $GLOBALS['Language']->getText('plugin_admindelegation', 'widget_btn_search') . '"/>'; $html .= '</form>'; $js = "new ProjectAutoCompleter('plugin_admindelegation_group', '" . util_get_dir_image_theme() . "', false);"; $GLOBALS['HTML']->includeFooterJavascriptSnippet($js); if ($func == 'show_admins' && $project && $project->isActive()) { $allAdmins = array(); $users = $this->getProjectAdmins($project->getId()); if (count($users) > 0) { $uh = UserHelper::instance(); $html .= '<table width="100%">'; $html .= '<theader>'; $html .= '<tr>'; $html .= '<th>' . $GLOBALS['Language']->getText('plugin_admindelegation', 'widget_admins_name') . '</th>'; $html .= '<th>' . $GLOBALS['Language']->getText('plugin_admindelegation', 'widget_admins_email') . '</th>'; $html .= '</tr>'; $html .= '</theader>'; $html .= '<tbody>'; $i = 1; foreach ($users as $u) { $mailto = $u->getRealname() . ' <' . $u->getEmail() . '>'; $allAdmins[] = $mailto; $html .= '<tr class="' . util_get_alt_row_color($i++) . '">'; $html .= '<td>' . $hp->purify($uh->getDisplayNameFromUser($u)) . '</td>'; $html .= '<td><a href="mailto:' . $mailto . '">' . $u->getEmail() . '</a></td>'; $html .= '</tr>'; } $html .= '</tbody>'; $html .= '</table>'; // Mail to all admins $html .= '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">'; $html .= '<a href="mailto:' . implode(',', $allAdmins) . '?Subject=' . $GLOBALS['Language']->getText('plugin_admindelegation', 'widget_admins_mass_mail_subject', array($GLOBALS['sys_name'], $project->getPublicName())) . '">' . $GLOBALS['Language']->getText('plugin_admindelegation', 'widget_admins_mass_mail') . '</a>'; $html .= '</div>'; } } return $html; }
function _getReviewerTable() { $html = ''; $uh = UserHelper::instance(); $html .= '<h3>' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_table_title') . '</h3>'; $html .= '<div id="docman_approval_table_create_table">'; if (!$this->table->isClosed()) { $html .= '<div class="docman_help">' . $GLOBALS['Language']->getText('plugin_docman', 'details_approval_table_help') . '</div>'; } $rIter = $this->table->getReviewerIterator(); if ($rIter !== null) { $docmanIcons =& $this->_getDocmanIcons(); $html .= html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_docman', 'details_approval_select'), $GLOBALS['Language']->getText('plugin_docman', 'details_approval_reviewer'), $GLOBALS['Language']->getText('plugin_docman', 'details_approval_review'), $GLOBALS['Language']->getText('plugin_docman', 'details_approval_rank')), false, false, false); $isFirst = true; $isLast = false; $nbReviewers = $rIter->count(); $i = 0; $rIter->rewind(); while ($rIter->valid()) { $isLast = $i == $nbReviewers - 1; $reviewer = $rIter->current(); // i+1 to start with 'white' $html .= '<tr class="' . html_get_alt_row_color($i + 1) . '">'; // Select if (!$this->table->isClosed()) { $checkbox = '<input type="checkbox" name="sel_user[]" value="' . $reviewer->getId() . '" />'; } else { $checkbox = ' '; } $html .= '<td align="center">' . $checkbox . '</td>'; // Username $html .= '<td>' . $this->hp->purify($uh->getDisplayNameFromUserId($reviewer->getId())) . '</td>'; // Review $html .= '<td>' . $this->atf->getReviewStateName($reviewer->getState()) . '</td>'; // Rank if (!$this->table->isClosed()) { $rank = $reviewer->getRank(); $baseUrl = '?group_id=' . $this->item->getGroupId() . '&action=approval_upd_user&id=' . $this->item->getId() . '&user_id=' . $reviewer->getId() . '&rank='; $begLink = ''; $upLink = ''; if (!$isFirst) { $begIcon = '<img src="' . $docmanIcons->getIcon('move-beginning') . '" alt="Beginning" />'; $begLink = '<a href="' . $baseUrl . 'beginning">' . $begIcon . '</a>'; $upIcon = '<img src="' . $docmanIcons->getIcon('move-up') . '" alt="Up" />'; $upLink = '<a href="' . $baseUrl . 'up">' . $upIcon . '</a>'; } $endLink = ''; $downLink = ''; if (!$isLast) { $endIcon = '<img src="' . $docmanIcons->getIcon('move-end') . '" alt="End" />'; $endLink = '<a href="' . $baseUrl . 'end">' . $endIcon . '</a>'; $downIcon = '<img src="' . $docmanIcons->getIcon('move-down') . '" alt="Down" />'; $downLink = '<a href="' . $baseUrl . 'down">' . $downIcon . '</a>'; } $rankHtml = $upLink . ' ' . $downLink . ' ' . $begLink . ' ' . $endLink; } else { $rankHtml = ' '; } $html .= '<td align="center">' . $rankHtml . '</td>'; $html .= '</tr>'; $isFirst = false; $i++; $rIter->next(); } $html .= '</table>'; // Action with selected reviewers if (!$this->table->isClosed()) { $html .= '<p>'; $html .= $GLOBALS['Language']->getText('plugin_docman', 'details_approval_create_table_act'); $vals = array('del', 'mail'); $txts = array($GLOBALS['Language']->getText('plugin_docman', 'details_approval_create_table_act_rm'), $GLOBALS['Language']->getText('plugin_docman', 'details_approval_create_table_act_mail')); $html .= html_build_select_box_from_arrays($vals, $txts, 'sel_user_act', 100, true); $html .= '</p>'; } } $html .= '</div>'; return $html; }
/** * Check membership of the user to a specified ugroup * $group_id is necessary for automatic project groups like project member, release admin, etc. * $atid is necessary for trackers since the tracker admin role is different for each tracker. * $keword is used to filter the users */ function ugroup_db_get_dynamic_members($ugroup_id, $atid, $group_id, $with_display_preferences = false, $keyword = null, $show_suspended = false) { $sqlname = "user.user_name AS full_name"; $sqlorder = "user.user_name"; if ($with_display_preferences) { $uh = UserHelper::instance(); $sqlname = $uh->getDisplayNameSQLQuery(); $sqlorder = $uh->getDisplayNameSQLOrder(); } $having_keyword = ''; if ($keyword) { $keyword = "'%" . db_es((string) $keyword) . "%'"; $having_keyword = " HAVING full_name LIKE {$keyword} "; } $user_status = "( status='A' OR status='R' "; if ($show_suspended) { $user_status .= "OR status='S'"; } $user_status .= ")"; // Special Cases if ($ugroup_id == $GLOBALS['UGROUP_NONE']) { // Empty group return; } else { if ($ugroup_id == $GLOBALS['UGROUP_ANONYMOUS']) { // Anonymous user return; } else { if ($ugroup_id == $GLOBALS['UGROUP_REGISTERED']) { // Registered user return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM user WHERE " . $user_status . " {$having_keyword} ORDER BY " . $sqlorder . " )"; } else { if ($ugroup_id == $GLOBALS['UGROUP_PROJECT_MEMBERS']) { // Project members return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM user, user_group ug WHERE user.user_id = ug.user_id AND ug.group_id = {$group_id} AND " . $user_status . " {$having_keyword} ORDER BY " . $sqlorder . ")"; } else { if ($ugroup_id == $GLOBALS['UGROUP_FILE_MANAGER_ADMIN']) { // File manager admins return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM user, user_group ug WHERE user.user_id = ug.user_id AND ug.group_id = {$group_id} AND file_flags = 2 AND " . $user_status . " {$having_keyword} ORDER BY " . $sqlorder . ")"; } else { if ($ugroup_id == $GLOBALS['UGROUP_DOCUMENT_ADMIN']) { // Document admin return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM user, user_group ug WHERE user.user_id = ug.user_id AND ug.group_id = {$group_id} AND doc_flags IN (2,3) AND " . $user_status . " {$having_keyword} ORDER BY " . $sqlorder . ")"; } else { if ($ugroup_id == $GLOBALS['UGROUP_DOCUMENT_TECH']) { // Document tech return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM user, user_group ug WHERE user.user_id = ug.user_id AND ug.group_id = {$group_id} AND doc_flags IN (1,2) AND " . $user_status . " {$having_keyword} ORDER BY " . $sqlorder . ")"; } else { if ($ugroup_id == $GLOBALS['UGROUP_WIKI_ADMIN']) { // Wiki admins return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM user, user_group ug WHERE user.user_id = ug.user_id AND ug.group_id = {$group_id} AND wiki_flags = '2' AND " . $user_status . " {$having_keyword} ORDER BY " . $sqlorder . ")"; } else { if ($ugroup_id == $GLOBALS['UGROUP_PROJECT_ADMIN']) { // Project admins return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM user, user_group ug WHERE user.user_id = ug.user_id AND ug.group_id = {$group_id} AND admin_flags = 'A' AND " . $user_status . " {$having_keyword} ORDER BY " . $sqlorder . ")"; } else { if ($ugroup_id == $GLOBALS['UGROUP_TRACKER_ADMIN']) { // Tracker admins return "(SELECT user.user_id, " . $sqlname . ", user.user_name FROM artifact_perm ap, user WHERE (user.user_id = ap.user_id) and group_artifact_id={$atid} AND perm_level in (2,3) AND " . $user_status . " ORDER BY " . $sqlorder . ")"; } } } } } } } } } } }
function getAuthorMessage($revision, $only_authenticated = true) { if (!$revision) { return ''; } $dbi =& $GLOBALS['request']->_dbi; $author = $revision->get('author_id'); if ($author or $only_authenticated) { if (!$author) { $author = $revision->get('author'); } if (!$author) { return ''; } //display revision author user_name according to the user choice: real name, or Codendi login if ($author != "The PhpWiki programming team") { $author = UserHelper::instance()->getDisplayNameFromUserName($author); } if ($dbi->isWikiPage($author)) { return fmt("by %s", WikiLink($author)); } else { return fmt("by %s", '"' . $author . '"'); } } }
/** * Display the submit form */ public function displaySearch(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { $hp = Codendi_HTMLPurifier::instance(); $pm = ProjectManager::instance(); $group_id = $request->get('group_id'); $group = $pm->getProject($group_id); if (!$group || !is_object($group) || $group->isError()) { exit_no_group(); } $breadcrumbs = array(array('title' => $GLOBALS['Language']->getText('plugin_tracker_browse', 'search_result'), 'url' => TRACKER_BASE_URL . '/?tracker=' . $this->getId())); $this->displayHeader($layout, $this->name, $breadcrumbs); $html = ''; $words = $request->get('words'); $criteria = 'OR'; if ($request->exist('exact') && $request->get('exact') == '1') { $criteria = 'AND'; } $offset = 0; if ($request->exist('offset')) { $offset = $request->get('offset'); } $limit = 25; $tracker_artifact_dao = new Tracker_ArtifactDao(); $dar = $tracker_artifact_dao->searchByKeywords($this->getId(), $words, $criteria, $offset, $limit); $rows_returned = $tracker_artifact_dao->foundRows(); $no_rows = false; if ($dar->rowCount() < 1 || $rows_returned < 1) { $no_rows = true; $html .= '<h2>' . $GLOBALS['Language']->getText('search_index', 'no_match_found', $hp->purify($words, CODENDI_PURIFIER_CONVERT_HTML)) . '</h2>'; } else { $html .= '<h3>' . $GLOBALS['Language']->getText('search_index', 'search_res', array($hp->purify($words, CODENDI_PURIFIER_CONVERT_HTML), $rows_returned)) . '</h3>'; $title_arr = array(); $art_field_fact = Tracker_FormElementFactory::instance(); $artifact_factory = Tracker_ArtifactFactory::instance(); $user_helper = UserHelper::instance(); $summary_field = $this->getTitleField(); if ($summary_field && $summary_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('plugin_tracker_search_index', 'artifact_title'); } $submitted_field = $art_field_fact->getFormElementByName($this->getId(), 'submitted_by'); if ($submitted_field && $submitted_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('search_index', 'submitted_by'); } $date_field = $art_field_fact->getFormElementByName($this->getId(), 'open_date'); if ($date_field && $date_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('search_index', 'date'); } $status_field = $this->getStatusField(); if ($status_field && $status_field->userCanRead()) { $title_arr[] = $GLOBALS['Language']->getText('global', 'status'); } $html .= html_build_list_table_top($title_arr); $nb_artifacts = 0; while ($row = $dar->getRow()) { $nb_artifacts++; $artifact_id = $row['artifact_id']; $artifact = $artifact_factory->getArtifactById($artifact_id); if ($artifact->userCanView()) { $html .= '<tr class="' . html_get_alt_row_color($nb_artifacts) . '">'; if ($summary_field->userCanRead()) { $html .= '<td><a href="' . TRACKER_BASE_URL . '/?aid=' . $artifact_id . '"><img src="' . util_get_image_theme('msg.png') . '" border="0" height="12" width="10"> ' . $artifact->getTitle() . '</a></td>'; } if ($submitted_field->userCanRead()) { $html .= '<td>' . $hp->purify($user_helper->getDisplayNameFromUserId($artifact->getSubmittedBy())) . '</td>'; } if ($date_field->userCanRead()) { $html .= '<td>' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $artifact->getSubmittedOn()) . '</td>'; } if ($status_field->userCanRead()) { $html .= '<td>' . $artifact->getStatus() . '</td>'; } $html .= '</tr>'; } } $html .= '</table>'; } // Search result pagination if (!$no_rows && ($rows_returned > $nb_artifacts || $offset != 0)) { $html .= '<br />'; $url_params = array('exact' => $request->get('exact') === '1' ? 1 : 0, 'group_id' => $this->getGroupId(), 'tracker' => $this->getId(), 'type_of_search' => 'tracker', 'words' => urlencode($words), 'offset' => $offset - $limit); $html .= '<table class="boxitem" width="100%" cellpadding="5" cellspacing="0">'; $html .= '<tr>'; $html .= '<td align="left">'; if ($offset != 0) { $html .= '<span class="normal"><b>'; $html .= '<a href="/search/?' . http_build_query($url_params); $html .= '">' . "<b><img src=\"" . util_get_image_theme('t2.png') . "\" height=15 width=15 border=0 align=middle> " . $GLOBALS['Language']->getText('search_index', 'prev_res') . " </a></b></span>"; } else { $html .= ' '; } $html .= '</td><td align="right">'; if ($rows_returned > $nb_artifacts && $rows_returned > $offset + $limit) { $url_params['offset'] = $offset + $limit; $html .= '<span class="normal"><b>'; $html .= '<a href="/search/?' . http_build_query($url_params); $html .= '"><b>' . $GLOBALS['Language']->getText('search_index', 'next_res') . ' <img src="' . util_get_image_theme('t.png') . '" height="15" width="15" border="0" align="middle"></a></b></span>'; } else { $html .= ' '; } $html .= '</td></tr>'; $html .= '</table>'; } echo $html; $this->displayFooter($layout); }
/** * Fetch all attachements for Mail output * * @param Integer $artifact_id The artifact Id * @param Array $values The actual value of the field * @param String $format The mail format * * @return String */ protected function fetchMailAllAttachment($artifact_id, $values, $format) { $output = ''; if (!count($values)) { return ''; } $uh = UserHelper::instance(); $proto = $GLOBALS['sys_force_ssl'] ? 'https' : 'http'; $url = $proto . '://' . $GLOBALS['sys_default_domain']; if ($format == 'text') { foreach ($values as $fileinfo) { $query_link = $this->getFileHTMLUrl($fileinfo); $link = '<' . $url . $query_link . '>'; $output .= $fileinfo->getDescription(); $output .= ' | '; $output .= $fileinfo->getFilename(); $output .= ' | '; $output .= $fileinfo->getHumanReadableFilesize(); $output .= ' | '; $output .= $uh->getDisplayNameFromUserId($fileinfo->getSubmittedBy()); $output .= PHP_EOL; $output .= $link; $output .= PHP_EOL; } } else { $hp = Codendi_HTMLPurifier::instance(); $added = array(); foreach ($values as $fileinfo) { $query_link = $this->getFileHTMLUrl($fileinfo); $sanitized_description = $hp->purify($fileinfo->getDescription(), CODENDI_PURIFIER_CONVERT_HTML); $link_show = '<a href="' . $url . $query_link . '" title="' . $sanitized_description . '">'; $info = $link_show . $hp->purify($fileinfo->getFilename(), CODENDI_PURIFIER_CONVERT_HTML) . '</a>'; $info .= ' (' . $fileinfo->getHumanReadableFilesize() . ')'; $add = '<div class="tracker_artifact_attachment">'; $add .= '<table><tr><td>'; $add .= $info; $add .= '</td></tr></table>'; $add .= '</div>'; $added[] = $add; } $output .= implode('', $added); } return $output; }
function svn_utils_show_revision_list($result, $offset, $total_rows, $set = 'any', $commiter = '100', $path = '', $chunksz = 15, $morder = '', $msort = 0) { global $group_id, $Language; /* Accepts a result set from the svn_commits table. Should include all columns from the table, and it should be joined to USER to get the user_name. */ $url = '?func=browse&group_id=' . $group_id . '&set=' . $set . '&msort=' . $msort; if ($set == 'custom') { $url .= $pref_stg; } $url_nomorder = $url; $url .= "&morder={$morder}"; if ($morder != '') { $orderstr = $Language->getText('svn_utils', 'sorted_by') . ' ' . svn_utils_criteria_list_to_text($morder, $url_nomorder); } else { $orderstr = ''; } echo '<A name="results"></A>'; echo '<h3>' . $Language->getText('svn_utils', 'match_ci', $total_rows) . ' ' . $orderstr . '</h3>'; $nav_bar = '<table width= "100%"><tr>'; $nav_bar .= '<td width="20%" align ="left">'; echo '<P>' . $Language->getText('svn_utils', 'sort', $url . '&order=#results') . ' '; if ($msort) { $url_alternate_sort = str_replace('msort=1', 'msort=0', $url) . '&order=#results'; $text = $Language->getText('svn_utils', 'deacti'); } else { $url_alternate_sort = str_replace('msort=0', 'msort=1', $url) . '&order=#results'; $text = $Language->getText('svn_utils', 'acti'); } echo $Language->getText('svn_utils', 'multi_sort', array($url_alternate_sort, $text)) . "\n"; // If all bugs on screen so no prev/begin pointer at all if ($total_rows > $chunksz) { if ($offset > 0) { $nav_bar .= '<A HREF="' . $url . '&offset=0#results"><B><< ' . $Language->getText('global', 'begin') . '</B></A>' . ' ' . '<A HREF="' . $url . '&offset=' . ($offset - $chunksz) . '#results"><B>< ' . $Language->getText('global', 'prev') . ' ' . $chunksz . '</B></A></td>'; } else { $nav_bar .= '<span class="disable"><< ' . $Language->getText('global', 'begin') . ' < ' . $Language->getText('global', 'prev') . ' ' . $chunksz . '</span>'; } } $nav_bar .= '</td>'; $offset_last = min($offset + $chunksz - 1, $total_rows - 1); $nav_bar .= '<td width= "60% " align = "center" class="small">' . $Language->getText('svn_utils', 'items', array($offset + 1, $offset_last + 1)) . "</td>\n"; $nav_bar .= '<td width="20%" align ="right">'; // If all bugs on screen, no next/end pointer at all if ($total_rows > $chunksz) { if ($offset + $chunksz < $total_rows) { $offset_end = $total_rows - $total_rows % $chunksz; if ($offset_end == $total_rows) { $offset_end -= $chunksz; } $nav_bar .= '<A HREF="' . $url . '&offset=' . ($offset + $chunksz) . '#results" class="small"><B>' . $Language->getText('global', 'next') . ' ' . $chunksz . ' ></B></A>' . ' ' . '<A HREF="' . $url . '&offset=' . $offset_end . '#results" class="small"><B>' . $Language->getText('global', 'end') . ' >></B></A></td>'; } else { $nav_bar .= '<span class="disable">' . $Language->getText('global', 'next') . ' ' . $chunksz . ' > ' . $Language->getText('global', 'end') . ' >></span>'; } } $nav_bar .= '</td>'; $nav_bar .= "</tr></table>\n"; echo $nav_bar; $filter_str = ''; if ($commiter != '100') { $filter_str = "&commiter='{$commiter}'"; } if ($path != '') { $filter_str = $filter_str . "&path='{$path}'"; } $url .= "&order="; $title_arr = array(); $title_arr[] = $Language->getText('svn_browse_revision', 'rev'); $title_arr[] = $Language->getText('svn_utils', 'desc'); $title_arr[] = $Language->getText('svn_utils', 'date'); $title_arr[] = $Language->getText('svn_browse_revision', 'commiter'); $links_arr = array(); $links_arr[] = $url . 'revision#results'; $links_arr[] = $url . 'description#results'; $links_arr[] = $url . 'date#results'; $links_arr[] = $url . 'who#results'; $url_nomorder = $url; $url .= "&morder={$morder}"; echo html_build_list_table_top($title_arr, $links_arr); $i = 0; $uh = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); while ($row = db_fetch_array($result)) { // description is escaped in svn-checkins.pl $description = htmlspecialchars_decode($row['description'], ENT_QUOTES); echo ' <TR class="' . util_get_alt_row_color($i++) . '">' . '<TD class="small"><b><A HREF="?func=detailrevision&group_id=' . $group_id . '&commit_id=' . $row['commit_id'] . $filter_str . '">' . $row['revision'] . '</b></A></TD>' . '<TD class="small">' . $hp->purify($description, CODENDI_PURIFIER_BASIC, $group_id) . '</TD>' . '<TD class="small">' . format_date($GLOBALS['Language']->getText('system', 'datefmt'), $row['date']) . '</TD>' . '<TD class="small">' . $uh->getLinkOnUserFromUserId($row['whoid']) . '</TD></TR>'; } /* Show extra rows for <-- Prev / Next --> */ echo '</TD></TR></TABLE>'; echo $nav_bar; }
private function getHeader() { $html = ''; $repoId = $this->repository->getId(); $creator = $this->repository->getCreator(); $parent = $this->repository->getParent(); $access = $this->repository->getAccess(); $creatorName = ''; if (!empty($creator)) { $creatorName = UserHelper::instance()->getLinkOnUserFromUserId($creator->getId()); } // Access type $accessType = $this->getAccessType($access, $this->repository->getBackend() instanceof Git_Backend_Gitolite); $html .= '<h1>' . $accessType . $this->repository->getFullName() . '</h1>'; if (!empty($parent)) { $html .= '<div id="plugin_git_repo_parent">'; $html .= $GLOBALS['Language']->getText('plugin_git', 'view_repo_parent_' . $this->repository->getBackendType(), $parent->getHTMLLink($this->url_manager)); $html .= '</div>'; } return $html; }
/** * Wrapper for UserHelper * * @return UserHelper */ protected function getUserHelper() { return UserHelper::instance(); }
function getValue() { $v = $this->md->getValue(); if ($v != null && $v != '') { $hp = Codendi_HTMLPurifier::instance(); $uh = UserHelper::instance(); return $hp->purify($uh->getDisplayNameFromUserId($v)); } else { return ''; } }
function getDisplayPresence($user_id, $user_name, $realname) { $user_helper = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); $im_object = $this->_get_im_object(); if (isset($im_object) && $im_object) { $jabberConf = $im_object->get_server_conf(); $server_dns = $jabberConf['server_dns']; $jid_value = $user_name . '@' . $server_dns; $adm_port_im = $jabberConf['webadmin_unsec_port']; $presence = $this->getDynamicPresence($jid_value); } else { $presence = ''; } return $presence . $hp->purify($user_helper->getDisplayName($user_name, $realname)); }
/** * Returns the artifact followup for mail rendering * * @param array $recipient * @param string $format, the mail format text or html * @param bool $ignore_perms, indicates if we ignore various permissions * * @return String */ public function fetchMailFollowUp($recipient, $format, $ignore_perms = false) { $uh = UserHelper::instance(); $um = UserManager::instance(); $cs = $this->getChangesets(); $hp = Codendi_HTMLPurifier::instance(); $output = ''; if ($format == 'html') { $output .= '<tr> <td colspan="3" align="left"> <h2>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'follow_ups') . ' </h2> </td> </tr>'; } foreach ($cs as $changeset) { $comment = $changeset->getComment(); /* @var $comment Tracker_Artifact_Changeset_Comment */ if (empty($comment) || $comment->hasEmptyBody()) { //do not display empty comment continue; } switch ($format) { case 'html': $followup = $comment->fetchMailFollowUp($format); $output .= $followup; break; case 'text': $user = $um->getUserById($comment->submitted_by); $output .= PHP_EOL; $output .= '----------------------------- '; $output .= PHP_EOL; $output .= $GLOBALS['Language']->getText('plugin_tracker_artifact', 'mail_followup_date') . util_timestamp_to_userdateformat($comment->submitted_on); $output .= "\t" . $GLOBALS['Language']->getText('plugin_tracker_artifact', 'mail_followup_by') . $uh->getDisplayNameFromUser($user); $output .= PHP_EOL; $output .= $comment->getPurifiedBodyForText(); $output .= PHP_EOL; $output .= PHP_EOL; break; default: $output .= '<!-- TODO -->'; break; } } return $output; }
/** * displayRSS * * Display the follow-ups of this artifact as a rss feed * */ function displayRSS() { $uh = UserHelper::instance(); $hp = Codendi_HTMLPurifier::instance(); $group = $this->ArtifactType->getGroup(); $rss = new RSS(array('title' => $group->getPublicName() . ' ' . $this->ArtifactType->getName() . ' #' . $this->getId() . ' - ' . $this->getValue('summary') . ' - ' . $GLOBALS['Language']->getText('tracker_include_artifact', 'follow_ups'), 'description' => '', 'link' => '<![CDATA[' . get_server_url() . '/tracker/?atid=' . $this->ArtifactType->getID() . '&group_id=' . $group->getGroupId() . ']]>', 'language' => 'en-us', 'copyright' => $GLOBALS['Language']->getText('rss', 'copyright', array($GLOBALS['sys_long_org_name'], $GLOBALS['sys_name'], date('Y', time()))), 'pubDate' => gmdate('D, d M Y h:i:s', $this->getLastUpdateDate()) . ' GMT')); $result = $this->getFollowups(); for ($i = 0; $i < db_numrows($result); $i++) { $comment_type = db_result($result, $i, 'comment_type'); $comment_type_id = db_result($result, $i, 'comment_type_id'); $comment_id = db_result($result, $i, 'artifact_history_id'); $field_name = db_result($result, $i, 'field_name'); $orig_subm = $this->getOriginalCommentSubmitter($comment_id); $orig_date = $this->getOriginalCommentDate($comment_id); if ($comment_type_id == 100 || $comment_type == "") { $comment_type = ''; } else { $comment_type = '<strong>[' . $comment_type . ']</strong><br />'; } $rss->addItem(array('title' => '<![CDATA[' . $GLOBALS['Language']->getText('tracker_include_artifact', 'add_flup_comment') . ' #' . $comment_id . ']]>', 'description' => '<![CDATA[' . $comment_type . util_make_links(nl2br(db_result($result, $i, 'new_value')), $group->getGroupId(), $this->ArtifactType->getID()) . ']]>', 'pubDate' => gmdate('D, d M Y h:i:s', db_result($orig_date, 0, 'date')) . ' GMT', 'dc:creator' => $hp->purify($uh->getDisplayNameFromUserId(db_result($orig_subm, 0, 'mod_by'))), 'link' => '<![CDATA[' . get_server_url() . '/tracker/?func=detail&aid=' . $this->getId() . '&atid=' . $this->ArtifactType->getID() . '&group_id=' . $group->getGroupId() . '#comment_' . $comment_id . ']]>', 'guid' => '<![CDATA[' . get_server_url() . '/tracker/?func=detail&aid=' . $this->getId() . '&atid=' . $this->ArtifactType->getID() . '&group_id=' . $group->getGroupId() . '#comment_' . $comment_id . ']]>')); } $rss->display(); exit; }
/** * This checks whether a wiki page is editable by checking if the user have write permission on it (including items lock check ) * */ function isWikiPageEditable() { $item_factory =& $this->_getItemFactory(); $wiki_page = $this->request->get('wiki_page'); $group_id = $this->request->get('group_id'); $referers = $item_factory->getWikiPageReferencers($wiki_page, $group_id); $uM = UserManager::instance(); $user = $uM->getCurrentUser(); $dPM = Docman_PermissionsManager::instance($group_id); $canWrite = false; if (count($referers) > 0) { foreach ($referers as $item) { //Check if some of referers has locked this wiki page. (should be done through new LockFactory). if (!$dPM->userCanWrite($user, $item->getId())) { $canWrite = false; if ($dPM->getLockFactory()->itemIsLocked($item) === true) { if (!$dPM->getLockFactory()->userIsLocker($item, $user)) { $lockInfos = $dPM->getLockFactory()->getLockInfoForItem($item); if ($lockInfos) { $uH = UserHelper::instance(); $locker = $uH->getDisplayNameFromUserId($lockInfos['user_id']); $message = $GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_page_locked', array($locker)); } break; } } } else { $canWrite = true; } } } else { $canWrite = true; } // TODO: find another way to return a value. // Codendi_Request->params should not be public if ($canWrite) { // User can edit the wiki page. $this->request->params['response'] = true; } else { $this->request->params['response'] = false; if (isset($lockInfos) && $lockInfos) { // User can NOT edit the page because there is a lock on the page and user is not page locker $this->feedback->log('warning', $message); } else { // User can NOT edit the page because he don't have write permission on it. $this->feedback->log('error', $GLOBALS['Language']->getText('plugin_docman', 'error_perms_edit')); } } }
/** * Return the string to display the follow ups comments * * @param Integer group_id: the group id * @param Integer output By default set to OUTPUT_BROWSER, the output is displayed on browser * set to OUTPUT_MAIL_TEXT, the followups will be sent in mail * else is an export csv/DB * @return string the follow-up comments to display in HTML or in ascii mode */ function showFollowUpComments($group_id, $pv, $output = self::OUTPUT_BROWSER) { $hp = $this->getHTMLPurifier(); $uh = UserHelper::instance(); // // Format the comment rows from artifact_history // global $Language; //$group = $this->ArtifactType->getGroup(); $group_artifact_id = $this->ArtifactType->getID(); //$group_id = $group->getGroupId(); $result = $this->getFollowups(); $rows = db_numrows($result); // No followup comment -> return now if ($rows <= 0) { if ($output == self::OUTPUT_EXPORT || $output == self::OUTPUT_MAIL_TEXT) { $out = $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . " " . $Language->getText('tracker_import_utils', 'no_followups') . $GLOBALS['sys_lf']; } else { $out = '<H4>' . $Language->getText('tracker_import_utils', 'no_followups') . '</H4>'; } return $out; } $out = ''; // Header first if ($output == self::OUTPUT_EXPORT || $output == self::OUTPUT_MAIL_TEXT) { $out .= $Language->getText('tracker_include_artifact', 'follow_ups') . $GLOBALS['sys_lf'] . str_repeat("*", strlen($Language->getText('tracker_include_artifact', 'follow_ups'))); } else { if ($rows > 0) { $out .= '<div style="text-align:right">'; $out .= '<script type="text/javascript"> function tracker_expand_all_comments() { $H(tracker_comment_togglers).values().each(function (value) { (value)(null, true, true); }); } function tracker_collapse_all_comments() { $H(tracker_comment_togglers).values().each(function (value) { (value)(null, true, false); }); } var matches = location.hash.match(/#comment_(\\d*)/); var linked_comment_id = matches ? matches[1] : null; </script>'; $out .= '<a href="#expand_all" onclick="tracker_expand_all_comments(); return false;">' . $Language->getText('tracker_include_artifact', 'expand_all') . '</a> | <a href="#expand_all" onclick="tracker_collapse_all_comments(); return false;">' . $Language->getText('tracker_include_artifact', 'collapse_all') . '</a></div>'; } } // Loop throuh the follow-up comments and format them $last_visit_date = user_get_preference('tracker_' . $this->ArtifactType->getId() . '_artifact_' . $this->getId() . '_last_visit'); for ($i = 0; $i < $rows; $i++) { $comment_type = db_result($result, $i, 'comment_type'); $comment_type_id = db_result($result, $i, 'comment_type_id'); $comment_id = db_result($result, $i, 'artifact_history_id'); $field_name = db_result($result, $i, 'field_name'); $orig_subm = $this->getOriginalCommentSubmitter($comment_id); $orig_date = $this->getOriginalCommentDate($comment_id); $value = db_result($result, $i, 'new_value'); $isHtml = db_result($result, $i, 'format'); if ($comment_type_id == 100 || $comment_type == "") { $comment_type = ''; } else { $comment_type = '[' . SimpleSanitizer::unsanitize($comment_type) . ']'; } if ($output == self::OUTPUT_EXPORT || $output == self::OUTPUT_MAIL_TEXT) { $fmt = $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . "------------------------------------------------------------------" . $GLOBALS['sys_lf'] . $Language->getText('tracker_import_utils', 'date') . ": %-30s" . $Language->getText('global', 'by') . ": %s" . $GLOBALS['sys_lf'] . "%s"; //The mail body $comment_txt = $this->formatFollowUp($group_id, $isHtml, $value, $output); $out .= sprintf($fmt, format_date(util_get_user_preferences_export_datefmt(), db_result($orig_date, 0, 'date')), db_result($orig_subm, 0, 'mod_by') == 100 ? db_result($orig_subm, 0, 'email') : user_getname(db_result($orig_subm, 0, 'mod_by')), ($comment_type != '' ? $comment_type . $GLOBALS['sys_lf'] : '') . $comment_txt); } else { $style = ''; $toggle = 'ic/toggle_minus.png'; if ($last_visit_date > db_result($orig_date, 0, 'date') && $i > 0) { $style = 'style="display:none;"'; $toggle = 'ic/toggle_plus.png'; } $out .= "\n" . ' <div class="followup_comment" id="comment_' . $comment_id . '"> <div class="' . util_get_alt_row_color($i) . ' followup_comment_header"> <div class="followup_comment_title">'; $out .= '<script type="text/javascript">document.write(\'<span>'; $out .= $GLOBALS['HTML']->getImage($toggle, array('id' => 'comment_' . (int) $comment_id . '_toggle', 'style' => 'vertical-align:middle; cursor:hand; cursor:pointer;', 'title' => addslashes($GLOBALS['Language']->getText('tracker_include_artifact', 'toggle')))); $out .= '</span>\');</script>'; $out .= '<script type="text/javascript">'; $out .= "tracker_comment_togglers[" . (int) $comment_id . "] = function (evt, force, expand) {\n var toggle = \$('comment_" . (int) $comment_id . "_toggle');\n var element = \$('comment_" . (int) $comment_id . "_content');\n if (element) {\n if (!force || (expand && !element.visible()) || (!expand && element.visible())) {\n Element.toggle(element);\n \n //replace image\n var src_search = 'toggle_minus';\n var src_replace = 'toggle_plus';\n if (toggle.src.match('toggle_plus')) {\n src_search = 'toggle_plus';\n src_replace = 'toggle_minus';\n }\n toggle.src = toggle.src.replace(src_search, src_replace);\n }\n }\n if (evt) {\n Event.stop(evt);\n }\n return false;\n };\n Event.observe(\$('comment_" . (int) $comment_id . "_toggle'), 'click', tracker_comment_togglers[" . (int) $comment_id . "]);"; $out .= '</script>'; $out .= '<span><a href="#comment_' . (int) $comment_id . '" title="Link to this comment - #' . (int) $comment_id . '" onclick="tracker_comment_togglers[' . (int) $comment_id . '](null, true, true);">'; $out .= $GLOBALS['HTML']->getImage('ic/comment.png', array('border' => 0, 'style' => 'vertical-align:middle', 'title' => 'Link to this comment - #' . (int) $comment_id)); $out .= '</a> </span>'; $out .= '<span class="followup_comment_title_user">'; if (db_result($orig_subm, 0, 'mod_by') == 100) { $out .= db_result($orig_subm, 0, 'email'); } else { $out .= '<a href="/users/' . urlencode(user_getname(db_result($orig_subm, 0, 'mod_by'))) . '">' . $hp->purify($uh->getDisplayNameFromUserId(db_result($orig_subm, 0, 'mod_by')), CODENDI_PURIFIER_CONVERT_HTML) . '</a>'; } $out .= ' </span>'; $out .= '<span class="followup_comment_title_date">'; $out .= html_time_ago(db_result($orig_date, 0, 'date')); $out .= '</span>'; if ($field_name != "comment") { $out .= " (" . $GLOBALS['Language']->getText('tracker_include_artifact', 'last_edited') . " "; $out .= '<span class="followup_comment_title_edited_user">'; if (db_result($result, $i, 'mod_by') == 100) { $out .= db_result($result, $i, 'email'); } else { $out .= '<a href="/users/' . urlencode(user_getname(db_result($result, $i, 'mod_by'))) . '">' . $hp->purify(user_getname(db_result($result, $i, 'mod_by')), CODENDI_PURIFIER_CONVERT_HTML) . '</a>'; } $out .= ' </span>'; $out .= '<span class="followup_comment_title_date">'; $out .= html_time_ago(db_result($result, $i, 'date')); $out .= '</span>' . ")"; } $out .= "\n</div><!-- followup_comment_title -->\n"; $out .= '<div class="followup_comment_title_toolbar">'; if (db_result($orig_subm, 0, 'mod_by') == 100) { $user_quoted = db_result($orig_subm, 0, 'email'); } else { $user_quoted = $uh->getDisplayNameFromUserId(db_result($orig_subm, 0, 'mod_by')); } $user_quoted = addslashes(addslashes($user_quoted)); if ($pv == 0) { $out .= '<script type="text/javascript">document.write(\'<a href="#quote" onclick="tracker_quote_comment(\\\'' . $user_quoted . '\\\', \\\'' . (int) $comment_id . '\\\'); return false;" title="quote">'; $out .= $GLOBALS['HTML']->getImage('ic/quote.png', array('border' => 0, 'alt' => 'quote')); $out .= '</a>\');</script>'; } if ($this->userCanEditFollowupComment($comment_id) && !$pv) { $out .= '<a href="/tracker/?func=editcomment&group_id=' . (int) $group_id . '&aid=' . (int) $this->getID() . '&atid=' . (int) $group_artifact_id . '&artifact_history_id=' . (int) $comment_id . '" title="' . $GLOBALS['Language']->getText('tracker_fieldeditor', 'edit') . '">'; $out .= $GLOBALS['HTML']->getImage('ic/edit.png', array('border' => 0, 'alt' => $GLOBALS['Language']->getText('tracker_fieldeditor', 'edit'))); $out .= '</a>'; $out .= '<a href="/tracker/?func=delete_comment&group_id=' . (int) $group_id . '&aid=' . (int) $this->getID() . '&atid=' . (int) $group_artifact_id . '&artifact_history_id=' . (int) $comment_id . '" '; $out .= ' onClick="return confirm(\'' . $GLOBALS['Language']->getText('tracker_include_artifact', 'delete_comment') . '\')" title="' . $GLOBALS['Language']->getText('tracker_include_artifact', 'del') . '">'; $out .= $GLOBALS['HTML']->getImage('ic/close.png', array('border' => 0, 'alt' => $GLOBALS['Language']->getText('tracker_include_artifact', 'del'))); $out .= '</a>'; } $out .= "\n</div><!-- followup_comment_title_toolbar -->\n"; $out .= '<div style="clear:both;"></div>'; $out .= "\n</div><!-- followup_comment_header -->\n"; $out .= '<div class="followup_comment_content" ' . $style . ' id="comment_' . (int) $comment_id . '_content">'; if ($comment_type != "") { $out .= '<div class="followup_comment_content_type"><b>' . $hp->purify($comment_type, CODENDI_PURIFIER_CONVERT_HTML) . '</b></div>'; } $out .= $this->formatFollowUp($group_id, $isHtml, $value, $output); $out .= '</div>'; $out .= '</div>'; $out .= '<script type="text/javascript"> if (linked_comment_id == ' . (int) $comment_id . ') { tracker_comment_togglers[' . (int) $comment_id . '](null, true, true); } </script>'; } } if ($output == self::OUTPUT_BROWSER) { if ($rows > 0) { $out .= '<div style="text-align:right">'; $out .= '<a href="#expand_all" onclick="tracker_expand_all_comments(); return false;">' . $Language->getText('tracker_include_artifact', 'expand_all') . '</a> | <a href="#expand_all" onclick="tracker_collapse_all_comments(); return false;">' . $Language->getText('tracker_include_artifact', 'collapse_all') . '</a></div>'; } } // final touch... $out .= $output != self::OUTPUT_BROWSER ? $GLOBALS['sys_lf'] : ""; return $out; }
/** * TREE SUBVIEW */ protected function _tree($params = array()) { if (empty($params)) { $params = $this->getData(); } if (!empty($params['repository_list'])) { //echo '<h3>'.$this->getText('tree_title_available_repo').' <a href="#" onclick="$(\'help_tree\').toggle();"> [?]</a></h3>'; if (!empty($params['repositories_owners'])) { $current_id = null; if (!empty($params['user'])) { $current_id = (int) $params['user']; } $select = '<select name="user" onchange="this.form.submit()">'; $uh = UserHelper::instance(); $selected = 'selected="selected"'; $select .= '<option value="" ' . ($current_id ? '' : $selected) . '>' . $this->getText('tree_title_available_repo') . '</option>'; foreach ($params['repositories_owners'] as $owner) { $select .= '<option value="' . (int) $owner['repository_creation_user_id'] . '" ' . ($owner['repository_creation_user_id'] == $current_id ? $selected : '') . '>' . $uh->getDisplayName($owner['user_name'], $owner['realname']) . '</option>'; } $select .= '</select>'; echo '<form action="" method="GET">'; echo '<p>'; echo '<input type="hidden" name="action" value="index" />'; echo '<input type="hidden" name="group_id" value="' . (int) $this->groupId . '" />'; echo $select; echo '<noscript><input type="submit" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" /></noscript>'; echo '</p>'; echo '</form>'; } $this->help('tree', array('display' => 'none')); $lastPushes = array(); $dao = new Git_LogDao(); foreach ($params['repository_list'] as $repository) { $id = $repository['repository_id']; $dar = $dao->searchLastPushForRepository($id); if ($dar && !$dar->isError() && $dar->rowCount() == 1) { $lastPushes[$id] = $dar->getRow(); } } $strategy = new GitViewsRepositoriesTraversalStrategy_Tree($this, $lastPushes); echo $strategy->fetch($params['repository_list'], $this->user); } else { echo "<h3>" . $this->getText('tree_msg_no_available_repo') . "</h3>"; } }
function _getlockInfo() { $html = ''; $dpm = Docman_PermissionsManager::instance($this->item->getGroupId()); if ($dpm->getLockFactory()->itemIsLocked($this->item)) { $lockInfos = $dpm->getLockFactory()->getLockInfoForItem($this->item); $locker = UserHelper::instance()->getLinkOnUserFromUserId($lockInfos['user_id']); $lockDate = format_date($GLOBALS['Language']->getText('system', 'datefmt'), $lockInfos['lock_date']); $html .= '<p>'; $html .= $GLOBALS['Language']->getText('plugin_docman', 'details_properties_lock_who', array($locker, $lockDate)); if (!$this->user_can_write) { $html .= $GLOBALS['Language']->getText('plugin_docman', 'details_properties_lock_info'); } $html .= '</p>'; } return $html; }