本文整理汇总了PHP中Filters::enum方法的典型用法代码示例。如果您正苦于以下问题:PHP Filters::enum方法的具体用法?PHP Filters::enum怎么用?PHP Filters::enum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filters
的用法示例。
在下文中一共展示了Filters::enum方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Project
function Project($id)
{
global $db, $fs;
// Get custom fields
$fields = $db->x->getAll('SELECT f.*, l.list_type
FROM {fields} f
LEFT JOIN {lists} l ON f.list_id = l.list_id
WHERE f.project_id IN (0, ?) ORDER BY field_name', null, array($id));
foreach ($fields as $field) {
$f = new Field($field);
if ($f->id == $fs->prefs['color_field']) {
$f->values = $this->get_list($f->prefs, $f->id);
}
$this->fields['field' . $field['field_id']] = $f;
}
$this->columns = array_combine($this->columns, array_map('L', $this->columns));
foreach ($this->fields as $field) {
$this->columns['field' . $field->id] = $field->prefs['field_name'];
}
if (is_numeric($id) && $id > 0) {
$this->prefs = $db->x->getRow("SELECT p.*, c.content AS pm_instructions, c.last_updated AS cache_update\n FROM {projects} p\n LEFT JOIN {cache} c ON c.topic = p.project_id AND c.type = 'msg'\n WHERE p.project_id = ?", null, array($id));
if (is_array($this->prefs)) {
$this->id = (int) $this->prefs['project_id'];
$this->prefs['visible_columns'] = implode(' ', array_intersect(explode(' ', $this->prefs['visible_columns']), array_keys($this->columns)));
$this->prefs['theme_style'] = Filters::enum($this->prefs['theme_style'], Flyspray::listThemes());
return;
}
}
$this->id = 0;
$this->prefs = array();
$this->prefs['project_title'] = L('allprojects');
$this->prefs['feed_description'] = L('feedforall');
$this->prefs['theme_style'] = $fs->prefs['global_theme'];
$this->prefs['theme_style'] = Filters::enum($this->prefs['theme_style'], Flyspray::listThemes());
$this->prefs['lang_code'] = $fs->prefs['lang_code'];
$this->prefs['others_view'] = 1;
$this->prefs['intro_message'] = '';
$this->prefs['anon_open'] = $this->prefs['override_user_lang'] = 0;
$this->prefs['feed_img_url'] = '';
$this->prefs['default_entry'] = $fs->prefs['default_entry'];
$this->prefs['notify_reply'] = '';
$fs->prefs['visible_columns'] = implode(' ', array_intersect(explode(' ', $fs->prefs['visible_columns']), array_keys($this->columns)));
return;
}
示例2: get_task_list
//.........这里部分代码省略.........
$temp .= ' product_category = ? OR';
$sql_params[] = $row['category_id'];
}
}
}
if ($temp) {
$where[] = '(' . substr($temp, 0, -3) . ')';
}
}
/// }}}
$order_keys = array('id' => 't.task_id', 'project' => 'project_title', 'tasktype' => 'tasktype_name', 'dateopened' => 'date_opened', 'summary' => 'item_summary', 'severity' => 'task_severity', 'category' => 'lc.category_name', 'status' => 'is_closed, item_status', 'dueversion' => 'lvc.list_position', 'duedate' => 'due_date', 'progress' => 'percent_complete', 'lastedit' => 'max_date', 'priority' => 'task_priority', 'openedby' => 'uo.real_name', 'reportedin' => 't.product_version', 'assignedto' => 'u.real_name', 'dateclosed' => 't.date_closed', 'os' => 'los.os_name', 'votes' => 'num_votes', 'attachments' => 'num_attachments', 'comments' => 'num_comments', 'private' => 'mark_private', 'supertask' => 't.supertask_id');
// make sure that only columns can be sorted that are visible (and task severity, since it is always loaded)
$order_keys = array_intersect_key($order_keys, array_merge(array_flip($visible), array('severity' => 'task_severity')));
// Implementing setting "Default order by"
if (!array_key_exists('order', $args)) {
# now also for $proj->id=0 (allprojects)
$orderBy = $proj->prefs['sorting'][0]['field'];
$sort = $proj->prefs['sorting'][0]['dir'];
if (count($proj->prefs['sorting']) > 1) {
$orderBy2 = $proj->prefs['sorting'][1]['field'];
$sort2 = $proj->prefs['sorting'][1]['dir'];
} else {
$orderBy2 = 'severity';
$sort2 = 'DESC';
}
} else {
$orderBy = $args['order'];
$sort = $args['sort'];
$orderBy2 = 'severity';
$sort2 = 'desc';
}
// TODO: Fix this! If something is already ordered by task_id, there's
// absolutely no use to even try to order by something else also.
$order_column[0] = $order_keys[Filters::enum(array_get($args, 'order', $orderBy), array_keys($order_keys))];
$order_column[1] = $order_keys[Filters::enum(array_get($args, 'order2', $orderBy2), array_keys($order_keys))];
$sortorder = sprintf('%s %s, %s %s, t.task_id ASC', $order_column[0], Filters::enum(array_get($args, 'sort', $sort), array('asc', 'desc')), $order_column[1], Filters::enum(array_get($args, 'sort2', $sort2), array('asc', 'desc')));
$having = array();
$dates = array('duedate' => 'due_date', 'changed' => $maxdatesql, 'opened' => 'date_opened', 'closed' => 'date_closed');
foreach ($dates as $post => $db_key) {
$var = $post == 'changed' ? 'having' : 'where';
if ($date = array_get($args, $post . 'from')) {
${$var}[] = '(' . $db_key . ' >= ' . Flyspray::strtotime($date) . ')';
}
if ($date = array_get($args, $post . 'to')) {
${$var}[] = '(' . $db_key . ' <= ' . Flyspray::strtotime($date) . ' AND ' . $db_key . ' > 0)';
}
}
if (array_get($args, 'string')) {
$words = explode(' ', strtr(array_get($args, 'string'), '()', ' '));
$comments = '';
$where_temp = array();
if (array_get($args, 'search_in_comments')) {
$comments .= " OR c.comment_text {$LIKEOP} ?";
}
if (array_get($args, 'search_in_details')) {
$comments .= " OR t.detailed_desc {$LIKEOP} ?";
}
foreach ($words as $word) {
$likeWord = '%' . str_replace('+', ' ', trim($word)) . '%';
$where_temp[] = "(t.item_summary {$LIKEOP} ? OR t.task_id = ? {$comments})";
array_push($sql_params, $likeWord, intval($word));
if (array_get($args, 'search_in_comments')) {
array_push($sql_params, $likeWord);
}
if (array_get($args, 'search_in_details')) {
array_push($sql_params, $likeWord);
示例3: get_task_list
/**
* Returns an array of tasks (respecting pagination) and an ID list (all tasks)
* @param array $args call by reference because we have to modifiy $_GET if we use default values from a user profile
* @param array $visible
* @param integer $offset
* @param integer $comment
* @param bool $perpage
* @access public
* @return array
* @version 1.0
*/
function get_task_list(&$args, $visible, $offset = 0, $perpage = null)
{
global $proj, $db, $user, $conf, $fs;
/* build SQL statement {{{ */
// Original SQL courtesy of Lance Conry http://www.rhinosw.com/
$where = $sql_params = array();
$select = '';
$groupby = 't.task_id, ';
$from = ' {tasks} t
LEFT JOIN {projects} p ON t.project_id = p.project_id
LEFT JOIN {list_items} lr ON t.resolution_reason = lr.list_item_id
LEFT JOIN {redundant} r ON t.task_id = r.task_id ';
// Only join tables which are really necessary to speed up the db-query
$from .= ' LEFT JOIN {assigned} ass ON t.task_id = ass.task_id ';
$from .= ' LEFT JOIN {users} u ON ass.user_id = u.user_id ';
if (array_get($args, 'dev') || in_array('assignedto', $visible)) {
$select .= ' MIN(u.real_name) AS assigned_to_name, ';
$select .= ' COUNT(ass.user_id) AS num_assigned, ';
}
if (array_get($args, 'only_primary')) {
$from .= ' LEFT JOIN {dependencies} dep ON dep.dep_task_id = t.task_id ';
$where[] = 'dep.depend_id IS null';
}
if (array_get($args, 'has_attachment')) {
$where[] = 'attachment_count > 0';
}
// sortable default fields
$order_keys = array('id' => 't.task_id %s', 'project' => 'project_title %s', 'dateopened' => 'date_opened %s', 'summary' => 'item_summary %s', 'progress' => 'percent_complete %s', 'lastedit' => 'last_changed_time %s', 'openedby' => 'r.opened_by_real_name %s', 'closedby' => 'r.closed_by_real_name %s', 'changedby' => 'r.last_changed_by_real_name %s', 'assignedto' => 'u.real_name %s', 'dateclosed' => 't.date_closed %s', 'votes' => 'vote_count %s', 'attachments' => 'attachment_count %s', 'comments' => 'comment_count %s', 'state' => 'closed_by %1$s, is_closed %1$s', 'projectlevelid' => 'prefix_id %s', 'private' => 'mark_private %s');
// custom sortable fields
foreach ($proj->fields as $field) {
if ($field->prefs['list_type'] == LIST_CATEGORY) {
// consider hierarchical structure of categories
$order_keys['field' . $field->id] = 'lcfield' . $field->id . '.lft %1$s, field' . $field->id . ' %1$s';
} else {
$order_keys['field' . $field->id] = 'field' . $field->id . ' %s';
}
}
// Default user sort column and order
if (!$user->isAnon()) {
if (!isset($args['sort'])) {
$args['sort'] = $user->infos['defaultorder'];
}
if (!isset($args['order'])) {
$usercolumns = explode(' ', $user->infos['defaultsortcolumn']);
foreach ($usercolumns as $column) {
if (isset($order_keys[$column])) {
$args['order'] = $column;
break;
}
}
}
}
// make sure that only columns can be sorted that are visible
$order_keys = array_intersect_key($order_keys, array_flip($visible));
$order_column[0] = $order_keys[Filters::enum(array_get($args, 'order', 'id'), array_keys($order_keys))];
$order_column[1] = $order_keys[Filters::enum(array_get($args, 'order2', 'project'), array_keys($order_keys))];
$order_column[0] = sprintf($order_column[0], strtoupper(Filters::enum(array_get($args, 'sort', 'desc'), array('asc', 'desc'))));
$order_column[1] = sprintf($order_column[1], strtoupper(Filters::enum(array_get($args, 'sort2', 'desc'), array('asc', 'desc'))));
$sortorder = sprintf('%s, %s, t.task_id ASC', $order_column[0], $order_column[1]);
// search custom fields
$custom_fields_joined = array();
foreach ($proj->fields as $field) {
$ref = 'field' . $field->id;
if ($field->prefs['field_type'] == FIELD_DATE) {
if (!array_get($args, 'field' . $field->id . 'from') && !array_get($args, 'field' . $field->id . 'to')) {
continue;
}
$from .= " LEFT JOIN {field_values} {$ref} ON t.task_id = {$ref}.task_id AND {$ref}.field_id = {$field->id} ";
$custom_fields_joined[] = $field->id;
if ($date = array_get($args, 'field' . $field->id . 'from')) {
$where[] = "({$ref}.field_value >= ?)";
$sql_params[] = Flyspray::strtotime($date);
}
if ($date = array_get($args, 'field' . $field->id . 'to')) {
$where[] = "({$ref}.field_value <= ? AND {$ref}.field_value > 0)";
$sql_params[] = Flyspray::strtotime($date);
}
} elseif ($field->prefs['field_type'] == FIELD_LIST) {
if (in_array('', (array) array_get($args, 'field' . $field->id, array('')))) {
continue;
}
$from .= " LEFT JOIN {field_values} {$ref} ON t.task_id = {$ref}.task_id AND {$ref}.field_id = {$field->id} ";
$custom_fields_joined[] = $field->id;
$fwhere = array();
foreach ($args['field' . $field->id] as $val) {
$fwhere[] = " {$ref}.field_value = ? ";
$sql_params[] = $val;
}
if (count($fwhere)) {
//.........这里部分代码省略.........
示例4: get_events
function get_events($task_id, $where = '', $sort = 'ASC')
{
global $db;
$sort = Filters::enum($sort, array('ASC', 'DESC'));
return $db->x->getAll("SELECT h.*,\n p1.project_title AS project_id1,\n p2.project_title AS project_id2,\n lr.item_name AS resolution_name,\n c.date_added AS c_date_added,\n c.user_id AS c_user_id,\n att.orig_name,\n lfn.item_name AS new_value_l,\n lfo.item_name AS old_value_l,\n lcfn.category_name AS new_value_c,\n lcfn.category_name AS old_value_c,\n f.*, li.list_type\n\n FROM {history} h\n\n LEFT JOIN {list_items} lr ON lr.list_item_id = h.new_value AND h.event_type = 2\n LEFT JOIN {list_items} lfn ON lfn.list_item_id = h.new_value AND h.event_type = 3\n LEFT JOIN {list_items} lfo ON lfo.list_item_id = h.old_value AND h.event_type = 3\n LEFT JOIN {list_category} lcfn ON lcfn.category_id = h.new_value AND h.event_type = 3\n LEFT JOIN {list_category} lcfo ON lcfo.category_id = h.old_value AND h.event_type = 3\n LEFT JOIN {fields} f ON f.field_id = h.field_changed AND h.event_type = 3\n LEFT JOIN {lists} li ON f.list_id = li.list_id\n\n LEFT JOIN {projects} p1 ON p1.project_id = h.old_value AND h.field_changed='project_id'\n LEFT JOIN {projects} p2 ON p2.project_id = h.new_value AND h.field_changed='project_id'\n\n LEFT JOIN {comments} c ON c.comment_id = h.field_changed AND h.event_type = 5\n\n LEFT JOIN {attachments} att ON att.attachment_id = h.new_value AND h.event_type = 7\n\n WHERE h.task_id = ? {$where}\n ORDER BY event_date {$sort}, event_type ASC", null, $task_id);
}
示例5: die
if (is_readable(BASEDIR . '/setup/index.php') && strpos($fs->version, 'dev') === false) {
die('Please empty the folder "' . BASEDIR . DIRECTORY_SEPARATOR . "setup\" before you start using Flyspray.\n" . "If you are upgrading, please go to the setup directory and launch upgrade.php");
}
// Get available do-modes and include the classes
$modes = str_replace('.php', '', array_map('basename', glob_compat(BASEDIR . "/scripts/*.php")));
// yes, we need all of them for now
foreach ($modes as $mode) {
require_once BASEDIR . '/scripts/' . $mode . '.php';
}
$do = Req::val('do');
// Any "do" mode that accepts a task_id or id field should be added here.
if (Req::num('task_id')) {
$project_id = $db->x->GetOne('SELECT project_id
FROM {tasks}
WHERE task_id = ?', null, Req::num('task_id'));
$do = Filters::enum($do, array('details', 'depends', 'editcomment'));
} else {
if ($do == 'admin' && Get::has('switch') && Get::val('project') != '0') {
$do = 'pm';
} elseif ($do == 'pm' && Get::has('switch') && Get::val('project') == '0') {
$do = 'admin';
} elseif (Get::has('switch') && $do == 'details') {
$do = 'index';
}
if ($do && class_exists('FlysprayDo' . ucfirst($do)) && !call_user_func(array('FlysprayDo' . ucfirst($do), 'is_projectlevel'))) {
$project_id = 0;
}
}
if (!isset($project_id)) {
// Determine which project we want to see
if (($project_id = Cookie::val('flyspray_project')) == '') {
示例6: area_users
/**
* area_users
*
* @access public
* @return void
*/
function area_users()
{
global $fs, $db, $proj, $user, $page;
// Prepare the sorting
$order_keys = array('username' => 'user_name', 'realname' => 'real_name', 'email' => 'email_address', 'jabber' => 'jabber_id', 'regdate' => 'register_date', 'status' => 'account_enabled');
$order_column[0] = $order_keys[Filters::enum(Get::val('order', 'username'), array_keys($order_keys))];
$order_column[1] = $order_keys[Filters::enum(Get::val('order2', 'username'), array_keys($order_keys))];
$sortorder = sprintf('%s %s, %s %s, u.user_id ASC', $order_column[0], Filters::enum(Get::val('sort', 'desc'), array('asc', 'desc')), $order_column[1], Filters::enum(Get::val('sort2', 'desc'), array('asc', 'desc')));
// Search options
$search_keys = array('user_name', 'real_name', 'email_address', 'jabber_id');
$where = 'WHERE 1=1 ';
$args = array();
foreach ($search_keys as $key) {
if (Get::val($key) != '') {
$where .= sprintf(' AND %s LIKE ? ', $key);
$args[] = '%' . Get::val($key) . '%';
}
}
// Search for users in a specific group
$groups = Get::val('group_id');
if (is_array($groups) && count($groups) && !in_array(0, $groups)) {
$where = ' LEFT JOIN {users_in_groups} uig ON u.user_id = uig.user_id ' . $where;
$where .= ' AND (' . substr(str_repeat(' uig.group_id = ? OR ', count($groups)), 0, -3) . ' ) ';
$args = array_merge($args, $groups);
}
$sql = $db->x->getAll('SELECT u.user_id, u.user_name, u.real_name, u.register_date,
u.jabber_id, u.email_address, u.account_enabled
FROM {users} u ' . $where . 'ORDER BY ' . $sortorder, null, $args);
$users = GroupBy($sql, 'user_id');
$page->assign('user_count', count($users));
// Offset and limit
$user_list = array();
$offset = max(Get::num('pagenum') - 1, 0) * 50;
for ($i = $offset; $i < $offset + 50 && $i < count($users); $i++) {
$user_list[] = $users[$i];
}
// Get the user groups in a separate query because groups may be hidden
// because of search options which are disregarded here
if (count($user_list)) {
$in = implode(',', array_map(create_function('$x', 'return reset($x);'), $user_list));
$sql = $db->x->getAll('SELECT user_id, g.group_id, g.group_name, g.project_id
FROM {groups} g
LEFT JOIN {users_in_groups} uig ON uig.group_id = g.group_id
WHERE user_id IN (' . $in . ')');
$user_groups = GroupBy($sql, 'user_id', array('group_id', 'group_name', 'project_id'), !REINDEX);
$page->assign('user_groups', $user_groups);
}
$page->assign('all_groups', Flyspray::listallGroups());
$page->assign('user_list', $user_list);
}
示例7: get_task_list
/**
* Returns an array of tasks (respecting pagination) and an ID list (all tasks)
* @param array $args
* @param array $visible
* @param integer $offset
* @param integer $comment
* @param bool $perpage
* @access public
* @return array
* @version 1.0
*/
public static function get_task_list($args, $visible, $offset = 0, $perpage = 20)
{
global $proj, $db, $user, $conf;
/* build SQL statement {{{ */
// Original SQL courtesy of Lance Conry http://www.rhinosw.com/
$where = $sql_params = array();
$select = '';
$groupby = 't.task_id, ';
$from = ' {tasks} t
LEFT JOIN {projects} p ON t.project_id = p.project_id
LEFT JOIN {list_tasktype} lt ON t.task_type = lt.tasktype_id
LEFT JOIN {list_status} lst ON t.item_status = lst.status_id
LEFT JOIN {list_resolution} lr ON t.resolution_reason = lr.resolution_id ';
// Only join tables which are really necessary to speed up the db-query
if (array_get($args, 'cat') || in_array('category', $visible)) {
$from .= ' LEFT JOIN {list_category} lc ON t.product_category = lc.category_id ';
$select .= ' lc.category_name AS category_name, ';
$groupby .= 'lc.category_name, ';
}
if (in_array('votes', $visible)) {
$from .= ' LEFT JOIN {votes} vot ON t.task_id = vot.task_id ';
$select .= ' COUNT(DISTINCT vot.vote_id) AS num_votes, ';
}
$maxdatesql = ' GREATEST((SELECT max(c.date_added) FROM {comments} c WHERE c.task_id = t.task_id), t.date_opened, t.date_closed, t.last_edited_time) ';
$search_for_changes = in_array('lastedit', $visible) || array_get($args, 'changedto') || array_get($args, 'changedfrom');
if ($search_for_changes) {
$select .= ' GREATEST((SELECT max(c.date_added) FROM {comments} c WHERE c.task_id = t.task_id), t.date_opened, t.date_closed, t.last_edited_time) AS max_date, ';
}
if (array_get($args, 'search_in_comments')) {
$from .= ' LEFT JOIN {comments} c ON t.task_id = c.task_id ';
}
if (in_array('comments', $visible)) {
$select .= ' (SELECT COUNT(cc.comment_id) FROM {comments} cc WHERE cc.task_id = t.task_id) AS num_comments, ';
}
if (in_array('reportedin', $visible)) {
$from .= ' LEFT JOIN {list_version} lv ON t.product_version = lv.version_id ';
$select .= ' lv.version_name AS product_version, ';
$groupby .= 'lv.version_name, ';
}
if (array_get($args, 'opened') || in_array('openedby', $visible)) {
$from .= ' LEFT JOIN {users} uo ON t.opened_by = uo.user_id ';
$select .= ' uo.real_name AS opened_by_name, ';
$groupby .= 'uo.real_name, ';
}
if (array_get($args, 'closed')) {
$from .= ' LEFT JOIN {users} uc ON t.closed_by = uc.user_id ';
$select .= ' uc.real_name AS closed_by_name, ';
$groupby .= 'uc.real_name, ';
}
if (array_get($args, 'due') || in_array('dueversion', $visible)) {
$from .= ' LEFT JOIN {list_version} lvc ON t.closedby_version = lvc.version_id ';
$select .= ' lvc.version_name AS closedby_version, ';
$groupby .= 'lvc.version_name, ';
}
if (in_array('os', $visible)) {
$from .= ' LEFT JOIN {list_os} los ON t.operating_system = los.os_id ';
$select .= ' los.os_name AS os_name, ';
$groupby .= 'los.os_name, ';
}
if (in_array('attachments', $visible) || array_get($args, 'has_attachment')) {
$from .= ' LEFT JOIN {attachments} att ON t.task_id = att.task_id ';
$select .= ' COUNT(DISTINCT att.attachment_id) AS num_attachments, ';
}
$from .= ' LEFT JOIN {assigned} ass ON t.task_id = ass.task_id ';
$from .= ' LEFT JOIN {users} u ON ass.user_id = u.user_id ';
if (array_get($args, 'dev') || in_array('assignedto', $visible)) {
$select .= ' MIN(u.real_name) AS assigned_to_name, ';
$select .= ' COUNT(DISTINCT ass.user_id) AS num_assigned, ';
}
if (array_get($args, 'only_primary')) {
$from .= ' LEFT JOIN {dependencies} dep ON dep.dep_task_id = t.task_id ';
$where[] = 'dep.depend_id IS NULL';
}
if (array_get($args, 'has_attachment')) {
$where[] = 'att.attachment_id IS NOT NULL';
}
if ($proj->id) {
$where[] = 't.project_id = ?';
$sql_params[] = $proj->id;
}
$order_keys = array('id' => 't.task_id', 'project' => 'project_title', 'tasktype' => 'tasktype_name', 'dateopened' => 'date_opened', 'summary' => 'item_summary', 'severity' => 'task_severity', 'category' => 'lc.category_name', 'status' => 'is_closed, item_status', 'dueversion' => 'lvc.list_position', 'duedate' => 'due_date', 'progress' => 'percent_complete', 'lastedit' => 'max_date', 'priority' => 'task_priority', 'openedby' => 'uo.real_name', 'reportedin' => 't.product_version', 'assignedto' => 'u.real_name', 'dateclosed' => 't.date_closed', 'os' => 'los.os_name', 'votes' => 'num_votes', 'attachments' => 'num_attachments', 'comments' => 'num_comments', 'private' => 'mark_private');
// make sure that only columns can be sorted that are visible (and task severity, since it is always loaded)
$order_keys = array_intersect_key($order_keys, array_merge(array_flip($visible), array('severity' => 'task_severity')));
$order_column[0] = $order_keys[Filters::enum(array_get($args, 'order', 'severity'), array_keys($order_keys))];
$order_column[1] = $order_keys[Filters::enum(array_get($args, 'order2', 'priority'), array_keys($order_keys))];
$sortorder = sprintf('%s %s, %s %s, t.task_id ASC', $order_column[0], Filters::enum(array_get($args, 'sort', 'desc'), array('asc', 'desc')), $order_column[1], Filters::enum(array_get($args, 'sort2', 'desc'), array('asc', 'desc')));
/// process search-conditions {{{
$submits = array('type' => 'task_type', 'sev' => 'task_severity', 'due' => 'closedby_version', 'reported' => 'product_version', 'cat' => 'product_category', 'status' => 'item_status', 'percent' => 'percent_complete', 'pri' => 'task_priority', 'dev' => array('a.user_id', 'us.user_name', 'us.real_name'), 'opened' => array('opened_by', 'uo.user_name', 'uo.real_name'), 'closed' => array('closed_by', 'uc.user_name', 'uc.real_name'));
foreach ($submits as $key => $db_key) {
//.........这里部分代码省略.........
示例8: show
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();
}
示例9: enum
function enum($key, $options, $default = null)
{
return Filters::enum(Get::val($key, $default), $options);
}
示例10: show
/**
* show
*
* @access public
* @return void
*/
function show()
{
global $user, $page, $fs, $conf, $db, $proj, $baseurl;
$path_to_dot = array_get($conf['general'], 'dot_path', '');
//php 4 on windows does not have is_executable..
$func = function_exists('is_executable') ? 'is_executable' : 'is_file';
$path_to_dot = $func($path_to_dot) ? $path_to_dot : '';
$useLocal = !Flyspray::function_disabled('shell_exec') && $path_to_dot;
$fmt = Filters::enum(array_get($conf['general'], 'dot_format', 'png'), array('png', 'svg'));
$id = $this->task['task_id'];
$page->assign('task_id', $id);
$prunemode = Get::num('prune', 0);
$selfurl = CreateURL(array('depends', 'task' . $id));
$pmodes = array(L('none'), L('pruneclosedlinks'), L('pruneclosedtasks'));
foreach ($pmodes as $mode => $desc) {
if ($mode == $prunemode) {
$strlist[] = $desc;
} else {
$strlist[] = "<a href='" . Filters::noXSS($selfurl) . ($mode != 0 ? "&prune={$mode}" : "") . "'>{$desc}</a>\n";
}
}
$page->assign('strlist', $strlist);
$starttime = microtime();
$sql = 'SELECT t1.task_id AS id1, t1.prefix_id AS pxid1, p1.project_prefix AS ppx1, t1.item_summary AS sum1,
t1.percent_complete AS pct1, t1.is_closed AS clsd1,
t1.closure_comment AS com1, u1c.real_name AS clsdby1,
r1.item_name as res1,
t2.task_id AS id2, t2.prefix_id AS pxid2, p2.project_prefix AS ppx2, t2.item_summary AS sum2,
t2.percent_complete AS pct2, t2.is_closed AS clsd2,
t2.closure_comment AS com2, u2c.real_name AS clsdby2,
r2.item_name as res2
FROM {dependencies} AS d
JOIN {tasks} AS t1 ON d.task_id=t1.task_id
LEFT JOIN {users} AS u1c ON t1.closed_by=u1c.user_id
LEFT JOIN {projects} AS p1 ON t1.project_id = p1.project_id
LEFT JOIN {list_items} AS r1 ON t1.resolution_reason=r1.list_item_id
JOIN {tasks} AS t2 ON d.dep_task_id=t2.task_id
LEFT JOIN {users} AS u2c ON t2.closed_by=u2c.user_id
LEFT JOIN {projects} AS p2 ON t2.project_id = p2.project_id
LEFT JOIN {list_items} AS r2 ON t2.resolution_reason=r2.list_item_id
WHERE t1.project_id= ?
ORDER BY d.task_id, d.dep_task_id';
$edges = $db->x->getAll($sql, null, $proj->id);
$edge_list = array();
$rvrs_list = array();
$node_list = array();
foreach ($edges as $row) {
extract($row, EXTR_REFS);
$edge_list[$id1][] = $id2;
$rvrs_list[$id2][] = $id1;
if (!isset($node_list[$id1])) {
$node_list[$id1] = array('id' => $id1, 'sum' => $sum1, 'pct' => $pct1, 'clsd' => $clsd1, 'ppx' => $ppx1, 'pxid' => $pxid1, 'com' => $com1, 'clsdby' => $clsdby1, 'res' => $res1);
}
if (!isset($node_list[$id2])) {
$node_list[$id2] = array('id' => $id2, 'sum' => $sum2, 'pct' => $pct2, 'clsd' => $clsd2, 'ppx' => $ppx2, 'pxid' => $pxid2, 'com' => $com2, 'clsdby' => $clsdby2, 'res' => $res2);
}
}
// Now we have our lists of nodes and edges, along with a helper
// list of reverse edges. Time to do the graph coloring, so we know
// which ones are in our particular connected graph. We'll set up a
// list and fill it up as we visit nodes that are connected to our
// main task.
$connected = array();
$levelsdown = 0;
$levelsup = 0;
function ConnectsTo($id, $down, $up, &$connected, &$edge_list, &$rvrs_list, &$levelsdown, &$levelsup, &$prunemode, &$node_list)
{
if (!isset($connected[$id])) {
$connected[$id] = 1;
}
if ($down > $levelsdown) {
$levelsdown = $down;
}
if ($up > $levelsup) {
$levelsup = $up;
}
$selfclosed = $node_list[$id]['clsd'];
if (isset($edge_list[$id])) {
foreach ($edge_list[$id] as $neighbor) {
$neighborclosed = $node_list[$neighbor]['clsd'];
if (!isset($connected[$neighbor]) && !($prunemode == 1 && $selfclosed && $neighborclosed) && !($prunemode == 2 && $neighborclosed)) {
ConnectsTo($neighbor, $down, $up + 1, $connected, $edge_list, $rvrs_list, $levelsdown, $levelsup, $prunemode, $node_list);
}
}
}
if (isset($rvrs_list[$id])) {
foreach ($rvrs_list[$id] as $neighbor) {
$neighborclosed = $node_list[$neighbor]['clsd'];
if (!isset($connected[$neighbor]) && !($prunemode == 1 && $selfclosed && $neighborclosed) && !($prunemode == 2 && $neighborclosed)) {
ConnectsTo($neighbor, $down + 1, $up, $connected, $edge_list, $rvrs_list, $levelsdown, $levelsup, $prunemode, $node_list);
}
}
}
}
//.........这里部分代码省略.........