Exemple #1
0
 protected function getReport(User $user)
 {
     $name = $GLOBALS['Language']->getText('plugin_tracker_homenav', 'search');
     $is_query_displayed = Toggler::shouldBeDisplayed($user, 'tracker_report_query_0', true);
     $report_id = $description = $current_renderer_id = $parent_report_id = $user_id = $is_default = $tracker_id = $updated_by = $updated_at = 0;
     return new Tracker_Report($report_id, $name, $description, $current_renderer_id, $parent_report_id, $user_id, $is_default, $tracker_id, $is_query_displayed, $updated_by, $updated_at);
 }
 protected function fetchArtifactPrefix()
 {
     $hp = Codendi_HTMLPurifier::instance();
     $current_user = UserManager::instance()->getCurrentUser();
     $always_collapsed = '';
     $fieldset_is_collapsed = $this->isCollapsed();
     $fieldset_is_expanded = !$fieldset_is_collapsed;
     if ($fieldset_is_collapsed) {
         $always_collapsed = 'active';
     }
     $html = '';
     $html .= '<fieldset class="tracker_artifact_fieldset">';
     $html .= '<legend title="' . $hp->purify($this->getDescription(), CODENDI_PURIFIER_CONVERT_HTML) . '" 
                       class="' . Toggler::getClassName('fieldset_' . $this->getId(), $fieldset_is_expanded, true) . '"
                       id="fieldset_' . $this->getId() . '"
                       data-id="' . $this->getId() . '">';
     $html .= '<table><tr><td class="tracker_artifact_fieldset_title">';
     $html .= $hp->purify($this->getLabel(), CODENDI_PURIFIER_CONVERT_HTML);
     $html .= '</td>';
     $html .= '<td class="tracker_artifact_fieldset_alwayscollapsed ' . $always_collapsed . '">';
     if ($current_user->isLoggedIn()) {
         $html .= '<i class="icon-pushpin"></i>';
     }
     $html .= '</td></tr></table>';
     $html .= '</legend>';
     $html .= '<div class="tracker_artifact_fieldset_content">';
     return $html;
 }
