diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-26 11:57:28 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-26 11:57:28 -0400 |
commit | b48c0cecbb1f687641594430260a67938d870cbb (patch) | |
tree | 82169826993d3d8c4790b653ce3901e152f6d4d8 /app | |
parent | 4a230d331ec220fc32a48525afb308af0d9787fa (diff) |
Added new arguments to project API calls and update composer.json
Diffstat (limited to 'app')
-rw-r--r-- | app/Api/Procedure/BaseProcedure.php | 1 | ||||
-rw-r--r-- | app/Api/Procedure/ProjectProcedure.php | 6 | ||||
-rw-r--r-- | app/Validator/ProjectValidator.php | 8 |
3 files changed, 9 insertions, 6 deletions
diff --git a/app/Api/Procedure/BaseProcedure.php b/app/Api/Procedure/BaseProcedure.php index 0aa43428..e31b3027 100644 --- a/app/Api/Procedure/BaseProcedure.php +++ b/app/Api/Procedure/BaseProcedure.php @@ -2,7 +2,6 @@ namespace Kanboard\Api\Procedure; -use JsonRPC\Exception\AccessDeniedException; use Kanboard\Api\Authorization\ProcedureAuthorization; use Kanboard\Api\Authorization\UserAuthorization; use Kanboard\Core\Base; diff --git a/app/Api/Procedure/ProjectProcedure.php b/app/Api/Procedure/ProjectProcedure.php index 9187f221..fe6b63e2 100644 --- a/app/Api/Procedure/ProjectProcedure.php +++ b/app/Api/Procedure/ProjectProcedure.php @@ -78,17 +78,17 @@ class ProjectProcedure extends BaseProcedure public function createProject($name, $description = null, $owner_id = 0, $identifier = null) { - $values = array( + $values = $this->filterValues(array( 'name' => $name, 'description' => $description, 'identifier' => $identifier, - ); + )); list($valid, ) = $this->projectValidator->validateCreation($values); return $valid ? $this->projectModel->create($values, $owner_id, $this->userSession->isLogged()) : false; } - public function updateProject($project_id, $name, $description = null, $owner_id = null, $identifier = null) + public function updateProject($project_id, $name = null, $description = null, $owner_id = null, $identifier = null) { ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateProject', $project_id); diff --git a/app/Validator/ProjectValidator.php b/app/Validator/ProjectValidator.php index 9ef59111..8c6117a4 100644 --- a/app/Validator/ProjectValidator.php +++ b/app/Validator/ProjectValidator.php @@ -28,7 +28,7 @@ class ProjectValidator extends BaseValidator new Validators\Integer('priority_start', t('This value must be an integer')), new Validators\Integer('priority_end', t('This value must be an integer')), new Validators\Integer('is_active', t('This value must be an integer')), - new Validators\Required('name', t('The project name is required')), + new Validators\NotEmpty('name', t('This field cannot be empty')), new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50), new Validators\MaxLength('identifier', t('The maximum length is %d characters', 50), 50), new Validators\MaxLength('start_date', t('The maximum length is %d characters', 10), 10), @@ -47,11 +47,15 @@ class ProjectValidator extends BaseValidator */ public function validateCreation(array $values) { + $rules = array( + new Validators\Required('name', t('The project name is required')), + ); + if (! empty($values['identifier'])) { $values['identifier'] = strtoupper($values['identifier']); } - $v = new Validator($values, $this->commonValidationRules()); + $v = new Validator($values, array_merge($this->commonValidationRules(), $rules)); return array( $v->execute(), |