/** * returns current active language id * @return mixed */ function execute() { $existLanguage = $this->fetchExistLanguage(); if ($existLanguage !== $this->context->getLang()) { $this->context->setLang($existLanguage); $theme = $this->context->getTheme(); if (!empty($theme)) { $this->session->setValue('CURRENT_THEME', $theme); } } return $this->context->getLang(); }
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); }
/** * logging into system as administrator * * Function logs administrator into system. * If operation succeded it registers session variables 'username' and 'usertype' * * @param string $username user's name * @param string $password user's password * @return bool 'true' if operation succeeded or 'false' otherwise */ public static function admin_login($username) { SJB_Session::setValue('username', SJB_DB::quote($username)); SJB_Session::setValue('usertype', 'admin'); SJB_Session::setValue('adminLoginCounter', 1); setcookie('admin_mode', 'on', null, '/'); return true; }
/** * logging into system as administrator * Function logs administrator into system. * If operation succeded it registers session variables 'username' and 'usertype' * @param string $username user's name * @param string $password user's password * @return bool 'true' if operation succeeded or 'false' otherwise */ public static function admin_login($username) { $username = SJB_DB::quote($username); SJB_SubAdmin::setAdminInfo($username); SJB_Session::setValue('adminLoginCounter', 1); SJB_Session::setValue('username', $username); SJB_Session::setValue('usertype', "subadmin"); setcookie("admin_mode", 'on', null, '/'); return true; }
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 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; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $activated = SJB_Request::getVar('account_activated', '') == 'yes'; if (SJB_Request::getVar('returnToShoppingCart', false)) { SJB_Session::setValue('fromAnonymousShoppingCart', 1); } if (!$activated) { if (!isset($_REQUEST['username'], $_REQUEST['activation_key'])) { $errors['PARAMETERS_MISSED'] = 1; } elseif (!($userInfo = SJB_UserManager::getUserInfoByUserName($_REQUEST['username']))) { $errors['USER_NOT_FOUND'] = 1; } elseif ($userInfo['activation_key'] != $_REQUEST['activation_key']) { $errors['INVALID_ACTIVATION_KEY'] = true; } elseif ($userInfo['approval'] == 'Rejected') { SJB_UserDBManager::deleteActivationKeyByUsername($_REQUEST['username']); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/system/users/activate_account/?account_activated=no&approval_status=Rejected'); } else { if (SJB_UserManager::activateUserByUserName($_REQUEST['username'])) { SJB_UserDBManager::deleteActivationKeyByUsername($_REQUEST['username']); if (!SJB_Authorization::isUserLoggedIn()) { SJB_Authorization::login($_REQUEST['username'], false, false, $errors, true, true); if (!SJB_SocialPlugin::getProfileSocialID($userInfo['sid'])) { SJB_Notifications::sendUserWelcomeLetter($userInfo['sid']); } $requireApprove = SJB_UserGroupManager::isApproveByAdmin($userInfo['user_group_sid']); if ($requireApprove && !empty($userInfo['approval'])) { $approvalStatus = $userInfo['approval']; } else { $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']); $pageId = !empty($userGroupInfo['after_registration_redirect_to']) ? $userGroupInfo['after_registration_redirect_to'] : ''; $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId); SJB_HelperFunctions::redirect($redirectUrl . 'account_activated=yes'); } } $activated = 1; } else { $errors['CANNOT_ACTIVATE'] = TRUE; } } } $tp->assign('activated', $activated); $tp->assign('errors', $errors); $tp->assign('approvalStatus', !empty($approvalStatus) ? $approvalStatus : SJB_Request::getVar('approval_status', '')); $tp->assign('isLoggedIn', SJB_Authorization::isUserLoggedIn()); $tp->display('activate_account.tpl'); }
public function execute() { $action = SJB_Request::getVar('action', ''); $tp = SJB_System::getTemplateProcessor(); $errors = array(); $formSubmitted = !empty($action) ? true : false; $adminCurrentDetails = SJB_AdminPasswordManager::getCurrentAdminDetails(); $adminDetails = array_merge($adminCurrentDetails, $_REQUEST); $admin = new SJB_AdminPassword($adminDetails); $admin->setSID($adminCurrentDetails['sid']); $adminPasswordForm = new SJB_Form($admin); $adminPasswordForm->registerTags($tp); $formFields = $adminPasswordForm->getFormFieldsInfo(); if ($formSubmitted) { if (SJB_System::getSystemSettings("isDemo")) { $errors['PERMISSION_DENIED'] = "You don't have permissions for it. This is a Demo version of the software."; } else { if ($action == 'change_admin_account' && $adminPasswordForm->isDataValid($errors)) { $oldPassword = $admin->getPropertyValue('password'); $newPassword = SJB_AdminPasswordManager::getNewPasswordValue($adminDetails); if ($adminCurrentDetails['password'] != md5($oldPassword)) { $errors['Password'] = '******'; } else { if ($newPassword) { $admin->setPropertyValue('password', $newPassword); } $admin->deleteProperty('new_password'); SJB_AdminPasswordManager::saveAdmin($admin); SJB_Session::setValue('username', $admin->getPropertyValue('username')); } } } } $tp->assign('action', $action); $tp->assign('errors', $errors); $tp->assign('adminInfo', SJB_AdminPasswordManager::getCurrentAdminDetails()); $tp->assign("form_fields", $formFields); $tp->display("adminpswd.tpl"); }
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 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); } }
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 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(); $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'); } }
private function setSessionValueForRedirectAfterRegister() { $refererUri = SJB_Request::getVar('HTTP_REFERER', null, 'SERVER'); if ($refererUri) { $refererUri = parse_url($refererUri); if (basename($refererUri['path']) != 'registration') { if (basename($refererUri['path']) != 'add-listing') { SJB_Session::unsetValue('proceed_to_posting'); SJB_Session::unsetValue('productSID'); SJB_Session::unsetValue('listing_type_id'); } if (basename($refererUri['path']) != 'shopping-cart') { SJB_Session::unsetValue('fromShoppingCart'); } else { if (SJB_Request::getVar('fromShoppingCart', false)) { SJB_Session::setValue('fromAnonymousShoppingCart', true); } } } } }
protected static function flagSocialPluginInSession($network) { SJB_Session::setValue('sn', array('authorized' => true, 'network' => $network)); }
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; } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $current_user = SJB_UserManager::getCurrentUser(); $currentUserInfo = SJB_UserManager::getCurrentUserInfo(); $tp->assign('current_user', $currentUserInfo); $errors = array(); $error = ''; $listing_id = SJB_Request::getVar('listing_id', null, 'default', 'int'); if (SJB_UserGroupManager::getUserGroupIDBySID($current_user->user_group_sid) == 'Employer') { $template = SJB_Request::getVar('input_template', 'copy_listing.tpl'); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-listings/Job/'); } //getting $tmp_listing_id from request $tmp_listing_id_from_request = SJB_Request::getVar('tmp_listing_id', false, 'default', 'int'); $listing_info = SJB_ListingManager::getListingInfoBySID($listing_id); $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing_info['listing_type_sid']); if ($productsInfo = $this->canCurrentUserAddListing($error, $listing_type_id)) { $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_info['listing_type_sid']); 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(); } $gallery = new SJB_ListingGallery(); $gallery->setListingSID($listing_info['sid']); $pictures_info = $gallery->getPicturesInfo(); $gallery->setListingSID($tmp_listing_sid); $pictures_info_new = $gallery->getPicturesInfo(); //reuploading pictures if (!$pictures_info_new) { foreach ($pictures_info as $v) { if (!$gallery->uploadImage($v['picture_url'], $v['caption'])) { $field_errors['Picture'] = $gallery->getError(); } } } $contractID = SJB_Request::getVar('contract_id', false, 'default', 'int'); if ($contractID) { $contract = new SJB_Contract(array('contract_id' => $contractID)); } elseif (count($productsInfo) == 1) { $productInfo = array_pop($productsInfo); $contractID = $productInfo['contract_id']; $contract = new SJB_Contract(array('contract_id' => $contractID)); } else { $tp->assign('listing_id', $listing_id); $tp->assign("products_info", $productsInfo); $tp->assign("listing_type_id", $listing_type_id); $tp->display("listing_product_choice.tpl"); } if ($contractID) { $tp->assign('tmp_listing_id', $tmp_listing_sid); $extraInfo = $contract->extra_info; $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $tp->assign("pic_limit", $numberOfPictures); $tp->assign('contractID', $contractID); if ($listing_info['user_sid'] != SJB_UserManager::getCurrentUserSID()) { $errors['NOT_OWNER_OF_LISTING'] = $listing_id; } elseif (!is_null($listing_info)) { $listing_info = array_merge($listing_info, $_REQUEST); $listing = new SJB_Listing($listing_info, $listing_info['listing_type_sid']); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('status'); $listing->deleteProperty('reject_reason'); $listing->setSID($listing_id); $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($current_user->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($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($current_user->getSID()), 'is_system' => true)); } } else { $listing->deleteProperty('screening_questionnaire'); } $listing_edit_form = new SJB_Form($listing); $listing_edit_form->registerTags($tp); $extraInfo = $listing_info['product_info']; if ($extraInfo) { $extraInfo = unserialize($extraInfo); $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $tp->assign("pic_limit", $numberOfPictures); } $form_is_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'save_info' || isset($_REQUEST['action']) && $_REQUEST['action'] == 'add'; $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contractID, 'is_system' => true)); $delete = SJB_Request::getVar('action', '') == 'delete'; $field_errors = null; if ($delete && isset($_REQUEST['field_id'])) { $field_id = $_REQUEST['field_id']; $listing->details->properties[$field_id]->type->property_info['value'] = null; } elseif ($form_is_submitted && $listing_edit_form->isDataValid($field_errors)) { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); $listing->setUserSID($current_user->getSID()); $extraInfo = $contract->extra_info; $listing->setProductInfo($extraInfo); $listing->sid = null; if (!empty($listing_info['subuser_sid'])) { $listing->addSubuserProperty($listing_info['subuser_sid']); } $listingSidsForCopy = array('filesFrom' => $listing_id, 'picturesFrom' => $tmp_listing_sid); SJB_ListingManager::saveListing($listing, $listingSidsForCopy); // >>> 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); } // clean temporary field storage $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}"); } //and remove token key from temporary storage $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}"); // clear temporary data in session storage SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage); $listingSidsForCopy = array('filesFrom' => $listing_id, 'picturesFrom' => $listing_id); SJB_ListingManager::saveListing($listing, $listingSidsForCopy); } // <<< SJB-1197 SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']); $contract->incrementPostingsNumber(); SJB_ProductsManager::incrementPostingsNumber($contract->product_sid); // is listing featured by default if ($extraInfo['featured']) { SJB_ListingManager::makeFeaturedBySID($listing->getSID()); } if ($extraInfo['priority']) { SJB_ListingManager::makePriorityBySID($listing->getSID()); } SJB_ListingManager::activateListingBySID($listing->getSID()); SJB_AdminNotifications::sendAdminListingAddedLetter($listing); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listing_type_id) . '/?listing_id=' . $listing->getSID()); } elseif ($form_is_submitted) { $field_id = 'video'; if (!isset($_REQUEST['video_hidden']) && $listing->getPropertyValue($field_id)) { $listing->details->properties[$field_id]->type->property_info['value'] = null; } } $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing); $form_fields = $listing_edit_form->getFormFieldsInfo(); $listing_fields_by_page = array(); $countPages = count($pages); $i = 1; foreach ($pages as $page) { $listing_fields_by_page[$page['page_name']] = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']); if ($i == $countPages && isset($form_fields['screening_questionnaire'])) { $listing_fields_by_page[$page['page_name']]['screening_questionnaire'] = $form_fields['screening_questionnaire']; } 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]); } } $i++; } $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); $contract_id = $listing_info['contract_id']; $contract = new SJB_Contract(array('contract_id' => $contract_id)); $tp->assign('contract_id', $contract_id); $tp->assign('contract', $contract->extra_info); $tp->assign('countPages', count($listing_fields_by_page)); $tp->assign('copy_listing', 1); $tp->assign('tmp_listing_id', $tmp_listing_sid); $tp->assign('listing_id', $listing_id); $tp->assign('contractID', $contractID); $tp->assign('listing', $listing_structure); $tp->assign('pages', $listing_fields_by_page); $tp->assign('field_errors', $field_errors); } $tp->assign('errors', $errors); $tp->display($template); } } else { $listing_type_id = isset($listing_info['listing_type_sid']) ? $listing_info['listing_type_sid'] : false; if ($error == 'NO_CONTRACT') { if ($_GET) { $getParam = '?'; foreach ($_GET as $key => $val) { $getParam .= $key . '=' . $val . '&'; } $getParam = substr($getParam, 0, -1); } $page = base64_encode(SJB_System::getURI() . $getParam); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-products/?page=' . $page); } $tp->assign('clone_job', 1); $tp->assign('listing_type_id', $listing_type_id); $tp->assign('error', $error); $tp->display('add_listing_error.tpl'); } }
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; }
<?php require_once 'phpbb_bridge_plugin.php'; $userSession = PhpBBBridgePlugin::getUserSessionBySessionId(SJB_Session::getSessionId()); if (!empty($userSession)) { if (SJB_UserManager::isUserLoggedIn()) { if ($userSession['user_sid'] !== SJB_UserManager::getCurrentUserSID()) { if (!$userSession['user_sid']) { SJB_Authorization::logout(); } else { SJB_Session::setValue('current_user', PhpBBBridgePlugin::sessionDecode($userSession['data'])); } } } else { SJB_Session::setValue('current_user', PhpBBBridgePlugin::sessionDecode($userSession['data'])); } } SJB_Event::handle('Login', array('PhpBBBridgePlugin', 'login')); SJB_Event::handle('Logout', array('PhpBBBridgePlugin', 'logout'));
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() { $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"); }
/** * @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(); $parent_name = null; $user_sid = SJB_Request::getVar('user_sid', false); if (!is_null($user_sid)) { $user_info = SJB_UserManager::getUserInfoBySID($user_sid); $user_info = array_merge($user_info, $_REQUEST); $form_submitted = SJB_Request::getVar('action_name'); $user = new SJB_User($user_info, $user_info['user_group_sid']); if (!empty($user_info['parent_sid'])) { $props = $user->getProperties(); $allowedProperties = array('username', 'email', 'password'); foreach ($props as $prop) { if (!in_array($prop->getID(), $allowedProperties)) { $user->deleteProperty($prop->getID()); } } $parent_name = SJB_UserManager::getUserNameByUserSID($user_info['parent_sid']); } $user->setSID($user_info['sid']); $user->getProperty('email')->type->disableEmailConfirmation(); $user->deleteProperty("active"); $user->makePropertyNotRequired("password"); if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) { if ($form_submitted) { $email = $user->getPropertyValue('email'); if (is_array($email)) { $email = $email['original']; } $user->setPropertyValue('username', $email); } } $user->addExtUserIDProperty($user_info['extUserID']); $edit_user_form = new SJB_Form($user); $errors = array(); if ($form_submitted && $edit_user_form->isDataValid($errors)) { $password_value = $user->getPropertyValue('password'); $properties = null; if (empty($password_value['original'])) { $properties = $user->getProperties(); $user->deleteProperty('password'); } SJB_UserManager::saveUser($user); // >>> 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 if (SJB_Request::isAjax()) { echo "<p class=\"green\">User Saved</p>"; exit; } if ($form_submitted == 'save_info') { $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-users/" . mb_strtolower($userGroupInfo['id'], 'utf8')); } if (!empty($properties)) { $user->details->properties = $properties; } } if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) { $user->deleteProperty("username"); } $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo(); $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($user_info['user_group_sid']); $allowedListingTypes = array(); foreach ($products as $product) { if (!empty($product['listing_type_sid']) && empty($allowedListingTypes[$product['listing_type_sid']])) { foreach ($listingTypes as $listingType) { if ($product['listing_type_sid'] == $listingType['sid']) { $allowedListingTypes[$product['listing_type_sid']] = $listingType; } } } } $edit_user_form = SJB_ObjectMother::createForm($user); $edit_user_form->registerTags($tp); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']); if (SJB_UserManager::checkBan($errors, $user_info['ip'])) { $user_info['ip_is_banned'] = 1; } $tp->assign("form_fields", $edit_user_form->getFormFieldsInfo()); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->assign("errors", $errors); $tp->assign("listingTypes", $allowedListingTypes); $tp->assign("user_info", $user_info); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('userTree', true); $tp->assign("parent_name", $parent_name); $tp->assign("restore", preg_match('/manage-(jobseekers)|(employers)|([a-z0-9\\_]-users)/', SJB_Request::getVar('HTTP_REFERER', '', 'SERVER'))); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->display("edit_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; }
/** * @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() { $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); }
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() { $tp = SJB_System::getTemplateProcessor(); $restore = SJB_Request::getVar('restore', false); $action = SJB_Request::getVar('action_name', 'view_log'); $action = $action == 'search' ? 'view_log' : $action; $paginator = new SJB_EmailLogPagination(); $display_error = SJB_Request::getVar('display_error', false); $savedErrors = SJB_Session::getValue(self::EMAIL_ERRORS); SJB_Session::unsetValue(self::EMAIL_ERRORS); $this->errors = $savedErrors ? $savedErrors : array(); $message = SJB_Session::getValue(self::EMAIL_LOG_MESSAGE); SJB_Session::unsetValue(self::EMAIL_LOG_MESSAGE); switch ($action) { case 'display_message': $sid = SJB_Request::getVar('sid', false); $email = SJB_EmailLogManager::getEmailInfoBySID($sid); $tp->assign('display_error', $display_error); $tp->assign('email', $email); $tp->display('display_log_message.tpl'); return true; break; case 'resend': try { SJB_Settings::saveSetting(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION, SJB_Request::getVar(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION)); $this->resendEmails(); SJB_Session::setValue(self::EMAIL_LOG_MESSAGE, 'The message(s) were successfully resent.'); } catch (Exception $e) { array_push($this->errors, $e->getMessage()); } SJB_Session::setValue(self::EMAIL_ERRORS, $this->errors); $searchFields = SJB_Request::getVar('searchFields'); SJB_HelperFunctions::redirect(SJB_HelperFunctions::getSiteUrl() . '/email-log/?sorting_field=' . $paginator->sortingField . '&sorting_order=' . $paginator->sortingOrder . '&items_per_page=' . $paginator->itemsPerPage . $searchFields); break; case 'view_log': $userSID = SJB_Request::getVar('user_sid', false); if ($userSID) { $template = 'user_email_log.tpl'; $_REQUEST['username']['equal'] = $userSID; $userInfo = SJB_UserManager::getUserInfoBySID($userSID); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']); $tp->assign('userGroupInfo', $userGroupInfo); $tp->assign('display_error', $display_error); $tp->assign('user_info', $userInfo); $tp->assign('user_sid', $userSID); } $email = new SJB_EmailLog($_REQUEST); $search_form_builder = new SJB_SearchFormBuilder($email); $criteria_saver = new SJB_EmailLogCriteriaSaver(); if ($restore) { $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria()); } $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $email); if (!$userSID) { $template = 'email_log.tpl'; $search_form_builder->setCriteria($criteria); $search_form_builder->registerTags($tp); $tp->display("email_log_search_form.tpl"); } $order_info = array('sorting_field' => $paginator->sortingField, 'sorting_order' => $paginator->sortingOrder); $criteria_saver->setSessionForOrderInfo($order_info); $criteria_saver->setSessionForCurrentPage($paginator->currentPage); $criteria_saver->setSessionForListingsPerPage($paginator->itemsPerPage); $searcher = new SJB_EmailLogSearcher(array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage), $paginator->sortingField, $paginator->sortingOrder); $found_emails = $searcher->getObjectsSIDsByCriteria($criteria); $criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs()); foreach ($found_emails as $id => $emailSID) { $emailInfo = SJB_EmailLogManager::getEmailInfoBySID($emailSID); $found_emails[$id] = $emailInfo; $found_emails[$id]['user'] = !empty($emailInfo['username']) ? SJB_UserManager::getUserInfoBySID($emailInfo['username']) : array(); $found_emails[$id]['admin'] = array(); if (!empty($emailInfo['admin'])) { if (is_numeric($emailInfo['admin'])) { $found_emails[$id]['admin'] = SJB_SubAdminManager::getSubAdminInfoBySID($emailInfo['admin']); } else { $found_emails[$id]['admin']['username'] = '******'; } } } $paginator->setItemsCount($searcher->getAffectedRows()); $searchFields = ''; foreach ($_REQUEST as $key => $val) { if (is_array($val)) { foreach ($val as $fieldName => $fieldValue) { $searchFields .= "&{$key}[{$fieldName}]={$fieldValue}"; } } } $tp->assign(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION, SJB_Settings::getSettingByName(self::DO_NOT_SHOW_ATTACHMENT_NOTIFICATION)); $tp->assign('message', $message); $tp->assign('errors', $this->errors); $tp->assign("searchFields", $searchFields); $tp->assign('paginationInfo', $paginator->getPaginationInfo()); $tp->assign("found_emails", $found_emails); $tp->display($template); break; } }