Exemple #3
0
 /**
  * @param string $request_uri '/plugins/agiledashboard/?group_id=1&action=show&....
  */
 public function __construct($request_uri)
 {
     $proto = Config::get('sys_force_ssl') ? 'https' : 'http';
     $url = $proto . '://' . Config::get('sys_default_domain') . $request_uri;
     $dimensions = $this->width . 'x' . $this->height;
     $this->class = Toggler::getClassname('plugin_cardwall_qrcode_toggler', false, true);
     $this->url = 'http://chart.apis.google.com/chart?' . http_build_query(array('chs' => $dimensions, 'cht' => 'qr', 'chld' => 'L|0', 'chl' => $url));
 }
 protected function fetchArtifactPrefix()
 {
     $html = '';
     $hp = Codendi_HTMLPurifier::instance();
     $html .= '<fieldset class="tracker_artifact_fieldset">';
     $html .= '<legend title="' . $hp->purify($this->getDescription(), CODENDI_PURIFIER_CONVERT_HTML) . '" 
                       class="' . Toggler::getClassName('fieldset_' . $this->getId(), true, true) . '" 
                       id="fieldset_' . $this->getId() . '">';
     $html .= $hp->purify($this->getLabel(), CODENDI_PURIFIER_CONVERT_HTML);
     $html .= '</legend>';
     return $html;
 }
 /**
  * @param Cardwall_Board $board The board
  * @param string $redirect_parameter the redirect paramter to add to various url
  * @param Tracker_FormElement_Field_Selectbox $field form to choose the column. false if no form (in widget) (thus no typehinting)
  * @param $form
  */
 public function __construct(Cardwall_Board $board, $redirect_parameter, $field, $form)
 {
     parent::__construct($board, $redirect_parameter);
     $hp = Codendi_HTMLPurifier::instance();
     $this->nifty = Toggler::getClassname('cardwall_board-nifty') == 'toggler' ? 'nifty' : false;
     $this->swimline_title = '';
     $this->has_swimline_header = false;
     $this->field = $field ? $field : false;
     $this->form = $form ? $form : false;
     $this->has_columns = count($this->board->columns) > 0;
     $this->warn_please_choose = $GLOBALS['Language']->getText('plugin_cardwall', 'warn_please_choose');
     $field_label = $field ? $hp->purify($this->field->getLabel()) : '###';
     $this->warn_no_values = $GLOBALS['Language']->getText('plugin_cardwall', 'warn_no_values', $field_label);
 }
 public function fetchDisplayQuery(array $criteria, array $additional_criteria, $report_can_be_modified, PFUser $current_user)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $html = '';
     $html .= '<div id="tracker_report_query" data-report-id="' . $this->id . '">';
     $html .= '<form action="" method="POST" id="tracker_report_query_form">';
     $html .= '<input type="hidden" name="report" value="' . $this->id . '" />';
     $id = 'tracker_report_query_' . $this->id;
     $html .= '<h4 class="backlog-planning-search-title ' . Toggler::getClassname($id, $this->is_query_displayed ? true : false) . '" id="' . $id . '">';
     //  Query title
     $html .= $GLOBALS['Language']->getText('plugin_tracker_report', 'search') . '</h4>';
     $used = array();
     $criteria_fetched = array();
     foreach ($criteria as $criterion) {
         if ($criterion->field->isUsed()) {
             $li = '<li id="tracker_report_crit_' . $criterion->field->getId() . '">';
             if ($current_user->isAnonymous()) {
                 $li .= $criterion->fetchWithoutExpandFunctionnality();
             } else {
                 $li .= $criterion->fetch();
             }
             $li .= '</li>';
             $criteria_fetched[] = $li;
             $used[$criterion->field->getId()] = $criterion->field;
         }
     }
     if ($report_can_be_modified && !$current_user->isAnonymous()) {
         $html .= '<div class="pull-right">';
         $html .= $this->getAddCriteriaDropdown($used);
         $html .= '</div>';
     }
     $array_of_html_criteria = array();
     EventManager::instance()->processEvent(TRACKER_EVENT_REPORT_DISPLAY_ADDITIONAL_CRITERIA, array('array_of_html_criteria' => &$array_of_html_criteria, 'tracker' => $this->getTracker(), 'additional_criteria' => $additional_criteria, 'user' => $current_user));
     foreach ($array_of_html_criteria as $additional_criteria) {
         $criteria_fetched[] = '<li>' . $additional_criteria . '</li>';
     }
     $html .= '<ul id="tracker_query">' . implode('', $criteria_fetched) . '</ul>';
     $html .= '<div align="center">';
     $html .= '<button type="submit" name="tracker_query_submit" class="btn btn-primary">';
     $html .= '<i class="icon-search"></i> ';
     $html .= $GLOBALS['Language']->getText('global', 'btn_search');
     $html .= '</button>';
     $html .= '</div>';
     $html .= '</form>';
     $html .= '</div>';
     return $html;
 }
 public function toggle($params)
 {
     if ($params['id'] === 'tracker_report_query_0') {
         Toggler::togglePreference($params['user'], $params['id']);
         $params['done'] = true;
     } else {
         if (strpos($params['id'], 'tracker_report_query_') === 0) {
             $report_id = (int) substr($params['id'], strlen('tracker_report_query_'));
             $report_factory = Tracker_ReportFactory::instance();
             if (($report = $report_factory->getReportById($report_id, $params['user']->getid())) && $report->userCanUpdate($params['user'])) {
                 $report->toggleQueryDisplay();
                 $report_factory->save($report);
             }
             $params['done'] = true;
         }
     }
 }
