Ejemplo n.º 1
0
 public static function getProductInfoBySID($productSID)
 {
     $cacheId = 'ProductManager::getProductInfoBySID' . $productSID;
     if (SJB_MemoryCache::has($cacheId)) {
         return SJB_MemoryCache::get($cacheId);
     }
     $product = SJB_ObjectDBManager::getObjectInfo("products", $productSID);
     if (!empty($product['serialized_extra_info'])) {
         $serialized_extra_info = unserialize($product['serialized_extra_info']);
         $product = array_merge($product, $serialized_extra_info);
     }
     SJB_MemoryCache::set($cacheId, $product);
     return $product;
 }
Ejemplo n.º 2
0
 public static function getAllCountriesCodesAndNames($active = false, $displayAS = false)
 {
     $cacheId = 'SJB_CountriesManager::getAllCountriesCodesAndNames';
     if (SJB_MemoryCache::has($cacheId)) {
         return SJB_MemoryCache::get($cacheId);
     }
     if ($active) {
         $countries = self::getAllActiveCountries($displayAS);
     } else {
         $countries = self::getAllCountries();
     }
     $countriesCodesAndNames = self::getCountriesCodesAndNames($countries);
     SJB_MemoryCache::set($cacheId, $countriesCodesAndNames);
     return $countriesCodesAndNames;
 }
Ejemplo n.º 3
0
 public function current()
 {
     $listing_structure = array();
     $info = current($this->array);
     if (is_numeric($info)) {
         $sid = $info;
         $cache = SJB_Cache::getInstance();
         $cacheID = md5('ListingIterator::SJB_ListingManager::getObjectBySID' . $sid);
         if ($cache->test($cacheID)) {
             $listing = $cache->load($cacheID);
         } else {
             $listing = SJB_ListingManager::getObjectBySID($sid);
             $cache->save($listing, $cacheID, array(SJB_Cache::TAG_LISTINGS));
         }
         $listing->addPicturesProperty();
         $cacheId = md5('SJB_ListingTypeManager::getListingTypeIDBySID' . $listing->getListingTypeSID());
         if (SJB_MemoryCache::has($cacheId)) {
             $listing_type = SJB_MemoryCache::get($cacheId);
         } else {
             $listing_type = SJB_ListingTypeManager::getListingTypeIDBySID($listing->getListingTypeSID());
             SJB_MemoryCache::set($cacheId, $listing_type);
         }
         $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
         $listing_structure = SJB_ListingManager::newValueFromSearchCriteria($listing_structure, $this->criteria);
         if ($this->user_logged_in) {
             $listing_structure['saved_listing'] = SJB_SavedListings::getSavedListingsByUserAndListingSid($this->current_user_sid, $listing->getID());
         }
         $listing_structure['activation_date'] = date('Y-m-d H:i:s', strtotime($listing_structure['activation_date']));
         $listing_structure['expiration_date'] = date('Y-m-d H:i:s', strtotime($listing_structure['expiration_date']));
         $listing_structure['listing_url'] = SJB_System::getSystemSettings('SITE_URL') . "/display-" . strtolower($listing_type) . "/" . $listing->getSID() . "/";
         if (isset($listing->details->properties['EmploymentType'])) {
             $employmentInfo = $listing->details->properties['EmploymentType']->type->property_info;
             $employmentTypes = array();
             $employment = explode(",", $employmentInfo['value']);
             foreach ($employmentInfo['list_values'] as $type) {
                 $empType = str_replace(" ", "", $type['caption']);
                 $employmentTypes[$empType] = 0;
                 if (in_array($type['id'], $employment)) {
                     $employmentTypes[$empType] = 1;
                 }
             }
             $listing_structure['myEmploymentType'] = $employmentTypes;
         }
         // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION
         if ($this->view == 'map') {
             $zipCode = $listing_structure['Location']['ZipCode'];
             // get 'latitude' and 'longitude' from zipCode field, if it not set
             $latitude = isset($listing_structure['latitude']) ? $listing_structure['latitude'] : '';
             $longitude = isset($listing_structure['longitude']) ? $listing_structure['longitude'] : '';
             if (!empty($zipCode) && empty($latitude) && empty($longitude)) {
                 $result = SJB_DB::query("SELECT * FROM `locations` WHERE `name` = ?s LIMIT 1", $zipCode);
                 if ($result) {
                     $current_coordinates = array($result[0]['latitude'], $result[0]['longitude']);
                     if (in_array($current_coordinates, self::$coordinates)) {
                         self::$index += 0.0001;
                     }
                     $listing_structure['latitude'] = $result[0]['latitude'] + self::$index;
                     $listing_structure['longitude'] = $result[0]['longitude'] + self::$index;
                     self::$coordinates = array_merge(self::$coordinates, array($current_coordinates));
                 }
             } elseif (!empty($listing_structure['Location']['City']) && !empty($listing_structure['Location']['State']) && !empty($listing_structure['Location']['Country'])) {
                 $address = $listing_structure['Location']['City'] . ', ' . $listing_structure['Location']['State'] . ', ' . $listing_structure['Location']['Country'];
                 $address = urlencode($address);
                 $cache = SJB_Cache::getInstance();
                 $parameters = array('City' => $listing_structure['Location']['City'], 'State' => $listing_structure['Location']['State'], 'Country' => $listing_structure['Location']['Country']);
                 $hash = md5('google_map' . serialize($parameters));
                 $data = $cache->load($hash);
                 if (!$data) {
                     try {
                         $geoCod = SJB_HelperFunctions::getUrlContentByCurl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false");
                         $geoCod = json_decode($geoCod);
                         if ($geoCod->status == 'OK') {
                             $cache->save($geoCod, $hash);
                         }
                     } catch (Exception $e) {
                         $backtrace = SJB_Logger::getBackTrace();
                         SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
                     }
                 } else {
                     $geoCod = $data;
                 }
                 try {
                     if (!is_object($geoCod)) {
                         throw new Exception("Map object nave not been Created");
                     }
                     if ($geoCod->status != 'OK') {
                         throw new Exception("Status is not OK");
                     }
                     $location = $geoCod->results[0]->geometry->location;
                     $current_coordinates = array($location->lat, $location->lng);
                     if (in_array($current_coordinates, self::$coordinates)) {
                         self::$index += 0.0001;
                     }
                     $listing_structure['latitude'] = $location->lat + self::$index;
                     $listing_structure['longitude'] = $location->lng + self::$index;
                     self::$coordinates = array_merge(self::$coordinates, array($current_coordinates));
                 } catch (Exception $e) {
                     $backtrace = SJB_Logger::getBackTrace();
                     SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
                 }
             }
         }
     } elseif ($info) {
         $listing_structure = $info;
     }
     return $listing_structure;
 }
