Пример #1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action');
     $api = SJB_Request::getVar('api', false);
     $request = $_REQUEST;
     unset($request['action']);
     switch ($action) {
         case 'header':
             $test = $tp->fetch("header.tpl");
             echo $test;
             exit;
             break;
         case 'simplyHired':
             SJB_Statistics::addStatistics('partneringSites');
             break;
         default:
             $isIPhone = false;
             if (class_exists('MobilePlugin')) {
                 $isIPhone = MobilePlugin::isPhone();
             }
             $url = SJB_Request::getVar('url');
             $url = $url ? base64_decode($url) : '';
             if (str_replace('www.', '', $_SERVER['HTTP_HOST']) === SJB_Settings::getValue('mobile_url') || SJB_Settings::getValue('detect_iphone') && $isIPhone) {
                 $url = str_replace('viewjob', 'm/viewjob', $url);
             }
             SJB_Statistics::addStatistics('partneringSites');
             if ($api && $api == 'indeed') {
                 SJB_HelperFunctions::redirect($url);
             }
             $tp->assign('url', $url);
             $tp->display("partnersite.tpl");
             break;
     }
 }
Пример #2
0
 public function execute()
 {
     if (!SJB_Settings::getValue('cookieLaw')) {
         return;
     }
     $template = SJB_Request::getVar('template', 'cookie_preferences.tpl');
     $tp = SJB_System::getTemplateProcessor();
     $mobileTheme = false;
     if (class_exists('MobilePlugin') && MobilePlugin::isMobileThemeOn()) {
         $this->processingMobileVersion($tp);
         $mobileTheme = true;
     }
     $showCookiePreferences = false;
     $cookiePreferences = SJB_Request::getVar('cookiePreferences', false, 'COOKIE');
     if (!$cookiePreferences) {
         $showCookiePreferences = true;
         $_COOKIE['cookiePreferences'] = 'Advertising';
         setcookie('cookiePreferences', 'Advertising', time() + 30 * 24 * 3600, '/');
     } else {
         if (($cookiePreferences != 'Advertising' || $mobileTheme) && !SJB_Session::getValue('cookiePreferencesAlreadyShown')) {
             $showCookiePreferences = true;
         }
     }
     $tp->assign('action', SJB_Array::get($this->params, 'action', 'view'));
     $tp->assign('showCookiePreferences', $showCookiePreferences);
     $tp->display($template);
     if (!SJB_Session::getValue('cookiePreferencesAlreadyShown')) {
         SJB_Session::setValue('cookiePreferencesAlreadyShown', true);
     }
 }
