public function getLatestNotificationsAndCounts($userId)
 {
     $notification = new Notification();
     $listUnread = $notification->Find("toUser = ? and status = ?", array($userId, 'Unread'));
     $unreadCount = count($listUnread);
     $limit = $unreadCount < 10 ? 10 : $unreadCount;
     $list = $notification->Find("toUser = ? order by time desc limit ?", array($userId, $limit));
     $newList = array();
     $fs = FileService::getInstance();
     foreach ($list as $noti) {
         if ($noti->fromEmployee > 0) {
             $employee = $this->baseService->getElement('Employee', $noti->fromEmployee, null, true);
             if (!empty($employee)) {
                 $employee = $fs->updateProfileImage($employee);
                 $noti->image = $employee->image;
                 if (empty($noti->image)) {
                     if ($employee->gender == 'Male') {
                         $noti->image = BASE_URL . "images/user_male.png";
                     } else {
                         $noti->image = BASE_URL . "images/user_female.png";
                     }
                 }
                 $newList[] = $noti;
             }
         } else {
             $noti->image = BASE_URL . "images/icehrm.png";
             $newList[] = $noti;
         }
     }
     return array($unreadCount, $list);
 }
 public function deleteProfileImage($req)
 {
     if ($this->user->user_level == 'Admin' || $this->user->profile == $req->id) {
         $fs = FileService::getInstance();
         $res = $fs->deleteProfileImage($req->id);
         return new IceResponse(IceResponse::SUCCESS, $res);
     }
 }
 public function deleteProfileImage($req)
 {
     $profileId = $this->getCurrentProfileId();
     $subordinate = new Employee();
     $subordinatesCount = $subordinate->Count("supervisor = ? and id = ?", array($profileId, $req->id));
     if ($this->user->user_level == 'Admin' || $this->user->employee == $req->id || $subordinatesCount == 1) {
         $fs = FileService::getInstance();
         $res = $fs->deleteProfileImage($req->id);
         return new IceResponse(IceResponse::SUCCESS, $res);
     }
     return new IceResponse(IceResponse::ERROR, "Not allowed to delete profile image");
 }
Пример #4
0
$profileCurrent = null;
$profileSwitched = null;
$profileClass = ucfirst(SIGN_IN_ELEMENT_MAPPING_FIELD_NAME);
$profileVar = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
if (!empty($user->{$profileVar})) {
    $profileCurrent = BaseService::getInstance()->getElement($profileClass, $user->{$profileVar}, null, true);
    if (!empty($profileCurrent)) {
        $profileCurrent = FileService::getInstance()->updateProfileImage($profileCurrent);
    }
}
if ($user->user_level == 'Admin' || $user->user_level == 'Manager') {
    $switchedEmpId = BaseService::getInstance()->getCurrentProfileId();
    if ($switchedEmpId != $user->{$profileVar} && !empty($switchedEmpId)) {
        $profileSwitched = BaseService::getInstance()->getElement($profileClass, $switchedEmpId, null, true);
        if (!empty($profileSwitched)) {
            $profileSwitched = FileService::getInstance()->updateProfileImage($profileSwitched);
        }
    }
}
$activeProfile = null;
if (!empty($profileSwitched)) {
    $activeProfile = $profileSwitched;
} else {
    $activeProfile = $profileCurrent;
}
//read field templates
$fieldTemplates = array();
$fieldTemplates['hidden'] = file_get_contents(CLIENT_PATH . '/templates/fields/hidden.html');
$fieldTemplates['text'] = file_get_contents(CLIENT_PATH . '/templates/fields/text.html');
$fieldTemplates['textarea'] = file_get_contents(CLIENT_PATH . '/templates/fields/textarea.html');
$fieldTemplates['select'] = file_get_contents(CLIENT_PATH . '/templates/fields/select.html');
Пример #5
0
 public function deleteElement($table, $id)
 {
     $fileFields = $this->fileFields;
     $ele = new $table();
     $ele->Load('id = ?', array($id));
     $this->checkSecureAccess("delete", $ele);
     if (isset($this->nonDeletables[$table])) {
         $nonDeletableTable = $this->nonDeletables[$table];
         if (!empty($nonDeletableTable)) {
             foreach ($nonDeletableTable as $field => $value) {
                 if ($ele->{$field} == $value) {
                     return "This item can not be deleted";
                 }
             }
         }
     }
     $ok = $ele->Delete();
     if (!$ok) {
         $error = $ele->ErrorMsg();
         LogManager::getInstance()->info($error);
         return $this->findError($error);
     } else {
         //Backup
         if ($table == "Profile") {
             $newObj = $this->cleanUpAdoDB($ele);
             $dataEntryBackup = new DataEntryBackup();
             $dataEntryBackup->tableType = $table;
             $dataEntryBackup->data = json_encode($newObj);
             $dataEntryBackup->Save();
         }
         $this->audit(IceConstants::AUDIT_DELETE, "Deleted an object in " . $table . " [id:" . $ele->id . "]");
     }
     if (isset($fileFields[$table])) {
         foreach ($fileFields[$table] as $k => $v) {
             if (!empty($ele->{$k})) {
                 FileService::getInstance()->deleteFileByField($ele->{$k}, $v);
             }
         }
     }
     return null;
 }
Пример #6
0
 public function getCompanyLogoUrl()
 {
     $logoFileSet = false;
     $logoFileName = CLIENT_BASE_PATH . "data/logo.png";
     $logoSettings = SettingsManager::getInstance()->getSetting("Company: Logo");
     if (!empty($logoSettings)) {
         $logoFileName = FileService::getInstance()->getFileUrl($logoSettings);
         $logoFileSet = true;
     }
     if (!$logoFileSet && !file_exists($logoFileName)) {
         return BASE_URL . "images/logo.png";
     }
     return $logoFileName;
 }
 public function postProcessGetData($obj)
 {
     $obj = FileService::getInstance()->updateSmallProfileImage($obj);
     return $obj;
 }