Exemplo n.º 1
0
 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');
     }
 }
Exemplo n.º 2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $listingTypeID = SJB_Request::getVar('listing_type_id', '');
     if (SJB_UserManager::isUserLoggedIn()) {
         if (!SJB_Acl::getInstance()->isAllowed('save_' . trim($listingTypeID))) {
             $errors[] = 'DENIED_VIEW_SAVED_LISTING';
         }
         if (!$errors) {
             $userSid = SJB_UserManager::getCurrentUserSID();
             if (SJB_Request::getVar('action', '') == 'delete') {
                 $listing_id = SJB_Request::getVar('listing_id', null);
                 if (!is_null($listing_id)) {
                     foreach ($listing_id as $key => $value) {
                         SJB_SavedListings::deleteListingFromDBBySID($key, $userSid);
                     }
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . SJB_Navigator::getURI());
                 }
             }
             $saved_listings_id = SJB_SavedListings::getSavedListingsFromDB($userSid);
             $listings_structure = array();
             $listing_structure_meta_data = array();
             foreach ($saved_listings_id as $saved_listing) {
                 $saved_listing_id = $saved_listing['listing_sid'];
                 $listing = SJB_ListingManager::getObjectBySID($saved_listing_id);
                 if (is_null($listing)) {
                     continue;
                 }
                 $listing->addPicturesProperty();
                 $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
                 $listings_structure[$listing->getID()] = $listing_structure;
                 $listings_structure[$listing->getID()]['saved_listing'] = $saved_listing;
                 if (isset($listing_structure['METADATA'])) {
                     $listing_structure_meta_data = array_merge($listing_structure_meta_data, $listing_structure['METADATA']);
                 }
             }
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure_meta_data)));
             $tp->assign("listings", $listings_structure);
             $tp->assign("listing_type_id", $listingTypeID);
             $tp->display("saved_listings.tpl");
         } else {
             $tp->assign("errors", $errors);
             $tp->display("save_search_failed.tpl");
         }
     } else {
         $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/system/classifieds" . SJB_System::getURI());
         switch ($listingTypeID) {
             case 'job':
                 $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/saved-jobs/");
                 break;
             case 'resume':
                 $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/saved-resumes/");
                 break;
         }
         $tp->assign("return_url", $url);
         $tp->display("../users/login.tpl");
     }
 }
Exemplo n.º 3
0
 function SJB_ListingCriteriaSaver($storage_id = '')
 {
     $storage_id = 'ListingSearcher' . $storage_id;
     parent::SJB_CriteriaSaver($storage_id, new SJB_ListingManager());
     $this->uri =& $_SESSION[$storage_id]['uri'];
     if (is_null($this->uri)) {
         $this->uri = SJB_Navigator::getURI();
     }
 }
Exemplo n.º 4
0
 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");
     }
 }
Exemplo n.º 5
0
 private function getCallBackUrl($feedSID, $action, $formSubmitted)
 {
     $url = SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI() . '?soc_network=twitter&process_token=1';
     if ($formSubmitted) {
         $url .= '&submit=' . $formSubmitted;
     }
     if (!empty($feedSID)) {
         $url .= '&sid=' . $feedSID;
         if ($action == 'grant') {
             $url .= '&action=authorize&sub_action=' . $action;
         } else {
             $url .= '&action=' . $action;
         }
     } else {
         $url .= '&action=' . $action;
     }
     return $url;
 }
Exemplo n.º 6
0
 public function execute()
 {
     $this->tp = SJB_System::getTemplateProcessor();
     if (!SJB_Authorization::isUserLoggedIn() && class_exists('SJB_SocialPlugin') && '/registration-social/' != SJB_Navigator::getUri() && ($socPlugins = SJB_SocialPlugin::getAvailablePlugins())) {
         $this->showErrorsIfExist();
         $userGroupID = SJB_Request::getVar('user_group_id', null);
         SJB_SocialPlugin::preparePluginsThatAreAvailableForRegistration($socPlugins, $userGroupID);
         if (empty($socPlugins)) {
             return null;
         }
         if ($userGroupID) {
             $this->tp->assign('user_group_id', $userGroupID);
         }
         $socNetworks = SJB_SocialPlugin::getSocialNetworks($socPlugins);
         $this->tp->assign('label', SJB_Request::getVar('label', null));
         $this->tp->assign('social_plugins', $socNetworks);
         $this->tp->assign('shoppingCart', SJB_Request::getVar('shoppingCart', null));
         $this->tp->display('social_plugins.tpl');
     } else {
         $this->showErrorsIfExist();
     }
 }