Ejemplo n.º 4
0
 /**
  * @param SJB_Listing $listing
  */
 public static function createTemplateStructureForListing($listing, $extraInfo = array())
 {
     $listing_info = parent::getObjectInfo($listing);
     if (SJB_MemoryCache::has('listingTypeInfo' . $listing->getListingTypeSID())) {
         $listing_type_info = SJB_MemoryCache::get('listingTypeInfo' . $listing->getListingTypeSID());
     } else {
         $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listing->getListingTypeSID());
         SJB_MemoryCache::set('listingTypeInfo' . $listing->getListingTypeSID(), $listing_type_info);
     }
     foreach ($listing->getProperties() as $property) {
         if ($property->isComplex()) {
             $isPropertyEmpty = true;
             $properties = $property->type->complex->getProperties();
             $properties = is_array($properties) ? $properties : array();
             foreach ($properties as $subProperty) {
                 if (!empty($listing_info['user_defined'][$property->getID()][$subProperty->getID()]) && is_array($listing_info['user_defined'][$property->getID()][$subProperty->getID()])) {
                     foreach ($listing_info['user_defined'][$property->getID()][$subProperty->getID()] as $subValue) {
                         if (!empty($subValue)) {
                             $isPropertyEmpty = false;
                         }
                     }
                 }
             }
             if ($isPropertyEmpty) {
                 $listing_info['user_defined'][$property->getID()] = '';
             }
         }
         if ($property->getType() == 'list') {
             $value = $property->getValue();
             $properties = $property->type->property_info;
             $listValues = isset($properties['list_values']) ? $properties['list_values'] : array();
             foreach ($listValues as $listValue) {
                 if ($listValue['id'] == $value) {
                     $listing_info['user_defined'][$property->getID()] = $listValue['caption'];
                 }
             }
         } elseif ($property->getType() == 'multilist') {
             $value = $property->getValue();
             if (!is_array($property->getValue())) {
                 $value = explode(',', $property->getValue());
             }
             $properties = $property->type->property_info;
             $listValues = isset($properties['list_values']) ? $properties['list_values'] : array();
             $listing_info['user_defined'][$property->getID()] = array();
             foreach ($listValues as $listValue) {
                 if (in_array($listValue['id'], $value)) {
                     $listing_info['user_defined'][$property->getID()][$listValue['id']] = $listValue['caption'];
                 }
             }
         } elseif ($property->getType() == 'location' && is_array($listing_info['user_defined'][$property->getID()])) {
             foreach ($property->type->fields as $locationField) {
                 if (array_key_exists($locationField['id'], $listing_info['user_defined'][$property->getID()])) {
                     if ($locationField['id'] == 'State') {
                         $listValues = SJB_StatesManager::getStateNamesBySid($property->value['State'], 'state_name');
                     } else {
                         $listValues = isset($locationField['list_values']) ? $locationField['list_values'] : array();
                     }
                     $value = $property->getValue();
                     $value = isset($value[$locationField['id']]) ? $value[$locationField['id']] : '';
                     foreach ($listValues as $listValue) {
                         if ($listValue['id'] == $value) {
                             $listing_info['user_defined'][$property->getID()][$locationField['id']] = $listValue['caption'];
                             $listing_info['user_defined'][$property->getID()][$locationField['id'] . '_Code'] = $listValue['Code'];
                             $listing_info['user_defined'][$property->getID()][$locationField['id'] . '_Name'] = $listValue['Name'];
                         }
                     }
                 }
             }
         }
     }
     $cache = SJB_Cache::getInstance();
     $cacheId = md5('SJB_UserManager::getObjectBySID' . $listing_info['system']['user_sid']);
     $user_info = array();
     if ($cache->test($cacheId)) {
         $user_info = $cache->load($cacheId);
     } else {
         $user = SJB_UserManager::getObjectBySID($listing_info['system']['user_sid']);
         $user_info = !empty($user) ? SJB_UserManager::createTemplateStructureForUser($user) : null;
         $cache->save($user_info, $cacheId, array(SJB_Cache::TAG_USERS));
     }
     $productInfo = SJB_ProductsManager::createTemplateStructureForProduct($listing_info['system']['product_info']);
     $priceForUpgradeToFeatured = 0;
     $priceForUpgradeToPriority = 0;
     if (!empty($listing_info['system']['product_info'])) {
         $listingProductInfo = unserialize($listing_info['system']['product_info']);
         $priceForUpgradeToFeatured = SJB_Array::get($listingProductInfo, 'upgrade_to_featured_listing_price', 0);
         $priceForUpgradeToPriority = SJB_Array::get($listingProductInfo, 'upgrade_to_priority_listing_price', 0);
     }
     $structure = array('id' => $listing_info['system']['id'], 'type' => array('id' => $listing_type_info['id'], 'caption' => $listing_type_info['name']), 'user' => $user_info, 'activation_date' => $listing_info['system']['activation_date'], 'expiration_date' => $listing_info['system']['expiration_date'], 'featured' => $listing_info['system']['featured'], 'priority' => $listing_info['system']['priority'], 'views' => $listing_info['system']['views'], 'active' => $listing_info['system']['active'], 'product' => $productInfo, 'contract_id' => $listing_info['system']['contract_id'], 'number_of_pictures' => isset($listing_info['user_defined']['pictures']) ? count($listing_info['user_defined']['pictures']) : 0, 'approveStatus' => $listing_info['system']['status'], 'complete' => $listing_info['system']['complete'], 'external_id' => $listing_info['system']['external_id'], 'priceForUpgradeToFeatured' => $priceForUpgradeToFeatured, 'priceForUpgradeToPriority' => $priceForUpgradeToPriority);
     if (SJB_Settings::getSettingByName('jobg8Installed') && SJB_PluginManager::isPluginActive('JobG8IntegrationPlugin')) {
         $structure['jobType'] = JobG8::getJobProperty($listing_info['system']['id'], 'jobType');
     }
     if (array_search('comments', $extraInfo)) {
         $structure['comments_num'] = SJB_CommentManager::getCommentsNumToListing($listing_info['system']['id']);
     }
     if (array_search('ratings', $extraInfo)) {
         $structure['rating_num'] = SJB_Rating::getRatingNumToListing($listing_info['system']['id']);
         $structure['rating'] = SJB_Rating::getRatingToListing($listing_info['system']['id']);
         $structure['rating_array'] = SJB_Rating::getRatingTplToListing($listing_info['system']['id']);
     }
     if (!empty($listing_info['system']['subuser_sid'])) {
         $structure['subuser'] = SJB_UserManager::getUserInfoBySID($listing_info['system']['subuser_sid']);
     }
     $structure['METADATA'] = array('activation_date' => array('type' => 'date'), 'expiration_date' => array('type' => 'date'), 'views' => array('type' => 'integer'), 'number_of_pictures' => array('type' => 'integer'), 'approveStatus' => array('type' => 'string'), 'rejectReason' => array('type' => 'string'));
     $structure = array_merge($structure, $listing_info['user_defined']);
     $structure['METADATA'] = array_merge($structure['METADATA'], parent::getObjectMetaData($listing));
     $listing_user_meta_data = array();
     if (isset($user_info['METADATA'])) {
         $listing_user_meta_data = $user_info['METADATA'];
         unset($user_info['METADATA']);
     }
     $listing_product_meta_data = array();
     if (isset($productInfo['METADATA'])) {
         $listing_product_meta_data = $productInfo['METADATA'];
         unset($productInfo['METADATA']);
     }
     $listing_type_meta_data = array('caption' => array('type' => 'string', 'propertyID' => 'listing_type'));
     $structure['METADATA'] = array_merge($structure['METADATA'], array('user' => $listing_user_meta_data, 'product' => $listing_product_meta_data, 'type' => $listing_type_meta_data));
     return array_merge($structure, $listing_info['user_defined']);
 }
