Skip to content

Commit

Permalink
Merge branch 'release/v29.0.0.OS'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddave001 committed Apr 5, 2021
2 parents 253b298 + bb8f119 commit 45d80e9
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 43 deletions.
2 changes: 1 addition & 1 deletion core/src/Classes/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function addModelClass($modelClass, $fullQualifiedName)
public function getCustomFieldClassMap()
{
$map = [];
foreach($this->customFieldsClassMap as $key => $val) {
foreach ($this->customFieldsClassMap as $key => $val) {
$map[] = [$key, $val];
}
return $map;
Expand Down
1 change: 0 additions & 1 deletion core/src/Classes/DomainAwareInputCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function cleanFilters($filters)

$filterData = json_decode($filters, true);
foreach ($filterData as $name => $value) {

if (!$this->isValidColumnName($name) || !$this->isValidFilterValue($value)) {
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/Classes/ModuleBuilderV2/ModuleBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ModuleBuilder
public $modules = array();
public $user = null;

function __construct()
public function __construct()
{
$this->user = \Classes\BaseService::getInstance()->getCurrentUser();
}
Expand Down
14 changes: 8 additions & 6 deletions core/src/Classes/ModuleBuilderV2/ModuleTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function __construct(
$orderBy,
$isActive = false,
$options = array()
)
{
) {

$this->modelPath = $modelPath;
$this->name = $name;
$this->class = $class;
Expand All @@ -43,12 +43,14 @@ public function __construct(
$this->isActive = $isActive;

$this->options = array_merge(
$options, [
$options,
[
"setObjectTypeName" => "'{$this->name}'",
"setAccess" => "data.permissions.{$this->name} ? data.permissions.{$this->name} : {}",
"setDataPipe" => 'new IceDataPipe(modJsList.tab' . $this->name . ')',
"setRemoteTable" => true,
]);
]
);
}

public function getHTML()
Expand All @@ -67,8 +69,8 @@ public function getPageHTML()
{
$active = ($this->isActive)?" active":"";
$html = '<div class="tab-pane'.$active.'" id="tabPage'.$this->name.'">'.
'<div id="'.$this->name.'Table" class="reviewBlock" data-content="List" style="padding-left:5px;"></div>'.
'<div id="'.$this->name.'Form"></div>'.
'<div id="'.$this->name.'Table" class="reviewBlock" data-content="List" style="padding-left:5px;"></div>'.
'<div id="'.$this->name.'Form"></div>'.
'<div id="'.$this->name.'FilterForm"></div>'.
'</div>';

Expand Down
35 changes: 25 additions & 10 deletions core/src/Classes/SAMLManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

class SAMLManager
{
public function getSSOEmail($samlData, $relayState) {
public function getSSOEmail($samlData, $relayState)
{
// Service Providers Assertion Consumer Service (ACS) URL
$acsUrl = CLIENT_BASE_URL.'login.php';
$samlResponse = htmlspecialchars($samlData);
Expand All @@ -27,15 +28,15 @@ public function getSSOEmail($samlData, $relayState) {
$statusString = $status->item(0)->getAttribute('Value');


$statusArray = explode(':',$statusString);
if(array_key_exists(7, $statusArray)){
$statusArray = explode(':', $statusString);
if (array_key_exists(7, $statusArray)) {
$status = $statusArray[7];
}

if ('Success' !== $status) {
$StatusMessage = $xpath->query('/samlp:Response/samlp:Status/samlp:StatusMessage', $doc)->item(0);
LogManager::getInstance()->error('SAML login failed: status = '. $status);
if(!empty($StatusMessage)) {
if (!empty($StatusMessage)) {
$StatusMessage = $StatusMessage->nodeValue;
LogManager::getInstance()->error('SAML login failed: status message = '. $StatusMessage);
}
Expand All @@ -51,17 +52,31 @@ public function getSSOEmail($samlData, $relayState) {
$certFingerPrint = MoXMLSecurityKey::getRawThumbprint($x509cert);
$certFingerPrint = preg_replace('/\s+/', '', $certFingerPrint);
$validSignature = false;
if(!empty($responseSignatureData)) {
$validSignature = \Utilities::processResponse($acsUrl, $certFingerPrint, $responseSignatureData, $samlResponse, 0, $relayState);
if (!empty($responseSignatureData)) {
$validSignature = \Utilities::processResponse(
$acsUrl,
$certFingerPrint,
$responseSignatureData,
$samlResponse,
0,
$relayState
);
LogManager::getInstance()->error('SAML: response signature validity :'.$validSignature);
}

if(!empty($assertionSignatureData)) {
$validSignature = \Utilities::processResponse($acsUrl, $certFingerPrint, $assertionSignatureData, $samlResponse, 0, $relayState);
if (!empty($assertionSignatureData)) {
$validSignature = \Utilities::processResponse(
$acsUrl,
$certFingerPrint,
$assertionSignatureData,
$samlResponse,
0,
$relayState
);
LogManager::getInstance()->error('SAML: response signature validity :'.$validSignature);
}

if(!$validSignature) {
if (!$validSignature) {
LogManager::getInstance()->error('Invalid response or assertion signature');
return false;
}
Expand All @@ -82,4 +97,4 @@ public function getSSOEmail($samlData, $relayState) {

return $ssoEmail;
}
}
}
30 changes: 18 additions & 12 deletions core/src/Classes/SettingsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ public static function getInstance()
return self::$me;
}

public function addEncryptedSetting($name) {
public function addEncryptedSetting($name)
{
if (!$this->isEncryptedSetting($name)) {
$this->encryptedSettings[] = $name;
}
}

public function isEncryptedSetting($name) {
public function isEncryptedSetting($name)
{
return in_array($name, $this->encryptedSettings);
}

public function getInstanceKey() {
public function getInstanceKey()
{
$settings = new Setting();
$settings->Load("name = ?", array("Instance: Key"));
if ($settings->name != "Instance: Key") {
Expand All @@ -47,16 +50,17 @@ public function getInstanceKey() {
return $settings->value;
}

private function encrypt($value) {
private function encrypt($value)
{
$id = BaseService::getInstance()->getInstanceId();
$key = $this->getInstanceKey();
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
if (
$this->isEncryptedSetting($name)
if ($this->isEncryptedSetting($name)
&& substr($value, 0, strlen(self::ENCRYPTED_PREFIX)) !== self::ENCRYPTED_PREFIX
) {
$value = self::ENCRYPTED_PREFIX.$this->encrypt($value);
Expand All @@ -65,15 +69,16 @@ public function encryptSetting($name, $value) {
return $value;
}

private function decrypt($value) {
private function decrypt($value)
{
$id = BaseService::getInstance()->getInstanceId();
$key = $this->getInstanceKey();
return AesCtr::decrypt($value, $id.$key, 256);
}

public function decryptSetting($name, $value) {
if (
$this->isEncryptedSetting($name)
public function decryptSetting($name, $value)
{
if ($this->isEncryptedSetting($name)
&& substr($value, 0, strlen(self::ENCRYPTED_PREFIX)) === self::ENCRYPTED_PREFIX
) {
$value = $this->decrypt(substr($value, strlen(self::ENCRYPTED_PREFIX)));
Expand Down Expand Up @@ -134,7 +139,8 @@ public function addSetting($name, $value)
}
}

public function getDeprecatedSettings() {
public function getDeprecatedSettings()
{
return [
'Attendance: Work Week Start Day',
'Attendance: Overtime Calculation Class'
Expand Down
2 changes: 1 addition & 1 deletion core/src/CustomField/Admin/Api/CustomFieldAdminManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public function setupModuleClassDefinitions()
{
$this->addModelClass('CustomField');
}
}
}
3 changes: 2 additions & 1 deletion core/src/Documents/Admin/Api/DocumentTaskCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ protected function getMyExpiredDocumentCount()
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);
// TODO - sending notifications only for Owner documents, this need to be extended later
Expand Down
2 changes: 1 addition & 1 deletion core/src/Model/CustomFieldTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public function isCustomFieldsEnabled()
{
return $this->allowCustomFields;
}
}
}
2 changes: 1 addition & 1 deletion core/src/Model/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function postProcessGetData($obj)
}

if (strlen($obj->value) > 30) {
$obj->value = substr($obj->value,0, 30).'...';
$obj->value = substr($obj->value, 0, 30).'...';
}
return $obj;
}
Expand Down
26 changes: 18 additions & 8 deletions core/src/Reports/Admin/Reports/EmployeeTimeTrackReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public function getData($report, $req)
LogManager::getInstance()->info(json_encode($report));
LogManager::getInstance()->info(json_encode($req));

if (
empty($req['period'])
if (empty($req['period'])
&& (
empty($req['date_start'])
|| 'NULL' === $req['date_start']
Expand Down Expand Up @@ -85,7 +84,13 @@ public function getData($report, $req)
$company->Load('id = ?', [$employeeObject->department]);

$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[] = ["Department:",$company->title,"","",""];
$reportData[] = ["Total Days:","","","",""];
Expand All @@ -94,7 +99,11 @@ public function getData($report, $req)
//Iterate date range

$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;
$totalHoursTimeSheets = 0;
Expand Down Expand Up @@ -154,21 +163,22 @@ public function getData($report, $req)
return $reportData;
}

private function setRequestDatesBasedOnThePeriod($req) {
private function setRequestDatesBasedOnThePeriod($req)
{
if (empty($req['period'])) {
return $req;
}

if ($req['period'] === 'Current Month') {
$req['date_start'] = date('Y-m-01', strtotime('now'));
$req['date_end'] = date('Y-m-d', strtotime('now'));
} else if ($req['period'] === 'Last Month') {
} elseif ($req['period'] === 'Last Month') {
$req['date_start'] = date('Y-m-d', strtotime('first day of last month'));
$req['date_end'] = date('Y-m-d', strtotime('last day of last month'));
} else if ($req['period'] === 'Last Week') {
} elseif ($req['period'] === 'Last Week') {
$req['date_start'] = date("Y-m-d", strtotime("-7 days"));
$req['date_end'] = date('Y-m-d', strtotime('now'));
} else if ($req['period'] === 'Last 2 Weeks') {
} elseif ($req['period'] === 'Last 2 Weeks') {
$req['date_start'] = date("Y-m-d", strtotime("-14 days"));
$req['date_end'] = date('Y-m-d', strtotime('now'));
}
Expand Down

0 comments on commit 45d80e9

Please sign in to comment.