public function execute() { $tp = SJB_System::getTemplateProcessor(); $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid', 0, SJB_Request::METHOD_GET)); $user_id = $user['sid']; if (SJB_Request::getVar('pm_action', '', SJB_Request::METHOD_POST) == 'delete') { $checked = SJB_Request::getVar('pm_check', array(), SJB_Request::METHOD_POST); SJB_PrivateMessage::delete($checked); } $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET)); $per_page = 10; $total = SJB_PrivateMessage::getTotalOutbox($user_id); $max_pages = ceil($total / $per_page); if ($max_pages == 0) { $max_pages = 1; } if ($max_pages < $page) { SJB_HelperFunctions::redirect("?user_sid={$user_id}&page={$max_pages}"); } $navigate = SJB_PrivateMessage::getNavigate($page, $total, $per_page); $list = SJB_PrivateMessage::getListOutbox($user_id, $page, $per_page); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('username', $user['username']); $tp->assign('user_sid', $user_id); $tp->assign('message', $list); $tp->assign('navigate', $navigate); $tp->assign('page', $page); $tp->display('pm_outbox.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $listing_id = SJB_Request::getVar('listing_id', null); $listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id); $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']); $display_form = new SJB_Form(); $display_form->registerTags($tp); if (is_null($listing_id)) { $errors['LISTING_ID_DOESNOT_SPECIFIED'] = $listing_id; } else { $listing = SJB_ListingManager::getObjectBySID($listing_id); $filename = SJB_Request::getVar('filename', false); if ($filename) { $file = SJB_UploadFileManager::openFile($filename, $listing_id); $errors['NO_SUCH_FILE'] = true; } if (!empty($listing)) { $listing->addPicturesProperty(); if ($listing->listing_type_sid == 6) { $listing->deleteProperty('access_type'); $listing->deleteProperty('anonymous'); } $access_type_properties = $listing->getProperty('access_type'); $tp->assign('access_type_properties', $access_type_properties); $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing); $tp->assign("listing", $listing_structure); $display_form = new SJB_Form($listing); $display_form->registerTags($tp); $form_fields = $display_form->getFormFieldsInfo(); $tp->assign("form_fields", $form_fields); $waitApprove = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing->listing_type_sid); $tp->assign('wait_approve', $waitApprove); } else { $errors['LISTING_DOESNOT_EXIST'] = $listing_id; } } $comments = SJB_CommentManager::getEnabledCommentsToListing($listing_id); $comments_total = count($comments); $rate = SJB_Rating::getRatingNumToListing($listing_id); $displayTemplate = SJB_Request::getVar('display_template', 'display_listing.tpl'); $videoFileId = SJB_Request::getVar('videoFileId', false); if ($videoFileId) { $videoFileLink = SJB_UploadFileManager::getUploadedFileLink($videoFileId); $tp->assign('videoFileLink', $videoFileLink); } $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->assign('errors', $errors); $tp->assign('comments_total', $comments_total); $tp->assign('rate', $rate); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $listingTypeInfo['id']); $tp->display($displayTemplate); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid')); $user_id = $user['sid']; $total_in = SJB_PrivateMessage::getTotalInbox($user_id); $total_out = SJB_PrivateMessage::getTotalOutbox($user_id); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->assign('username', $user['username']); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('user_sid', $user_id); $tp->assign('total_in', $total_in); $tp->assign('total_out', $total_out); $tp->display('main.tpl'); }
/** * * @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 isAccessible() { switch (SJB_Request::getVar('type')) { case 'user': $userSid = SJB_Request::getVar('role', null); $userGroupID = SJB_UserGroupManager::getUserGroupIDByUserSID($userSid); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupID); $this->setPermissionLabel('manage_' . strtolower($userGroupID)); break; case 'group': $this->setPermissionLabel('manage_user_groups_permissions'); break; case 'product': $this->setPermissionLabel('manage_products'); break; } return parent::isAccessible(); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', '', SJB_Request::METHOD_GET); $mess_id = intval(SJB_Request::getVar('mess', 0, SJB_Request::METHOD_GET)); $return_to = SJB_Request::getVar('from', 'in', SJB_Request::METHOD_GET); $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET)); $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid')); $user_id = $user['sid']; if ($action == 'delete') { SJB_DB::query("DELETE FROM `private_message` WHERE `id` = '{$mess_id}'"); $per_page = 10; if ($return_to == 'in') { $total = SJB_PrivateMessage::getTotalInbox($user_id); } else { $total = SJB_PrivateMessage::getTotalOutbox($user_id); } $max_pages = ceil($total / $per_page); if ($max_pages == 0) { $max_pages = 1; } if ($max_pages < $page) { $page = $max_pages; } $site_url = SJB_System::getSystemSettings('SITE_URL'); SJB_HelperFunctions::redirect($site_url . '/private-messages/pm-' . ($return_to == 'in' ? 'inbox' : 'outbox') . "/?user_sid={$user_id}&page={$page}"); } $message = SJB_PrivateMessage::ReadMessage($mess_id, true); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('returt_to', $return_to); $tp->assign('username', $user['username']); $tp->assign('user_sid', $user_id); $tp->assign('message', $message); $tp->assign('page', $page); $tp->display('pm_read.tpl'); }
function deleteLanguage($lang_id) { if ($this->admin->deleteLanguage($lang_id)) { if ($lang_id == $this->context->getLang()) { $defaultLang = $this->context->getDefaultLang(); $this->context->setLang($defaultLang); SJB_System::setGlobalTemplateVariable('current_language', $defaultLang); } return true; } return false; }
function _tpl_breadcrumbs($params, $content) { SJB_System::setGlobalTemplateVariable('ADMIN_BREADCRUMBS', $content, false); }
<?php $timeBegin = microtime(true); error_reporting(-1); ini_set('display_errors', 'on'); define('PATH_TO_SYSTEM_CLASS', '../system/core/System.php'); $DEBUG = array(); $PATH_BASE = str_replace('/admin', '', dirname(__FILE__)); require_once PATH_TO_SYSTEM_CLASS; define('SJB_BASE_DIR', realpath(dirname(__FILE__) . "/..") . '/'); SJB_System::loadSystemSettings('../system/admin-config/DefaultSettings.php'); SJB_System::loadSystemSettings('../config.php'); $GLOBALS['system_settings']['USER_SITE_URL'] = $GLOBALS['system_settings']['SITE_URL']; $GLOBALS['system_settings']['SITE_URL'] = $GLOBALS['system_settings']['ADMIN_SITE_URL']; // load installed SJB version info SJB_System::setGlobalTemplateVariable('version', SJB_System::getSystemSettings('version')); SJB_System::boot(); SJB_System::init(); if (SJB_Profiler::getInstance()->isProfilerEnable()) { SJB_Profiler::getInstance()->setStartTime($timeBegin); } // bind send notification emails if listing deactivated/deleted SJB_Event::handle('listingDeactivated', array('SJB_Notifications', 'notifyOnUserListingDeactivated')); SJB_Event::handle('beforeListingDelete', array('SJB_Notifications', 'notifyOnUserListingDeleted')); // bind send notification emails if user deactivated/deleted SJB_Event::handle('onBeforeUserDelete', array('SJB_Notifications', 'notifyOnUserDeleted')); SJB_Event::handle('onBeforeUserDeactivate', array('SJB_Notifications', 'notifyOnUserDeactivated')); SJB_Request::getInstance()->execute(); SJB_HelperFunctions::debugInfoPrint();
public static function getCurrentTheme($accessType = false) { $i18n = SJB_I18N::getInstance(); $i18n->switchLang(); $activeLanguagesData = $i18n->getActiveLanguagesData(); $currentLanguage = $i18n->getCurrentLanguage(); $currentLanguageData = null; foreach ($activeLanguagesData as $activeLanguageData) { if ($activeLanguageData['id'] == $currentLanguage) { $currentLanguageData = $activeLanguageData; } } SJB_System::setGlobalTemplateVariable('languages', $activeLanguagesData); SJB_System::setGlobalTemplateVariable('current_language', $currentLanguage); SJB_System::setGlobalTemplateVariable('current_language_data', $currentLanguageData); $arr = glob(SJB_BASE_DIR . 'system/ext/jquery/datepicker/i18n/jquery.ui.datepicker-*.js'); if (is_array($arr) && !empty($arr)) { $available_datepicker_localizations = array(); foreach ($arr as $item) { $matches = array(); if (!preg_match('/datepicker-([a-zA-Z0-9-]+).js$/', $item, $matches)) { continue; } $available_datepicker_localizations[$matches[1]] = $matches[1]; } SJB_System::setGlobalTemplateVariable('available_datepicker_localizations', $available_datepicker_localizations); } $theme = null; if (SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == 'admin') { if ($accessType === false || $accessType === 'admin') { return SJB_System::getSystemSettings('SYSTEM_TEMPLATE_DIR') . '/admin'; } } else { if (isset($_GET['theme'])) { $theme = $_GET['theme']; if (strtolower($theme) == 'mobile') { $theme = 'mobile'; } SJB_Session::setValue('theme', $theme); } } if (!ThemeManager::isThemeExists($theme, $accessType)) { $theme = SJB_Session::getValue('theme'); if (empty($theme) || !ThemeManager::isThemeExists($theme, $accessType)) { $theme = SJB_Settings::getSettingByName('CURRENT_THEME'); if (!ThemeManager::isThemeExists($theme, $accessType)) { $theme = SJB_System::getSystemSettings('DEFAULT_THEME'); } } } SJB_Event::dispatch('GetCurrentTheme', $theme, true); SJB_Session::setValue('CURRENT_THEME', $theme); return $theme; }
public static function init() { SJB_DB::init(SJB_System::getSystemSettings('DBHOST'), SJB_System::getSystemSettings('DBUSER'), SJB_System::getSystemSettings('DBPASSWORD'), SJB_System::getSystemSettings('DBNAME')); ini_set('zlib.output_compression', SJB_System::getSettingByName('gzip_compression')); $GLOBALS['fatal_error_reserve_buffer'] = str_repeat('x', 1024 * 200); ob_start(array('SJB_Error', 'fatalErrorHandler')); SJB_Session::init(SJB_System::getSystemSettings('SITE_URL')); $sessionId = SJB_DB::queryValue("SELECT `session_id` FROM `user_session_data_storage` WHERE `session_id` = ?s", SJB_Session::getSessionId()); // if not updated (row not exists) - insert that value if (empty($sessionId)) { SJB_DB::query("INSERT INTO `user_session_data_storage` SET `last_activity` = NOW(), `session_id` = ?s", SJB_Session::getSessionId()); } else { SJB_DB::query("UPDATE `user_session_data_storage` SET `last_activity` = NOW() WHERE `session_id` = ?s", $sessionId); } //set timezone if (SJB_Settings::getSettingByName('timezone')) { ini_set('date.timezone', SJB_Settings::getSettingByName('timezone')); } // Set Error Handler and Shutdown function set_error_handler(array('SJB_Error', 'errorHandler')); register_shutdown_function(array('SJB_System', 'shutdownFunction')); SJB_System::prepareGlobalArrays(); SJB_System::setGlobalTemplateVariable('is_ajax', SJB_Request::isAjax()); SJB_System::setGlobalTemplateVariable('site_url', SJB_System::getSystemSettings('SITE_URL')); SJB_System::setGlobalTemplateVariable('user_site_url', SJB_System::getSystemSettings('USER_SITE_URL')); SJB_System::setGlobalTemplateVariable('admin_site_url', SJB_System::getSystemSettings('ADMIN_SITE_URL')); SJB_System::setGlobalTemplateVariable('radius_search_unit', SJB_System::getSettingByName('radius_search_unit')); SJB_System::setGlobalTemplateVariable('settings', SJB_Settings::getSettings()); ThemeManager::getCurrentTheme(); SJB_PluginManager::loadPlugins(SJB_System::getSystemSettings('PLUGINS_DIR')); SJB_System::setGlobalTemplateVariable('plugins', SJB_PluginManager::getAllPluginsList()); $GLOBALS['System']['MODULE_MANAGER'] = new SJB_ModuleManager(); SJB_Event::dispatch('moduleManagerCreated'); $GLOBALS['System']['MODULE_MANAGER']->executeModulesStartupFunctions(); // define if subadmin loged in and set subamdinmode for templates if (SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE') && SJB_SubAdmin::getSubAdminSID()) { SJB_System::setGlobalTemplateVariable('subAdminSID', SJB_SubAdmin::getSubAdminSID()); } $GLOBALS['uri'] = SJB_Navigator::getURI(); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $parent_name = null; $user_sid = SJB_Request::getVar('user_sid', false); if (!is_null($user_sid)) { $user_info = SJB_UserManager::getUserInfoBySID($user_sid); $user_info = array_merge($user_info, $_REQUEST); $form_submitted = SJB_Request::getVar('action_name'); $user = new SJB_User($user_info, $user_info['user_group_sid']); if (!empty($user_info['parent_sid'])) { $props = $user->getProperties(); $allowedProperties = array('username', 'email', 'password'); foreach ($props as $prop) { if (!in_array($prop->getID(), $allowedProperties)) { $user->deleteProperty($prop->getID()); } } $parent_name = SJB_UserManager::getUserNameByUserSID($user_info['parent_sid']); } $user->setSID($user_info['sid']); $user->getProperty('email')->type->disableEmailConfirmation(); $user->deleteProperty("active"); $user->makePropertyNotRequired("password"); if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) { if ($form_submitted) { $email = $user->getPropertyValue('email'); if (is_array($email)) { $email = $email['original']; } $user->setPropertyValue('username', $email); } } $user->addExtUserIDProperty($user_info['extUserID']); $edit_user_form = new SJB_Form($user); $errors = array(); if ($form_submitted && $edit_user_form->isDataValid($errors)) { $password_value = $user->getPropertyValue('password'); $properties = null; if (empty($password_value['original'])) { $properties = $user->getProperties(); $user->deleteProperty('password'); } SJB_UserManager::saveUser($user); // >>> SJB-1197 // needs to check session for ajax-uploaded files, and set it to user profile $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage'); $formToken = SJB_Request::getVar('form_token'); if (!empty($formToken)) { $tmpUploadedFields = SJB_Array::getPath($tmpUploadsStorage, $formToken); if (!is_null($tmpUploadsStorage) && is_array($tmpUploadedFields)) { // prepare user profile fields array $userProfileFieldsInfo = SJB_UserProfileFieldManager::getAllFieldsInfo(); $userProfileFields = array(); foreach ($userProfileFieldsInfo as $field) { $userProfileFields[$field['id']] = $field; } // look for temporary values foreach ($tmpUploadedFields as $fieldId => $fieldInfo) { // check field ID for valid ID in user profile fields if (!array_key_exists($fieldId, $userProfileFields) || empty($fieldInfo)) { continue; } $fieldType = $userProfileFields[$fieldId]['type']; $profilePropertyId = $fieldId . '_' . $user->getSID(); switch (strtolower($fieldType)) { case 'video': case 'file': // change temporary file ID SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']); // set value of user property to new uploaded file $user->setPropertyValue($fieldId, $profilePropertyId); break; case 'logo': // change temporary file ID and thumb ID SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId . '_thumb', $fieldInfo['file_id'] . '_thumb'); // set value of user property to new uploaded file $user->setPropertyValue($fieldId, $profilePropertyId); break; default: break; } $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}/{$fieldId}"); } // and save user with new fields data SJB_UserManager::saveUser($user); SJB_Authorization::updateCurrentUserSession(); // clean temporary storage $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}"); // CLEAR TEMPORARY SESSION STORAGE SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage); } } // <<< SJB-1197 if (SJB_Request::isAjax()) { echo "<p class=\"green\">User Saved</p>"; exit; } if ($form_submitted == 'save_info') { $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-users/" . mb_strtolower($userGroupInfo['id'], 'utf8')); } if (!empty($properties)) { $user->details->properties = $properties; } } if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) { $user->deleteProperty("username"); } $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo(); $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($user_info['user_group_sid']); $allowedListingTypes = array(); foreach ($products as $product) { if (!empty($product['listing_type_sid']) && empty($allowedListingTypes[$product['listing_type_sid']])) { foreach ($listingTypes as $listingType) { if ($product['listing_type_sid'] == $listingType['sid']) { $allowedListingTypes[$product['listing_type_sid']] = $listingType; } } } } $edit_user_form = SJB_ObjectMother::createForm($user); $edit_user_form->registerTags($tp); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']); if (SJB_UserManager::checkBan($errors, $user_info['ip'])) { $user_info['ip_is_banned'] = 1; } $tp->assign("form_fields", $edit_user_form->getFormFieldsInfo()); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->assign("errors", $errors); $tp->assign("listingTypes", $allowedListingTypes); $tp->assign("user_info", $user_info); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('userTree', true); $tp->assign("parent_name", $parent_name); $tp->assign("restore", preg_match('/manage-(jobseekers)|(employers)|([a-z0-9\\_]-users)/', SJB_Request::getVar('HTTP_REFERER', '', 'SERVER'))); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->display("edit_user.tpl"); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $display_form = new SJB_Form(); $display_form->registerTags($tp); $current_user = SJB_UserManager::getCurrentUser(); $errors = array(); $template = SJB_Request::getVar('display_template', 'display_listing.tpl'); $tcpdfError = SJB_Request::getVar('error', false); $action = substr($template, 0, -4); $listing_id = SJB_Request::getVar("listing_id"); if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $listing_id = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } if (is_null($listing_id) && SJB_FormBuilderManager::getIfBuilderModeIsSet()) { $listing_type_id = SJB_Request::getVar('listing_type_id'); $listing_id = SJB_ListingManager::getListingIDByListingTypeID($listing_type_id); } if (is_null($listing_id)) { $errors['UNDEFINED_LISTING_ID'] = true; } elseif (is_null($listing = SJB_ListingManager::getObjectBySID($listing_id)) || !SJB_ListingManager::isListingAccessableByUser($listing_id, SJB_UserManager::getCurrentUserSID())) { $errors['WRONG_LISTING_ID_SPECIFIED'] = true; } elseif (!$listing->isActive() && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) { $errors['LISTING_IS_NOT_ACTIVE'] = true; } elseif (($listingStatus = SJB_ListingManager::getListingApprovalStatusBySID($listing_id)) != 'approved' && SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing->listing_type_sid) == 1 && $listing->getUserSID() != SJB_UserManager::getCurrentUserSID()) { $errors['LISTING_IS_NOT_APPROVED'] = true; } elseif (SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Resume' && ($template == 'display_job.tpl' or SJB_System::getURI() == '/print-job/') || SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid) == 'Job' && ($template == 'display_resume.tpl' or SJB_System::getURI() == '/print-resume/')) { $errors['WRONG_DISPLAY_TEMPLATE'] = true; } else { $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid); if (SJB_System::getURI() == '/print-listing/') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/print-' . strtolower($listing_type_id) . '/?listing_id=' . $listing_id); exit; } $listing->addPicturesProperty(); $display_form = new SJB_Form($listing); $display_form->registerTags($tp); $form_fields = $display_form->getFormFieldsInfo(); $listingOwner = SJB_UserManager::getObjectBySID($listing->user_sid); if ($action !== 'print_listing') { SJB_ListingManager::incrementViewsCounterForListing($listing_id, $listing); } $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing, array('comments', 'ratings')); $filename = SJB_Request::getVar('filename', false); if ($filename) { $file = SJB_UploadFileManager::openFile($filename, $listing_id); $errors['NO_SUCH_FILE'] = true; } $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure['METADATA']), "form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields))); $comments = array(); $comments_total = ''; if (SJB_Settings::getSettingByName('show_comments') == '1') { $comments = SJB_CommentManager::getEnabledCommentsToListing($listing_id); $comments_total = count($comments); } $searchId = SJB_Request::getVar("searchId", ""); $page = SJB_Request::getVar("page", ""); $criteria_saver = new SJB_ListingCriteriaSaver($searchId); $searchCriteria = $criteria_saver->getCriteria(); $keywordsHighlight = ''; if (isset($searchCriteria['keywords']) && SJB_System::getSettingByName('use_highlight_for_keywords')) { foreach ($searchCriteria['keywords'] as $type => $keywords) { switch ($type) { case 'like': case 'exact_phrase': $keywordsHighlight = json_encode($keywords); break; case 'all_words': case 'any_words': $keywordsHighlight = json_encode(explode(' ', $keywords)); break; case 'boolean': $keywordsHighlight = json_encode(SJB_BooleanEvaluator::parse($keywords, true)); break; } } } $prevNextIds = $criteria_saver->getPreviousAndNextObjectID($listing_id); $search_criteria_structure = $criteria_saver->createTemplateStructureForCriteria(); //permissions contact info $acl = SJB_Acl::getInstance(); $permission = 'view_' . $listing_type_id . '_contact_info'; $allowViewContactInfo = false; if (SJB_UserManager::isUserLoggedIn()) { if (SJB_ContractManager::isPageViewed($current_user->getSID(), $permission, $listing_id) || $acl->isAllowed($permission) && in_array($acl->getPermissionParams($permission), array('', '0'))) { $allowViewContactInfo = true; } elseif ($acl->isAllowed($permission)) { $viewContactInfo['count_views'] = 0; $contractIDs = $current_user->getContractID(); $numberOfContactViewed = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), $contractIDs, $permission); foreach ($contractIDs as $contractID) { if ($acl->getPermissionParams($permission, $contractID, 'contract')) { $params = $acl->getPermissionParams($permission, $contractID, 'contract'); $viewsLeft = SJB_ContractManager::getNumbeOfPagesViewed($current_user->getSID(), array($contractID), $permission); if (isset($viewContactInfo['count_views']) && is_numeric($params)) { $viewContactInfo['count_views'] += $params; if ($params > $viewsLeft) { $viewContactInfo['contract_id'] = $contractID; } } } } if ($viewContactInfo && $viewContactInfo['count_views'] > $numberOfContactViewed) { $allowViewContactInfo = true; SJB_ContractManager::addViewPage($current_user->getSID(), $permission, $listing_id, $viewContactInfo['contract_id'], $listing->getListingTypeSID()); } } $user_group_id = SJB_UserGroupManager::getUserGroupIDBySID($current_user->getUserGroupSID()); if ($allowViewContactInfo && $user_group_id == 'JobSeeker' && $listing_type_id == 'Job') { SJB_UserManager::saveRecentlyViewedListings($current_user->getSID(), $listing_id); } } elseif ($acl->isAllowed($permission)) { $allowViewContactInfo = true; } $tp->assign("keywordsHighlight", $keywordsHighlight); $tp->assign('allowViewContactInfo', $allowViewContactInfo); $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates')); $tp->assign("isApplied", SJB_Applications::isApplied($listing_id, SJB_UserManager::getCurrentUserSID())); $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates')); $tp->assign('show_comments', SJB_Settings::getSettingByName('show_comments')); $tp->assign('comments', $comments); $tp->assign('comments_total', $comments_total); $tp->assign('listing_id', $listing_id); $tp->assign("form_fields", $form_fields); $tp->assign('video_fields', SJB_HelperFunctions::takeMediaFields($form_fields)); $tp->assign('uri', base64_encode(SJB_Navigator::getURIThis())); $tp->assign('listingOwner', $listingOwner); $listing_structure = SJB_ListingManager::newValueFromSearchCriteria($listing_structure, $criteria_saver->criteria); // SJB-1197: ajax autoupload. // Fix to view video from temporary uploaded storage. $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage'); // NEED TO CHECK FOR COMPLEX PARENT AND COMPLEX STEP PARAMETERS! $complexParent = SJB_Request::getVar('complexParent'); $complexStep = SJB_Request::getVar('complexEnum'); $fieldId = SJB_Request::getVar('field_id'); $isComplex = false; if ($complexParent && $complexStep) { $fieldId = $complexParent . ":" . $fieldId . ":" . $complexStep; $isComplex = true; } $tempFileValue = SJB_Array::getPath($sessionFilesStorage, "listings/{$listing_id}/{$fieldId}"); if ($isComplex) { $uploadFileManager = new SJB_UploadFileManager(); $fileLink = $uploadFileManager->getUploadedFileLink($tempFileValue['file_id']); $tp->assign('videoFileLink', $fileLink); } else { if (!empty($tempFileValue)) { $fileUniqueId = isset($tempFileValue['file_id']) ? $tempFileValue['file_id'] : ''; if (!empty($fileUniqueId)) { $upload_manager = new SJB_UploadFileManager(); // file structure for videoplayer $fileInfo = array('file_url' => $upload_manager->getUploadedFileLink($fileUniqueId), 'file_name' => $upload_manager->getUploadedFileName($fileUniqueId), 'saved_file_name' => $upload_manager->getUploadedSavedFileName($fileUniqueId), 'file_id' => $fileUniqueId); $listing_structure[$fieldId] = $fileInfo; } } } // SJB-1197 // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION $zipCode = ''; if (!empty($listing_structure['Location']['ZipCode'])) { $zipCode = $listing_structure['Location']['ZipCode']; } // get 'latitude' and 'longitude' from zipCode field, if it not set $latitude = isset($listing_structure['latitude']) ? $listing_structure['latitude'] : ''; $longitude = isset($listing_structure['longitude']) ? $listing_structure['longitude'] : ''; if (!empty($zipCode) && empty($latitude) && empty($longitude)) { $result = SJB_DB::query("SELECT * FROM `locations` WHERE `name` = ?s LIMIT 1", $zipCode); if ($result) { $listing_structure['latitude'] = $result[0]['latitude']; $listing_structure['longitude'] = $result[0]['longitude']; } } elseif (!empty($listing_structure['Location']['City']) && !empty($listing_structure['Location']['State']) && !empty($listing_structure['Location']['Country'])) { $address = $listing_structure['Location']['City'] . ', ' . $listing_structure['Location']['State'] . ', ' . $listing_structure['Location']['Country']; $address = urlencode($address); $cache = SJB_Cache::getInstance(); $parameters = array('City' => $listing_structure['Location']['City'], 'State' => $listing_structure['Location']['State'], 'Country' => $listing_structure['Location']['Country']); $hash = md5('google_map' . serialize($parameters)); $data = $cache->load($hash); $geoCod = ''; if (!$data) { try { $geoCod = SJB_HelperFunctions::getUrlContentByCurl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false"); $geoCod = json_decode($geoCod); if ($geoCod->status == 'OK') { $cache->save($geoCod, $hash); } } catch (Exception $e) { $backtrace = SJB_Logger::getBackTrace(); SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace))))); } } else { $geoCod = $data; } try { if (!is_object($geoCod)) { throw new Exception("Map object nave not been Created"); } if ($geoCod->status !== 'OK') { throw new Exception("Status is not OK"); } $location = $geoCod->results[0]->geometry->location; $listing_structure['latitude'] = $location->lat; $listing_structure['longitude'] = $location->lng; } catch (Exception $e) { $backtrace = SJB_Logger::getBackTrace(); SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace))))); } } if (SJB_Request::getVar('view')) { $tp->assign('listings', array($listing_structure)); } $tp->filterThenAssign("listing", $listing_structure); $tp->assign("prev_next_ids", $prevNextIds); $tp->assign("searchId", $searchId); $tp->assign("page", $page); $tp->filterThenAssign("search_criteria", $search_criteria_structure); $tp->filterThenAssign("search_uri", $criteria_saver->getUri()); if ($field_id = SJB_Request::getVar('field_id')) { // SJB-825 $complexEnum = SJB_Request::getVar('complexEnum', null, 'GET'); $complexFieldID = SJB_Request::getVar('complexParent', null, 'GET'); if (!is_null($complexEnum) && !is_null($complexFieldID)) { $videoFileID = $complexFieldID . ':' . $field_id . ':' . $complexEnum . '_' . $listing_id; $videoFileLink = SJB_UploadFileManager::getUploadedFileLink($videoFileID); if ($videoFileLink) { $tp->assign('videoFileLink', $videoFileLink); } } // SJB-825 $tp->assign('field_id', $field_id); } else { if (SJB_Request::getVar('action', false) == 'download_pdf_version') { $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_PDF, $listing_type_id); $formBuilder->setChargedTemplateProcessor($tp); $tpl = 'resume_to_pdf.tpl'; if ($listing_structure['anonymous'] == '1') { $filename = 'Anonymous User_' . $listing_structure['Title'] . '.pdf'; } else { $filename = $listing_structure['user']['FirstName'] . ' ' . $listing_structure['user']['LastName'] . '_' . $listing_structure['Title'] . '.pdf'; } try { $html = $tp->fetch($tpl); $html = preg_replace('/<div[^>]*>/', '', $html); $html = str_replace('</div>', '', $html); SJB_HelperFunctions::html2pdf($html, $filename, str_replace('http://', '', SJB_HelperFunctions::getSiteUrl())); exit; } catch (Exception $e) { SJB_Error::writeToLog($e->getMessage()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/display-resume/' . $listing_id . '/?error=TCPDF_ERROR'); } } else { $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, $listing_type_id); $formBuilder->setChargedTemplateProcessor($tp); } } } if ($errors) { foreach ($errors as $k => $v) { switch ($k) { case 'TCPDF_ERROR': case 'UNDEFINED_LISTING_ID': case 'WRONG_LISTING_ID_SPECIFIED': case 'LISTING_IS_NOT_ACTIVE': case 'LISTING_IS_NOT_APPROVED': $header = $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'; $header_status = "Status: 404 Not Found"; header($header_status); header($header); SJB_System::setGlobalTemplateVariable('page_not_found', true); break; } } } $tp->assign('errors', $errors); $tp->assign('tcpdfError', $tcpdfError); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $displayTemplate = 'view.tpl'; $errors = array(); $filename = SJB_Request::getVar('filename', false); if ($filename) { $appsID = SJB_Request::getVar('appsID', false); if ($appsID) { $file = SJB_UploadFileManager::openApplicationFile($filename, $appsID); if (!$file) { $errors['NO_SUCH_FILE'] = true; } } else { $errors['NO_SUCH_APPS'] = true; } } $cu = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid', null)); $tp->assign('user_sid', $cu['sid']); $tp->assign('username', $cu['username']); $appJobId = SJB_Request::getVar('appJobId', false); // посортируем чего-нибуть $orderBy = SJB_Request::getVar('orderBy', 'date'); $order = SJB_Request::getVar('order', 'desc'); $tp->assign('orderBy', $orderBy); $tp->assign('order', $order); if (!empty($orderBy) && isset($order)) { switch ($orderBy) { case 'date': $orderInfo = array('sorting_field' => 'date', 'sorting_order' => $order); break; case 'title': $orderInfo = array('sorting_field' => 'Title', 'sorting_order' => $order, 'inner_join' => array('table' => 'listings', 'field1' => 'sid', 'field2' => 'listing_id')); break; case 'applicant': $orderInfo = false; $sortByUsername = true; break; case 'status': $orderInfo = array('sorting_field' => 'status', 'sorting_order' => $order); break; case 'company': $orderInfo = array('sorting_field' => 'CompanyName', 'sorting_order' => $order, 'inner_join' => array('table' => 'listings', 'field1' => 'sid', 'field2' => 'listing_id'), 'inner_join2' => array('table1' => 'users', 'table2' => 'listings', 'field1' => 'sid', 'field2' => 'user_sid')); break; } } if ($cu['user_group_sid'] == 41) { // Работадатель if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'approve': if (isset($_POST['applications'])) { foreach ($_POST['applications'] as $key => $value) { SJB_Applications::accept($key); } } break; case 'reject': if (isset($_POST['applications'])) { foreach ($_POST['applications'] as $key => $value) { SJB_Applications::reject($key); } } break; case 'delete': if (isset($_POST['applications'])) { foreach ($_POST['applications'] as $key => $value) { SJB_Applications::hideEmp($key); } } break; } } if ($appJobId) { $apps = SJB_Applications::getByJob($appJobId, $orderInfo); } else { $apps = SJB_Applications::getByEmployer($cu['sid'], $orderInfo); } for ($i = 0; $i < count($apps); ++$i) { $apps[$i]['job'] = SJB_ListingManager::getListingInfoBySID($apps[$i]['listing_id']); if (isset($apps[$i]['resume']) && !empty($apps[$i]['resume'])) { $apps[$i]['resumeInfo'] = SJB_ListingManager::getListingInfoBySID($apps[$i]['resume']); } if ($apps[$i]['jobseeker_id'] == 0) { $apps[$i]['user']['FirstName'] = $apps[$i]['username']; } else { $apps[$i]['user'] = SJB_UserManager::getUserInfoBySID($apps[$i]['jobseeker_id']); } } $jobs = SJB_ListingManager::getListingsByUserSID($cu['sid']); $appJobs = array(); foreach ($jobs as $job) { $appJobs[] = array('title' => $job->details->properties['Title']->value, 'id' => $job->sid); } $tp->assign('appJobs', $appJobs); $tp->assign('current_filter', $appJobId); } else { // Соискатель if (SJB_Request::getVar('action', '', SJB_Request::METHOD_POST) == 'Delete selected') { if (isset($_POST['applications'])) { foreach ($_POST['applications'] as $key => $value) { SJB_Applications::hideJS($key); } } } $apps = SJB_Applications::getByJobseeker($cu['sid'], $orderInfo); for ($i = 0; $i < count($apps); ++$i) { $apps[$i]['job'] = SJB_ListingManager::getListingInfoBySID($apps[$i]['listing_id']); $apps[$i]['company'] = SJB_UserManager::getUserInfoBySID($apps[$i]['job']['user_sid']); } $displayTemplate = 'view_seeker.tpl'; } if (isset($sortByUsername)) { $order = $order == 'desc' ? SORT_DESC : SORT_ASC; foreach ($apps as $key => $value) { if (!isset($apps[$key]['user']['FirstName'])) { $apps[$key]['user']['FirstName'] = ''; } if (!isset($apps[$key]['user']['LastName'])) { $apps[$key]['user']['LastName'] = ''; } $sortKeys[$key] = $apps[$key]['user']['FirstName'] . ' ' . $apps[$key]['user']['LastName']; } if ($apps) { array_multisort($sortKeys, $order, SORT_REGULAR, $apps); } } $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($cu['user_group_sid']); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']); $tp->assign('METADATA', SJB_Application::getApplicationMeta()); $tp->assign("user_group_info", $userGroupInfo); $tp->assign('applications', $apps); $tp->assign('errors', $errors); $tp->display($displayTemplate); }
public function execute() { $listing_id = SJB_Request::getVar('listing_id', null); $listing_info = SJB_ListingManager::getListingInfoBySID($listing_id); $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_info['listing_type_sid']); if (!is_null($listing_info)) { $filename = SJB_Request::getVar('filename', false); if ($filename) { $file = SJB_UploadFileManager::openFile($filename, $listing_id); $errors['NO_SUCH_FILE'] = true; } if (isset($_REQUEST['Occupations']) && isset($_REQUEST['Occupations']['tree']) && !$_REQUEST['Occupations']['tree']) { unset($_REQUEST['Occupations']['tree']); } $listing_info = array_merge($listing_info, $_REQUEST); if (isset($_REQUEST['Occupations']) && isset($_REQUEST['Occupations']['tree']) && $_REQUEST['Occupations']['tree']) { $listing_info['Occupations'] = $_REQUEST['Occupations']['tree']; } $listing = new SJB_Listing($listing_info, $listing_info['listing_type_sid']); $listing->setSID($listing_id); $listing_edit_form = new SJB_Form($listing); $form_is_submitted = SJB_Request::getVar('action'); $errors = array(); if ($form_is_submitted) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true)); } if ($form_is_submitted && $listing_edit_form->isDataValid($errors)) { $listingSid = $listing->getID(); SJB_BrowseDBManager::deleteListings($listingSid); SJB_ListingManager::saveListing($listing); SJB_BrowseDBManager::addListings($listingSid); $formToken = SJB_Request::getVar('form_token'); $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage'); $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken); if (!empty($uploadedFields)) { foreach ($uploadedFields as $fieldId => $fieldValue) { // get field of listing $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldValue['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } // unset value from session temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}"); } //and remove token key from temporary storage $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}"); SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage); SJB_ListingManager::saveListing($listing); } SJB_Event::dispatch('listingEdited', $listingSid); if (SJB_Request::isAjax()) { echo '<p class="green">Listing Saved</p>'; exit; } if ($form_is_submitted == 'save_info') { $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listing_info['listing_type_sid']); $listingType = $listingTypeId != 'Job' && $listingTypeId != 'Resume' ? $listingTypeId . '-listings' : $listingTypeId . 's'; SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/manage-" . strtolower($listingType) . "/?restore=1"); } } $listing->deleteProperty('access_list'); $comments = SJB_CommentManager::getEnabledCommentsToListing($listing_id); $comments_total = count($comments); $rate = SJB_Rating::getRatingNumToListing($listing_id); $form_fields = $listing_edit_form->getFormFieldsInfo(); $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing->getListingTypeSID()); $realFormFields = array(); foreach ($pages as $page) { $listingFields = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']); foreach ($listingFields as $fieldID => $listingField) { if (isset($form_fields[$fieldID])) { $realFormFields[$fieldID] = $form_fields[$fieldID]; } } } $adminFields = array(); foreach ($form_fields as $fieldName => $field) { if (!isset($realFormFields[$fieldName])) { $adminFields[$fieldName] = $field; } } $realFormFields = array_merge($adminFields, $realFormFields); $tp = SJB_System::getTemplateProcessor(); $listing_edit_form->registerTags($tp); $extraInfo = $listing_info['product_info']; if ($extraInfo) { $extraInfo = unserialize($extraInfo); $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $tp->assign("listing_duration", $extraInfo['listing_duration']); $tp->assign("pic_limit", $numberOfPictures); } $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing); if (!isset($listing_structure['access_type'])) { $listing_structure['access_type'] = 'everyone'; } $listing_access_list = SJB_ListingManager::getListingAccessList($listing_id, $listing->getPropertyValue('access_type')); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->assign('form_fields', $realFormFields); $tp->assign('listing', $listing_structure); $tp->assign('errors', $errors); $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo)); $tp->assign('listing_access_list', $listing_access_list); $tp->assign('comments_total', $comments_total); $tp->assign('rate', $rate); $tp->assign('expired', SJB_ListingManager::getIfListingHasExpiredBySID($listing->getSID())); SJB_System::setGlobalTemplateVariable('wikiExtraParam', $listingTypeInfo['id']); $tp->display('edit_listing.tpl'); } }