🧲 New features Custom user role permissions Employee edit form updated Employee daily task list Attendance and employee distribution charts on dashboard Improvements to company structure and company assets module Improved tables for displaying data in several modules Faster data loading (specially for employee module) Initials based profile pictures Re-designed login page Re-designed user profile page Improvements to filtering New REST endpoints for employee qualifications 🐛 Bug fixes Fixed, issue with managers being able to create performance reviews for employees who are not their direct reports Fixed, issues related to using full profile image instead of using smaller version of profile image Changing third gender to other Improvements and fixes for internal frontend data caching
67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Thilina
|
|
* Date: 11/3/17
|
|
* Time: 4:11 PM
|
|
*/
|
|
|
|
namespace Classes;
|
|
|
|
use Company\Common\Model\CompanyStructure;
|
|
use Employees\Common\Model\Employee;
|
|
use Model\BaseModel;
|
|
|
|
class PermissionManager
|
|
{
|
|
const RESTRICTED_USER_LEVELS = ['Restricted Admin', 'Restricted Manager', 'Restricted Employee'];
|
|
|
|
const ACCESS_LIST_DESCRIPTION = [
|
|
'get' => 'List',
|
|
'element' => 'View Details',
|
|
'save' => 'Add/Edit',
|
|
'delete' => 'Delete',
|
|
];
|
|
|
|
public static function isRestrictedUserLevel($userLevel)
|
|
{
|
|
return in_array($userLevel, self::RESTRICTED_USER_LEVELS);
|
|
}
|
|
|
|
public static function manipulationAllowed($employeeId, BaseModel $object)
|
|
{
|
|
$subIds = self::getSubordinateIds($employeeId, $object->allowIndirectMapping());
|
|
if ($object->table === 'Employees') {
|
|
return in_array($object->id, $subIds);
|
|
}
|
|
|
|
return in_array($object->employee, $subIds);
|
|
}
|
|
|
|
private static function getSubordinateIds($employeeId, $addIndirect)
|
|
{
|
|
$subIds = [$employeeId];
|
|
$employee = new Employee();
|
|
$list = $employee->Find("supervisor = ?", array($employeeId));
|
|
|
|
foreach ($list as $emp) {
|
|
$subIds[] = $emp->id;
|
|
}
|
|
|
|
if ($addIndirect) {
|
|
$list = $employee->Find("indirect_supervisors like ?", array('%\"'.$employeeId.'\"%'));
|
|
foreach ($list as $emp) {
|
|
$subIds[] = $emp->id;
|
|
}
|
|
}
|
|
|
|
return $subIds;
|
|
}
|
|
|
|
public static function checkGeneralAccess($object)
|
|
{
|
|
$currentUser = BaseService::getInstance()->getCurrentUser();
|
|
return $object->getRoleBasedAccess($currentUser->user_level, $currentUser->user_roles);
|
|
}
|
|
}
|