From f20ba236407fd255ff26d4503402c8d5af173fd7 Mon Sep 17 00:00:00 2001 From: jekkos Date: Fri, 17 Aug 2018 23:54:47 +0200 Subject: [PATCH 1/2] No password change in testing mode (#2073) --- application/controllers/Employees.php | 2 +- application/models/Employee.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/application/controllers/Employees.php b/application/controllers/Employees.php index 3267f5c13..ab68faff8 100644 --- a/application/controllers/Employees.php +++ b/application/controllers/Employees.php @@ -121,7 +121,7 @@ class Employees extends Persons } //Password has been changed OR first time password set - if($this->input->post('password') != '') + if($this->input->post('password') != '' && ENVIRONMENT != 'testing') { $exploded = explode(":", $this->input->post('language')); $employee_data = array( diff --git a/application/models/Employee.php b/application/models/Employee.php index f5678d666..32a11f3d6 100644 --- a/application/models/Employee.php +++ b/application/models/Employee.php @@ -119,11 +119,9 @@ class Employee extends Person //Now insert the new grants if($success) { - $count = 0; foreach($grants_data as $grant) { $success = $this->db->insert('grants', array('permission_id' => $grant['permission_id'], 'person_id' => $employee_id, 'menu_group' => $grant['menu_group'])); - $count = $count+ 1; } } } @@ -473,6 +471,10 @@ class Employee extends Person { $success = FALSE; + if (ENVIRONMENT == 'testing') { + return $success; + } + //Run these queries as a transaction, we want to make sure we do all or nothing $this->db->trans_start(); From 9c3c7a9c773d5cf0e073ad7b7bb2553ea704faed Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sat, 18 Aug 2018 12:35:29 +0100 Subject: [PATCH 2/2] Update Employee.php --- application/models/Employee.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/application/models/Employee.php b/application/models/Employee.php index 32a11f3d6..aa4dd9f07 100644 --- a/application/models/Employee.php +++ b/application/models/Employee.php @@ -364,7 +364,7 @@ class Employee extends Person /* Determines whether the employee has access to at least one submodule - */ + */ public function has_module_grant($permission_id, $person_id) { $this->db->from('grants'); @@ -431,8 +431,8 @@ class Employee extends Person } /* - Gets employee permission grants - */ + Gets employee permission grants + */ public function get_employee_grants($person_id) { $this->db->from('grants'); @@ -441,7 +441,6 @@ class Employee extends Person return $this->db->get()->result_array(); } - /* Attempts to login employee and set session. Returns boolean based on outcome. */ @@ -471,20 +470,19 @@ class Employee extends Person { $success = FALSE; - if (ENVIRONMENT == 'testing') { - return $success; + if(ENVIRONMENT != 'testing') + { + //Run these queries as a transaction, we want to make sure we do all or nothing + $this->db->trans_start(); + + $this->db->where('person_id', $employee_id); + $success = $this->db->update('employees', $employee_data); + + $this->db->trans_complete(); + + $success &= $this->db->trans_status(); } - //Run these queries as a transaction, we want to make sure we do all or nothing - $this->db->trans_start(); - - $this->db->where('person_id', $employee_id); - $success = $this->db->update('employees', $employee_data); - - $this->db->trans_complete(); - - $success &= $this->db->trans_status(); - return $success; } }