Exemplo n.º 7
0
 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}&region={$taxRegionCode}";
             } else {
                 $message = "?cid={$cid}&a={$mode}&region={$taxRegionCode}";
             }
         } else {
             if ($mode == 'ADHOC') {
                 $message = "?cid={$cid}&a={$mode}&email={$userEmail}&adv={$username}&m={$markup}&region={$taxRegionCode}";
             } else {
                 $message = "?cid={$cid}&a={$mode}&m={$markup}&region={$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");
     }
 }
Exemplo n.º 8
0
 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');
     }
 }
Exemplo n.º 9
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template = SJB_Request::getVar('template', 'users.tpl');
     $searchTemplate = SJB_Request::getVar('search_template', 'user_search_form.tpl');
     $passedParametersViaUri = SJB_UrlParamProvider::getParams();
     $userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false;
     $userGroupSID = $userGroupID ? SJB_UserGroupManager::getUserGroupSIDByID($userGroupID) : null;
     $errors = array();
     /********** A C T I O N S   W I T H   U S E R S **********/
     $action = SJB_Request::getVar('action_name');
     if (!empty($action)) {
         $users_sids = SJB_Request::getVar('users', array());
         $_REQUEST['restore'] = 1;
         switch ($action) {
             case 'approve':
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     SJB_UserManager::setApprovalStatusByUserName($username, 'Approved');
                     SJB_UserManager::activateUserByUserName($username);
                     SJB_UserDBManager::deleteActivationKeyByUsername($username);
                     if (!SJB_SocialPlugin::getProfileSocialID($user_sid)) {
                         SJB_Notifications::sendUserWelcomeLetter($user_sid);
                     } else {
                         SJB_Notifications::sendUserApprovedLetter($user_sid);
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'reject':
                 $rejection_reason = SJB_Request::getVar('rejection_reason', '');
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     SJB_UserManager::setApprovalStatusByUserName($username, 'Rejected', $rejection_reason);
                     SJB_UserManager::deactivateUserByUserName($username);
                     SJB_Notifications::sendUserRejectedLetter($user_sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'activate':
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     $userinfo = SJB_UserManager::getUserInfoByUserName($username);
                     SJB_UserManager::activateUserByUserName($username);
                     if ($userinfo['approval'] == 'Approved') {
                         SJB_UserDBManager::deleteActivationKeyByUsername($username);
                         SJB_Notifications::sendUserApprovedLetter($user_sid);
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'deactivate':
                 foreach ($users_sids as $user_sid => $value) {
                     $username = SJB_UserManager::getUserNameByUserSID($user_sid);
                     SJB_UserManager::deactivateUserByUserName($username);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'delete':
                 foreach (array_keys($users_sids) as $user_sid) {
                     try {
                         SJB_UserManager::deleteUserById($user_sid);
                     } catch (Exception $e) {
                         $errors[] = $e->getMessage();
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'send_activation_letter':
                 foreach ($users_sids as $user_sid => $value) {
                     SJB_Notifications::sendUserActivationLetter($user_sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'change_product':
                 $productToChange = SJB_Request::getVar('product_to_change');
                 if (empty($productToChange)) {
                     $productToChange = 0;
                 }
                 foreach ($users_sids as $user_sid => $value) {
                     $user = SJB_UserManager::getObjectBySID($user_sid);
                     // UNSUBSCRIBE selected
                     if ($productToChange == 0) {
                         SJB_ContractManager::deleteAllContractsByUserSID($user_sid);
                     } else {
                         $productInfo = SJB_ProductsManager::getProductInfoBySID($productToChange);
                         $listingNumber = SJB_Request::getVar('number_of_listings', null);
                         if (is_null($listingNumber) && !empty($productInfo['number_of_listings'])) {
                             $listingNumber = $productInfo['number_of_listings'];
                         }
                         $contract = new SJB_Contract(array('product_sid' => $productToChange, 'numberOfListings' => $listingNumber, 'is_recurring' => 0));
                         $contract->setUserSID($user_sid);
                         $contract->saveInDB();
                         if ($contract->isFeaturedProfile()) {
                             SJB_UserManager::makeFeaturedBySID($user_sid);
                         }
                     }
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 break;
             case 'ban_ip':
                 $cantBanUsers = array();
                 foreach ($users_sids as $user_sid => $value) {
                     $user = SJB_UserManager::getUserInfoBySID($user_sid);
                     if ($user['ip'] && !SJB_IPManager::getBannedIPByValue($user['ip'])) {
                         SJB_IPManager::makeIPBanned($user['ip']);
                     } else {
                         $cantBanUsers[] = $user['username'];
                     }
                 }
                 if ($cantBanUsers) {
                     $tp->assign('cantBanUsers', $cantBanUsers);
                 } else {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 }
                 break;
             case 'unban_ip':
                 $cantUnbanIPs = array();
                 foreach ($users_sids as $user_sid => $value) {
                     $user = SJB_UserManager::getUserInfoBySID($user_sid);
                     if ($user['ip'] !== '') {
                         if (SJB_IPManager::getBannedIPByValue($user['ip'])) {
                             SJB_IPManager::makeIPEnabledByValue($user['ip']);
                         } elseif (SJB_UserManager::checkBan($errors, $user['ip'])) {
                             $cantUnbanIPs[] = $user['ip'];
                         }
                     }
                 }
                 if ($cantUnbanIPs) {
                     $tp->assign('rangeIPs', $cantUnbanIPs);
                 } else {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
                 }
                 break;
             default:
                 unset($_REQUEST['restore']);
                 break;
         }
         if (empty($errors)) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI());
         }
     }
     /***************************************************************/
     $_REQUEST['action'] = 'search';
     $user = new SJB_User(array(), $userGroupSID);
     $user->addProperty(array('id' => 'user_group', 'type' => 'list', 'value' => '', 'is_system' => true, 'list_values' => SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions()));
     $user->addProperty(array('id' => 'registration_date', 'type' => 'date', 'value' => '', 'is_system' => true));
     $user->addProperty(array('id' => 'approval', 'caption' => 'Approval', 'type' => 'list', 'list_values' => array(array('id' => 'Pending', 'caption' => 'Pending'), array('id' => 'Approved', 'caption' => 'Approved'), array('id' => 'Rejected', 'caption' => 'Rejected')), 'length' => '10', 'is_required' => false, 'is_system' => true));
     // get array of accessible products
     $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userGroupSID);
     $products = array();
     foreach ($productsSIDs as $key => $productSID) {
         $product = SJB_ProductsManager::getProductInfoBySID($productSID);
         $products[$key] = $product;
         if (!empty($product['pricing_type']) && $product['pricing_type'] == 'volume_based' && !empty($product['volume_based_pricing'])) {
             $volumeBasedPricing = $product['volume_based_pricing'];
             $minListings = min($volumeBasedPricing['listings_range_from']);
             $maxListings = max($volumeBasedPricing['listings_range_to']);
             $countListings = array();
             for ($i = $minListings; $i <= $maxListings; $i++) {
                 $countListings[] = $i;
             }
             $products[$key]['count_listings'] = $countListings;
         }
     }
     $user->addProperty(array('id' => 'product', 'type' => 'list', 'value' => '', 'list_values' => $products, 'is_system' => true));
     $aliases = new SJB_PropertyAliases();
     $aliases->addAlias(array('id' => 'user_group', 'real_id' => 'user_group_sid', 'transform_function' => 'SJB_UserGroupManager::getUserGroupSIDByID'));
     $aliases->addAlias(array('id' => 'product', 'real_id' => 'product_sid'));
     $_REQUEST['user_group']['equal'] = $userGroupSID;
     $search_form_builder = new SJB_SearchFormBuilder($user);
     $criteria_saver = new SJB_UserCriteriaSaver();
     if (isset($_REQUEST['restore'])) {
         $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
     }
     $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user);
     $search_form_builder->setCriteria($criteria);
     $search_form_builder->registerTags($tp);
     $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSID);
     if (SJB_Request::getVar('online', '') == '1') {
         $tp->assign("online", true);
     }
     $tp->assign('userGroupInfo', $userGroupInfo);
     $tp->assign('products', $products);
     $tp->assign('selectedProduct', isset($_REQUEST['product']['simple_equal']) ? $_REQUEST['product']['simple_equal'] : '');
     $tp->display($searchTemplate);
     /********************** S O R T I N G *********************/
     $paginator = new SJB_UsersPagination($userGroupInfo, SJB_Request::getVar('online', ''), $template);
     $firstLastName = '';
     if (!empty($_REQUEST['FirstName']['equal'])) {
         $name['FirstName']['any_words'] = $name['LastName']['any_words'] = $_REQUEST['FirstName']['equal'];
         $firstLastName = $_REQUEST['FirstName'];
         unset($_REQUEST['FirstName']);
         $_REQUEST['FirstName']['fields_or'] = $name;
     }
     $criteria = $search_form_builder->extractCriteriaFromRequestData($_REQUEST, $user);
     $inner_join = false;
     // if search by product field
     if (isset($_REQUEST['product']['simple_equal']) && $_REQUEST['product']['simple_equal'] != '') {
         $inner_join = array('contracts' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'join' => 'INNER JOIN'));
     }
     if (SJB_Request::getVar('online', '') == '1') {
         $maxLifeTime = ini_get("session.gc_maxlifetime");
         $currentTime = time();
         $innerJoinOnline = array('user_session_data_storage' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'select_field' => 'session_id', 'join' => 'INNER JOIN', 'where' => "AND unix_timestamp(`user_session_data_storage`.`last_activity`) + {$maxLifeTime} > {$currentTime}"));
         if ($inner_join) {
             $inner_join = array_merge($inner_join, $innerJoinOnline);
         } else {
             $inner_join = $innerJoinOnline;
         }
     }
     $searcher = new SJB_UserSearcher(array('limit' => ($paginator->currentPage - 1) * $paginator->itemsPerPage, 'num_rows' => $paginator->itemsPerPage), $paginator->sortingField, $paginator->sortingOrder, $inner_join);
     $found_users = array();
     $found_users_sids = array();
     if (SJB_Request::getVar('action', '') == 'search') {
         $found_users = $searcher->getObjectsSIDsByCriteria($criteria, $aliases);
         $criteria_saver->setSession($_REQUEST, $searcher->getFoundObjectSIDs());
     } elseif (isset($_REQUEST['restore'])) {
         $found_users = $criteria_saver->getObjectsFromSession();
     }
     foreach ($found_users as $id => $userID) {
         $user_info = SJB_UserManager::getUserInfoBySID($userID);
         $contractInfo = SJB_ContractManager::getAllContractsInfoByUserSID($user_info['sid']);
         $user_info['products'] = count($contractInfo);
         $found_users[$id] = $user_info;
     }
     $paginator->setItemsCount($searcher->getAffectedRows());
     $sorted_found_users_sids = $found_users_sids;
     /****************************************************************/
     $tp->assign("userGroupInfo", $userGroupInfo);
     $tp->assign("found_users", $found_users);
     $searchFields = '';
     foreach ($_REQUEST as $key => $val) {
         if (is_array($val)) {
             foreach ($val as $fieldName => $fieldValue) {
                 if (is_array($fieldValue)) {
                     foreach ($fieldValue as $fieldSubName => $fieldSubValue) {
                         $searchFields .= "&{$key}[{$fieldSubName}]=" . array_pop($fieldSubValue);
                     }
                 } else {
                     $searchFields .= "&{$key}[{$fieldName}]={$fieldValue}";
                 }
             }
         }
     }
     $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     $tp->assign("searchFields", $searchFields);
     $tp->assign("found_users_sids", $sorted_found_users_sids);
     $tp->assign('errors', $errors);
     $tp->display($template);
 }
Exemplo n.º 10
0
 private function __construct($uri = null)
 {
     // fill request properties
     if (isset($_SERVER['REQUEST_METHOD'])) {
         self::$method = self::getVar('REQUEST_METHOD', '', 'SERVER');
     }
     // $_SERVER['REQUEST_METHOD'];
     if (isset($_SERVER['REMOTE_ADDR'])) {
         self::$remoteAddr = self::getVar('REMOTE_ADDR', '', 'SERVER');
     }
     // $_SERVER['REMOTE_ADDR'];
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
         self::$userAgent = self::getVar('HTTP_USER_AGENT', '', 'SERVER');
     }
     // default header
     $this->headers['Content-type'] = 'text/html;charset=utf-8';
     $this->uri = $uri;
     if ($uri === null || empty($uri)) {
         $this->uri = SJB_Navigator::getUri();
     }
     $errors = array();
     if (SJB_UserManager::checkBan($errors) && SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') != SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE')) {
         $this->uri = "/user-banned/";
     }
     // maintenance mode
     if (SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') != SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE')) {
         $oMaintenance = new SJB_MaintenanceMode(self::$remoteAddr);
         if (!$oMaintenance->getAllowed()) {
             $this->uri = '/maintenance-mode/';
         }
     }
     $this->page_config = SJB_PageConfig::getPageConfig($this->uri);
 }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
 /**
  * @return array
  */
 public static function getPageModule()
 {
     $modules = SJB_DB::query("SELECT `module` FROM `pages` WHERE `uri` = ?s", SJB_Navigator::getURI());
     $moduleNames = array();
     foreach ($modules as $module) {
         $moduleNames[] = $module['module'];
     }
     return $moduleNames;
 }
