ksort($ugroupRow); format_html_row($ugroupRow, $row_num); } } if ($group_id != 100) { $result = db_query("SELECT * FROM ugroup WHERE group_id={$group_id} ORDER BY name"); if (db_numrows($result) > 0) { while ($row = db_fetch_array($result)) { $ugroupRow[100] = '<a href="/project/admin/editugroup.php?group_id=' . $group_id . '&ugroup_id=' . $row['ugroup_id'] . '&func=edit">' . util_translate_name_ugroup($row['name']); $ugroupRow[200] = util_translate_desc_ugroup($row['description']); $res2 = db_query("SELECT count(*) FROM ugroup_user WHERE ugroup_id=" . $row['ugroup_id']); $nb_members = db_result($res2, 0, 0); if ($nb_members) { $ugroupRow[300] = array('value' => $nb_members, 'html_attrs' => 'align="center"'); } else { $ugroupRow[300] = array('value' => 0, 'html_attrs' => 'align="center"'); } $token = $csrf->getTokenName() . '=' . $csrf->getToken(); $link = '?group_id=' . $group_id . '&ugroup_id=' . $row['ugroup_id'] . '&func=delete&' . $token; $warn = $Language->getText('project_admin_ugroup', 'del_ug'); $alt = $Language->getText('project_admin_servicebar', 'del'); $ugroupRow[400] = html_trash_link($link, $warn, $alt); $em->processEvent('ugroup_table_row', array('row' => $row, 'html_array' => &$ugroupRow)); ksort($ugroupRow); format_html_row($ugroupRow, $row_num); } } } echo "</table>\n"; echo "<p>" . $Language->getText('project_admin_ugroup', 'predef_g') . "</p>\n"; project_admin_footer(array());
/** * Compute a html table to display the status of the last n events * * @param int $offset the offset of the pagination * @param int $limit the number of event to includ in the table * @param boolean $full display a full table or only a summary * @param array $filter_status the filter on status * @param array $filter_type the filter on type * @param CSRFSynchronizerToken $csrf The token to use to build actions on events * * @return string html */ public function fetchLastEventsStatus($offset = 0, $limit = 10, $full = false, $filter_status = false, $filter_type = false, CSRFSynchronizerToken $csrf = null, $queue = null) { $hp = Codendi_HTMLPurifier::instance(); $html = ''; $classname = 'table table-striped'; if ($full) { $classname .= ' table-hover table-bordered'; } else { $classname .= ' table-condensed'; } $html .= '<table class="' . $classname . '">'; if ($full) { $html .= '<thead><tr>'; $html .= '<th>' . 'id' . '</td>'; $html .= '<th>' . 'type' . '</td>'; $html .= '<th>' . 'owner' . '</td>'; $html .= '<th>' . 'status' . '</th>'; $html .= '<th>' . 'priority' . '</th>'; $html .= '<th>' . 'parameters' . '</th>'; $html .= '<th>' . 'create_date' . '</th>'; $html .= '<th>' . 'process_date' . '</th>'; $html .= '<th>' . 'end_date' . '</th>'; $html .= '<th>' . 'log' . '</th>'; $html .= '<th>' . 'actions' . '</th>'; $html .= '</tr></thead>'; } $html .= '<tbody>'; $replay_action_params = array(); if ($csrf) { $replay_action_params[$csrf->getTokenName()] = $csrf->getToken(); } if (!$filter_status) { $filter_status = array(SystemEvent::STATUS_NEW, SystemEvent::STATUS_RUNNING, SystemEvent::STATUS_DONE, SystemEvent::STATUS_WARNING, SystemEvent::STATUS_ERROR); } if ($queue) { $allowed_types = $this->getTypesForQueue($queue); } else { $allowed_types = $this->getTypesForQueue(SystemEvent::DEFAULT_QUEUE); } if ($filter_type) { $filter_type = array_intersect($filter_type, $allowed_types); } else { $filter_type = $allowed_types; } $events = $this->dao->searchLastEvents($offset, $limit, $filter_status, $filter_type); list(, $num_total_rows) = each($this->dao->retrieve("SELECT FOUND_ROWS() AS nb")->getRow()); foreach ($events as $row) { if ($sysevent = $this->getInstanceFromRow($row)) { $html .= '<tr>'; //id $html .= '<td>' . $sysevent->getId() . '</td>'; //name of the event $html .= '<td>' . $sysevent->getType() . '</td>'; $html .= '<td>' . $sysevent->getOwner() . '</td>'; //status $html .= '<td class="system_event_status_' . $row['status'] . '"'; if ($sysevent->getLog()) { $html .= ' title="' . $hp->purify($sysevent->getLog(), CODENDI_PURIFIER_CONVERT_HTML) . '" '; } $html .= '>'; $html .= $sysevent->getStatus(); $html .= '</td>'; if ($full) { $replay_link = ''; if ($sysevent->getStatus() == SystemEvent::STATUS_ERROR) { $replay_action_params['replay'] = $sysevent->getId(); $replay_link .= '<a href="/admin/system_events/?' . ($queue !== SystemEvent::DEFAULT_QUEUE ? 'queue=' . $queue . '&' : '') . http_build_query($replay_action_params) . '" title="Replay this event">'; $replay_link .= $GLOBALS['HTML']->getImage('ic/arrow-circle.png'); $replay_link .= '</a>'; } $html .= '<td style="text-align:center">' . $sysevent->getPriority() . '</td>'; $html .= '<td>' . $sysevent->verbalizeParameters(true) . '</td>'; $html .= '<td>' . $sysevent->getCreateDate() . '</td>'; $html .= '<td>' . $sysevent->getProcessDate() . '</td>'; $html .= '<td>' . $sysevent->getEndDate() . '</td>'; $html .= '<td>' . nl2br($sysevent->getLog()) . '</td>'; $html .= '<td>' . $replay_link . '</td>'; } $html .= '</tr>'; } } $html .= '</tbody></table>'; if ($full) { //Pagination $nb_of_pages = ceil($num_total_rows / $limit); $current_page = round($offset / $limit); $html .= '<div class="pagination"><ul>'; $width = 10; for ($i = 0; $i < $nb_of_pages; ++$i) { if ($i == 0 || $i == $nb_of_pages - 1 || $current_page - $width / 2 <= $i && $i <= $width / 2 + $current_page) { $class = ''; if ($i == $current_page) { $class = 'class="active"'; } $html .= '<li ' . $class . '>'; $html .= '<a href="?' . http_build_query(array('offset' => (int) ($i * $limit), 'filter_status' => $filter_status, 'filter_type' => $filter_type, 'queue' => $queue)) . '">'; $html .= $i + 1; $html .= '</a>'; $html .= '</li>'; } else { if ($current_page - $width / 2 - 1 == $i || $current_page + $width / 2 + 1 == $i) { $html .= '<li class="disabled">'; $html .= '<a href="#">...</a>'; $html .= '<li>'; } } } $html .= '</ul></div>'; } return $html; }
/** * Compute a html table to display the status of the last n events * * @param int $offset the offset of the pagination * @param int $limit the number of event to includ in the table * @param boolean $full display a full table or only a summary * @param array $filter_status the filter on status * @param array $filter_type the filter on type * @param CSRFSynchronizerToken $csrf The token to use to build actions on events * * @return string html */ public function fetchLastEventsStatus($offset = 0, $limit = 10, $full = false, $filter_status = false, $filter_type = false, CSRFSynchronizerToken $csrf = null) { $hp = Codendi_HTMLPurifier::instance(); $html = ''; $html .= '<table width="100%">'; if ($full) { $html .= '<thead><tr>'; $html .= '<th class="boxtitle">' . 'id' . '</td>'; $html .= '<th class="boxtitle">' . 'type' . '</td>'; $html .= '<th class="boxtitle" style="text-align:center">' . 'status' . '</th>'; $html .= '<th class="boxtitle" style="text-align:center">' . 'priority' . '</th>'; $html .= '<th class="boxtitle">' . 'parameters' . '</th>'; $html .= '<th class="boxtitle">' . 'create_date' . '</th>'; $html .= '<th class="boxtitle">' . 'process_date' . '</th>'; $html .= '<th class="boxtitle">' . 'end_date' . '</th>'; $html .= '<th class="boxtitle">' . 'log' . '</th>'; $html .= '<th class="boxtitle">' . 'actions' . '</th>'; $html .= '</tr></thead>'; } $html .= '<tbody>'; $replay_action_params = array(); if ($csrf) { $replay_action_params[$csrf->getTokenName()] = $csrf->getToken(); } if (!$filter_status) { $filter_status = array(SystemEvent::STATUS_NEW, SystemEvent::STATUS_RUNNING, SystemEvent::STATUS_DONE, SystemEvent::STATUS_WARNING, SystemEvent::STATUS_ERROR); } if (!$filter_type) { $filter_type = $this->getTypes(); } $i = 0; foreach ($this->dao->searchLastEvents($offset, $limit, $filter_status, $filter_type) as $row) { if ($sysevent = $this->getInstanceFromRow($row)) { $html .= '<tr class="' . html_get_alt_row_color($i++) . '">'; //id $html .= '<td>' . $sysevent->getId() . '</td>'; //name of the event $html .= '<td>' . $sysevent->getType() . '</td>'; //status $html .= '<td class="system_event_status_' . $row['status'] . '"'; if ($sysevent->getLog()) { $html .= ' title="' . $hp->purify($sysevent->getLog(), CODENDI_PURIFIER_CONVERT_HTML) . '" '; } $html .= '>'; $html .= $sysevent->getStatus(); $html .= '</td>'; if ($full) { $replay_link = ''; if ($sysevent->getStatus() == SystemEvent::STATUS_ERROR) { $replay_action_params['replay'] = $sysevent->getId(); $replay_link .= '<a href="/admin/system_events/?' . http_build_query($replay_action_params) . '" title="Replay this event">'; $replay_link .= $GLOBALS['HTML']->getImage('ic/arrow-circle.png'); $replay_link .= '</a>'; } $html .= '<td style="text-align:center">' . $sysevent->getPriority() . '</td>'; $html .= '<td>' . $sysevent->verbalizeParameters(true) . '</td>'; $html .= '<td>' . $sysevent->getCreateDate() . '</td>'; $html .= '<td>' . $sysevent->getProcessDate() . '</td>'; $html .= '<td>' . $sysevent->getEndDate() . '</td>'; $html .= '<td>' . $sysevent->getLog() . '</td>'; $html .= '<td>' . $replay_link . '</td>'; } $html .= '</tr>'; } } $html .= '</tbody></table>'; if ($full) { //Pagination list(, $num_total_rows) = each($this->dao->retrieve("SELECT FOUND_ROWS() AS nb")->getRow()); $nb_of_pages = ceil($num_total_rows / $limit); $current_page = round($offset / $limit); $html .= '<div style="font-family:Verdana">Page: '; $width = 10; for ($i = 0; $i < $nb_of_pages; ++$i) { if ($i == 0 || $i == $nb_of_pages - 1 || $current_page - $width / 2 <= $i && $i <= $width / 2 + $current_page) { $html .= '<a href="?' . http_build_query(array('offset' => (int) ($i * $limit), 'filter_status' => $filter_status, 'filter_type' => $filter_type)) . '">'; if ($i == $current_page) { $html .= '<b>' . ($i + 1) . '</b>'; } else { $html .= $i + 1; } $html .= '</a> '; } else { if ($current_page - $width / 2 - 1 == $i || $current_page + $width / 2 + 1 == $i) { $html .= '... '; } } } echo '</div>'; } return $html; }