public function verifyActionData() { $returnValue = true; if ($this->action_id != NULL && !TasksappValidator::checkInteger($this->action_id)) { $this->errorArray['action_id'] = true; } if (!TasksappValidator::checkString($this->action)) { $this->errorArray['action'] = true; } if (!TasksappValidator::checkList($this->importance, array("0", "1", "2", "3", "4", "wf"))) { $this->errorArray['importance'] = true; } if (!TasksappValidator::checkDate($this->dateDue)) { $this->errorArray['dateDue'] = true; } if (!TasksappValidator::checkList($this->context, Command::getContexts())) { $this->errorArray['context'] = true; } if (!TasksappValidator::checkInteger($this->project_id)) { $this->errorArray['project_id'] = true; } if (count($this->errorArray) != 0) { $returnValue = false; } return $returnValue; }
/** * Validate an importance variable * * Tests that the input is a nmber, and that it is in the array of acceptable * values * * @param Integer $testDate The importance to validate * * @return Bool * */ public static function checkImportance($testInteger) { $impValues = array(0, 1, 2, 3, 4, 5, 6); if (TasksappValidator::checkInteger($testInteger) && in_array($testInteger, $impValues)) { return True; } else { return False; } }
<?php $actionID = $this->id(); Command::captureUrl(); if (TasksappValidator::checkInteger($actionID)) { $db = Database::getInstance(); $inputArray = $db->getActionByActionID($actionID); $action = $inputArray[0]; } else { $action = new Action($_POST); if ($action->verifyActionData()) { $action->save(); header("Location: " . Command::retrieveUrl()); exit; } } $projectsArray = Command::getProjectList($action->client_id()); include_once '../views/showEditActionForm.php';
/** * Return a dynamic array of user's current projects * * This method queries the database and uses the result to populate an array * containing project_id/name pairs. This array is returned to the calling * script, mainly to facilitate display of all a user's projects using the * ProjectContainer class. * * @param void * @return Array * */ public static function getProjectList($client_id) { $db = Database::getInstance(); $projectsArray[1] = "@inbox"; foreach ($db->getProjectsInScope($client_id) as $row) { if (TasksappValidator::checkInteger(intval($row->project_id())) && TasksappValidator::checkString($row->name())) { $projectsArray[$row->project_id()] = $row->name(); } } return $projectsArray; }