<?php // Get task ID to add this step to $task_id = TaskerMAN\Core\IO::GET('task_id'); try { // Creates a new step, loads information, and then saves $step = new TaskerMAN\Application\TaskStep(); $step->setTaskID(TaskerMAN\Core\IO::GET('task_id')); $step->setComment(TaskerMAN\Core\IO::POST('comment')); $step->setTitle(TaskerMAN\Core\IO::POST('title')); $step->save(); } catch (TaskerMAN\Application\TaskException $e) { } // Redirect back to the task page header('Location: index.php?p=task&id=' . $task_id);
<?php // Get username and password $email = TaskerMAN\Core\IO::GET('email'); $password = TaskerMAN\Core\IO::GET('password'); if (empty($email) || empty($password)) { throw new TaskerMAN\Application\APIErrorException('Requires email and password'); } // Verify the user's login credentials $user = TaskerMAN\Application\Login::verifyCredentials($email, $password); // Login details incorrect if (!$user) { throw new TaskerMAN\Application\APIErrorException('Incorrect email or password'); } // Login success, return API Token echo TaskerMAN\Application\API::response(array('key' => $user->api_token));
<?php $uid = TaskerMAN\Core\IO::GET('id'); $user = new TaskerMAN\Application\User($uid); // User does not exist, throw 404 if (!$user->exists) { throw new TaskMAN\Core\FatalException('404 - Page Not Found', new \Exception('Requested user (' . $uid . ') was not found')); } TaskerMAN\WebInterface\WebInterface::setTitle($user->name); $stats = TaskerMAN\Application\DashboardStats::getStats($user->id); if (isset($_POST['delete'])) { try { TaskerMAN\Application\UserManagement::delete($uid); if ($uid == TaskerMAN\WebInterface\WebInterface::$user->getID()) { // User deleted themselves, log them out TaskerMAN\WebInterface\Session::destroy(); header('Location: index.php?p=login'); exit; } header('Location: index.php?p=list_users'); exit; } catch (TaskerMAN\Application\UserManagementException $e) { $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>'; } } elseif (isset($_POST['submit'])) { // Form submitted if (isset($_POST['admin'])) { $is_admin = true; } else { $is_admin = false; }
echo $stats['average_completion_time']; ?> average completion time</span> </div> </div> <?php // Only show 'Allocated' tasks TaskerMAN\Application\TaskListInterface::setSearchCriteria('status', 1); // Pagination $Pagination = new TaskerMAN\WebInterface\WebPagination(); $Pagination->setItemsPerPage(25); $Pagination->setNumItems(TaskerMAN\Application\TaskListInterface::getNumTasks()); $Pagination->setCurrentPage(TaskerMAN\Core\IO::GET('page')); $Pagination->setBaseURL('index.php?p=main'); TaskerMAN\Application\TaskListInterface::setStartPosition($Pagination->generateLIMITStartPosition()); TaskerMAN\Application\TaskListInterface::setLimit($Pagination->getItemsPerPage()); // Load tasks $TaskData = TaskerMAN\Application\TaskListInterface::getTasks(true); ?> <h2 class="sub-header">Outstanding Tasks</h2> <div class="table-responsive"> <div align="center"> <?php echo $Pagination->getOutput(); ?> </div>
<?php // Get task ID and status variables $task_id = (int) TaskerMAN\Core\IO::GET('id'); $status = (int) TaskerMAN\Core\IO::GET('status'); // Expects time in UNIX timestamp format $completed_time = (int) TaskerMAN\Core\IO::GET('completed_time'); // If no completed time is passed, use current time if (empty($completed_time)) { $completed_time = time(); } $task = new TaskerMAN\Application\Task($task_id); if (empty($task->id)) { // Unable to load task, throw error throw new TaskerMAN\Application\APIErrorException('Invalid task ID'); } switch ($status) { // Make sure we're not setting the status to a state it's already in case $task->status: throw new TaskerMAN\Application\APIErrorException('Trying to change status to same value as it already has'); break; // allocated // allocated case 1: $task->setStatus(1); $task->setCompletedTime('0000-00-00 00:00:00'); break; // completed // completed case 2: $task->setStatus(2);
<?php // Get array of task IDs $ids = explode(',', TaskerMAN\Core\IO::GET('id')); // Remove non-numeric IDs foreach ($ids as $key => $id) { if (!is_numeric($id)) { unset($ids[$key]); } } $steps = array(); // Loop through each task foreach ($ids as $id) { $task = new TaskerMAN\Application\Task($id); if (is_null($task->id)) { // Unable to load task throw new TaskerMAN\Application\APIErrorException('Task ' . $id . ' does not exist'); } if ((int) $task->assignee_uid !== TaskerMAN\Application\API::$uid) { throw new TaskerMAN\Application\APIErrorException('User does not have access to task ' . $id); } // Load steps into response array $steps[$id] = $task->getSteps(); } if (empty($steps)) { throw new TaskerMAN\Application\APIErrorException('No steps found'); } echo TaskerMAN\Application\API::response(array('steps' => $steps));
<?php $id = (int) TaskerMAN\Core\IO::GET('id'); $comment = TaskerMAN\Core\IO::POST('comment', false); $step = new TaskerMAN\Application\TaskStep($id); if ($step->task_id === NULL) { // Unable to load step, does not exist throw new TaskerMAN\Application\APIErrorException('Unknown step ID'); } // Check that user is permitted to modify this task if ((int) $step->assignee_uid != TaskerMAN\Application\API::$uid) { throw new TaskerMAN\Application\APIErrorException('User does not have access to modify this step'); } // Set comment and commit changes try { $step->setComment($comment); $step->save(); } catch (TaskerMAN\Application\TaskException $e) { throw new TaskerMAN\Application\APIErrorException($e->getMessage()); } echo TaskerMAN\Application\API::response('Step comment updated successfully');
<?php // Get task and step ID $id = TaskerMAN\Core\IO::GET('id'); $task_id = TaskerMAN\Core\IO::GET('task_id'); // Load step $step = new TaskerMAN\Application\TaskStep($id); // If unable to load step, redirect back to task page if (is_null($step->id)) { header('Location: index.php?p=task&id=' . $task_id); exit; } if (isset($_POST['delete'])) { $step->delete(); } else { try { $step->setComment(TaskerMAN\Core\IO::POST('comment')); $step->setTitle(TaskerMAN\Core\IO::POST('title')); $step->save(); } catch (TaskerMAN\Application\TaskException $e) { } } header('Location: index.php?p=task&id=' . $task_id);