function show() { global $page, $db, $fs, $proj, $user; $page->setTitle($fs->prefs['page_title'] . L('roadmap')); // Get milestones $list_id = $db->x->GetOne('SELECT list_id FROM {fields} WHERE field_id = ?', null, $proj->prefs['roadmap_field']); $milestones = array(); if ($list_id) { $milestones = $db->x->getAll('SELECT list_item_id AS version_id, item_name AS version_name FROM {list_items} li WHERE list_id = ? AND version_tense = 3 ORDER BY list_position ASC', null, $list_id); } $data = array(); foreach ($milestones as $row) { // Get all tasks related to a milestone $all_tasks = $db->x->getAll('SELECT percent_complete, is_closed, t.* FROM {tasks} t LEFT JOIN {field_values} fv ON (fv.task_id = t.task_id AND field_id = ?) WHERE field_value = ? AND project_id = ?', null, array($proj->prefs['roadmap_field'], $row['version_id'], $proj->id)); $all_tasks = array_filter($all_tasks, array($user, 'can_view_task')); $percent_complete = 0; foreach ($all_tasks as $task) { if ($task['is_closed']) { $percent_complete += 100; } else { $percent_complete += $task['percent_complete']; } } $percent_complete = round($percent_complete / max(count($all_tasks), 1)); if (count($all_tasks)) { $tasks = $db->x->getAll('SELECT t.task_id, item_summary, detailed_desc, mark_private, fs.field_value AS field' . $fs->prefs['color_field'] . ', opened_by, content, task_token, t.project_id, prefix_id FROM {tasks} t LEFT JOIN {cache} ca ON (t.task_id = ca.topic AND ca.type = ? AND t.last_edited_time <= ca.last_updated) LEFT JOIN {field_values} f ON f.task_id = t.task_id LEFT JOIN {field_values} fs ON (fs.task_id = t.task_id AND fs.field_id = ?) WHERE f.field_value = ? AND f.field_id = ? AND t.project_id = ? AND is_closed = 0', null, array('rota', $fs->prefs['color_field'], $row['version_id'], $proj->prefs['roadmap_field'], $proj->id)); $count = count($tasks); for ($i = 0; $i < $count; $i++) { if (!$user->can_view_task($tasks[$i])) { unset($tasks[$i]); } } } $data[] = array('id' => $row['version_id'], 'open_tasks' => isset($tasks) ? $tasks : array(), 'percent_complete' => $percent_complete, 'all_tasks' => $all_tasks ? $all_tasks : array(), 'name' => $row['version_name']); unset($tasks); } if (Get::val('txt')) { $page = new FSTpl(); header('Content-Type: text/plain; charset=UTF-8'); $page->assign('data', $data); $page->display('roadmap.text.tpl'); exit; } else { $page->assign('data', $data); $page->pushTpl('roadmap.tpl'); } }
function show() { global $page, $db, $fs, $proj, $user; $page->setTitle($fs->prefs['page_title'] . L('changelog')); // Get milestones $list_id = $db->x->GetOne('SELECT list_id FROM {fields} WHERE field_id = ?', null, $proj->prefs['roadmap_field']); if (!$list_id) { trigger_error('Roadmap / changelog has not been configured in the project management area.', E_USER_ERROR); } $milestones = $db->x->getAll('SELECT list_item_id AS version_id, item_name AS version_name FROM {list_items} li WHERE list_id = ? AND (version_tense = 1 OR version_tense = 2) AND show_in_list = 1 ORDER BY list_position ASC', null, $list_id); $data = array(); $reasons = implode(',', explode(' ', $proj->prefs['changelog_reso'])); while ((list(, $row) = each($milestones)) && $reasons) { $tasks = $db->x->getAll('SELECT t.task_id, percent_complete, item_summary, detailed_desc, mark_private, fs.field_value AS field' . $fs->prefs['color_field'] . ', opened_by, task_token, t.project_id, prefix_id, li.item_name AS res_name, li.list_item_id AS res_id FROM {tasks} t LEFT JOIN {field_values} f ON f.task_id = t.task_id LEFT JOIN {field_values} fs ON (fs.task_id = t.task_id AND fs.field_id = ?) LEFT JOIN {list_items} li ON t.resolution_reason = li.list_item_id WHERE f.field_value = ? AND f.field_id = ? AND t.project_id = ? AND is_closed = 1 AND t.resolution_reason IN (' . $reasons . ') ORDER BY t.resolution_reason DESC', null, array($fs->prefs['color_field'], $row['version_id'], $proj->prefs['roadmap_field'], $proj->id)); $tasks = array_filter($tasks, array($user, 'can_view_task')); if (count($tasks)) { $resolutions = array(); foreach ($tasks as $task) { $resolutions[$task['res_name']] = isset($resolutions[$task['res_name']]) ? $resolutions[$task['res_name']] + 1 : 1; } $data[] = array('tasks' => $tasks, 'name' => $row['version_name'], 'resolutions' => $resolutions); } } if (Get::val('txt')) { $page = new FSTpl(); header('Content-Type: text/plain; charset=UTF-8'); $page->assign('data', $data); $page->display('changelog.text.tpl'); exit; } else { $page->assign('data', $data); $page->pushTpl('changelog.tpl'); } }
/** * show * * @access public * @return void */ function show() { global $proj, $page, $fs; // Get the visibility state of all columns $visible = explode(' ', trim($proj->id ? $proj->prefs['visible_columns'] : $fs->prefs['visible_columns'])); list($tasks, $id_list) = Backend::get_task_list($_GET, $visible, 0); $page = new FSTpl(); $page->assign('tasks', $tasks); $page->assign('visible', $visible); if (Get::val('type') == 'iCal') { $datecols = array('dateopened' => 'date_opened', 'lastedit' => 'max_date', 'dateclosed' => 'date_closed'); header('Content-Type: text/calendar; charset=utf-8'); header('Content-Disposition: filename="export.ics"'); $page->assign('datecols', $datecols); $page->finish('icalexport.tpl'); } else { header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: filename="export.csv"'); $page->finish('csvexport.tpl'); } }
<?php // We can't include this script as part of index.php?do= etc, // as that would introduce html code into it. HTML != Valid XML // So, include the headerfile to set up database access etc define('IN_FS', true); require dirname(__FILE__) . '/header.php'; if (!$user->id && Get::val('user_id') && Get::val('auth')) { $user = new User(Get::val('user_id')); if (Get::val('auth') != md5($user->infos['user_pass'] . $user->infos['register_date'])) { $user = new User(); } } $page = new FSTpl(); // Set up the basic XML head header('Content-type: text/html; charset=utf-8'); $max_items = Get::num('num', 10) == 10 ? 10 : 20; $sql_project = ' 1=1 '; if ($proj->id) { $sql_project = sprintf(' t.project_id = %d', $proj->id); } $feed_type = Get::enum('feed_type', array('rss1', 'rss2', 'atom'), 'rss2'); switch (Get::val('topic')) { case 'clo': $orderby = 'date_closed'; $closed = 't.is_closed = 1'; $topic = 1; $title = 'Recently closed tasks'; break; case 'edit': $orderby = 'last_edited_time';
function tpl_double_select($name, $options, $selected = null, $labelIsValue = false, $updown = true) { static $_id = 0; static $tpl = null; if (!$tpl) { // poor man's cache $tpl = new FSTpl(); } settype($selected, 'array'); settype($options, 'array'); $tpl->assign('id', '_task_id_' . $_id++); $tpl->assign('name', $name); $tpl->assign('selected', $selected); $tpl->assign('updown', $updown); $html = $tpl->fetch('common.dualselect.tpl'); $selectedones = array(); $opt1 = ''; foreach ($options as $value => $label) { if (is_array($label) && count($label) >= 2) { $value = $label[0]; $label = $label[1]; } if ($labelIsValue) { $value = $label; } if (in_array($value, $selected)) { $selectedones[$value] = $label; continue; } $label = htmlspecialchars($label, ENT_QUOTES, 'utf-8'); $value = htmlspecialchars($value, ENT_QUOTES, 'utf-8'); $opt1 .= sprintf('<option title="%2$s" value="%1$s">%2$s</option>', $value, $label); } $opt2 = ''; foreach ($selected as $value) { if (!isset($selectedones[$value])) { continue; } $label = htmlspecialchars($selectedones[$value], ENT_QUOTES, 'utf-8'); $value = htmlspecialchars($value, ENT_QUOTES, 'utf-8'); $opt2 .= sprintf('<option title="%2$s" value="%1$s">%2$s</option>', $value, $label); } return sprintf($html, $opt1, $opt2); }
// Load translations load_translations(); /*******************************************************************************/ /* Here begins the deep flyspray : html rendering */ /*******************************************************************************/ # no cache headers are now in header.php! // see http://www.w3.org/TR/html401/present/styles.html#h-14.2.1 header('Content-Style-Type: text/css'); header('Content-type: text/html; charset=utf-8'); if ($conf['general']['output_buffering'] == 'gzip' && extension_loaded('zlib')) { // Start Output Buffering and gzip encoding if setting is present. ob_start('ob_gzhandler'); } else { ob_start(); } $page = new FSTpl(); // make sure people are not attempting to manually fiddle with projects they are not allowed to play with if (Req::has('project') && Req::val('project') != 0 && !$user->can_view_project(Req::val('project'))) { Flyspray::show_error(L('nopermission')); exit; } if ($show_task = Get::val('show_task')) { // If someone used the 'show task' form, redirect them if (is_numeric($show_task)) { Flyspray::Redirect(CreateURL('details', $show_task)); } else { Flyspray::Redirect($baseurl . '?string=' . $show_task); } } if (Flyspray::requestDuplicated()) { // Check that this page isn't being submitted twice
<?php /* This script gets the history of a task and returns it for HTML display in a page. */ define('IN_FS', true); header('Content-type: text/html; charset=utf-8'); require_once '../../header.php'; $baseurl = dirname(dirname($baseurl)) . '/'; $user->save_search(); $page = new FSTpl(); $page->display('links.searches.tpl');
<?php /* This script gets the searches of current user and returns it for HTML display in a page. */ define('IN_FS', true); header('Content-type: text/html; charset=utf-8'); require_once '../../header.php'; $baseurl = dirname(dirname($baseurl)) . '/'; // Initialise user if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) { $user = new User(Cookie::val('flyspray_userid')); $user->check_account_ok(); } else { $user = new User(0, $proj); } // don't allow anonymous users to access this page at all if ($user->isAnon()) { die; } $user->save_search(); # currently used for loading user searches from db into user object ... $page = new FSTpl(); $page->setTheme($proj->prefs['theme_style']); $page->display('links.searches.tpl');
// see http://www.w3.org/TR/html401/present/styles.html#h-14.2.1 header('Content-Style-Type: text/css'); header('Content-type: text/html; charset=utf-8'); if ($conf['general']['output_buffering'] == 'gzip' && extension_loaded('zlib')) { // Start Output Buffering and gzip encoding if setting is present. ob_start('ob_gzhandler'); } else { ob_start(); } // our own error handler, so that especially notices don't stay unnoticed if (version_compare(phpversion(), '5.0.0', '>=')) { set_error_handler(array('FlysprayDo', 'error'), ini_get('error_reporting')); } else { set_error_handler(array('FlysprayDo', 'error')); } $page = new FSTpl(); if (Get::val('opensearch')) { $page->finish('opensearch.tpl'); } if ($show_task = Get::val('show_task')) { // If someone used the 'show task' form, redirect them $task_id = Flyspray::GetTaskId($show_task); if ($task_id) { Flyspray::Redirect(CreateURL(array('details', 'task' . $task_id))); } else { Flyspray::Redirect(Createurl('index', array('string' => $show_task))); } } if ($proj->id && $user->perms('manage_project')) { // Find out if there are any PM requests wanting attention $count = $db->x->GetOne('SELECT COUNT(*) FROM {admin_requests} WHERE project_id = ? AND resolved_by = 0', null, array($proj->id));
$baseurl = dirname(dirname($baseurl)) . '/'; // Initialise user if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) { $user = new User(Cookie::val('flyspray_userid')); $user->check_account_ok(); } else { $user = new User(0, $proj); } // Check permissions if (!$user->perms('view_history')) { die; } // Load translations load_translations(); if ($details = Get::num('details')) { $details = " AND h.history_id = {$details}"; } else { $details = null; } $sql = get_events(Get::num('task_id'), $details); $histories = $db->fetchAllArray($sql); $page = new FSTpl(); $page->setTheme($proj->prefs['theme_style']); $page->uses('histories', 'details'); if ($details) { event_description($histories[0]); // modifies global variables $page->assign('details_previous', $GLOBALS['details_previous']); $page->assign('details_new', $GLOBALS['details_new']); } $page->display('details.tabs.history.callback.tpl');
foreach ($all_tasks as $task) { if ($task['is_closed']) { $percent_complete += 100; } else { $percent_complete += $task['percent_complete']; } } $percent_complete = round($percent_complete / max(count($all_tasks), 1)); $tasks = $db->Query('SELECT task_id, item_summary, detailed_desc, item_status, task_severity, task_priority, task_type, mark_private, opened_by, content, task_token, t.project_id,estimated_effort FROM {tasks} t LEFT JOIN {cache} ca ON (t.task_id = ca.topic AND ca.type = \'rota\' AND t.last_edited_time <= ca.last_updated) WHERE closedby_version = ? AND t.project_id = ? AND is_closed = 0', array($row['version_id'], $proj->id)); $tasks = $db->fetchAllArray($tasks); $count = count($tasks); for ($i = 0; $i < $count; $i++) { if (!$user->can_view_task($tasks[$i])) { unset($tasks[$i]); } } $data[] = array('id' => $row['version_id'], 'open_tasks' => $tasks, 'percent_complete' => $percent_complete, 'all_tasks' => $all_tasks, 'name' => $row['version_name']); } if (Get::val('txt')) { $page = new FSTpl(); header('Content-Type: text/plain; charset=UTF-8'); $page->uses('data', 'page'); $page->display('roadmap.text.tpl'); exit; } else { $page->uses('data', 'page'); $page->pushTpl('roadmap.tpl'); }
function show() { global $db, $page, $fs, $proj, $do; $page = new FSTpl(); $page->setTheme($proj->prefs['theme_style']); $page->assign('do', $do); $page->pushTpl('baseheader.tpl'); $assignees = ''; if (Get::val('onlyassignees')) { $assignees = 'AND (g.show_as_assignees = 1 OR g.is_admin = 1)'; } $query = 'SELECT g.group_id, g.group_name, g.group_desc, g.group_open, count(u.user_id) AS num_users FROM {groups} g LEFT JOIN {users_in_groups} uig ON uig.group_id = g.group_id LEFT JOIN {users} u ON (uig.user_id = u.user_id ' . $assignees . ') WHERE g.project_id = ? GROUP BY g.group_id'; $page->assign('groups', $db->x->getAll($query, null, $proj->id)); $page->assign('globalgroups', $db->x->getAll($query, null, 0)); // Search conditions $where = array(); $params = array(); foreach (array('user_name', 'real_name') as $key) { if (Post::val($key)) { $where[] = ' ' . $key . ' LIKE ? '; $params[] = '%' . Post::val($key) . '%'; } } $where = count($where) ? implode(' OR ', $where) : '1=1'; // fill the table with users if (Get::val('group_id', -1) > 0) { $order_keys = array('username' => 'user_name', 'realname' => 'real_name'); $order_column = $order_keys[Filters::enum(Get::val('order', 'username'), array_keys($order_keys))]; $sortorder = sprintf('ORDER BY %s %s, u.user_id ASC', $order_column, Filters::enum(Get::val('sort', 'desc'), array('asc', 'desc'))); $users = $db->x->getAll('SELECT u.user_id, user_name, real_name, email_address FROM {users} u LEFT JOIN {users_in_groups} uig ON uig.user_id = u.user_id LEFT JOIN {groups} g ON uig.group_id = g.group_id WHERE uig.group_id = ? ' . $assignees . ' AND ( ' . $where . ' )' . $sortorder, null, array_merge(array(Get::val('group_id')), $params)); // Offset and limit $user_list = array(); $offset = max(Get::num('pagenum') - 1, 0) * 20; for ($i = $offset; $i < $offset + 20 && $i < count($users); $i++) { $user_list[] = $users[$i]; } $page->assign('users', $user_list); } else { // be tricky ^^: show most assigned users $db->setLimit(20); $users = $db->x->getAll('SELECT a.user_id, u.user_name, u.real_name, email_address, count(a.user_id) AS a_count, CASE WHEN t.project_id = ? THEN 1 ELSE 0 END AS my_project FROM {assigned} a LEFT JOIN {users} u ON a.user_id = u.user_id LEFT JOIN {tasks} t ON a.task_id = t.task_id WHERE ( ' . $where . ' )' . ' AND u.account_enabled = 1 GROUP BY a.user_id ORDER BY my_project DESC, a_count DESC', null, array_merge(array($proj->id), $params)); $page->assign('users', $users); } $page->assign('usercount', count($users)); $page->setTitle($fs->prefs['page_title'] . L('userselect')); $page->pushTpl('userselect.tpl'); $page->finish(); }
case 'progress': $arr = array(); for ($i = 0; $i <= 100; $i += 10) { $arr[$i] = $i . '%'; } echo '<select ' . $id . '>' . tpl_options($arr, $task['percent_complete']) . ' </select>'; break; case 'assignedto': // additional permission check is needed if (!$user->perms('edit_assignments')) { header('HTTP/1.1 400 Bad Request'); exit; } $field = 'assigned_to'; $page = new FSTpl(); $page->assign('id', 'task' . $task['task_id'] . '_' . $field); $list = $db->x->getCol('SELECT u.user_name FROM {assigned} a, {users} u WHERE a.user_id = u.user_id AND task_id = ? ORDER BY u.user_name DESC', null, $task['task_id']); $page->assign('userlist', $list); $page->display('common.multiuserselect.tpl'); break; default: // consider custom fields $field_id = substr($field, 5); $f = new Field($field_id); if ($f->id) { echo $f->edit(!USE_DEFAULT, !LOCK_FIELD, $task, array(), array(), 'task' . $task['task_id'] . '_qe'); $field = 'qe' . $field;
function url() { $args = func_get_args(); return FSTpl::relativeUrl(call_user_func_array('CreateUrl', $args)); }
*/ define('IN_FS', true); header('Content-type: text/html; charset=utf-8'); require_once '../../header.php'; require_once '../../includes/events.inc.php'; $baseurl = dirname(dirname($baseurl)) . '/'; // Initialise user if (Cookie::has('flyspray_userid') && Cookie::has('flyspray_passhash')) { $user = new User(Cookie::val('flyspray_userid')); $user->check_account_ok(); } // Check permissions if (!$user->perms('view_history')) { die; } if ($details = Get::num('details')) { $details = " AND h.history_id = {$details}"; } else { $details = null; } $sql = get_events(Get::num('task_id'), $details); $histories = $db->fetchAllArray($sql); $page = new FSTpl(); $page->uses('histories', 'details'); if ($details) { event_description($histories[0]); // modifies global variables $page->assign('details_previous', $GLOBALS['details_previous']); $page->assign('details_new', $GLOBALS['details_new']); } $page->display('details.tabs.history.callback.tpl');
function error($errno, $errstr = '', $errfile = '', $errline = 0) { global $db, $proj, $fs; $page = new FSTpl(); $page->pushTpl('header.tpl'); $page->assign('do', 'index'); $page->setTheme(isset($proj) ? $proj->prefs['theme_style'] : $fs->prefs['global_theme']); if (is_array($errno)) { list($errno, $errstr, $url) = array_pad($errno, 3, ''); } else { // ignore E_STRICT and @ if (($errno > E_ALL || !ini_get('error_reporting')) && (isset($errstr) && strpos($errstr, 'by reference') === false)) { return; } $errno = ERROR_INTERNAL; } if (isset($db) && is_object($db) && $db->inTransaction()) { $db->rollback(); // if possible, undo database queries } switch ($errno) { case ERROR_INTERNAL: $page->assign('file', str_replace(BASEDIR . DIRECTORY_SEPARATOR, '', $errfile)); $page->assign('line', $errline); case ERROR_PERMS: case ERROR_INPUT: @ob_clean(); // make sure that previous output is erased $page->assign('type', $errno); $page->assign('message', $errstr); $page->pushTpl('error.tpl'); $page->finish('footer.tpl'); case ERROR_RECOVER: if ($errstr) { $_SESSION['ERROR'] = $errstr; } if ($url) { Flyspray::Redirect($url); } break; case SUBMIT_OK: if ($errstr) { $_SESSION['SUCCESS'] = $errstr; } if ($url) { Flyspray::Redirect($url); } break; } }