Exemple #8
0
 /**
  * Display debug info gathered along the execution
  *
  * @return void
  */
 public static function showDebugInfo()
 {
     global $Language;
     echo '<div id="footer_debug_separator"/>';
     echo '<div id="footer_debug">';
     echo '<div class="alert alert-info">
                <h4> Development useful information! </h4>
                The section above will show you some useful information about Tuleap for development purpose.
           </div>';
     echo '<div id="footer_debug_content">';
     $debug_compute_tile = microtime(true) - $GLOBALS['debug_time_start'];
     if (function_exists('xdebug_time_index')) {
         $xdebug_time_index = xdebug_time_index();
     }
     $query_time = 0;
     foreach ($GLOBALS['DBSTORE'] as $d) {
         foreach ($d['trace'] as $trace) {
             $query_time += $trace[2] - $trace[1];
         }
     }
     $purifier = Codendi_HTMLPurifier::instance();
     echo '<span class="debug">' . $Language->getText('include_layout', 'query_count') . ": ";
     echo $GLOBALS['DEBUG_DAO_QUERY_COUNT'] . "</span>";
     $percent = (int) ($GLOBALS['DEBUG_TIME_IN_PRE'] * 100 / $debug_compute_tile);
     $sql_percent = (int) ($query_time * 100 / $debug_compute_tile);
     echo '<table border=1><thead><tr><th></th><th>Page generated in</th></tr></thead><tbody>';
     echo '<tr><td>pre.php</td><td>' . number_format(1000 * $GLOBALS['DEBUG_TIME_IN_PRE'], 0, '.', "'") . ' ms (' . $percent . '%)</td>';
     echo '<tr><td>remaining</td><td>' . number_format(1000 * ($debug_compute_tile - $GLOBALS['DEBUG_TIME_IN_PRE']), 0, '.', "'") . ' ms</td>';
     echo '<tr><td><b>total</td><td><b>' . number_format(1000 * $debug_compute_tile, 0, '.', "'") . ' ms</td>';
     if (function_exists('xdebug_time_index')) {
         echo '<tr><td>xdebug</td><td>' . number_format(1000 * $xdebug_time_index, 0, '.', "'") . ' ms</tr>';
     }
     echo '<tr><td>sql</td><td>' . number_format(1000 * $query_time, 0, '.', "'") . ' ms (' . $sql_percent . '%)</tr>';
     echo '</tbody></table>';
     if (function_exists('xdebug_get_profiler_filename')) {
         if ($file = xdebug_get_profiler_filename()) {
             echo '<div>Profiler info has been written in: ' . $file . '</div>';
         }
     }
     $hook_params = array();
     EventManager::instance()->processEvent('layout_footer_debug', $hook_params);
     //Display the config
     // Uncomment this only if you know what you are doing. This may lead to sensitive information leakage /!\
     //echo '<fieldset><legend id="footer_debug_config" class="'. Toggler::getClassname('footer_debug_config') .'">Config:</legend>';
     //echo '<pre>';
     //Config::dump();
     //echo '</pre>';
     //echo '</fieldset>';
     // Display all queries used to generate the page
     echo '<fieldset><legend id="footer_debug_allqueries" class="' . Toggler::getClassname('footer_debug_allqueries') . '">All queries:</legend>';
     echo '<pre>';
     $queries = array();
     $queries_by_time_taken = array();
     $i = 0;
     foreach ($GLOBALS['QUERIES'] as $sql) {
         $t = 0;
         foreach ($GLOBALS['DBSTORE'][md5($sql)]['trace'] as $trace) {
             $t += $trace[2] - $trace[1];
         }
         $q = array('sql' => $purifier->purify($sql), 'total time' => number_format(1000 * $t, 0, '.', "'") . ' ms');
         $queries[] = $q;
         $queries_by_time_taken[] = array('n°' => $i++, 't' => $t) + $q;
     }
     print_r($queries);
     echo '</pre>';
     echo '</fieldset>';
     // Display all queries used to generate the page ordered by time taken
     usort($queries_by_time_taken, array(__CLASS__, 'sort_queries_by_time_taken'));
     echo '<fieldset><legend id="footer_debug_allqueries_time_taken" class="' . Toggler::getClassname('footer_debug_allqueries_time_taken') . '">All queries by time taken:</legend>';
     echo '<table border="1" style="border-collapse:collapse" cellpadding="2" cellspacing="0">';
     echo '<thead><tr><th>n°</th><th style="white-space:nowrap;">time taken</th><th>sum</th><th>sql</th></tr></thead>';
     $i = 0;
     $sum = 0;
     foreach ($queries_by_time_taken as $q) {
         echo '<tr valign="top" class="' . html_get_alt_row_color($i++) . '">';
         echo '<td>' . $q['n°'] . '</td>';
         echo '<td style="white-space:nowrap;">' . $q['total time'] . '</td>';
         echo '<td style="white-space:nowrap;">' . number_format(1000 * ($sum += $q['t']), 0, '.', "'") . ' ms' . '</td>';
         echo '<td><pre>' . $q['sql'] . '</pre></td>';
         echo '</tr>';
     }
     echo '</table>';
     echo '</fieldset>';
     echo '<fieldset><legend id="footer_debug_queriespaths" class="' . Toggler::getClassname('footer_dubug_queriespaths') . '">Path of all queries:</legend>';
     $max = 0;
     foreach ($GLOBALS['DBSTORE'] as $d) {
         foreach ($d['trace'] as $trace) {
             $time_taken = 1000 * round($trace[2] - $trace[1], 3);
             if ($max < $time_taken) {
                 $max = $time_taken;
             }
         }
     }
     $paths = array();
     $time = $GLOBALS['debug_time_start'];
     foreach ($GLOBALS['DBSTORE'] as $d) {
         foreach ($d['trace'] as $trace) {
             $time_taken = 1000 * round($trace[2] - $trace[1], 3);
             self::_debug_backtrace_rec($paths, array_reverse($trace[0]), '[' . 1000 * round($trace[1] - $GLOBALS['debug_time_start'], 3) . '/' . $time_taken . '] ' . ($time_taken >= $max ? ' <span style="background:yellow; padding-left:4px; padding-right:4px; color:red;">top!</span> ' : '') . $purifier->purify($d['sql']));
         }
     }
     echo '<table>';
     self::_debug_display_paths($paths, false);
     echo '</table>';
     echo '</fieldset>';
     //Print the backtrace of specific queries
     /*
                 echo '<pre>';
                 $specific_queries = array(48,49);
                 $i = 0;
                 foreach($GLOBALS['DBSTORE'] as $d) {
                     //echo $i ."\t". $d['sql'] ."\n";
                     if (in_array($i++, $specific_queries)) {
                         $traces = $d['trace'][0];
                         foreach($traces as $trace) {
                             echo '<code>'. $trace['file']. ' #'. $trace['line'] .' ('. (isset($trace['class']) ? $trace['class'] .'::' : '') . $trace['function'] ."</code>\n";
                         }
                         echo "\n";
                     }
                 }
                 echo '</pre>';
                 /**/
     // Display queries executed more than once
     $title_displayed = false;
     foreach ($GLOBALS['DBSTORE'] as $key => $value) {
         if ($GLOBALS['DBSTORE'][$key]['nb'] > 1) {
             if (!$title_displayed) {
                 echo '<fieldset><legend>Queries executed more than once :</legend>';
                 $title_displayed = true;
             }
             echo "<fieldset>";
             echo '<legend id="footer_debug_doublequery_' . $key . '" class="' . Toggler::getClassname('footer_debug_doublequery_' . $key) . '">';
             echo '<b>Run ' . $GLOBALS['DBSTORE'][$key]['nb'] . " times: </b>";
             echo $purifier->purify($GLOBALS['DBSTORE'][$key]['sql']) . "\n";
             echo '</legend>';
             self::_debug_backtraces($GLOBALS['DBSTORE'][$key]['trace']);
             echo "</fieldset>";
         }
     }
     if ($title_displayed) {
         echo '</fieldset>';
     }
     echo '<fieldset>';
     echo '<legend id="footer_debug_session" class="' . Toggler::getClassname('footer_debug_session') . '">Session</legend>';
     echo "<div>";
     echo '<a href="#" onclick="new Ajax.Updater(\'footer_debug_session_data\', \'/include/debug_session.php?reload\');return false;">reload</a>';
     echo '  |  ';
     echo '<a href="#" onclick="new Ajax.Updater(\'footer_debug_session_data\', \'/include/debug_session.php?reset\');return false;">reset</a>';
     echo '<pre id="footer_debug_session_data">' . print_r($_SESSION, 1) . '</pre>';
     echo "</div>";
     echo '</fieldset>';
     echo "</pre>\n";
     echo '</div>';
     echo '</div>';
 }
 /**
  * Returns HTML code to display the artifact follow-up comments
  *
  * @param User $current_user the current user
  *
  * @return string The HTML code for artifact follow-up comments
  */
 protected function fetchFollowUps($current_user, $submitted_comment = '')
 {
     $html = '';
     $html_submit_button = '<p style="text-align:center;">';
     $html_submit_button .= '<input type="submit" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />';
     $html_submit_button .= ' ';
     $html_submit_button .= '<input type="submit" name="submit_and_stay" value="' . $GLOBALS['Language']->getText('global', 'btn_submit_and_stay') . '" />';
     $html_submit_button .= '</p>';
     $html .= $html_submit_button;
     $html .= '<fieldset id="tracker_artifact_followup_comments"><legend
                       class="' . Toggler::getClassName('tracker_artifact_followups', true, true) . '"
                       id="tracker_artifact_followups">' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'follow_ups') . '</legend>';
     $html .= '<ul class="tracker_artifact_followups">';
     $previous_changeset = null;
     $i = 0;
     foreach ($this->getChangesets() as $changeset) {
         if ($previous_changeset) {
             $html .= '<li id="followup_' . $changeset->id . '" class="' . html_get_alt_row_color($i++) . ' tracker_artifact_followup">';
             $html .= $changeset->fetchFollowUp($previous_changeset);
             $html .= '</li>';
         }
         $previous_changeset = $changeset;
     }
     $html .= '<li>';
     $html .= '<div class="' . html_get_alt_row_color($i++) . '">';
     $hp = Codendi_HTMLPurifier::instance();
     if (count($responses = $this->getTracker()->getCannedResponseFactory()->getCannedResponses($this->getTracker()))) {
         $html .= '<p><b>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'use_canned') . '</b>&nbsp;';
         $html .= '<select id="tracker_artifact_canned_response_sb">';
         $html .= '<option selected="selected" value="">--</option>';
         foreach ($responses as $r) {
             $html .= '<option value="' . $hp->purify($r->body, CODENDI_PURIFIER_CONVERT_HTML) . '">' . $hp->purify($r->title, CODENDI_PURIFIER_CONVERT_HTML) . '</option>';
         }
         $html .= '</select>';
         $html .= '<noscript> javascript must be enabled to use this feature! </noscript>';
         $html .= '</p>';
     }
     $html .= '<b>' . $GLOBALS['Language']->getText('plugin_tracker_include_artifact', 'add_comment') . '</b><br />';
     $html .= '<textarea id="tracker_followup_comment_new" wrap="soft" rows="12" cols="80" style="width:99%;" name="artifact_followup_comment" id="artifact_followup_comment">' . $hp->purify($submitted_comment, CODENDI_PURIFIER_CONVERT_HTML) . '</textarea>';
     $html .= '</div>';
     if ($current_user->isAnonymous()) {
         $html .= $this->fetchAnonymousEmailForm();
     }
     $html .= '</li>';
     $html .= '</ul>';
     $html .= '</fieldset>';
     $html .= $html_submit_button;
     $html .= '</td></tr></table>';
     //see fetchFields
     return $html;
 }
 function _display_artifacts($artifacts)
 {
     $request = HTTPRequest::instance();
     $hp = Codendi_HTMLPurifier::instance();
     $html_my_artifacts = '';
     $html_current_tracker_header = '';
     $html_current_tracker_arts = '';
     $tracker_artifacts_counter = 0;
     $tracker = false;
     foreach ($artifacts as $tracker_id => $tracker_and_its_artifacts) {
         if (count($tracker_and_its_artifacts['artifacts'])) {
             $tracker = $tracker_and_its_artifacts['tracker'];
             //header (project name - tracker name)
             $div_id = 'plugin_tracker_my_artifacts_tracker_' . $tracker->getId();
             $classname = Toggler::getClassname($div_id);
             $group_id = $tracker->getGroupId();
             $project = ProjectManager::instance()->getProject($group_id);
             $project_and_tracker = $project->getPublicName() . ' - ' . $tracker->getName();
             $html_my_artifacts .= '<div>';
             $html_my_artifacts .= '<div class="' . $classname . '" id="' . $div_id . '">';
             $html_my_artifacts .= '<a href="/plugins/tracker/?tracker=' . $tracker->getId() . '">';
             $html_my_artifacts .= '<strong>' . $hp->purify($project_and_tracker, CODENDI_PURIFIER_CONVERT_HTML) . '</strong>';
             $html_my_artifacts .= '</a>';
             $html_my_artifacts .= ' [' . count($tracker_and_its_artifacts['artifacts']) . ']';
             $html_my_artifacts .= ' </div>';
             $html_my_artifacts .= '<ul class="plugin_tracker_my_artifacts_list">';
             foreach ($tracker_and_its_artifacts['artifacts'] as $artifact_and_its_title) {
                 // Display artifact
                 $html_my_artifacts .= '<li>';
                 $html_my_artifacts .= $artifact_and_its_title['artifact']->fetchWidget($tracker->getItemName(), $artifact_and_its_title['title']);
                 $html_my_artifacts .= '</li>';
             }
             $html_my_artifacts .= '</ul>';
             $html_my_artifacts .= '</div>';
         }
     }
     return $html_my_artifacts;
 }
