summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Authentication.php130
-rw-r--r--app/Model/Category.php62
-rw-r--r--app/Model/Comment.php61
-rw-r--r--app/Model/Currency.php23
-rw-r--r--app/Model/CustomFilter.php62
-rw-r--r--app/Model/Group.php55
-rw-r--r--app/Model/Link.php45
7 files changed, 0 insertions, 438 deletions
diff --git a/app/Model/Authentication.php b/app/Model/Authentication.php
deleted file mode 100644
index d10f2bf8..00000000
--- a/app/Model/Authentication.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-
-namespace Kanboard\Model;
-
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-use Gregwar\Captcha\CaptchaBuilder;
-
-/**
- * Authentication model
- *
- * @package model
- * @author Frederic Guillot
- */
-class Authentication extends Base
-{
- /**
- * Validate user login form
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateForm(array $values)
- {
- $result = false;
- $errors = array();
-
- foreach (array('validateFields', 'validateLocking', 'validateCaptcha', 'validateCredentials') as $method) {
- list($result, $errors) = $this->$method($values);
-
- if (! $result) {
- break;
- }
- }
-
- return array($result, $errors);
- }
-
- /**
- * Validate credentials syntax
- *
- * @access private
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- private function validateFields(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('username', t('The username is required')),
- new Validators\MaxLength('username', t('The maximum length is %d characters', 50), 50),
- new Validators\Required('password', t('The password is required')),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors(),
- );
- }
-
- /**
- * Validate user locking
- *
- * @access private
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- private function validateLocking(array $values)
- {
- $result = true;
- $errors = array();
-
- if ($this->userLocking->isLocked($values['username'])) {
- $result = false;
- $errors['login'] = t('Your account is locked for %d minutes', BRUTEFORCE_LOCKDOWN_DURATION);
- $this->logger->error('Account locked: '.$values['username']);
- }
-
- return array($result, $errors);
- }
-
- /**
- * Validate password syntax
- *
- * @access private
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- private function validateCredentials(array $values)
- {
- $result = true;
- $errors = array();
-
- if (! $this->authenticationManager->passwordAuthentication($values['username'], $values['password'])) {
- $result = false;
- $errors['login'] = t('Bad username or password');
- }
-
- return array($result, $errors);
- }
-
- /**
- * Validate captcha
- *
- * @access private
- * @param array $values Form values
- * @return boolean
- */
- private function validateCaptcha(array $values)
- {
- $result = true;
- $errors = array();
-
- if ($this->userLocking->hasCaptcha($values['username'])) {
- if (! isset($this->sessionStorage->captcha)) {
- $result = false;
- } else {
- $builder = new CaptchaBuilder;
- $builder->setPhrase($this->sessionStorage->captcha);
- $result = $builder->testPhrase(isset($values['captcha']) ? $values['captcha'] : '');
-
- if (! $result) {
- $errors['login'] = t('Invalid captcha');
- }
- }
- }
-
- return array($result, $errors);;
- }
-}
diff --git a/app/Model/Category.php b/app/Model/Category.php
index bf40c60a..58cee738 100644
--- a/app/Model/Category.php
+++ b/app/Model/Category.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Category model
*
@@ -212,63 +209,4 @@ class Category extends Base
return true;
}
-
- /**
- * Validate category creation
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateCreation(array $values)
- {
- $rules = array(
- new Validators\Required('project_id', t('The project id is required')),
- new Validators\Required('name', t('The name is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate category modification
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateModification(array $values)
- {
- $rules = array(
- new Validators\Required('id', t('The id is required')),
- new Validators\Required('name', t('The name is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Integer('id', t('The id must be an integer')),
- new Validators\Integer('project_id', t('The project id must be an integer')),
- new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50)
- );
- }
}
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index eb83f8d6..6eb4a1e5 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -3,8 +3,6 @@
namespace Kanboard\Model;
use Kanboard\Event\CommentEvent;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
/**
* Comment model
@@ -152,63 +150,4 @@ class Comment extends Base
{
return $this->db->table(self::TABLE)->eq('id', $comment_id)->remove();
}
-
- /**
- * Validate comment creation
- *
- * @access public
- * @param array $values Required parameters to save an action
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateCreation(array $values)
- {
- $rules = array(
- new Validators\Required('task_id', t('This value is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate comment modification
- *
- * @access public
- * @param array $values Required parameters to save an action
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateModification(array $values)
- {
- $rules = array(
- new Validators\Required('id', t('This value is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Integer('id', t('This value must be an integer')),
- new Validators\Integer('task_id', t('This value must be an integer')),
- new Validators\Integer('user_id', t('This value must be an integer')),
- new Validators\MaxLength('reference', t('The maximum length is %d characters', 50), 50),
- new Validators\Required('comment', t('Comment is required'))
- );
- }
}
diff --git a/app/Model/Currency.php b/app/Model/Currency.php
index c1156610..316a0141 100644
--- a/app/Model/Currency.php
+++ b/app/Model/Currency.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Currency
*
@@ -83,24 +80,4 @@ class Currency extends Base
{
return $this->db->table(self::TABLE)->eq('currency', $currency)->update(array('rate' => $rate));
}
-
- /**
- * Validate
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validate(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('currency', t('Field required')),
- new Validators\Required('rate', t('Field required')),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}
diff --git a/app/Model/CustomFilter.php b/app/Model/CustomFilter.php
index 6550b4a7..3a6a1a3a 100644
--- a/app/Model/CustomFilter.php
+++ b/app/Model/CustomFilter.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Custom Filter model
*
@@ -102,63 +99,4 @@ class CustomFilter extends Base
{
return $this->db->table(self::TABLE)->eq('id', $filter_id)->remove();
}
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Required('project_id', t('Field required')),
- new Validators\Required('user_id', t('Field required')),
- new Validators\Required('name', t('Field required')),
- new Validators\Required('filter', t('Field required')),
- new Validators\Integer('user_id', t('This value must be an integer')),
- new Validators\Integer('project_id', t('This value must be an integer')),
- new Validators\MaxLength('name', t('The maximum length is %d characters', 100), 100),
- new Validators\MaxLength('filter', t('The maximum length is %d characters', 100), 100)
- );
- }
-
- /**
- * Validate filter creation
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateCreation(array $values)
- {
- $v = new Validator($values, $this->commonValidationRules());
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate filter modification
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateModification(array $values)
- {
- $rules = array(
- new Validators\Required('id', t('Field required')),
- new Validators\Integer('id', t('This value must be an integer')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}
diff --git a/app/Model/Group.php b/app/Model/Group.php
index a086fe9d..ce8c0284 100644
--- a/app/Model/Group.php
+++ b/app/Model/Group.php
@@ -117,59 +117,4 @@ class Group extends Base
{
return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
}
-
- /**
- * Validate creation
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateCreation(array $values)
- {
- $v = new Validator($values, $this->commonValidationRules());
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate modification
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateModification(array $values)
- {
- $rules = array(
- new Validators\Required('id', t('The id is required')),
- );
-
- $v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Common validation rules
- *
- * @access private
- * @return array
- */
- private function commonValidationRules()
- {
- return array(
- new Validators\Required('name', t('The name is required')),
- new Validators\MaxLength('name', t('The maximum length is %d characters', 100), 100),
- new Validators\Unique('name', t('The name must be unique'), $this->db->getConnection(), self::TABLE, 'id'),
- new Validators\MaxLength('external_id', t('The maximum length is %d characters', 255), 255),
- new Validators\Integer('id', t('This value must be an integer')),
- );
- }
}
diff --git a/app/Model/Link.php b/app/Model/Link.php
index 00b6dfc5..7b81a237 100644
--- a/app/Model/Link.php
+++ b/app/Model/Link.php
@@ -3,8 +3,6 @@
namespace Kanboard\Model;
use PDO;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
/**
* Link model
@@ -176,47 +174,4 @@ class Link extends Base
$this->db->table(self::TABLE)->eq('opposite_id', $link_id)->update(array('opposite_id' => 0));
return $this->db->table(self::TABLE)->eq('id', $link_id)->remove();
}
-
- /**
- * Validate creation
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateCreation(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('label', t('Field required')),
- new Validators\Unique('label', t('This label must be unique'), $this->db->getConnection(), self::TABLE),
- new Validators\NotEquals('label', 'opposite_label', t('The labels must be different')),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
-
- /**
- * Validate modification
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validateModification(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('id', t('Field required')),
- new Validators\Required('opposite_id', t('Field required')),
- new Validators\Required('label', t('Field required')),
- new Validators\Unique('label', t('This label must be unique'), $this->db->getConnection(), self::TABLE),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}