public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $errors = array(); $id = SJB_Request::getInt('id', 0, 'GET'); $action = SJB_Request::getVar('action', '', 'GET'); if ($id > 0) { // read message if (SJB_PrivateMessage::isMyMessage($id)) { if ($action == 'delete') { SJB_PrivateMessage::delete(array($id)); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/'); } $message = SJB_PrivateMessage::readMessage($id); SJB_Authorization::updateCurrentUserSession(); $current_user_info = SJB_UserManager::createTemplateStructureForCurrentUser(); $current_user_info['logged_in'] = true; $current_user_info['new_messages'] = SJB_PrivateMessage::getCountUnreadMessages($current_user_info['id']); SJB_System::setCurrentUserInfo($current_user_info); $tp->assign('message', $message); $tp->assign('include', 'message_detail.tpl'); } else { $errors['NOT_EXISTS_MESSAGE'] = 1; } } $tp->assign('errors', $errors); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('main.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $tp->display('../users/login.tpl'); } }
public function execute() { $template_processor = SJB_System::getTemplateProcessor(); $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int'); $listingType = SJB_Request::getVar('listing_type', null); if (!$listingType) { if ($listingId) { $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); $listingType = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']); } else { $listingType = 'job'; } } $displayForm = SJB_Request::getVar('displayForm', false); $error = null; if (!SJB_Acl::getInstance()->isAllowed('save_' . trim($listingType))) { $error = 'DENIED_SAVE_LISTING'; } if (SJB_UserManager::isUserLoggedIn()) { if (!$error) { if (!is_null($listingId)) { if (SJB_UserManager::isUserLoggedIn()) { SJB_SavedListings::saveListingOnDB($listingId, SJB_UserManager::getCurrentUserSID()); SJB_Statistics::addStatistics('saveListing', SJB_ListingTypeManager::getListingTypeSIDByID($listingType), $listingId); } else { SJB_SavedListings::saveListingInCookie($listingId); } $template_processor->assign('saved_listing', SJB_SavedListings::getSavedListingsByUserAndListingSid(SJB_UserManager::getCurrentUserSID(), $listingId)); } else { $error = 'LISTING_ID_NOT_SPECIFIED'; } } $params = SJB_Request::getVar('params', false); $searchId = SJB_Request::getVar('searchId', false); $page = SJB_Request::getVar('page', false); $template_processor->assign("params", $params); $template_processor->assign("searchId", $searchId); $template_processor->assign("page", $page); $template_processor->assign("listing_type", $listingType); $template_processor->assign("listing_sid", $listingId); $template_processor->assign("from_login", SJB_Request::getVar("from_login", false)); $template_processor->assign("error", $error); $template_processor->assign("displayForm", $displayForm); $template_processor->assign("view", SJB_Request::getVar('view')); $template_processor->display("save_listing.tpl"); } else { $template_processor->assign("return_url", base64_encode(SJB_Navigator::getURIThis() . "&from_login=1")); $template_processor->assign("ajaxRelocate", true); $template_processor->display("../users/login.tpl"); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $info = ''; if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $to = SJB_Request::getVar('to'); // POST and check for errors form_to form_subject form_message if (isset($_POST['form_to'])) { $to_user_name = SJB_Request::getVar('form_to', null, 'POST'); $to_user_info = null; // trying to get user info by user id if (intval($to_user_name)) { $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name); } /* * в функции compose private message функцию отправки * сообщения по имени пользователя оставить рабочей */ if (is_null($to_user_info)) { $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); } // trying to get user info by user id if (intval($to_user_name)) { $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name); } /* * в функции compose private message функцию отправки * сообщения по имени пользователя оставить рабочей */ if (is_null($to_user_info)) { $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); } $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0; $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : ''; $message = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : ''; $save = isset($_POST['form_save']) ? true : false; if ($to_user == 0) { $errors['form_to'] = 'You specified wrong username'; } if (empty($subject)) { $errors['form_subject'] = 'Please, enter message subject'; } if (empty($message)) { $errors['form_message'] = 'Please, enter message'; } if (count($errors) == 0) { $anonym = SJB_Request::getVar('anonym'); SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $message, $save, false, false, $anonym); $info = 'The message was sent successfully'; $to = ''; // save to contacts if (!$anonym) { SJB_PrivateMessage::saveContact($user_id, $to_user); SJB_PrivateMessage::saveContact($to_user, $user_id); } } else { $tp->assign("form_to", htmlentities($to_user_name, ENT_QUOTES, "UTF-8")); $tp->assign("form_subject", htmlentities($subject, ENT_QUOTES, "UTF-8")); $tp->assign("form_message", $message); $tp->assign("form_save", $save); $tp->assign("errors", $errors); } } $display_to = ''; // get display name for "Message to" field SJB_UserManager::getComposeDisplayName($to, $display_to); $tp->assign('info', $info); $tp->assign('to', $to); $tp->assign('anonym', SJB_Request::getVar('anonym')); $tp->assign('display_to', $display_to); $tp->assign('include', 'new_message.tpl'); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('main.tpl'); } 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(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $errors = array(); $info = ''; $to = SJB_Request::getVar('to', '', 'GET'); // POST and check for errors form_to form_subject form_message if (isset($_POST['act'])) { $to_user_name = SJB_Request::getVar('form_to', '', 'POST'); $to_user_info = null; if (intval($to_user_name)) { $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name); } // в функции compose private message функцию отправки // сообщения по имени пользователя оставить рабочей if (is_null($to_user_info)) { $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); } $cc = SJB_Request::getVar('cc', false); if ($cc !== false) { if (intval($cc)) { $cc_info = SJB_UserManager::getUserInfoBySID($cc); } // в функции compose private message функцию отправки // сообщения по имени пользователя оставить рабочей if (is_null($cc_info)) { $cc_info = SJB_UserManager::getUserInfoByUserName($cc); } if (!empty($cc_info)) { $cc = $cc_info['sid']; } } $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0; $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : ''; $message = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : ''; $save = isset($_POST['form_save']) ? $_POST['form_save'] == 1 ? true : false : false; if ($to_user == 0) { $errors['form_to'] = 'Please enter correct username'; } if (empty($subject)) { $errors['form_subject'] = 'Please, enter message subject'; } if (empty($message)) { $errors['form_message'] = 'Please, enter message'; } if (count($errors) == 0) { $anonym = SJB_Request::getVar('anonym'); SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $message, $save, false, $cc, $anonym); // save to contacts if (!$anonym) { SJB_PrivateMessage::saveContact($user_id, $to_user); SJB_PrivateMessage::saveContact($to_user, $user_id); } echo '<p class="message">' . SJB_I18N::getInstance()->gettext(null, 'The message was sent successfully') . '</p>'; exit; } } $display_to = ''; // get display name for 'Message to' field SJB_UserManager::getComposeDisplayName($to, $display_to); $tp->assign('errors', $errors); $tp->assign('info', $info); $tp->assign('to', $to); $tp->assign('display_to', $display_to); $tp->assign('anonym', SJB_Request::getVar('anonym')); $tp->assign('cc', SJB_Request::getVar('cc', '')); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('new_message_ajax.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $tp->assign('ajaxRelocate', true); $tp->display('../users/login.tpl'); } }
public function execute() { /*************************************************** * Integration of JobSource Jobg8 script * * This script integrate P4P of JobG8 ***************************************************/ /* For example in SJB there is a user "emp", с user_id = 8, emal = emp@emp.com, username = EMPjob Are we correct to assume that the encryption parameters will be as follows: ADHOC is ON: ?cid=810388&a=ADHOC&email=emp@emp.com&adv=EMPjob ADHOC is OFF: ?cid=810388&a=8&email=emp@emp.com&adv=EMPjob */ $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $currentUser = SJB_UserManager::getCurrentUserInfo(); $currentUsername = $currentUser['username']; $userEmail = $currentUser['email']; $username = $currentUser['CompanyName']; if (empty($username)) { $username = $currentUser['username']; } // our jobg8 Job Board ID $jobboardID = SJB_Settings::getSettingByName('jobg8_jobboard_id_p4p'); $jobg8_p4p_url = SJB_Settings::getSettingByName('jobg8_p4p_url'); $cid = SJB_Settings::getSettingByName('jobg8_cid'); $markup = ''; $mode = ''; // check current user for individual markup value $result = SJB_DB::query("SELECT * FROM `users_markup` WHERE `user_sid` = ?n", $currentUser['sid']); if (!empty($result)) { $markup = $result[0]['markup']; } // check individual adhoc mode if ($currentUser['jobg8_adhoc'] == 1) { $adhoc_mode = true; } else { $adhoc_mode = false; } // look jobg8 p4p-integration doc (parameter 'a') if ($adhoc_mode) { $mode = 'ADHOC'; } else { $mode = $currentUser['sid']; } ////////////////////////////////// // set region field for P4P // check tax countries and states list ////////////////////////////////// $taxRegions = array('Canada' => array("Alberta" => "AB", "British Columbia" => "BC", "Manitoba" => "MB", "New Brunswick" => "NB", "Newfoundland and Labrador" => "NL", "Nova Scotia" => "NS", "Northwest Territories" => "NT", "Nunavut" => "NU", "Ontario" => "ON", "Prince Edward Island" => "PE", "Quebec" => "QC", "Saskatchewan" => "SK", "Yukon" => "YT"), 'Germany' => 'DEU', 'Spain' => 'ESP', 'Ireland' => 'IRL'); // check country $taxRegionCode = ''; $userCountry = $currentUser['Country']; $userState = $currentUser['State']; if (!empty($userCountry) && !empty($userState) && array_key_exists($userCountry, $taxRegions)) { if (isset($taxRegions[$userCountry]) && is_string($taxRegions[$userCountry])) { $taxRegionCode = $taxRegions[$userCountry]; } elseif (isset($taxRegions[$userCountry]) && is_array($taxRegions[$userCountry]) && array_key_exists($userState, $taxRegions[$userCountry])) { // check region $taxRegionCode = $taxRegions[$userCountry][$userState]; } } if ($markup == '' || !is_numeric($markup)) { if ($mode == 'ADHOC') { $message = "?cid={$cid}&a={$mode}&email={$userEmail}&adv={$username}®ion={$taxRegionCode}"; } else { $message = "?cid={$cid}&a={$mode}®ion={$taxRegionCode}"; } } else { if ($mode == 'ADHOC') { $message = "?cid={$cid}&a={$mode}&email={$userEmail}&adv={$username}&m={$markup}®ion={$taxRegionCode}"; } else { $message = "?cid={$cid}&a={$mode}&m={$markup}®ion={$taxRegionCode}"; } } // use RSA library for crypt $sshKey = JobG8IntegrationPlugin::getRsaKey(); $keyArray = explode(' ', $sshKey, 3); $keyLength = $keyArray[0]; $exponent = $keyArray[1]; $modulus = $keyArray[2]; // Encrypt the message $encryptedData = rsa_encrypt($message, $exponent, $modulus, $keyLength); // Base64 encode the encrypted data $output = urlencode(base64_encode($encryptedData)); $tp->assign('jobg8_p4p_url', $jobg8_p4p_url); $tp->assign('jobboardID', $jobboardID); $tp->assign('encoded_data', $output); $tp->display('jobg8_p4p.tpl'); } else { $tp->assign("return_url", base64_encode(SJB_Navigator::getURIThis())); //$tp->assign("ajaxRelocate", true); $tp->display("../users/login.tpl"); } }
public function execute() { $logged_in = false; $tp = SJB_System::getTemplateProcessor(); $shoppingCart = SJB_Request::getVar('shopping_cart', false); $proceedToPosting = SJB_Request::getVar('proceed_to_posting', false); $productSID = SJB_Request::getVar('productSID', false); $listingTypeID = SJB_Request::getVar('listing_type_id', false); $errors = array(); if (SJB_Authorization::isUserLoggedIn() && !isset($_REQUEST['as_user'])) { $tp->display('already_logged_in.tpl'); } else { $template = SJB_Request::getVar('template', 'login.tpl'); $page_config = SJB_System::getPageConfig(SJB_System::getURI()); if (SJB_Request::getVar('action', false) == 'login') { $username = SJB_Request::getVar('username'); $password = SJB_Request::getVar('password'); $keep_signed = SJB_Request::getVar('keep', false); $login_as_user = false; if (isset($_REQUEST['as_user'])) { $login_as_user = true; if (SJB_UserManager::getCurrentUserSID()) { SJB_Authorization::logout(); } } // redirect user to the home page if it's login page or to the same page otherwise if (SJB_Request::getVar('return_url', false) != false) { $redirect_url = base64_decode(SJB_Request::getVar('return_url')); if (!empty($proceedToPosting)) { $redirect_url .= '&proceed_to_posting=1&productSID=' . $productSID; } } else { if ($page_config->module == 'users' && $page_config->function == 'login') { $redirect_url = SJB_System::getSystemSettings("SITE_URL") . "/my-account/"; } else { $redirect_url = SJB_System::getSystemSettings("SITE_URL") . SJB_System::getURI(); } } if (SJB_UserManager::getCurrentUserSID()) { $logged_in = true; } else { SJB_UserManager::login($username, $password, $errors, false, $login_as_user); if ($errors) { if (is_null(SJB_Session::getValue('userLoginCounter'))) { SJB_Session::setValue('userLoginCounter', 1); } else { SJB_Session::setValue('userLoginCounter', SJB_Session::getValue('userLoginCounter') + 1); } } if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors) && empty($errors)) { $logged_in = SJB_Authorization::login($username, $password, $keep_signed, $errors, $login_as_user); } } if ($logged_in && !$shoppingCart) { SJB_HelperFunctions::redirect($redirect_url); } $tp->assign('logged_in', $logged_in); } $return_url = SJB_Request::getVar('return_url', $page_config->function != 'login' && $page_config->function != 'search_form' ? base64_encode(SJB_Navigator::getURIThis()) : false); if (!filter_var(SJB_System::getSystemSettings("SITE_URL") . base64_decode($return_url), FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) { $return_url = ''; } $tp->assign('shopping_cart', $shoppingCart); $tp->assign('proceedToPosting', $proceedToPosting); $tp->assign('productSID', $productSID); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('return_url', $return_url); $tp->assign('ajaxRelocate', SJB_Request::getVar('ajaxRelocate', false)); $tp->assign('errors', $errors); $tp->assign('adminEmail', SJB_System::getSettingByName('system_email')); $tp->display($template); } }
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(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $id = SJB_Request::getInt('id', 0, 'GET'); if ($id > 0) { $errors = array(); if (isset($_POST['form_to'])) { $to_user_name = isset($_POST['form_to']) ? strip_tags($_POST['form_to']) : ''; $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0; $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : ''; $text = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : ''; $save = isset($_POST['form_save']) ? true : false; $reply_id = isset($_POST['reply_id']) ? $_POST['reply_id'] : false; if ($to_user == 0) { $errors['form_to'] = 'You specified wrong username'; } if (empty($subject)) { $errors['form_subject'] = 'Please, enter message subject'; } if (empty($text)) { $errors['form_message'] = 'Please, enter message'; } if (count($errors) == 0) { $anonym = SJB_Request::getVar('anonym'); SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $text, $save, $reply_id, false, $anonym); // save to contacts if (!$anonym) { SJB_PrivateMessage::saveContact($user_id, $to_user); SJB_PrivateMessage::saveContact($to_user, $user_id); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/'); } else { $message['to_name'] = htmlentities($to_user_name, ENT_QUOTES, "UTF-8"); $message['subject'] = htmlentities($subject, ENT_QUOTES, "UTF-8"); $message['message'] = $text; $tp->assign('save', $save); } } else { if (SJB_PrivateMessage::isMyMessage($id)) { $message = SJB_PrivateMessage::readMessage($id); } else { $errors['NOT_EXISTS_MESSAGE'] = 1; $message = ''; } if ($message) { $message['to_name'] = htmlentities($message['from_name'], ENT_QUOTES, "UTF-8"); $message['subject'] = 'RE: ' . htmlentities($message['subject'], ENT_QUOTES, "UTF-8"); $message['message'] = '<p> </p><blockquote class="pmQuote">' . $message['message'] . '</blockquote>'; } $tp->assign('reply_id', $id); } } $tp->assign('errors', $errors); $tp->assign('include', 'reply_message.tpl'); $tp->assign('message', $message); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('main.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $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); }