Пример #1
0
 public static function getDetails($user_group_sid, $referenceUid = false)
 {
     $details = array(array('id' => 'featured', 'caption' => 'Featured', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => null), array('id' => 'active', 'caption' => 'Status', 'type' => 'list', 'list_values' => array(array('id' => '1', 'caption' => 'Active'), array('id' => '0', 'caption' => 'Not active')), 'length' => '10', 'is_required' => false, 'is_system' => true), array('id' => 'sendmail', 'caption' => "Don't send mailings", 'type' => 'boolean', 'length' => '1', 'is_required' => false, 'is_system' => true));
     $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
     $email_confirmation = false;
     if (isset($user_group_info['email_confirmation'])) {
         $email_confirmation = $user_group_info['email_confirmation'];
     }
     if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) || class_exists('SJB_SocialPlugin') && $referenceUid) {
         $userFields = array(array('id' => 'username', 'caption' => 'User name', 'type' => 'string', 'table_name' => 'users', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 0), array('id' => 'password', 'caption' => 'Password', 'type' => 'password', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 2), array('id' => 'email', 'caption' => 'Email', 'type' => 'unique_email', 'table_name' => 'users', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 1, 'email_confirmation' => $email_confirmation));
     } else {
         $userFields = array(array('id' => 'username', 'caption' => 'User name', 'type' => 'unique_string', 'table_name' => 'users', 'length' => '20', 'validators' => array('SJB_IdValidator', 'SJB_UniqueSystemValidator'), 'is_required' => true, 'is_system' => true, 'order' => 0), array('id' => 'password', 'caption' => 'Password', 'type' => 'password', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 1), array('id' => 'email', 'caption' => 'Email', 'type' => 'unique_email', 'table_name' => 'users', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 2, 'email_confirmation' => $email_confirmation));
     }
     $details = array_merge($userFields, $details);
     $extra_details = SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($user_group_sid);
     foreach ($extra_details as $key => $extra_detail) {
         if ($extra_detail['type'] == 'monetary' || $extra_detail['type'] == 'complex') {
             $extra_details[$key]['is_system'] = false;
         } else {
             $extra_details[$key]['is_system'] = true;
         }
     }
     $details = array_merge($details, $extra_details);
     if (SJB_PluginManager::isPluginActive('CaptchaPlugin') && SJB_System::getSettingByName('registrationCaptcha') == 1 && SJB_System::getURI() == '/registration/') {
         $details_captcha = array(array('id' => 'captcha', 'caption' => 'Enter code from image', 'type' => 'captcha', 'length' => '20', 'is_required' => true, 'is_system' => false));
         $details = array_merge($details, $details_captcha);
     }
     return $details;
 }
Пример #2
0
 public static function getDetails($listing_type_sid, $pageID = 0)
 {
     $system_details = array(array('id' => 'featured', 'caption' => 'Featured', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => null), array('id' => 'priority', 'caption' => 'Priority Listing', 'type' => 'boolean', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => null));
     $listing_field_manager = new SJB_ListingFieldManager();
     $common_details = $listing_field_manager->getCommonListingFieldsInfo($pageID);
     $extra_details = $listing_field_manager->getListingFieldsInfoByListingType($listing_type_sid, $pageID);
     $details = array_merge($common_details, $extra_details);
     foreach ($details as $key => $detail) {
         $details[$key]['is_system'] = true;
         if ($detail['type'] == 'complex' || $detail['id'] == 'ApplicationSettings') {
             $details[$key]['is_system'] = false;
         } elseif ($detail['id'] == 'access_type') {
             $details[$key]['is_system'] = true;
             $details[$key]['list_values'] = array(array('id' => 'everyone', 'caption' => 'Everyone'), array('id' => 'no_one', 'caption' => 'No one'), array('id' => 'only', 'caption' => 'Only selected employers'), array('id' => 'except', 'caption' => 'Everyone except selected employers'));
         }
     }
     $details = array_merge($system_details, $details);
     $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageID, $listing_type_sid);
     if ($isPageLast) {
         $status_details = array(array('id' => 'status', 'caption' => 'Approve Status', 'type' => 'list', 'list_values' => array(array('id' => 'pending', 'caption' => 'Pending'), array('id' => 'approved', 'caption' => 'Approved'), array('id' => 'rejected', 'caption' => 'Rejected')), 'is_required' => false, 'is_system' => true, 'order' => 1000000));
         $details = array_merge($details, $status_details);
         $rejectReasonDetails = array(array('id' => 'reject_reason', 'caption' => 'Reject Reason', 'type' => 'text', 'is_required' => false, 'is_system' => true, 'order' => 1000000));
         $details = array_merge($details, $rejectReasonDetails);
         if (SJB_PluginManager::isPluginActive('CaptchaPlugin') && SJB_System::getSettingByName('postJobCaptcha') && strpos(SJB_System::getURI(), '/add-listing/') === 0) {
             $details_captcha = array(array('id' => 'captcha', 'caption' => 'Enter code from image', 'type' => 'captcha', 'length' => '20', 'is_required' => true, 'is_system' => true, 'order' => 10000000));
             $details = array_merge($details, $details_captcha);
         }
     }
     return $details;
 }
Пример #3
0
 /**
  * @return bool
  */
 private function isCaptchaEnable()
 {
     $isCaptcha = false;
     if (SJB_PluginManager::isPluginActive('CaptchaPlugin') && SJB_Session::getValue('CURRENT_THEME') != 'mobile') {
         $userType = SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') != SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE') ? 'user' : 'admin';
         $captchaSettingName = '';
         if (!($currentFunction = SJB_Request::getVar('currentFunction'))) {
             $currentFunction = SJB_Array::get(SJB_System::getModuleManager()->getCurrentFunction(), 1);
         }
         switch ($currentFunction) {
             case 'apply_now':
                 $captchaSettingName = 'contactUserCaptcha';
                 break;
             case 'flag_listing':
                 $captchaSettingName = 'flagListingCaptcha';
                 break;
             case 'tell_friend':
                 $captchaSettingName = 'tellFriendCaptcha';
                 break;
             case 'contact_form':
                 $captchaSettingName = 'contactUsCaptcha';
                 break;
             default:
                 if (SJB_System::getSettingByName('captcha_max_allowed_auth_attempts') != 0) {
                     if (SJB_Session::getValue($userType . 'LoginCounter') >= SJB_System::getSettingByName('captcha_max_allowed_auth_attempts')) {
                         $isCaptcha = true;
                         if (SJB_Session::getValue($userType . 'LoginCounter') == SJB_System::getSettingByName('captcha_max_allowed_auth_attempts')) {
                             SJB_Session::setValue($userType . 'LoginCounter', SJB_Session::getValue($userType . 'LoginCounter') + 1);
                             $this->isNotValidate = true;
                         }
                     }
                 }
         }
         if (!$isCaptcha) {
             $isCaptcha = SJB_System::getSettingByName($captchaSettingName) == 1;
         }
     }
     return $isCaptcha;
 }
Пример #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']);
 }