Fix code style

This commit is contained in:
Alan Cell
2021-04-05 19:01:58 +02:00
parent 6581d1424e
commit bb8f11963a
11 changed files with 76 additions and 43 deletions

View File

@@ -61,7 +61,6 @@ class DomainAwareInputCleaner
$filterData = json_decode($filters, true); $filterData = json_decode($filters, true);
foreach ($filterData as $name => $value) { foreach ($filterData as $name => $value) {
if (!$this->isValidColumnName($name) || !$this->isValidFilterValue($value)) { if (!$this->isValidColumnName($name) || !$this->isValidFilterValue($value)) {
return ''; return '';
} }

View File

@@ -15,7 +15,7 @@ class ModuleBuilder
public $modules = array(); public $modules = array();
public $user = null; public $user = null;
function __construct() public function __construct()
{ {
$this->user = \Classes\BaseService::getInstance()->getCurrentUser(); $this->user = \Classes\BaseService::getInstance()->getCurrentUser();
} }

View File

@@ -31,8 +31,8 @@ class ModuleTab
$orderBy, $orderBy,
$isActive = false, $isActive = false,
$options = array() $options = array()
) ) {
{
$this->modelPath = $modelPath; $this->modelPath = $modelPath;
$this->name = $name; $this->name = $name;
$this->class = $class; $this->class = $class;
@@ -43,12 +43,14 @@ class ModuleTab
$this->isActive = $isActive; $this->isActive = $isActive;
$this->options = array_merge( $this->options = array_merge(
$options, [ $options,
[
"setObjectTypeName" => "'{$this->name}'", "setObjectTypeName" => "'{$this->name}'",
"setAccess" => "data.permissions.{$this->name} ? data.permissions.{$this->name} : {}", "setAccess" => "data.permissions.{$this->name} ? data.permissions.{$this->name} : {}",
"setDataPipe" => 'new IceDataPipe(modJsList.tab' . $this->name . ')', "setDataPipe" => 'new IceDataPipe(modJsList.tab' . $this->name . ')',
"setRemoteTable" => true, "setRemoteTable" => true,
]); ]
);
} }
public function getHTML() public function getHTML()

View File

