public function execute() { $listing_id = isset($_REQUEST['listing_id']) ? $_REQUEST['listing_id'] : null; $listing = SJB_ListingManager::getObjectBySID($listing_id); $current_user = SJB_UserManager::getCurrentUser(); $template_processor = SJB_System::getTemplateProcessor(); if (is_null($listing_id)) { $errors['PARAMETERS_MISSED'] = 1; } elseif (empty($current_user)) { $errors['NOT_LOGGED_IN'] = 1; } elseif (is_null($listing)) { $errors['WRONG_PARAMETERS_SPECIFIED'] = 1; } elseif ($listing->getUserSID() != $current_user->getSID()) { $errors['NOT_OWNER'] = 1; } else { $productInfo = $listing->getProductInfo(); $listing_info = SJB_ListingManager::getListingInfoBySID($listing_id); $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_info['listing_type_sid']); $waitApprove = $listing_type_info['waitApprove']; $listing_info['type'] = array('id' => $listing_type_info['id'], 'caption' => $listing_type_info['name']); $listing_info['product'] = $productInfo; $template_processor->assign("listing", $listing_info); $contract_id = $listing_info['contract_id']; $template_processor->assign("waitApprove", $waitApprove); } $template_processor->assign("errors", isset($errors) ? $errors : null); $template_processor->display("manage_listing.tpl"); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $user = SJB_UserManager::getCurrentUser(); if ($user) { $userNotificationsManager = new SJB_UserNotificationsManager($user); $userNotificationsInfo = $userNotificationsManager->getUserNotificationsInfo(); $userNotificationsInfo = array_merge($userNotificationsInfo, $_REQUEST); $userNotifications = new SJB_UserNotifications($userNotificationsInfo); $userNotificationsForm = new SJB_Form($userNotifications); $userNotificationsForm->registerTags($tp); $userNotificationsFields = $userNotificationsForm->getFormFieldsInfo(); $tp->assign('form_fields', $userNotificationsFields); if (SJB_Request::getVar('action') === 'save') { $errors = array(); if ($userNotificationsForm->isDataValid($errors)) { $userNotifications->update(); $tp->assign('isSaved', true); } $tp->assign('errors', $errors); } $tp->assign('userNotificationGroups', $userNotificationsManager->getNotificationGroups()->getGroups()); $tp->assign('userNotifications', $userNotificationsManager->getEnabledForGroupUserNotifications()); $listingTypes = SJB_ListingTypeManager::getListingTypeByUserSID($user->getSID()); $approveSetting = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listingTypes); $tp->assign('approve_setting', $approveSetting); $tp->display('user_notifications.tpl'); } else { $tp->display('login.tpl'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $count_listing = SJB_Request::getVar('count_listing', 10, null, 'int'); $current_user = SJB_UserManager::getCurrentUser(); if (SJB_UserManager::isUserLoggedIn()) { $lastAddedListing = SJB_ListingManager::getLastAddedListingByUserSID($current_user->getSID()); if ($lastAddedListing) { $properties = $current_user->getProperties(); $phrase['title'] = $lastAddedListing->getPropertyValue('Title'); foreach ($properties as $property) { if ($property->getType() == 'location') { $fields = $property->type->child; $childProperties = $fields->getProperties(); foreach ($childProperties as $childProperty) { if (in_array($childProperty->getID(), array('City', 'State', 'Country'))) { $value = $childProperty->getValue(); switch ($childProperty->getType()) { case 'list': if ($childProperty->getID() == 'State') { $displayAS = $childProperty->display_as; $displayAS = $displayAS ? $displayAS : 'state_name'; $listValues = SJB_StatesManager::getStatesNamesByCountry(false, true, $displayAS); } else { $listValues = $childProperty->type->list_values; } foreach ($listValues as $values) { if ($value == $values['id']) { $phrase[strtolower($childProperty->getID())] = $values['caption']; } } break; default: $phrase[strtolower($childProperty->getID())] = $value; break; } } } } } $phrase = array_diff($phrase, array('')); $phrase = implode(" ", $phrase); $listing_type_id = "Job"; $request['action'] = 'search'; $request['listing_type']['equal'] = $listing_type_id; $request['default_listings_per_page'] = $count_listing; $request['default_sorting_field'] = "activation_date"; $request['default_sorting_order'] = "DESC"; $request['keywords']['relevance'] = $phrase; $searchResultsTP = new SJB_SearchResultsTP($request, $listing_type_id, array('field' => 'keywords', 'value' => $phrase)); $tp = $searchResultsTP->getChargedTemplateProcessor(); } $tp->display('suggested_jobs.tpl'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $sid = false; if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } $cu = SJB_UserManager::getCurrentUser(); if (!isset($cu->user_group_sid)) { $userGroupSID = 0; } else { $userGroupSID = $cu->user_group_sid; } $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; if ($sid && SJB_PollsManager::isActive($sid, $userGroupSID, $langId)) { $countVotes = SJB_PollsManager::getCountVotesBySID($sid); $pollResults = SJB_PollsManager::getPollResultsBySID($sid); $result = array(); $i = 0; $colors = array('613978', 'aad434', 'f55c00', 'f9c635', 'f97c9e', '870000', '0ec300', '6f6f6f', '0400a5', '6eeffb', '000000', 'ff00ff'); foreach ($pollResults as $poll) { $result[$i]['vote'] = $countVotes > 0 ? round(100 / $countVotes * $poll['count'], 2) : 0; $result[$i]['value'] = $poll['question']; $result[$i]['color'] = $colors[$i]; $i++; } $pollInfo = SJB_PollsManager::getPollInfoBySID($sid); $tp->assign('pollInfo', $pollInfo); $tp->assign('result', $result); $tp->assign('width', count($pollResults) * 40 + (count($pollResults) - 1) * 3); $tp->assign('show_total_votes', isset($pollInfo['show_total_votes']) ? $pollInfo['show_total_votes'] : 0); $tp->assign('count_vote', $countVotes); } else { $pollInfo = SJB_PollsManager::getPollInfoBySID($sid); if ($pollInfo['language'] != $langId) { $errors[] = 'This poll is not available for this language'; } } $tp->assign('errors', $errors); $tp->display('poll_results.tpl'); }
public function execute() { if (SJB_Authorization::isUserLoggedIn() && class_exists('SJB_SocialPlugin') && !SJB_SocialPlugin::getProfileObject() && ($socPlugins = SJB_SocialPlugin::getAvailablePlugins())) { $tp = SJB_System::getTemplateProcessor(); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID(SJB_UserManager::getCurrentUser()->user_group_sid); /** * delete from plugins array plugins that are not allowed * for this userGroup registration */ SJB_SocialPlugin::preparePluginsThatAreAvailableForRegistration($socPlugins, $userGroupInfo['id']); if (empty($socPlugins)) { return null; } $socialNetworks = SJB_SocialPlugin::getSocialNetworks($socPlugins); $tp->assign('label', 'link'); $tp->assign('social_plugins', $socialNetworks); $tp->display('social_plugins.tpl'); } }
public function execute() { $template = SJB_Request::getVar('display_template', 'my_reports.tpl'); $action = SJB_Request::getVar('action', 'quickStat'); $tp = SJB_System::getTemplateProcessor(); $errors = array(); $currentUser = SJB_UserManager::getCurrentUser(); if (empty($currentUser)) { $tp->assign('ERROR', 'NOT_LOGIN'); $tp->display('../miscellaneous/error.tpl'); return; } else { if (SJB_UserGroupManager::getUserGroupIDBySID($currentUser->getUserGroupSID()) == 'Employer') { switch ($action) { case 'generalStat': $generalStat = SJB_Statistics::getEmployerGeneralStatistics($currentUser->getSID()); $tp->assign('generalStat', $generalStat); break; case 'jobsStat': $active = SJB_Request::getVar('active', 1); $sortingField = SJB_Request::getVar('sortingField', 'postedDate'); $sortingOrder = SJB_Request::getVar('sortingOrder', 'DESC'); $jobsStat = SJB_Statistics::getEmployerJobsStatistics($currentUser->getSID(), $active, $sortingField, $sortingOrder); $tp->assign('jobsStat', $jobsStat); $tp->assign('active', $active); $tp->assign('sortingField', $sortingField); $tp->assign('sortingOrder', $sortingOrder); break; case 'quickStat': $quickStat = SJB_Statistics::getEmployerQuickStatistics($currentUser->getSID()); $tp->assign('quickStat', $quickStat); break; default: break; } } else { $errors['NOT_EMPLOYER'] = true; } } $tp->assign('errors', $errors); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $currentUser = SJB_UserManager::getCurrentUser(); $products = array(); if (!empty($_SESSION['products'])) { $products = $_SESSION['products']; } if (SJB_UserManager::isUserLoggedIn()) { foreach ($products as $product) { if (!empty($product['product_info'])) { $productInfo = unserialize($product['product_info']); if ($currentUser->getUserGroupSID() != $productInfo['user_group_sid']) { SJB_Session::unsetValue('products'); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/?error=user_group"); } else { SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUser->getSID()); } } } SJB_Session::unsetValue('products'); $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID()); } $total_price = 0; foreach ($products as $product) { $productInfo = unserialize($product['product_info']); $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(); $total_price += $productInfo['price']; if ($productInfo['pricing_type'] != 'volume_based' && $productInfo['code_info']) { $total_price += $productInfo['code_info']['promoAmount']; } } $tp->assign('products_number', count($products)); $tp->assign('total_price', $total_price); $tp->assign("currency", SJB_CurrencyManager::getDefaultCurrency()); $tp->display('show_shopping_cart.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $pollSID = SJB_Request::getVar('sid', 0, null, 'int'); $cu = SJB_UserManager::getCurrentUser(); $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; if (!$pollSID) { $pollSID = SJB_PollsManager::getPollForDisplay($cu->user_group_sid, $langId); } if ($pollSID) { if (SJB_PollsManager::isActive($pollSID, $cu->user_group_sid, $langId)) { $action = SJB_Request::getVar('action', false); $IP = $_SERVER['REMOTE_ADDR']; $isVoted = SJB_PollsManager::isVoted($pollSID, $IP); switch ($action) { case 'save': $value = SJB_Request::getVar('poll', false); if ($value && $pollSID && !$isVoted) { SJB_PollsManager::addPollResult($pollSID, $value, $IP); $isVoted = true; } break; } $poll_info = SJB_PollsManager::getPollInfoBySID($pollSID); $poll = new SJB_UserPollsManager($poll_info); $poll->setSID($poll_info['sid']); $edit_form = new SJB_Form($poll); $edit_form->registerTags($tp); $form_fields = $edit_form->getFormFieldsInfo(); $tp->assign('display_results', $poll_info['display_results']); $tp->assign('question', trim(strip_tags($poll_info['question']))); $tp->assign('isVoted', $isVoted); $tp->assign('form_fields', $form_fields); $tp->assign('sid', $pollSID); $tp->display('polls.tpl'); } } }
public function execute() { $invoiceSID = SJB_Request::getVar('invoice_sid', null, 'default', 'int'); $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', false); $checkPaymentErrors = array(); $currentUser = SJB_UserManager::getCurrentUser(); if ($action == 'pay_for_products') { $subscribe = SJB_Request::getVar('subscribe', false); $subTotalPrice = SJB_Request::getVar('sub_total_price', 0); $products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID()); $codeInfo = array(); $index = 1; $items = array(); foreach ($products as $product) { $product_info = unserialize($product['product_info']); $items['products'][$index] = $product_info['sid']; $qty = !empty($product_info['number_of_listings']) ? $product_info['number_of_listings'] : null; if ($qty > 0) { $items['price'][$index] = round($product_info['price'] / $qty, 2); } else { $items['price'][$index] = round($product_info['price'], 2); } $items['amount'][$index] = $product_info['price']; $items['custom_item'][$index] = ""; $items['qty'][$index] = $qty; $items['custom_info'][$index]['shoppingCartRecord'] = $product['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); } $userSID = $currentUser->getSID(); $invoiceSID = SJB_InvoiceManager::generateInvoice($items, $userSID, $subTotalPrice, SJB_System::getSystemSettings('SITE_URL') . "/create-contract/", (bool) $subscribe); SJB_PromotionsManager::addCodeToHistory($codeInfo, $invoiceSID, $userSID); } $gatewayId = SJB_Request::getVar('gw', false); if (SJB_Request::$method == SJB_Request::METHOD_POST && !$action && $gatewayId == 'authnet_sim') { if (isset($_REQUEST['submit'])) { $gateway = SJB_PaymentGatewayManager::getObjectByID($gatewayId, true); $subscriptionResult = $gateway->createSubscription($_REQUEST); if ($subscriptionResult !== true) { $tp->assign('form_submit_url', $_SERVER['REQUEST_URI']); $tp->assign('form_data_source', $_REQUEST); $tp->assign('errors', $subscriptionResult); $tp->display('recurring_payment_page.tpl'); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-products/?subscriptionComplete=true'); } } else { $tp->assign('form_submit_url', $_SERVER['REQUEST_URI']); $tp->assign('form_data_source', $_REQUEST); $tp->display('recurring_payment_page.tpl'); } } else { if (!is_null($invoiceSID)) { $invoice_info = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSID); $invoice = new SJB_Invoice($invoice_info); if (SJB_PromotionsManager::isPromoCodeExpired($invoiceSID)) { $checkPaymentErrors['PROMOTION_TOO_MANY_USES'] = true; } else { $invoice->setSID($invoiceSID); if (count($invoice->isValid($invoiceSID)) == 0) { $invoiceUserSID = $invoice->getPropertyValue('user_sid'); $currentUserSID = SJB_UserManager::getCurrentUserSID(); if ($invoiceUserSID === $currentUserSID) { $payment_gateway_forms = SJB_InvoiceManager::getPaymentForms($invoice); $tp->assign('productsNames', $invoice->getProductNames()); $tp->assign('gateways', $payment_gateway_forms); $tp->assign('invoice_info', $invoice_info); } else { $checkPaymentErrors['NOT_OWNER'] = true; } } else { $checkPaymentErrors['WRONG_INVOICE_PARAMETERS'] = true; } } $tp->assign('checkPaymentErrors', $checkPaymentErrors); $tp->display('invoice_payment_page.tpl'); } else { $tp->display('recurring_payment_page.tpl'); } } }
public function getProfileInformation() { if (!$this->takeDataFromServer && ($oCurUser = SJB_UserManager::getCurrentUser())) { $curUserSID = $oCurUser->getSID(); $profileSocialID = self::getProfileSocialID($curUserSID); if ($profileSocialID) { $aProfExpl = explode($this->getNetwork() . '_', $profileSocialID); $linkedinID = SJB_Array::get($aProfExpl, 1); $profileSocialInfo = $this->getProfileSocialSavedInfoBySocialID($linkedinID); if ($profileSocialInfo) { self::$oProfile = SJB_Array::get($profileSocialInfo, 'profile_info'); self::$oSocialPlugin = $this; if (SJB_HelperFunctions::debugModeIsTurnedOn()) { SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGIN'); } return true; } } } if (self::$object) { try { $this->_getProfileInfoByAccessToken(); if (self::$oProfile) { if (SJB_HelperFunctions::debugModeIsTurnedOn()) { SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGINS'); } return true; } else { SJB_Session::unsetValue('sn'); } } catch (FacebookApiException $e) { SJB_Error::writeToLog($e->getMessage()); } } return null; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $current_user = SJB_UserManager::getCurrentUser(); $action = SJB_Request::getVar('action', 'productList'); $productSID = SJB_Request::getVar('product_sid', 0, 'default', 'int'); $template = 'products.tpl'; $availableProducts = array(); $errors = array(); switch ($action) { case 'productList': if (SJB_UserManager::isUserLoggedIn()) { $postingProductsOnly = SJB_Request::getVar('postingProductsOnly', false); $availableProducts = SJB_ProductsManager::getProductsByUserGroupSID($current_user->getUserGroupSID(), $current_user->getSID()); $trialProduncts = $current_user->getTrialProductSIDByUserSID(); foreach ($availableProducts as $key => $availableProduct) { if (in_array($availableProduct['sid'], $trialProduncts) || $postingProductsOnly && $availableProduct['product_type'] != "post_listings" && $availableProduct['product_type'] != "mixed_product") { unset($availableProducts[$key]); } } if ($postingProductsOnly) { $tp->assign('postingProductsOnly', $postingProductsOnly); } } elseif ($userGroupID = SJB_Request::getVar('userGroupID', false)) { $userGroupSID = SJB_UserGroupManager::getUserGroupSIDByID($userGroupID); $availableProducts = SJB_ProductsManager::getProductsByUserGroupSID($userGroupSID, 0); } else { $availableProducts = SJB_ProductsManager::getAllActiveProducts(); } foreach ($availableProducts as $key => $availableProductInfo) { if (SJB_ProductsManager::isProductTrialAndAlreadyInCart($availableProductInfo, $current_user)) { unset($availableProducts[$key]); continue; } $availableProduct = new SJB_Product($availableProductInfo, $availableProductInfo['product_type']); $availableProduct->setNumberOfListings(1); $availableProducts[$key]['price'] = $availableProduct->getPrice(); if (isset($availableProducts[$key]['listing_type_sid'])) { $availableProducts[$key]['listing_type_id'] = SJB_ListingTypeDBManager::getListingTypeIDBySID($availableProducts[$key]['listing_type_sid']); } } SJB_Event::dispatch('RedefineTemplateName', $template, true); SJB_Event::dispatch('RedefineProductsDisplayInfo', $availableProducts, true); $tp->assign("account_activated", SJB_Request::getVar('account_activated', '')); $tp->assign("availableProducts", $availableProducts); break; case 'view_product_detail': $template = 'view_product_detail.tpl'; if (!SJB_UserManager::isUserLoggedIn() || $current_user->mayChooseProduct($productSID, $errors)) { $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (in_array($productInfo['product_type'], array('post_listings', 'mixed_product'))) { $productInfo['listingTypeID'] = SJB_ListingTypeManager::getListingTypeIDBySID($productInfo['listing_type_sid']); } $event = SJB_Request::getVar('event', false); if ($event) { if ($productInfo) { switch ($productInfo['product_type']) { case 'banners': $params = $_REQUEST; if (empty($params['title'])) { $errors[] = "Banner Title is empty."; } if (empty($params['link'])) { $errors[] = "Banner link mismatched!"; } if (empty($_FILES['image']['name'])) { $errors[] = "No file attached!"; } elseif ($_FILES['image']['error']) { switch ($_FILES['image']['error']) { case '1': $errors[] = 'UPLOAD_ERR_INI_SIZE'; break; case '2': $errors[] = 'UPLOAD_ERR_FORM_SIZE'; break; case '3': $errors[] = 'UPLOAD_ERR_PARTIAL'; break; case '4': $errors[] = 'UPLOAD_ERR_NO_FILE'; break; default: $errors[] = 'NOT_UPLOAD_FILE'; break; } } else { $imageInfo = @getimagesize($_FILES['image']['tmp_name']); if (!$imageInfo || $imageInfo['2'] < 1 && $imageInfo['2'] > 3) { $errors[] = 'Image format is not supported'; } elseif (!empty($productInfo['width']) && $imageInfo[0] != $productInfo['width']) { $errors[] = "Your banner dimensions exceed the required size. Please upload an appropriate banner."; } elseif (!empty($productInfo['height']) && $imageInfo[1] != $productInfo['height']) { $errors[] = "Your banner dimensions exceed the required size. Please upload an appropriate banner."; } } if ($errors) { break; } //add banner $title = $params['title']; $link = $params['link']; $expr = preg_match("/(http:\\/\\/)/", $link, $matches); if ($expr != true) { $link = "http://" . $link; } $filesDir = SJB_System::getSystemSettings('FILES_DIR'); $ext = preg_match("|\\.(\\w{3})\\b|u", $_FILES['image']['name'], $arr); $fileName = preg_replace("|\\.(\\w{3})\\b|u", "", $_FILES['image']['name']); $hashName = md5(time() * $_FILES['image']['size']) . "_" . $fileName; $bannerFilePath = $filesDir . "banners/" . $hashName . "." . $arr[1]; $copy = move_uploaded_file($_FILES['image']['tmp_name'], $bannerFilePath); if (!$copy) { $errors[] = 'Cannot copy file from TMP dir to Banners Dir'; break; } if ($_FILES['image']['type'] != 'application/x-shockwave-flash') { $bannerInfo = getimagesize($bannerFilePath); if ($productInfo['width'] != '' && $productInfo['height'] != '') { $sx = $productInfo['width']; $sy = $productInfo['height']; } else { $sx = $bannerInfo[0]; $sy = $bannerInfo[1]; } $type = $bannerInfo['mime']; } else { if ($productInfo['width'] == '' || $productInfo['height'] == '') { $errors[] = 'Your banner dimensions exceed the required size. Please upload an appropriate banner.'; break; } $sx = $productInfo['width']; $sy = $productInfo['height']; $type = $_FILES['image']['type']; } $active = 0; $group = $productInfo['banner_group_sid']; $params['bannerFilePath'] = "/" . str_replace("../", "/", str_replace(SJB_BASE_DIR, '', $bannerFilePath)); $params['openBannerIn'] = ''; $params['bannerType'] = 'file'; $params['code'] = ''; $params['title'] = $title; $params['link'] = $link; $params['type'] = $type; $params['sx'] = $sx; $params['sy'] = $sy; $params['banner_group_sid'] = $group; $productInfo['banner_info'] = $params; break; } if (!$errors) { $numberOfListings = SJB_Request::getVar('number_of_listings'); $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID); if (!empty($extraInfo['pricing_type']) && $extraInfo['pricing_type'] == 'volume_based' && $numberOfListings) { $productInfo['number_of_listings'] = $numberOfListings; $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 (SJB_UserManager::isUserLoggedIn()) { SJB_ShoppingCart::addToShoppingCart($productInfo, $current_user->getSID()); } else { if (isset($_SESSION['products'])) { foreach ($_SESSION['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(); $_SESSION['products'][$id]['product_info'] = serialize($productInfo); $_SESSION['products'][$id]['sid'] = $id; $_SESSION['products'][$id]['user_sid'] = 0; } } if (!$errors) { SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/'); } } } } if (!empty($productInfo['expiration_period']) && !is_numeric($productInfo['expiration_period'])) { $productInfo['period'] = ucwords($productInfo['expiration_period']); } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based' && !empty($productInfo['volume_based_pricing'])) { $volumeBasedPricing = $productInfo['volume_based_pricing']; $price = array(); $firstPrice = 0; if (!empty($volumeBasedPricing['listings_range_from'])) { for ($i = 1; $i <= count($volumeBasedPricing['listings_range_from']); $i++) { if ($volumeBasedPricing['listings_range_from'][$i] == $volumeBasedPricing['listings_range_to'][$i]) { $price[$i]['range']['from'] = $volumeBasedPricing['listings_range_from'][$i]; } else { $price[$i]['range']['from'] = $volumeBasedPricing['listings_range_from'][$i]; $price[$i]['range']['to'] = $volumeBasedPricing['listings_range_to'][$i]; } $price[$i]['price'] = $volumeBasedPricing['price_per_unit'][$i]; if ($i > 1 && $firstPrice > $volumeBasedPricing['price_per_unit'][$i]) { $price[$i]['savings'] = round(100 - 100 / $firstPrice * $volumeBasedPricing['price_per_unit'][$i]); } else { $firstPrice = $volumeBasedPricing['price_per_unit'][$i]; } } } $productInfo['volume_based_pricing'] = $price; $minListings = min($volumeBasedPricing['listings_range_from']); $maxListings = max($volumeBasedPricing['listings_range_to']); $countListings = array(); for ($i = $minListings; $i <= $maxListings; $i++) { $countListings[] = $i; } $productInfo['count_listings'] = $countListings; } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') { $productInfo['fixed_period'] = 1; } if ($productInfo['product_type'] == 'banners') { $params = $_REQUEST; $bannersObj = new SJB_Banners(); $banner_fields = $bannersObj->getBannersMeta(); foreach ($banner_fields as $key => $banner_field) { $banner_fields[$banner_field['id']] = $banner_field; if (!empty($params[$banner_field['id']])) { $banner_fields[$banner_field['id']]['value'] = $params[$banner_field['id']]; } unset($banner_fields[$key]); } if (!empty($params['errors'])) { $tp->assign("errors", $params['errors']); } $tp->assign("banner_fields", $banner_fields); } $userGroupID = SJB_UserGroupDBManager::getUserGroupIDBySID($productInfo['user_group_sid']); $tp->assign('productInfo', $productInfo); $tp->assign('userGroupID', $userGroupID); $tp->assign('productSID', $productSID); $tp->assign('mayChooseProduct', true); } $tp->assign('errors', $errors); break; } $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $current_user = SJB_UserManager::getCurrentUser(); if ($current_user->isSubuser()) { // У саб-юзера должны быть свои алерты $current_user = $current_user->getSubuserInfo(); } else { $current_user = SJB_UserManager::getCurrentUserInfo(); } $listing_type_id = ''; /************************************************************/ $tp = SJB_System::getTemplateProcessor(); $tp->assign('action', 'list'); $errors = array(); $redirectUri = '/saved-searches/'; if (isset($_REQUEST['is_alert'])) { if (isset($_REQUEST['listing_type_id'])) { $listing_type_id = $_REQUEST['listing_type_id']; SJB_Session::setValue('listing_type_id', $listing_type_id); } elseif (isset($_REQUEST['restore'])) { $listing_type_id = SJB_Session::getValue('listing_type_id'); } else { SJB_Session::setValue('listing_type_id', null); } if (!SJB_Acl::getInstance()->isAllowed("use_{$listing_type_id}_alerts")) { $errors = array('NOT_SUBSCRIBE' => true); $tp->assign('ERRORS', $errors); $tp->display('error.tpl'); return; } else { $redirectUri = '/' . strtolower($listing_type_id) . '-alerts/'; } } else { if (isset($_REQUEST['listing_type_id'])) { $listing_type_id = $_REQUEST['listing_type_id']; } if (!SJB_Acl::getInstance()->isAllowed('save_searches')) { $errors = array('NOT_SUBSCRIBE' => true); $tp->assign('ERRORS', $errors); $tp->display('error.tpl'); return; } } $isSubmittedForm = SJB_Request::getVar('submit', false); $listing_type_sid = !empty($listing_type_id) ? SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id) : 0; if (!isset($_REQUEST['listing_type']['equal']) && isset($listing_type_id)) { $_REQUEST['listing_type']['equal'] = $listing_type_id; } $action = SJB_Request::getVar('action', 'list'); switch ($action) { case 'save': if ($isSubmittedForm) { $search_name = SJB_Request::getVar('name'); $emailFrequency = SJB_Request::getVar('email_frequency'); if (empty($search_name['equal'])) { $errors['EMPTY_VALUE'] = 1; $tp->assign('action', 'save'); } else { unset($_REQUEST['name']); unset($_REQUEST['email_frequency']); if ($emailFrequency) { $emailFrequency = array_pop($emailFrequency); $emailFrequency = '&email_frequency=' . array_pop($emailFrequency); } else { $emailFrequency = ''; } $search_name = $search_name['equal']; $searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id); $tp = $searchResultsTP->getChargedTemplateProcessor(); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/save-search/?alert=true&url=' . $redirectUri . '&action=save&search_name=' . $search_name . '&searchId=' . $searchResultsTP->searchId . $emailFrequency); } } else { $tp->assign('action', 'save'); } break; case 'edit': if (isset($_REQUEST['id_saved'])) { if ($isSubmittedForm) { $id_saved = $_REQUEST['id_saved']; $name = $_REQUEST['name']; $search_name = SJB_Request::getVar('name'); $emailFrequency = SJB_Request::getVar('email_frequency'); if (empty($search_name['equal'])) { $errors['EMPTY_VALUE'] = 1; } else { unset($_REQUEST['name']); unset($_REQUEST['email_frequency']); if ($emailFrequency) { $emailFrequency = array_pop($emailFrequency); $emailFrequency = array_pop($emailFrequency); } else { $emailFrequency = 'daily'; } $searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id); $tp = $searchResultsTP->getChargedTemplateProcessor(); $criteria_saver = new SJB_ListingCriteriaSaver($searchResultsTP->searchId); $requested_data = $criteria_saver->getCriteria(); SJB_SavedSearches::updateSearchOnDB($requested_data, $id_saved, $current_user['sid'], $name['equal'], $emailFrequency); } if (!empty($errors)) { $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . $redirectUri . '?alert=is_update'); } } else { $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); } } break; case 'edit_alert': $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); break; case 'edit_search': $tp->assign('action', 'edit'); $tp->assign('id_saved', $_REQUEST['id_saved']); $_REQUEST['form_template'] = SJB_Request::getVar('formTemplateNem'); break; case 'new': $tp->assign('action', 'save'); break; case 'delete': if (isset($_REQUEST['search_id'])) { $search_id = $_REQUEST['search_id']; SJB_SavedSearches::deleteSearchFromDBBySID($search_id); } break; case 'disable_notify': if (isset($_REQUEST['search_id'])) { SJB_SavedSearches::disableSearchAutoNotify($current_user['sid'], $_REQUEST['search_id']); } break; case 'enable_notify': if (isset($_REQUEST['search_id'])) { SJB_SavedSearches::enableSearchAutoNotify($current_user['sid'], $_REQUEST['search_id']); } break; } if ($action != 'new' && $action != 'edit_alert') { $saved_searches = SJB_SavedSearches::getSavedSearchesFromDB($current_user['sid']); if (isset($_REQUEST['is_alert'])) { $saved_searches = SJB_SavedSearches::getSavedJobAlertFromDB($current_user['sid']); } foreach ($saved_searches as $key => $saved_search) { $saved_searches[$key]['data'] = SJB_SavedSearches::buildCriteriaFields($saved_search['data']); if (isset($saved_search['data']['listing_type']['equal'])) { $saved_searches[$key]['listing_type'] = $saved_search['data']['listing_type']['equal']; } } $tp->assign('saved_searches', $saved_searches); } $listing = new SJB_Listing(array(), $listing_type_sid); $listing->addIDProperty(); $listing->addActivationDateProperty(); $listing->addUsernameProperty(); $listing->addKeywordsProperty(); $listing->addPicturesProperty(); $listing->addEmailFrequencyProperty(); $listing->addListingTypeIDProperty(); $listing->addPostedWithinProperty(); $search_form_builder = new SJB_SearchFormBuilder($listing); $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST); $search_form_builder->setCriteria($criteria); $search_form_builder->registerTags($tp); $form_fields = $search_form_builder->getFormFieldsInfo(); $tp->assign('form_fields', $form_fields); if (!empty($_REQUEST['name'])) { $tp->assign('search_name', $_REQUEST['name']); } if (!empty($_REQUEST['email_frequency'])) { $tp->assign('email_frequency', $_REQUEST['email_frequency']); } $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); $form_template = SJB_Request::getVar('form_template', 'search_form.tpl'); switch (SJB_Request::getVar('alert')) { case 'added': $tp->assign('alert_added', 'added'); break; case 'is_update': $tp->assign('alert_update', 'update'); break; } if (!$listing_type_id && isset($saved_search['data']['listing_type']['equal'])) { $listing_type_id = $saved_search['data']['listing_type']['equal']; } $tp->assign('errors', $errors); $tp->assign('user_logged_in', true); $tp->assign('listing_type_id', $listing_type_id); $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_SEARCH, $listing_type_id); $formBuilder->setChargedTemplateProcessor($tp); $tp->display($form_template); } else { $tp->assign("ERROR", "NOT_LOGIN"); $tp->display("../miscellaneous/error.tpl"); return; } }
/** * @param $listingSID * @param $contractID * @param $productSID */ public function addListing($listingSID, $contractID = false, $productSID = false) { if ($productSID != false) { $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID); $extraInfo['product_sid'] = (string) $extraInfo['product_sid']; } else { $contract = new SJB_Contract(array('contract_id' => $contractID)); $extraInfo = $contract->extra_info; } $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $this->tp->assign("pic_limit", $numberOfPictures); $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo(); if (!$this->listingTypeID && count($listingTypesInfo) == 1) { $listingTypeInfo = array_pop($listingTypesInfo); $this->listingTypeID = $listingTypeInfo['id']; } $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID); $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID); $pageSID = $this->getPageSID($pages, $listingTypeSID); $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listingTypeSID); $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST'); if (($contractID || !empty($this->buttonPressedPostToProceed)) && $this->listingTypeID) { $formSubmitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested; /* * social plugin * complete listing of data from an array of social data * if is allowed */ $aAutoFillData = array('formSubmitted' => &$formSubmitted, 'listingTypeID' => &$this->listingTypeID); SJB_Event::dispatch('SocialSynchronization', $aAutoFillData); /* * end of "social plugin" */ $listing = new SJB_Listing($_REQUEST, $listingTypeSID, $pageSID); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('status'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('ListingLogo'); $access_type = $listing->getProperty('access_type'); if ($formSubmitted) { if (!empty($access_type)) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true)); } $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contractID, 'is_system' => true)); } $currentUser = SJB_UserManager::getCurrentUser(); $screeningQuestionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID()); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screeningQuestionnaires) { $issetQuestionnairyField = $listing->getProperty('screening_questionnaire'); if ($issetQuestionnairyField) { $value = SJB_Request::getVar("screening_questionnaire"); $listingInfo = $_REQUEST; $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 if sync is turned off in admin part */ $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $this->listingTypeID, 'listing_info' => $_REQUEST); SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData); /* * end of social plugin "sync" */ $listingFormAdd = new SJB_Form($listing); $listingFormAdd->registerTags($this->tp); $fieldErrors = array(); if ($formSubmitted && ($this->formSubmittedFromPreview || $listingFormAdd->isDataValid($fieldErrors))) { if ($isPageLast) { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } $listing->setUserSID($currentUser->getSID()); $listing->setProductInfo($extraInfo); if (empty($access_type->value)) { $listing->setPropertyValue('access_type', 'everyone'); } if ($currentUser->isSubuser()) { $subuserInfo = $currentUser->getSubuserInfo(); $listing->addSubuserProperty($subuserInfo['sid']); } /** * >>>>> listing preview @author still */ if (!empty($listingSID)) { $listing->setSID($listingSID); } /* * <<<<< listing preview */ SJB_ListingManager::saveListing($listing); if (!empty($this->buttonPressedPostToProceed)) { SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID()); } SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']); if ($contractID) { $contract = new SJB_Contract(array('contract_id' => $contractID)); $contract->incrementPostingsNumber(); SJB_ProductsManager::incrementPostingsNumber($contract->product_sid); } if (SJB_Session::getValue('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'); } // >>> 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_ListingManager::saveListing($listing); $keywords = $listing->getKeywords(); SJB_ListingManager::updateKeywords($keywords, $listing->getSID()); } // <<< SJB-1197 if ($isPageLast && !$isPreviewListingRequested) { /* delete temp preview listing sid */ SJB_Session::unsetValue('preview_listing_sid_for_add'); // Start Event $listingSid = $listing->getSID(); SJB_Event::dispatch('listingSaved', $listingSid); if ($extraInfo['featured']) { SJB_ListingManager::makeFeaturedBySID($listing->getSID()); } if ($extraInfo['priority']) { SJB_ListingManager::makePriorityBySID($listing->getSID()); } if (!empty($this->buttonPressedPostToProceed)) { $this->proceedToCheckout($currentUser->getSID(), $productSID); } else { 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($this->listingTypeID) . '/?listing_id=' . $listing->getSID()); } } } elseif ($isPageLast && $isPreviewListingRequested) { // for listing preview SJB_Session::setValue('preview_listing_sid_for_add', $listing->getSID()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($this->listingTypeID) . '-preview/' . $listing->getSID() . '/'); } else { // listing steps (pages) SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$this->listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . "/" . $listing->getSID()); } } else { $listing->deleteProperty('access_list'); $listing->deleteProperty('contract_id'); $listingFormAdd = new SJB_Form($listing); if ($formSubmitted) { $listingFormAdd->isDataValid($fieldErrors); } $listingFormAdd->registerTags($this->tp); $template = isset($_REQUEST['input_template']) ? $_REQUEST['input_template'] : "input_form.tpl"; $formFields = $listingFormAdd->getFormFieldsInfo(); $employersList = SJB_Request::getVar('list_emp_ids', false); $employers = array(); if (is_array($employersList)) { foreach ($employersList as $emp) { $currEmp = SJB_UserManager::getUserInfoBySID($emp); $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']); } sort($employers); } $this->tp->assign('form_token', SJB_Request::getVar('form_token')); $this->tp->assign("account_activated", SJB_Request::getVar('account_activated', '')); $this->tp->assign("contract_id", $contractID); $this->tp->assign("listing_access_list", $employers); $this->tp->assign("listingTypeID", $this->listingTypeID); $this->tp->assign('listingTypeStructure', SJB_ListingTypeManager::createTemplateStructure(SJB_ListingTypeManager::getListingTypeInfoBySID($listing->listing_type_sid))); $this->tp->assign("field_errors", $fieldErrors); $this->tp->assign("form_fields", $formFields); $this->tp->assign("pages", $pages); $this->tp->assign("pageSID", $pageSID); $this->tp->assign("extraInfo", $extraInfo); $this->tp->assign("currentPage", SJB_PostingPagesManager::getPageInfoBySID($pageSID)); $this->tp->assign("isPageLast", $isPageLast); $this->tp->assign("nextPage", SJB_PostingPagesManager::getNextPage($pageSID)); $this->tp->assign("prevPage", SJB_PostingPagesManager::getPrevPage($pageSID)); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $this->tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($formFields))); /* * social plugin * only for Resume listing types */ $aAutoFillData = array('tp' => &$this->tp, 'listingTypeID' => &$this->listingTypeID, 'userSID' => $currentUser->getSID()); SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData); /* * social plugin */ $this->tp->display($template); } } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $template = 'sub_accounts.tpl'; $currentUserInfo = SJB_UserManager::getCurrentUserInfo(); $listSubusers = false; if (!empty($currentUserInfo['subuser']) && SJB_Request::getVar('action_name') != 'edit' && SJB_Request::getVar('user_id', 0) != $currentUserInfo['subuser']['sid']) { $errors['ACCESS_DENIED'] = 'ACCESS_DENIED'; } switch (SJB_Request::getVar('action_name')) { case 'new': $form_submitted = SJB_Request::getMethod() === SJB_Request::METHOD_POST; $user_group_sid = $currentUserInfo['user_group_sid']; $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid); $_REQUEST['user_group_id'] = $user_group_info['id']; $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid); $props = $user->getProperties(); $allowedProperties = array('username', 'email', 'password'); foreach ($props as $prop) { if (!in_array($prop->getID(), $allowedProperties)) { $user->deleteProperty($prop->getID()); } } $registration_form = SJB_ObjectMother::createForm($user); $registration_form->registerTags($tp); if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) { $email = $user->getPropertyValue('email'); if (is_array($email)) { $email = $email['original']; } $user->setPropertyValue('username', $email); } $registration_form = SJB_ObjectMother::createForm($user); if ($form_submitted && $registration_form->isDataValid($errors)) { $user->addParentProperty($currentUserInfo['sid']); $subuserPermissions = array('subuser_add_listings' => array('title' => 'Add new listings', 'value' => 'deny'), 'subuser_manage_listings' => array('title' => 'Manage listings and applications of other sub users', 'value' => 'deny'), 'subuser_manage_subscription' => array('title' => 'View and update subscription', 'value' => 'deny'), 'subuser_use_screening_questionnaires' => array('title' => 'Manage Questionnaries', 'value' => 'deny')); SJB_UserManager::saveUser($user); SJB_Statistics::addStatistics('addSubAccount', $user->getUserGroupSID(), $user->getSID()); SJB_Acl::clearPermissions('user', $user->getSID()); foreach ($subuserPermissions as $permissionID => $permission) { $allowDeny = SJB_Request::getVar($permissionID, 'deny'); $subuserPermissions[$permissionID]['value'] = $allowDeny; SJB_Acl::allow($permissionID, 'user', $user->getSID(), $allowDeny); } SJB_UserManager::activateUserByUserName($user->getUserName()); SJB_Notifications::sendSubuserRegistrationLetter($user, SJB_Request::get(), $subuserPermissions); $tp->assign('isSubuserRegistered', true); $listSubusers = true; } else { if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) { $user->deleteProperty("username"); } $registration_form = SJB_ObjectMother::createForm($user); if ($form_submitted) { $registration_form->isDataValid($errors); } $registration_form->registerTags($tp); $form_fields = $registration_form->getFormFieldsInfo(); $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid); $tp->assign("user_group_info", $user_group_info); $tp->assign("errors", $errors); $tp->assign("form_fields", $form_fields); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields))); $tp->display('subuser_registration_form.tpl'); } break; case 'edit': $userInfo = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_id', 0)); if (!empty($userInfo) && $userInfo['parent_sid'] === $currentUserInfo['sid']) { $userInfo = array_merge($userInfo, $_REQUEST); $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']); $user = new SJB_User($userInfo, $userInfo['user_group_sid']); $user->setSID($userInfo['sid']); $user->addParentProperty($currentUserInfo['sid']); $props = $user->getProperties(); $allowedProperties = array('username', 'email', 'password'); foreach ($props as $prop) { if (!in_array($prop->getID(), $allowedProperties)) { $user->deleteProperty($prop->getID()); } } $user->makePropertyNotRequired("password"); $edit_profile_form = SJB_ObjectMother::createForm($user); $edit_profile_form->registerTags($tp); $edit_profile_form->makeDisabled("username"); $form_submitted = SJB_Request::getMethod() == SJB_Request::METHOD_POST; if (empty($errors) && $form_submitted && $edit_profile_form->isDataValid($errors)) { $password_value = $user->getPropertyValue('password'); if (empty($password_value['original'])) { $user->deleteProperty('password'); } $currentUser = SJB_UserManager::getCurrentUser(); if (!$currentUser->isSubuser()) { $subuserPermissions = array('subuser_add_listings', 'subuser_manage_listings', 'subuser_manage_subscription', 'subuser_use_screening_questionnaires'); SJB_Acl::clearPermissions('user', $user->getSID()); foreach ($subuserPermissions as $permission) { SJB_Acl::allow($permission, 'user', $user->getSID(), SJB_Request::getVar($permission, 'deny')); } } SJB_UserManager::saveUser($user); $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("form_fields", $form_fields); $tp->assign('user_info', $userInfo); $tp->display('edit_subuser_profile.tpl'); } break; case 'delete': $users = SJB_Request::getVar('user_id', array()); foreach ($users as $user) { SJB_UserManager::deleteUserById($user); } $listSubusers = true; break; default: $listSubusers = true; break; } if ($listSubusers) { $tp->assign('errors', $errors); $tp->assign('subusers', SJB_UserManager::getSubusers($currentUserInfo['sid'])); $tp->assign('isEmailAsUsername', SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($currentUserInfo['user_group_sid'])); $tp->display($template); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (!SJB_UserManager::isUserLoggedIn()) { $errors['NOT_LOGGED_IN'] = true; $tp->assign("ERRORS", $errors); $tp->display("../classifieds/error.tpl"); return; } if (SJB_Request::getVar('subscriptionComplete') == 'false') { $this->errors['SUBSCRIPTION_IS_FAIL'] = 1; } $currentUser = SJB_UserManager::getCurrentUser(); $contractsInfo = SJB_ContractManager::getAllContractsInfoByUserSID($currentUser->getSID()); $cancelRecurringContract = SJB_Request::getVar('cancelRecurringContract', false); if ($cancelRecurringContract) { $tp->assign('cancelRecurringContractId', $cancelRecurringContract); } $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo(); $contractSIDs = array(); foreach ($contractsInfo as $key => $contractInfo) { $contractInfo['extra_info'] = unserialize($contractInfo['serialized_extra_info']); $contractInfo['avalaibleViews'] = array(); $contractInfo['avalaibleContactViews'] = array(); $contractInfo['listingAmount'] = array(); foreach ($listingTypes as $listingType) { $listingTypeID = $listingType['id']; if ($this->acl->isAllowed('view_' . $listingTypeID . '_details', $contractInfo['id'], 'contract')) { $contractInfo['avalaibleViews'][$listingTypeID]['name'] = $listingType['name']; $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_details', $contractInfo['id'], 'contract'); $contractInfo['avalaibleViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractInfo['id']), false, $listingType['sid']); if (empty($permissionParam)) { $contractInfo['avalaibleViews'][$listingTypeID]['count'] = 'unlimited'; $contractInfo['avalaibleViews'][$listingTypeID]['viewsLeft'] = 'unlimited'; } else { $contractInfo['avalaibleViews'][$listingTypeID]['count'] = $permissionParam; $contractInfo['avalaibleViews'][$listingTypeID]['viewsLeft'] = $permissionParam - $contractInfo['avalaibleViews'][$listingTypeID]['numOfViews']; } } if ($this->acl->isAllowed('post_' . $listingTypeID, $contractInfo['id'], 'contract')) { $contractInfo['listingAmount'][$listingTypeID]['name'] = $listingType['name']; $permissionParam = $this->acl->getPermissionParams('post_' . $listingTypeID, $contractInfo['id'], 'contract'); $contractInfo['listingAmount'][$listingTypeID]['numPostings'] = $contractInfo['number_of_postings']; if (empty($permissionParam)) { $contractInfo['listingAmount'][$listingTypeID]['count'] = 'unlimited'; $contractInfo['listingAmount'][$listingTypeID]['listingsLeft'] = 'unlimited'; } else { $contractInfo['listingAmount'][$listingTypeID]['count'] = $permissionParam; $contractInfo['listingAmount'][$listingTypeID]['listingsLeft'] = max($contractInfo['listingAmount'][$listingTypeID]['count'] - $contractInfo['listingAmount'][$listingTypeID]['numPostings'], 0); } } if ($this->acl->isAllowed('view_' . $listingTypeID . '_contact_info', $contractInfo['id'], 'contract')) { $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info', $contractInfo['id'], 'contract'); $contractInfo['avalaibleContactViews'][$listingTypeID]['name'] = $listingType['name']; $contractInfo['avalaibleContactViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractInfo['id']), 'view_' . $listingTypeID . '_contact_info'); if (empty($permissionParam)) { $contractInfo['avalaibleContactViews'][$listingTypeID]['count'] = 'unlimited'; $contractInfo['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = 'unlimited'; } else { $contractInfo['avalaibleContactViews'][$listingTypeID]['count'] = $permissionParam; $contractInfo['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = $contractInfo['avalaibleContactViews'][$listingTypeID]['count'] - $contractInfo['avalaibleContactViews'][$listingTypeID]['numOfViews']; } } } $contractsInfo[$key] = $contractInfo; $contractsInfo[$key]['product_info'] = SJB_ProductsManager::getProductInfoBySID($contractInfo['extra_info']['product_sid']); $contractSIDs[] = $contractInfo['id']; } $statistics = array(); foreach ($listingTypes as $listingType) { $listingTypeID = $listingType['id']; if ($this->acl->isAllowed('view_' . $listingTypeID . '_details')) { $statistics['avalaibleViews'][$listingTypeID]['name'] = $listingType['name']; $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_details'); $statistics['avalaibleViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractSIDs, false, $listingType['sid']); if (empty($permissionParam)) { $statistics['avalaibleViews'][$listingTypeID]['count'] = 'unlimited'; $statistics['avalaibleViews'][$listingTypeID]['viewsLeft'] = 'unlimited'; } else { $statistics['avalaibleViews'][$listingTypeID]['count'] = $permissionParam; $statistics['avalaibleViews'][$listingTypeID]['viewsLeft'] = $statistics['avalaibleViews'][$listingTypeID]['count'] - $statistics['avalaibleViews'][$listingTypeID]['numOfViews']; } } if ($this->acl->isAllowed('post_' . $listingTypeID)) { $statistics['listingAmount'][$listingTypeID]['name'] = $listingType['name']; $permissionParam = $this->acl->getPermissionParams('post_' . $listingTypeID); $statistics['listingAmount'][$listingTypeID]['numPostings'] = SJB_ContractManager::getListingsNumberByContractSIDsListingType($contractSIDs, $listingTypeID); if (empty($permissionParam)) { $statistics['listingAmount'][$listingTypeID]['count'] = 'unlimited'; $statistics['listingAmount'][$listingTypeID]['listingsLeft'] = 'unlimited'; } else { $statistics['listingAmount'][$listingTypeID]['count'] = $permissionParam; $statistics['listingAmount'][$listingTypeID]['listingsLeft'] = $statistics['listingAmount'][$listingTypeID]['count'] - $statistics['listingAmount'][$listingTypeID]['numPostings']; } } if ($this->acl->isAllowed('view_' . $listingTypeID . '_contact_info')) { $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info'); $statistics['avalaibleContactViews'][$listingTypeID]['name'] = $listingType['name']; $statistics['avalaibleContactViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractSIDs, 'view_' . $listingTypeID . '_contact_info'); if (empty($permissionParam)) { $statistics['avalaibleContactViews'][$listingTypeID]['count'] = 'unlimited'; $statistics['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = 'unlimited'; } else { $statistics['avalaibleContactViews'][$listingTypeID]['count'] = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info'); $statistics['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = $statistics['avalaibleContactViews'][$listingTypeID]['count'] - $statistics['avalaibleContactViews'][$listingTypeID]['numOfViews']; } } } $productsFailedList = urldecode(SJB_Request::getVar('failedProducts')); if ($productsFailedList != '') { $productsFailedArray = explode(',', $productsFailedList); if (!empty($productsFailedArray)) { $tp->assign('productsFailed', $productsFailedArray); } } $tp->assign('statistics', $statistics); $tp->assign("contracts_info", $contractsInfo); $tp->assign('errors', $this->errors); $tp->display("my_products.tpl"); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $isAlert = $enableNotify = isset($_REQUEST["alert"]); $tp->assign('is_alert', $isAlert); if (SJB_UserManager::isUserLoggedIn()) { $cu = SJB_UserManager::getCurrentUser(); if ($cu->isSubuser()) { $current_user_info = $cu->getSubuserInfo(); } else { $current_user_info = SJB_UserManager::getCurrentUserInfo(); } $criteria_saver = new SJB_ListingCriteriaSaver(SJB_Request::getVar("searchId", "")); $requested_data = $criteria_saver->getCriteria(); if (isset($requested_data['listing_type'])) { $current_listing_type = array_pop($requested_data['listing_type']); } else { $current_listing_type = ''; if (isset($requested_data['listing_type_sid'])) { $listing_type_sid = array_pop($requested_data['listing_type_sid']); $current_listing_type = SJB_ListingTypeManager::getListingTypeIDBySID($listing_type_sid); } } $errors = array(); if (!$isAlert && !SJB_Acl::getInstance()->isAllowed('save_searches')) { $errors[] = "DENIED_SAVE_JOB_SEARCH"; } elseif ($isAlert && !SJB_Acl::getInstance()->isAllowed('use_' . trim($current_listing_type) . '_alerts')) { $errors[] = "DENIED_SAVE_JOB_SEARCH"; } switch (SJB_Request::getVar("action")) { case 'edit': unset($_GET['action']); if (isset($_GET['id_saved'])) { $id_saved = $_GET['id_saved']; unset($_GET['id_saved']); $errors = array(); SJB_SavedSearches::updateSearchOnDB($_GET, $id_saved, $current_user_info['sid'], 0); if (!empty($errors)) { $tp->assign("errors", $errors); $tp->display("save_search_failed.tpl"); } else { $url = SJB_System::getSystemSettings('SITE_URL') . "/saved-searches/"; if ($isAlert) { $url = SJB_System::getSystemSettings('SITE_URL') . "/job-alerts/"; } $tp->assign("url", $url); $tp->display("save_search_success.tpl"); } } break; case 'save': $search_name = SJB_Request::getVar("search_name"); $errors = array(); $criteria_saver = new SJB_ListingCriteriaSaver(SJB_Request::getVar("searchId", "")); $requested_data = $criteria_saver->getCriteria(); if (is_array($criteria_saver->order_info)) { $requested_data = array_merge($requested_data, $criteria_saver->order_info); } $requested_data['listings_per_page'] = $criteria_saver->listings_per_page; $emailFrequency = SJB_Request::getVar("email_frequency", 'daily'); SJB_SavedSearches::saveSearchOnDB($requested_data, $search_name, $current_user_info['sid'], $enableNotify, $isAlert, $emailFrequency); if (!empty($errors)) { $tp->assign("errors", $errors); $tp->display("save_search_failed.tpl"); } else { if (isset($_REQUEST['url'])) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . $_REQUEST['url'] . "?alert=added"); } $tp->display("save_search_success.tpl"); } break; default: if (!empty($errors)) { $tp->assign("errors", $errors); $tp->display("save_search_failed.tpl"); } else { $tp->assign("searchId", SJB_Request::getVar("searchId", "")); $tp->assign("listing_type_id", SJB_Session::getValue('listing_type_id')); $tp->display("save_search_form.tpl"); } break; } } else { $tp->assign("return_url", base64_encode(SJB_Navigator::getURIThis())); $tp->assign("ajaxRelocate", true); $tp->display("../users/login.tpl"); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $display_form = new SJB_Form(); $display_form->registerTags($tp); $current_user = SJB_UserManager::getCurrentUser(); $errors = array(); $template = SJB_Request::getVar('display_template', 'display_listing.tpl'); $tcpdfError = SJB_Request::getVar('error', false); $action = substr($template, 0, -4); $listing_id = SJB_Request::getVar("listing_id"); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $listing_id = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } if (is_null($listing_id) && SJB_FormBuilderManager::getIfBuilderModeIsSet()) { $listing_type_id = SJB_Request::getVar('listing_type_id'); $listing_id = SJB_ListingManager::getListingIDByListingTypeID($listing_type_id); } if (is_null($listing_id)) { $errors['UNDEFINED_LISTING_ID'] = true; } elseif (is_null($listing = SJB_ListingManager::getObjectBySID($listing_id)) || !SJB_ListingManager::isListingAccessableByUser($listing_id, SJB_UserManager::getCurrentUserSID())) { $errors['WRONG_LISTING_ID_SPECIFIED'] = true; } elseif (!$listing->isActive() && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) { $errors['LISTING_IS_NOT_ACTIVE'] = true; } elseif (($listingStatus = SJB_ListingManager::getListingApprovalStatusBySID($listing_id)) != 'approved' && SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing->listing_type_sid) == 1 && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) { $errors['LISTING_IS_NOT_APPROVED'] = true; } elseif (SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Resume' && ($template == 'display_job.tpl' or SJB_System::getURI() == '/print-job/') || SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Job' && ($template == 'display_resume.tpl' or SJB_System::getURI() == '/print-resume/')) { $errors['WRONG_DISPLAY_TEMPLATE'] = true; } else { $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid); if (SJB_System::getURI() == '/print-listing/') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/print-' . strtolower($listing_type_id) . '/?listing_id=' . $listing_id); exit; } $listing->addPicturesProperty(); $display_form = new SJB_Form($listing); $display_form->registerTags($tp); $form_fields = $display_form->getFormFieldsInfo(); $listingOwner = SJB_UserManager::getObjectBySID($listing->user_sid); if ($action !== 'print_listing') { SJB_ListingManager::incrementViewsCounterForListing($listing_id, $listing); } $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing, array('comments', 'ratings')); $filename = SJB_Request::getVar('filename', false); if ($filename) { $file = SJB_UploadFileManager::openFile($filename, $listing_id); $errors['NO_SUCH_FILE'] = true; } $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure['METADATA']), "form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields))); $comments = array(); $comments_total = ''; if (SJB_Settings::getSettingByName('show_comments') == '1') { $comments = SJB_CommentManager::getEnabledCommentsToListing($listing_id); $comments_total = count($comments); } $searchId = SJB_Request::getVar("searchId", ""); $page = SJB_Request::getVar("page", ""); $criteria_saver = new SJB_ListingCriteriaSaver($searchId); $searchCriteria = $criteria_saver->getCriteria(); $keywordsHighlight = ''; if (isset($searchCriteria['keywords']) && SJB_System::getSettingByName('use_highlight_for_keywords')) { foreach ($searchCriteria['keywords'] as $type => $keywords) { switch ($type) { case 'like': case 'exact_phrase': $keywordsHighlight = json_encode($keywords); break; case 'all_words': case 'any_words': $keywordsHighlight = json_encode(explode(' ', $keywords)); break; case 'boolean': $keywordsHighlight = json_encode(SJB_BooleanEvaluator::parse($keywords, true)); break; } } } $prevNextIds = $criteria_saver->getPreviousAndNextObjectID($listing_id); $search_criteria_structure = $criteria_saver->createTemplateStructureForCriteria(); //permissions contact info $acl = SJB_Acl::getInstance(); $permission = 'view_' . $listing_type_id . '_contact_info'; $allowViewContactInfo = false; if (SJB_UserManager::isUserLoggedIn()) { if (SJB_ContractManager::isPageViewed($current_user->getSID(), $permission, $listing_id) || $acl->isAllowed($permission) && in_array($acl->getPermissionParams($permission), array('', '0'))) { $allowViewContactInfo = true; } elseif ($acl->isAllowed($permission)) { $viewContactInfo['count_views'] = 0; $contractIDs = $current_user->getContractID(); $numberOfContactViewed = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), $contractIDs, $permission); foreach ($contractIDs as $contractID) { if ($acl->getPermissionParams($permission, $contractID, 'contract')) { $params = $acl->getPermissionParams($permission, $contractID, 'contract'); $viewsLeft = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), array($contractID), $permission); if (isset($viewContactInfo['count_views']) && is_numeric($params)) { $viewContactInfo['count_views'] += $params; if ($params > $viewsLeft) { $viewContactInfo['contract_id'] = $contractID; } } } } if ($viewContactInfo && $viewContactInfo['count_views'] > $numberOfContactViewed) { $allowViewContactInfo = true; SJB_ContractManager::addViewPage($current_user->getSID(), $permission, $listing_id, $viewContactInfo['contract_id'], $listing->getListingTypeSID()); } } $user_group_id = SJB_UserGroupManager::getUserGroupIDBySID($current_user->getUserGroupSID()); if ($allowViewContactInfo && $user_group_id == 'JobSeeker' && $listing_type_id == 'Job') { SJB_UserManager::saveRecentlyViewedListings($current_user->getSID(), $listing_id); } } elseif ($acl->isAllowed($permission)) { $allowViewContactInfo = true; } $tp->assign("keywordsHighlight", $keywordsHighlight); $tp->assign('allowViewContactInfo', $allowViewContactInfo); $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates')); $tp->assign("isApplied", SJB_Applications::isApplied($listing_id, SJB_UserManager::getCurrentUserSID())); $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates')); $tp->assign('show_comments', SJB_Settings::getSettingByName('show_comments')); $tp->assign('comments', $comments); $tp->assign('comments_total', $comments_total); $tp->assign('listing_id', $listing_id); $tp->assign("form_fields", $form_fields); $tp->assign('video_fields', SJB_HelperFunctions::takeMediaFields($form_fields)); $tp->assign('uri', base64_encode(SJB_Navigator::getURIThis())); $tp->assign('listingOwner', $listingOwner); $listing_structure = SJB_ListingManager::newValueFromSearchCriteria($listing_structure, $criteria_saver->criteria); // SJB-1197: ajax autoupload. // Fix to view video from temporary uploaded storage. $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage'); // NEED TO CHECK FOR COMPLEX PARENT AND COMPLEX STEP PARAMETERS! $complexParent = SJB_Request::getVar('complexParent'); $complexStep = SJB_Request::getVar('complexEnum'); $fieldId = SJB_Request::getVar('field_id'); $isComplex = false; if ($complexParent && $complexStep) { $fieldId = $complexParent . ":" . $fieldId . ":" . $complexStep; $isComplex = true; } $tempFileValue = SJB_Array::getPath($sessionFilesStorage, "listings/{$listing_id}/{$fieldId}"); if ($isComplex) { $uploadFileManager = new SJB_UploadFileManager(); $fileLink = $uploadFileManager->getUploadedFileLink($tempFileValue['file_id']); $tp->assign('videoFileLink', $fileLink); } else { if (!empty($tempFileValue)) { $fileUniqueId = isset($tempFileValue['file_id']) ? $tempFileValue['file_id'] : ''; if (!empty($fileUniqueId)) { $upload_manager = new SJB_UploadFileManager(); // file structure for videoplayer $fileInfo = array('file_url' => $upload_manager->getUploadedFileLink($fileUniqueId), 'file_name' => $upload_manager->getUploadedFileName($fileUniqueId), 'saved_file_name' => $upload_manager->getUploadedSavedFileName($fileUniqueId), 'file_id' => $fileUniqueId); $listing_structure[$fieldId] = $fileInfo; } } } // SJB-1197 // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION $zipCode = ''; if (!empty($listing_structure['Location']['ZipCode'])) { $zipCode = $listing_structure['Location']['ZipCode']; } // get 'latitude' and 'longitude' from zipCode field, if it not set $latitude = isset($listing_structure['latitude']) ? $listing_structure['latitude'] : ''; $longitude = isset($listing_structure['longitude']) ? $listing_structure['longitude'] : ''; if (!empty($zipCode) && empty($latitude) && empty($longitude)) { $result = SJB_DB::query("SELECT * FROM `locations` WHERE `name` = ?s LIMIT 1", $zipCode); if ($result) { $listing_structure['latitude'] = $result[0]['latitude']; $listing_structure['longitude'] = $result[0]['longitude']; } } elseif (!empty($listing_structure['Location']['City']) && !empty($listing_structure['Location']['State']) && !empty($listing_structure['Location']['Country'])) { $address = $listing_structure['Location']['City'] . ', ' . $listing_structure['Location']['State'] . ', ' . $listing_structure['Location']['Country']; $address = urlencode($address); $cache = SJB_Cache::getInstance(); $parameters = array('City' => $listing_structure['Location']['City'], 'State' => $listing_structure['Location']['State'], 'Country' => $listing_structure['Location']['Country']); $hash = md5('google_map' . serialize($parameters)); $data = $cache->load($hash); $geoCod = ''; if (!$data) { try { $geoCod = SJB_HelperFunctions::getUrlContentByCurl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false"); $geoCod = json_decode($geoCod); if ($geoCod->status == 'OK') { $cache->save($geoCod, $hash); } } catch (Exception $e) { $backtrace = SJB_Logger::getBackTrace(); SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace))))); } } else { $geoCod = $data; } try { if (!is_object($geoCod)) { throw new Exception("Map object nave not been Created"); } if ($geoCod->status !== 'OK') { throw new Exception("Status is not OK"); } $location = $geoCod->results[0]->geometry->location; $listing_structure['latitude'] = $location->lat; $listing_structure['longitude'] = $location->lng; } catch (Exception $e) { $backtrace = SJB_Logger::getBackTrace(); SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace))))); } } if (SJB_Request::getVar('view')) { $tp->assign('listings', array($listing_structure)); } $tp->filterThenAssign("listing", $listing_structure); $tp->assign("prev_next_ids", $prevNextIds); $tp->assign("searchId", $searchId); $tp->assign("page", $page); $tp->filterThenAssign("search_criteria", $search_criteria_structure); $tp->filterThenAssign("search_uri", $criteria_saver->getUri()); if ($field_id = SJB_Request::getVar('field_id')) { // SJB-825 $complexEnum = SJB_Request::getVar('complexEnum', null, 'GET'); $complexFieldID = SJB_Request::getVar('complexParent', null, 'GET'); if (!is_null($complexEnum) && !is_null($complexFieldID)) { $videoFileID = $complexFieldID . ':' . $field_id . ':' . $complexEnum . '_' . $listing_id; $videoFileLink = SJB_UploadFileManager::getUploadedFileLink($videoFileID); if ($videoFileLink) { $tp->assign('videoFileLink', $videoFileLink); } } // SJB-825 $tp->assign('field_id', $field_id); } else { if (SJB_Request::getVar('action', false) == 'download_pdf_version') { $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_PDF, $listing_type_id); $formBuilder->setChargedTemplateProcessor($tp); $tpl = 'resume_to_pdf.tpl'; if ($listing_structure['anonymous'] == '1') { $filename = 'Anonymous User_' . $listing_structure['Title'] . '.pdf'; } else { $filename = $listing_structure['user']['FirstName'] . ' ' . $listing_structure['user']['LastName'] . '_' . $listing_structure['Title'] . '.pdf'; } try { $html = $tp->fetch($tpl); $html = preg_replace('/<div[^>]*>/', '', $html); $html = str_replace('</div>', '', $html); SJB_HelperFunctions::html2pdf($html, $filename, str_replace('http://', '', SJB_HelperFunctions::getSiteUrl())); exit; } catch (Exception $e) { SJB_Error::writeToLog($e->getMessage()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/display-resume/' . $listing_id . '/?error=TCPDF_ERROR'); } } else { $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, $listing_type_id); $formBuilder->setChargedTemplateProcessor($tp); } } } if ($errors) { foreach ($errors as $k => $v) { switch ($k) { case 'TCPDF_ERROR': case 'UNDEFINED_LISTING_ID': case 'WRONG_LISTING_ID_SPECIFIED': case 'LISTING_IS_NOT_ACTIVE': case 'LISTING_IS_NOT_APPROVED': $header = $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'; $header_status = "Status: 404 Not Found"; header($header_status); header($header); SJB_System::setGlobalTemplateVariable('page_not_found', true); break; } } } $tp->assign('errors', $errors); $tp->assign('tcpdfError', $tcpdfError); $tp->display($template); }
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 assignCurrentUserCountry() { $user = SJB_UserManager::getCurrentUser(); if ($user) { $locationValue = $user->getPropertyValue('Location'); $country = SJB_Array::get($locationValue, 'Country'); if ($country) { $countryInfo = SJB_CountriesManager::getCountryInfoBySID($country); $this->getTemplateProcessor()->assign('curUserCountryInfo', $countryInfo); } } }
public static function isUserAccessThisPage() { $pageID = SJB_PageManager::getPageParentURI(SJB_Navigator::getURI(), SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE'), false); $access = true; $currentUser = SJB_UserManager::getCurrentUser(); if (!is_null($currentUser)) { $access = false; $queryParam = ''; $listingId = SJB_Request::getVar("listing_id", false); $passedParametersViaUri = SJB_Request::getVar("passed_parameters_via_uri", false); if (!$listingId && $passedParametersViaUri) { $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $listingId = isset($passedParametersViaUri[0]) ? $passedParametersViaUri[0] : ''; } if ($listingId) { $queryParam = " AND `param` = '" . SJB_DB::quote($listingId) . "' "; } $pageHasBeenVisited = SJB_DB::query("SELECT `param` FROM `page_view` WHERE `id_user` = ?s AND `id_pages` = ?s {$queryParam}", $currentUser->getSID(), $pageID); if (!empty($queryParam) && $pageHasBeenVisited || strpos($pageID, 'print') !== false) { $access = true; } else { $contractsId = $currentUser->getContractID(); $pageAccess = SJB_ContractManager::getPageAccessByUserContracts($contractsId, $pageID); $numberOfPagesViewed = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractsId, $pageID); if (isset($pageAccess[$pageID]) && $pageAccess[$pageID]['count_views'] != '') { if ($numberOfPagesViewed < $pageAccess[$pageID]['count_views']) { $access = true; } if ($access === true) { $listingTypeSID = null; if (is_numeric($listingId)) { $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); if ($listingInfo) { $listingTypeSID = $listingInfo['listing_type_sid']; } } $availableContractId = ''; foreach ($contractsId as $contractId) { $pageAccessByContract = SJB_ContractManager::getPageAccessByUserContracts(array($contractId), $pageID); $viewsLeft = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractId), false, $listingTypeSID); if (!empty($pageAccessByContract[$pageID]['count_views']) && $pageAccessByContract[$pageID]['count_views'] > $viewsLeft) { $availableContractId = $contractId; } } if (!empty($availableContractId)) { SJB_DB::query("INSERT INTO page_view (`id_user` ,`id_pages`, `param`, `contract_id`, `listing_type_sid`) VALUES ( ?n, ?s, ?s, ?n, ?n)", $currentUser->getSID(), $pageID, $listingId, $availableContractId, $listingTypeSID); } else { $access = false; } } } else { $access = true; } } } return $access; }
public function execute() { if (!function_exists('_filter_data')) { function _filter_data(&$array, $key, $pattern) { if (isset($array[$key])) { if (!preg_match($pattern, $array[$key])) { unset($array[$key]); } } } } _filter_data($_REQUEST, 'sorting_field', "/^[_\\w\\d]+\$/"); _filter_data($_REQUEST, 'sorting_order', "/(^DESC\$)|(^ASC\$)/i"); _filter_data($_REQUEST, 'default_sorting_field', "/^[_\\w\\d]+\$/"); _filter_data($_REQUEST, 'default_sorting_order', "/(^DESC\$)|(^ASC\$)/i"); $tp = SJB_System::getTemplateProcessor(); if (!SJB_UserManager::isUserLoggedIn()) { $errors['NOT_LOGGED_IN'] = true; $tp->assign("ERRORS", $errors); $tp->display("error.tpl"); return; } $this->defineRequestedListingTypeID(); if (!$this->listingTypeID) { $tp->assign('listingTypes', SJB_ListingTypeManager::getAllListingTypesInfo()); $tp->display('my_available_listing_types.tpl'); return; } $this->listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID); if (!$this->listingTypeSID) { SJB_HelperFunctions::redirect(SJB_HelperFunctions::getSiteUrl() . '/my-listings/'); return; } $currentUser = SJB_UserManager::getCurrentUser(); $userSID = $currentUser->getSID(); $this->requestCriteria = array('user_sid' => array('equal' => $userSID), 'listing_type_sid' => array('equal' => $this->listingTypeSID)); $acl = SJB_Acl::getInstance(); if ($currentUser->isSubuser()) { $subUserInfo = $currentUser->getSubuserInfo(); if (!$acl->isAllowed('subuser_manage_listings', $subUserInfo['sid'])) { $this->requestCriteria['subuser_sid'] = array('equal' => $subUserInfo['sid']); } } SJB_ListingManager::deletePreviewListingsByUserSID($userSID); $searcher = new SJB_ListingSearcher(); // to save criteria in the session different from search_results $criteriaSaver = new SJB_ListingCriteriaSaver('MyListings'); if (isset($_REQUEST['restore'])) { $_REQUEST = array_merge($_REQUEST, $criteriaSaver->getCriteria()); } if (isset($_REQUEST['listings'])) { $listingsSIDs = $_REQUEST['listings']; if (isset($_REQUEST['action_deactivate'])) { $this->executeAction($listingsSIDs, 'deactivate'); } elseif (isset($_REQUEST['action_activate'])) { $redirectToShoppingCard = false; $activatedListings = array(); foreach ($listingsSIDs as $listingSID => $value) { $listingInfo = SJB_ListingManager::getListingInfoBySID($listingSID); $productInfo = !empty($listingInfo['product_info']) ? unserialize($listingInfo['product_info']) : array(); if ($listingInfo['active']) { continue; } else { if (SJB_ListingManager::getIfListingHasExpiredBySID($listingSID) && isset($productInfo['renewal_price']) && $productInfo['renewal_price'] > 0) { $redirectToShoppingCard = true; $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']); $newProductName = "Reactivation of \"{$listingInfo['Title']}\" {$listingTypeId}"; $newProductInfo = SJB_ShoppingCart::createInfoForCustomProduct($userSID, $productInfo['product_sid'], $listingSID, $productInfo['renewal_price'], $newProductName, 'activateListing'); SJB_ShoppingCart::createCustomProduct($newProductInfo, $userSID); } else { if ($listingInfo['checkouted'] == 0) { $redirectToShoppingCard = true; } else { if (SJB_ListingManager::activateListingBySID($listingSID, false)) { $listing = SJB_ListingManager::getObjectBySID($listingSID); SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID()); $activatedListings[] = $listingSID; } } } } } SJB_BrowseDBManager::addListings($activatedListings); if ($redirectToShoppingCard) { $shoppingUrl = SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/'; SJB_HelperFunctions::redirect($shoppingUrl); } } else { if (isset($_REQUEST['action_delete'])) { $this->executeAction($listingsSIDs, 'delete'); $allowedPostBeforeCheckout = SJB_Settings::getSettingByName('allow_to_post_before_checkout'); foreach ($listingsSIDs as $listingSID => $value) { if ($allowedPostBeforeCheckout == true) { $this->deleteCheckoutedListingFromShopCart($listingSID, $userSID); } } } elseif (isset($_REQUEST['action_sendToApprove'])) { $processListingsIds = array(); foreach ($listingsSIDs as $listingSID => $value) { $processListingsIds[] = $listingSID; } SJB_ListingManager::setListingApprovalStatus($processListingsIds, 'pending'); } } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/my-listings/{$this->listingTypeID}/"); } $listing = new SJB_Listing(array(), $this->listingTypeSID); $idAliasInfo = $listing->addIDProperty(); $listing->addActivationDateProperty(); $listing->addKeywordsProperty(); $listing->addPicturesProperty(); $listingTypeIdAliasInfo = $listing->addListingTypeIDProperty(); $sortingFields = array(); $innerJoin = array(); $sortingField = SJB_Request::getVar("sorting_field", null); $sortingOrder = SJB_Request::getVar("sorting_order", null); if (isset($sortingField, $sortingOrder)) { $orderInfo = array('sorting_field' => $sortingField, 'sorting_order' => $sortingOrder); } else { $orderInfo = $criteriaSaver->getOrderInfo(); } if ($orderInfo['sorting_field'] == 'applications') { $innerJoin['applications'] = array('count' => 'count(`applications`.id) as appCount', 'join' => 'LEFT JOIN', 'join_field' => 'listing_id', 'join_field2' => 'sid', 'main_table' => 'listings'); $sortingFields['appCount'] = $orderInfo['sorting_order']; $searcher->setGroupByField(array('listings' => 'sid')); } else { if ($orderInfo['sorting_field'] == 'id') { $sortingFields['sid'] = $orderInfo['sorting_order']; } else { if ($orderInfo['sorting_field'] == 'subuser_sid') { $innerJoin['users'] = array('join' => 'LEFT JOIN', 'join_field' => 'sid', 'join_field2' => 'subuser_sid', 'main_table' => 'listings'); $sortingFields['username'] = $orderInfo['sorting_order']; } else { $property = $listing->getProperty($sortingField); if (!empty($property) && $property->isSystem()) { $sortingFields[$orderInfo['sorting_field']] = $orderInfo['sorting_order']; } else { $sortingFields['activation_date'] = 'DESC'; } } } } $this->requestCriteria['sorting_field'] = $orderInfo['sorting_field']; $this->requestCriteria['sorting_order'] = $orderInfo['sorting_order']; $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData(array_merge($_REQUEST, $this->requestCriteria), $listing); $aliases = new SJB_PropertyAliases(); $aliases->addAlias($idAliasInfo); $aliases->addAlias($listingTypeIdAliasInfo); $foundListingsSIDs = $searcher->getObjectsSIDsByCriteria($criteria, $aliases, $sortingFields, $innerJoin); $searchFormBuilder = new SJB_SearchFormBuilder($listing); $searchFormBuilder->registerTags($tp); $searchFormBuilder->setCriteria($criteria); // получим информацию о имеющихся листингах $listingsInfo = array(); $currentUserInfo = SJB_UserManager::getCurrentUserInfo(); $contractInfo['extra_info']['listing_amount'] = 0; if ($acl->isAllowed('post_' . $this->listingTypeID)) { $permissionParam = $acl->getPermissionParams('post_' . $this->listingTypeID); if (empty($permissionParam)) { $contractInfo['extra_info']['listing_amount'] = 'unlimited'; } else { $contractInfo['extra_info']['listing_amount'] = $permissionParam; } } $currentUser = SJB_UserManager::getCurrentUser(); $contractsSIDs = $currentUser->getContractID(); $listingsInfo['listingsNum'] = SJB_ContractManager::getListingsNumberByContractSIDsListingType($contractsSIDs, $this->listingTypeID); $listingsInfo['listingsMax'] = $contractInfo['extra_info']['listing_amount']; if ($listingsInfo['listingsMax'] === 'unlimited') { $listingsInfo['listingsLeft'] = 'unlimited'; } else { $listingsInfo['listingsLeft'] = $listingsInfo['listingsMax'] - $listingsInfo['listingsNum']; $listingsInfo['listingsLeft'] = $listingsInfo['listingsLeft'] < 0 ? 0 : $listingsInfo['listingsLeft']; } $tp->assign('listingTypeID', $this->listingTypeID); $tp->assign('listingTypeName', SJB_ListingTypeManager::getListingTypeNameBySID($this->listingTypeSID)); $tp->assign('listingsInfo', $listingsInfo); $tp->display('my_listings_form.tpl'); $page = SJB_Request::getVar('page', 1); $listingsPerPage = $criteriaSaver->getListingsPerPage(); //save 'listings per page' in the session if (empty($listingsPerPage)) { $listingsPerPage = 10; } $listingsPerPage = SJB_Request::getVar('listings_per_page', $listingsPerPage); $criteriaSaver->setSessionForListingsPerPage($listingsPerPage); $criteriaSaver->setSessionForCurrentPage($page); $criteriaSaver->setSessionForCriteria($_REQUEST); $criteriaSaver->setSessionForOrderInfo($orderInfo); $criteriaSaver->setSessionForObjectSIDs($foundListingsSIDs); // get Applications $appsGroups = SJB_Applications::getAppGroupsByEmployer($currentUserInfo['sid']); $apps = array(); foreach ($appsGroups as $group) { $apps[$group['listing_id']] = $group['count']; } $searchCriteriaStructure = $criteriaSaver->createTemplateStructureForCriteria(); $listingSearchStructure = $criteriaSaver->createTemplateStructureForSearch(); /**************** P A G I N G *****************/ if ($listingSearchStructure['current_page'] > $listingSearchStructure['pages_number']) { $listingSearchStructure['current_page'] = $listingSearchStructure['pages_number']; } if ($listingSearchStructure['current_page'] < 1) { $listingSearchStructure['current_page'] = 1; } $sortedFoundListingsSIDsByPages = array_chunk($foundListingsSIDs, $listingSearchStructure['listings_per_page'], true); /************* S T R U C T U R E **************/ $listingsStructure = array(); $listingStructureMetaData = array(); if (isset($sortedFoundListingsSIDsByPages[$listingSearchStructure['current_page'] - 1])) { foreach ($sortedFoundListingsSIDsByPages[$listingSearchStructure['current_page'] - 1] as $sid) { $listing = SJB_ListingManager::getObjectBySID($sid); $listing->addPicturesProperty(); $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing); $listingsStructure[$listing->getID()] = $listingStructure; if (isset($listingStructure['METADATA'])) { $listingStructureMetaData = array_merge($listingStructureMetaData, $listingStructure['METADATA']); } } } /*************** D I S P L A Y ****************/ $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $metadata = array(); $metadata['listing'] = $metaDataProvider->getMetaData($listingStructureMetaData); $waitApprove = SJB_ListingTypeManager::getWaitApproveSettingByListingType($this->listingTypeSID); $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates')); $tp->assign('show_comments', SJB_Settings::getSettingByName('show_comments')); $tp->assign('METADATA', $metadata); $tp->assign('sorting_field', $listingSearchStructure['sorting_field']); $tp->assign('sorting_order', $listingSearchStructure['sorting_order']); $tp->assign('property', $this->getSortableProperties()); $tp->assign('listing_search', $listingSearchStructure); $tp->assign('search_criteria', $searchCriteriaStructure); $tp->assign('listings', $listingsStructure); $tp->assign('waitApprove', $waitApprove); $tp->assign('apps', $apps); $hasSubusersWithListings = false; $subusers = SJB_UserManager::getSubusers($currentUserInfo['sid']); foreach ($subusers as $subuser) { if ($acl->isAllowed('subuser_add_listings', $subuser['sid']) || $acl->isAllowed('subuser_manage_listings', $subuser['sid'])) { $hasSubusersWithListings = true; break; } } $tp->assign('hasSubusersWithListings', $hasSubusersWithListings); $tp->display('my_listings.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $appsPerPage = SJB_Request::getVar('appsPerPage', 10); $this->currentPage = SJB_Request::getVar('page', 1); $currentUser = SJB_UserManager::getCurrentUser(); $appJobId = SJB_Request::getVar('appJobId', false, null, 'int'); $score = SJB_Request::getVar('score', false); $orderBy = SJB_Request::getVar('orderBy', 'date'); $order = SJB_Request::getVar('order', 'desc'); $displayTemplate = "view.tpl"; $errors = array(); // не бум пускать незарегенных if (SJB_UserManager::isUserLoggedIn() === false) { $tp->assign("ERROR", "NOT_LOGIN"); $tp->display("../miscellaneous/error.tpl"); return; } $filename = SJB_Request::getVar('filename', false); if ($filename) { $appsID = SJB_Request::getVar('appsID', false); if ($appsID) { $file = SJB_UploadFileManager::openApplicationFile($filename, $appsID); if (!$file) { $errors['NO_SUCH_FILE'] = true; } } else { $errors['NO_SUCH_APPS'] = true; } } if (!is_numeric($this->currentPage) || $this->currentPage < 1) { $this->currentPage = 1; } if (!is_numeric($appsPerPage) || $appsPerPage < 1) { $appsPerPage = 10; } if ($order != 'asc' && $order != 'desc') { $order = 'desc'; } if (!empty($score) && $score != 'passed' && $score != 'not_passed') { $score = false; } $tp->assign("orderBy", $orderBy); $tp->assign("order", $order); if (isset($orderBy) && isset($order) && $orderBy != "") { switch ($orderBy) { case "date": $orderInfo = array('sorting_field' => 'date', 'sorting_order' => $order); break; case "title": $orderInfo = array('sorting_field' => 'Title', 'sorting_order' => $order, 'inner_join' => array('table' => 'listings', 'field1' => 'sid', 'field2' => 'listing_id')); break; case "applicant": $orderInfo = false; $sortByUsername = true; break; case "status": $orderInfo = array('sorting_field' => 'status', 'sorting_order' => $order); break; case "score": $orderInfo = array('sorting_field' => 'score', 'sorting_order' => $order); break; case "company": $orderInfo = array('sorting_field' => 'CompanyName', 'sorting_order' => $order, 'inner_join' => array('table' => 'listings', 'field1' => 'sid', 'field2' => 'listing_id'), 'inner_join2' => array('table1' => 'users', 'table2' => 'listings', 'field1' => 'sid', 'field2' => 'user_sid')); break; default: $orderInfo = array('sorting_field' => 'date', 'sorting_order' => $order); } } if ($currentUser->getUserGroupSID() == 41) { // Работадатель switch (SJB_Request::getVar('action', '')) { case "approve": $applications = SJB_Request::getVar('applications', ''); if (!empty($applications)) { if (is_array($applications)) { foreach ($applications as $key => $value) { $this->approveApplication($key); } } else { $this->approveApplication($applications); } } break; case "reject": $applications = SJB_Request::getVar('applications', ''); if (!empty($applications)) { if (is_array($applications)) { foreach ($applications as $key => $value) { $this->rejectApplication($key); } } else { $this->rejectApplication($applications); } } break; case "delete": if (isset($_POST["applications"])) { foreach ($_POST["applications"] as $key => $value) { SJB_Applications::hideEmp($key); } } break; } $whereSubuser = ''; if (!empty($subuser)) { $whereSubuser = '******' . SJB_DB::quote($subuser); } $jobs = SJB_DB::query('select `Title` as `title`, `sid` as `id` from `listings` where `user_sid` = ?n' . $whereSubuser, $currentUser->sid); $listingTitle = null; foreach ($jobs as $job) { if ($job['id'] == $appJobId) { $listingTitle = $job['title']; } } $apps = $this->executeApplicationsForEmployer($appsPerPage, $appJobId, $currentUser, $score, $orderInfo, $listingTitle); if (empty($apps) && $this->currentPage > 1) { $this->currentPage = 1; $apps = $this->executeApplicationsForEmployer($appsPerPage, $appJobId, $currentUser, $score, $orderInfo, $listingTitle); } foreach ($apps as $i => $app) { $apps[$i]["job"] = SJB_ListingManager::getListingInfoBySID($apps[$i]["listing_id"]); if (!empty($apps[$i]["job"]['screening_questionnaire'])) { $screening_questionnaire = SJB_ScreeningQuestionnaires::getInfoBySID($apps[$i]["job"]['screening_questionnaire']); $passing_score = 0; switch ($screening_questionnaire['passing_score']) { case 'acceptable': $passing_score = 1; break; case 'good': $passing_score = 2; break; case 'very_good': $passing_score = 3; break; case 'excellent': $passing_score = 4; break; } if ($apps[$i]['score'] >= $passing_score) { $apps[$i]['passing_score'] = 'Passed'; } else { $apps[$i]['passing_score'] = 'Not passed'; } } if (isset($apps[$i]["resume"]) && !empty($apps[$i]["resume"])) { $apps[$i]["resumeInfo"] = SJB_ListingManager::getListingInfoBySID($apps[$i]["resume"]); } // если это анонимный соискатель - то возьмем имя из пришедшего поля 'username' if ($apps[$i]['jobseeker_id'] == 0) { $apps[$i]["user"]["FirstName"] = $apps[$i]['username']; } else { $apps[$i]["user"] = SJB_UserManager::getUserInfoBySID($apps[$i]["jobseeker_id"]); $apps[$i]['user']['stateInfo'] = SJB_StatesManager::getStateInfoBySID($apps[$i]['user']['Location_State']); if (isset($apps[$i]['user']['stateInfo']['state_code'])) { $apps[$i]['user']['Location']['State_Code'] = $apps[$i]['user']['stateInfo']['state_code']; } } } $tp->assign("appsPerPage", $appsPerPage); $tp->assign("currentPage", $this->currentPage); $tp->assign("pages", $this->pages); $tp->assign("totalPages", $this->totalPages); $tp->assign("appJobs", $jobs); $tp->assign("score", $score); $tp->assign("current_filter", $appJobId); $tp->assign("listing_title", $listingTitle); } else { // Соискатель if (SJB_Request::getVar('action', '', 'POST') == "delete") { foreach (SJB_Request::getVar('applications', array(), 'POST') as $key => $value) { SJB_Applications::hideJS($key); } } $apps = SJB_Applications::getByJobseeker($currentUser->sid, $orderInfo); for ($i = 0; $i < count($apps); ++$i) { $apps[$i]["job"] = SJB_ListingManager::getListingInfoBySID($apps[$i]["listing_id"]); $apps[$i]["company"] = SJB_UserManager::getUserInfoBySID($apps[$i]["job"]["user_sid"]); } $displayTemplate = "view_seeker.tpl"; } if (isset($sortByUsername)) { $sortKeys = array(); $order = $order == "desc" ? SORT_DESC : SORT_ASC; foreach ($apps as $key => $value) { if (!isset($apps[$key]["user"]["FirstName"])) { $apps[$key]["user"]["FirstName"] = ''; } if (!isset($apps[$key]["user"]["LastName"])) { $apps[$key]["user"]["LastName"] = ''; } $sortKeys[$key] = $apps[$key]["user"]["FirstName"] . " " . $apps[$key]["user"]["LastName"]; } array_multisort($sortKeys, $order, SORT_REGULAR, $apps); } if (empty($apps) && empty($errors['NOT_OWNER_OF_APPLICATIONS'])) { $errors['APPLICATIONS_NOT_FOUND'] = true; } $tp->assign("METADATA", SJB_Application::getApplicationMeta()); $tp->assign("applications", $apps); $tp->assign("errors", $errors); $tp->display($displayTemplate); }
public static function createTemplateStructureForCurrentUser() { return SJB_UserManager::createTemplateStructureForUser(SJB_UserManager::getCurrentUser()); }
private function getProfileInformation() { if (!$this->takeDataFromServer && ($oCurUser = SJB_UserManager::getCurrentUser())) { $curUserSID = $oCurUser->getSID(); $profileSocialID = self::getProfileSocialID($curUserSID); if ($profileSocialID) { $aProfExpl = explode($this->getNetwork() . '_', $profileSocialID); $linkedinID = $aProfExpl[1]; $profileSocialInfo = $this->getProfileSocialSavedInfoBySocialID($linkedinID); if ($profileSocialInfo) { self::$oProfile = $profileSocialInfo['profile_info']; self::$oSocialPlugin = $this; if (SJB_HelperFunctions::debugModeIsTurnedOn()) { SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGIN'); } return true; } } } if (self::$object) { try { $response = self::$object->getProfileInfo($this->requestedProfileFields); if ($response) { self::$oProfile = new SimpleXMLElement($response); self::$oSocialPlugin = $this; if (SJB_HelperFunctions::debugModeIsTurnedOn()) { SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGIN'); } return true; } } catch (Exception $ex) { // revocation successful, clear session unset($_SESSION['oauth'][self::NETWORK_ID]); $this->cleanSessionData(self::NETWORK_ID); if (SJB_HelperFunctions::debugModeIsTurnedOn()) { $debug = "Error retrieving profile information:\n\nRESPONSE:\n\n<pre>" . print_r($ex->getMessage()) . "</pre>"; SJB_HelperFunctions::debugInfoPush($debug, 'SOCIAL_PLUGINS'); } } } return null; }
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 static function getRedirectUrlByPageID($pageId) { $error = ''; if (!is_null(SJB_Session::getValue('fromAnonymousShoppingCart'))) { SJB_Session::unsetValue('fromAnonymousShoppingCart'); return SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/?'; } $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/my-account/?'; if (empty($pageId)) { return $redirectUrl; } if ($pageId == 'posting_page') { $user = SJB_UserManager::getCurrentUser(); $userGroupId = SJB_UserGroupManager::getUserGroupIDBySID($user->getUserGroupSID()); $listingTypeSid = SJB_ListingTypeManager::getListingTypeByUserSID($user->getSID()); $listingTypeId = !empty($listingTypeSid) ? SJB_ListingTypeManager::getListingTypeIDBySID(array_pop($listingTypeSid)) : ''; if ($user->hasContract() && SJB_ListingManager::canCurrentUserAddListing($error, $listingTypeId)) { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/add-listing/?listing_type_id=' . $listingTypeId . "&"; } elseif ($user->hasContract()) { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/my-account/?'; } else { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/' . mb_strtolower($userGroupId) . '-products/?postingProductsOnly=1&'; } } return $redirectUrl; }
public static function canCurrentUserAddListing(&$error, $listingTypeId = false) { $acl = SJB_Acl::getInstance(); if (SJB_UserManager::isUserLoggedIn()) { $current_user = SJB_UserManager::getCurrentUser(); if ($current_user->hasContract()) { $contracts_id = $current_user->getContractID(); $contractsSIDs = $contracts_id ? implode(',', $contracts_id) : 0; $resultContractInfo = SJB_DB::query("SELECT `id`, `product_sid`, `expired_date`, `number_of_postings` FROM `contracts` WHERE `id` in ({$contractsSIDs}) ORDER BY `expired_date` DESC"); $PlanAcces = count($resultContractInfo) > 0 ? true : false; if ($PlanAcces && $acl->isAllowed('post_' . $listingTypeId)) { $productsInfo = array(); $is_contract = false; foreach ($resultContractInfo as $contractInfo) { if ($acl->isAllowed('post_' . $listingTypeId, $contractInfo['id'], 'contract')) { $permissionParam = $acl->getPermissionParams('post_' . $listingTypeId, $contractInfo['id'], 'contract'); if (empty($permissionParam) || $acl->getPermissionParams('post_' . $listingTypeId, $contractInfo['id'], 'contract') > $contractInfo['number_of_postings']) { $product = SJB_ProductsManager::getProductInfoBySID($contractInfo['product_sid']); $productsInfo[$contractInfo['id']]['product_name'] = $product['name']; $productsInfo[$contractInfo['id']]['expired_date'] = $contractInfo['expired_date']; $productsInfo[$contractInfo['id']]['contract_id'] = $contractInfo['id']; } } $is_contract = true; } if ($is_contract && count($productsInfo) > 0) { return $productsInfo; } else { $error = 'LISTINGS_NUMBER_LIMIT_EXCEEDED'; } } else { $error = 'DO_NOT_MATCH_POST_THIS_TYPE_LISTING'; } } else { $error = 'NO_CONTRACT'; } } else { $error = 'NOT_LOGGED_IN'; } return false; }
/** * get SJB_Function instance by function name and module name * * @param $script_filename * @param $function_name * @param $module_name * @param SJB_Acl $acl * @param array $params * $param int $aclRoleID * @return SJB_Function */ public function getFunction($function_name, $module_name, $params = array()) { $aclRoleID = null; $adminAccessType = SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE'); $accessTypePrefix = $adminAccessType ? 'Admin_' : ''; if ($adminAccessType && SJB_SubAdmin::admin_authed()) { $aclRoleID = SJB_SubAdmin::getSubAdminSID(); $acl = SJB_SubAdminAcl::getInstance(); } else { $acl = SJB_Acl::getInstance(); $cu = SJB_UserManager::getCurrentUser(); if (!empty($cu) && $cu->isSubuser()) { $cu = $cu->getSubuserInfo(); $aclRoleID = SJB_Array::get($cu, 'sid'); } } $functionPart = $this->getCamelCaseName($function_name); $modulePart = $this->getCamelCaseName($module_name); $className = 'SJB_' . $accessTypePrefix . $modulePart . '_' . $functionPart; return new $className($acl, $params, $aclRoleID); }
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() { $this->redirectToListingByKeywords(); // SEO friendly URL for company profile $m = array(); $isCompanyProfilePage = false; if (preg_match('#/company/([0-9]+)/.*#', SJB_Navigator::getURI(), $m)) { $isCompanyProfilePage = true; $params = SJB_FixedUrlParamProvider::getParams($_REQUEST); if (!empty($params)) { $aliasUsername = SJB_UserManager::getUserNameByUserSID($m[1]); if (!empty($aliasUsername)) { $_REQUEST['username']['equal'] = $aliasUsername; $_REQUEST['anonymous']['equal'] = 0; } } } if (!empty($_REQUEST['username']['equal']) && is_int($_REQUEST['username']['equal'])) { $aliasUsername = SJB_UserManager::getUserNameByUserSID(intval($_REQUEST['username']['equal'])); if (!empty($aliasUsername)) { $_REQUEST['username']['equal'] = $aliasUsername; } } $listingTypeId = SJB_Request::getVar('listing_type_id', 0); if (!$listingTypeId) { $listingTypeId = isset($_REQUEST['listing_type']['equal']) ? $_REQUEST['listing_type']['equal'] : SJB_Session::getValue('listing_type_id'); } if ($listingTypeId) { $_REQUEST['listing_type']['equal'] = $listingTypeId; } $action = SJB_Request::getVar('action', 'search'); //XSS defense $searchId = SJB_Request::getVar('searchId', false); if ($searchId && !is_numeric($searchId)) { $_REQUEST['searchId'] = false; } $request = $_REQUEST; if (SJB_System::getSettingByName('turn_on_refine_search_' . $listingTypeId)) { switch ($action) { case 'refine': $searchID = SJB_Request::getVar('searchId', false); unset($request['searchId']); $criteria_saver = new SJB_ListingCriteriaSaver($searchID); $request = SJB_RefineSearch::mergeCriteria($criteria_saver->getCriteria(), $request); break; case 'undo': $param = SJB_Request::getVar('param', false); $field_type = SJB_Request::getVar('type', false); $value = SJB_Request::getVar('value', false); if ($param && $field_type && $value) { $searchID = SJB_Request::getVar('searchId', false); unset($request['searchId']); $criteria_saver = new SJB_ListingCriteriaSaver($searchID); $criteria = $criteria_saver->criteria; if (isset($criteria[$param][$field_type])) { switch ($field_type) { case 'geo': if ($criteria[$param][$field_type]['location'] == $value) { unset($criteria[$param]); } break; case 'monetary': if ($criteria[$param][$field_type]['not_less'] == $value) { $criteria[$param][$field_type]['not_less'] = ""; } if ($criteria[$param][$field_type]['not_more'] == $value) { $criteria[$param][$field_type]['not_more'] = ""; } break; case 'tree': // search params incoming as string, where params separated by ',' // we need to undo one of them $params = explode(',', $criteria[$param][$field_type]); $params = array_flip($params); unset($params[$value]); $params = array_flip($params); $criteria[$param][$field_type] = implode(',', $params); break; default: if (is_array($criteria[$param][$field_type])) { foreach ($criteria[$param][$field_type] as $key => $val) { if ($val == $value) { unset($criteria[$param][$field_type][$key]); } } } else { unset($criteria[$param]); } break; } } $criteria['default_sorting_field'] = $request['default_sorting_field']; $criteria['default_sorting_order'] = $request['default_sorting_order']; $criteria['default_listings_per_page'] = $request['default_listings_per_page']; $criteria['results_template'] = $request['results_template']; $request = array_merge($criteria, $request); } break; } } $searchResultsTP = new SJB_SearchResultsTP($request, $listingTypeId, false, true); $searchResultsTP->usePriority(true); $template = SJB_Request::getVar("results_template", "search_results.tpl"); $allowViewContactInfo = false; if (!empty($_REQUEST['username']['equal'])) { $pageID = 'contact_info'; $username = $_REQUEST['username']['equal']; if (SJB_UserManager::isUserLoggedIn()) { $current_user = SJB_UserManager::getCurrentUser(); if (SJB_ContractManager::isPageViewed($current_user->getSID(), $pageID, $username) || $this->acl->isAllowed('view_' . $listingTypeId . '_contact_info') && in_array($this->acl->getPermissionParams('view_' . $listingTypeId . '_contact_info'), array('', '0'))) { $allowViewContactInfo = true; } elseif ($this->acl->isAllowed('view_' . $listingTypeId . '_contact_info')) { $viewContactInfo['count_views'] = 0; $contractIDs = $current_user->getContractID(); $numberOfContactViewed = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), $contractIDs, $pageID); foreach ($contractIDs as $contractID) { if ($this->acl->getPermissionParams('view_' . $listingTypeId . '_contact_info', $contractID, 'contract')) { $params = $this->acl->getPermissionParams('view_' . $listingTypeId . '_contact_info', $contractID, 'contract'); if (isset($viewContactInfo['count_views'])) { $viewContactInfo['count_views'] += $params; $viewContactInfo['contract_id'] = $contractID; } } } if ($viewContactInfo && $viewContactInfo['count_views'] > $numberOfContactViewed) { $allowViewContactInfo = true; SJB_ContractManager::addViewPage($current_user->getSID(), $pageID, $username, $viewContactInfo['contract_id']); } } } elseif ($this->acl->isAllowed('view_' . $listingTypeId . '_contact_info')) { $allowViewContactInfo = true; } } $tp = $searchResultsTP->getChargedTemplateProcessor(); SJB_Statistics::addSearchStatistics($searchResultsTP->getListingSidCollectionForCurrentPage(), $listingTypeId); $userForm = null; if ($isCompanyProfilePage) { $user = SJB_UserManager::getObjectBySID(intval($m[1])); $userForm = new SJB_Form($user); $userForm->registerTags($tp); } $errors = array(); if (!empty($searchResultsTP->pluginErrors)) { foreach ($searchResultsTP->pluginErrors as $err) { $errors[] = $err; } } $tp->assign('errors', $errors); $tp->assign('is_company_profile_page', $isCompanyProfilePage); $tp->assign("listing_type_id", $listingTypeId); $tp->assign('allowViewContactInfo', $allowViewContactInfo); if ($userForm) { $tp->assign('form_fields', $userForm->getFormFieldsInfo()); } $tp->display($template); }