Пример #3
0
 public static function getListingsFromBeyond($params)
 {
     $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
     if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
         $limit = SJB_Settings::getSettingByName('countBeyondListings');
         $start = $limit * ($params->listing_search_structure['current_page'] - 1) + 1;
         if ($limit) {
             // SET PARAMS FOR REQUEST
             $criteria = $params->criteria_saver->criteria;
             $categoryCriteria = isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : '';
             $category = SJB_Settings::getSettingByName('BeyondIndustryList');
             if (!empty($categoryCriteria)) {
                 $categoryFromCriteria = self::getCategory($categoryCriteria);
                 if ($category) {
                     $category = explode('|', $category);
                     $category = array_unique(array_merge($category, $categoryFromCriteria));
                 } else {
                     $category = $categoryFromCriteria;
                 }
                 $category = implode('|', $category);
             }
             $keywords = SJB_Settings::getSettingByName('BeyondKeywords');
             foreach ($criteria as $field) {
                 if (is_array($field)) {
                     foreach ($field as $fieldType => $values) {
                         if ($fieldType === 'multi_like_and') {
                             foreach ($values as $val) {
                                 if ($keywords != '') {
                                     $keywords .= ' AND ';
                                 }
                                 $keywords .= $val;
                             }
                         }
                         if ($fieldType === 'location') {
                             if (isset($values['value']) && !empty($values['value'])) {
                                 if ($keywords != '') {
                                     $keywords .= ' AND ';
                                 }
                                 $keywords .= $values['value'];
                             }
                         }
                         if ($fieldType === 'like') {
                             if ($keywords != '') {
                                 $keywords .= ' AND ';
                             }
                             $keywords .= $values;
                         }
                     }
                 }
             }
             if (isset($criteria['keywords']) && !empty($criteria['keywords'])) {
                 foreach ($criteria['keywords'] as $key => $item) {
                     if (in_array($key, array('exact_phrase', 'any_words', 'all_words', 'like'))) {
                         if (!empty($keywords)) {
                             $keywords .= ' OR ';
                         }
                         $keywords .= $item;
                     }
                 }
             }
             if (substr($keywords, -4) == ' OR ') {
                 $keywords = substr($keywords, 0, strlen($keywords) - 4);
             }
             $keywords = trim($keywords);
             $keywords = urlencode($keywords);
             $keywords = !empty($keywords) ? "({$keywords})" : '';
             $city = '';
             if (!empty($criteria['Location_City']['like'])) {
                 $city = urlencode($criteria['Location_City']['like']);
             } else {
                 if (!empty($criteria['Location_City']['multi_like_and'][0])) {
                     $city = urlencode($criteria['Location_City']['multi_like_and'][0]);
                 } else {
                     if (!empty($criteria['Location']['location']['value'])) {
                         $city = urlencode($criteria['Location']['location']['value']);
                     }
                 }
             }
             $state = SJB_Settings::getSettingByName('BeyondState');
             if (isset($criteria['Location_State']['multi_like'])) {
                 foreach ($criteria['Location_State']['multi_like'] as $stateSID) {
                     if (!empty($stateSID)) {
                         $stateInfo = SJB_StatesManager::getStateInfoBySID($stateSID);
                         $state = !empty($stateInfo['state_code']) ? $stateInfo['state_code'] : '';
                     }
                 }
             }
             $countryCriteria = isset($criteria['Location_Country']['multi_like'][0]) ? $criteria['Location_Country']['multi_like'][0] : SJB_Settings::getSettingByName('BeyondCountry');
             $country = SJB_Settings::getSettingByName('BeyondCountry');
             if ($countryCriteria && is_numeric($countryCriteria)) {
                 $countryInfo = SJB_CountriesManager::getCountryInfoBySID($countryCriteria);
                 $country = !empty($countryInfo['country_code']) ? $countryInfo['country_code'] : '';
             }
             $employmentTypeCriteria = isset($criteria['EmploymentType']['multi_like']) ? $criteria['EmploymentType']['multi_like'] : '';
             $employmentType = SJB_Settings::getSettingByName('BeyonEmploymentType');
             if ($employmentTypeCriteria) {
                 $employmentType = self::getEmploymentType($employmentTypeCriteria);
             }
             $zipCode = SJB_Settings::getSettingByName('BeyondZipcode');
             if (isset($criteria['Location_ZipCode']['geo']['location']) && !empty($criteria['Location_ZipCode']['geo']['location'])) {
                 $zipCode = $criteria['Location_ZipCode']['geo']['location'];
             }
             $educationLevel = SJB_Settings::getSettingByName('BeyonEducationLevel');
             $experienceLevel = SJB_Settings::getSettingByName('BeyonExperienceLevel');
             $affID = SJB_Settings::getSettingByName('BeyondAffiliateID');
             $isIPhone = false;
             if (class_exists('MobilePlugin')) {
                 $isIPhone = MobilePlugin::isPhone();
             }
             if (str_replace('www.', '', $_SERVER['HTTP_HOST']) === SJB_Settings::getValue('mobile_url') || SJB_Settings::getValue('detect_iphone') && $isIPhone) {
                 $mobileAffID = SJB_Settings::getSettingByName('MobileBeyondAffiliateID');
                 $affID = $mobileAffID ? $mobileAffID : $affID;
             }
             $url = "http://www.beyond.com/common/services/job/search/default.asp?aff={$affID}&kw={$keywords}&kt=3&il={$category}&ct={$country}&st={$state}&zc={$zipCode}&el={$educationLevel}&et={$employmentType}&ex={$experienceLevel}&nw=e&pn={$start}&mx={$limit}&fwhere={$city}";
             $ch = curl_init();
             // set URL and other appropriate options
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             // grab URL and pass it to the browser
             $xml = curl_exec($ch);
             // close cURL resource, and free up system resources
             curl_close($ch);
             $beyondListings = array();
             if ($xml !== false) {
                 $doc = new DOMDocument();
                 $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
                 $results = $doc->getElementsByTagName('Item');
                 if ($results instanceof DOMNodeList) {
                     // if we need just total results number
                     foreach ($results as $node) {
                         $resultXML = simplexml_import_dom($node);
                         $jobKey = (string) $resultXML->SourceInformationID;
                         $location = explode(',', (string) $resultXML->Location);
                         $state = '';
                         $stateCode = '';
                         $country = '';
                         $city = !empty($location[0]) ? $location[0] : '';
                         if (isset($location[1])) {
                             $location = explode(' ', trim($location[1]));
                             if (!empty($location[0])) {
                                 $stateCode = trim($location[0]);
                                 $state = self::getState($stateCode);
                             }
                             if (!empty($location[1])) {
                                 $country = self::getCountry(trim($location[1]));
                             }
                         }
                         $beyondListings[$jobKey] = array('Title' => (string) $resultXML->Title, 'CompanyName' => (string) $resultXML->CompanyName, 'JobDescription' => (string) $resultXML->ShortDescription, 'JobCategory' => (string) $resultXML->CareerFocus, 'State' => $state, 'Country' => $country, 'City' => $city, 'Location' => array('Country' => $country, 'State' => $state, 'State_Code' => $stateCode, 'City' => $city), 'url' => SJB_System::getSystemSettings('SITE_URL') . '/partnersite/?url=' . base64_encode((string) $resultXML->ApplyURL), 'jobkey' => $jobKey, 'activation_date' => (string) $resultXML->Modified, 'api' => 'beyond', 'code' => '<span id=beyond_at><a href="http://www.beyond.com/">jobs</a> by <a href="http://www.beyond.com/" title="Job Search"><img src="' . SJB_System::getSystemSettings('SITE_URL') . '/system/plugins/beyond_integration_plugin/logo.png" style="border: 0; vertical-align: middle;" alt="Beyond job search"></a></span>');
                     }
                 } else {
                     SJB_Logger::error('CANT GET BEYOND XML RESULTS');
                 }
             } else {
                 SJB_Logger::error('NOT VALID RESPONSE FROM BEYOND');
             }
             self::$beyondListings = $beyondListings;
         }
     }
     return $params;
 }
