Latest updates from IceHrmPro
This commit is contained in:
@@ -60,9 +60,9 @@ abstract class ApproveModel extends BaseModel
|
||||
|
||||
if ($user->user_level == "Admin") {
|
||||
//Auto approve
|
||||
$obj->status = "Approved";
|
||||
$notificationMsg = "Your ".$this->notificationUnitName
|
||||
." is auto approved since you are an administrator and do not have any supervisor assigned";
|
||||
$obj->status = 'Approved';
|
||||
$notificationMsg = 'Your '.$this->notificationUnitName
|
||||
.' is auto approved since you are an administrator and do not have any supervisor assigned';
|
||||
BaseService::getInstance()->notificationManager->addNotification(
|
||||
null,
|
||||
$notificationMsg,
|
||||
@@ -76,11 +76,11 @@ abstract class ApproveModel extends BaseModel
|
||||
//If the user do not have a supervisor, notify all admins
|
||||
$admins = BaseService::getInstance()->getAllAdmins();
|
||||
foreach ($admins as $admin) {
|
||||
$notificationMsg = "A new ".$this->notificationUnitName." has been added by "
|
||||
.$employee->first_name . " " . $employee->last_name . ". Please visit "
|
||||
$notificationMsg = 'A new '.$this->notificationUnitName.' has been added by '
|
||||
.$employee->first_name . ' ' . $employee->last_name . '. Please visit '
|
||||
.$this->notificationModuleName
|
||||
." module to review it. You are getting this notification since you are an "
|
||||
."administrator and the user do not have any supervisor assigned.";
|
||||
.' module to review it. You are getting this notification since you are an '
|
||||
.'administrator and the user do not have any supervisor assigned.';
|
||||
BaseService::getInstance()->notificationManager->addNotification(
|
||||
null,
|
||||
$notificationMsg,
|
||||
@@ -151,22 +151,22 @@ abstract class ApproveModel extends BaseModel
|
||||
} else {
|
||||
$user = BaseService::getInstance()->getCurrentUser();
|
||||
|
||||
if ($user->user_level == "Admin") {
|
||||
if ($user->user_level == 'Admin') {
|
||||
} else {
|
||||
//If the user do not have a supervisor, notify all admins
|
||||
$admins = BaseService::getInstance()->getAllAdmins();
|
||||
foreach ($admins as $admin) {
|
||||
$notificationMsg = $this->notificationUnitPrefix." "
|
||||
.$this->notificationUnitName." request has been updated by "
|
||||
.$employee->first_name . " " . $employee->last_name
|
||||
.". Please visit ".$this->notificationModuleName
|
||||
." module to review it. You are getting this notification since you are "
|
||||
."an administrator and the user do not have any supervisor assigned.";
|
||||
$notificationMsg = $this->notificationUnitPrefix.' '
|
||||
.$this->notificationUnitName.' request has been updated by '
|
||||
.$employee->first_name . ' ' . $employee->last_name
|
||||
.'. Please visit '.$this->notificationModuleName
|
||||
.' module to review it. You are getting this notification since you are '
|
||||
.'an administrator and the user do not have any supervisor assigned.';
|
||||
BaseService::getInstance()->notificationManager->addNotification(
|
||||
null,
|
||||
$notificationMsg,
|
||||
'{"type":"url","url":"g=admin&n=travel&m=admin_Employees"}',
|
||||
"Travel Module",
|
||||
'Travel Module',
|
||||
$admin->id,
|
||||
false,
|
||||
$sendNotificationEmail
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
namespace Model;
|
||||
|
||||
use Classes\ModuleAccess;
|
||||
|
||||
class Audit extends BaseModel
|
||||
{
|
||||
public $table = 'AuditLog';
|
||||
@@ -21,4 +23,11 @@ class Audit extends BaseModel
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return [
|
||||
new ModuleAccess('audit', 'admin'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<?php
|
||||
namespace Model;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Classes\IceResponse;
|
||||
use Classes\ModuleAccess;
|
||||
use Classes\ModuleAccessService;
|
||||
use Modules\Common\Model\Module;
|
||||
use Utils\LogManager;
|
||||
|
||||
class BaseModel extends \ADOdb_Active_Record
|
||||
{
|
||||
@@ -24,9 +29,62 @@ class BaseModel extends \ADOdb_Active_Record
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getOtherAccess()
|
||||
private function getRestrictedAccess($userRoles, $allowedAccessMatrix)
|
||||
{
|
||||
return array();
|
||||
if (empty($userRoles)) {
|
||||
return $this->getDefaultAccessLevel();
|
||||
}
|
||||
|
||||
$userRoles = json_decode($userRoles, true);
|
||||
|
||||
if (empty($userRoles)) {
|
||||
return $this->getDefaultAccessLevel();
|
||||
}
|
||||
|
||||
$moduleAccessData = $this->getModuleAccess();
|
||||
if (empty($moduleAccessData)) {
|
||||
return $this->getDefaultAccessLevel();
|
||||
}
|
||||
|
||||
$modules = [];
|
||||
/** @var ModuleAccess $moduleAccess */
|
||||
foreach ($moduleAccessData as $moduleAccess) {
|
||||
$modules[] = ModuleAccessService::getInstance()->getModule(
|
||||
$moduleAccess->getName(),
|
||||
$moduleAccess->getGroup()
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($modules)) {
|
||||
return $this->getDefaultAccessLevel();
|
||||
}
|
||||
|
||||
foreach ($modules as $module) {
|
||||
if (empty($module->user_roles) || $module->user_roles == '[]') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count(array_intersect($userRoles, json_decode($module->user_roles, true))) > 0) {
|
||||
return $allowedAccessMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getDefaultAccessLevel();
|
||||
}
|
||||
|
||||
public function getRestrictedAdminAccess($userRoles)
|
||||
{
|
||||
return $this->getRestrictedAccess($userRoles, $this->getAdminAccess());
|
||||
}
|
||||
|
||||
public function getRestrictedManagerAccess($userRoles)
|
||||
{
|
||||
return $this->getRestrictedAccess($userRoles, $this->getAdminAccess());
|
||||
}
|
||||
|
||||
public function getRestrictedEmployeeAccess($userRoles)
|
||||
{
|
||||
return $this->getRestrictedAccess($userRoles, $this->getAdminAccess());
|
||||
}
|
||||
|
||||
public function getManagerAccess()
|
||||
@@ -69,6 +127,11 @@ class BaseModel extends \ADOdb_Active_Record
|
||||
return "employee";
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function validateSave($obj)
|
||||
{
|
||||
return new IceResponse(IceResponse::SUCCESS, "");
|
||||
@@ -109,7 +172,7 @@ class BaseModel extends \ADOdb_Active_Record
|
||||
|
||||
public function getDefaultAccessLevel()
|
||||
{
|
||||
return array("get","element","save","delete");
|
||||
return $this->getAnonymousAccess();
|
||||
}
|
||||
|
||||
public function getVirtualFields()
|
||||
@@ -125,7 +188,7 @@ class BaseModel extends \ADOdb_Active_Record
|
||||
|
||||
public function getDisplayName()
|
||||
{
|
||||
return get_called_class();
|
||||
return $this->getEntity();
|
||||
}
|
||||
|
||||
public function fieldValueMethods()
|
||||
@@ -179,4 +242,67 @@ class BaseModel extends \ADOdb_Active_Record
|
||||
|
||||
return $keys;
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
public function Find($whereOrderBy, $bindarr = false, $cache = false, $pkeysArr = false, $extra = array())
|
||||
{
|
||||
if ($cache && BaseService::getInstance()->queryCacheEnabled()) {
|
||||
$data = BaseService::getInstance()->getCacheService()->getDBQuery($this->getEntity(),$whereOrderBy, $bindarr);
|
||||
if ($data !== null) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
$data = parent::Find($whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
|
||||
if (empty($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ($cache && BaseService::getInstance()->queryCacheEnabled()) {
|
||||
BaseService::getInstance()->getCacheService()->setDBQuery($this->getEntity(),$whereOrderBy, $bindarr, $data);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getEntity()
|
||||
{
|
||||
$data = explode('\\', get_called_class());
|
||||
return end($data);
|
||||
}
|
||||
|
||||
public function Save()
|
||||
{
|
||||
$ok = parent::Save();
|
||||
if (!$ok) {
|
||||
$message = sprintf('%s: (%s) %s', 'Error saving :', $this->ErrorMsg(), json_encode($this));
|
||||
LogManager::getInstance()->error($message);
|
||||
LogManager::getInstance()->notifyException(new \Exception($message));
|
||||
}
|
||||
if (BaseService::getInstance()->queryCacheEnabled()) {
|
||||
BaseService::getInstance()->getCacheService()->deleteByEntity($this->getEntity());
|
||||
}
|
||||
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
public function Delete()
|
||||
{
|
||||
$ok = parent::Delete();
|
||||
if (!$ok) {
|
||||
$message = sprintf('%s: (%s) %s', 'Error deleting', $this->ErrorMsg(), json_encode($this));
|
||||
LogManager::getInstance()->error($message);
|
||||
LogManager::getInstance()->notifyException(new \Exception($message));
|
||||
}
|
||||
|
||||
if (BaseService::getInstance()->queryCacheEnabled()) {
|
||||
BaseService::getInstance()->getCacheService()->deleteByEntity($this->getEntity());
|
||||
}
|
||||
|
||||
return $ok;
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
||||
8
core/src/Model/EmailLogEntry.php
Normal file
8
core/src/Model/EmailLogEntry.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Model;
|
||||
|
||||
class EmailLogEntry extends BaseModel
|
||||
{
|
||||
public $table = 'EmailLog';
|
||||
}
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
namespace Model;
|
||||
|
||||
use Classes\ModuleAccess;
|
||||
|
||||
class Report extends BaseModel
|
||||
{
|
||||
public function getAdminAccess()
|
||||
@@ -25,6 +27,13 @@ class Report extends BaseModel
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return [
|
||||
new ModuleAccess('reports', 'admin'),
|
||||
];
|
||||
}
|
||||
|
||||
public function postProcessGetData($entry)
|
||||
{
|
||||
$entry->icon = '<img src="'.BASE_URL.'images/file-icons/'.strtolower($entry->output).".png".'"/>';
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
namespace Model;
|
||||
|
||||
use Classes\ModuleAccess;
|
||||
|
||||
class ReportFile extends BaseModel
|
||||
{
|
||||
public function getAdminAccess()
|
||||
@@ -30,6 +32,13 @@ class ReportFile extends BaseModel
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return [
|
||||
new ModuleAccess('report_files', 'admin'),
|
||||
];
|
||||
}
|
||||
|
||||
public function postProcessGetData($entry)
|
||||
{
|
||||
$data = explode(".", $entry->name);
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Model;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Classes\IceResponse;
|
||||
use Classes\ModuleAccess;
|
||||
use Classes\RestApiManager;
|
||||
use Users\Common\Model\User;
|
||||
|
||||
@@ -30,6 +31,13 @@ class Setting extends BaseModel
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return [
|
||||
new ModuleAccess('settings', 'admin'),
|
||||
];
|
||||
}
|
||||
|
||||
public function postProcessGetElement($obj)
|
||||
{
|
||||
if ($obj->name == 'Api: REST Api Token') {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
namespace Model;
|
||||
|
||||
use Classes\ModuleAccess;
|
||||
|
||||
class UserReport extends BaseModel
|
||||
{
|
||||
public function getAdminAccess()
|
||||
@@ -25,6 +27,13 @@ class UserReport extends BaseModel
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return [
|
||||
new ModuleAccess('reports', 'user'),
|
||||
];
|
||||
}
|
||||
|
||||
public function postProcessGetData($entry)
|
||||
{
|
||||
$entry->icon = '<img src="'.BASE_URL.'images/file-icons/'.strtolower($entry->output).".png".'"/>';
|
||||
|
||||
Reference in New Issue
Block a user