private function processingMobileVersion($tp) { if (!SJB_Session::getValue('cookiePreferencesAlreadyShown')) { $_COOKIE['cookiePreferences'] = 'Advertising'; setcookie('cookiePreferences', 'Advertising', time() + 30 * 24 * 3600, '/'); } $refererUri = SJB_Request::getVar('HTTP_REFERER', null, 'SERVER'); if ($refererUri) { $refererUri = parse_url($refererUri); } if ($refererUri && SJB_System::getURI() != '/' . basename($refererUri['path']) . '/') { SJB_Session::setValue('cookiePreferencesMobileReferer', SJB_Request::getVar('HTTP_REFERER', SJB_System::getSystemSettings('SITE_URL'), 'SERVER')); } if (SJB_Request::getVar('cookiePreferencesSave', false, 'POST')) { if (!SJB_Request::getVar('Functional', false, 'POST')) { $_COOKIE['cookiePreferences'] = 'System'; setcookie('cookiePreferences', 'System', time() + 30 * 24 * 3600, '/'); } else { if (!SJB_Request::getVar('Advertising', false, 'POST')) { $_COOKIE['cookiePreferences'] = 'Functional'; setcookie('cookiePreferences', 'Functional', time() + 30 * 24 * 3600, '/'); } else { $_COOKIE['cookiePreferences'] = 'Advertising'; setcookie('cookiePreferences', 'Advertising', time() + 30 * 24 * 3600, '/'); } } } $tp->assign('mobileVersion', true); }
/** * checking for existing authorized administrator * Function checks if administrator has authorized * @return 'true' if administrator has authorized or 'false' otherwise */ public static function admin_authed() { if (!is_null(SJB_Session::getValue('username')) && !is_null(SJB_Session::getValue('usertype')) && SJB_Session::getValue('usertype') == "subadmin") { return self::setAdminInfo(SJB_Session::getValue('username')); } return false; }
public function execute() { if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_allowPeopleSearch')) { $liSearch = SJB_Request::getVar('li_search', false); $oLinkedin = SJB_SocialPlugin::getActiveSocialPlugin(); if ('Resume' == $_REQUEST['listing_type']['equal'] && $liSearch && $oLinkedin instanceof LinkedinSocialPlugin) { SJB_Session::setValue('linkedinPeopleSearch', true); $request =& $_REQUEST; /* * keywords=[space delimited keywords] * sort=[connections|recommenders|distance|relevance] * postal-code=[postal code] * start=[number]& count=[1-25]& facet=[facet code, values]& facets=[facet * * info: * http://developer.linkedin.com/docs/DOC-1191 */ $sKeywords = ''; $sZip = !empty($request['ZipCode']['geo']['location']) ? $request['ZipCode']['geo']['location'] : ''; $aIndustry = !empty($request['JobCategory']['multi_like']) ? $request['JobCategory']['multi_like'] : array(); $sIndustry = ''; $sCount = !empty($request['count']) ? (int) $request['count'] : 10; if (!empty($request['keywords']) && is_array($request['keywords'])) { foreach ($request['keywords'] as $keywords) { $sKeywords = $keywords; } } $aFields = array('keywords' => $sKeywords, 'postal-code' => $sZip, 'count' => $sCount); foreach ($aIndustry as $industryName) { if ($industryKey = SJB_LinkedinFields::getIndustryCodeByIndustryName($industryName)) { $sIndustry .= ',' . $industryKey; } } if (!empty($sIndustry)) { $aFields['facets'] = 'industry'; $aFields['facet'] = 'industry' . $sIndustry; } $liResults = $oLinkedin->peopleSearch($aFields); if (isset($liResults->{'num-results'}) && (int) $liResults->{'num-results'} >= 0) { $tp = SJB_System::getTemplateProcessor(); if (empty($sKeywords)) { $tp->assign('liKeywordEmpty', true); } $tp->assign('liResults', $oLinkedin->preparePeopleStructure($liResults)); $tp->assign('liNumResults', (int) $liResults->{'num-results'}); $tp->assign('linkedinSearchIsAllowed', true); $linkedinPeopleSearch = SJB_Session::getValue('linkedinPeopleSearch'); $tp->assign('linkedinSearch', !empty($linkedinPeopleSearch) && 'no' === $linkedinPeopleSearch && !empty($_GET['searchId']) ? 'notChecked' : 'no'); $tp->display('linkedin_people_search_results.tpl'); } } else { SJB_Session::setValue('linkedinPeopleSearch', 'no'); } } }
public static function getProductsInfoAlreadyCheckedForGuest() { $serializedProductsInfo = SJB_Session::getValue('products'); $alreadyCheckedProducts = array(); if (is_array($serializedProductsInfo)) { foreach ($serializedProductsInfo as $serializedInfo) { array_push($alreadyCheckedProducts, unserialize($serializedInfo['product_info'])); } } return $alreadyCheckedProducts; }
public function execute() { $action = SJB_Request::getVar('action'); $sessionUpdateData = SJB_Session::getValue(self::SESSION_UPDATE_TAG); if ($action == 'mark_as_closed') { if (is_array($sessionUpdateData)) { $sessionUpdateData['closed_by_user'] = true; SJB_Session::setValue(self::SESSION_UPDATE_TAG, $sessionUpdateData); } exit; } // check updates $serverUrl = SJB_System::getSystemSettings('SJB_UPDATE_SERVER_URL'); $version = SJB_System::getSystemSettings('version'); // CHECK FOR UPDATES $updateInfo = SJB_Session::getValue(self::SESSION_UPDATE_TAG); if (empty($updateInfo)) { // check URL for accessibility $ch = curl_init($serverUrl); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); $urlInfo = curl_getinfo($ch); $availableVersion = array(); $updateStatus = ''; if ($urlInfo['http_code'] > 0) { // OK. Url is accessible - lets get update info try { $client = new Zend_Rest_Client($serverUrl); $result = $client->isUpdateAvailable($version['major'], $version['minor'], $version['build'], SJB_System::getSystemSettings('USER_SITE_URL'))->get(); if ($result->isSuccess()) { $updateStatus = (string) $result->updateStatus; switch ($updateStatus) { case 'available': $availableVersion = array('major' => (string) $result->version->major, 'minor' => (string) $result->version->minor, 'build' => (string) $result->version->build); break; } } } catch (Exception $e) { SJB_Error::writeToLog('Update Check: ' . $e->getMessage()); } } $updateInfo = array('availableVersion' => $availableVersion, 'updateStatus' => $updateStatus); SJB_Session::setValue(self::SESSION_UPDATE_TAG, $updateInfo); } else { if (isset($updateInfo['availableVersion']) && !empty($updateInfo['availableVersion'])) { if ($updateInfo['availableVersion']['build'] <= $version['build']) { $updateInfo = array('availableVersion' => $updateInfo['availableVersion'], 'updateStatus' => 'none'); } } } echo json_encode($updateInfo); exit; }
function isValid() { $property_info = $this->property_info; $property_info['type'] = 'kCaptcha'; SJB_Event::dispatch('captchaValidation', $property_info, true); if ($property_info['type'] == 'kCaptcha') { $this->captchaImg = SJB_Session::getValue('captcha_keystring'); if ($this->captchaImg != $this->property_info['value']) { return 'NOT_VALID'; } } else { if ($property_info === false) { return 'NOT_VALID'; } } return true; }
public function getAccessToken($feedSID = null, $action = null, &$errors) { SJB_Session::setValue('twitterFeed', serialize($_REQUEST)); if ($feedSID != null) { $feedInfo = SJB_SocialMedia::getFeedInfoByNetworkIdAndSID(self::NETWORK_ID, $feedSID); } if ($action != 'grant') { $feedInfo['consumerKey'] = SJB_Request::getVar('consumerKey'); $feedInfo['consumerSecret'] = SJB_Request::getVar('consumerSecret'); $feedInfo['account_id'] = SJB_Request::getVar('account_id'); } $config = array('callbackUrl' => self::getCallBackUrl($feedSID, $action, SJB_Request::getVar('submit')), 'siteUrl' => 'http://twitter.com/oauth', 'consumerKey' => $feedInfo['consumerKey'], 'consumerSecret' => $feedInfo['consumerSecret'], 'requestTokenUrl' => 'https://api.twitter.com/oauth/request_token', 'userAuthorizationUrl' => 'https://api.twitter.com/oauth/authorize', 'accessTokenUrl' => 'https://api.twitter.com/oauth/access_token'); $consumer = new Zend_Oauth_Consumer($config); $client = new Zend_Http_Client(); $client->setConfig(array('sslcert' => 'cacert.pem')); $consumer->setHttpClient($client); $sessionTwitterRequestToken = SJB_Session::getValue('TWITTER_REQUEST_TOKEN'); if (SJB_Request::getVar('process_token', false) && !is_null($sessionTwitterRequestToken)) { $accessToken = $consumer->getAccessToken($_GET, unserialize($sessionTwitterRequestToken)); $feedInfo['access_token'] = $accessToken; $twitter = self::getZendServiceTwitter($feedInfo, $accessToken); $response = $twitter->account->accountVerifyCredentials()->toValue(); if (!empty($response->screen_name) && strtolower($response->screen_name) == strtolower($feedInfo['account_id'])) { return $accessToken; } else { $errors[] = 'Twitter account verification failed'; return false; } } else { if ($requestToken = $consumer->getRequestToken()) { SJB_Session::setValue('TWITTER_REQUEST_TOKEN', serialize($requestToken)); $consumer->redirect(); } else { $errors[] = 'Could not retrieve a valid Token. Please check "Consumer Key" and "Consumer secret"'; return false; } } }
public static function getCurrentUserInfo() { $currentUser = SJB_Session::getValue('current_user'); if (!empty($currentUser)) { return $currentUser; } if (isset($_COOKIE['session_key'])) { $user_sid = SJB_UserManager::getUserSIDBySessionKey($_COOKIE['session_key']); if (!empty($user_sid)) { $userInfo = SJB_UserManager::getUserInfoBySID($user_sid); if (!empty($userInfo['parent_sid'])) { $subuserInfo = $userInfo; $userInfo = SJB_UserManager::getUserInfoBySID($userInfo['parent_sid']); $userInfo['subuser'] = $subuserInfo; } SJB_Session::setValue('current_user', $userInfo); SJB_Authorization::setKeepCookieForUser($_COOKIE['session_key']); return $userInfo; } } return null; }
public static function getRefineSearchBlock() { $tp = SJB_System::getTemplateProcessor(); $listingTypeId = SJB_Request::getVar('listing_type'); if (!isset($listingTypeId['equal'])) { $_REQUEST['listing_type']['equal'] = SJB_Session::getValue('listing_type_id'); } $searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listingTypeId['equal']); $searchCriteria = $searchResultsTP->getCriteriaSaver()->getCriteria(); if (SJB_Request::getVar('showRefineFields', false)) { $refineFields = SJB_RefineSearch::getRefineFieldsByCriteria($searchResultsTP, $searchCriteria); $tp->assign('refineFields', $refineFields); } $currentSearch = SJB_RefineSearch::getCurrentSearchByCriteria($searchCriteria); $tp->assign('currentSearch', $currentSearch); $tp->assign('searchId', SJB_Request::getVar('searchId')); $tp->assign('view', SJB_Request::getVar('view')); $tp->display('../classifieds/search_results_refine_block.tpl'); }
protected static function cleanCurrrentSessionData($network) { $sessionSN = SJB_Session::getValue('sn'); if (!empty($sessionSN['authorized']) && $sessionSN['network'] == $network) { SJB_Session::unsetValue('sn'); } }
public function execute() { $formToken = SJB_Request::getVar('form_token'); $tp = SJB_System::getTemplateProcessor(); $tp->assign('form_token', $formToken); $post_max_size_orig = ini_get('post_max_size'); $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null; // get post_max_size in bytes $val = trim($post_max_size_orig); $tmp = substr($val, strlen($val) - 1); $tmp = strtolower($tmp); switch ($tmp) { case 'g': $val *= 1024; break; case 'm': $val *= 1024; break; case 'k': $val *= 1024; break; } $post_max_size = $val; $errors = array(); if (SJB_Request::getVar('from-preview', false, 'POST') && !SJB_Request::getVar('action_add', false, 'POST')) { $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int'); $previewListingId = SJB_Session::getValue('preview_listing_sid'); if ($previewListingId && SJB_ListingManager::isListingExists($previewListingId)) { $listingId = $previewListingId; } } else { $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int'); } $template = SJB_Request::getVar('edit_template', 'edit_listing.tpl'); $filename = SJB_Request::getVar('filename', false); if ($filename) { SJB_UploadFileManager::openFile($filename, $listingId); // if file not found - set error here $errors['NO_SUCH_FILE'] = true; } if (empty($_POST) && $server_content_length > $post_max_size) { $errors['MAX_FILE_SIZE_EXCEEDED'] = 1; $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int'); $tp->assign('post_max_size', $post_max_size_orig); } $current_user = SJB_UserManager::getCurrentUser(); $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); // for listing preview $formSubmittedFromPreview = false; if (empty($listingInfo)) { $listingId = SJB_Session::getValue('preview_listing_sid'); $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); if (!empty($listingInfo)) { // if on preview page 'POST' button was pressed $formSubmittedFromPreview = SJB_Request::getVar('action_add', false, 'POST') && SJB_Request::getVar('from-preview', false, 'POST'); if ($formSubmittedFromPreview) { $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']); $properties = $listing->getProperties(); foreach ($properties as $fieldID => $property) { switch ($property->getType()) { case 'date': if (!empty($listingInfo[$fieldID])) { $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]); } break; case 'complex': $complex = $property->type->complex; $complexProperties = $complex->getProperties(); foreach ($complexProperties as $complexfieldID => $complexProperty) { if ($complexProperty->getType() == 'date') { $values = $complexProperty->getValue(); foreach ($values as $index => $value) { if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) { $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]); } } } } break; } } } } else { $listingId = null; SJB_Session::unsetValue('preview_listing_sid'); } } // if preview button was pressed $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST'); if (SJB_UserManager::isUserLoggedIn()) { if ($listingInfo['user_sid'] != $current_user->getID()) { $errors['NOT_OWNER_OF_LISTING'] = $listingId; } elseif (!is_null($listingInfo)) { $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingInfo['listing_type_sid']); $form_is_submitted = SJB_Request::getVar('action', '') == 'save_info' || SJB_Request::getVar('action', '') == 'add' || $isPreviewListingRequested || $formSubmittedFromPreview; if (!$form_is_submitted && !SJB_Request::getVar('from-preview', false, 'POST')) { SJB_Session::unsetValue('previewListingId'); SJB_Session::unsetValue('preview_listing_sid_or'); } // fill listing from an array of social data if allowed $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']); $listingTypeID = $listing_type_info['id']; $aAutoFillData = array('formSubmitted' => $form_is_submitted, 'listingTypeID' => $listingTypeID); SJB_Event::dispatch('SocialSynchronization', $aAutoFillData); $listingInfo = array_merge($listingInfo, $_REQUEST); $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']); $listing->deleteProperty('ListingLogo'); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('status'); $list_emp_ids = SJB_Request::getVar('list_emp_ids'); $listing->setSID($listingId); $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($current_user->getSID()); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) { $value = SJB_Request::getVar('screening_questionnaire'); $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : ''; $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($current_user->getSID()), 'is_system' => true)); } else { $listing->deleteProperty('screening_questionnaire'); } //--->CLT-2637 $properties = $listing->getProperties(); $listing_fields_by_page = array(); foreach ($pages as $page) { $listing_fields_by_page = array_merge(SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']), $listing_fields_by_page); } foreach ($properties as $property) { if (!in_array($property->getID(), array_keys($listing_fields_by_page))) { $listing->deleteProperty($property->getID()); } } //--->CLT-2637 // if user is not registered using linkedin , delete linkedin sync property, also if sync is turned off in admin part $aAutoFillData = array('oListing' => &$listing, 'userSID' => $current_user->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo); SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData); $listing_edit_form = new SJB_Form($listing); $listing_edit_form->registerTags($tp); $extraInfo = $listingInfo['product_info']; if ($extraInfo) { $extraInfo = unserialize($extraInfo); $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $listingSidForPictures = SJB_Session::getValue('preview_listing_sid_or') ? SJB_Session::getValue('preview_listing_sid_or') : $listingId; $tp->assign('pic_limit', $numberOfPictures); $tp->assign('listingSidForPictures', $listingSidForPictures); } if ($form_is_submitted) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true)); } $field_errors = array(); if ($form_is_submitted && ($formSubmittedFromPreview || $listing_edit_form->isDataValid($field_errors))) { $or_listing_id = SJB_Session::getValue('preview_listing_sid_or'); /* preview listing */ if ($isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') != $listing->getSID()) { SJB_Session::setValue('preview_listing_sid_or', $listing->getSID()); $listing->setSID(null); } elseif (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listing->getSID() && $or_listing_id && $or_listing_id != $listingId) { $listing->setSID($or_listing_id); } if ($isPreviewListingRequested) { $listing->addProperty(array('id' => 'preview', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } else { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } if ($isPreviewListingRequested) { $listing->product_info = $extraInfo; if (SJB_Session::getValue('previewListingId')) { $listing->setSID(SJB_Session::getValue('previewListingId')); } } else { SJB_BrowseDBManager::deleteListings($listing->getID()); } $listingSidsForCopy = array('filesFrom' => $listingId, 'picturesFrom' => $isPreviewListingRequested && (!$or_listing_id || $or_listing_id === $listingId) ? $listingId : null); SJB_ListingManager::saveListing($listing, $listingSidsForCopy); if (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listingId && $or_listing_id && $or_listing_id != $listingId) { SJB_Session::unsetValue('preview_listing_sid'); SJB_ListingManager::deleteListingBySID($listingId); } $listingInfo = SJB_ListingManager::getListingInfoBySID($listing->getSID()); if ($listingInfo['active']) { SJB_ListingManager::activateListingKeywordsBySID($listing->getSID()); SJB_BrowseDBManager::addListings($listing->getID()); } // >>> SJB-1197 // SET VALUES FROM TEMPORARY SESSION STORAGE $formToken = SJB_Request::getVar('form_token'); $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage'); $tempFieldsData = SJB_Array::getPath($sessionFileStorage, $formToken); if (is_array($tempFieldsData)) { foreach ($tempFieldsData as $fieldId => $fieldData) { $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldData['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } } SJB_ListingManager::saveListing($listing); // recreate form object for saved listing // it fix display of complex file fields $listing = SJB_ListingManager::getObjectBySID($listing->getSID()); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('status'); $listing_edit_form = new SJB_Form($listing); $listing_edit_form->registerTags($tp); } // <<< SJB-1197 if ($isPreviewListingRequested) { SJB_Session::setValue('previewListingId', $listing->getSID()); } /* preview listing */ if ($isPreviewListingRequested) { $listing->setUserSID($current_user->getSID()); SJB_Session::setValue('preview_listing_sid', $listing->getSID()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/'); } else { /* normal */ $listingSid = $listing->getSID(); SJB_Event::dispatch('listingEdited', $listingSid); $tp->assign('display_preview', 1); SJB_Session::unsetValue('preview_listing_sid'); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-' . strtolower($listingTypeID) . '-details/' . $listing->getSID() . '/'); } } $listing->deleteProperty('access_list'); $tp->assign('form_is_submitted', $form_is_submitted); $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing); $form_fields = $listing_edit_form->getFormFieldsInfo(); $listing_fields_by_page = array(); foreach ($pages as $page) { $listing_fields_by_page[$page['page_name']] = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']); foreach (array_keys($listing_fields_by_page[$page['page_name']]) as $field) { if (!$listing->propertyIsSet($field)) { unset($listing_fields_by_page[$page['page_name']][$field]); } } } // delete sync fields from posting pages that are not in array $form_fields $aAutoFillData = array('listing_fields_by_page' => &$listing_fields_by_page, 'pages' => &$pages, 'form_fields' => $form_fields); SJB_Event::dispatch('SocialSynchronizationFieldsOnPostingPages', $aAutoFillData); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); if (!isset($listing_structure['access_type'])) { $listing_structure['access_type'] = 'everyone'; } $listing_access_list = SJB_ListingManager::getListingAccessList($listingId, $listing->getPropertyValue('access_type')); $tp->assign('contract_id', $listingInfo['contract_id']); $tp->assign('extraInfo', $extraInfo); $tp->assign('listing', $listing_structure); $tp->assign('pages', $listing_fields_by_page); $tp->assign('countPages', count($listing_fields_by_page)); $tp->assign('field_errors', $field_errors); $tp->assign('listing_access_list', $listing_access_list); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('expired', SJB_ListingManager::getIfListingHasExpiredBySID($listing->getSID())); // only for Resume listing types $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $current_user->getSID()); SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData); } } else { $errors['NOT_LOGGED_IN'] = 1; } $tp->assign('errors', $errors); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $listingTypeID = SJB_Request::getVar('listing_type_id', null); $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID); $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSID); $productSID = SJB_Request::getVar('product_sid', false); $editUser = SJB_Request::getVar('edit_user', false); $action = SJB_Request::getVar('action', false); $username = SJB_Request::getVar('username', false); $errors = array(); if ($username && ($userSID = SJB_UserManager::getUserSIDbyUsername($username))) { $userInfo = SJB_UserManager::getUserInfoBySID($userSID); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']); if (!$productSID) { $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($userGroupInfo['sid']); foreach ($products as $key => $product) { if (empty($product['listing_type_sid']) || $product['listing_type_sid'] != $listingTypeSID) { unset($products[$key]); } } if ($action == 'productVerify') { $errors['PRODUCT_NOT_SELECTED'] = 1; } $tp->assign('errors', $errors); $tp->assign('username', $username); $tp->assign('products', $products); $tp->assign('edit_user', $editUser); $tp->assign('userSID', $userSID); $tp->assign('userGroupInfo', $userGroupInfo); $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->display('select_product.tpl'); } else { $form_submitted = SJB_Request::getVar('action', '') == 'add'; $tmp_listing_id_from_request = SJB_Request::getVar('listing_id', false, 'default', 'int'); if (!empty($tmp_listing_id_from_request)) { $tmp_listing_sid = $tmp_listing_id_from_request; } elseif (!$tmp_listing_id_from_request) { $tmp_listing_sid = time(); } $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); $extraInfo = is_null($productInfo['serialized_extra_info']) ? null : unserialize($productInfo['serialized_extra_info']); if (!empty($extraInfo)) { $extraInfo['product_sid'] = $productSID; } $_REQUEST['featured'] = !empty($_REQUEST['featured']) ? $_REQUEST['featured'] : $productInfo['featured']; $_REQUEST['priority'] = !empty($_REQUEST['priority']) ? $_REQUEST['priority'] : $productInfo['priority']; $listing = new SJB_Listing($_REQUEST, $listingTypeSID); $properties = $listing->getPropertyList(); foreach ($properties as $property) { $propertyInfo = $listing->getPropertyInfo($property); $propertyInfo['user_sid'] = $userSID; if ($propertyInfo['type'] == 'location') { $child = $listing->getChild($property); $childProperties = $child->getPropertyList(); foreach ($childProperties as $childProperty) { $childPropertyInfo = $child->getPropertyInfo($childProperty); $childPropertyInfo['user_sid'] = $userSID; $child->setPropertyInfo($childProperty, $childPropertyInfo); } } $listing->setPropertyInfo($property, $propertyInfo); } $listing->deleteProperty('status'); $listing->deleteProperty('reject_reason'); $access_type = $listing->getProperty('access_type'); if ($form_submitted) { if (!empty($access_type)) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true)); } } $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($userSID); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) { $issetQuestionnairyField = $listing->getProperty('screening_questionnaire'); if ($issetQuestionnairyField) { $value = SJB_Request::getVar("screening_questionnaire"); $listing_info = $_REQUEST; $value = $value ? $value : isset($listing_info['screening_questionnaire']) ? $listing_info['screening_questionnaire'] : ''; $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($userSID), 'is_system' => true)); } } else { $listing->deleteProperty('screening_questionnaire'); } if ($listing->getProperty('captcha')) { $listing->deleteProperty('captcha'); } $add_listing_form = new SJB_Form($listing); $add_listing_form->registerTags($tp); $field_errors = array(); if ($form_submitted && $add_listing_form->isDataValid($field_errors)) { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); $listing->setUserSID($userSID); $listing->setProductInfo($extraInfo); if (empty($access_type->value)) { $listing->setPropertyValue('access_type', 'everyone'); } SJB_ListingManager::saveListing($listing); SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $_REQUEST['featured'], $_REQUEST['priority'], $userSID); if (isset($_SESSION['tmp_file_storage'])) { foreach ($_SESSION['tmp_file_storage'] as $v) { SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s", $listing->getSID(), $v['picture_saved_name']); SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s", $listing->getSID(), $v['thumb_saved_name']); } SJB_Session::unsetValue('tmp_file_storage'); } $formToken = SJB_Request::getVar('form_token'); $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage'); $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken); if (!empty($uploadedFields)) { foreach ($uploadedFields as $fieldId => $fieldValue) { // get field of listing $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldValue['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } // unset value from session temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}"); } //and remove token key from temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}"); SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage); SJB_ListingManager::saveListing($listing); } SJB_ListingManager::activateListingBySID($listing->getSID()); SJB_ProductsManager::incrementPostingsNumber($productSID); $listingSid = $listing->getSID(); SJB_Event::dispatch('listingSaved', $listingSid); if ($editUser) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-user/?user_sid=" . $userSID); } else { if ($listingTypeID == 'resume' || $listingTypeID == 'job') { $link = "manage-" . strtolower($listingTypeID) . "s"; } else { $link = "manage-" . strtolower($listingTypeID) . "-listings"; } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/{$link}/?action=search&listing_type_sid=" . $listingTypeSID); } } else { $listing->deleteProperty('access_list'); $listing->deleteProperty('contract_id'); $add_listing_form = new SJB_Form($listing); if ($form_submitted) { $add_listing_form->isDataValid($field_errors); } $add_listing_form->registerTags($tp); $form_fields = $add_listing_form->getFormFieldsInfo(); $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID); $formFieldsSorted = array(); $formFieldsSorted['featured'] = $form_fields['featured']; $formFieldsSorted['priority'] = $form_fields['priority']; foreach ($pages as $page) { $listing_fields = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']); foreach (array_keys($listing_fields) as $field) { if ($listing->propertyIsSet($field)) { $formFieldsSorted[$field] = $form_fields[$field]; } } } $form_fields = $formFieldsSorted; //SJB_HelperFunctions::d($form_fields); $employers_list = SJB_Request::getVar('list_emp_ids', false); $employers = array(); if (is_array($employers_list)) { foreach ($employers_list as $emp) { $currEmp = SJB_UserManager::getUserInfoBySID($emp); $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']); } sort($employers); } $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $tp->assign("pic_limit", $numberOfPictures); $tp->assign("listing_id", $tmp_listing_sid); $tp->assign("listing_access_list", $employers); $tp->assign("errors", $field_errors); $tp->assign("form_fields", $form_fields); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields))); } $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->assign('edit_user', $editUser); $tp->assign('productInfo', $productInfo); $tp->assign('username', $username); $tp->assign('product_sid', $productSID); $tp->assign('userSID', $userSID); $tp->assign('userGroupInfo', $userGroupInfo); $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->display('input_form.tpl'); } } else { if ($username && !$userSID) { $errors['USER_NOT_FOUND'] = 1; } elseif ($action == 'userVerify') { $errors['USER_NOT_SELECTED'] = 1; } $tp->assign('errors', $errors); $tp->assign('username', $username); $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->display('select_user.tpl'); } }
public static function getCurrentTheme($accessType = false) { $i18n = SJB_I18N::getInstance(); $i18n->switchLang(); $activeLanguagesData = $i18n->getActiveLanguagesData(); $currentLanguage = $i18n->getCurrentLanguage(); $currentLanguageData = null; foreach ($activeLanguagesData as $activeLanguageData) { if ($activeLanguageData['id'] == $currentLanguage) { $currentLanguageData = $activeLanguageData; } } SJB_System::setGlobalTemplateVariable('languages', $activeLanguagesData); SJB_System::setGlobalTemplateVariable('current_language', $currentLanguage); SJB_System::setGlobalTemplateVariable('current_language_data', $currentLanguageData); $arr = glob(SJB_BASE_DIR . 'system/ext/jquery/datepicker/i18n/jquery.ui.datepicker-*.js'); if (is_array($arr) && !empty($arr)) { $available_datepicker_localizations = array(); foreach ($arr as $item) { $matches = array(); if (!preg_match('/datepicker-([a-zA-Z0-9-]+).js$/', $item, $matches)) { continue; } $available_datepicker_localizations[$matches[1]] = $matches[1]; } SJB_System::setGlobalTemplateVariable('available_datepicker_localizations', $available_datepicker_localizations); } $theme = null; if (SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == 'admin') { if ($accessType === false || $accessType === 'admin') { return SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR') . '/admin'; } } else { if (isset($_GET['theme'])) { $theme = $_GET['theme']; if (strtolower($theme) == 'mobile') { $theme = 'mobile'; } SJB_Session::setValue('theme', $theme); } } if (!ThemeManager::isThemeExists($theme, $accessType)) { $theme = SJB_Session::getValue('theme'); if (empty($theme) || !ThemeManager::isThemeExists($theme, $accessType)) { $theme = SJB_Settings::getSettingByName('CURRENT_THEME'); if (!ThemeManager::isThemeExists($theme, $accessType)) { $theme = SJB_System::getSystemSettings('DEFAULT_THEME'); } } } SJB_Event::dispatch('GetCurrentTheme', $theme, true); SJB_Session::setValue('CURRENT_THEME', $theme); return $theme; }
/** * checking for existing authorized administrator * Function checks if administrator has authorized * @return 'true' if administrator has authorized or 'false' otherwise */ public static function admin_authed() { return !is_null(SJB_Session::getValue('username')) && !is_null(SJB_Session::getValue('usertype')) && SJB_Session::getValue('usertype') == "admin"; }
public static function getRedirectUrlByPageID($pageId) { $error = ''; if (!is_null(SJB_Session::getValue('fromAnonymousShoppingCart'))) { SJB_Session::unsetValue('fromAnonymousShoppingCart'); return SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/?'; } $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/my-account/?'; if (empty($pageId)) { return $redirectUrl; } if ($pageId == 'posting_page') { $user = SJB_UserManager::getCurrentUser(); $userGroupId = SJB_UserGroupManager::getUserGroupIDBySID($user->getUserGroupSID()); $listingTypeSid = SJB_ListingTypeManager::getListingTypeByUserSID($user->getSID()); $listingTypeId = !empty($listingTypeSid) ? SJB_ListingTypeManager::getListingTypeIDBySID(array_pop($listingTypeSid)) : ''; if ($user->hasContract() && SJB_ListingManager::canCurrentUserAddListing($error, $listingTypeId)) { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/add-listing/?listing_type_id=' . $listingTypeId . "&"; } elseif ($user->hasContract()) { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/my-account/?'; } else { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/' . mb_strtolower($userGroupId) . '-products/?postingProductsOnly=1&'; } } return $redirectUrl; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $isAlert = $enableNotify = isset($_REQUEST["alert"]); $tp->assign('is_alert', $isAlert); if (SJB_UserManager::isUserLoggedIn()) { $cu = SJB_UserManager::getCurrentUser(); if ($cu->isSubuser()) { $current_user_info = $cu->getSubuserInfo(); } else { $current_user_info = SJB_UserManager::getCurrentUserInfo(); } $criteria_saver = new SJB_ListingCriteriaSaver(SJB_Request::getVar("searchId", "")); $requested_data = $criteria_saver->getCriteria(); if (isset($requested_data['listing_type'])) { $current_listing_type = array_pop($requested_data['listing_type']); } else { $current_listing_type = ''; if (isset($requested_data['listing_type_sid'])) { $listing_type_sid = array_pop($requested_data['listing_type_sid']); $current_listing_type = SJB_ListingTypeManager::getListingTypeIDBySID($listing_type_sid); } } $errors = array(); if (!$isAlert && !SJB_Acl::getInstance()->isAllowed('save_searches')) { $errors[] = "DENIED_SAVE_JOB_SEARCH"; } elseif ($isAlert && !SJB_Acl::getInstance()->isAllowed('use_' . trim($current_listing_type) . '_alerts')) { $errors[] = "DENIED_SAVE_JOB_SEARCH"; } switch (SJB_Request::getVar("action")) { case 'edit': unset($_GET['action']); if (isset($_GET['id_saved'])) { $id_saved = $_GET['id_saved']; unset($_GET['id_saved']); $errors = array(); SJB_SavedSearches::updateSearchOnDB($_GET, $id_saved, $current_user_info['sid'], 0); if (!empty($errors)) { $tp->assign("errors", $errors); $tp->display("save_search_failed.tpl"); } else { $url = SJB_System::getSystemSettings('SITE_URL') . "/saved-searches/"; if ($isAlert) { $url = SJB_System::getSystemSettings('SITE_URL') . "/job-alerts/"; } $tp->assign("url", $url); $tp->display("save_search_success.tpl"); } } break; case 'save': $search_name = SJB_Request::getVar("search_name"); $errors = array(); $criteria_saver = new SJB_ListingCriteriaSaver(SJB_Request::getVar("searchId", "")); $requested_data = $criteria_saver->getCriteria(); if (is_array($criteria_saver->order_info)) { $requested_data = array_merge($requested_data, $criteria_saver->order_info); } $requested_data['listings_per_page'] = $criteria_saver->listings_per_page; $emailFrequency = SJB_Request::getVar("email_frequency", 'daily'); SJB_SavedSearches::saveSearchOnDB($requested_data, $search_name, $current_user_info['sid'], $enableNotify, $isAlert, $emailFrequency); if (!empty($errors)) { $tp->assign("errors", $errors); $tp->display("save_search_failed.tpl"); } else { if (isset($_REQUEST['url'])) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . $_REQUEST['url'] . "?alert=added"); } $tp->display("save_search_success.tpl"); } break; default: if (!empty($errors)) { $tp->assign("errors", $errors); $tp->display("save_search_failed.tpl"); } else { $tp->assign("searchId", SJB_Request::getVar("searchId", "")); $tp->assign("listing_type_id", SJB_Session::getValue('listing_type_id')); $tp->display("save_search_form.tpl"); } break; } } else { $tp->assign("return_url", base64_encode(SJB_Navigator::getURIThis())); $tp->assign("ajaxRelocate", true); $tp->display("../users/login.tpl"); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $user_info = SJB_Authorization::getCurrentUserInfo(); if (!empty($user_info['subuser'])) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/sub-accounts/edit/?user_id=' . $user_info['subuser']['sid']); } if (!empty($user_info)) { $user_info = array_merge($user_info, $_REQUEST); $username = $user_info['username']; $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']); $delete_profile = SJB_Request::getVar('command', '', 'post') == 'unregister-user'; $errors = array(); if ($delete_profile && SJB_Acl::getInstance()->isAllowed('delete_user_profile')) { try { $user = SJB_UserManager::getObjectBySID($user_info['sid']); SJB_UserManager::deleteUserById($user_info['sid']); SJB_AdminNotifications::sendAdminDeletingUserProfile($user, SJB_Request::getVar('reason', '', 'post')); SJB_Authorization::logout(); $user_info = array(); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-profile/?profile_deleted=true'); } catch (Exception $e) { $errors[] = $e->getMessage(); } } $user = new SJB_User($user_info, $user_info['user_group_sid']); $user->setSID($user_info['sid']); $user->deleteProperty("active"); $user->deleteProperty("featured"); $user->makePropertyNotRequired("password"); $user->getProperty('email')->type->disableEmailConfirmation(); $edit_profile_form = new SJB_Form($user); $edit_profile_form->registerTags($tp); $edit_profile_form->makeDisabled("username"); $form_submitted = SJB_Request::getVar('action', false) == 'save_info'; if ($form_submitted && $edit_profile_form->isDataValid($errors)) { $password_value = $user->getPropertyValue('password'); if (empty($password_value['original'])) { $user->deleteProperty('password'); } SJB_UserManager::saveUser($user); SJB_Authorization::updateCurrentUserSession(); // >>> SJB-1197 // needs to check session for ajax-uploaded files, and set it to user profile $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage'); $formToken = SJB_Request::getVar('form_token'); 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}"); } // and save user with new fields data SJB_UserManager::saveUser($user); SJB_Authorization::updateCurrentUserSession(); // clean temporary storage $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}"); // CLEAR TEMPORARY SESSION STORAGE SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage); } } // <<< SJB-1197 $tp->assign("form_is_submitted", true); } else { $tp->assign("errors", $errors); } $form_fields = $edit_profile_form->getFormFieldsInfo(); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields))); $tp->assign("show_mailing_flag", $user_group_info['show_mailing_flag']); $tp->assign("form_fields", $form_fields); $tp->assign('userTree', true); $tp->display('edit_profile.tpl'); } elseif (empty($user_info) && SJB_Request::getVar('profile_deleted', '') == true) { $user = new SJB_User(array()); $edit_profile_form = new SJB_Form($user); $edit_profile_form->registerTags($tp); $edit_profile_form->makeDisabled("username"); $form_fields = $edit_profile_form->getFormFieldsInfo(); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields))); $tp->assign("form_fields", $form_fields); $tp->assign('action', 'delete_profile'); $tp->assign('tree_link_users', 'users'); $tp->assign('userTree', true); $tp->display('edit_profile.tpl'); } else { $tp->assign("ERROR", "NOT_LOGIN"); $tp->display("../miscellaneous/error.tpl"); return; } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $template = SJB_Request::getVar('input_template', 'input_form.tpl'); $error = null; $listingTypeID = SJB_Request::getVar('listing_type_id', false); $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false); $pageID = false; if ($passed_parameters_via_uri) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $listingTypeID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : $listingTypeID; $pageID = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : false; $listing_id = isset($passed_parameters_via_uri[2]) ? $passed_parameters_via_uri[2] : false; } if (SJB_UserManager::isUserLoggedIn()) { $post_max_size_orig = ini_get('post_max_size'); $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null; $fromPreview = SJB_Request::getVar('from-preview', false); // get post_max_size in bytes $val = trim($post_max_size_orig); $tmp = substr($val, strlen($val) - 1); $tmp = strtolower($tmp); /* if ini value is K - then multiply to 1024 * if ini value is M - then multiply twice: in case 'm', and case 'k' * if ini value is G - then multiply tree times: in 'g', 'm', 'k' * out value - in bytes! */ switch ($tmp) { case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } $post_max_size = $val; $filename = SJB_Request::getVar('filename', false); if ($filename) { $file = SJB_UploadFileManager::openFile($filename, $listing_id); $errors['NO_SUCH_FILE'] = true; } if (empty($_POST) && $server_content_length > $post_max_size) { $errors['MAX_FILE_SIZE_EXCEEDED'] = 1; $tp->assign('post_max_size', $post_max_size_orig); } $listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id); $currentUser = SJB_UserManager::getCurrentUser(); $contractID = $listingInfo['contract_id']; if ($contractID == 0) { $extraInfo = unserialize($listingInfo['product_info']); $productSID = $extraInfo['product_sid']; } else { $contract = new SJB_Contract(array('contract_id' => $contractID)); $extraInfo = $contract->extra_info; } if ($listingInfo['user_sid'] != SJB_UserManager::getCurrentUserSID()) { $errors['NOT_OWNER_OF_LISTING'] = $listing_id; } else { $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID); $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid); if (!$pageID) { $pageID = $pages[0]['page_id']; } $pageSID = SJB_PostingPagesManager::getPostingPageSIDByID($pageID, $listing_type_sid); $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listing_type_sid); // preview listing $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST'); $form_submitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested; // fill listing from an array of social data if allowed $aAutoFillData = array('formSubmitted' => &$form_submitted, 'listingTypeID' => &$listingTypeID); SJB_Event::dispatch('SocialSynchronization', $aAutoFillData); $listingInfo = array_merge($listingInfo, $_REQUEST); $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID); if ($fromPreview) { if ($form_submitted) { $properties = $listing->getProperties(); foreach ($properties as $fieldID => $property) { switch ($property->getType()) { case 'date': if (!empty($listing_info[$fieldID])) { $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]); } break; case 'complex': $complex = $property->type->complex; $complexProperties = $complex->getProperties(); foreach ($complexProperties as $complexfieldID => $complexProperty) { if ($complexProperty->getType() == 'date') { $values = $complexProperty->getValue(); foreach ($values as $index => $value) { if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) { $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]); } } } } break; } } $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID); } } $previousComplexFields = $this->processComplexFields($listing, $listingInfo); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('status'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('ListingLogo'); $listing->setSID($listing_id); $access_type = $listing->getProperty('access_type'); if ($form_submitted && !empty($access_type)) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true)); } $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID()); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) { $issetQuestionnairyField = $listing->getProperty('screening_questionnaire'); if ($issetQuestionnairyField) { $value = SJB_Request::getVar('screening_questionnaire'); $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : ''; $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true)); } } else { $listing->deleteProperty('screening_questionnaire'); } /* social plugin * "synchronization" * if user is not registered using linkedin , delete linkedin sync property * also deletes it if sync is turned off in admin part */ if ($pages[0]['page_id'] == $pageID) { $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo); SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData); } $add_listing_form = new SJB_Form($listing); $add_listing_form->registerTags($tp); $field_errors = array(); if ($form_submitted && (SJB_Session::getValue(self::PREVIEW_LISTING_SID) == $listing_id || $add_listing_form->isDataValid($field_errors))) { /* delete temp preview listing sid */ SJB_Session::unsetValue(self::PREVIEW_LISTING_SID); if ($isPageLast) { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } $listing->setUserSID($currentUser->getSID()); if (empty($access_type->value)) { $listing->setPropertyValue('access_type', 'everyone'); } if (isset($_SESSION['tmp_file_storage'])) { foreach ($_SESSION['tmp_file_storage'] as $k => $v) { SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s', $listing->getSID(), $v['picture_saved_name']); SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s', $listing->getSID(), $v['thumb_saved_name']); } SJB_Session::unsetValue('tmp_file_storage'); } // >>> SJB-1197 // check temporary uploaded storage for listing uploads and assign it to saved listing $formToken = SJB_Request::getVar('form_token'); $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage'); $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken); if (!empty($uploadedFields)) { foreach ($uploadedFields as $fieldId => $fieldValue) { // get field of listing $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldValue['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } // unset value from session temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}"); } //and remove token key from temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}"); SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage); } // <<< SJB-1197 SJB_ListingManager::saveListing($listing); foreach ($previousComplexFields as $propertyId) { $listing->deleteProperty($propertyId); } if ($isPageLast && !$isPreviewListingRequested) { $listingSID = $listing->getSID(); $listing = SJB_ListingManager::getObjectBySID($listingSID); $listing->setSID($listingSID); $keywords = $listing->getKeywords(); SJB_ListingManager::updateKeywords($keywords, $listing->getSID()); // Start Event $listingSid = $listing->getSID(); SJB_Event::dispatch('listingSaved', $listingSid); // is listing featured by default if ($extraInfo['featured']) { SJB_ListingManager::makeFeaturedBySID($listing->getSID()); } if ($extraInfo['priority']) { SJB_ListingManager::makePriorityBySID($listing->getSID()); } if ($contractID) { if (SJB_ListingManager::activateListingBySID($listing->getSID())) { SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID()); } // notify administrator SJB_AdminNotifications::sendAdminListingAddedLetter($listing); if (isset($_REQUEST['action_add_pictures'])) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-pictures/?listing_id=" . $listing->getSID()); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeID) . '/?listing_id=' . $listing->getSID()); } } else { SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID()); $this->proceedToCheckout($currentUser->getSID(), $productSID); } } elseif ($isPageLast && $isPreviewListingRequested) { // for listing preview SJB_Session::setValue(self::PREVIEW_LISTING_SID, $listing->getSID()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/'); } else { // listing steps (pages) SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . '/' . $listing->getSID()); } } else { foreach ($previousComplexFields as $propertyId) { $listing->deleteProperty($propertyId); } $listing->deleteProperty('access_list'); $listing->deleteProperty('contract_id'); $add_listing_form = new SJB_Form($listing); if (SJB_Request::get('action_add') == 'Next') { $add_listing_form->setUseDefaultValues(); } if ($form_submitted) { $add_listing_form->isDataValid($field_errors); } $add_listing_form->registerTags($tp); $form_fields = $add_listing_form->getFormFieldsInfo(); $employers_list = SJB_Request::getVar('list_emp_ids', false); $employers = array(); if (is_array($employers_list)) { foreach ($employers_list as $emp) { $currEmp = SJB_UserManager::getUserInfoBySID($emp); $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']); } sort($employers); } else { $access_type = $listing->getPropertyValue('access_type'); $employers = SJB_ListingManager::getListingAccessList($listing_id, $access_type); } $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $tp->assign('pic_limit', $numberOfPictures); $tp->assign('listing_sid', $listing_id); $tp->assign('listing_id', $listing_id); $tp->assign('listingSID', $listing->getSID()); $tp->assign('listing_access_list', $employers); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('contract_id', $contractID); $tp->assign('field_errors', $field_errors); $tp->assign('form_fields', $form_fields); $tp->assign("extraInfo", $extraInfo); $tp->assign('pages', $pages); $tp->assign('pageSID', $pageSID); $tp->assign('currentPage', SJB_PostingPagesManager::getPageInfoBySID($pageSID)); $tp->assign('isPageLast', $isPageLast); $tp->assign('nextPage', SJB_PostingPagesManager::getNextPage($pageSID)); $tp->assign('prevPage', SJB_PostingPagesManager::getPrevPage($pageSID)); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); // social plugin only for Resume listing types $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $currentUser->getSID()); SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData); SJB_Session::unsetValue(self::PREVIEW_LISTING_SID); $tp->display($template); } } } else { $tp->assign('listingTypeID', $listingTypeID); $tp->assign('error', 'NOT_LOGGED_IN'); $tp->display('add_listing_error.tpl'); } }
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); }
public function execute() { ini_set('max_execution_time', 0); $errors = array(); $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', false); $dir_separator = DIRECTORY_SEPARATOR; $script_path = explode(SJB_System::getSystemSettings('SYSTEM_URL_BASE'), __FILE__); $script_path = array_shift($script_path); $identifier = SJB_Request::getVar('identifier', time()); $filename = SJB_Request::getVar('filename', false); $settings = array(); if ($filename) { SJB_Backup::sendArchiveFile($filename, $script_path . 'backup' . $dir_separator . $filename); } if (SJB_Request::getVar('action') == "save") { $expPeriod = SJB_Request::getVar('backup_expired_period'); if (!empty($expPeriod) && (!is_numeric($expPeriod) || $expPeriod < 0)) { $errors[] = 'EXP_PERIOD_NOT_VALID'; } $ftpValid = $this->isFTPDataValid(); if (SJB_Request::getVar('autobackup', false) && SJB_Request::getVar('ftp_backup', false) && !$ftpValid) { $errors[] = 'FTP_DETAILS_NOT_VALID'; } if (empty($errors)) { $backupSettings = $_REQUEST; foreach ($backupSettings as $setting => $value) { if (!SJB_Settings::saveSetting($setting, $value)) { $errors['SETTINGS_SAVED_WITH_PROBLEMS'] = "SETTINGS_SAVED_WITH_PROBLEMS"; } } if (empty($errors)) { $tp->assign('successSaveMessage', true); } } else { $settings = $_REQUEST; } } switch ($action) { case 'backup': if (SJB_System::getSystemSettings('isDemo')) { $i18N = SJB_I18N::getInstance(); $str = $i18N->gettext('Backend', 'Error: You don\'t have permissions for it. This is a Demo version of the software.'); SJB_Session::setValue('error', $str); break; } if (SJB_System::getIfTrialModeIsOn() && $_SERVER['REMOTE_ADDR'] != "91.205.51.231") { $i18N = SJB_I18N::getInstance(); $str = $i18N->gettext('Backend', 'Error: You don\'t have permissions for it. This is a Trial version of the software.'); SJB_Session::setValue('error', $str); break; } SessionStorage::destroy('backup_' . $identifier); SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time()))); SJB_Session::unsetValue('restore'); SJB_Session::unsetValue('error'); $backup_type = SJB_Request::getVar('backup_type'); $backupDir = $script_path . 'backup' . $dir_separator; try { $this->prepareBackupDir($backupDir); } catch (Exception $e) { SJB_Session::setValue('error', $e->getMessage()); exit; } switch ($backup_type) { case 'full': SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time()))); $backupDir = $script_path; $name = 'db.sql'; SJB_Backup::dump($name, $script_path, $identifier); $d = dir($script_path); $contentDir = array(); $folders = array('.', '..', 'backup', '.svn', '.settings', '.cache', 'restore', $name); while (false !== ($entry = $d->read())) { if (!in_array($entry, $folders)) { $contentDir[] = $entry; } } $listFilesAndFolders = !empty($contentDir) ? $contentDir : false; $backupName = 'full_backup_' . date('Y_m_d__H_i') . '.tar.gz'; $export_files_dir_name = '..' . $dir_separator; if (SJB_Backup::archive($name, $listFilesAndFolders, $backupDir, $export_files_dir_name, $backupName, true, $identifier, 'full')) { SessionStorage::write('backup_' . $identifier, serialize(array('name' => $backupName))); } exit; break; case 'database': SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time()))); $name = 'db.sql'; $backupName = 'mysqldump_' . date('Y_m_d__H_i') . '.tar.gz'; $export_files_dir_name = '../backup' . $dir_separator; SJB_Backup::dump($name, $script_path, $identifier); if (SJB_Backup::archive(false, $name, $script_path, $export_files_dir_name, $backupName, false, $identifier, 'database')) { SessionStorage::write('backup_' . $identifier, serialize(array('name' => $backupName))); } exit; break; case 'files': SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time()))); $backupDir = $script_path; $d = dir($script_path); $contentDir = array(); $folders = array('.', '..', 'backup', '.svn', '.settings', '.cache', 'restore'); while (false !== ($entry = $d->read())) { if (!in_array($entry, $folders)) { $contentDir[] = $entry; } } $listFilesAndFolders = !empty($contentDir) ? $contentDir : false; $backupName = 'backup_' . date('Y_m_d__H_i') . '.tar.gz'; $export_files_dir_name = '..' . $dir_separator; if (SJB_Backup::archive(false, $listFilesAndFolders, $backupDir, $export_files_dir_name, $backupName, true, $identifier, 'files')) { SessionStorage::write('backup_' . $identifier, serialize(array('name' => $backupName))); } exit; break; } break; case 'restore': if (SJB_System::getSystemSettings('isDemo')) { SJB_Session::setValue('error', 'Error: You don\'t have permissions for it. This is a Demo version of the software.'); exit; } if (SJB_System::getIfTrialModeIsOn()) { SJB_Session::setValue('error', 'Error: You don\'t have permissions for it. This is a Trial version of the software.'); exit; } SJB_Session::unsetValue('restore'); SJB_Session::unsetValue('error'); $error = false; $restoreDir = $script_path . 'restore' . $dir_separator; try { $fileName = $this->moveUploadedFile($restoreDir); $tar = new Archive_Tar($restoreDir . $fileName, 'gz'); $tar->_error_class = 'SJB_PEAR_Exception'; $tar->extractList('db.sql', $restoreDir); $tar->extract($script_path); if (is_file($restoreDir . 'db.sql')) { SJB_Backup::restore_base_tables($restoreDir . 'db.sql'); } SJB_Cache::getInstance()->clean(); } catch (Exception $ex) { $error = $ex->getMessage(); } SJB_Filesystem::delete($restoreDir); if (is_file($script_path . 'install.php')) { SJB_Filesystem::delete($script_path . 'install.php'); } if ($error) { SJB_Session::setValue('error', $error); } else { SJB_Session::setValue('restore', 1); } exit; break; case 'send_archive': $name = SJB_Request::getVar('name', false); $archive_file_path = SJB_Path::combine(SJB_BASE_DIR . 'backup' . $dir_separator, $name); if ($name) { SJB_Backup::sendArchiveFile($name, $archive_file_path); } break; case 'check': $sessionBackup = SessionStorage::read('backup_' . $identifier); $sessionBackup = $sessionBackup ? unserialize($sessionBackup) : array(); $sessionRestore = SJB_Session::getValue('restore'); $sessionError = SJB_Session::getValue('error'); if (!empty($sessionBackup['name'])) { $name = $sessionBackup['name']; SessionStorage::destroy('backup_' . $identifier); echo SJB_System::getSystemSettings('SITE_URL') . "/backup/?action=send_archive&name={$name}"; exit; } elseif (!empty($sessionRestore)) { SJB_Session::unsetValue('restore'); echo SJB_System::getSystemSettings('SITE_URL') . '/backup/#restore'; exit; } elseif (!empty($sessionError)) { echo 'Error'; if (SJB_System::getSystemSettings('isDemo')) { echo ': You don\'t have permissions for it. This is a Demo version of the software.'; } if (SJB_System::getIfTrialModeIsOn()) { echo ': You don\'t have permissions for it. This is a Trial version of the software.'; } exit; } elseif (!empty($sessionBackup['last_time'])) { $period = (time() - $sessionBackup['last_time']) / 60; if ($period < 5) { echo 1; } else { SJB_Session::setValue('error', 'The backup generation process was unexpectedly interrupted. Please try again.'); echo 'error'; } exit; } else { echo 1; } exit; break; case 'delete_backup': $name = SJB_Request::getVar('name', false); if ($name) { $backup = $script_path . 'backup' . $dir_separator . $name; if (is_file($backup)) { SJB_Filesystem::delete($backup); SJB_Autobackup::deleteFileFromFtp($name); } else { $errors['FILE_NOT_FOUND'] = 1; } } $tp->assign('errors', $errors); $tp->assign('delBackup', 1); case 'created_backups': $path = $script_path . 'backup' . $dir_separator; if (is_dir($path)) { $di = new DirectoryIterator($path); $backupsArr = array(); foreach ($di as $file) { $fileName = $file->getFilename(); if (!$file->isDir() && !$file->isLink() && $fileName != '.htaccess') { $cTime = $file->getCTime(); $backupsArr[$cTime]['name'] = $fileName; if (preg_match('/mysqldump/', $fileName)) { $backupsArr[$cTime]['type'] = 'Site database only'; } elseif (preg_match('/full_backup/', $fileName)) { $backupsArr[$cTime]['type'] = 'Full site backup'; } elseif (preg_match('/backup/', $fileName)) { $backupsArr[$cTime]['type'] = 'Site files only'; } else { $backupsArr[$cTime]['type'] = 'Unknown'; } $pattern = '/(\\w+)_(\\d+)_(\\d+)_(\\d+)__(\\d+)_(\\d+).tar.gz/i'; $replacement = '$2-$3-$4 $5:$6'; $backupsArr[$cTime]['date'] = preg_replace($pattern, $replacement, $fileName); } } krsort($backupsArr); $tp->assign('created_backups', $backupsArr); } $tp->display('created_backups.tpl'); exit; break; case 'error': $sessionError = SJB_Session::getValue('error'); if (!is_null($sessionError)) { echo '<p class="error">' . $sessionError . '</p>'; exit; } break; } if (empty($settings)) { $settings = SJB_Settings::getSettings(); } $tp->assign('errors', $errors); $tp->assign('settings', $settings); $tp->assign('identifier', $identifier); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display('backup.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $networkFeeds = array(); $template = 'social_media.tpl'; $formSubmitted = SJB_Request::getVar('submit'); $action = SJB_Request::getVar('action'); $subAction = SJB_Request::getVar('sub_action'); $sid = SJB_Request::getVar('sid'); $groups = array(); $accountInfo = null; $messages = array(); $savedSettings = array(); if (SJB_Request::getVar('error', false)) { $errors[] = SJB_Request::getVar('error', false); } if (SJB_Request::getVar('message', false)) { $messages[] = SJB_Request::getVar('message', false); } $socNetworks = array('facebook' => array('name' => 'Facebook'), 'linkedin' => array('name' => 'Linkedin'), 'twitter' => array('name' => 'Twitter'), 'googleplus' => array('name' => 'Google+'), 'bitly' => array('name' => 'Bitly')); $network = SJB_Request::getVar('passed_parameters_via_uri'); if (empty($network)) { $network = SJB_Request::getVar('soc_network'); } switch ($network) { case 'facebook': $template = 'social_media_settings.tpl'; $objectName = 'SJB_FacebookSocial'; break; case 'linkedin': $template = 'social_media_settings.tpl'; $objectName = 'SJB_LinkedInSocial'; break; case 'twitter': $template = 'social_media_settings.tpl'; $objectName = 'SJB_TwitterSocial'; break; case 'googleplus': $template = 'social_media_settings.tpl'; $objectName = 'SJB_GooglePlusSocial'; break; default: $network = ''; $action = ''; $objectName = ''; break; } switch ($action) { case 'add_feed': SJB_Session::unsetValue($network); SJB_Session::unsetValue($network . 'Feed'); $template = 'feed_input_form.tpl'; $accountID = SJB_Request::getVar('account_id', false); $isAuthorized = SJB_Request::getVar('authorized', false); if ($accountID) { $tp->assign('accountID', $accountID); } $feed = new $objectName(); $addForm = new SJB_Form($feed); $addForm->registerTags($tp); $searchFormBuilder = new SJB_SearchFormBuilder($feed); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST); $searchFormBuilder->setCriteria($criteria); $searchFormBuilder->registerTags($tp); $systemFields = $feed->details->systemFields; $postingFields = $feed->details->postingFields; $listingFields = $feed->details->commonFields; $tp->assign('authorized', $isAuthorized); $tp->assign('listingFields', $listingFields); $tp->assign('postingFields', $postingFields); $tp->assign('systemFields', $systemFields); $tp->assign('action', $action); break; case 'save_feed': $template = 'feed_input_form.tpl'; $fieldErrors = array(); $mediaObject = $objectName . 'Media'; $networkSocialMedia = new $mediaObject(); $isAuthorized = SJB_Request::getVar('authorized', false); $actionFeed = SJB_Request::getVar('action_feed'); if ($actionFeed != 'add_feed' && $network != 'twitter') { try { $accountInfo = $networkSocialMedia->getAccountInfo($sid); } catch (Exception $e) { $isAuthorized = false; $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage()); } } $isGroupsExist = !empty($accountInfo['groups']); if (SJB_Request::getVar('process_token', false)) { $_REQUEST = unserialize(SJB_Session::getValue($network . 'Feed')); $_REQUEST['process_token'] = 1; } $feed = new $objectName($_REQUEST, $isGroupsExist, $isAuthorized); if ($isGroupsExist) { $groups = $accountInfo['groups']; } if ($sid) { $feed->setSID($sid); $tp->assign('feed_sid', $sid); } $criteriaSaver = new SJB_ListingCriteriaSaver(); $criteriaSaver->setSessionForCriteria($_REQUEST); $requestedData = $criteriaSaver->getCriteria(); $searchFormBuilder = new SJB_SearchFormBuilder($feed); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST); $searchFormBuilder->setCriteria($criteria); $searchFormBuilder->registerTags($tp); $properties = $feed->getProperties(); foreach ($properties as $key => $property) { if (!$property->isSystem()) { $feed->deleteProperty($key); } } $this->checkToken($tp, $networkSocialMedia, $errors, array(), $network, $sid); $addForm = new SJB_Form($feed); $addForm->registerTags($tp); if ($addForm->isDataValid($fieldErrors)) { if ($network == 'twitter') { try { $accessToken = $networkSocialMedia->getAccessToken($sid, $action, $errors); } catch (Exception $e) { $accessToken = false; $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage()); } if (empty($errors) && $accessToken != false) { $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => serialize($accessToken), 'is_system' => true)); } } else { if ($network == 'facebook' && !empty($accountInfo)) { $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => serialize($accountInfo['access_token']), 'is_system' => true)); $feed->addProperty(array('id' => 'account_name', 'type' => 'text', 'value' => serialize($accountInfo['account_name']), 'is_system' => true)); } } if (empty($errors)) { unset($requestedData['groups']); $feed->addProperty(array('id' => 'search_data', 'type' => 'text', 'value' => serialize($requestedData), 'is_system' => true)); $feed->saveFeed($feed, $action); if ($formSubmitted == 'save') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs'); } $tp->assign('feed_sid', $feed->getSID()); } } $systemFields = $feed->details->systemFields; $postingFields = $feed->details->postingFields; $listingFields = $feed->details->commonFields; $changeAccountUrl = "action=authorize&sid={$sid}&sub_action=change_account&soc_network={$network}"; $tp->assign('field_errors', $fieldErrors); $tp->assign('change_url', $changeAccountUrl); $tp->assign('listingFields', $listingFields); $tp->assign('postingFields', $postingFields); $tp->assign('systemFields', $systemFields); $tp->assign('action', $actionFeed); $tp->assign('authorized', $isAuthorized); $tp->assign('allGroups', $groups); break; case 'grant': $mediaObject = $objectName . 'Media'; $networkSocialMedia = new $mediaObject(); $error = ''; try { $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction); } catch (Exception $e) { $tp->assign('authorized', false); $error = $e->getMessage(); } if (empty($error)) { $networkSocialMedia->updateAccessToken($sid, $accountInfo['account_id'], $accountInfo['account_name']); $logoutUrl = SJB_System::getSystemSettings('SITE_URL') . "/social-media/{$network}?message=ACCOUNT_UPDATED#postJobs"; } else { $logoutUrl = SJB_System::getSystemSettings('SITE_URL') . "/social-media/{$network}?error={$error}#postJobs"; } // After clicking the 'Grant Permission' button and login to Facebook we are redirected to the feeds list. SJB_HelperFunctions::redirect($logoutUrl); break; case 'edit_feed': if (!SJB_Request::getVar('oauth_token', false)) { SJB_Session::unsetValue($network); } if (!SJB_Request::getVar('process_token', false)) { SJB_Session::unsetValue($network . 'Feed'); } if ($sid) { $changeAccountUrl = "action=authorize&sid={$sid}&sub_action=change_account&soc_network={$network}"; $feedInfo = $objectName::getFeedInfoByNetworkIdAndSID($network, $sid); $feedInfo = array_merge($feedInfo, $_REQUEST); $criteriaInfo = $feedInfo['search_data'] ? unserialize($feedInfo['search_data']) : ''; $mediaObject = $objectName . 'Media'; $networkSocialMedia = new $mediaObject(); $isAuthorized = true; if ($network != 'twitter') { try { $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction); } catch (Exception $e) { $isAuthorized = false; $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage()); } } $isGroupsExist = !empty($accountInfo['groups']); if ($isGroupsExist) { $groups = $accountInfo['groups']; } if ($accountInfo && $subAction == 'changed') { $feedInfo = array_merge($feedInfo, $accountInfo); } $feed = new $objectName($feedInfo, $isGroupsExist, $isAuthorized); $editForm = new SJB_Form($feed); $editForm->registerTags($tp); $searchFormBuilder = new SJB_SearchFormBuilder($feed); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($criteriaInfo); $searchFormBuilder->setCriteria($criteria); $searchFormBuilder->registerTags($tp); $systemFields = $feed->details->systemFields; $postingFields = $feed->details->postingFields; $listingFields = $feed->details->commonFields; $this->checkToken($tp, $networkSocialMedia, $errors, $feedInfo, $network, $sid); $tp->assign('listingFields', $listingFields); $tp->assign('postingFields', $postingFields); $tp->assign('systemFields', $systemFields); $tp->assign('feed_sid', $sid); $tp->assign('authorized', $isAuthorized); $tp->assign('allGroups', $groups); $tp->assign('action', $action); $tp->assign('change_url', $changeAccountUrl); $template = 'feed_input_form.tpl'; } break; case 'authorize': if (!SJB_Request::getVar('oauth_token', false)) { SJB_Session::unsetValue($network); } $mediaObject = $objectName . 'Media'; $networkSocialMedia = new $mediaObject(); try { if ($network == 'twitter') { $accessToken = $networkSocialMedia->getAccessToken($sid, $subAction, $errors); $networkSocialMedia->updateFeedToken($sid, $accessToken); if (SJB_Request::getVar('sub_action', null, 'GET') == 'grant') { if (empty($errors)) { $messages[] = 'Account is successfully updated.'; } break; } } else { $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction); } } catch (Exception $e) { $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage()); } $changeAccountUrl = "action=authorize&sub_action=change_account&soc_network={$network}"; $template = 'feed_input_form.tpl'; $isAuthorized = isset($accountInfo['account_id']); $isGroupsExist = !empty($accountInfo['groups']); $feed = new $objectName($accountInfo, $isGroupsExist, $isAuthorized); if ($isGroupsExist) { $groups = $accountInfo['groups']; } $addForm = new SJB_Form($feed); $addForm->registerTags($tp); $searchFormBuilder = new SJB_SearchFormBuilder($feed); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST); $searchFormBuilder->setCriteria($criteria); $searchFormBuilder->registerTags($tp); $systemFields = $feed->details->systemFields; $postingFields = $feed->details->postingFields; $listingFields = $feed->details->commonFields; $tp->assign('listingFields', $listingFields); $tp->assign('postingFields', $postingFields); $tp->assign('systemFields', $systemFields); $tp->assign('action', $action); $tp->assign('authorized', $isAuthorized); $tp->assign('change_url', $changeAccountUrl); $tp->assign('allGroups', $groups); break; case 'delete_feed': $sid = SJB_Request::getVar('sid'); if ($sid) { $feed = new $objectName(); $feed->deleteFeed($sid); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs'); } break; case 'status': $sid = SJB_Request::getVar('sid'); $active = SJB_Request::getVar('active'); $feedInfo = $objectName::getFeedInfoByNetworkIdAndSID($network, $sid); if ($feedInfo != null && ($active == '1' || $active == '0')) { $objectName::updateFeedStatus($network . '_feeds', $active, $sid); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs'); } else { $errors[] = 'Feed does not exist'; } break; case 'save_settings': $request = $_REQUEST; $error = $this->checkFields($request, $objectName); if (!$error) { SJB_Settings::updateSettings($request); if ($formSubmitted == 'save') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/'); } else { if ($formSubmitted == 'apply') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network); } } } $savedSettings = $request; break; } if ($network) { if (empty($savedSettings)) { $savedSettings = SJB_Settings::getSettings(); } SJB_Event::dispatch('RedefineSavedSetting', $savedSettings, true); if ($network != 'googleplus' && $action != 'edit_feed' && $action != 'add_feed' && $action != 'save_feed') { $networkFeeds = SJB_SocialMedia::getFeedsInfoByNetworkID($network); $currentDate = date('Y-m-d', time()); foreach ($networkFeeds as $key => $feed) { if (SJB_SocialMedia::isFeedExpired($feed, $currentDate)) { $networkFeeds[$key]['expired'] = true; } } } $tp->assign('network', $network); $tp->assign('savedSettings', $savedSettings); $tp->assign('networkFeeds', $networkFeeds); $tp->assign('networkName', $socNetworks[$network]['name']); if ($network != 'twitter') { $networkObject = new $objectName(); $settings = $networkObject->getConnectSettings(); $tp->assign('settings', $settings); } } else { $tp->assign('socNetworks', $socNetworks); } $tp->assign('networkFeeds', $networkFeeds); $tp->assign('socNetworks', $socNetworks); $tp->assign('errors', $errors); $tp->assign('messages', $messages); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (isset($_REQUEST['listing_type_id'])) { $listing_type_id = $_REQUEST['listing_type_id']; SJB_Session::setValue('listing_type_id', $listing_type_id); } elseif (isset($_REQUEST['restore'])) { $listing_type_id = SJB_Session::getValue('listing_type_id'); } else { SJB_Session::setValue('listing_type_id', null); } $listing_type_sid = 0; if (!empty($listing_type_id)) { $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id); } if (!isset($_REQUEST['listing_type']['equal']) && isset($listing_type_id)) { $_REQUEST['listing_type']['equal'] = $listing_type_id; } if (isset($_REQUEST['searchId'])) { $criteria_saver = new SJB_ListingCriteriaSaver($_REQUEST['searchId']); $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria()); } $empty_listing = new SJB_Listing(array(), $listing_type_sid); $empty_listing->addIDProperty(); $empty_listing->addActivationDateProperty(); $empty_listing->addUsernameProperty(); $empty_listing->addKeywordsProperty(); $empty_listing->addPicturesProperty(); $empty_listing->addListingTypeIDProperty(); $empty_listing->addPostedWithinProperty(); $search_form_builder = new SJB_SearchFormBuilder($empty_listing); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST); $properties = $empty_listing->getProperties(); foreach ($properties as $propertyName => $property) { if ($property->getType() == 'location') { $propertyInfo = $property->type->property_info; if ($propertyInfo['enable_search_by_radius'] == 1) { if (!isset($criteria['system'][$propertyName])) { $value = array('value' => '', 'radius' => '10'); $criterion = SJB_SearchCriterion::getCriterionByType('location'); $criterion->setProperty($property); $criterion->setPropertyName($propertyName); $criterion->setValue($value); $criteria['system'][$propertyName][] = $criterion; } } } } $search_form_builder->setCriteria($criteria); $search_form_builder->registerTags($tp); $form_fields = $search_form_builder->getFormFieldsInfo(); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $template = SJB_Request::getVar('form_template', 'search_form.tpl'); $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_SEARCH, $listing_type_id); $formBuilder->setChargedTemplateProcessor($tp); if ($template == 'quick_search.tpl') { $fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('Location'); if ($fieldSID) { $fields = SJB_ListingFieldManager::getFieldInfoBySID($fieldSID); if (!empty($fields['fields'])) { foreach ($fields['fields'] as $field) { $form_fields[$fields['id'] . '_' . $field['id']] = $field; } } $tp->assign('locationFields', array($fields)); } } $tp->assign('form_fields', $form_fields); $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); $tp->display($template); }
/** * @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; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $current_user = SJB_UserManager::getCurrentUser(); if ($current_user->isSubuser()) { // У саб-юзера должны быть свои алерты $current_user = $current_user->getSubuserInfo(); } else { $current_user = SJB_UserManager::getCurrentUserInfo(); } $listing_type_id = ''; /************************************************************/ $tp = SJB_System::getTemplateProcessor(); $tp->assign('action', 'list'); $errors = array(); $redirectUri = '/saved-searches/'; if (isset($_REQUEST['is_alert'])) { if (isset($_REQUEST['listing_type_id'])) { $listing_type_id = $_REQUEST['listing_type_id']; SJB_Session::setValue('listing_type_id', $listing_type_id); } elseif (isset($_REQUEST['restore'])) { $listing_type_id = SJB_Session::getValue('listing_type_id'); } else { SJB_Session::setValue('listing_type_id', null); } if (!SJB_Acl::getInstance()->isAllowed("use_{$listing_type_id}_alerts")) { $errors = array('NOT_SUBSCRIBE' => true); $tp->assign('ERRORS', $errors); $tp->display('error.tpl'); return; } else { $redirectUri = '/' . strtolower($listing_type_id) . '-alerts/'; } } else { if (isset($_REQUEST['listing_type_id'])) { $listing_type_id = $_REQUEST['listing_type_id']; } if (!SJB_Acl::getInstance()->isAllowed('save_searches')) { $errors = array('NOT_SUBSCRIBE' => true); $tp->assign('ERRORS', $errors); $tp->display('error.tpl'); return; } } $isSubmittedForm = SJB_Request::getVar('submit', false); $listing_type_sid = !empty($listing_type_id) ? SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id) : 0; if (!isset($_REQUEST['listing_type']['equal']) && isset($listing_type_id)) { $_REQUEST['listing_type']['equal'] = $listing_type_id; } $action = SJB_Request::getVar('action', 'list'); switch ($action) { case 'save': if ($isSubmittedForm) { $search_name = SJB_Request::getVar('name'); $emailFrequency = SJB_Request::getVar('email_frequency'); if (empty($search_name['equal'])) { $errors['EMPTY_VALUE'] = 1; $tp->assign('action', 'save'); } else { unset($_REQUEST['name']); unset($_REQUEST['email_frequency']); if ($emailFrequency) { $emailFrequency = array_pop($emailFrequency); $emailFrequency = '&email_frequency=' . array_pop($emailFrequency); } else { $emailFrequency = ''; } $search_name = $search_name['equal']; $searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id); $tp = $searchResultsTP->getChargedTemplateProcessor(); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/save-search/?alert=true&url=' . $redirectUri . '&action=save&search_name=' . $search_name . '&searchId=' . $searchResultsTP->searchId . $emailFrequency); } } else { $tp->assign('action', 'save'); } break; case 'edit': if (isset($_REQUEST['id_saved'])) { if ($isSubmittedForm) { $id_saved = $_REQUEST['id_saved']; $name = $_REQUEST['name']; $search_name = SJB_Request::getVar('name'); $emailFrequency = SJB_Request::getVar('email_frequency'); if (empty($search_name['equal'])) { $errors['EMPTY_VALUE'] = 1; } else { unset($_REQUEST['name']); unset($_REQUEST['email_frequency']); if ($emailFrequency) { $emailFrequency = array_pop($emailFrequency); $emailFrequency = array_pop($emailFrequency); } else { $emailFrequency = 'daily'; } $searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id); $tp = $searchResultsTP->getChargedTemplateProcessor(); $criteria_saver = new SJB_ListingCriteriaSaver($searchResultsTP->searchId); $requested_data = $criteria_saver->getCriteria(); SJB_SavedSearches::updateSearchOnDB($requested_data, $id_saved, $current_user['sid'], $name['equal'], $emailFrequency); } if (!empty($errors)) { $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . $redirectUri . '?alert=is_update'); } } else { $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); } } break; case 'edit_alert': $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); break; case 'edit_search': $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); $_REQUEST['form_template'] = SJB_Request::getVar('formTemplateNem'); break; case 'new': $tp->assign('action', 'save'); break; case 'delete': if (isset($_REQUEST['search_id'])) { $search_id = $_REQUEST['search_id']; SJB_SavedSearches::deleteSearchFromDBBySID($search_id); } break; case 'disable_notify': if (isset($_REQUEST['search_id'])) { SJB_SavedSearches::disableSearchAutoNotify($current_user['sid'], $_REQUEST['search_id']); } break; case 'enable_notify': if (isset($_REQUEST['search_id'])) { SJB_SavedSearches::enableSearchAutoNotify($current_user['sid'], $_REQUEST['search_id']); } break; } if ($action != 'new' && $action != 'edit_alert') { $saved_searches = SJB_SavedSearches::getSavedSearchesFromDB($current_user['sid']); if (isset($_REQUEST['is_alert'])) { $saved_searches = SJB_SavedSearches::getSavedJobAlertFromDB($current_user['sid']); } foreach ($saved_searches as $key => $saved_search) { $saved_searches[$key]['data'] = SJB_SavedSearches::buildCriteriaFields($saved_search['data']); if (isset($saved_search['data']['listing_type']['equal'])) { $saved_searches[$key]['listing_type'] = $saved_search['data']['listing_type']['equal']; } } $tp->assign('saved_searches', $saved_searches); } $listing = new SJB_Listing(array(), $listing_type_sid); $listing->addIDProperty(); $listing->addActivationDateProperty(); $listing->addUsernameProperty(); $listing->addKeywordsProperty(); $listing->addPicturesProperty(); $listing->addEmailFrequencyProperty(); $listing->addListingTypeIDProperty(); $listing->addPostedWithinProperty(); $search_form_builder = new SJB_SearchFormBuilder($listing); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST); $search_form_builder->setCriteria($criteria); $search_form_builder->registerTags($tp); $form_fields = $search_form_builder->getFormFieldsInfo(); $tp->assign('form_fields', $form_fields); if (!empty($_REQUEST['name'])) { $tp->assign('search_name', $_REQUEST['name']); } if (!empty($_REQUEST['email_frequency'])) { $tp->assign('email_frequency', $_REQUEST['email_frequency']); } $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); $form_template = SJB_Request::getVar('form_template', 'search_form.tpl'); switch (SJB_Request::getVar('alert')) { case 'added': $tp->assign('alert_added', 'added'); break; case 'is_update': $tp->assign('alert_update', 'update'); break; } if (!$listing_type_id && isset($saved_search['data']['listing_type']['equal'])) { $listing_type_id = $saved_search['data']['listing_type']['equal']; } $tp->assign('errors', $errors); $tp->assign('user_logged_in', true); $tp->assign('listing_type_id', $listing_type_id); $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_SEARCH, $listing_type_id); $formBuilder->setChargedTemplateProcessor($tp); $tp->display($form_template); } else { $tp->assign("ERROR", "NOT_LOGIN"); $tp->display("../miscellaneous/error.tpl"); return; } }
/** * @param int $currentUserID * @param int $productSID * @return bool|int|mixed */ public function proceedToCheckout($currentUserID, $productSID) { $errors = array(); $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (SJB_UserManager::isUserLoggedIn()) { $numberOfListings = SJB_ListingDBManager::getNumberOfCheckoutedListingsByProductSID($productSID, $currentUserID); $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID); $shoppingCartProducts = SJB_ShoppingCart::getProductsInfoFromCartByProductSID($productSID, $currentUserID); if (!empty($shoppingCartProducts)) { if ($productInfo['product_type'] == 'mixed_product' || isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') { if ($numberOfListings / (count($shoppingCartProducts) * $productInfo['number_of_listings']) > 1) { SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID); } } if (isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') { if ($numberOfListings / (count($shoppingCartProducts) * end($productInfo['volume_based_pricing']['listings_range_to'])) > 1) { $productInfo['number_of_listings'] = 1; $productObj = new SJB_Product($productInfo, $productInfo['product_type']); $productObj->setNumberOfListings($productInfo['number_of_listings']); $productInfo['price'] = $productObj->getPrice(); SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID); } else { foreach ($shoppingCartProducts as $shoppingCartProduct) { $unserializedProductInfoFromShopCart = unserialize($shoppingCartProduct['product_info']); if ($unserializedProductInfoFromShopCart['number_of_listings'] < end($unserializedProductInfoFromShopCart['volume_based_pricing']['listings_range_to'])) { $unserializedProductInfoFromShopCart['number_of_listings'] += 1; SJB_ShoppingCart::updateItemBySID($shoppingCartProduct['sid'], $unserializedProductInfoFromShopCart); break; } } } } } else { if (!empty($extraInfo['pricing_type']) && $extraInfo['pricing_type'] == 'volume_based') { $productInfo['number_of_listings'] = 1; $productObj = new SJB_Product($productInfo, $productInfo['product_type']); $productObj->setNumberOfListings($productInfo['number_of_listings']); $productInfo['price'] = $productObj->getPrice(); } SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID); } } else { $products = SJB_Session::getValue('products'); if (isset($products)) { foreach ($products as $addedProduct) { $addedProductInfo = unserialize($addedProduct['product_info']); if ($addedProductInfo['user_group_sid'] != $productInfo['user_group_sid']) { $errors[] = 'You are trying to add products of different User Groups in your Shopping Cart. You сan add only products belonging to one User Group. If you want to add this product in the Shopping Cart please go back to the Shopping Cart and remove products of other User Groups.'; break; } } } if (!$errors) { $id = time(); $products[$id]['product_info'] = serialize($productInfo); $products[$id]['sid'] = $id; $products[$id]['user_sid'] = 0; SJB_Session::setValue('products', $products); } } if (!$errors) { SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/'); } }
public function execute() { $listingTypeSid = SJB_Request::getVar('listing_type_sid', false); $template_processor = SJB_System::getTemplateProcessor(); if (isset($_REQUEST['restore']) && isset($listingSearcher['criteria_values']['listing_type_sid'])) { $listingSearcher = SJB_Session::getValue('ListingSearcher', null); $listingTypeSid = $listingSearcher['criteria_values']['listing_type_sid']['equal']; } $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSid); $template_processor->assign('showApprovalStatusField', $listingTypeInfo['waitApprove']); $template_processor->assign('listingsType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $show_search_form = true; if (empty($_REQUEST['action']) && empty($_REQUEST['restore'])) { $show_search_form = false; } $template_processor->assign('show_search_form', $show_search_form); /**************** S E A R C H F O R M ****************/ $listing = SJB_ObjectMother::createListing(array(), $listingTypeSid); $id_alias_info = $listing->addIDProperty(); $username_alias_info = $listing->addUsernameProperty(); $productAliasInfo = $listing->addProductProperty($listingTypeSid); $listing->addCompanyNameProperty(); $listing->addActivationDateProperty(); $listing->addExpirationDateProperty(); $listing->addActiveProperty(); $listing->addKeywordsProperty(); $listing->addDataSourceProperty(); $listing->addPriorityProperty(); $aliases = new SJB_PropertyAliases(); $aliases->addAlias($username_alias_info); $aliases->addAlias($id_alias_info); $aliases->addAlias($productAliasInfo); $search_form_builder = new SJB_SearchFormBuilder($listing); $criteria_saver = SJB_ObjectMother::createListingCriteriaSaver(); $keywords = NULL; if (isset($_REQUEST['restore'])) { $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria()); $criteria = $criteria_saver->getCriteria(); $listingSid = SJB_Array::getPath($criteria, 'sid') ? $criteria['sid']['equal'] : ''; $keywords = SJB_Array::getPath($criteria, 'keywords') ? $criteria['keywords']['like'] : $listingSid; } if ($listingTypeSid) { $_REQUEST['listing_type_sid'] = array('equal' => $listingTypeSid); } $template_processor->assign('companyName', isset($_REQUEST['company_name']['like']) ? $_REQUEST['company_name']['like'] : ''); $template_processor->assign('idKeyword', isset($_REQUEST['idKeyword']) ? $_REQUEST['idKeyword'] : $keywords); $this->prepareRequestedCriteria(); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST, $listing); $search_form_builder->setCriteria($criteria); $search_form_builder->registerTags($template_processor); $template_processor->display("manage_listings.tpl"); /************* S E A R C H F O R M R E S U L T S *************/ $paginator = new SJB_ListingPagination($listingTypeInfo); $searcher = SJB_ObjectMother::createListingSearcher(); $inner_join = array(); if (SJB_Request::getVar('action', '') == 'search' || isset($_REQUEST['restore'])) { if (!isset($_REQUEST['restore'])) { $criteria_saver->resetSearchResultsDisplay(); } if (isset($_REQUEST['company_name']['like']) && $_REQUEST['company_name']['like'] != '') { $inner_join = array('users' => array('join_field' => 'sid', 'join_field2' => 'user_sid', 'main_table' => 'listings', 'join' => 'INNER JOIN')); } $foundListingsSIDs = $searcher->getObjectsSIDsByCriteria($criteria, $aliases, array(), $inner_join); //get found listing sids if (empty($foundListingsSIDs) && $paginator->currentPage != 1) { if ($listingTypeInfo['id'] == 'Job' || $listingTypeInfo['id'] == 'Resume') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeInfo['id']) . 's/?page=1&restore=1'); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeInfo['id']) . '-listings/?page=1&restore=1'); } } $criteria_saver->setSessionForListingsPerPage($paginator->itemsPerPage); $criteria_saver->setSessionForCurrentPage($paginator->currentPage); $criteria_saver->setSessionForCriteria($_REQUEST); $orderInfo = array('sorting_field' => $paginator->sortingField, 'sorting_order' => $paginator->sortingOrder); $criteria_saver->setSessionForOrderInfo($orderInfo); } else { $criteria_saver->resetSearchResultsDisplay(); return; } $criteria_saver->setSessionForObjectSIDs($foundListingsSIDs); $listing_search_structure = $criteria_saver->createTemplateStructureForSearch(); /**************** S O R T I N G *****************/ $empty_listing = SJB_ObjectMother::createListing(array(), $listingTypeSid); $empty_listing->addPicturesProperty(); $empty_listing->addIDProperty(); $empty_listing->addListingTypeIDProperty(); $empty_listing->addActivationDateProperty(); $empty_listing->addExpirationDateProperty(); $empty_listing->addUsernameProperty(); $empty_listing->addPicturesProperty(); $empty_listing->addNumberOfViewsProperty(); $empty_listing->addActiveProperty(); $empty_listing->addKeywordsProperty(); $empty_listing->addDataSourceProperty(); $listing->addRejectReasonProperty(); if ($empty_listing->propertyIsSet($listing_search_structure['sorting_field']) && !empty($foundListingsSIDs)) { $sorting_field = $listing_search_structure['sorting_field']; $sorting_order = $listing_search_structure['sorting_order']; switch ($sorting_field) { case 'username': $ids = join(", ", $foundListingsSIDs); $sql = "\tSELECT\t\tlistings.*\n\t\t\t\t\t\tFROM \t\tlistings\n\t\t\t\t\t\tLEFT JOIN\tusers on listings.user_sid = users.sid\n\t\t\t\t\t\tWHERE \t\tlistings.sid IN ({$ids})\n\t\t\t\t\t\tORDER BY users.username {$sorting_order}"; $listings_info = SJB_DB::query($sql); break; case 'listing_type': $ids = join(", ", $foundListingsSIDs); $sql = "\tSELECT\t\tlistings.*\n\t\t\t\t\t\tFROM \t\tlistings\n\t\t\t\t\t\tLEFT JOIN\tlisting_types on listings.listing_type_sid = listing_types.sid\n\t\t\t\t\t\tWHERE \t\tlistings.sid IN ({$ids})\n\t\t\t\t\t\tORDER BY listing_types.id {$sorting_order}"; $listings_info = SJB_DB::query($sql); break; case 'id': $ids = join(", ", $foundListingsSIDs); $sql = "\tSELECT\t\tlistings.*\n\t\t\t\t\t\tFROM \t\tlistings\n\t\t\t\t\t\tWHERE\t\tlistings.sid IN ({$ids})\n\t\t\t\t\t\tORDER BY sid {$sorting_order}"; $listings_info = SJB_DB::query($sql); break; default: $property = $empty_listing->getProperty($sorting_field); $listing_request_creator = new SJB_ListingRequestCreator($foundListingsSIDs, array('property' => $property, 'sorting_order' => $sorting_order)); $listings_info = SJB_DB::query($listing_request_creator->getRequest()); break; } $listings_sids = array(); foreach ($listings_info as $listing_info) { $listings_sids[$listing_info['sid']] = $listing_info['sid']; } $sortedFoundListingsSIDs = array_keys($listings_sids); $criteria_saver->setSessionForObjectSIDs($sortedFoundListingsSIDs); } else { $sortedFoundListingsSIDs = $foundListingsSIDs; $criteria_saver->setSessionForObjectSIDs($foundListingsSIDs); } /**************** P A G I N G *****************/ $sortedFoundListingsSIDsByPages = array_chunk($sortedFoundListingsSIDs, $paginator->itemsPerPage, true); $paginator->setItemsCount(count($sortedFoundListingsSIDs)); /************* S T R U C T U R E **************/ $listings_structure = array(); if (isset($sortedFoundListingsSIDsByPages[$paginator->currentPage - 1])) { foreach ($sortedFoundListingsSIDsByPages[$paginator->currentPage - 1] as $sid) { $listing = SJB_ListingManager::getObjectBySID($sid); $listing->addPicturesProperty(); $listings_structure[$listing->getID()] = SJB_ListingManager::createTemplateStructureForListing($listing); } } /*************** D I S P L A Y ****************/ $template_processor->assign("search_criteria", $criteria_saver->createTemplateStructureForCriteria()); $template_processor->assign('paginationInfo', $paginator->getPaginationInfo()); $template_processor->assign('listings', $listings_structure); $template_processor->display('display_results.tpl'); }
public function execute() { $template_processor = SJB_System::getTemplateProcessor(); $listing_id = SJB_Request::getVar('listing_sid', SJB_Request::getVar('listing_id', null)); $listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id); $productSID = SJB_Request::getVar('product_sid' . null); $errors = null; $field_errors = null; $extraInfo = array(); if (empty($listing_id)) { $errors['WRONG_PARAMETERS_SPECIFIED'] = 1; } elseif (!empty($listing_id) && strlen($listing_id) == strlen(time())) { if ($productSID) { SJB_Session::setValue('product_sid', $productSID); } else { $productSID = SJB_Session::getValue('product_sid'); } if (empty($_SESSION['tmp_file_storage'])) { SJB_Session::setValue('tmp_file_storage', array()); } $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); $contract = new SJB_Contract(array('contract_id' => $productSID)); $gallery = new SJB_ListingGallery(); $gallery->setListingSID($listing_id); $template_processor->assign("contract", $contract); if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { if (!isset($_FILES['picture'])) { $field_errors['Picture'] = 'FILE_NOT_SPECIFIED'; } elseif ($_FILES['picture']['error']) { switch ($_FILES['picture']['error']) { case '1': $field_errors['Picture'] = 'UPLOAD_ERR_INI_SIZE'; break; case '2': $field_errors['Picture'] = 'UPLOAD_ERR_FORM_SIZE'; break; case '3': $field_errors['Picture'] = 'UPLOAD_ERR_PARTIAL'; break; case '4': $field_errors['Picture'] = 'UPLOAD_ERR_NO_FILE'; break; default: break; } } else { $image_caption = isset($_REQUEST['caption']) ? $_REQUEST['caption'] : ''; $_FILES['picture']['caption'] = $image_caption; if (!$gallery->uploadImage($_FILES['picture']['tmp_name'], $image_caption)) { $field_errors['Picture'] = $gallery->getError(); } } } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { if (isset($_REQUEST['picture_id'])) { $picture_id = $_REQUEST['picture_id']; $gallery->deleteImageBySID($picture_id); } } if ($listingInfo) { $extraInfo = !empty($listingInfo['product_info']) ? unserialize($listingInfo['product_info']) : array(); } elseif ($contract && $contract->extra_info) { $extraInfo = $contract->extra_info; } elseif ($productInfo) { $extraInfo = !empty($productInfo['serialized_extra_info']) ? unserialize($productInfo['serialized_extra_info']) : array(); } $number_of_picture_allowed = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $number_of_picture = $gallery->getPicturesAmount(); $pictures_info = $gallery->getPicturesInfo(); $_SESSION['tmp_file_storage'] = $pictures_info; $template_processor->assign("listing", array('id' => "{$listing_id}")); $template_processor->assign("number_of_picture_allowed", $number_of_picture_allowed); $template_processor->assign("number_of_picture", $number_of_picture); $template_processor->assign('pictures', $_SESSION['tmp_file_storage']); } else { $listing = SJB_ListingManager::getObjectBySID($listing_id); if (is_null($listing)) { $errors['WRONG_PARAMETERS_SPECIFIED'] = 1; } else { $gallery = new SJB_ListingGallery(); $gallery->setListingSID($listing_id); $contract = new SJB_Contract(array('contract_id' => $productSID)); if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { if (!isset($_FILES['picture'])) { $field_errors['Picture'] = 'FILE_NOT_SPECIFIED'; } elseif ($_FILES['picture']['error']) { switch ($_FILES['picture']['error']) { case '1': $field_errors['Picture'] = 'UPLOAD_ERR_INI_SIZE'; break; case '2': $field_errors['Picture'] = 'UPLOAD_ERR_FORM_SIZE'; break; case '3': $field_errors['Picture'] = 'UPLOAD_ERR_PARTIAL'; break; case '4': $field_errors['Picture'] = 'UPLOAD_ERR_NO_FILE'; break; default: break; } } else { $image_caption = isset($_REQUEST['caption']) ? $_REQUEST['caption'] : ''; if (!$gallery->uploadImage($_FILES['picture']['tmp_name'], $image_caption)) { $field_errors['Picture'] = $gallery->getError(); } } } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { if (isset($_REQUEST['picture_id'])) { $gallery->deleteImageBySID($_REQUEST['picture_id']); } } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'move_up') { if (isset($_REQUEST['picture_id'])) { $gallery->moveUpImageBySID($_REQUEST['picture_id']); } } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'move_down') { if (isset($_REQUEST['picture_id'])) { $gallery->moveDownImageBySID($_REQUEST['picture_id']); } } if ($listingInfo) { $extraInfo = !empty($listingInfo['product_info']) ? unserialize($listingInfo['product_info']) : array(); } elseif ($contract && $contract->extra_info) { $extraInfo = $contract->extra_info; } $number_of_picture_allowed = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $number_of_picture = $gallery->getPicturesAmount(); $listing_info['id'] = $listing_id; $template_processor->assign("listing", $listing_info); $pictures_info = $gallery->getPicturesInfo(); $template_processor->assign("pictures", $pictures_info); $template_processor->assign("number_of_picture", $number_of_picture); $template_processor->assign("number_of_picture_allowed", $number_of_picture_allowed); } } $template_processor->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $template_processor->assign("errors", $errors); $template_processor->assign("field_errors", $field_errors); $template_processor->display("manage_pictures.tpl"); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $listingTypeID = SJB_Request::getVar('listing_type_id'); $listingTypeSID = SJB_Request::getVar('listing_type'); if ($listingTypeID !== null) { $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID); } // SET PAGINATION AND SORTING VALUES $restore = SJB_Request::getVar('restore', false); $paginator = new SJB_FlaggedListingsPagination(); // FILTERS $filters = array(); $filters['title'] = SJB_Request::getVar('filter_title'); $filters['username'] = SJB_Request::getVar('filter_user'); $filters['flag'] = SJB_Request::getVar('filter_flag'); // check session for pagination settings $sessionFlaggedSettings = !is_null(SJB_Session::getValue('flagged_settings')) ? SJB_Session::getValue('flagged_settings') : false; if ($sessionFlaggedSettings !== false) { if (!$restore) { SJB_Session::setValue('flagged_settings', array('filters' => $filters)); } else { if (!$listingTypeSID && !empty($sessionFlaggedSettings['listing_type_sid'])) { $listingTypeSID = $sessionFlaggedSettings['listing_type_sid']; } $filters = $sessionFlaggedSettings['filters']; } } else { SJB_Session::setValue('flagged_settings', array('filters' => $filters)); } // DEFAULT SORTING // resolve flag to it text value for search $filterFlag = $filters['flag']; if (!empty($filterFlag) && is_numeric($filterFlag)) { $result = SJB_DB::query('SELECT * FROM `flag_listing_settings` WHERE `sid` = ?n LIMIT 1', $filterFlag); if (!empty($result)) { $filters['flag_reason'] = $result[0]['value']; } } ////////////////////// ACTIONS $action = SJB_Request::getVar('action_name'); $flagSIDs = SJB_Request::getVar('flagged'); if (!empty($flagSIDs)) { switch ($action) { case 'remove': foreach ($flagSIDs as $sid => $val) { SJB_ListingManager::removeFlagBySID($sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); break; case 'deactivate': foreach ($flagSIDs as $sid => $val) { SJB_ListingManager::deactivateListingByFlagSID($sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); break; case 'delete': foreach ($flagSIDs as $sid => $val) { SJB_ListingManager::deleteListingByFlagSID($sid); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); break; } } //////////////////////// OUTPUT $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo(); $allFlags = SJB_ListingManager::getAllFlags(); $countFlaggedListings = SJB_ListingManager::getFlagsNumberByListingTypeSID($listingTypeSID, $filters); $paginator->setItemsCount($countFlaggedListings); $flaggedListings = SJB_ListingManager::getFlaggedListings($listingTypeSID, $paginator->currentPage, $paginator->itemsPerPage, $paginator->sortingField, $paginator->sortingOrder, $filters); if (empty($flaggedListings) && $paginator->currentPage != 1) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1'); } foreach ($flaggedListings as $key => $val) { $listingInfo = SJB_ListingManager::getListingInfoBySID($val['listing_sid']); $listingUser = SJB_UserManager::getUserInfoBySID($listingInfo['user_sid']); $flaggedUser = SJB_UserManager::getUserInfoBySID($val['user_sid']); $flaggedListings[$key]['listing_info'] = $listingInfo; $flaggedListings[$key]['user_info'] = $listingUser; $flaggedListings[$key]['flagged_user'] = $flaggedUser; } $tp->assign('paginationInfo', $paginator->getPaginationInfo()); $tp->assign('listing_types', $allListingTypes); $tp->assign('listings', $flaggedListings); $tp->assign('listing_type_sid', $listingTypeSID); $tp->assign('all_flags', $allFlags); $tp->assign('filters', $filters); $tp->display('flagged_listings.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $currentUser = SJB_UserManager::getCurrentUser(); $action = SJB_Request::getVar('action', false); $error = SJB_Request::getVar('error', false); $applyPromoCode = SJB_Request::getVar('applyPromoCode', false); $action = $applyPromoCode ? 'applyPromoCode' : $action; $numberOfListings = SJB_Request::getVar('number_of_listings'); $productInfo = null; $errors = array(); switch ($action) { case 'delete': $itemSID = SJB_Request::getVar('item_sid', 0, false, 'int'); if (SJB_UserManager::isUserLoggedIn()) { if (SJB_Settings::getSettingByName('allow_to_post_before_checkout') == true) { $this->findCheckoutedListingsByProduct($itemSID, $currentUser->getSID()); } SJB_ShoppingCart::deleteItemFromCartBySID($itemSID, $currentUser->getSID()); } else { $products = SJB_Session::getValue('products'); if (!empty($products[$itemSID])) { unset($products[$itemSID]); SJB_Session::setValue('products', $products); } } break; case 'checkout': if (SJB_UserManager::isUserLoggedIn()) { $products = SJB_Session::getValue('products'); $products = $products ? $products : array(); $trialProduct = false; foreach ($products as $product) { if (!empty($product['product_info'])) { $productInfo = unserialize($product['product_info']); if ($currentUser->getUserGroupSID() != $productInfo['user_group_sid']) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/?error=user_group"); } elseif (in_array($productInfo['sid'], $currentUser->getTrialProductSIDByUserSID())) { $trialProduct = true; } else { $product = new SJB_Product($productInfo, $productInfo['product_type']); $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1; $product->setNumberOfListings($number_of_listings); $productInfo['price'] = $product->getPrice(); SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUser->getSID()); } } } SJB_Session::unsetValue('products'); if ($trialProduct) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/?error=trial_product"); } elseif ($products) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/"); } $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID()); if (empty($products)) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/my-account/"); } $isRecurring = false; $subTotal = 0; foreach ($products as $key => $product) { $productInfo = unserialize($product['product_info']); if (!empty($productInfo['recurring'])) { $isRecurring = true; } if (!empty($productInfo['pricing_type']) == 'volume_based' && isset($numberOfListings[$productInfo['sid']][$product['sid']])) { $productInfo['number_of_listings'] = $numberOfListings[$productInfo['sid']][$product['sid']]; $productObj = new SJB_Product($productInfo, $productInfo['product_type']); $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1; $productObj->setNumberOfListings($number_of_listings); $productInfo['price'] = $productObj->getPrice(); if (!empty($productInfo['code_info'])) { SJB_PromotionsManager::applyPromoCodeToProduct($productInfo, $productInfo['code_info']); } SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo); } $subTotal += $productInfo['price']; $products[$key] = $productInfo; $products[$key]['item_sid'] = $product['sid']; $products[$key]['product_info'] = serialize($productInfo); } $index = 1; $items = array(); $codeInfo = array(); if ($isRecurring) { $tp->assign('confirmation', 1); $tp->assign('sub_total_price', $subTotal); } else { foreach ($products as $product) { $product_info = unserialize($product['product_info']); SJB_PromotionsManager::preparePromoCodeInfoByProductPromoCodeInfo($product, $product['code_info']); $qty = !empty($product_info['number_of_listings']) ? $product_info['number_of_listings'] : null; $items['products'][$index] = $product_info['sid']; if ($qty > 0) { $items['price'][$index] = round($product['price'] / $qty, 2); } else { $items['price'][$index] = round($product['price'], 2); } $items['amount'][$index] = $product['price']; $items['qty'][$index] = $qty; if (isset($product['custom_item'])) { $items['custom_item'][$index] = $product['custom_item']; } else { $items['custom_item'][$index] = ""; } if (isset($product['custom_info'])) { $items['custom_info'][$index] = $product['custom_info']; } else { $items['custom_info'][$index]['shoppingCartRecord'] = $product['item_sid']; } if ($product_info['product_type'] == 'banners' && !empty($product_info['banner_info'])) { $items['custom_info'][$index]['banner_info'] = $product_info['banner_info']; } $index++; SJB_PromotionsManager::preparePromoCodeInfoByProductPromoCodeInfo($product_info, $codeInfo); } $subUserInfo = $currentUser->getSubuserInfo(); $userSID = isset($subUserInfo['sid']) ? $subUserInfo['sid'] : $currentUser->getSID(); $invoiceSID = SJB_InvoiceManager::generateInvoice($items, $userSID, $subTotal, SJB_System::getSystemSettings('SITE_URL') . "/create-contract/"); SJB_PromotionsManager::addCodeToHistory($codeInfo, $invoiceSID, $userSID); if ($subTotal <= 0) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/create-contract/?invoice_sid=' . $invoiceSID); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/payment-page/?invoice_sid=" . $invoiceSID); } } } break; case 'applyPromoCode': $promotionCode = SJB_Request::getVar('promotion_code', false); if ($promotionCode) { if (SJB_UserManager::isUserLoggedIn()) { $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID()); } else { $products = SJB_Session::getValue('products'); $products = $products ? $products : array(); krsort($products); } $allowShoppingItems = array(); $productSIDs = array(); foreach ($products as $product) { $productInfo = unserialize($product['product_info']); if (!isset($productInfo['code_info'])) { if (isset($productInfo['custom_info'])) { $allowShoppingItems[] = $product['sid']; $productSIDs[] = $productInfo['custom_info']['productSid']; } else { $allowShoppingItems[] = $product['sid']; $productSIDs[] = $productInfo['sid']; } } else { $appliedPromoCode = $productInfo['code_info']; } } if ($codeInfo = SJB_PromotionsManager::checkCode($promotionCode, $productSIDs)) { $productSIDs = $codeInfo['product_sid'] ? explode(',', $codeInfo['product_sid']) : false; $appliedProducts = array(); $codeValid = false; foreach ($products as $key => $product) { $productInfo = unserialize($product['product_info']); if ($productInfo['sid'] != '-1') { $productSid = $productInfo['sid']; } else { $productSid = $productInfo['custom_info']['productSid']; } if ($productSIDs && in_array($productSid, $productSIDs) && $allowShoppingItems && in_array($product['sid'], $allowShoppingItems)) { $currentUsesCount = SJB_PromotionsManager::getUsesCodeBySID($codeInfo['sid']); if ($codeInfo['maximum_uses'] != 0 && $codeInfo['maximum_uses'] > $currentUsesCount || $codeInfo['maximum_uses'] == 0) { $codeValid = true; SJB_PromotionsManager::applyPromoCodeToProduct($productInfo, $codeInfo); $appliedProducts[] = $productInfo; if (SJB_UserManager::isUserLoggedIn()) { SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo); } else { $products[$key]['product_info'] = serialize($productInfo); SJB_Session::setValue('products', $products); } } } } if (!$codeValid) { $errors['NOT_VALID'] = 'Invalid promotion code'; unset($promotionCode); } $tp->assign('applied_products', $appliedProducts); $tp->assign('code_info', $codeInfo); } else { $errors['NOT_VALID'] = 'Invalid promotion code'; } if (isset($promotionCode) && isset($appliedPromoCode)) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/'); } } else { $errors['EMPTY_VALUE'] = 'Promotion code'; } break; case 'deletePromoCode': if (SJB_UserManager::isUserLoggedIn()) { $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID()); } else { $products = SJB_Session::getValue('products'); $products = $products ? $products : array(); krsort($products); } foreach ($products as $key => $product) { $productInfo = unserialize($product['product_info']); SJB_PromotionsManager::removePromoCodeFromProduct($productInfo); if (SJB_UserManager::isUserLoggedIn()) { $numberOfListings = is_array($numberOfListings) ? array_pop($numberOfListings) : false; if (is_array($numberOfListings)) { foreach ($numberOfListings as $listingSid => $listingsCount) { if ($listingSid == $product['sid']) { $productInfo['number_of_listings'] = $listingsCount; } } } SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo); } else { $products[$key]['product_info'] = serialize($productInfo); SJB_Session::setValue('products', $products); } } break; } if (SJB_UserManager::isUserLoggedIn()) { $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID()); // To display products in shopping cart after user has been registered from shopping cart page if (empty($products)) { $products = SJB_Session::getValue('products'); $products = $products ? $products : array(); } } else { $products = SJB_Session::getValue('products'); $products = $products ? $products : array(); krsort($products); } $allowShoppingItems = array(); foreach ($products as $product) { $productInfo = unserialize($product['product_info']); if (!empty($productInfo['code_info'])) { $promotionCode = $productInfo['code_info']['code']; $promotionCodeInfo = $productInfo['code_info']; } else { $allowShoppingItems[] = $product['sid']; } } $promotionCode = isset($promotionCode) ? $promotionCode : ''; $totalPrice = 0; $discountTotalAmount = 0; $numberOfListings = SJB_Request::getVar('number_of_listings', false); foreach ($products as $key => $product) { $productInfo = unserialize($product['product_info']); if ($allowShoppingItems && in_array($product['sid'], $allowShoppingItems)) { $this->applyPromoCodesToProduct($promotionCode, $productInfo); if (SJB_UserManager::isUserLoggedIn()) { SJB_ShoppingCart::updateItemBySID($product['sid'], $productInfo); } else { $products[$key]['product_info'] = serialize($productInfo); } } if ($numberOfListings && array_key_exists('number_of_listings', $productInfo) && array_key_exists($productInfo['sid'], $numberOfListings)) { $productInfo['number_of_listings'] = $numberOfListings[$productInfo['sid']][$product['sid']]; } $productObj = new SJB_Product($productInfo, $productInfo['product_type']); $productExtraInfo = unserialize($productInfo['serialized_extra_info']); if (!empty($productInfo['expiration_period']) && !is_numeric($productInfo['expiration_period'])) { $productInfo['primaryPrice'] = $productExtraInfo['price']; $productInfo['period'] = ucwords($productInfo['expiration_period']); } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') { $volumeBasedPricing = $productInfo['volume_based_pricing']; $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1; $productObj->setNumberOfListings($number_of_listings); $productInfo['price'] = $productObj->getPrice(); $productInfo['primaryPrice'] = $productObj->getPrice(); $this->applyPromoCodesToProduct($promotionCode, $productInfo); $minListings = min($volumeBasedPricing['listings_range_from']); $maxListings = max($volumeBasedPricing['listings_range_to']); $countListings = array(); for ($i = $minListings; $i <= $maxListings; $i++) { $countListings[$i]['number_of_listings'] = $i; for ($j = 1; $j <= count($volumeBasedPricing['listings_range_from']); $j++) { if ($i >= $volumeBasedPricing['listings_range_from'][$j] && $i <= $volumeBasedPricing['listings_range_to'][$j]) { $countListings[$i]['price'] = $volumeBasedPricing['price_per_unit'][$j] * $i; $countListings[$i]['primaryPrice'] = $volumeBasedPricing['price_per_unit'][$j] * $i; if (!empty($productInfo['code_info']['type'])) { switch ($productInfo['code_info']['type']) { case 'percentage': $countListings[$i]['price'] = round($countListings[$i]['price'] - $countListings[$i]['primaryPrice'] / 100 * $productInfo['code_info']['discount'], 2); $countListings[$i]['percentPromoAmount'] = round($countListings[$i]['primaryPrice'] - $countListings[$i]['price'], 2); $countListings[$i]['percentPromoCode'] = $productInfo['code_info']['code']; break; case 'fixed': $countListings[$i]['price'] = round($countListings[$i]['price'] - $productInfo['code_info']['discount'], 2); break; } } } } } $productInfo['count_listings'] = $countListings; } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') { $productInfo['primaryPrice'] = $productObj->getPrice(); $this->applyPromoCodesToProduct($promotionCode, $productInfo); unset($productInfo['volume_based_pricing']); } if (isset($productInfo['code_info'])) { if ($productInfo['code_info']['type'] != 'fixed' && isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') { $discountTotalAmount += (double) $productInfo['count_listings'][$productInfo['number_of_listings']]['percentPromoAmount']; } else { $discountTotalAmount += (double) $productInfo['code_info']['promoAmount']; } } if (empty($productInfo['volume_based_pricing'])) { $productInfo['primaryPrice'] = $productExtraInfo['price']; $this->applyPromoCodesToProduct($promotionCode, $productInfo); $totalPrice += (double) $productInfo['price']; } $products[$key] = $productInfo; $products[$key]['item_sid'] = $product['sid']; } if ($currentUser) { $taxInfo = SJB_TaxesManager::getTaxInfoByUserSidAndPrice($currentUser->getSID(), $totalPrice); $tp->assign('tax', $taxInfo); } $userGroupID = $productInfo ? SJB_UserGroupDBManager::getUserGroupIDBySID($productInfo['user_group_sid']) : false; $tp->assign('promotionCodeAlreadyUsed', $promotionCode && empty($errors)); if (isset($promotionCodeInfo)) { $tp->assign('promotionCodeInfo', $promotionCodeInfo); } $tp->assign('error', $error); $tp->assign('errors', $errors); $tp->assign('total_price', $totalPrice); $tp->assign('discountTotalAmount', $discountTotalAmount); $tp->assign('products', $products); $tp->assign('userGroupID', $userGroupID); $tp->assign('account_activated', SJB_Request::getVar('account_activated', '')); $tp->display('shopping_cart.tpl'); }
public function execute() { $logged_in = false; $tp = SJB_System::getTemplateProcessor(); $shoppingCart = SJB_Request::getVar('shopping_cart', false); $proceedToPosting = SJB_Request::getVar('proceed_to_posting', false); $productSID = SJB_Request::getVar('productSID', false); $listingTypeID = SJB_Request::getVar('listing_type_id', false); $errors = array(); if (SJB_Authorization::isUserLoggedIn() && !isset($_REQUEST['as_user'])) { $tp->display('already_logged_in.tpl'); } else { $template = SJB_Request::getVar('template', 'login.tpl'); $page_config = SJB_System::getPageConfig(SJB_System::getURI()); if (SJB_Request::getVar('action', false) == 'login') { $username = SJB_Request::getVar('username'); $password = SJB_Request::getVar('password'); $keep_signed = SJB_Request::getVar('keep', false); $login_as_user = false; if (isset($_REQUEST['as_user'])) { $login_as_user = true; if (SJB_UserManager::getCurrentUserSID()) { SJB_Authorization::logout(); } } // redirect user to the home page if it's login page or to the same page otherwise if (SJB_Request::getVar('return_url', false) != false) { $redirect_url = base64_decode(SJB_Request::getVar('return_url')); if (!empty($proceedToPosting)) { $redirect_url .= '&proceed_to_posting=1&productSID=' . $productSID; } } else { if ($page_config->module == 'users' && $page_config->function == 'login') { $redirect_url = SJB_System::getSystemSettings("SITE_URL") . "/my-account/"; } else { $redirect_url = SJB_System::getSystemSettings("SITE_URL") . SJB_System::getURI(); } } if (SJB_UserManager::getCurrentUserSID()) { $logged_in = true; } else { SJB_UserManager::login($username, $password, $errors, false, $login_as_user); if ($errors) { if (is_null(SJB_Session::getValue('userLoginCounter'))) { SJB_Session::setValue('userLoginCounter', 1); } else { SJB_Session::setValue('userLoginCounter', SJB_Session::getValue('userLoginCounter') + 1); } } if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors) && empty($errors)) { $logged_in = SJB_Authorization::login($username, $password, $keep_signed, $errors, $login_as_user); } } if ($logged_in && !$shoppingCart) { SJB_HelperFunctions::redirect($redirect_url); } $tp->assign('logged_in', $logged_in); } $return_url = SJB_Request::getVar('return_url', $page_config->function != 'login' && $page_config->function != 'search_form' ? base64_encode(SJB_Navigator::getURIThis()) : false); if (!filter_var(SJB_System::getSystemSettings("SITE_URL") . base64_decode($return_url), FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) { $return_url = ''; } $tp->assign('shopping_cart', $shoppingCart); $tp->assign('proceedToPosting', $proceedToPosting); $tp->assign('productSID', $productSID); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('return_url', $return_url); $tp->assign('ajaxRelocate', SJB_Request::getVar('ajaxRelocate', false)); $tp->assign('errors', $errors); $tp->assign('adminEmail', SJB_System::getSettingByName('system_email')); $tp->display($template); } }