Exemple #11
0
echo '<h2>' . $hp->purify($title, CODENDI_PURIFIER_CONVERT_HTML) . '</h2>';
$se = SystemEventManager::instance();
$offset = $request->get('offset') && !$request->exist('filter') ? (int) $request->get('offset') : 0;
$limit = 50;
$full = true;
$filter_status = $request->get('filter_status');
if (!$filter_status) {
    $filter_status = array(SystemEvent::STATUS_NEW, SystemEvent::STATUS_RUNNING, SystemEvent::STATUS_DONE, SystemEvent::STATUS_WARNING, SystemEvent::STATUS_ERROR);
}
$filter_type = $request->get('filter_type');
if (!$filter_type) {
    $filter_type = $se->getTypes();
}
echo '<form action="" method="POST">';
echo '<fieldset>';
echo '<legend id="system_events_filter" class="' . Toggler::getClassname('system_events_filter') . '">Filter:</legend>';
echo '<strong>' . 'Status:' . '</strong> <input type="hidden" name="filter_status[]" value="' . $hp->purify(SystemEvent::STATUS_NONE, CODENDI_PURIFIER_CONVERT_HTML) . '" />';
echo '<br />';
foreach (array(SystemEvent::STATUS_NEW, SystemEvent::STATUS_RUNNING, SystemEvent::STATUS_DONE, SystemEvent::STATUS_WARNING, SystemEvent::STATUS_ERROR) as $status) {
    echo '<input type="checkbox" 
                 name="filter_status[]" 
                 value="' . $hp->purify($status, CODENDI_PURIFIER_CONVERT_HTML) . '" 
                 id="filter_' . $hp->purify($status, CODENDI_PURIFIER_CONVERT_HTML) . '"
                 ' . (in_array($status, $filter_status) ? 'checked="checked"' : '') . '
                 />';
    echo '<label for="filter_' . $hp->purify($status, CODENDI_PURIFIER_CONVERT_HTML) . '">' . $hp->purify($status, CODENDI_PURIFIER_CONVERT_HTML) . '</label> ';
}
echo '<hr size="1" />';
echo '<strong>' . 'Types:' . '</strong> <input type="hidden" name="filter_type[]" value="-" />';
echo '<table>';
$types = $se->getTypes();
 public function fetchDisplayQuery(array $criteria, $report_can_be_modified, User $current_user = null)
 {
     $hp = Codendi_HTMLPurifier::instance();
     $html = '';
     $html .= '<div class="tracker_report_query">';
     $html .= '<form action="" method="POST" id="tracker_report_query_form">';
     $html .= '<input type="hidden" name="report" value="' . $this->id . '" />';
     $id = 'tracker_report_query_' . $this->id;
     $html .= '<h3 class="' . Toggler::getClassname($id, $this->is_query_displayed ? true : false) . '" id="' . $id . '">';
     //  Query title
     $html .= $hp->purify($this->name, CODENDI_PURIFIER_CONVERT_HTML) . '</h3>';
     $used = array();
     $criteria_fetched = array();
     foreach ($criteria as $criterion) {
         if ($criterion->field->isUsed()) {
             $criteria_fetched[] = '<li id="tracker_report_crit_' . $criterion->field->getId() . '">' . $criterion->fetch() . '</li>';
             $used[$criterion->field->getId()] = $criterion->field;
         }
     }
     if ($report_can_be_modified && $this->userCanUpdate($current_user)) {
         $html .= '<div id="tracker_report_addcriteria_panel">' . $this->_fetchAddCriteria($used) . '</div>';
     }
     $html .= '<ul id="tracker_query">' . implode('', $criteria_fetched) . '</ul>';
     $html .= '<div align="center"><input type="submit" name="tracker_query_submit" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" /></div>';
     $html .= '</form>';
     $html .= '</div>';
     return $html;
 }
 /**
  * Compute the content of the widget
  *
  * @return String
  */
 public function getContent()
 {
     $dao = new Git_LogDao();
     $um = UserManager::instance();
     $user = $um->getCurrentUser();
     $date = $_SERVER['REQUEST_TIME'] - $this->pastDays * 24 * 60 * 60;
     $result = $dao->getLastPushesRepositories($user->getId(), $date);
     $content = '';
     $project = '';
     $dh = new DateHelper();
     if ($result && !$result->isError()) {
         foreach ($result as $entry) {
             if (!empty($entry['repository_namespace'])) {
                 $namespace = $entry['repository_namespace'] . "/";
             } else {
                 $namespace = '';
             }
             $dar = $dao->getLastPushesByUser($user->getId(), $entry['repository_id'], $this->offset, $date);
             if ($dar && !$dar->isError() && $dar->rowCount() > 0) {
                 if ($project != $entry['group_name']) {
                     if (!empty($project)) {
                         $content .= '</fieldset>';
                     }
                     $project = $entry['group_name'];
                     $content .= '<fieldset>
                                  <legend id="plugin_git_user_pushes_widget_project_' . $project . '" class="' . Toggler::getClassname('plugin_git_user_pushes_widget_project_' . $project) . '">
                                  <span title="' . $GLOBALS['Language']->getText('plugin_git', 'tree_view_project') . '">
                                  <b>' . $project . '</b>
                                  </span>
                                  </legend>
                                  <a href="' . $this->pluginPath . '/index.php?group_id=' . $entry['group_id'] . '">[ ' . $GLOBALS['Language']->getText('plugin_git', 'widget_user_pushes_details') . ' ]</a>';
                 }
                 $content .= '<fieldset>
                              <legend id="plugin_git_user_pushes_widget_repo_' . $project . $namespace . $entry['repository_name'] . '" class="' . Toggler::getClassname('plugin_git_user_pushes_widget_repo_' . $project . $namespace . $entry['repository_name']) . '">
                              <span title="' . $GLOBALS['Language']->getText('plugin_git', 'tree_view_repository') . '">
                              ' . $namespace . $entry['repository_name'] . '
                              </span>
                              </legend>
                              ' . html_build_list_table_top(array($GLOBALS['Language']->getText('plugin_git', 'tree_view_date'), $GLOBALS['Language']->getText('plugin_git', 'tree_view_commits')));
                 $i = 0;
                 $hp = Codendi_HTMLPurifier::instance();
                 foreach ($dar as $row) {
                     $content .= '<tr class="' . html_get_alt_row_color(++$i) . '">
                                      <td><span title="' . $dh->timeAgoInWords($row['push_date'], true) . '">' . $hp->purify(format_date($GLOBALS['Language']->getText('system', 'datefmt'), $row['push_date'])) . '</span></td>
                                      <td>
                                          <a href="' . $this->pluginPath . '/index.php/' . $entry['group_id'] . '/view/' . $entry['repository_id'] . '/">
                                          ' . $hp->purify($row['commits_number']) . '
                                          </a>
                                      </td>
                                  </tr>';
                 }
                 $content .= "</table>\n                                 </fieldset>";
             } else {
                 $content .= $GLOBALS['Language']->getText('plugin_git', 'widget_user_pushes_no_content');
             }
         }
     } else {
         $content = $GLOBALS['Language']->getText('plugin_git', 'widget_user_pushes_no_content');
     }
     return $content;
 }
 public function system_events_filter_classname()
 {
     return Toggler::getClassname('system_events_filter');
 }
 /**
  * Build the HTML for all the link with the same way (from or to the project)
  * 
  * It build either the list of all "forward" links or the list of all
  * "back links"
  * 
  * @param  String $way Either 'links' or 'back_links'
  * @param  String $res One row of link
  * @return String
  */
 function getLinks($way, DataAccessResult $dar)
 {
     $html = '';
     $previousLinkName = '';
     $ulClosed = true;
     foreach ($dar as $row) {
         if ($row['link_name'] != $previousLinkName) {
             if (!$ulClosed) {
                 // Do not close the list when the list is not started
                 $html .= "    </ul>\n";
                 $html .= "  </li>\n";
                 $ulClosed = true;
             }
             $spanId = 'plugin_project_links_name_' . $way . '_' . $row['link_type_id'];
             $cssClass = Toggler::getClassName($spanId);
             // Link name title
             $html .= "  <li><span id=\"" . $spanId . "\" class=\"" . $cssClass . "\">" . $row['link_name'] . "</span>\n";
             $html .= "    <ul>\n";
             $ulClosed = false;
         }
         $html .= "      <li>";
         $html .= $this->getOneLink($row);
         $html .= "  </li>\n";
         $previousLinkName = $row['link_name'];
     }
     if (!$ulClosed) {
         $html .= "    </ul>\n";
         $html .= "  </li>\n";
     }
     return $html;
 }
