/** * * @param SJB_User $user */ public static function createTemplateStructureForUser($user) { if (!$user) { return array(); } $structure = $user->getUserInfo(); if (SJB_MemoryCache::has('userGroupInfo' . $user->getUserGroupSID())) { $user_group_info = SJB_MemoryCache::get('userGroupInfo' . $user->getUserGroupSID()); } else { $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user->getUserGroupSID()); SJB_MemoryCache::set('userGroupInfo' . $user->getUserGroupSID(), $user_group_info); } foreach ($user->getProperties() as $property) { $value = $property->getValue(); if ($property->getType() == 'list') { $listValues = isset($property->type->property_info['list_values']) ? $property->type->property_info['list_values'] : array(); foreach ($listValues as $listValue) { if ($listValue['id'] == $value) { $structure[$property->getID()] = $listValue['caption']; } } } elseif ($property->getType() == 'location') { foreach ($property->type->fields as $locationField) { if (isset($structure[$property->getID()]) && array_key_exists($locationField['id'], $structure[$property->getID()])) { if ($locationField['id'] == 'State') { $displayAs = !empty($locationField['display_as']) ? $locationField['display_as'] : 'state_name'; $listValues = SJB_StatesManager::getStateNamesBySid($property->value['State'], $displayAs); } else { $listValues = isset($locationField['list_values']) ? $locationField['list_values'] : array(); } foreach ($listValues as $listValue) { if ($listValue['id'] == $value[$locationField['id']]) { $structure[$property->getID()][$locationField['id']] = $listValue['caption']; $structure[$property->getID()][$locationField['id'] . '_Code'] = $listValue['Code']; $structure[$property->getID()][$locationField['id'] . '_Name'] = $listValue['Name']; } } } } } else { $structure[$property->getID()] = $value; } } $structure['id'] = $user->getID(); $structure['isJobg8'] = strpos($structure['username'], 'jobg8_') !== false; $structure['group'] = array('id' => $user_group_info['id'], 'caption' => $user_group_info['name']); $subuserInfo = $user->getSubuserInfo(); if (!empty($subuserInfo)) { $structure['subuser'] = $subuserInfo; } $structure['METADATA'] = array('group' => array('caption' => array('type' => 'string', 'propertyID' => 'caption')), 'registration_date' => array('type' => 'date')); $structure['METADATA'] = array_merge($structure['METADATA'], parent::getObjectMetaData($user)); return $structure; }
private function executeApplicationsForEmployer($appsPerPage, $appJobId, SJB_User $currentUser, $score, $orderInfo, $listingTitle) { $limit['countRows'] = $appsPerPage; $limit['startRow'] = $this->currentPage * $appsPerPage - $appsPerPage; $subuser = false; if ($appJobId) { $isUserOwnerApps = SJB_Applications::isUserOwnsAppsByAppJobId($currentUser->getID(), $appJobId); if (!$isUserOwnerApps) { SJB_FlashMessages::getInstance()->addWarning('NOT_OWNER_OF_APPLICATIONS', array('listingTitle' => $listingTitle)); } $allAppsCountByJobID = SJB_Applications::getCountAppsByJob($appJobId, $score); $this->setPaginationInfo($appsPerPage, $allAppsCountByJobID); $apps = SJB_Applications::getByJob($appJobId, $orderInfo, $score, $limit); } else { if ($currentUser->isSubuser()) { $subuserInfo = $currentUser->getSubuserInfo(); if (!SJB_Acl::getInstance()->isAllowed('subuser_manage_listings', $subuserInfo['sid'])) { $subuser = $subuserInfo['sid']; } } $allAppsCount = SJB_Applications::getCountApplicationsByEmployer($currentUser->getSID(), $score, $subuser); $this->setPaginationInfo($appsPerPage, $allAppsCount); $apps = SJB_Applications::getByEmployer($currentUser->getSID(), $orderInfo, $score, $subuser, $limit); } return $apps; }