Check owner existence before to create project

This commit is contained in:
Frederic Guillot
2017-05-27 12:18:05 -04:00
parent 80d1293c42
commit ad8b1223cc
4 changed files with 64 additions and 0 deletions

View File

@@ -355,6 +355,10 @@ class ProjectModel extends Base
*/
public function create(array $values, $userId = 0, $addUser = false)
{
if (! empty($userId) && ! $this->userModel->exists($userId)) {
return false;
}
$this->db->startTransaction();
$values['token'] = '';
@@ -447,6 +451,10 @@ class ProjectModel extends Base
$values['end_date'] = $this->dateParser->getIsoDate($values['end_date']);
}
if (! empty($values['owner_id']) && ! $this->userModel->exists($values['owner_id'])) {
return false;
}
$this->helper->model->convertIntegerFields($values, array('priority_default', 'priority_start', 'priority_end'));
return $this->exists($values['id']) &&