public function testAddTask() { $_SESSION["login"] = "******"; createTask("Test", "23-01-2016", "This is a test"); $monfichier = fopen(__DIR__ . "/../src/files/todo.json", "r"); $line = fgets($monfichier); fclose($monfichier); $arr = json_decode($line, true); $this->assertArrayHasKey('Test', $arr[0]); unset($_SESSION["login"]); }
public function testCreateTask() { global $app; $userWithPerm = 'user_with_allPermissions'; $userWithoutPerm = 'user_with_nonepermissions'; $goodCategory = 'todo'; $badCategory = 'unknow_cat'; // check with good values BUT user without permission // -> exception $caught = false; try { createTask($goodCategory, 'mybesttitle', $userWithoutPerm, 'user_with_nonepermissions', 'desc'); } catch (\Exception $e) { $caught = true; } $this->assertTrue($caught); // check with bad value BUT user with permission // -> exception $caught = false; try { createTask($badCategory, 'mybesttitle', $userWithPerm, 'user_with_nonepermissions', 'desc'); } catch (\Exception $e) { $caught = true; } $this->assertTrue($caught); // check with good values and good user permissions // -> should work ! $this->assertEquals(count($app['tasks']), 1); // 1 task $caught = false; try { createTask($goodCategory, 'mybesttitle', $userWithPerm, 'user_with_nonepermissions', 'desc'); } catch (\Exception $e) { $caught = true; } $this->assertFalse($caught); $this->assertEquals(count($app['tasks']), 2); // 2 task }
$show_pdf = la_tag('iframe src="' . $url . '" width="600px" height="800px"'); $show_pdf .= la_tag('iframe', true); $inputs = la_CheckInput('custom_agreement', __('I have read text above and agree with terms of use'), FALSE, FALSE); $inputs .= la_delimiter(); $inputs .= la_Submit(__('Order')); $show_pdf .= la_Form("", "POST", $inputs); show_window(__("You must accept license agreement"), $show_pdf); } if (isset($_POST['custom_agreement'])) { $date = GetFullApplyDate(); $action = 'tagadd'; $param = vf($_GET['service'], 3); $param = preg_replace('/\\0/s', '', $param); $param = strip_tags($param); $param = mysql_real_escape_string($param); $note = 'Order from userstats'; if (checkTask($user_login, $action, $param)) { createTask($date, $user_login, $action, $param, $note); } rcms_redirect('?module=adservice&action=add&wait=true'); } } if (!isset($_GET['accept'])) { show_window(__('Aditional services'), __('You can order aditional services. Available services - listed below.')); show_window(__('Aditional services cost'), AdServicesList($serviceCost, $us_config['currency'])); show_window(__('Order aditional service'), AdServicesSelector($availableServices, $user_login)); show_window(__('Activated services'), ShowAllOrderedServices($availableServices, $user_login)); } } else { show_window(__('Sorry'), __('This module is disabled')); }
<?php include $VERSION_PATH . "core/header.php"; if (isset($_POST['description'])) { $description = cleanInput($_POST['description']); if ($description) { $year = cleanInput($_POST['year']); $month = cleanInput($_POST['month']); $day = cleanInput($_POST['day']); $startDate = $year . "-" . $month . "-" . $day; if (createTask($startDate, $description)) { echo "TASK SUCCESSFULLY CREATED"; } else { echo "THERE WAS AN ERROR CREATING YOUR TASK. PLEASE TRY AGAIN LATER."; } } else { echo "PLEASE FILL OUT ALL REQUIRED FIELDS."; } } ?> <h1 class="title">Create a Task</h1> <div class="entry"> <form name="input" action="/create/index.php" method="post"> <table> <tr><td colspan="3"><hr /></td></tr> <tr> <td align="left"><b>TASK DETAILS</b></td> <td></td> <td></td> </tr> <tr><td colspan="3"><hr /></td></tr>
<?php // check user permission exists if (checkUserPermission(getUsername(), "createTask")) { // okay, let's deal with form $formError = false; // check form is submitted if (isset($_POST["submit"])) { $formError = true; // check all field given if (isset($_POST["category"]) && isset($_POST["title"]) && isset($_POST["affectedUser"]) && isset($_POST["description"])) { $formError = false; createTask($_POST["category"], $_POST["title"], getUsername(), $_POST["affectedUser"], $_POST["description"]); redirect('listTask'); } } include_once 'views/createTaskForm.php'; } else { // user do not have permission -> display to him include_once 'views/permissionError.php'; }
} } } } $approved = false; if ($approved) { // load and show current build options $buildTree = file_get_contents($gamePath . '/buildings.desc'); $bldgList = explode('<-->', $buildTree); $listSize = sizeof($bldgList) / 7; // Read material requirements for the building $rscReq = explode(",", $bldgList[$postVals[1] * 7 + 4]); //<< - insert offset for resource requirements $numRsc = sizeof($rscReq) / 2; $rscDat = pack('i*', 1, time(), $bldgList[$postVals[1] * 7 + 2]); //<< - insert offset for building points requirements for ($i = 0; $i < $numRsc; $i++) { $rscDat .= pack('i*', $rscReq[$i * 2], $rscReq[$i * 2 + 1]); } // approved - start the task $taskFile = fopen($gamePath . '/tasks.tdt', 'r+b'); $taskIndex = fopen($gamePath . '/tasks.tix', 'r+b'); $newTask = createTask($taskFile, $taskIndex, 0, $rscDat, $gamePath, $slotFile); // Record the task number in the list of buildings in progress for the city fclose($taskFiel); fclose($taskIndex); } else { echo 'Not approved'; } fclose($slotFile); fclose($unitFile);
$mantis->addArg($b); $bug = $mantis->call(); if (ERROR::isError($bug)) { die($bug->getErrstr()); } $obj = new CTask(); $obj->task_id = false; $obj->task_name = $bug["summary"]; $obj->task_project = $_POST["project_id"]; $obj->task_start_date = date("Y-m-d h:i:s", time()); $obj->task_end_date = date("Y-m-d h:i:s", time() + 24 * 60 * 60); $obj->task_description = $bug["description"]; $obj->task_owner = $AppUI->user_id; $obj->task_milestone = false; $obj->task_type = 3; $result = createTask($obj); if (!$result) { die("Task not added"); } $mantis->resetRequest(); $mantis->setFunction("MantisRPC"); $mantis->addArg(array($mantis_user, $mantis_pass)); $mantis->addArg("updateMantisBugStatusById"); $mantis->addArg($b); $mantis->addArg("30"); $result = $mantis->call(); if (ERROR::isError($result)) { die($result->getErrstr()); } } $AppUI->redirect($forward_link);
if ($conn = connectDB()) { if (isset($_GET['action']) && $_GET['action'] == 'getprogress') { $taskID = isTaskRunning($conn); if ($taskID != 0) { echo getTaskUserCountProgress($conn, $taskID) . '/' . getTaskTotalUserToUpdate($conn, $taskID); } } else { $users = getAllUsersWithoutSorting($conn); if (($taskID = isTaskRunning($conn)) != 0 && !(isset($_GET['action']) && $_GET['action'] == 'continue')) { //If there is a task running and the action!=continue, //we stop to avoid multiple task instance being ran at same time. exit; } if (($taskID = isTaskRunning($conn)) == 0) { //if no task is running, create a new one. $taskID = createTask($conn, count($users)); } if ($taskID != 0) { for ($i = getTaskUserCountProgress($conn, $taskID); $i < count($users); $i++) { //If time elapsed is more than 15 seconds, rerun the script to bypass PHP timeout if (time() - $startTime > 15) { asyncExecuteScript('update_user_stats.php?action=continue'); exit('Script continuing on another process.'); } updateTaskProgress($conn, $taskID, $users[$i]['id']); $newUserStats = fetchUserStatsFromKid($users[$i]['invite_url']); updateUserStats($conn, $users[$i]['username'], explode(';', $newUserStats)[0], explode(';', $newUserStats)[1]); } setTaskFinished($conn, $taskID, -1); exit('Update finished.'); } else {
$cityDat[10] = startASlot($slotFile, $gamePath . '/gameSlots.slt'); //startASlot($slot_file, $slot_handle) fseek($unitFile, $cityID * $defaultBlockSize + 36); fwrite($unitFile, pack('i', $cityDat[10])); echo 'created new slot ' . $cityDat[10]; // Save new slot to city information fseek($unitFile, $cityID * $defaultBlockSize + 36); fwrite($unitFile, pack('i', $cityDat[10])); } addDataToSlot($gamePath . '/gameSlots.slt', $cityDat[10], pack('i', $newID), $slotFile); echo '<p>New unit ID is ' . $newID . '<br>'; // add a task to the town as an "in progress" task // Create a new task to be processed. $taskFile = fopen($gamePath . '/tasks.tdt', 'r+b'); $parameters = pack('i*', intval($postVals[1] / 2) * 2, intval($postVals[2] / 2) * 2, 1, time(), $buildPts[0], 0, 2, $cityID, 0, $cityID, $newID, $postVals[3]); $newTask = createTask($taskFile, $parameters); //createTask($taskFile, $taskIndex, $duration, $parameters, $gamePath, $slotFile) fclose($taskFile); echo '<p>Parameters:'; print_r(unpack('i*', $parameters)); addDataToSlot($gamePath . '/gameSlots.slt', $cityDat[21], pack('i', $newTask), $slotFile); // this is for adding to a map slot -> addtoSlotGen($gamePath.'/gameSlots.slt', $cityDat[21], pack('i', $taskIndex), $slot_file, 40) // function addtoSlotGen($slot_handle, $check_slot, $addData, $slot_file, $slotSize) // add the building to the map file at the specified location $mapSlot = floor($postVals[2] / 120) * 120 + floor($postVals[1] / 120); $mapSlotFile = fopen($gamePath . '/mapSlotFile.slt', 'r+b'); //$mapSlot->addItem($mapSlotFile, pack('i*', $townID, 1), $mLoc); // file, bin value, loc $mSlotItem = new blockSlot($mapSlot, $mapSlotFile, 404); //$mSlotItem->addItem($newID, $mapSlotFile); $mLoc = sizeof($mSlotItem->slotData); for ($i = 1; $i <= sizeof($mSlotItem->slotData); $i += 2) { if ($mSlotItem->slotData[$i] == 0) {
createTask($_POST['name'], $_POST['del'], $_POST['des']); $done = $TXT_CREATED; header("Location: " . $file1 . ".php?done=" . $done); exit; } else { if (isset($_POST['Delete'])) { $file1 = "deletetask"; deleteTask($_POST['name']); $done = $TXT_DELETED; header("Location: " . $file1 . ".php?done=" . $done); exit; } else { if (isset($_POST['Update'])) { $file1 = "updatetask"; deleteTask($_POST['oldname']); createTask($_POST['newname'], $_POST['del'], $_POST['des']); $done = $TXT_UPDATED; header("Location: " . $file1 . ".php?done=" . $done); exit; } } } function createTask($name, $deadline, $description) { global $TXT_ERROR, $file1; $dir = opendir(__DIR__ . "/files/projects_file/"); while (($file = readdir($dir)) !== false && $file != $name . ".json") { } closedir($dir); if ($file == $name . ".json") { $error = $TXT_ERROR;