Exemplo n.º 13
0
 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>&nbsp;</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');
     }
 }
Exemplo n.º 14
0
 /**
  * @static
  * @param int $listingId
  * @param string $ipAddress
  */
 public static function setListingLatestViewDateByIp($listingId, $ipAddress)
 {
     $listingViewPageID = self::getListingViewPageID($ipAddress, $listingId);
     $pageId = SJB_System::getUserPageParentURI(SJB_Navigator::getURI());
     if ($listingViewPageID) {
         SJB_DB::query('UPDATE `page_view` SET `date` = NOW() WHERE `id` = ?n', $listingViewPageID);
     } else {
         SJB_DB::query('INSERT INTO `page_view` SET `id_pages` = ?s, `param` = ?n, `ip_address` = ?s, `date` = NOW(), `contract_id` = 0', $pageId, $listingId, $ipAddress);
     }
 }
Exemplo n.º 15
0
 public function createCallbackUrl()
 {
     return SJB_System::getSystemSettings('SITE_URL') . SJB_Navigator::getURI() . '?network=linkedin&' . SJB_LinkedIn::_GET_RESPONSE . '=1';
 }
Exemplo n.º 16
0
 public static function getURI()
 {
     return SJB_Navigator::getURI();
 }
Exemplo n.º 17
0
 /**
  * @param  string $selectedSids
  * @return string
  */
 private function getParentsSid($selectedSids)
 {
     $table = in_array('users', SJB_PageManager::getPageModule()) || SJB_Navigator::getURI() == '/registration-social/' ? 'user_profile_field_tree' : 'listing_field_tree';
     $result = SJB_DB::query("SELECT `parent_sid`, `level` FROM `{$table}` WHERE `sid` IN (?w)", $selectedSids);
     $parentSids = '';
     $allSids = '';
     foreach ($result as $value) {
         $allSids .= ',' . $value['parent_sid'];
         if ($value['level'] > 2) {
             $parentSids .= empty($parentSids) ? $value['parent_sid'] : ',' . $value['parent_sid'];
         }
     }
     if (!empty($parentSids)) {
         $allSids .= $this->getParentsSid($parentSids);
     }
     return $allSids;
 }