Ejemplo n.º 5
0
 /**
  * 
  * @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;
 }
Ejemplo n.º 6
0
 public static function getTemplatesByGroupForListType($group)
 {
     $cacheId = 'SJB_TemplateEditor::getTemplatesByGroupForListType' . $group;
     if (SJB_MemoryCache::has($cacheId)) {
         return SJB_MemoryCache::get($cacheId);
     }
     $emailTemplates = SJB_DB::query("SELECT * FROM `email_templates` WHERE `group` = ?s ORDER BY `name`", $group);
     $listEmails = array();
     foreach ($emailTemplates as $emailTemplate) {
         $listEmails[] = array('id' => $emailTemplate['sid'], 'caption' => $emailTemplate['name']);
     }
     SJB_MemoryCache::set($cacheId, $listEmails);
     return $listEmails;
 }
Ejemplo n.º 7
0
 public static function getAllUserGroupsIDsAndCaptions()
 {
     $cacheId = 'UserGroupManager::getAllUserGroupsIDsAndCaptions';
     if (SJB_MemoryCache::has($cacheId)) {
         return SJB_MemoryCache::get($cacheId);
     }
     $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo();
     $user_groups_ids_and_captions = array();
     foreach ($user_groups_info as $user_group_info) {
         $user_groups_ids_and_captions[] = array('id' => $user_group_info['sid'], 'key' => $user_group_info['id'], 'caption' => $user_group_info['name']);
     }
     SJB_MemoryCache::set($cacheId, $user_groups_ids_and_captions);
     return $user_groups_ids_and_captions;
 }
Ejemplo n.º 8
0
 public static function getListingAllTypesForListType()
 {
     $cacheId = 'SJB_ListingTypeManager::getListingAllTypesForListType';
     if (SJB_MemoryCache::has($cacheId)) {
         return SJB_MemoryCache::get($cacheId);
     }
     $listingTypes = self::getAllListingTypesInfo();
     $listTypes = array();
     foreach ($listingTypes as $listingType) {
         $listTypes[] = array('id' => $listingType['sid'], 'key' => $listingType['id'], 'caption' => $listingType['name']);
     }
     SJB_MemoryCache::set($cacheId, $listTypes);
     return $listTypes;
 }
Ejemplo n.º 9
0
 /**
  * Можно ли?
  * @param $resource
  * @param $roleId
  */
 public function isAllowed($resource, $roleId = null, $type = 'user', $returnParams = false, $returnMessage = false)
 {
     $resource = strtolower($resource);
     $userInfo = array();
     if (null === $roleId) {
         // если не задан пользователь, то попробуем использовать текущего
         $userInfo = SJB_UserManager::getCurrentUserInfo();
         if (!empty($userInfo)) {
             $roleId = $userInfo['sid'];
         }
         if (null === $roleId) {
             if (SJB_Admin::admin_authed() && SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == 'admin') {
                 if ($returnParams) {
                     return '';
                 }
                 if ($returnMessage) {
                     return '';
                 }
                 return true;
             }
             $roleId = 'guest';
         }
     } else {
         $cacheId = 'SJB_Acl::SJB_UserManager::getUserInfoBySID' . $roleId;
         if (SJB_MemoryCache::has($cacheId)) {
             $userInfo = SJB_MemoryCache::get($cacheId);
         } else {
             $userInfo = SJB_UserManager::getUserInfoBySID($roleId);
             SJB_MemoryCache::set($cacheId, $userInfo);
         }
     }
     $role = $type . '_' . $roleId;
     if ($resource == 'use_screening_questionnaires' && intval($userInfo['parent_sid']) > 0) {
         if ($this->isAllowed($resource, $userInfo['parent_sid'])) {
             return $this->isAllowed('subuser_use_screening_questionnaires', $userInfo['sid']);
         }
         return false;
     }
     if (!isset($this->permissions[$role])) {
         switch ($type) {
             case 'user':
             case 'guest':
                 if ($roleId == 'guest' || $type == 'guest') {
                     $role = 'user_guest';
                     if (empty($this->permissions[$role])) {
                         $this->permissions[$role] = $this->getPermissions('guest', 'guest');
                     }
                 } else {
                     $permissions = $this->getPermissions('user', $roleId);
                     $groupPermissions = $this->getPermissions('group', $userInfo['user_group_sid']);
                     $this->permissions['group_' . $userInfo['user_group_sid']] = $groupPermissions;
                     $contracts = SJB_ContractManager::getAllContractsSIDsByUserSID($roleId);
                     if (!empty($contracts)) {
                         foreach ($contracts as $contract) {
                             $contractPermissions = $this->mergePermissionsWithGroup($this->getPermissions('contract', $contract), $groupPermissions);
                             $this->permissions['contract_' . $contract] = $contractPermissions;
                             $permissions = $this->mergePermissions($contractPermissions, $permissions);
                         }
                     } else {
                         $permissions = $this->mergePermissionsWithGroup($permissions, $groupPermissions);
                     }
                     $this->permissions[$role] = $permissions;
                 }
                 break;
             case 'group':
                 $this->permissions[$role] = $this->getPermissions($type, $roleId);
                 break;
             case 'product':
                 $productInfo = SJB_ProductsManager::getProductInfoBySID($roleId);
                 if (!empty($productInfo['user_group_sid'])) {
                     $groupRole = 'group_' . $productInfo['user_group_sid'];
                     if (empty($this->permissions[$groupRole])) {
                         $this->permissions[$groupRole] = $this->getPermissions('group', $productInfo['user_group_sid']);
                     }
                     $this->permissions[$role] = $this->mergePermissionsWithGroup($this->getPermissions('product', $roleId), $this->permissions[$groupRole]);
                 } else {
                     $this->permissions[$role] = $this->getPermissions('product', $roleId);
                 }
                 break;
             case 'contract':
                 $this->permissions[$role] = $this->getPermissions('contract', $roleId);
                 break;
         }
     }
     if (!isset($userInfo)) {
         $userInfo = SJB_UserManager::getCurrentUserInfo();
     }
     $is_display_resume = !preg_match_all("/.*\\/(?:display_resume|display_job)\\/(\\d*)/i", $_SERVER['REQUEST_URI'], $match) ? isset($_SERVER['REDIRECT_URL']) ? preg_match_all("/.*\\/(?:display_resume|display_job)\\/(\\d*)/i", $_SERVER['REDIRECT_URL'], $match) : false : true;
     // Allow access to Resume/Job Details page if an employer has an application linked to the resume
     if (isset($userInfo) && $is_display_resume) {
         $apps = SJB_DB::query("SELECT `a`.resume FROM `applications` `a`\n\t\t\t\t\t\t            INNER JOIN `listings` l ON\n\t\t\t\t\t\t                  `l`.`sid` = `a`.`listing_id`\n\t\t\t\t\t\t            WHERE `l`.`user_sid` = ?n AND `a`.`show_emp` = 1  ORDER BY a.`date` DESC", $userInfo['sid']);
         if (isset($match[1]) && in_array(array("resume" => array_pop($match[1])), $apps)) {
             $this->permissions[$role][$resource]['value'] = 'allow';
             $this->permissions[$role][$resource]['params'] = '';
         }
     }
     if ($returnParams) {
         return empty($this->permissions[$role][$resource]['params']) ? '' : $this->permissions[$role][$resource]['params'];
     } elseif ($returnMessage) {
         $message = empty($this->permissions[$role][$resource]['message']) ? '' : $this->permissions[$role][$resource]['message'];
         if (!$message) {
             if (!empty($userInfo)) {
                 $groupRole = 'group_' . $userInfo['user_group_sid'];
                 $message = empty($this->permissions[$groupRole][$resource]['message']) ? '' : $this->permissions[$groupRole][$resource]['message'];
             }
         }
         return $message;
     }
     return isset($this->permissions[$role][$resource]['value']) && $this->permissions[$role][$resource]['value'] == 'allow';
 }