/**
 * Nicely html-formatted output of this group's audit trail
 *
 * @param Integer $group_id     Id of the project
 * @param Integer $offset       Offset used for pagination
 * @param Integer $limit        Number of events by page
 * @param String  $event        Events category used to filter results
 * @param String  $subEventsBox Event used to filter results
 * @param String  $value        Value used to filter results
 * @param Integer $startDate    Start date used to filter results
 * @param Integer $endDate      End date used to filter results
 * @param String  $by           User name used to filter results
 *
 * @return void
 */
function show_grouphistory($group_id, $offset, $limit, $event = null, $subEventsBox = null, $value = null, $startDate = null, $endDate = null, $by = null)
{
    /*
    show the group_history rows that are relevant to
    this group_id
    */
    global $Language;
    $dao = new ProjectHistoryDao(CodendiDataAccess::instance());
    $history_filter = build_grouphistory_filter($event, $subEventsBox, $value, $startDate, $endDate, $by);
    $res = $dao->groupGetHistory($offset, $limit, $group_id, $history_filter);
    if (isset($subEventsBox)) {
        $subEventsString = implode(",", array_keys($subEventsBox));
        $forwardSubEvents = '&event=' . $event . '&subEventsBox=' . $subEventsString;
    } else {
        $forwardSubEvents = '&event=' . $event;
    }
    echo '
        <H2>' . $Language->getText('project_admin_utils', 'g_change_history') . '</H2>';
    echo '<FORM METHOD="POST" ACTION="?group_id=' . $group_id . '" id="project_history_form" name="project_history_form">';
    echo '<div>';
    echo '<SPAN title="' . $Language->getText('project_admin_utils', 'toggle_search') . '" id="history_search_title" class="' . Toggler::getClassname('history_search_title') . '"><B>' . $Language->getText('project_admin_utils', 'history_search_title') . '</B></SPAN>';
    echo '<TABLE ID="project_history_search">';
    echo '<TH colspan="2" style="text-align:left">' . $Language->getText('project_admin_utils', 'event') . '</TH>
              <TH style="text-align:left">' . $Language->getText('project_admin_utils', 'val') . '</TH>
              <TH style="text-align:left">' . $Language->getText('project_admin_utils', 'from') . '</TH>
              <TH style="text-align:left">' . $Language->getText('project_admin_utils', 'to') . '</TH>
              <TH style="text-align:left">' . $Language->getText('global', 'by') . '</TH>
              <TR VALIGN="TOP"><TD>';
    //Event select Box
    $events = array('any' => $GLOBALS["Language"]->getText('global', 'any'), 'event_permission' => $GLOBALS["Language"]->getText("project_admin_utils", "event_permission"), 'event_project' => $GLOBALS["Language"]->getText("project_admin_utils", "event_project"), 'event_user' => $GLOBALS["Language"]->getText("project_admin_utils", "event_user"), 'event_ug' => $GLOBALS["Language"]->getText("project_admin_utils", "event_ug"), 'event_others' => $GLOBALS["Language"]->getText("project_admin_utils", "event_others"));
    $select = new HTML_Element_Selectbox('', 'events_box', '');
    $select->setId('events_box');
    $select->addMultipleOptions($events, $event);
    echo $select->renderValue();
    //SubEvent select Box
    echo '</TD><TD><select id="sub_events_box" name="sub_events_box[]" multiple>
         <Option value="choose_event" disabled="disabled">' . $GLOBALS['Language']->getText('project_admin_utils', 'choose_event') . '</Option>
         </select>';
    echo '</TD><TD><input type="text" name="value" value="' . $value . '"></TD>
              <TD>';
    echo html_field_date('start', $startDate, false, 10, 10, 'project_history_form', false);
    echo '</TD>
              <TD>';
    echo html_field_date('end', $endDate, false, 10, 10, 'project_history_form', false);
    echo '</TD>
              <TD><input type="text" name="by" id="by" value="' . $by . '"></TD>
              </TR>';
    echo '<TR><TD id="events_array"></TD></TR>';
    echo '<TR><TD><input type="submit" name="filter"></TD></TR>
              </TABLE>';
    echo '</div>';
    echo '<P>';
    if ($res['numrows'] > 0) {
        $title_arr = array();
        $title_arr[] = $Language->getText('project_admin_utils', 'event');
        $title_arr[] = $Language->getText('project_admin_utils', 'val');
        $title_arr[] = $Language->getText('project_admin_utils', 'date');
        $title_arr[] = $Language->getText('global', 'by');
        echo html_build_list_table_top($title_arr);
        $i = 1;
        displayProjectHistoryResults($group_id, $res, false, $i);
        echo '</TABLE>';
        echo '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">';
        if ($offset > 0) {
            echo '<a href="?group_id=' . $group_id . '&offset=' . ($offset - $limit) . $forwardSubEvents . '&value=' . $value . '&start=' . $startDate . '&end=' . $endDate . '&by=' . $by . '">[ ' . $Language->getText('project_admin_utils', 'previous') . ' ]</a>';
            echo '&nbsp;';
        }
        if ($offset + $limit < $res['numrows']) {
            echo '&nbsp;';
            echo '<a href="?group_id=' . $group_id . '&offset=' . ($offset + $limit) . $forwardSubEvents . '&value=' . $value . '&start=' . $startDate . '&end=' . $endDate . '&by=' . $by . '">[ ' . $Language->getText('project_admin_utils', 'next') . ' ]</a>';
        }
        echo '</div>';
        echo '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">';
        echo $offset + $i - 3 . '/' . $res['numrows'];
        echo '</div>';
        echo '<BR><TABLE align="left"><TR><TD>
                 <input type="submit" name="export" value="' . $GLOBALS['Language']->getText('project_admin_utils', 'export_history') . '">
                 </TD></TR></TABLE></FORM><BR><P>';
    } else {
        echo '<H3>' . $Language->getText('project_admin_utils', 'no_g_change') . '</H3>';
    }
    $translatedEvents = convert_project_history_events(get_history_entries(), false);
    if (isset($subEventsString)) {
        $selectedSubEvents = explode(",", $subEventsString);
        foreach ($selectedSubEvents as $element) {
            $subEventsBox[] = $element;
        }
    }
    $translatedSelectedEvents = convert_project_history_events($subEventsBox, true);
    $js = "options = new Array();\n           options['defaultValueActsAsHint'] = false;\n           new UserAutoCompleter('by', '" . util_get_dir_image_theme() . "', true, options);\n           new ProjectHistory(" . $translatedEvents . ", " . $translatedSelectedEvents . ");";
    $GLOBALS['HTML']->includeFooterJavascriptFile('/scripts/codendi/ProjectHistory.js');
    $GLOBALS['Response']->includeFooterJavascriptSnippet($js);
}
Exemple #17
0
<?php

/*
 * Copyright (c) Xerox, 2008. All Rights Reserved.
 *
 * Originally written by Nicolas Terray, 2008. Xerox Codendi Team.
 *
 * This file is a part of Codendi.
 *
 * Codendi is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Codendi is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with CodeX; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
require_once 'pre.php';
require_once 'common/include/Toggler.class.php';
Toggler::toggle(HTTPRequest::instance()->get('id'));
 public function __construct(IFeaturesBackend $backend)
 {
     $config = $backend->getConfig();
     parent::__construct($config);
 }
 public function toggler_class_name()
 {
     return Toggler::getClassname('history_search_title');
 }