本文整理匯總了PHP中Flyspray類的典型用法代碼示例。如果您正苦於以下問題:PHP Flyspray類的具體用法?PHP Flyspray怎麽用?PHP Flyspray使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Flyspray類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: show
function show()
{
global $page, $db, $user, $fs, $proj;
$page->setTitle($fs->prefs['page_title'] . L('reports'));
$events = array(1 => L('taskopened'), 13 => L('taskreopened'), 2 => L('taskclosed'), 3 => L('taskedited'), 14 => L('assignmentchanged'), 29 => L('events.useraddedtoassignees'), 4 => L('commentadded'), 5 => L('commentedited'), 6 => L('commentdeleted'), 7 => L('attachmentadded'), 8 => L('attachmentdeleted'), 11 => L('relatedadded'), 12 => L('relateddeleted'), 9 => L('notificationadded'), 10 => L('notificationdeleted'), 17 => L('reminderadded'), 18 => L('reminderdeleted'));
$user_events = array(30 => L('created'), 31 => L('deleted'));
$page->assign('events', $events);
$page->assign('user_events', $user_events);
$sort = strtoupper(Get::enum('sort', array('desc', 'asc')));
$where = array();
$params = array();
$orderby = '';
switch (Get::val('order')) {
case 'type':
$orderby = "h.event_type {$sort}, h.event_date {$sort}";
break;
case 'user':
$orderby = "user_id {$sort}, h.event_date {$sort}";
break;
case 'date':
default:
$orderby = "h.event_date {$sort}, h.event_type {$sort}";
}
foreach (Get::val('events', array()) as $eventtype) {
$where[] = 'h.event_type = ?';
$params[] = $eventtype;
}
$where = '(' . implode(' OR ', $where) . ')';
if ($proj->id) {
$where = $where . 'AND (t.project_id = ? OR h.event_type > 29) ';
$params[] = $proj->id;
}
if (($fromdate = Req::val('fromdate')) || Req::val('todate')) {
$where .= ' AND ';
$todate = Req::val('todate');
if ($fromdate) {
$where .= ' h.event_date > ?';
$params[] = Flyspray::strtotime($fromdate) + 0;
}
if ($todate && $fromdate) {
$where .= ' AND h.event_date < ?';
$params[] = Flyspray::strtotime($todate) + 86400;
} else {
if ($todate) {
$where .= ' h.event_date < ?';
$params[] = Flyspray::strtotime($todate) + 86400;
}
}
}
$histories = array();
if (count(Get::val('events'))) {
if (Get::num('event_number') > 0) {
$db->setLimit(Get::num('event_number'));
}
$histories = $db->x->getAll("SELECT h.*, t.*, p.project_prefix\n FROM {history} h\n LEFT JOIN {tasks} t ON h.task_id = t.task_id\n LEFT JOIN {projects} p ON t.project_id = p.project_id\n WHERE {$where}\n ORDER BY {$orderby}", null, $params);
}
$page->assign('histories', $histories);
$page->assign('sort', $sort);
$page->pushTpl('reports.tpl');
}
示例2: area_prefs
function area_prefs()
{
global $page, $user, $fs;
$page->assign('groups', Flyspray::ListGroups());
$page->assign('all_groups', Flyspray::listallGroups($user->id));
$page->assign('theuser', $user);
$page->setTitle($fs->prefs['page_title'] . L('editmydetails'));
}
示例3: setTheme
function setTheme($theme = '')
{
// Check available themes
$themes = Flyspray::listThemes();
if (in_array($theme, $themes)) {
$this->_theme = $theme . '/';
} else {
$this->_theme = $themes[0] . '/';
}
}
示例4: addEffort
/**
* Manually add effort to the effort table for this issue / user.
*
* @param $effort_to_add int Amount of Effort in hours to add to effort table.
*/
public function addEffort($effort_to_add, $proj)
{
global $db;
$effort = self::EditStringToSeconds($effort_to_add, $proj->prefs['hours_per_manday'], $proj->prefs['estimated_effort_format']);
if ($effort === FALSE) {
Flyspray::show_error(L('invalideffort'));
return;
}
$db->Query('INSERT INTO {effort}
(task_id, date_added, user_id,start_timestamp,end_timestamp,effort)
VALUES ( ?, ?, ?, ?,?,? )', array($this->_task_id, time(), $this->_userId, time(), time(), $effort));
}
示例5: execute_upgrade_file
function execute_upgrade_file($folder, $installed_version)
{
global $db, $page, $conf;
// At first the config file
$upgrade_path = BASEDIR . '/upgrade/' . $folder;
new ConfUpdater(CONFIG_PATH, $upgrade_path);
$upgrade_info = parse_ini_file($upgrade_path . '/upgrade.info', true);
// dev version upgrade?
if ($folder == Flyspray::base_version($installed_version)) {
$type = 'develupgrade';
} else {
$type = 'defaultupgrade';
}
// Next a mix of XML schema files and PHP upgrade scripts
if (!isset($upgrade_info[$type])) {
die('#1 Bad upgrade.info file.');
}
ksort($upgrade_info[$type]);
foreach ($upgrade_info[$type] as $file) {
if (substr($file, -4) == '.php') {
require_once $upgrade_path . '/' . $file;
}
if (substr($file, -4) == '.xml') {
$schema = new adoSchema($db->dblink);
$xml = file_get_contents($upgrade_path . '/' . $file);
$xml = str_replace('<table name="', '<table name="' . $conf['database']['dbprefix'], $xml);
$schema->ParseSchemaString($xml);
$schema->ExecuteSchema(null, true);
}
}
// Last but not least global prefs update
if (isset($upgrade_info['fsprefs'])) {
$sql = $db->Query('SELECT pref_name FROM {prefs}');
$existing = $db->FetchCol($sql);
// Add what is missing
foreach ($upgrade_info['fsprefs'] as $name => $value) {
if (!in_array($name, $existing)) {
$db->Query('INSERT INTO {prefs} (pref_name, pref_value) VALUES (?, ?)', array($name, $value));
}
}
// Delete what is too much
foreach ($existing as $name) {
if (!isset($upgrade_info['fsprefs'][$name])) {
$db->Query('DELETE FROM {prefs} WHERE pref_name = ?', array($name));
}
}
}
$db->Query('UPDATE {prefs} SET pref_value = ? WHERE pref_name = ?', array(basename($upgrade_path), 'fs_ver'));
$page->assign('done', true);
}
示例6: show
function show($area = null)
{
global $page, $fs, $db, $proj, $user, $conf;
$perpage = '20';
if (isset($user->infos['tasks_perpage'])) {
$perpage = $user->infos['tasks_perpage'];
}
$pagenum = max(1, Get::num('pagenum', 1));
$offset = $perpage * ($pagenum - 1);
// Get the visibility state of all columns
$visible = explode(' ', trim($proj->id ? $proj->prefs['visible_columns'] : $fs->prefs['visible_columns']));
if (!is_array($visible) || !count($visible) || !$visible[0]) {
$visible = array('id');
}
list($tasks, $id_list) = Backend::get_task_list($_GET, $visible, $offset, $perpage);
$page->assign('tasks', $tasks);
$page->assign('offset', $offset);
$page->assign('perpage', $perpage);
$page->assign('pagenum', $pagenum);
$page->assign('visible', $visible);
// List of task IDs for next/previous links
$_SESSION['tasklist'] = $id_list;
$page->assign('total', count($id_list));
// Javascript replacement
if (Get::val('toggleadvanced')) {
$advanced_search = intval(!Req::val('advancedsearch'));
Flyspray::setCookie('advancedsearch', $advanced_search, time() + 60 * 60 * 24 * 30);
$_COOKIE['advancedsearch'] = $advanced_search;
}
// Update check {{{
if (Get::has('hideupdatemsg')) {
unset($_SESSION['latest_version']);
} else {
if ($conf['general']['update_check'] && $user->perms('is_admin') && $fs->prefs['last_update_check'] < time() - 60 * 60 * 24 * 3) {
if (!isset($_SESSION['latest_version'])) {
$latest = Flyspray::remote_request('http://flyspray.org/version.txt', GET_CONTENTS);
//if for some silly reason we get and empty response, we use the actual version
$_SESSION['latest_version'] = empty($latest) ? $fs->version : $latest;
$db->x->execParam('UPDATE {prefs} SET pref_value = ? WHERE pref_name = ?', array(time(), 'last_update_check'));
}
}
}
if (isset($_SESSION['latest_version']) && version_compare($fs->version, $_SESSION['latest_version'], '<')) {
$page->assign('updatemsg', true);
}
// }}}
$page->setTitle($fs->prefs['page_title'] . $proj->prefs['project_title'] . ': ' . L('tasklist'));
$page->pushTpl('index.tpl');
}
示例7: add_related
function add_related($arr)
{
global $log, $col, $db;
static $imported = array();
$task = $arr[1] . $arr[2];
list($prefix, $task) = explode(strpos($task, '#') !== false ? '#' : ' ', $task);
$task = Flyspray::GetTaskDetails($task, true, $prefix);
if (!$task['task_id'] || isset($imported[$task['task_id'] . '-' . $log['version-name']])) {
return;
}
echo sprintf('<p> Adding task %d for revision %d</p>', $task['task_id'], $log['version-name']);
flush();
$imported[$task['task_id'] . '-' . $log['version-name']] = true;
$db->x->execParam("INSERT INTO {related} (this_task, related_task, {$col}) VALUES (?,?,?)", array($task['task_id'], $log['version-name'], RELATED_SVN));
}
示例8: show
function show()
{
global $db, $page, $fs;
// Some possibly interesting information about the user
$sql = $db->x->GetOne('SELECT count(*) FROM {comments} WHERE user_id = ?', null, $this->user->id);
$page->assign('comments', $sql);
$sql = $db->x->GetOne('SELECT count(*) FROM {tasks} WHERE opened_by = ?', null, $this->user->id);
$page->assign('tasks', $sql);
$sql = $db->x->GetOne('SELECT count(*) FROM {assigned} WHERE user_id = ?', null, $this->user->id);
$page->assign('groups', Flyspray::listallGroups($this->user->id));
$page->assign('assigned', $sql);
$page->assign('theuser', $this->user);
$page->setTitle($fs->prefs['page_title'] . L('viewprofile'));
$page->pushTpl('profile.tpl');
}
示例9: imageAttachment
function imageAttachment($matches)
{
global $db, $baseurl, $user;
// we'll not blindly make images out of all attachments
$ext = substr($matches[1], -3);
if (!in_array($ext, array('png', 'jpg', 'gif'))) {
return $matches[0];
}
$att = $db->x->getRow('SELECT * FROM {attachments} WHERE orig_name = ?', null, $matches[1]);
$task = Flyspray::GetTaskDetails($att['task_id']);
if ($att && $user->can_view_task($task)) {
return sprintf('<img src="%s" alt="%s" />', Filters::noXSS($baseurl . '?getfile=' . $att['attachment_id']), Filters::noXSS($att['orig_name']));
} else {
return $matches[0];
}
}
示例10: addEffort
/**
* Manually add effort to the effort table for this issue / user.
*
* @param $effort_to_add int amount of effort in hh:mm to add to effort table.
*/
public function addEffort($effort_to_add, $proj)
{
global $db;
# note: third parameter seem useless, not used by EditStringToSeconds().., maybe drop it..
$effort = self::EditStringToSeconds($effort_to_add, $proj->prefs['hours_per_manday'], $proj->prefs['estimated_effort_format']);
if ($effort === FALSE) {
Flyspray::show_error(L('invalideffort'));
return false;
}
# quickfix to avoid useless table entries.
if ($effort == 0) {
Flyspray::show_error(L('zeroeffort'));
return false;
} else {
$db->Query('INSERT INTO {effort}
(task_id, date_added, user_id,start_timestamp,end_timestamp,effort)
VALUES ( ?, ?, ?, ?,?,? )', array($this->_task_id, time(), $this->_userId, time(), time(), $effort));
return true;
}
}
示例11: action_edit
function action_edit()
{
foreach (Get::val('ids') as $task_id) {
// Edit or close? If we have a resolution_reason, then close! otherwise, edit.
if (Post::val('resolution_reason')) {
Backend::close_task($task_id, Post::val('resolution_reason'), Post::val('closure_comment'), Post::val('mark100'));
} elseif (count(Post::val('changes'))) {
$task = Flyspray::GetTaskDetails($task_id);
$args = $task;
// import previous values
foreach (Post::val('changes') as $change) {
$args[$change] = Post::val($change);
}
if (is_array($args['assigned_to'])) {
$args['assigned_to'] = implode(';', $task['assigned_to_uname']);
}
Backend::edit_task($task, $args);
}
}
return array(SUBMIT_OK, L('masseditsuccessful'));
}
示例12: action_sendmagic
/**
* action_sendmagic
*
* @access public
* @return array
*/
function action_sendmagic()
{
global $db, $baseurl;
// Check that the username exists
if (strpos(Post::val('user_name'), '@') === false) {
$user = Flyspray::getUserDetails(Flyspray::UserNameToId(Post::val('user_name')));
} else {
$user_id = $db->x->GetOne('SELECT user_id FROM {users} WHERE email_address = ?', null, Post::val('user_name'));
$user = Flyspray::getUserDetails($user_id);
}
// If the username doesn't exist, throw an error
if (!is_array($user) || !count($user)) {
return array(ERROR_RECOVER, L('usernotexist'));
}
$magic_url = md5(uniqid(mt_rand(), true));
// Insert the random "magic url" into the user's profile
$db->x->execParam('UPDATE {users}
SET magic_url = ?
WHERE user_id = ?', array($magic_url, $user['user_id']));
Notifications::send($user['user_id'], ADDRESS_USER, NOTIFY_PW_CHANGE, array($baseurl, $magic_url));
return array(SUBMIT_OK, L('magicurlsent'));
}
示例13: get_task_list
//.........這裏部分代碼省略.........
}
/// }}}
$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);
}
}
$where[] = '(' . implode(array_get($args, 'search_for_all') ? ' AND ' : ' OR ', $where_temp) . ')';
}
if ($user->isAnon()) {
$where[] = 't.mark_private = 0 AND p.others_view = 1';
if (array_key_exists('status', $args)) {
if (in_array('closed', $args['status']) && !in_array('open', $args['status'])) {
示例14: 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)) {
//.........這裏部分代碼省略.........
示例15: logout
public function logout()
{
// Set cookie expiry time to the past, thus removing them
Flyspray::setcookie('flyspray_userid', '', time() - 60);
Flyspray::setcookie('flyspray_passhash', '', time() - 60);
Flyspray::setcookie('flyspray_project', '', time() - 60);
if (Cookie::has(session_name())) {
Flyspray::setcookie(session_name(), '', time() - 60);
}
// Unset all of the session variables.
$_SESSION = array();
session_destroy();
return !$this->isAnon();
}