@@ -7,7 +7,8 @@ use Utils\LogManager;
class SAMLManager class SAMLManager
{ {
public function getSSOEmail($samlData, $relayState) { public function getSSOEmail($samlData, $relayState)
{
// Service Providers Assertion Consumer Service (ACS) URL // Service Providers Assertion Consumer Service (ACS) URL
$acsUrl = CLIENT_BASE_URL.'login.php'; $acsUrl = CLIENT_BASE_URL.'login.php';
$samlResponse = htmlspecialchars($samlData); $samlResponse = htmlspecialchars($samlData);
@@ -52,12 +53,26 @@ class SAMLManager
$certFingerPrint = preg_replace('/\s+/', '', $certFingerPrint); $certFingerPrint = preg_replace('/\s+/', '', $certFingerPrint);
$validSignature = false; $validSignature = false;
if (!empty($responseSignatureData)) { if (!empty($responseSignatureData)) {
$validSignature = \Utilities::processResponse($acsUrl, $certFingerPrint, $responseSignatureData, $samlResponse, 0, $relayState); $validSignature = \Utilities::processResponse(
$acsUrl,
$certFingerPrint,
$responseSignatureData,
$samlResponse,
0,
$relayState
);
LogManager::getInstance()->error('SAML: response signature validity :'.$validSignature); LogManager::getInstance()->error('SAML: response signature validity :'.$validSignature);
} }
if (!empty($assertionSignatureData)) { if (!empty($assertionSignatureData)) {
$validSignature = \Utilities::processResponse($acsUrl, $certFingerPrint, $assertionSignatureData, $samlResponse, 0, $relayState); $validSignature = \Utilities::processResponse(
$acsUrl,
$certFingerPrint,
$assertionSignatureData,
$samlResponse,
0,
$relayState
);
LogManager::getInstance()->error('SAML: response signature validity :'.$validSignature); LogManager::getInstance()->error('SAML: response signature validity :'.$validSignature);
} }

View File

@@ -28,17 +28,20 @@ class SettingsManager
return self::$me; return self::$me;
} }
public function addEncryptedSetting($name) { public function addEncryptedSetting($name)
{
if (!$this->isEncryptedSetting($name)) { if (!$this->isEncryptedSetting($name)) {
$this->encryptedSettings[] = $name; $this->encryptedSettings[] = $name;
} }
} }
public function isEncryptedSetting($name) { public function isEncryptedSetting($name)
{
return in_array($name, $this->encryptedSettings); return in_array($name, $this->encryptedSettings);
} }
public function getInstanceKey() { public function getInstanceKey()
{
$settings = new Setting(); $settings = new Setting();
$settings->Load("name = ?", array("Instance: Key")); $settings->Load("name = ?", array("Instance: Key"));
if ($settings->name != "Instance: Key") { if ($settings->name != "Instance: Key") {
@@ -47,16 +50,17 @@ class SettingsManager
return $settings->value; return $settings->value;
} }
private function encrypt($value) { private function encrypt($value)
{
$id = BaseService::getInstance()->getInstanceId(); $id = BaseService::getInstance()->getInstanceId();
$key = $this->getInstanceKey(); $key = $this->getInstanceKey();
return AesCtr::encrypt($value, $id.$key, 256); return AesCtr::encrypt($value, $id.$key, 256);
} }
public function encryptSetting($name, $value) { public function encryptSetting($name, $value)
{
// check the existence of prefix and encrypt only if need to avoid double encryption // check the existence of prefix and encrypt only if need to avoid double encryption
if ( if ($this->isEncryptedSetting($name)
$this->isEncryptedSetting($name)
&& substr($value, 0, strlen(self::ENCRYPTED_PREFIX)) !== self::ENCRYPTED_PREFIX && substr($value, 0, strlen(self::ENCRYPTED_PREFIX)) !== self::ENCRYPTED_PREFIX
) { ) {
$value = self::ENCRYPTED_PREFIX.$this->encrypt($value); $value = self::ENCRYPTED_PREFIX.$this->encrypt($value);
@@ -65,15 +69,16 @@ class SettingsManager
return $value; return $value;
} }
private function decrypt($value) { private function decrypt($value)
{
$id = BaseService::getInstance()->getInstanceId(); $id = BaseService::getInstance()->getInstanceId();
$key = $this->getInstanceKey(); $key = $this->getInstanceKey();
return AesCtr::decrypt($value, $id.$key, 256); return AesCtr::decrypt($value, $id.$key, 256);
} }
public function decryptSetting($name, $value) { public function decryptSetting($name, $value)
if ( {
$this->isEncryptedSetting($name) if ($this->isEncryptedSetting($name)
&& substr($value, 0, strlen(self::ENCRYPTED_PREFIX)) === self::ENCRYPTED_PREFIX && substr($value, 0, strlen(self::ENCRYPTED_PREFIX)) === self::ENCRYPTED_PREFIX
) { ) {
$value = $this->decrypt(substr($value, strlen(self::ENCRYPTED_PREFIX))); $value = $this->decrypt(substr($value, strlen(self::ENCRYPTED_PREFIX)));
@@ -134,7 +139,8 @@ class SettingsManager
} }
} }
public function getDeprecatedSettings() { public function getDeprecatedSettings()
{
return [ return [
'Attendance: Work Week Start Day', 'Attendance: Work Week Start Day',
'Attendance: Overtime Calculation Class' 'Attendance: Overtime Calculation Class'

View File

@@ -45,7 +45,8 @@ class DocumentTaskCreator implements TaskCreator
return 0; return 0;
} }
$query = "select count(id) as c from EmployeeDocuments where employee = ? and valid_until < ? and visible_to = ?"; $query
= "select count(id) as c from EmployeeDocuments where employee = ? and valid_until < ? and visible_to = ?";
$user->DB()->SetFetchMode(ADODB_FETCH_ASSOC); $user->DB()->SetFetchMode(ADODB_FETCH_ASSOC);
// TODO - sending notifications only for Owner documents, this need to be extended later // TODO - sending notifications only for Owner documents, this need to be extended later

View File

@@ -17,8 +17,7 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
LogManager::getInstance()->info(json_encode($report)); LogManager::getInstance()->info(json_encode($report));
LogManager::getInstance()->info(json_encode($req)); LogManager::getInstance()->info(json_encode($req));
if ( if (empty($req['period'])
empty($req['period'])
&& ( && (
empty($req['date_start']) empty($req['date_start'])
|| 'NULL' === $req['date_start'] || 'NULL' === $req['date_start']
@@ -85,7 +84,13 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
$company->Load('id = ?', [$employeeObject->department]); $company->Load('id = ?', [$employeeObject->department]);
$reportData = []; $reportData = [];
$reportData[] = ["Date","First Punch-In Time","Last Punch-Out Time","Time in Attendance (Hours)","Time in Time-sheets (Hours)"]; $reportData[] = [
"Date",
"First Punch-In Time",
"Last Punch-Out Time",
"Time in Attendance (Hours)",
"Time in Time-sheets (Hours)",
];
$reportData[] = ["Employee:",$employeeObject->first_name." ".$employeeObject->last_name,"","",""]; $reportData[] = ["Employee:",$employeeObject->first_name." ".$employeeObject->last_name,"","",""];
$reportData[] = ["Department:",$company->title,"","",""]; $reportData[] = ["Department:",$company->title,"","",""];
$reportData[] = ["Total Days:","","","",""]; $reportData[] = ["Total Days:","","","",""];
@@ -94,7 +99,11 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
//Iterate date range //Iterate date range
$interval = \DateInterval::createFromDateString('1 day'); $interval = \DateInterval::createFromDateString('1 day');
$period = new \DatePeriod(new \DateTime($req['date_start']), $interval, (new \DateTime($req['date_end']))->modify('+1 day')); $period = new \DatePeriod(
new \DateTime($req['date_start']),
$interval,
(new \DateTime($req['date_end']))->modify('+1 day')
);
$totalHoursOffice = 0; $totalHoursOffice = 0;
$totalHoursTimeSheets = 0; $totalHoursTimeSheets = 0;
@@ -154,7 +163,8 @@ class EmployeeTimeTrackReport extends ClassBasedReportBuilder implements ReportB
return $reportData; return $reportData;
} }
private function setRequestDatesBasedOnThePeriod($req) { private function setRequestDatesBasedOnThePeriod($req)
{
if (empty($req['period'])) { if (empty($req['period'])) {
return $req; return $req;
} }