Ejemplo n.º 10
0
 public static function getListingFieldsInfoByParentSID($field_id)
 {
     if (SJB_MemoryCache::has('ListingFieldsInfoByParentSID' . $field_id)) {
         $listing_fields_info = SJB_MemoryCache::get('ListingFieldsInfoByParentSID' . $field_id);
     } else {
         $sids = SJB_ListingFieldDBManager::getListingComplexFieldsValue($field_id, 'field_sid');
         $listing_fields_info = array();
         foreach ($sids as $sid) {
             $listing_fields_info[] = SJB_ListingFieldDBManager::getListingComplexFieldInfoBySID($sid['sid']);
         }
         SJB_MemoryCache::set('ListingFieldsInfoByParentSID' . $field_id, $listing_fields_info);
     }
     return $listing_fields_info;
 }
Ejemplo n.º 11
0
 public static function getStateNamesBySid($sid = false, $displayAS = false)
 {
     $stateNames = array();
     $cacheID = 'StateNamesBySid' . $sid . $displayAS;
     if (SJB_MemoryCache::has($cacheID)) {
         $stateNames = SJB_MemoryCache::get($cacheID);
     } else {
         if (!$displayAS) {
             $displayAS = 'state_name';
         }
         $states = SJB_DB::query("SELECT `sid`, `state_code`, `state_name` as stateName, ?w as `state_name` FROM `states`\n\t\t\t\tWHERE `sid` = ?n  ORDER BY `order`", $displayAS, $sid);
         foreach ($states as $state) {
             $stateNames[] = array('id' => $state['sid'], 'Code' => $state['state_code'], 'Name' => $state['stateName'], 'caption' => $state['state_name']);
         }
         SJB_MemoryCache::set($cacheID, $stateNames);
     }
     return $stateNames;
 }
