private function perform_command(FlySprayCommand &$ncmd, array &$out) { static $backend; if (is_null($backend)) { $backend = new Backend(); } //zorn - translate local id to global id if ($ncmd->action != 'active_user') { $ncmd->id = Flyspray::GetTaskId($ncmd->id); } try { $result = $this->process_command($ncmd, $backend); if (is_null($result)) { $result = sprintf('[%s] %s', $ncmd->id, $ncmd->action); } $out[] = new FlySprayResponse(1, $result); } catch (Exception $exc) { $out[] = new FlySprayResponse(0, sprintf('%d - %s', $exc->getCode(), $exc->getMessage())); } }
function tpl_tasklink($task, $text = null, $strict = false, $attrs = array(), $title = array('state', 'summary', 'percent_complete')) { global $user; $params = array(); if (!is_array($task)) { $task = Flyspray::GetTaskDetails(Flyspray::GetTaskId($task), true); } if ($strict === true && (!is_object($user) || !$user->can_view_task($task))) { return ''; } if (is_object($user) && $user->can_view_task($task)) { $summary = utf8_substr($task['item_summary'], 0, 64); } else { $summary = L('taskmadeprivate'); } if (is_null($text)) { $text = sprintf('%s#%d - %s', $task['project_prefix'], $task['prefix_id'], Filters::noXSS($summary)); } elseif (is_string($text)) { $text = Filters::noXSS(utf8_substr($text, 0, 64)); } else { //we can't handle non-string stuff here. return ''; } if (!$task['task_id']) { return $text; } $title_text = array(); foreach ($title as $info) { switch ($info) { case 'state': if ($task['is_closed']) { $title_text[] = L('closed'); $attrs['class'] = 'closedtasklink'; } elseif ($task['closed_by']) { $title_text[] = L('reopened'); } else { $title_text[] = L('open'); } break; case 'summary': $title_text[] = $summary; break; case 'assignedto': if (isset($task['assigned_to_name'])) { if (is_array($task['assigned_to_name'])) { $title_text[] = implode(', ', $task['assigned_to_name']); } else { $title_text[] = $task['assigned_to_name']; } } break; case 'percent_complete': $title_text[] = $task['percent_complete'] . '%'; break; case 'age': $title_text[] = formatDate($task['date_opened']); break; // ... more options if necessary } } $title_text = implode(' | ', $title_text); $params = $_GET; unset($params['do'], $params['action'], $params['task_id'], $params['switch']); $url = Filters::noXSS(FSTpl::relativeUrl(CreateURL(array('details', 'task' . $task['task_id']), $params))); $title_text = Filters::noXSS($title_text); $link = sprintf('<a href="%s" title="%s" %s>%s</a>', $url, $title_text, join_attrs($attrs), $text); if ($task['is_closed']) { $link = '<del> ' . $link . ' </del>'; } return $link; }
} 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)); $page->assign('pm_pendingreq_num', $count); } // Get e-mail addresses of the admins if ($user->isAnon() && !$fs->prefs['user_notify']) { $amails = $db->x->getCol('SELECT email_address FROM {users} u
function action_add_related($task) { global $user, $db, $fs, $proj; if (!$user->can_edit_task($task)) { return array(ERROR_PERMS); } $task_id = Flyspray::GetTaskId(Post::val('related_task')); $pid = $db->x->GetOne('SELECT project_id FROM {tasks} WHERE task_id = ?', null, $task_id); if (!$pid) { return array(ERROR_RECOVER, L('relatedinvalid')); } $rid = $db->x->GetOne('SELECT related_id FROM {related} WHERE related_type IN (0,1) AND (this_task = ? AND related_task = ? OR related_task = ? AND this_task = ?)', null, array($task['task_id'], $task_id, $task['task_id'], $task_id)); if ($rid) { return array(ERROR_RECOVER, L('relatederror')); } $db->x->autoExecute('{related}', array('this_task' => $task['task_id'], 'related_task' => $task_id, 'related_type' => RELATED_TASK)); Flyspray::logEvent($task['task_id'], 11, $task_id); Flyspray::logEvent($task_id, 11, $task['task_id']); Notifications::send($task['task_id'], ADDRESS_TASK, NOTIFY_REL_ADDED, array('rel_task' => $task_id)); return array(SUBMIT_OK, L('relatedaddedmsg')); }