public function execute() { if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $etSID = SJB_Array::get($passed_parameters_via_uri, 0); } $field_id = SJB_Request::getVar('field_id', null); $etInfo = SJB_EmailTemplateEditor::getEmailTemplateInfoBySID($etSID); if (is_null($etSID) || is_null($field_id)) { $errors['PARAMETERS_MISSED'] = 1; } elseif (is_null($etInfo) || !isset($etInfo[$field_id])) { $errors['WRONG_PARAMETERS_SPECIFIED'] = 1; } else { $uploaded_file_id = $etInfo[$field_id]; SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id); $etInfo[$field_id] = ''; $emailTemplate = new SJB_EmailTemplate($etInfo); $emailTemplate->setSID($etSID); SJB_EmailTemplateEditor::saveEmailTemplate($emailTemplate); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/edit-email-templates/' . $emailTemplate->getPropertyValue('group') . '/' . $etSID); } $tp = SJB_System::getTemplateProcessor(); $tp->assign('errors', isset($errors) ? $errors : null); $tp->display('delete_uploaded_file.tpl'); }
public function execute() { $errors = array(); $this->setEtGroups(SJB_EmailTemplateEditor::getEmailTemplateGroups()); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $etGroup = SJB_Array::get($passed_parameters_via_uri, 0); $etSID = SJB_Array::get($passed_parameters_via_uri, 1); $action = SJB_Array::get($passed_parameters_via_uri, 2); if ($etGroup && SJB_Array::get($this->etGroups, $etGroup)) { $this->tp->assign('group', $etGroup); if ($etSID) { switch ($action) { case 'delete': $this->deleteEmailTemplate($etGroup, $etSID); break; case 'getvars': $this->prepareTemplateVarsInfo($etGroup); exit; break; default: if (isset($_FILES['file']) && $_FILES['file']['name'] && $_FILES['file']['error']) { $errors['Attachment'] = 'UPLOAD_ERR_INI_SIZE'; } else { $filename = SJB_Request::getVar('filename', false); if ($filename) { SJB_UploadFileManager::openEmailTemplateFile($filename, $etSID); $errors['NO_SUCH_FILE'] = true; } } $this->editEmailTemplate($etSID, $errors); break; } } else { $this->addNewTemplateForm($etGroup); $this->getEmailTemplatesByGroup($etGroup); } } } else { $this->addNewTemplateForm(); } if ($errors || $this->errors) { $errors = array_merge($errors, $this->errors); } $this->tp->assign('message', $this->successMessage); $this->tp->assign('error', $this->error); $this->tp->assign('errors', $errors); $this->tp->assign('etGroups', $this->etGroups); $this->tp->assign('uploadMaxFilesize', SJB_UploadFileManager::getIniUploadMaxFilesize()); $this->tp->display($this->template); }
/** * * @param SJB_PageConfig $page_config */ public static function getPage($page_config) { SJB_System::setPageTitle($page_config->getPageTitle()); SJB_System::setGlobalTemplateVariable('user_page_uri', $page_config->getPageUri()); SJB_System::setPageKeywords($page_config->getPageKeywords()); SJB_System::setPageDescription($page_config->getPageDescription()); if ($page_config->getMainContentFunction() == 'add_listing') { $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false); if ($passed_parameters_via_uri) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); if (isset($passed_parameters_via_uri[2])) { $page_config->setMainContentFunction('add_listing_step'); } } } $maincontent = SJB_System::executeFunction($page_config->getMainContentModule(), $page_config->getMainContentFunction(), $page_config->getParameters(), $page_config->getPageUri()); if ($page_config->hasRawOutput()) { return $maincontent; } $page_templates_set_name = SJB_System::getSystemSettings('PAGE_TEMPLATES_MODULE_NAME'); $template_supplier = new SJB_TemplateSupplier($page_templates_set_name); $tp = new SJB_TemplateProcessor($template_supplier); // assign 'highlight_templates' variable to main or index template if (SJB_Settings::getSettingByName('highlight_templates') == 1 && SJB_Request::getVar('admin_mode', false, 'COOKIE')) { $tp->assign('highlight_templates', true); } if ($errors = SJB_Error::getErrorContent()) { SJB_FlashMessages::getInstance()->addWarning($errors); } $tp->assign('MAIN_CONTENT', $maincontent); $tp->registerGlobalVariables(); $tp->assign('sjb_version', SJB_System::getSystemSettings('SJB_VERSION')); $template = $page_config->getPageTemplate(); $template_supplier->addContainerTemplate($template); if (SJB_Request::isAjax()) { $template = SJB_System::getSettingByName('default_page_template_by_http'); } elseif (SJB_FormBuilderManager::getIfBuilderModeIsSet()) { $template = 'index_b.tpl'; } else { if (empty($template)) { $template = SJB_Settings::getSettingByName('DEFAULT_PAGE_TEMPLATE'); } } return $tp->fetch($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $sid = false; if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } $cu = SJB_UserManager::getCurrentUser(); if (!isset($cu->user_group_sid)) { $userGroupSID = 0; } else { $userGroupSID = $cu->user_group_sid; } $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; if ($sid && SJB_PollsManager::isActive($sid, $userGroupSID, $langId)) { $countVotes = SJB_PollsManager::getCountVotesBySID($sid); $pollResults = SJB_PollsManager::getPollResultsBySID($sid); $result = array(); $i = 0; $colors = array('613978', 'aad434', 'f55c00', 'f9c635', 'f97c9e', '870000', '0ec300', '6f6f6f', '0400a5', '6eeffb', '000000', 'ff00ff'); foreach ($pollResults as $poll) { $result[$i]['vote'] = $countVotes > 0 ? round(100 / $countVotes * $poll['count'], 2) : 0; $result[$i]['value'] = $poll['question']; $result[$i]['color'] = $colors[$i]; $i++; } $pollInfo = SJB_PollsManager::getPollInfoBySID($sid); $tp->assign('pollInfo', $pollInfo); $tp->assign('result', $result); $tp->assign('width', count($pollResults) * 40 + (count($pollResults) - 1) * 3); $tp->assign('show_total_votes', isset($pollInfo['show_total_votes']) ? $pollInfo['show_total_votes'] : 0); $tp->assign('count_vote', $countVotes); } else { $pollInfo = SJB_PollsManager::getPollInfoBySID($sid); if ($pollInfo['language'] != $langId) { $errors[] = 'This poll is not available for this language'; } } $tp->assign('errors', $errors); $tp->display('poll_results.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = null; if (SJB_UserManager::isUserLoggedIn()) { $userSID = SJB_UserManager::getCurrentUserSID(); $contactSID = 0; $errors = array(); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $contactSID = SJB_Array::get($passed_parameters_via_uri, 0); } if (!$contactSID) { $errors['UNDEFINED_CONTACT_ID'] = 1; } else { $contactInfo = SJB_PrivateMessage::getContactInfo($userSID, $contactSID); if (!$contactInfo) { $errors['WRONG_CONTACT_ID_SPECIFIED'] = 1; } else { $action = SJB_Request::getVar('action'); switch ($action) { case 'save': $note = SJB_Request::getVar('note'); $result = SJB_PrivateMessage::saveContactNote($userSID, $contactSID, $note); if ($result) { $tp->assign('noteSaved', true); } break; default: break; } } $tp->assign('contactInfo', $contactInfo); } $tp->assign('errors', $errors); } if ($action) { $tp->assign('action', $action); $tp->display('notes.tpl'); } else { $tp->display('contact.tpl'); } }
public function execute() { $this->tp = SJB_System::getTemplateProcessor(); $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $promotionSID = array_shift($passedParametersViaUri); $promotionCodeInfo = SJB_PromotionsManager::getCodeInfoBySID($promotionSID); $this->tp->assign('promotionInfo', $promotionCodeInfo); if (!$promotionCodeInfo) { array_push($this->errors, 'INVALID_ID'); } $page = SJB_Request::getInt('page', 1); $itemsPerPage = SJB_Request::getInt('items_per_page', 50); $itemsCount = SJB_PromotionsManager::getHistoryCountBySID($promotionSID); $this->assignParametersForPagination($page, $itemsPerPage, $itemsCount); $promotions = SJB_PromotionsManager::getHistoryBySID($promotionSID, $page, $itemsPerPage); SJB_PromotionsManager::preparePromotionsInfoForLog($promotions); $currency = SJB_CurrencyManager::getDefaultCurrency(); $this->tp->assign('currency', $currency); $this->tp->assign('promotions', $promotions); $this->tp->assign('errors', $this->errors); $this->tp->display('promotions_log.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn() === false) { $tp->assign('ERROR', 'NOT_LOGIN'); $tp->display('../miscellaneous/error.tpl'); return; } $appsSID = 0; if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $appsSID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } if (SJB_Applications::isUserOwnerApps(SJB_UserManager::getCurrentUserSID(), $appsSID)) { $apps_info = SJB_Applications::getBySID($appsSID); if (!empty($apps_info['questionnaire'])) { $questions = unserialize($apps_info['questionnaire']); $tp->assign('questions', $questions); } $tp->assign('apps_info', $apps_info); $tp->display('view_questionaire.tpl'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $display_form = new SJB_Form(); $display_form->registerTags($tp); $errors = array(); $criteria_saver = new SJB_ListingCriteriaSaver('MyListings'); $listingSID = SJB_Request::getVar("listing_id"); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $listingSID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } $template = SJB_Request::getVar('display_template', 'display_listing.tpl'); if (is_null($listingSID)) { $errors['UNDEFINED_LISTING_ID'] = true; } elseif (is_null($listing = SJB_ListingManager::getObjectBySID($listingSID))) { $errors['WRONG_LISTING_ID_SPECIFIED'] = true; } elseif (!$listing->isActive() && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) { $errors['LISTING_IS_NOT_ACTIVE'] = true; } else { $listing->addPicturesProperty(); if ($listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) { $errors['NOT_OWNER'] = true; } $display_form = new SJB_Form($listing); $display_form->registerTags($tp); $form_fields = $display_form->getFormFieldsInfo(); $listingOwner = SJB_UserManager::getObjectBySID($listing->user_sid); // listing preview @author still $listingTypeSID = $listing->getListingTypeSID(); $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSID); if (SJB_Request::getInstance()->page_config->uri == '/' . strtolower($listingTypeID) . '-preview/') { if (!empty($_SERVER['HTTP_REFERER']) && (stristr($_SERVER['HTTP_REFERER'], 'edit-' . $listingTypeID) || stristr($_SERVER['HTTP_REFERER'], 'clone-job'))) { $tp->assign('referer', $_SERVER['HTTP_REFERER']); } else { $lastPage = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID); $lastPage = array_pop($lastPage); $tp->assign('referer', SJB_System::getSystemSettings('SITE_URL') . '/add-listing/' . $listingTypeID . '/' . $lastPage['page_id'] . '/' . $listing->getSID()); } $tp->assign('checkouted', SJB_ListingManager::isListingCheckOuted($listing->getSID())); $tp->assign('contract_id', $listing->contractID); } $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing, array('comments', 'ratings')); $filename = SJB_Request::getVar('filename', false); if ($filename) { SJB_UploadFileManager::openFile($filename, $listingSID); $errors['NO_SUCH_FILE'] = true; } $prev_and_next_listing_id = $criteria_saver->getPreviousAndNextObjectID($listingSID); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listingStructure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); $comments = ''; $comments_total = ''; if (SJB_Settings::getSettingByName('show_comments') == '1') { $comments = SJB_CommentManager::getEnabledCommentsToListing($listingSID); $comments_total = count($comments); } $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', $listingSID); $tp->assign('form_fields', $form_fields); $tp->assign('video_fields', SJB_HelperFunctions::takeMediaFields($form_fields)); $tp->filterThenAssign("listing", $listingStructure); $tp->assign('prev_next_ids', $prev_and_next_listing_id); $tp->assign('preview_listing_sid', SJB_Request::getVar('preview_listing_sid')); $tp->assign('listingOwner', $listingOwner); if (SJB_Request::getVar('action', false) == 'download_pdf_version') { $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_PDF, SJB_Array::getPath($listingStructure, 'type/id')); $formBuilder->setChargedTemplateProcessor($tp); $tpl = 'resume_to_pdf.tpl'; $filename = $listingStructure['user']['FirstName'] . ' ' . $listingStructure['user']['LastName'] . '_' . $listingStructure['Title'] . '.pdf'; try { $tp->assign('myListing', 1); $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") . '/my-resume-details/' . $listingSID . '/?error=TCPDF_ERROR'); } } else { $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, SJB_Array::getPath($listingStructure, 'type/id')); $formBuilder->setChargedTemplateProcessor($tp); } } $search_criteria_structure = $criteria_saver->createTemplateStructureForCriteria(); $tp->filterThenAssign('search_criteria', $search_criteria_structure); $tp->assign('errors', $errors); $tp->assign('myListing', true); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false); $listing_type_id = ''; $action = SJB_Request::getVar('action', 'list'); $pageSID = SJB_Request::getVar('page_sid', 0); if ($passed_parameters_via_uri) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $listing_type_id = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; $action = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : $action; $pageSID = isset($passed_parameters_via_uri[2]) ? $passed_parameters_via_uri[2] : $pageSID; } $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id); $submit = SJB_Request::getVar('submit', false); $errors = array(); $template = 'posting_pages.tpl'; if ($listing_type_sid) { $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_type_sid); switch ($action) { case 'new': $page = new SJB_PostingPages($_REQUEST, $listing_type_sid); $form = new SJB_Form($page); $form->registerTags($tp); $form_fields = $form->getFormFieldsInfo(); if ($submit) { $addValidParam = array('field' => 'listing_type_sid', 'value' => $listing_type_sid); if ($form->isDataValid($errors, $addValidParam)) { SJB_PostingPagesManager::savePage($page); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/posting-pages/" . strtolower($listingTypeInfo['id']) . "/added"); } } $tp->assign("form_fields", $form_fields); $template = 'input_page_form.tpl'; break; case 'edit': $template = 'input_page_form.tpl'; $field_action = SJB_Request::getVar('field_action'); $pageInfo = SJB_PostingPagesManager::getPageInfoBySID($pageSID); $pageInfo = array_merge($pageInfo, $_REQUEST); $page = new SJB_PostingPages($pageInfo, $listing_type_sid); $page->setSID($pageSID); $form = new SJB_Form($page); $form->registerTags($tp); $form_fields = $form->getFormFieldsInfo(); if ($submit) { $addValidParam = array('field' => 'listing_type_sid', 'value' => $listing_type_sid); if ($form->isDataValid($errors, $addValidParam)) { SJB_PostingPagesManager::savePage($page); $pageInfo = SJB_PostingPagesManager::getPageInfoBySID($pageSID); if ($submit == 'save') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/posting-pages/" . $listing_type_id . "/"); } } } //echo "field_action: $field_action<br>"; exit; switch ($field_action) { case 'add_fields': $listing_fields = SJB_Request::getVar('listing_fields', array()); foreach ($listing_fields as $listing_field) { SJB_PostingPagesManager::addListingFieldOnPage($listing_field, $pageSID, $listing_type_sid); } break; case 'move_down': $field_sid = SJB_Request::getVar('field_sid', null); SJB_PostingPagesManager::moveDownFieldBySID($field_sid, $pageSID); break; case 'move_up': $field_sid = SJB_Request::getVar('field_sid', null); SJB_PostingPagesManager::moveUpFieldBySID($field_sid, $pageSID); break; case 'remove': SJB_PostingPagesManager::removeFieldFromPageById(SJB_Request::getVar('relationId', null), $listing_type_sid); break; case 'move': $field_sid = SJB_Request::getVar('field_sid', null); $movePageID = SJB_Request::getVar('movePageID', false); if ($movePageID !== false) { SJB_PostingPagesManager::moveFieldToPade($field_sid, $movePageID, $listing_type_sid); } $template = 'move_field.tpl'; break; case 'save_order': $item_order = SJB_Request::getVar('item_order', null); SJB_PostingPagesManager::saveNewJobFieldsOrder($item_order, $pageSID); break; } $listing_fields = SJB_PostingPagesManager::getListingFieldsInfo($listing_type_sid); $fieldsOnPage = SJB_PostingPagesManager::getAllFieldsByPageSID($pageSID); $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid); $tp->assign('pageInfo', $pageInfo); $tp->assign('pages', $pages); $tp->assign('countPages', count($pages)); $tp->assign("pageSID", $pageSID); $tp->assign("fieldsOnPage", $fieldsOnPage); $tp->assign("form_fields", $form_fields); $tp->assign("listing_fields", $listing_fields); break; case 'added': $action = 'list'; break; case 'modified': $action = 'list'; break; case 'move_up': SJB_PostingPagesManager::moveUpPageBySID($pageSID); $action = 'list'; break; case 'move_down': SJB_PostingPagesManager::moveDownPageBySID($pageSID); $action = 'list'; break; case 'delete': $countPages = SJB_PostingPagesManager::getNumPagesByListingTypeSID($listing_type_sid); if ($countPages > 1) { SJB_PostingPagesManager::deletePageBySID($pageSID); } $action = 'list'; break; } if ($action == 'list') { $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid); $tp->assign('pages', $pages); $tp->assign('countPages', count($pages)); $template = 'posting_pages.tpl'; } $tp->assign('listingTypeInfo', $listingTypeInfo); } else { $errors['UNDEFINED_LISTING_TYPE_ID'] = 1; } $tp->assign('action', $action); $tp->assign('errors', $errors); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $sid = SJB_Request::getVar('sid', null, null, 'int'); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } $request['field_sid'] = $sid; $display_list_controller = new SJB_ScreeningQuestionnairesDisplayListController($request); $questionInfo = SJB_ScreeningQuestionnairesFieldManager::getFieldInfoBySID($sid); if (!empty($questionInfo['questionnaire_sid']) && SJB_ScreeningQuestionnaires::isUserOwnerQuestionnaire(SJB_UserManager::getCurrentUserSID(), $questionInfo['questionnaire_sid'])) { $questionInfo = array_merge($questionInfo, $_REQUEST); $questionnaire_field = new SJB_ScreeningQuestionnairesField($questionInfo); $questionnaire_field->deleteProperty('maxlength'); $questionnaire_field->deleteProperty('template'); $add_questionnaire_field_form = new SJB_Form($questionnaire_field); $add_questionnaire_field_form->registerTags($tp); $form_is_submitted = SJB_Request::getVar('action', '') == 'add'; $errors = null; $type = SJB_Request::getVar('type', false); $savedType = $display_list_controller->field->getProperty('type')->value; $type = $type ? $type : $savedType; $answers = SJB_Request::getVar('answer', false); $score = SJB_Request::getVar('score', false); $answer_boolean = SJB_Request::getVar('answer_boolean', false); $score_boolean = SJB_Request::getVar('score_boolean', false); if ($type != 'string') { $answers = $answers ? $answers : $display_list_controller->list_items['answer']; $score = $score ? $score : $display_list_controller->list_items['score']; $answer_boolean = $answer_boolean ? $answer_boolean : $display_list_controller->list_items['answer']; $score_boolean = $score_boolean ? $score_boolean : $display_list_controller->list_items['score']; } if ($answer_boolean && $score_boolean) { foreach ($answer_boolean as $key => $val) { $score_boolean[strtolower($val)] = $score_boolean[$key]; } } if ($form_is_submitted && $add_questionnaire_field_form->isDataValid($errors)) { $questionnaire_field->addProperty(array('id' => 'questionnaire_sid', 'type' => 'id', 'value' => $questionInfo['questionnaire_sid'], 'is_system' => true)); $id = $questionnaire_field->getProperty('caption'); $questionnaire_field->addProperty(array('id' => 'id', 'type' => 'string', 'value' => md5($id->value), 'is_system' => true)); $questionnaire_field->setSID($sid); $questionnairesListItemManager = new SJB_ScreeningQuestionnairesListItemManager(); $questionnairesListItemManager->deleteItemsByFieldSID($sid); SJB_ScreeningQuestionnairesFieldManager::saveQuestion($questionnaire_field); if ($type == 'boolean') { $request['list_multiItem_value'] = $answer_boolean; $request['field_sid'] = $questionnaire_field->sid; $request['score'] = $score_boolean; $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request); if ($edit_list_controller->isvalidFieldSID()) { $edit_list_controller->saveItem(true); } } elseif ($type != 'string') { $request['list_multiItem_value'] = $answers; $request['field_sid'] = $questionnaire_field->sid; $request['score'] = $score; $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request); if ($edit_list_controller->isvalidFieldSID()) { $edit_list_controller->saveItem(true); } } $questionnaire_sid = $questionnaire_field->getSID(); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-questions/{$questionInfo['questionnaire_sid']}/?edit=1"); } else { switch ($type) { case 'boolean': $tp->assign('answer_boolean', $answer_boolean); $tp->assign('score_boolean', $score_boolean); break; case 'multilist': case 'list': $tp->assign('answers', $answers); $tp->assign('score', $score); break; } $tp->assign('errors', $errors); $tp->assign('action', 'edit'); $tp->assign('questionnaire_sid', $questionInfo['questionnaire_sid']); $add_questionnaire_field_form->registerTags($tp); $tp->assign('form_fields', $add_questionnaire_field_form->getFormFieldsInfo()); $tp->display('add_questions.tpl'); } } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', false); $sid = SJB_Request::getVar('sid', null, null, 'int'); $edit = SJB_Request::getVar('edit', false); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; $questionSID = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : false; } if (SJB_ScreeningQuestionnaires::isUserOwnerQuestionnaire(SJB_UserManager::getCurrentUserSID(), $sid)) { switch ($action) { case 'delete': if ($questionSID) { SJB_ScreeningQuestionnairesFieldManager::deleteQuestionBySID($questionSID); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-questions/{$sid}/"); break; case 'move_up': $questionSID = SJB_Request::getVar('question', false); if ($questionSID) { SJB_ScreeningQuestionnairesFieldManager::moveUpFieldBySID($questionSID); } break; case 'move_down': $questionSID = SJB_Request::getVar('question', false); if ($questionSID) { SJB_ScreeningQuestionnairesFieldManager::moveDownFieldBySID($questionSID); } break; } $questionnaire_field = new SJB_ScreeningQuestionnairesField($_REQUEST); $questions = array(); if ($sid) { $questions = SJB_ScreeningQuestionnairesFieldManager::getFieldsInfoByQuestionnairesSID($sid); $tp->assign('questionnarieInfo', SJB_ScreeningQuestionnaires::getInfoBySID($sid)); } $add_questionnaire_field_form = new SJB_Form($questionnaire_field); $add_questionnaire_field_form->registerTags($tp); $form_is_submitted = SJB_Request::getVar('action', '') == 'add'; $errors = null; $answers = SJB_Request::getVar('answer', false); $score = SJB_Request::getVar('score', false); $answer_boolean = SJB_Request::getVar('answer_boolean', false); $score_boolean = SJB_Request::getVar('score_boolean', false); $type = SJB_Request::getVar('type', false); if (is_array($answers)) { foreach ($answers as $key => $val) { if ($key != 0 && $val == null) { unset($answers[$key]); } } } if ($form_is_submitted && $add_questionnaire_field_form->isDataValid($errors)) { $questionnaire_field->addProperty(array('id' => 'questionnaire_sid', 'type' => 'id', 'value' => $sid, 'is_system' => true)); $id = $questionnaire_field->getProperty('caption'); $questionnaire_field->addProperty(array('id' => 'id', 'type' => 'string', 'value' => md5($id->value), 'is_system' => true)); SJB_ScreeningQuestionnairesFieldManager::saveQuestion($questionnaire_field); if ($type == 'boolean') { $request['list_multiItem_value'] = $answer_boolean; $request['field_sid'] = $questionnaire_field->sid; $request['score'] = $score_boolean; $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request); if ($edit_list_controller->isvalidFieldSID()) { $edit_list_controller->saveItem(true); } } elseif ($type != 'string') { $request['list_multiItem_value'] = $answers; $request['field_sid'] = $questionnaire_field->sid; $request['score'] = $score; $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request); if ($edit_list_controller->isvalidFieldSID()) { $edit_list_controller->saveItem(true); } } $questionnaire_sid = $questionnaire_field->getSID(); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-questions/{$sid}/"); } else { switch ($type) { case 'boolean': $tp->assign('answer_boolean', $answer_boolean); $tp->assign('score_boolean', $score_boolean); break; case 'multilist': case 'list': $tp->assign('answers', $answers); $tp->assign('score', $score); break; } $tp->assign('edit', $edit); $tp->assign('sid', $sid); $tp->assign('questions', $questions); $tp->assign('action', 'edit'); $tp->assign('errors', $errors); $add_questionnaire_field_form->registerTags($tp); $tp->assign('form_fields', $add_questionnaire_field_form->getFormFieldsInfo()); $tp->display('edit_questions.tpl'); } } }
public function execute() { $errors = array(); $tp = SJB_System::getTemplateProcessor(); $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; // Category SID incoming as part of URL. $categoryId = SJB_Request::getVar("category_sid"); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $categoryId = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } if ($categoryId && $categoryId != 'category') { $article = false; if (is_null($categoryId)) { $errors['ITEM_SID_IS_EMPTY'] = 1; } else { $article = SJB_NewsManager::getActiveItemBySID($categoryId); } if (!$article) { $errors['ARTICLE_NOT_EXISTS'] = 1; echo SJB_System::executeFunction('static_content', 'show_static_content', array('pageid' => '404')); return; } $tp->assign('article', $article); $template = 'article_details.tpl'; } else { $categoryId = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : null; // other params in query string $searchText = SJB_Request::getVar('search_text', false); $current_page = SJB_Request::getVar('page', 1); $itemsPerPage = 10; $action = SJB_Request::getVar('action'); if ($action == 'search') { // COUNT FOR SEARCH ACTION $totalNews = SJB_NewsManager::getAllNewsCountBySearchText($searchText, $langId, true); } else { $totalNews = SJB_NewsManager::getAllNewsCount($categoryId, $langId, true); } $pages = ceil($totalNews / $itemsPerPage); if ($pages == 0) { $pages = 1; } if ($current_page > $pages) { $current_page = $pages; } if ($action == 'search') { // GET ARTICLES FOR SEARCH ACTION if ($totalNews == 0) { $articles = array(); } else { $articles = SJB_NewsManager::searchArticles($searchText, $langId, true); } } else { $articles = SJB_NewsManager::getNewsByPage($current_page, $itemsPerPage, $categoryId, $langId, true); } $tp->assign('searchText', $searchText); $tp->assign('current_page', $current_page); $tp->assign('pages', $pages); $tp->assign('articles', $articles); $categories = SJB_NewsManager::getCategories($langId); $countOfNotEmptyCategories = 0; foreach ($categories as $category) { if ($category['count'] > 0) { $countOfNotEmptyCategories++; } } $showCategoriesBlock = false; if ($countOfNotEmptyCategories > 1) { $showCategoriesBlock = true; } $tp->assign('show_categories_block', $showCategoriesBlock); $tp->assign('categories', $categories); $tp->assign('current_category_sid', $categoryId); $template = 'articles_list.tpl'; } $tp->display($template); }
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); }
/** * @param $pages * @param $listingTypeSID * @return bool|int|mixed */ public function getPageSID($pages, $listingTypeSID) { $passedParametersViaUri = SJB_Request::getVar('passed_parameters_via_uri', false); $pageID = false; if ($passedParametersViaUri) { $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $this->listingTypeID = isset($passedParametersViaUri[0]) ? $passedParametersViaUri[0] : $this->listingTypeID; $pageID = isset($passedParametersViaUri[1]) ? $passedParametersViaUri[1] : false; } if (!$pageID) { $pageID = $pages[0]['page_id']; } $pageSID = SJB_PostingPagesManager::getPostingPageSIDByID($pageID, $listingTypeSID); return $pageSID; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $extUserID = SJB_Request::getVar('extUserID', null); $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false; if (!$userGroupID) { $userGroupsInfo = SJB_UserGroupManager::getAllUserGroupsInfo(); $tp->assign('user_groups_info', $userGroupsInfo); $tp->display('add_user_choose_user_group.tpl'); } else { $userGroupSID = SJB_UserGroupManager::getUserGroupSIDByID($userGroupID); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSID); $user = SJB_ObjectMother::createUser($_REQUEST, $userGroupSID); $user->deleteProperty('active'); $user->addExtUserIDProperty($extUserID); $registration_form = SJB_ObjectMother::createForm($user); $registration_form->registerTags($tp); $form_submitted = SJB_Request::getVar('action', '') == 'add'; $errors = array(); if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($userGroupSID) && $form_submitted) { $email = $user->getPropertyValue('email'); if (is_array($email)) { $email = $email['original']; } $user->setPropertyValue('username', $email); } if ($form_submitted && $registration_form->isDataValid($errors)) { SJB_UserManager::saveUser($user); // >>> SJB-1197 // needs to check session for ajax-uploaded files, and set it to user profile $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage'); $formToken = SJB_Request::getVar('form_token'); if (!empty($formToken)) { $tmpUploadedFields = SJB_Array::getPath($tmpUploadsStorage, $formToken); if (!is_null($tmpUploadsStorage) && is_array($tmpUploadedFields)) { // prepare user profile fields array $userProfileFieldsInfo = SJB_UserProfileFieldManager::getAllFieldsInfo(); $userProfileFields = array(); foreach ($userProfileFieldsInfo as $field) { $userProfileFields[$field['id']] = $field; } // look for temporary values foreach ($tmpUploadedFields as $fieldId => $fieldInfo) { // check field ID for valid ID in user profile fields if (!array_key_exists($fieldId, $userProfileFields) || empty($fieldInfo)) { continue; } $fieldType = $userProfileFields[$fieldId]['type']; $profilePropertyId = $fieldId . '_' . $user->getSID(); switch (strtolower($fieldType)) { case 'video': case 'file': // change temporary file ID SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']); // set value of user property to new uploaded file $user->setPropertyValue($fieldId, $profilePropertyId); break; case 'logo': // change temporary file ID and thumb ID SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId . '_thumb', $fieldInfo['file_id'] . '_thumb'); // set value of user property to new uploaded file $user->setPropertyValue($fieldId, $profilePropertyId); break; default: break; } $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}/{$fieldId}"); } // and save user with new fields data SJB_UserManager::saveUser($user); // clean temporary storage $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}"); // CLEAR TEMPORARY SESSION STORAGE SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage); } } // <<< SJB-1197 SJB_UserManager::activateUserByUserName($user->getUserName()); $defaultProduct = SJB_UserGroupManager::getDefaultProduct($userGroupSID); $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userGroupSID); if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) { $contract = new SJB_Contract(array('product_sid' => $defaultProduct)); $contract->setUserSID($user->getSID()); $contract->saveInDB(); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-users/" . mb_strtolower($userGroupInfo['id'], 'utf8')); } else { if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($userGroupSID)) { $user->deleteProperty('username'); } $registration_form = SJB_ObjectMother::createForm($user); $registration_form->registerTags($tp); $tp->assign("errors", $errors); $tp->assign("user_group", $userGroupInfo); $tp->assign('userTree', true); $tp->assign("form_fields", $registration_form->getFormFieldsInfo()); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display("add_user.tpl"); } } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $template = SJB_Request::getVar('input_template', 'input_form.tpl'); $error = null; $listingTypeID = SJB_Request::getVar('listing_type_id', false); $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false); $pageID = false; if ($passed_parameters_via_uri) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $listingTypeID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : $listingTypeID; $pageID = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : false; $listing_id = isset($passed_parameters_via_uri[2]) ? $passed_parameters_via_uri[2] : false; } if (SJB_UserManager::isUserLoggedIn()) { $post_max_size_orig = ini_get('post_max_size'); $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null; $fromPreview = SJB_Request::getVar('from-preview', false); // get post_max_size in bytes $val = trim($post_max_size_orig); $tmp = substr($val, strlen($val) - 1); $tmp = strtolower($tmp); /* if ini value is K - then multiply to 1024 * if ini value is M - then multiply twice: in case 'm', and case 'k' * if ini value is G - then multiply tree times: in 'g', 'm', 'k' * out value - in bytes! */ switch ($tmp) { case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } $post_max_size = $val; $filename = SJB_Request::getVar('filename', false); if ($filename) { $file = SJB_UploadFileManager::openFile($filename, $listing_id); $errors['NO_SUCH_FILE'] = true; } if (empty($_POST) && $server_content_length > $post_max_size) { $errors['MAX_FILE_SIZE_EXCEEDED'] = 1; $tp->assign('post_max_size', $post_max_size_orig); } $listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id); $currentUser = SJB_UserManager::getCurrentUser(); $contractID = $listingInfo['contract_id']; if ($contractID == 0) { $extraInfo = unserialize($listingInfo['product_info']); $productSID = $extraInfo['product_sid']; } else { $contract = new SJB_Contract(array('contract_id' => $contractID)); $extraInfo = $contract->extra_info; } if ($listingInfo['user_sid'] != SJB_UserManager::getCurrentUserSID()) { $errors['NOT_OWNER_OF_LISTING'] = $listing_id; } else { $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID); $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid); if (!$pageID) { $pageID = $pages[0]['page_id']; } $pageSID = SJB_PostingPagesManager::getPostingPageSIDByID($pageID, $listing_type_sid); $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listing_type_sid); // preview listing $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST'); $form_submitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested; // fill listing from an array of social data if allowed $aAutoFillData = array('formSubmitted' => &$form_submitted, 'listingTypeID' => &$listingTypeID); SJB_Event::dispatch('SocialSynchronization', $aAutoFillData); $listingInfo = array_merge($listingInfo, $_REQUEST); $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID); if ($fromPreview) { if ($form_submitted) { $properties = $listing->getProperties(); foreach ($properties as $fieldID => $property) { switch ($property->getType()) { case 'date': if (!empty($listing_info[$fieldID])) { $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]); } break; case 'complex': $complex = $property->type->complex; $complexProperties = $complex->getProperties(); foreach ($complexProperties as $complexfieldID => $complexProperty) { if ($complexProperty->getType() == 'date') { $values = $complexProperty->getValue(); foreach ($values as $index => $value) { if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) { $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]); } } } } break; } } $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID); } } $previousComplexFields = $this->processComplexFields($listing, $listingInfo); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('status'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('ListingLogo'); $listing->setSID($listing_id); $access_type = $listing->getProperty('access_type'); if ($form_submitted && !empty($access_type)) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true)); } $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID()); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) { $issetQuestionnairyField = $listing->getProperty('screening_questionnaire'); if ($issetQuestionnairyField) { $value = SJB_Request::getVar('screening_questionnaire'); $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : ''; $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true)); } } else { $listing->deleteProperty('screening_questionnaire'); } /* social plugin * "synchronization" * if user is not registered using linkedin , delete linkedin sync property * also deletes it if sync is turned off in admin part */ if ($pages[0]['page_id'] == $pageID) { $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo); SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData); } $add_listing_form = new SJB_Form($listing); $add_listing_form->registerTags($tp); $field_errors = array(); if ($form_submitted && (SJB_Session::getValue(self::PREVIEW_LISTING_SID) == $listing_id || $add_listing_form->isDataValid($field_errors))) { /* delete temp preview listing sid */ SJB_Session::unsetValue(self::PREVIEW_LISTING_SID); if ($isPageLast) { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } $listing->setUserSID($currentUser->getSID()); if (empty($access_type->value)) { $listing->setPropertyValue('access_type', 'everyone'); } if (isset($_SESSION['tmp_file_storage'])) { foreach ($_SESSION['tmp_file_storage'] as $k => $v) { SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s', $listing->getSID(), $v['picture_saved_name']); SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s', $listing->getSID(), $v['thumb_saved_name']); } SJB_Session::unsetValue('tmp_file_storage'); } // >>> SJB-1197 // check temporary uploaded storage for listing uploads and assign it to saved listing $formToken = SJB_Request::getVar('form_token'); $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage'); $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken); if (!empty($uploadedFields)) { foreach ($uploadedFields as $fieldId => $fieldValue) { // get field of listing $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldValue['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } // unset value from session temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}"); } //and remove token key from temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}"); SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage); } // <<< SJB-1197 SJB_ListingManager::saveListing($listing); foreach ($previousComplexFields as $propertyId) { $listing->deleteProperty($propertyId); } if ($isPageLast && !$isPreviewListingRequested) { $listingSID = $listing->getSID(); $listing = SJB_ListingManager::getObjectBySID($listingSID); $listing->setSID($listingSID); $keywords = $listing->getKeywords(); SJB_ListingManager::updateKeywords($keywords, $listing->getSID()); // Start Event $listingSid = $listing->getSID(); SJB_Event::dispatch('listingSaved', $listingSid); // is listing featured by default if ($extraInfo['featured']) { SJB_ListingManager::makeFeaturedBySID($listing->getSID()); } if ($extraInfo['priority']) { SJB_ListingManager::makePriorityBySID($listing->getSID()); } if ($contractID) { if (SJB_ListingManager::activateListingBySID($listing->getSID())) { SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID()); } // notify administrator SJB_AdminNotifications::sendAdminListingAddedLetter($listing); if (isset($_REQUEST['action_add_pictures'])) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-pictures/?listing_id=" . $listing->getSID()); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeID) . '/?listing_id=' . $listing->getSID()); } } else { SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID()); $this->proceedToCheckout($currentUser->getSID(), $productSID); } } elseif ($isPageLast && $isPreviewListingRequested) { // for listing preview SJB_Session::setValue(self::PREVIEW_LISTING_SID, $listing->getSID()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/'); } else { // listing steps (pages) SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . '/' . $listing->getSID()); } } else { foreach ($previousComplexFields as $propertyId) { $listing->deleteProperty($propertyId); } $listing->deleteProperty('access_list'); $listing->deleteProperty('contract_id'); $add_listing_form = new SJB_Form($listing); if (SJB_Request::get('action_add') == 'Next') { $add_listing_form->setUseDefaultValues(); } if ($form_submitted) { $add_listing_form->isDataValid($field_errors); } $add_listing_form->registerTags($tp); $form_fields = $add_listing_form->getFormFieldsInfo(); $employers_list = SJB_Request::getVar('list_emp_ids', false); $employers = array(); if (is_array($employers_list)) { foreach ($employers_list as $emp) { $currEmp = SJB_UserManager::getUserInfoBySID($emp); $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']); } sort($employers); } else { $access_type = $listing->getPropertyValue('access_type'); $employers = SJB_ListingManager::getListingAccessList($listing_id, $access_type); } $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $tp->assign('pic_limit', $numberOfPictures); $tp->assign('listing_sid', $listing_id); $tp->assign('listing_id', $listing_id); $tp->assign('listingSID', $listing->getSID()); $tp->assign('listing_access_list', $employers); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('contract_id', $contractID); $tp->assign('field_errors', $field_errors); $tp->assign('form_fields', $form_fields); $tp->assign("extraInfo", $extraInfo); $tp->assign('pages', $pages); $tp->assign('pageSID', $pageSID); $tp->assign('currentPage', SJB_PostingPagesManager::getPageInfoBySID($pageSID)); $tp->assign('isPageLast', $isPageLast); $tp->assign('nextPage', SJB_PostingPagesManager::getNextPage($pageSID)); $tp->assign('prevPage', SJB_PostingPagesManager::getPrevPage($pageSID)); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); // social plugin only for Resume listing types $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $currentUser->getSID()); SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData); SJB_Session::unsetValue(self::PREVIEW_LISTING_SID); $tp->display($template); } } } else { $tp->assign('listingTypeID', $listingTypeID); $tp->assign('error', 'NOT_LOGGED_IN'); $tp->display('add_listing_error.tpl'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', 'add'); $submit = SJB_Request::getVar('submit', false); $template = SJB_Request::getVar('template_name', 'add_questionnaire.tpl'); $sid = SJB_Request::getVar('sid', null, null, 'int'); $edit = SJB_Request::getVar('edit', false); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } $errors = array(); $questionnaireInfo = SJB_ScreeningQuestionnaires::getInfoBySID($sid); if (!empty($questionnaireInfo['sid']) && !SJB_ScreeningQuestionnaires::isUserOwnerQuestionnaire(SJB_UserManager::getCurrentUserSID(), $questionnaireInfo['sid'])) { SJB_FlashMessages::getInstance()->addError('NOT_OWNER'); } else { if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires')) { $questionnaireInfo = $questionnaireInfo ? $questionnaireInfo : array(); $questionnaireInfo = array_merge($questionnaireInfo, $_REQUEST); $questionnaire = new SJB_ScreeningQuestionnaires($questionnaireInfo); if ($submit) { $questionnaire->addProperty(array('id' => 'user_sid', 'type' => 'id', 'value' => SJB_UserManager::getCurrentUserSID(), 'is_system' => true)); } if (isset($sid) && !is_null($sid)) { $questionnaire->setSID($sid); } $addForm = new SJB_Form($questionnaire); $addForm->registerTags($tp); switch ($submit) { case 'add': if ($addForm->isDataValid($errors)) { SJB_ScreeningQuestionnaires::save($questionnaire); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/screening-questionnaires/add-questions/{$questionnaire->sid}/"); } else { $action = 'add'; $questionnaire->deleteProperty('user_sid'); $addForm = new SJB_Form($questionnaire); $addForm->registerTags($tp); } break; case 'edit': if ($addForm->isDataValid($errors)) { SJB_ScreeningQuestionnaires::save($questionnaire); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/screening-questionnaires/edit/{$questionnaire->sid}/?edit=1"); } else { $tp->assign('sid', $_REQUEST['sid']); $questionnaire->deleteProperty('user_sid'); $addForm = new SJB_Form($questionnaire); $addForm->registerTags($tp); $action = 'edit'; } break; } $form_fields = $addForm->getFormFieldsInfo(); $tp->assign('form_fields', $form_fields); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); $tp->assign('edit', $edit); $tp->assign('request', $questionnaireInfo); $tp->assign('sid', $sid); $tp->assign('action', $action); $tp->assign('errors', $errors); $tp->display($template); } } }
public static function isUserAccessThisPage() { $pageID = SJB_PageManager::getPageParentURI(SJB_Navigator::getURI(), SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE'), false); $access = true; $currentUser = SJB_UserManager::getCurrentUser(); if (!is_null($currentUser)) { $access = false; $queryParam = ''; $listingId = SJB_Request::getVar("listing_id", false); $passedParametersViaUri = SJB_Request::getVar("passed_parameters_via_uri", false); if (!$listingId && $passedParametersViaUri) { $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $listingId = isset($passedParametersViaUri[0]) ? $passedParametersViaUri[0] : ''; } if ($listingId) { $queryParam = " AND `param` = '" . SJB_DB::quote($listingId) . "' "; } $pageHasBeenVisited = SJB_DB::query("SELECT `param` FROM `page_view` WHERE `id_user` = ?s AND `id_pages` = ?s {$queryParam}", $currentUser->getSID(), $pageID); if (!empty($queryParam) && $pageHasBeenVisited || strpos($pageID, 'print') !== false) { $access = true; } else { $contractsId = $currentUser->getContractID(); $pageAccess = SJB_ContractManager::getPageAccessByUserContracts($contractsId, $pageID); $numberOfPagesViewed = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractsId, $pageID); if (isset($pageAccess[$pageID]) && $pageAccess[$pageID]['count_views'] != '') { if ($numberOfPagesViewed < $pageAccess[$pageID]['count_views']) { $access = true; } if ($access === true) { $listingTypeSID = null; if (is_numeric($listingId)) { $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); if ($listingInfo) { $listingTypeSID = $listingInfo['listing_type_sid']; } } $availableContractId = ''; foreach ($contractsId as $contractId) { $pageAccessByContract = SJB_ContractManager::getPageAccessByUserContracts(array($contractId), $pageID); $viewsLeft = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractId), false, $listingTypeSID); if (!empty($pageAccessByContract[$pageID]['count_views']) && $pageAccessByContract[$pageID]['count_views'] > $viewsLeft) { $availableContractId = $contractId; } } if (!empty($availableContractId)) { SJB_DB::query("INSERT INTO page_view (`id_user` ,`id_pages`, `param`, `contract_id`, `listing_type_sid`) VALUES ( ?n, ?s, ?s, ?n, ?n)", $currentUser->getSID(), $pageID, $listingId, $availableContractId, $listingTypeSID); } else { $access = false; } } } else { $access = true; } } } return $access; }
public function execute() { $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); }