Exemplo n.º 18
0
 /**
  * @param array $menu
  * @param $item
  * @param $menuKey
  * @param $itemKey
  */
 private function removeSimilarHighlight(array &$menu, $item, $menuKey, $itemKey)
 {
     if (in_array(SJB_System::getSystemSettings('SITE_URL') . $this->pageID, $item['highlight'])) {
         $highlight = '';
         $highlightPrefix = '/manage-';
         $userSid = SJB_Request::getVar('user_sid', 0);
         switch ($menuKey) {
             case 'Listing Configuration':
                 $fieldSID = SJB_Request::getVar('field_sid', false);
                 if ($fieldSID) {
                     $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($fieldSID);
                     //remove unwanted highlights
                     if ($fieldInfo['listing_type_sid'] == 0 && $item['title'] == 'Listing Types' || $fieldInfo['listing_type_sid'] != 0 && $item['title'] == 'Common Fields') {
                         $highlight = $this->pageID;
                     }
                 }
                 break;
             case 'Listing Management':
                 if (preg_match('/manage-resume|job|[a-zA-Z0-9]+-listings/', $item['reference']) && !preg_match('/import|export|flagged-listings/', $item['reference'])) {
                     if (!($listingTypeId = SJB_Request::getVar('listing_type_id', null))) {
                         $listingId = SJB_Request::getVar('listing_id', null);
                         $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                         $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
                     }
                     $highlight = strtolower($listingTypeId);
                 }
                 break;
             case 'Users':
                 $highlightPrefix = '/manage-users/';
                 if ($userSid) {
                     $userGroupSid = SJB_UserManager::getUserGroupByUserSid($userSid);
                     $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSid);
                     if (preg_match($highlightPrefix, $item['reference'])) {
                         $highlight = strtolower($userGroupInfo['id']);
                     }
                 } else {
                     if ($role = SJB_Request::getVar('role', null)) {
                         $type = SJB_Request::getVar('type', null);
                         // for user permissions
                         if ($type == 'user') {
                             $role = SJB_UserManager::getUserGroupByUserSid($role);
                             $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($role);
                             $highlight = strtolower($userGroupInfo['id']);
                         } else {
                             if (in_array($type, array('group', 'guest'))) {
                                 $highlightPrefix = 'user-';
                                 $highlight = 'group';
                             }
                         }
                     } else {
                         //retrieve user group from uri
                         if (preg_match('|./(\\w*)/?|u', urldecode(SJB_Navigator::getURI()), $userGroupHub)) {
                             $highlight = array_pop($userGroupHub);
                         }
                         //remove unwanted highlights
                         if ($this->pageID == '/email-log/') {
                             $highlight = $this->pageID;
                         }
                     }
                 }
                 break;
             case 'System Configuration':
                 //remove unwanted highlights
                 if ($this->pageID == '/email-log/' && $userSid) {
                     $highlight = $this->pageID;
                 }
                 break;
             default:
         }
         if (!$highlight || strpos($item['reference'], $highlightPrefix . $highlight) !== false) {
             if (!isset($this->handledHighlightGroups[$highlightPrefix])) {
                 $this->handledHighlightGroups[$highlightPrefix] = true;
                 $handledHighlightGroups[$highlightPrefix] = true;
                 $menu[$menuKey][$itemKey]['active'] = true;
                 $menu[$menuKey]['active'] = true;
             }
         }
     }
 }
Exemplo n.º 19
0
 public function isAccessible()
 {
     $permLabel = preg_replace(array("/\\//", "/-/"), array("", "_"), SJB_Navigator::getURI());
     $this->setPermissionLabel($permLabel);
     return parent::isAccessible();
 }
Exemplo n.º 20
0
 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");
     }
 }
Exemplo n.º 21
0
 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);
     }
 }
Exemplo n.º 22
0
 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');
     }
 }
Exemplo n.º 23
0
 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);
 }