Ejemplo n.º 12
0
 public static function getUploadedFileInfo($uploaded_file_id)
 {
     if (!is_string($uploaded_file_id) || empty($uploaded_file_id)) {
         return null;
     }
     if (SJB_MemoryCache::has('UploadedFileInfo' . $uploaded_file_id)) {
         return SJB_MemoryCache::get('UploadedFileInfo' . $uploaded_file_id);
     } else {
         $file_info = SJB_DB::query("SELECT * FROM `uploaded_files` WHERE `id` = ?s", $uploaded_file_id);
         if (!empty($file_info)) {
             $result = array_pop($file_info);
             SJB_MemoryCache::set('UploadedFileInfo' . $uploaded_file_id, $result);
             return $result;
         }
     }
     return null;
 }
Ejemplo n.º 13
0
 function addListingTypeIDProperty($type_id)
 {
     if (SJB_MemoryCache::has('listingTypesInfo')) {
         $listing_types_info = SJB_MemoryCache::get('listingTypesInfo');
     } else {
         $listing_types_info = SJB_ListingTypeManager::getAllListingTypesInfo();
         SJB_MemoryCache::set('listingTypesInfo', $listing_types_info);
     }
     $list_values = array();
     foreach ($listing_types_info as $type_info) {
         $list_values[] = array('id' => $type_info['id'], 'caption' => $type_info['name']);
     }
     $this->addProperty(array('id' => 'listing_type', 'type' => 'list', 'value' => $type_id, 'is_system' => true, 'list_values' => $list_values));
     return array('id' => 'listing_type', 'real_id' => 'listing_type_sid', 'transform_function' => 'SJB_ListingTypeManager::getListingTypeSIDByID');
 }