From 6c61577583bdb274548a4aac27f157d59664a0cc Mon Sep 17 00:00:00 2001 From: gamonoid Date: Sun, 24 Sep 2017 19:23:30 +0200 Subject: [PATCH] Making code PSR2 compliant --- .travis.yml | 3 +- build.xml | 10 +- cache.properties | 11 + .../Admin/Api/AttendanceActionManager.php | 3 +- src/Attendance/Common/Model/Attendance.php | 2 +- .../Common/Model/AttendanceStatus.php | 5 +- src/Classes/AbstractInitialize.php | 2 +- src/Classes/AbstractModuleManager.php | 27 +- src/Classes/Approval/ApprovalStatus.php | 2 +- .../Approval/ApproveAdminActionManager.php | 2 +- src/Classes/BaseService.php | 230 ++++++++----- src/Classes/Cron/CronUtils.php | 4 +- src/Classes/Cron/Task/EmailIceTask.php | 3 +- src/Classes/Email/EmailSender.php | 2 +- src/Classes/Email/PHPMailer.php | 8 +- src/Classes/Email/SMTPEmailSender.php | 8 +- src/Classes/Email/SNSEmailSender.php | 10 +- src/Classes/FileService.php | 2 +- src/Classes/IceResponse.php | 6 +- src/Classes/ModuleBuilder/ModuleBuilder.php | 2 +- src/Classes/ModuleBuilder/ModuleTab.php | 35 +- src/Classes/ModuleBuilder/ModuleTabGroup.php | 10 +- src/Classes/NotificationManager.php | 17 +- src/Classes/ReportHandler.php | 12 +- src/Classes/RestApiManager.php | 2 +- src/Classes/RestEndPoint.php | 10 +- src/Classes/S3FileSystem.php | 10 +- src/Classes/SimpleImage.php | 210 +++++++----- src/Classes/SubActionManager.php | 6 +- src/Classes/UIManager.php | 26 +- src/Company/Admin/Api/CompanyAdminManager.php | 11 +- src/Company/Common/Model/CompanyStructure.php | 2 +- src/Company/Common/Model/Timezone.php | 2 +- .../Admin/Api/DashboardActionManager.php | 2 +- src/Data/Admin/Api/AbstractDataImporter.php | 18 +- .../Admin/Import/AttendanceDataImporter.php | 2 +- .../Admin/Import/EmployeeDataImporter.php | 2 +- src/Data/Common/Model/DataImport.php | 2 +- src/Data/Common/Model/DataImportFile.php | 2 +- .../Common/Model/EmployeeDependent.php | 2 +- .../Common/Model/EmergencyContact.php | 2 +- .../Admin/Api/EmployeesActionManager.php | 252 ++++++++------- .../Admin/Api/EmployeesAdminManager.php | 5 +- .../Common/Model/ArchivedEmployee.php | 2 +- src/Employees/Common/Model/Employee.php | 22 +- .../Common/Model/EmployeeApproval.php | 2 +- .../Common/Model/EmploymentStatus.php | 2 +- src/Employees/Rest/EmployeeRestEndPoint.php | 8 +- .../User/Api/EmployeesActionManager.php | 7 +- src/Expenses/Common/Model/EmployeeExpense.php | 12 +- .../Common/Model/EmployeeExpenseApproval.php | 3 +- .../Common/Model/ExpensesCategory.php | 2 +- .../Common/Model/ExpensesPaymentMethod.php | 2 +- .../User/Api/ExpensesActionManager.php | 1 - src/FieldNames/Common/Model/CustomField.php | 2 +- .../Common/Model/FieldNameMapping.php | 2 +- src/Jobs/Common/Model/JobTitle.php | 2 +- src/Jobs/Common/Model/PayGrade.php | 2 +- src/Loans/Common/Model/CompanyLoan.php | 2 +- .../Common/Model/EmployeeCompanyLoan.php | 2 +- src/Metadata/Common/Model/CalculationHook.php | 5 +- src/Metadata/Common/Model/Country.php | 4 +- src/Metadata/Common/Model/CurrencyType.php | 4 +- .../Common/Model/CustomFieldValue.php | 2 +- src/Metadata/Common/Model/Ethnicity.php | 2 +- .../Common/Model/ImmigrationStatus.php | 2 +- src/Metadata/Common/Model/Nationality.php | 5 +- src/Metadata/Common/Model/Province.php | 2 +- .../Common/Model/SupportedLanguage.php | 2 +- src/Model/ApproveModel.php | 81 ++++- src/Model/Audit.php | 2 +- src/Model/BaseModel.php | 2 +- src/Model/Cron.php | 2 +- src/Model/DataEntryBackup.php | 2 +- src/Model/File.php | 2 +- src/Model/IceEmail.php | 2 +- src/Model/Migration.php | 2 +- src/Model/Notification.php | 2 +- src/Model/Report.php | 2 +- src/Model/ReportFile.php | 2 +- src/Model/RestAccessToken.php | 2 +- src/Model/Setting.php | 2 +- src/Model/StatusChangeLog.php | 2 +- src/Model/UserReport.php | 2 +- src/Modules/Common/Model/Module.php | 2 +- .../Admin/Api/OvertimeActionManager.php | 1 - .../Common/Model/EmployeeOvertime.php | 12 +- .../Common/Model/EmployeeOvertimeApproval.php | 2 + .../Common/Model/OvertimeCategory.php | 2 +- .../User/Api/OvertimeActionManager.php | 1 - .../Admin/Api/PayrollActionManager.php | 53 ++- src/Payroll/Common/Model/Deduction.php | 2 +- src/Payroll/Common/Model/DeductionGroup.php | 2 +- src/Payroll/Common/Model/PayFrequency.php | 2 +- src/Payroll/Common/Model/Payroll.php | 2 +- .../Common/Model/PayrollCalculations.php | 15 +- src/Payroll/Common/Model/PayrollColumn.php | 2 +- .../Common/Model/PayrollColumnTemplate.php | 2 +- src/Payroll/Common/Model/PayrollData.php | 2 +- src/Payroll/Common/Model/PayslipTemplate.php | 2 +- src/Permissions/Common/Model/Permission.php | 2 +- src/Projects/Common/Model/Client.php | 2 +- src/Projects/Common/Model/EmployeeProject.php | 2 +- src/Projects/Common/Model/Project.php | 11 +- .../Common/Model/Certification.php | 2 +- src/Qualifications/Common/Model/Education.php | 2 +- .../Common/Model/EmployeeCertification.php | 2 +- .../Common/Model/EmployeeEducation.php | 2 +- .../Common/Model/EmployeeLanguage.php | 2 +- .../Common/Model/EmployeeSkill.php | 2 +- src/Qualifications/Common/Model/Language.php | 2 +- src/Qualifications/Common/Model/Skill.php | 2 +- src/Reports/Admin/Api/PDFReportBuilder.php | 6 +- .../Admin/Reports/ActiveEmployeeReport.php | 12 +- .../Reports/EmployeeAttendanceReport.php | 3 +- .../EmployeeLeaveEntitlementReport.php | 8 +- .../Admin/Reports/EmployeeLeavesReport.php | 39 ++- .../Admin/Reports/EmployeeTimeTrackReport.php | 57 ++-- .../Admin/Reports/EmployeeTimesheetReport.php | 32 +- src/Reports/Admin/Reports/ExpenseReport.php | 9 +- src/Reports/Admin/Reports/OvertimeReport.php | 12 +- .../Admin/Reports/TravelRequestReport.php | 9 +- .../User/Reports/ClientProjectTimeReport.php | 3 +- .../User/Reports/EmployeeLeavesReport.php | 28 +- .../User/Reports/EmployeeTimeTrackReport.php | 49 +-- .../User/Reports/EmployeeTimesheetReport.php | 6 +- src/Reports/User/Reports/OvertimeReport.php | 10 +- src/Salary/Common/Model/EmployeeSalary.php | 2 +- src/Salary/Common/Model/PayFrequency.php | 2 +- src/Salary/Common/Model/PayrollEmployee.php | 2 +- src/Salary/Common/Model/SalaryComponent.php | 2 +- .../Common/Model/SalaryComponentType.php | 2 +- src/Settings/Admin/Api/SettingsInitialize.php | 4 +- .../Common/Model/EmployeeTimeEntry.php | 2 +- .../Common/Model/EmployeeTimeSheet.php | 7 +- .../User/Api/TimeSheetsActionManager.php | 73 ++--- .../User/Api/TimeSheetsModulesManager.php | 5 +- src/Travel/Admin/Api/TravelActionManager.php | 1 - .../Common/Model/EmployeeImmigration.php | 2 +- .../Common/Model/EmployeeTravelRecord.php | 13 +- .../Model/EmployeeTravelRecordApproval.php | 2 + .../Common/Model/ImmigrationDocument.php | 2 +- src/Users/Admin/Api/UsersEmailSender.php | 4 +- src/Users/Common/Model/User.php | 14 +- src/Users/Common/Model/UserRole.php | 2 +- src/Utils/LogManager.php | 2 +- src/Utils/Math/EvalMath.php | 302 +++++++----------- src/Utils/Math/EvalMathFuncs.php | 32 +- src/Utils/Math/EvalMathStack.php | 10 +- test/TestTemplate.php | 141 ++++---- test/bootstrap.php | 4 +- test/helper/EmployeeTestDataHelper.php | 54 ++-- .../integration/ApprovalStatusIntegration.php | 39 +-- .../MigrationManagerIntegration.php | 55 ++-- test/test.config.php | 23 +- test/test.includes.php | 52 +-- test/unit/BaseServiceUnit.php | 13 +- test/unit/LanguageManagerUnit.php | 7 +- test/unit/UserAttendanceActionManagerUnit.php | 27 +- tools/phpcs | Bin 0 -> 1048194 bytes 160 files changed, 1432 insertions(+), 1086 deletions(-) create mode 100644 cache.properties create mode 100755 tools/phpcs diff --git a/.travis.yml b/.travis.yml index 6f9921e6..1ff810dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ before_script: install: - composer require --dev phpunit/phpunit ^5.7 - $TRAVIS_BUILD_DIR/vendor/bin/phpunit --version -script: $TRAVIS_BUILD_DIR/vendor/bin/phpunit +#script: $TRAVIS_BUILD_DIR/vendor/bin/phpunit +script: ant build language: php php: - '5.6' diff --git a/build.xml b/build.xml index 0810f055..b6ae7eac 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - + @@ -12,11 +12,11 @@ - + + @@ -205,6 +206,7 @@ + diff --git a/cache.properties b/cache.properties new file mode 100644 index 00000000..3d5f70c7 --- /dev/null +++ b/cache.properties @@ -0,0 +1,11 @@ +#Sun Sep 24 19:05:50 CEST 2017 +/Users/Thilina/Projects/icehrm-open/test/unit/LanguageManagerUnit.php=41989d0928b56a52afcc8aa8f2e19d25 +/Users/Thilina/Projects/icehrm-open/test/test.includes.php=c95e42c8e70c1b8a51ae07bbdc5434bc +/Users/Thilina/Projects/icehrm-open/test/integration/MigrationManagerIntegration.php=6ddf5624de40c43f0b8cd0afea73da83 +/Users/Thilina/Projects/icehrm-open/test/unit/BaseServiceUnit.php=6b0b00ed12317c8728589991739e02eb +/Users/Thilina/Projects/icehrm-open/test/unit/UserAttendanceActionManagerUnit.php=ff667aa4dd92ab90d407b76a278f0213 +/Users/Thilina/Projects/icehrm-open/test/bootstrap.php=40977e57e1f93fd751e61b5538caff33 +/Users/Thilina/Projects/icehrm-open/test/integration/ApprovalStatusIntegration.php=fa3d925b5f0aa07142b44f8d1d5d8857 +/Users/Thilina/Projects/icehrm-open/test/TestTemplate.php=8487090220b74541514016bc793af9c1 +/Users/Thilina/Projects/icehrm-open/test/test.config.php=cd05b2263f83d3022a6f02c5b2640c73 +/Users/Thilina/Projects/icehrm-open/test/helper/EmployeeTestDataHelper.php=2f0e1a23d3266616b8ca3cdb602d4750 diff --git a/src/Attendance/Admin/Api/AttendanceActionManager.php b/src/Attendance/Admin/Api/AttendanceActionManager.php index e735a96b..974cabda 100644 --- a/src/Attendance/Admin/Api/AttendanceActionManager.php +++ b/src/Attendance/Admin/Api/AttendanceActionManager.php @@ -75,7 +75,8 @@ class AttendanceActionManager extends SubActionManager if (empty($attendance->out_time) || $attendance->out_time == "0000-00-00 00:00:00") { return new IceResponse( IceResponse::ERROR, - "There is a non closed attendance entry for today. Please mark punch-out time of the open entry before adding a new one" + "There is a non closed attendance entry for today. + Please mark punch-out time of the open entry before adding a new one" ); } elseif (!empty($outDateTime)) { if (strtotime($attendance->out_time) >= strtotime($outDateTime) diff --git a/src/Attendance/Common/Model/Attendance.php b/src/Attendance/Common/Model/Attendance.php index d045160c..32113f39 100644 --- a/src/Attendance/Common/Model/Attendance.php +++ b/src/Attendance/Common/Model/Attendance.php @@ -12,7 +12,7 @@ use Model\BaseModel; class Attendance extends BaseModel { - var $_table = 'Attendance'; + public $table = 'Attendance'; public function getAdminAccess() { diff --git a/src/Attendance/Common/Model/AttendanceStatus.php b/src/Attendance/Common/Model/AttendanceStatus.php index e498edd8..ac477ecf 100644 --- a/src/Attendance/Common/Model/AttendanceStatus.php +++ b/src/Attendance/Common/Model/AttendanceStatus.php @@ -14,7 +14,7 @@ use Model\BaseModel; class AttendanceStatus extends BaseModel { - var $_table = 'Attendance'; + public $table = 'Attendance'; public function getRecentAttendanceEntries($limit) { @@ -59,9 +59,10 @@ class AttendanceStatus extends BaseModel return array_values($employees); } - + // @codingStandardsIgnoreStart public function Find($whereOrderBy, $bindarr = false, $pkeysArr = false, $extra = array()) { + // @codingStandardsIgnoreEnd $shift = intval(SettingsManager::getInstance()->getSetting("Attendance: Shift (Minutes)")); $employee = new Employee(); $data = array(); diff --git a/src/Classes/AbstractInitialize.php b/src/Classes/AbstractInitialize.php index e10ffcf3..f628ec3c 100644 --- a/src/Classes/AbstractInitialize.php +++ b/src/Classes/AbstractInitialize.php @@ -25,7 +25,7 @@ namespace Classes; abstract class AbstractInitialize { /* @var \Classes\BaseService $baseService */ - var $baseService = null; + public $baseService = null; public function setBaseService($baseService) { $this->baseService = $baseService; diff --git a/src/Classes/AbstractModuleManager.php b/src/Classes/AbstractModuleManager.php index 8777c971..7699a0ba 100644 --- a/src/Classes/AbstractModuleManager.php +++ b/src/Classes/AbstractModuleManager.php @@ -1,6 +1,7 @@ addDatabaseErrorMapping('CONSTRAINT `Fk_User_Employee` FOREIGN KEY',"Can not delete Employee, please delete the User for this employee first."); + $this->addDatabaseErrorMapping('CONSTRAINT `Fk_User_Employee` FOREIGN KEY',"Can not delete Employee, + * please delete the User for this employee first."); $this->addDatabaseErrorMapping("Duplicate entry|for key 'employee'","A duplicate entry found"); } */ abstract public function initializeDatabaseErrorMappings(); /** - * Override this method in module manager class to add model classes to this module. All the model classes defind for the module should be added here + * Override this method in module manager class to add model classes to this module. + * All the model classes defind for the module should be added here * @method setupModuleClassDefinitions * @example public function setupModuleClassDefinitions(){ @@ -133,7 +141,8 @@ abstract class AbstractModuleManager return $this->modulePath; } - public function setModulePath($modulePath) { + public function setModulePath($modulePath) + { $this->modulePath = $modulePath; } diff --git a/src/Classes/Approval/ApprovalStatus.php b/src/Classes/Approval/ApprovalStatus.php index ded8e139..2c421d7e 100644 --- a/src/Classes/Approval/ApprovalStatus.php +++ b/src/Classes/Approval/ApprovalStatus.php @@ -188,7 +188,7 @@ class ApprovalStatus return new IceResponse(IceResponse::SUCCESS, array($currentAL, $nextAL)); } - /** + /** * @param $level * @param $employeeId * @return int $approverId diff --git a/src/Classes/Approval/ApproveAdminActionManager.php b/src/Classes/Approval/ApproveAdminActionManager.php index 574d595c..4e2c660b 100644 --- a/src/Classes/Approval/ApproveAdminActionManager.php +++ b/src/Classes/Approval/ApproveAdminActionManager.php @@ -24,7 +24,7 @@ abstract class ApproveAdminActionManager extends ApproveCommonActionManager $class = $this->getModelClass(); $itemName = $this->getItemName(); - /* @var BaseModel $obj */ + /* @var BaseModel $obj */ $nsClass = BaseService::getInstance()->getFullQualifiedModelClassName($class); $obj = new $nsClass(); $obj->Load("id = ?", array($req->id)); diff --git a/src/Classes/BaseService.php b/src/Classes/BaseService.php index 0f0366c6..1d8f2316 100644 --- a/src/Classes/BaseService.php +++ b/src/Classes/BaseService.php @@ -51,27 +51,27 @@ use Utils\SessionUtils; class BaseService { - var $nonDeletables = array(); - var $errros = array(); + public $nonDeletables = array(); + public $errros = array(); public $userTables = array(); /* @var User $currentUser */ - var $currentUser = null; - var $db = null; - var $auditManager = null; + public $currentUser = null; + public $db = null; + public $auditManager = null; /* @var NotificationManager $notificationManager */ - var $notificationManager = null; + public $notificationManager = null; /* @var SettingsManager $settingsManager*/ - var $settingsManager = null; - var $fileFields = null; - var $moduleManagers = null; + public $settingsManager = null; + public $fileFields = null; + public $moduleManagers = null; /* @var EmailSender $emailSender */ - var $emailSender = null; - var $user = null; - var $historyManagers = array(); - var $calculationHooks = array(); - var $customFieldManager = null; - var $migrationManager = null; - var $modelClassMap = array(); + public $emailSender = null; + public $user = null; + public $historyManagers = array(); + public $calculationHooks = array(); + public $customFieldManager = null; + public $migrationManager = null; + public $modelClassMap = array(); private static $me = null; @@ -97,9 +97,16 @@ class BaseService /** * Get an array of objects from database * @method get - * @param $table {String} model class name of the table to retive data (e.g for Users table model class name is User) - * @param $mappingStr {String} a JSON string to specify fields of the $table should be mapped to other tables (e.g {"profile":["Profile","id","first_name+last_name"]} : this is how the profile field in Users table is mapped to Profile table. In this case users profile field will get filled by Profile first name and last name. The original value in User->profile field will get moved to User->profile_id) - * @param $filterStr {String} a JSON string to specify the ordering of the items (e.g {"job_title":"2","department":"2"} - this will select only items having job_title = 2 and department = 2) + * @param $table {String} model class name of the table to retive data + * (e.g for Users table model class name is User) + * @param $mappingStr {String} a JSON string to specify fields of the $table should be mapped + * to other tables (e.g {"profile":["Profile","id","first_name+last_name"]} : this is how the + * profile field in Users table is mapped to Profile table. In this case users profile field + * will get filled by Profile first name and last name. The original value in User->profile + * field will get moved to User->profile_id) + * @param $filterStr {String} a JSON string to specify the ordering of the items + * (e.g {"job_title":"2","department":"2"} - this will select only items having + * job_title = 2 and department = 2) * @param $orderBy {String} a string to specify the ordering (e.g in_time desc) * @param string $limit {String} a string to specify the limit (e.g limit 2) * @return {Array} an array of objects of type $table @@ -110,7 +117,7 @@ class BaseService if (!empty($mappingStr)) { $map = json_decode($mappingStr); } - $nsTable = $this->getFullQualifiedModelClassName($table); + $nsTable = $this->getFullQualifiedModelClassName($table); $obj = new $nsTable(); $this->checkSecureAccess("get", $obj); @@ -238,24 +245,46 @@ class BaseService /** * An extention of get method for the use of data tables with ability to search * @method getData - * @param $table {String} model class name of the table to retive data (e.g for Users table model class name is User) - * @param $mappingStr {String} a JSON string to specify fields of the $table should be mapped to other tables (e.g {"profile":["Profile","id","first_name+last_name"]} : this is how the profile field in Users table is mapped to Profile table. In this case users profile field will get filled by Profile first name and last name. The original value in User->profile field will get moved to User->profile_id) - * @param $filterStr {String} a JSON string to specify the ordering of the items (e.g {"job_title":"2","department":"2"} - this will select only items having job_title = 2 and department = 2) + * @param $table {String} model class name of the table to retive data + * (e.g for Users table model class name is User) + * @param $mappingStr {String} a JSON string to specify fields of the $table should + * be mapped to other tables (e.g {"profile":["Profile","id","first_name+last_name"]} + * : this is how the profile field in Users table is mapped to Profile table. + * In this case users profile field will get filled by Profile first name and last name. + * The original value in User->profile field will get moved to User->profile_id) + * @param $filterStr {String} a JSON string to specify the ordering of the items + * (e.g {"job_title":"2","department":"2"} - this will select only items having + * job_title = 2 and department = 2) * @param $orderBy {String} a string to specify the ordering (e.g in_time desc) * @param string $limit {String} a string to specify the limit (e.g limit 2) - * @param string $searchColumns {String} a JSON string to specify names of searchable fields (e.g ["id","employee_id","first_name","last_name","mobile_phone","department","gender","supervisor"]) + * @param string $searchColumns {String} a JSON string to specify names of searchable + * fields (e.g ["id","employee_id","first_name","last_name","mobile_phone","department","gender","supervisor"]) * @param string $searchTerm {String} a string to specify term to search - * @param string $isSubOrdinates {Boolean} a Boolean to specify if we only need to retive subordinates. Any item is a subordinate item if the item has "profile" field defined and the value of "profile" field is equal to id of one of the subordinates of currenly logged in profile id. (Any Profile is a subordinate of curently logged in Profile if the supervisor field of a Profile is set to the id of currently logged in Profile) + * @param string $isSubOrdinates {Boolean} a Boolean to specify if we only need to retive + * subordinates. Any item is a subordinate item if the item has "profile" field defined + * and the value of "profile" field is equal to id of one of the subordinates of currenly + * logged in profile id. (Any Profile is a subordinate of curently logged in Profile if the + * supervisor field of a Profile is set to the id of currently logged in Profile) * @param string $skipProfileRestriction {Boolean} default if false - TODO - I'll explain this later * @return {Array} an array of objects of type $table */ - public function getData($table, $mappingStr = null, $filterStr = null, $orderBy = null, $limit = null, $searchColumns = null, $searchTerm = null, $isSubOrdinates = false, $skipProfileRestriction = false, $sortData = array()) - { + public function getData( + $table, + $mappingStr = null, + $filterStr = null, + $orderBy = null, + $limit = null, + $searchColumns = null, + $searchTerm = null, + $isSubOrdinates = false, + $skipProfileRestriction = false, + $sortData = array() + ) { if (!empty($mappingStr)) { $map = json_decode($mappingStr); } - $nsTable = $this->getFullQualifiedModelClassName($table); - $obj = new $nsTable(); + $nsTable = $this->getFullQualifiedModelClassName($table); + $obj = new $nsTable(); $this->checkSecureAccess("get", $obj); $query = ""; $queryData = array(); @@ -317,7 +346,9 @@ class BaseService array_unshift($queryData, $cemp); //$signInMappingField = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME; $signInMappingField = $obj->getUserOnlyMeAccessField(); - LogManager::getInstance()->debug("Data Load Query (x1):"."1=1".$signInMappingField." = ?".$query.$orderBy.$limit); + LogManager::getInstance()->debug( + "Data Load Query (x1):"."1=1".$signInMappingField." = ?".$query.$orderBy.$limit + ); LogManager::getInstance()->debug("Data Load Query Data (x1):".json_encode($queryData)); $list = $obj->Find($signInMappingField." = ?".$query.$orderBy.$limit, $queryData); } else { @@ -335,7 +366,10 @@ class BaseService } $childCompaniesIds = array(); - if (SettingsManager::getInstance()->getSetting('System: Child Company Structure Managers Enabled') == '1') { + if (SettingsManager::getInstance()->getSetting( + 'System: Child Company Structure Managers Enabled' + ) == '1' + ) { $childCompaniesResp = CompanyStructure::getAllChildCompanyStructures($cempObj->department); $childCompanies = $childCompaniesResp->getObject(); @@ -347,7 +381,10 @@ class BaseService } if (!empty($childCompaniesIds)) { - $childStructureSubordinates = $subordinate->Find("department in (" . implode(',', $childCompaniesIds) . ") and id != ?", array($cemp)); + $childStructureSubordinates = $subordinate->Find( + "department in (" . implode(',', $childCompaniesIds) . ") and id != ?", + array($cemp) + ); $subordinates = array_merge($subordinates, $childStructureSubordinates); } } @@ -361,7 +398,10 @@ class BaseService } if ($obj->allowIndirectMapping()) { - $indeirectEmployees = $subordinate->Find("indirect_supervisors IS NOT NULL and indirect_supervisors <> '' and status = 'Active'", array()); + $indeirectEmployees = $subordinate->Find( + "indirect_supervisors IS NOT NULL and indirect_supervisors <> '' and status = 'Active'", + array() + ); foreach ($indeirectEmployees as $ie) { $indirectSupervisors = json_decode($ie->indirect_supervisors, true); if (in_array($cemp, $indirectSupervisors)) { @@ -374,10 +414,16 @@ class BaseService } $signInMappingField = $obj->getUserOnlyMeAccessField(); - LogManager::getInstance()->debug("Data Load Query (x2):"."1=1".$signInMappingField." in (".$subordinatesIds.") ".$query.$orderBy.$limit); + LogManager::getInstance()->debug( + "Data Load Query (x2):"."1=1".$signInMappingField." in (".$subordinatesIds.") " + .$query.$orderBy.$limit + ); LogManager::getInstance()->debug("Data Load Query Data (x2):".json_encode($queryData)); if (!empty($subordinatesIds)) { - $list = $obj->Find($signInMappingField . " in (" . $subordinatesIds . ") " . $query . $orderBy . $limit, $queryData); + $list = $obj->Find( + $signInMappingField . " in (" . $subordinatesIds . ") " . $query . $orderBy . $limit, + $queryData + ); } else { $list = array(); } @@ -401,7 +447,10 @@ class BaseService } $childCompaniesIds = array(); - if (SettingsManager::getInstance()->getSetting('System: Child Company Structure Managers Enabled') == '1') { + if (SettingsManager::getInstance()->getSetting( + 'System: Child Company Structure Managers Enabled' + ) == '1' + ) { $childCompaniesResp = CompanyStructure::getAllChildCompanyStructures($cempObj->department); $childCompanies = $childCompaniesResp->getObject(); @@ -413,7 +462,10 @@ class BaseService } if (!empty($childCompaniesIds)) { - $childStructureSubordinates = $subordinate->Find("department in (" . implode(',', $childCompaniesIds) . ") and id != ?", array($cemp)); + $childStructureSubordinates = $subordinate->Find( + "department in (" . implode(',', $childCompaniesIds) . ") and id != ?", + array($cemp) + ); $subordinates = array_merge($subordinates, $childStructureSubordinates); } } @@ -427,7 +479,10 @@ class BaseService } if ($obj->allowIndirectMapping()) { - $indeirectEmployees = $subordinate->Find("indirect_supervisors IS NOT NULL and indirect_supervisors <> '' and status = 'Active'", array()); + $indeirectEmployees = $subordinate->Find( + "indirect_supervisors IS NOT NULL and indirect_supervisors <> '' and status = 'Active'", + array() + ); foreach ($indeirectEmployees as $ie) { $indirectSupervisors = json_decode($ie->indirect_supervisors, true); if (in_array($cemp, $indirectSupervisors)) { @@ -440,8 +495,13 @@ class BaseService } $signInMappingField = $obj->getUserOnlyMeAccessField(); - LogManager::getInstance()->debug("Data Load Query (a1):".$signInMappingField." in (".$subordinatesIds.") ".$query.$orderBy.$limit); - $list = $obj->Find($signInMappingField." in (".$subordinatesIds.") ".$query.$orderBy.$limit, $queryData); + LogManager::getInstance()->debug( + "Data Load Query (a1):".$signInMappingField." in (".$subordinatesIds.") ".$query.$orderBy.$limit + ); + $list = $obj->Find( + $signInMappingField." in (".$subordinatesIds.") ".$query.$orderBy.$limit, + $queryData + ); } else { $list = $obj->Find("1=1".$query.$orderBy.$limit, $queryData); } @@ -527,15 +587,18 @@ class BaseService * @method getElement * @param $table {String} model class name of the table to get data (e.g for Users table model class name is User) * @param $table {Integer} id of the item to get from $table - * @param $mappingStr {String} a JSON string to specify fields of the $table should be mapped to other tables (e.g {"profile":["Profile","id","first_name+last_name"]} : this is how the profile field in Users table is mapped to Profile table. In this case users profile field will get filled by Profile first name and last name. The original value in User->profile field will get moved to User->profile_id) + * @param $mappingStr {String} a JSON string to specify fields of the $table should be mapped to other + * tables (e.g {"profile":["Profile","id","first_name+last_name"]} : this is how the profile field in + * Users table is mapped to Profile table. In this case users profile field will get filled by Profile + * first name and last name. The original value in User->profile field will get moved to User->profile_id) * @param $skipSecurityCheck {Boolean} if true won't check whether the user has access to that object * @return {Object} an object of type $table */ public function getElement($table, $id, $mappingStr = null, $skipSecurityCheck = false) { - $nsTable = $this->getFullQualifiedModelClassName($table); - $obj = new $nsTable(); + $nsTable = $this->getFullQualifiedModelClassName($table); + $obj = new $nsTable(); if (in_array($table, $this->userTables)) { $cemp = $this->getCurrentProfileId(); @@ -595,7 +658,8 @@ class BaseService * Add an element to a given table * @method addElement * @param $table {String} model class name of the table to add data (e.g for Users table model class name is User) - * @param $obj {Array} an associative array with field names and values for the new object. If the object id is not empty an existing object will be updated + * @param $obj {Array} an associative array with field names and values for the new object. + * If the object id is not empty an existing object will be updated * @return {Object} newly added or updated element of type $table */ @@ -603,8 +667,8 @@ class BaseService { $customFields = array(); $isAdd = true; - $nsTable = $this->getFullQualifiedModelClassName($table); - $ele = new $nsTable(); + $nsTable = $this->getFullQualifiedModelClassName($table); + $ele = new $nsTable(); //LogManager::getInstance()->error("Obj:".json_encode($obj)); if (class_exists("\\Classes\\ProVersion")) { @@ -680,13 +744,13 @@ class BaseService if ($isAdd) { $this->audit( - IceConstants::AUDIT_ERROR, - "Error occured while adding an object to ".$table." \ Error: ".$error + IceConstants::AUDIT_ERROR, + "Error occured while adding an object to ".$table." \ Error: ".$error ); } else { $this->audit( - IceConstants::AUDIT_ERROR, - "Error occured while editing an object in ".$table." [id:".$ele->id."] \ Error: ".$error + IceConstants::AUDIT_ERROR, + "Error occured while editing an object in ".$table." [id:".$ele->id."] \ Error: ".$error ); } return new IceResponse(IceResponse::ERROR, $this->findError($error)); @@ -716,15 +780,16 @@ class BaseService /** * Delete an element if not the $table and $id is defined as a non deletable * @method deleteElement - * @param $table {String} model class name of the table to delete data (e.g for Users table model class name is User) + * @param $table {String} model class name of the table to delete data + * (e.g for Users table model class name is User) * @param $id {Integer} id of the item to delete * @return NULL */ public function deleteElement($table, $id) { $fileFields = $this->fileFields; - $nsTable = $this->getFullQualifiedModelClassName($table); - $ele = new $nsTable(); + $nsTable = $this->getFullQualifiedModelClassName($table); + $ele = new $nsTable(); $ele->Load('id = ?', array($id)); @@ -784,12 +849,16 @@ class BaseService } /** - * Get associative array of by retriving data from $table using $key field ans key and $value field as value. Mainly used for getting data for populating option lists of select boxes when adding and editing items + * Get associative array of by retriving data from $table using $key field ans key and + * $value field as value. Mainly used for getting data for populating option lists of select + * boxes when adding and editing items * @method getFieldValues * @param $table {String} model class name of the table to get data (e.g for Users table model class name is User) * @param $key {String} key field name * @param $value {String} value field name (multiple fileds cam be concatinated using +) - e.g first_name+last_name - * @param $method {String} if not empty, use this menthod to get only a selected set of objects from db instead of retriving all objects. This method should be defined in class $table and should return an array of objects of type $table + * @param $method {String} if not empty, use this menthod to get only a selected set of objects + * from db instead of retriving all objects. This method should be defined in class $table + * and should return an array of objects of type $table * @return {Array} associative array */ @@ -799,8 +868,8 @@ class BaseService $values = explode("+", $value); $ret = array(); - $nsTable = $this->getFullQualifiedModelClassName($table); - $ele = new $nsTable(); + $nsTable = $this->getFullQualifiedModelClassName($table); + $ele = new $nsTable(); if (!empty($method)) { LogManager::getInstance()->debug("Call method for getFieldValues:".$method); LogManager::getInstance()->debug("Call method params for getFieldValues:".json_decode($methodParams)); @@ -851,7 +920,7 @@ class BaseService public function setUserTables($userTables) { - $this->userTables = $userTables; + $this->userTables = $userTables; } /** @@ -898,7 +967,8 @@ class BaseService } /** - * Get the Profile id attached to currently logged in user. if the user is switched, this will return the id of switched Profile instead of currently logged in users Prifile id + * Get the Profile id attached to currently logged in user. if the user is switched, + * this will return the id of switched Profile instead of currently logged in users Prifile id * @method getCurrentProfileId * @return {Integer} */ @@ -1003,7 +1073,8 @@ class BaseService } else { $accessMatrix = $object->getUserOnlyMeAccess(); $signInMappingField = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME; - if (in_array($type, $accessMatrix) && $_REQUEST[$object->getUserOnlyMeAccessField()] == $this->currentUser->$signInMappingField) { + if (in_array($type, $accessMatrix) && $_REQUEST[$object->getUserOnlyMeAccessField()] + == $this->currentUser->$signInMappingField) { return true; } @@ -1022,7 +1093,8 @@ class BaseService } else { $accessMatrix = $object->getUserOnlyMeAccess(); $signInMappingField = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME; - if (in_array($type, $accessMatrix) && $_REQUEST[$object->getUserOnlyMeAccessField()] == $this->currentUser->$signInMappingField) { + if (in_array($type, $accessMatrix) && $_REQUEST[$object->getUserOnlyMeAccessField()] + == $this->currentUser->$signInMappingField) { return true; } @@ -1043,7 +1115,8 @@ class BaseService } /** - * Use user level security functions defined in model classes to check whether a given action type is allowed to be executed by the current user on a given object + * Use user level security functions defined in model classes to check whether a given action + * type is allowed to be executed by the current user on a given object * @method checkSecureAccess * @param $type {String} Action type * @param $object {Object} object to test access @@ -1077,8 +1150,10 @@ class BaseService $userOnlyMeAccessRequestField = $object->getUserOnlyMeAccessRequestField(); //This will check whether user can access his own records using a value in request - if (isset($_REQUEST[$object->getUserOnlyMeAccessField()]) && isset($this->currentUser->$userOnlyMeAccessRequestField)) { - if (in_array($type, $accessMatrix) && $_REQUEST[$object->getUserOnlyMeAccessField()] == $this->currentUser->$userOnlyMeAccessRequestField) { + if (isset($_REQUEST[$object->getUserOnlyMeAccessField()]) + && isset($this->currentUser->$userOnlyMeAccessRequestField)) { + if (in_array($type, $accessMatrix) && $_REQUEST[$object->getUserOnlyMeAccessField()] + == $this->currentUser->$userOnlyMeAccessRequestField) { return true; } } @@ -1188,7 +1263,11 @@ class BaseService //Check if user has permissions to this module //Check Module Permissions - $modulePermissions = BaseService::getInstance()->loadModulePermissions($moduleManagerObj->getModuleType(), $moduleObject['name'], BaseService::getInstance()->getCurrentUser()->user_level); + $modulePermissions = BaseService::getInstance()->loadModulePermissions( + $moduleManagerObj->getModuleType(), + $moduleObject['name'], + BaseService::getInstance()->getCurrentUser()->user_level + ); if (!in_array(BaseService::getInstance()->getCurrentUser()->user_level, $modulePermissions['user'])) { if (!empty(BaseService::getInstance()->getCurrentUser()->user_roles)) { @@ -1216,7 +1295,11 @@ class BaseService //Check if user has permissions to this module //Check Module Permissions - $modulePermissions = BaseService::getInstance()->loadModulePermissions($moduleManagerObj->getModuleType(), $moduleObject['name'], $user->user_level); + $modulePermissions = BaseService::getInstance()->loadModulePermissions( + $moduleManagerObj->getModuleType(), + $moduleObject['name'], + $user->user_level + ); if (!in_array($user->user_level, $modulePermissions['user'])) { if (!empty($user->user_roles)) { @@ -1396,7 +1479,7 @@ class BaseService public function getItemFromCache($class, $id) { - $class = $this->getFullQualifiedModelClassName($class); + $class = $this->getFullQualifiedModelClassName($class); $data = MemcacheService::getInstance()->get($class."-".$id); if ($data !== false) { return unserialize($data); @@ -1478,10 +1561,11 @@ END; return $this->customFieldManager; } - public function getFullQualifiedModelClassName($class) { - if ($this->modelClassMap[$class]) { - return $this->modelClassMap[$class]; - } - return '\\Model\\'.$class; - } + public function getFullQualifiedModelClassName($class) + { + if ($this->modelClassMap[$class]) { + return $this->modelClassMap[$class]; + } + return '\\Model\\'.$class; + } } diff --git a/src/Classes/Cron/CronUtils.php b/src/Classes/Cron/CronUtils.php index b995c9ff..70e92e71 100644 --- a/src/Classes/Cron/CronUtils.php +++ b/src/Classes/Cron/CronUtils.php @@ -3,8 +3,8 @@ namespace Classes\Cron; class CronUtils { - var $clientBasePath; - var $cronFile; + public $clientBasePath; + public $cronFile; private static $me = null; diff --git a/src/Classes/Cron/Task/EmailIceTask.php b/src/Classes/Cron/Task/EmailIceTask.php index 36cd0d08..b38b83e7 100644 --- a/src/Classes/Cron/Task/EmailIceTask.php +++ b/src/Classes/Cron/Task/EmailIceTask.php @@ -24,7 +24,8 @@ abstract class EmailIceTask implements IceTask foreach ($emailList as $employeeId => $emailData) { $ccList = array(); if (SettingsManager::getInstance()->getSetting( - 'Notifications: Copy Document Expiry Emails to Manager') == '1' + 'Notifications: Copy Document Expiry Emails to Manager' + ) == '1' ) { $employee = new Employee(); $employee->Load("id = ?", array($employeeId)); diff --git a/src/Classes/Email/EmailSender.php b/src/Classes/Email/EmailSender.php index 60b6a5c0..b459f8f5 100644 --- a/src/Classes/Email/EmailSender.php +++ b/src/Classes/Email/EmailSender.php @@ -16,7 +16,7 @@ use Users\Common\Model\User; abstract class EmailSender { /* @var \Classes\SettingsManager $settings */ - var $settings = null; + public $settings = null; public function __construct($settings) { $this->settings = $settings; diff --git a/src/Classes/Email/PHPMailer.php b/src/Classes/Email/PHPMailer.php index 3fab6cb1..5b3dc507 100644 --- a/src/Classes/Email/PHPMailer.php +++ b/src/Classes/Email/PHPMailer.php @@ -19,7 +19,13 @@ class PHPMailer extends EmailSender } protected function sendMail( - $subject, $body, $toEmail, $fromEmail, $replyToEmail = null, $ccList = array(), $bccList = array() + $subject, + $body, + $toEmail, + $fromEmail, + $replyToEmail = null, + $ccList = array(), + $bccList = array() ) { try { diff --git a/src/Classes/Email/SMTPEmailSender.php b/src/Classes/Email/SMTPEmailSender.php index 81651b53..0336be3f 100644 --- a/src/Classes/Email/SMTPEmailSender.php +++ b/src/Classes/Email/SMTPEmailSender.php @@ -19,7 +19,13 @@ class SMTPEmailSender extends EmailSender } protected function sendMail( - $subject, $body, $toEmail, $fromEmail, $replyToEmail = null, $ccList = array(), $bccList = array() + $subject, + $body, + $toEmail, + $fromEmail, + $replyToEmail = null, + $ccList = array(), + $bccList = array() ) { try { diff --git a/src/Classes/Email/SNSEmailSender.php b/src/Classes/Email/SNSEmailSender.php index 2e8c1d1e..3f52bb11 100644 --- a/src/Classes/Email/SNSEmailSender.php +++ b/src/Classes/Email/SNSEmailSender.php @@ -12,7 +12,7 @@ use Utils\LogManager; class SNSEmailSender extends EmailSender { - var $ses = null; + private $ses = null; public function __construct($settings) { parent::__construct($settings); @@ -25,7 +25,13 @@ class SNSEmailSender extends EmailSender } protected function sendMail( - $subject, $body, $toEmail, $fromEmail, $replyToEmail = null, $ccList = array(), $bccList = array() + $subject, + $body, + $toEmail, + $fromEmail, + $replyToEmail = null, + $ccList = array(), + $bccList = array() ) { try { diff --git a/src/Classes/FileService.php b/src/Classes/FileService.php index 8924cf37..a6ee479a 100644 --- a/src/Classes/FileService.php +++ b/src/Classes/FileService.php @@ -97,7 +97,7 @@ class FileService //Resize image to 100 $img = new \Classes\SimpleImage("/tmp/".$file->filename."_orig"); - $img->fit_to_width(100); + $img->fitToWidth(100); $img->save("/tmp/".$file->filename); $uploadFilesToS3Key = SettingsManager::getInstance()->getSetting( diff --git a/src/Classes/IceResponse.php b/src/Classes/IceResponse.php index a4ecbb53..8a85c325 100644 --- a/src/Classes/IceResponse.php +++ b/src/Classes/IceResponse.php @@ -14,9 +14,9 @@ class IceResponse const SUCCESS = "SUCCESS"; const ERROR = "ERROR"; - var $status; - var $data; - var $code; + public $status; + public $data; + public $code; public function __construct($status, $data = null, $code = null) { diff --git a/src/Classes/ModuleBuilder/ModuleBuilder.php b/src/Classes/ModuleBuilder/ModuleBuilder.php index 6b8dab6b..4c243b6b 100644 --- a/src/Classes/ModuleBuilder/ModuleBuilder.php +++ b/src/Classes/ModuleBuilder/ModuleBuilder.php @@ -10,7 +10,7 @@ namespace Classes\ModuleBuilder; class ModuleBuilder { - var $modules = array(); + public $modules = array(); /** * @param ModuleTab $module diff --git a/src/Classes/ModuleBuilder/ModuleTab.php b/src/Classes/ModuleBuilder/ModuleTab.php index 91f07a40..97dea94e 100644 --- a/src/Classes/ModuleBuilder/ModuleTab.php +++ b/src/Classes/ModuleBuilder/ModuleTab.php @@ -11,17 +11,24 @@ namespace Classes\ModuleBuilder; class ModuleTab { public $name; - var $class; - var $label; - var $adapterName; - var $filter; - var $orderBy; + public $class; + public $label; + public $adapterName; + public $filter; + public $orderBy; public $isActive = false; public $isInsideGroup = false; - var $options = array(); + public $options = array(); public function __construct( - $name, $class, $label, $adapterName, $filter, $orderBy, $isActive = false, $options = array() + $name, + $class, + $label, + $adapterName, + $filter, + $orderBy, + $isActive = false, + $options = array() ) { $this->name = $name; $this->class = $class; @@ -37,10 +44,10 @@ class ModuleTab { $active = ($this->isActive)?"active":""; if (!$this->isInsideGroup) { - return '
  • ' . t($this->label) . '
  • '; } else { - return '
  • ' . t($this->label) . '
  • '; } } @@ -50,7 +57,8 @@ class ModuleTab $active = ($this->isActive)?" active":""; $html = '
    '. '
    '. - ''. + ''. '
    '; return $html; @@ -60,9 +68,12 @@ class ModuleTab { $js = ''; if (empty($this->filter)) { - $js.= "modJsList['tab" . $this->name . "'] = new " . $this->adapterName . "('" . $this->class . "','" . $this->name . "','','".$this->orderBy."');"; + $js.= "modJsList['tab" . $this->name . "'] = new " . + $this->adapterName . "('" . $this->class . "','" . $this->name . "','','".$this->orderBy."');"; } else { - $js.= "modJsList['tab" . $this->name . "'] = new " . $this->adapterName . "('" . $this->class . "','" . $this->name . "'," . $this->filter . ",'".$this->orderBy."');"; + $js.= "modJsList['tab" . $this->name . "'] = new " . + $this->adapterName . "('" . $this->class . "','" . $this->name . "'," . + $this->filter . ",'".$this->orderBy."');"; } foreach ($this->options as $key => $val) { diff --git a/src/Classes/ModuleBuilder/ModuleTabGroup.php b/src/Classes/ModuleBuilder/ModuleTabGroup.php index 07efa616..8e87640e 100644 --- a/src/Classes/ModuleBuilder/ModuleTabGroup.php +++ b/src/Classes/ModuleBuilder/ModuleTabGroup.php @@ -10,9 +10,9 @@ namespace Classes\ModuleBuilder; class ModuleTabGroup { - var $name; - var $label; - var $isActive = false; + public $name; + public $label; + public $isActive = false; public $modules = array(); public function __construct($name, $label) @@ -37,7 +37,9 @@ class ModuleTabGroup $active = ($this->isActive)?" active":""; $html.= '