From 62da0ed23af9ae74faf8d103bc3ce025c56b673e Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 21 Mar 2016 16:48:47 -0700 Subject: [PATCH] Introduced shorter functions for Errors class --- WEB-INF/lib/form/ActionErrors.class.php | 28 ++++++++++++++----------- admin_options.php | 2 +- admin_team_edit.php | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/WEB-INF/lib/form/ActionErrors.class.php b/WEB-INF/lib/form/ActionErrors.class.php index 04a6333f..02061361 100644 --- a/WEB-INF/lib/form/ActionErrors.class.php +++ b/WEB-INF/lib/form/ActionErrors.class.php @@ -28,14 +28,26 @@ class ActionErrors { var $errors = array(); - + function ActionErrors() { } - + function isEmpty() { - return (count($this->errors)>0 ? false : true ); + return (count($this->errors)>0 ? false : true); } - + + function exist() { + return (count($this->errors)>0 ? true : false); + } + + function no() { + return (count($this->errors)>0 ? false : true); + } + + function yes() { + return (count($this->errors)>0 ? true : false); + } + function add($message, $arg0 = '', $arg1 = '') { $patterns = array ("/\{0\}/","/\{1\}/"); $replace = array ($arg0, $arg1); @@ -43,14 +55,6 @@ class ActionErrors { $this->errors[]["message"] = $message; } - function addAll($arr) { - if (is_array($arr)) { - foreach ($arr as $k=>$v) { - $this->errors[$k] = $v; - } - } - } - function get($key) { return $this->errors["$key"]["message"]; } diff --git a/admin_options.php b/admin_options.php index 2a44e3e2..ac718377 100644 --- a/admin_options.php +++ b/admin_options.php @@ -55,7 +55,7 @@ if ($request->getMethod() == 'POST') { $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password')); } - if ($errors->isEmpty() && $cl_password1) { + if ($errors->no() && $cl_password1) { if (ttUserHelper::setPassword($user->id, $cl_password1)) { header('Location: admin_teams.php'); exit(); diff --git a/admin_team_edit.php b/admin_team_edit.php index fa67f7aa..d443928b 100644 --- a/admin_team_edit.php +++ b/admin_team_edit.php @@ -90,7 +90,7 @@ if ($request->getMethod() == 'POST') { if ($cl_manager_login != $team_details['manager_login']) if (ttUserHelper::getUserByLogin($cl_manager_login)) $errors->add($i18n->getKey('error.user_exists')); - if ($errors->isEmpty()) { + if ($errors->no()) { $update_result = ttTeamHelper::update($team_id, array('name'=>$cl_team_name)); if ($update_result) { $update_result = ttUserHelper::update($team_details['manager_id'], array( -- 2.20.1