function checkTask($kan_task, $project_id) { $query = queryTask($kan_task, $project_id); if ($query == NULL) { addTask($kan_task, $project_id); $query = queryTask($kan_task, $project_id); } $task = $query; return $task; }
public function testAddDelTask() { $COUNT = intval(file_get_contents('./data/count')); $COUNT++; addTask("polo", "marco", "2016-01-01", "wip", $COUNT); $WIP = json_decode(file_get_contents('./data/wip.json'), true); $this->assertEquals('marco', $WIP[$COUNT]['data']); delTask($COUNT, "wip"); $WIP = json_decode(file_get_contents('./data/wip.json'), true); $this->assertFalse(isset($WIP[$COUNT])); }
<?php require_once "functions.php"; $ERROR_MESSAGES = ["miss_param" => 'O parâmetro "%s" é obrigatório', "task_not_found" => 'A tarefa %s não foi encontrada', "task_already_exists" => 'Já existe uma tarefa com o nome "%s"']; $RESPONSE_CODES = ["ok" => 200, "no_content" => 204, "bad_request" => 400]; $method = $_SERVER['REQUEST_METHOD']; switch ($method) { //Verifica o tipo de requisição recebida case 'POST': //POST é somente usado para a inserção de tarefas if (isset($_POST['nome']) && !empty($_POST['nome'])) { $name = $_POST['nome']; $description = isset($_POST['descricao']) ? $_POST['descricao'] : ""; $task = addTask($name, $description); if ($task) { echo json_encode($task, JSON_PRETTY_PRINT); return http_response_code($RESPONSE_CODES['ok']); } else { $responseCode = $RESPONSE_CODES['bad_request']; echo json_encode(["status" => $responseCode, "mensagem" => sprintf($ERROR_MESSAGES['task_already_exists'], $name)]); return http_response_code($responseCode); } } else { $responseCode = $RESPONSE_CODES['bad_request']; echo json_encode(["status" => $responseCode, "mensagem" => sprintf($ERROR_MESSAGES['miss_param'], 'nome')]); return http_response_code($responseCode); //Bad request } case 'GET': //GET apenas lista as tarefas $tasks = getAllTasks();
/** Page that processes new task @author Joseph Fehrman */ session_start(); include_once "../db/connection.php"; // Post parameter collection $taskName = $_POST['task_name']; $description = $_POST['description']; $difficulty = $_POST['difficulty']; $dueDate = $_POST['due_date']; // Grabs username $username = $_SESSION['username']; addTask($username, $dueDate, $difficulty, $description, $taskName, $conn); /** Creates a new task @param $username - username which new task is assigned @param $dueDate - due date of task @param $difficulty - how difficult the task is @param $description - description of the task assignment @param $taskName - task name of new task @param $conn - database connection */ function addTask($username, $dueDate, $difficulty, $description, $taskName, $conn) { $sqlGetDifficultyID = "SELECT ID FROM todo_task_difficulty_rating WHERE difficulty_type = '{$difficulty}'"; $results = mysqli_query($conn, $sqlGetDifficultyID) or die("Error on query: " . $sqlGetDifficultyID); $row = mysqli_fetch_array($results);
getAllAdminSpecTasks(); break; case 6: find_task(); break; case 7: getAllHospitals(); break; case 8: addNurse(); break; case 9: getAllNurses(); break; case 10: addTask(); break; case 11: accept_completion(); break; case 12: reject_completion(); break; case 13: register(); break; case 14: logout(); break; case 15: removeNurse();
} return null; } function deselectProject() { unset($_SESSION['selected_project_id']); unset($_SESSION['selected_project']); } /* * SELF ACTIONS */ if (isset($_POST["action"])) { switch ($_POST["action"]) { case 'new_task': if (isset($_POST["task_title"]) && isset($_POST["id_category"])) { if (addTask($_POST["task_title"], $_POST["id_category"])) { header("HTTP/1.1 302 Redirect"); header("location:home.php"); } } break; case 'update_task_state': if (isset($_POST["id_task"])) { error_log('update task » ' . $_POST["id_task"] . " " . isset($_POST["is_complete"])); updateTask($_POST["id_task"], isset($_POST["is_complete"])); } break; case 'clear_completed': if (isset($_POST["id_project"])) { error_log('clear_completed task » ' . $_POST["id_project"]); clearArchives($_POST["id_project"]);
if (_get('setCompl') && have_write_access($listId)) { $bitwise = _get('compl') == 0 ? 'taskview & ~1' : 'taskview | 1'; $db->dq("UPDATE {$db->prefix}lists SET taskview={$bitwise} WHERE id={$listId}"); } jsonExit($t); } elseif (isset($_GET['newTask'])) { stop_gpc($_POST); $listId = (int) _post('list'); check_write_access($listId); $t = addTask($db, $listId, _post('title'), _post('tag')); jsonExit($t); } elseif (isset($_GET['fullNewTask'])) { stop_gpc($_POST); $listId = (int) _post('list'); check_write_access($listId); $t = addTask($db, $listId, _post('title'), _post('tag'), _post('note'), _post('prio'), _post('duedate'), _post('tags')); jsonExit($t); } elseif (isset($_GET['deleteTask'])) { $id = (int) _post('id'); $deleted = deleteTask($id); $t = array(); $t['total'] = $deleted; $t['list'][] = array('id' => $id); jsonExit($t); } elseif (isset($_GET['completeTask'])) { check_write_access(); $id = (int) _post('id'); $compl = _post('compl') ? 1 : 0; $listId = (int) $db->sq("SELECT list_id FROM {$db->prefix}todolist WHERE id={$id}"); if ($compl) { $ow = 1 + (int) $db->sq("SELECT MAX(ow) FROM {$db->prefix}todolist WHERE list_id={$listId} AND compl=1");
if (isset($_POST['disconnect'])) { session_destroy(); header("Refresh:0"); exit; } //Refresher if (isset($_POST['refresh'])) { unset($_POST['refresh']); header("Refresh:0"); exit; } //Add task if (isset($_POST['newTask']) && $_POST['taskType']) { $COUNT = intval(file_get_contents('./data/count')); $COUNT++; addTask($_SESSION['USER'], $_POST['taskdata'], $_POST['taskdate'], $_POST['taskType'], $COUNT); file_put_contents('./data/count', $COUNT); } //Deletes tasks TODO... if (isset($_POST['deltodo'])) { foreach ($_POST['deltodo'] as $delete => $void) { delTask($delete, "todo"); } } //... WIP ... if (isset($_POST['delwip'])) { foreach ($_POST['delwip'] as $delete => $void) { delTask($delete, "wip"); } } //... and ENDED
switch ($argv[1]) { case "importmail": ########################## # pecl install mailparse # ########################## require_once MTTPATH . "third-party/MimeMailParser.class.php"; $Parser = new MimeMailParser(); $Parser->setStream(STDIN); $parsed = parseMail($Parser->getMessageBody('text'), $db, $Parser->getHeader('from')); if ($parsed['body']) { $parsed['body'] = trim($parsed['body']) . "\n\n"; } else { $parsed['body'] = ""; } $parsed['body'] .= "Received " . date("F j, Y, g:i A") . " via mail from: " . $Parser->getHeader('from'); $t = addTask($db, $parsed['list'], $Parser->getHeader('subject'), null, $parsed['body'], $parsed['priority'], $parsed['duedate'], $parsed['tags']); if (!$t['total'] || $t['total'] < 1) { err("error creating new task.", $Parser->getHeader('from')); } break; case "getduetasks": $where = array(); $start = date("Y-m-d"); $end = date("Y-m-d", time() + 60 * 60 * 24 * 14); # now + 14 days $minprio = -1; $list = null; $mail = null; for ($i = 2; $i < count($argv); $i += 2) { if ($i < count($argv) - 1) { switch ($argv[$i]) {
<?php require_once 'PlistParser.php'; require_once 'functions.php'; $taskID = $_POST['taskID']; $name = $_POST['name']; addTask($taskID, $name); $pending_tasks = getPendingTasks(); $pp = new PlistParser(); $plist = $pp->convertIntoPlist($pending_tasks, true); echo $plist;
<?php if (!defined('MTG_ENABLE')) { exit; } if (!$users->hasAccess('staff_panel_tasks_manage')) { $mtg->error('You don\'t have access'); } $_GET['ID'] = array_key_exists('ID', $_GET) && ctype_digit($_GET['ID']) ? $_GET['ID'] : null; $_GET['action'] = array_key_exists('action', $_GET) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null; switch ($_GET['action']) { case 'add': if (!$users->hasAccess('staff_panel_tasks_add')) { $mtg->error('You don\'t have access'); } addTask($db, $mtg, $items, $logs); break; case 'edit': if (!$users->hasAccess('staff_panel_tasks_edit')) { $mtg->error('You don\'t have access'); } editTask($db, $mtg, $items, $logs); break; case 'del': if (!$users->hasAccess('staff_panel_tasks_delete')) { $mtg->error('You don\'t have access'); } deleteTask($db, $mtg, $logs); break; case 'groups': if (!$users->hasAccess('staff_panel_tasks_groups_manage')) {
<?php function addTask($user_id, $task) { include 'db_connect.php'; $stmt = $db->prepare("\n insert into todos (user_id,task,created) values\n (:id,:task,current_timestamp);\n "); $stmt->bindParam(':id', $user_id, PDO::PARAM_INT); $stmt->bindParam(':task', $task, PDO::PARAM_STR); $stmt->execute(); } addTask($_POST['id'], $_POST['task']); header('Location: ../todo.php'); exit;
<?php if (isset($_POST) && $_POST != null) { $method = $_POST["do"]; $task = isset($_POST["task"]) ? $_POST["task"] : null; if ($method == "fetchTask") { fetchTask(); } else { if ($method == "deleteTask") { deleteTask($task); } else { if ($method == "addTask") { addTask($task); } else { if ($method == "updateTask") { updateTask($task); } } } } } function fetchTask() { //fetch task $task = array(); $temp = array(); //calling db api to fetch tasks... //creating dummy array data for ($i = 0; $i < 5; $i++) { $temp[$i] = ["id" => $i, "text" => "This is task # " . $i, "checked" => "false"]; }
$lecturer = "Andrus Rinde"; } if ($subject == "Programmeerimise alused") { $lecturer = "Inga Petuhhov"; } if ($subject == "Veebiprogrammeerimine") { $lecturer = "Romil Rõbtšenkov"; } if ($subject == "Arvutiriistvara") { $lecturer = "Teet Evartson"; } if ($subject == "Suuline ja kirjalik kommunikatsioon") { $lecturer = "Krista Kerge"; } if ($subject_error == "" && $lecturer_error == "" && $task_error == "" && $date_error == "" && $difficulty_error == "" && $importance_error == "") { addTask($subject, $lecturer, $task, $date, $difficulty, $importance); echo "Salvestatud!"; echo $lecturer; echo $date; } } function cleanInput($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <html> <head>
error_reporting(E_ALL & ~E_NOTICE); header("Content-type: text/html; charset=utf-8"); $config = (include 'config.php'); $code = $_GET["code"]; if (!empty($code)) { if ($_COOKIE["access_token"]) { $config['access_token'] = $_COOKIE["access_token"]; } else { $responseText = send_post($config['accountURL'] . '/oauth2/access_token', array('client_id' => $config['client_id'], 'client_secret' => $config['client_secret'], 'code' => $code)); $json = json_decode($responseText, true); $config['access_token'] = $json['access_token']; //存放令牌 setcookie("access_token", $json['access_token'], time() + 3600 * 24 * 7); } addTask($config); } else { echo "非法操作"; } exit; //创建任务 function addTask($config) { echo send_post2($config['apiURL'] . "/api/tasks", array('content' => '测试订单', '_tasklistId' => $config['_tasklistId'], '_stageId' => $config['_stageId']), $config['access_token']); } //验证access_token是否合法 function validateToken($config) { echo send_get2($config['apiURL'] . "/api/applications/" . $config['client_id'] . "/tokens/check", $config['access_token']); } //获取我的任务
echo $data; } //getServices if ($task == "lookupService") { $service = $request->service; $data = lookupService($userid, $service); echo $data; } //lookupService if ($task == "getTasks") { echo getTasks(); } //task getTimes if ($task == "addTask") { $description = $request->taskdescription; echo addTask($description); } //task addProject if ($task == "getAllEntries") { $billed = $request->includebilled; $data = getAllEntries($userid, $billed); echo $data; } //task getAllEntries if ($task == "loadAllInvoices") { $data = loadAllInvoices($userid); echo $data; } //task loadAllInvoices if ($task == "generateInvoiceNumber") { $data = generateInvoiceNumber($userid);
<?php session_start(); require_once 'lib.php'; if (isset($_POST['task']) && !empty($_POST['task'])) { addTask($_SESSION['name'], $_POST['task']); Header('Location: todo.php'); } else { Header('Location: todo.php?error="Invalid task name"'); }