Пример #4
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $registration_form_template = 'registration_form.tpl';
     if (SJB_Authorization::isUserLoggedIn()) {
         $tp->display('already_logged_in.tpl');
         return;
     }
     $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check'));
     $user_group_id = SJB_Request::getVar('user_group_id', null);
     if (!is_null($user_group_id)) {
         $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id);
         if (empty($user_group_sid)) {
             $errors['NO_SUCH_USER_GROUP_IN_THE_SYSTEM'] = 1;
         }
     }
     $this->setSessionValueForRedirectAfterRegister();
     if (!is_null($user_group_id) && empty($errors)) {
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
         if (SJB_Request::isAjax() || 'true' == SJB_Request::getVar('isajaxrequest')) {
             $field = SJB_Request::getVar('type');
             if ('email' == $field) {
                 $user->getProperty($field)->type->disableEmailConfirmation();
             }
             echo $user->getProperty($field)->isValid();
             exit;
         }
         $user->deleteProperty('active');
         $user->deleteProperty('featured');
         $form_submitted = SJB_Request::getVar('action', false) == 'register';
         if (class_exists('MobilePlugin') && MobilePlugin::isMobileThemeOn()) {
             $user->prepareRegistrationFields();
         }
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) {
             $email = $user->getPropertyValue('email');
             if (is_array($email)) {
                 $email = $email['original'];
             }
             $user->setPropertyValue('username', $email);
         }
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             $user->deleteProperty('captcha');
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid);
             SJB_UserManager::saveUser($user);
             SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID());
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             // >>> SJB-1197
             // needs to check session for ajax-uploaded files, and set it to user profile
             $formToken = SJB_Request::getVar('form_token');
             $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
             if (!empty($formToken)) {
                 $tmpUploadedFields = SJB_Array::getPath($tmpUploadsStorage, $formToken);
                 if (!is_null($tmpUploadsStorage) && is_array($tmpUploadedFields)) {
                     // prepare user profile fields array
                     $userProfileFieldsInfo = SJB_UserProfileFieldManager::getAllFieldsInfo();
                     $userProfileFields = array();
                     foreach ($userProfileFieldsInfo as $field) {
                         $userProfileFields[$field['id']] = $field;
                     }
                     // look for temporary values
                     foreach ($tmpUploadedFields as $fieldId => $fieldInfo) {
                         // check field ID for valid ID in user profile fields
                         if (!array_key_exists($fieldId, $userProfileFields) || empty($fieldInfo)) {
                             continue;
                         }
                         $fieldType = $userProfileFields[$fieldId]['type'];
                         $profilePropertyId = $fieldId . '_' . $user->getSID();
                         switch (strtolower($fieldType)) {
                             case 'video':
                             case 'file':
                                 // change temporary file ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             case 'logo':
                                 // change temporary file ID and thumb ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId . '_thumb', $fieldInfo['file_id'] . '_thumb');
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             default:
                                 break;
                         }
                         $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}/{$fieldId}");
                     }
                     // save user with new values
                     SJB_UserManager::saveUser($user);
                     // clean temporary storage
                     $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}");
                     // CLEAR TEMPORARY SESSION STORAGE
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
             }
             // <<< SJB-1197
             // notifying administrator
             SJB_AdminNotifications::sendAdminUserRegistrationLetter($user);
             // Activation
             $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid);
             $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid);
             if ($isApproveByAdmin) {
                 SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
             }
             if ($isSendActivationEmail) {
                 $fromAnonymousShoppingCart = SJB_Session::getValue('fromAnonymousShoppingCart');
                 SJB_Session::unsetValue('fromAnonymousShoppingCart');
                 $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID(), $fromAnonymousShoppingCart ? true : false);
                 if ($isSent) {
                     $registration_form_template = 'registration_confirm.tpl';
                 } else {
                     SJB_FlashMessages::getInstance()->addWarning('ERROR_SEND_ACTIVATION_EMAIL');
                     $registration_form_template = 'registration_failed_to_send_activation_email.tpl';
                 }
             } else {
                 if (!$isSendActivationEmail && $isApproveByAdmin) {
                     SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
                     $registration_form_template = 'registration_pending.tpl';
                 } else {
                     SJB_UserManager::activateUserByUserName($user->getUserName());
                     if (!SJB_SocialPlugin::getProfileSocialID($user->getSID())) {
                         SJB_Notifications::sendUserWelcomeLetter($user->getSID());
                     }
                     SJB_Authorization::login($user->getUserName(), $_REQUEST['password']['original'], false, $errors);
                     $proceedToPosting = SJB_Session::getValue('proceed_to_posting');
                     if ($proceedToPosting) {
                         $redirectUrl = SJB_HelperFunctions::getSiteUrl() . '/add-listing/?listing_type_id=' . SJB_Session::getValue('listing_type_id') . '&proceed_to_posting=' . $proceedToPosting . '&productSID=' . SJB_Session::getValue('productSID');
                     } else {
                         $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : '';
                         $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                     }
                     SJB_HelperFunctions::redirect($redirectUrl);
                 }
             }
         } else {
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             $registration_form->registerTags($tp);
             $registration_form_template = 'registration_form.tpl';
             if (isset($_REQUEST['reg_form_template'])) {
                 $registration_form_template = $_REQUEST['reg_form_template'];
             } elseif (!empty($user_group_info['reg_form_template'])) {
                 $registration_form_template = $user_group_info['reg_form_template'];
             }
             $form_fields = $registration_form->getFormFieldsInfo();
             // define default template with ajax checking
             $registration_form->setDefaultTemplateByFieldName('email', 'email_ajaxchecking.tpl');
             $registration_form->setDefaultTemplateByFieldName('username', 'unique_string.tpl');
             // use specific template for user profile video
             $registration_form->setDefaultTemplateByFieldName('video', 'video_profile.tpl');
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $tp->assign('user_group_info', $user_group_info);
             $tp->assign('errors', $errors);
             $tp->assign('form_fields', $form_fields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         }
     } else {
         $registration_form_template = 'registration_choose_user_group.tpl';
         $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo();
         $tp->assign('user_groups_info', $user_groups_info);
     }
     $tp->assign('userTree', true);
     $tp->assign('errors', $errors);
     $tp->display($registration_form_template);
 }