public function search() { $action = SJB_Request::getVar('action'); $period = SJB_Request::getVar('period', array()); $sorting_field = SJB_Request::getVar('sorting_field', 'usageCount'); $sorting_order = SJB_Request::getVar('sorting_order', 'DESC'); $i18n = SJB_I18N::getInstance(); $statistics = array(); if ($action) { if (!empty($period['from']) && !empty($period['to'])) { $from = $i18n->getInput('date', $period['from']); $to = $i18n->getInput('date', $period['to']); if (strtotime($from) > strtotime($to)) { throw new Exception('SELECTED_PERIOD_IS_INCORRECT'); } } $statistics = SJB_Statistics::getPromotionsStatistics($period, $sorting_field, $sorting_order); } $periodView = array(); foreach ($period as $key => $value) { $periodView[$key] = $i18n->getInput('date', $period[$key]); } $this->tp->assign('currency', SJB_CurrencyManager::getDefaultCurrency()); $this->tp->assign('action', $action); $this->tp->assign('period', $period); $this->tp->assign('periodView', $periodView); $this->tp->assign('statistics', $statistics); $this->tp->assign('countResult', count($statistics)); $this->tp->assign('sorting_field', $sorting_field); $this->tp->assign('sorting_order', $sorting_order); }
public static function translate($string, $domain = null, $mode = null) { if (empty($string)) { return $string; } $i18n = \SJB_I18N::getInstance(); $matches = array(); $result = array(); if (strpos($string, ',') !== false) { $stringStack = explode(', ', $string); } else { $stringStack = array($string); } foreach ($stringStack as $string) { $isFeaturedPayment = preg_match("#Upgrade of (\".+\") Job to featured( \\(.+\\))?#", $string, $matchesFeatured); $isPriorityPayment = preg_match("#Upgrade of (\".+\") Job to priority( \\(.+\\))?#", $string, $matchesPriority); if ($isFeaturedPayment) { $matches = $matchesFeatured; $prefix = 'Upgrade of $listingTitle Job to featured'; } else { if ($isPriorityPayment) { $matches = $matchesPriority; $prefix = 'Upgrade of $listingTitle Job to priority'; } } if ($matches) { $listingTitle = $matches[1]; $prefix = $i18n->gettext($domain, trim($prefix), $mode); $result[] = str_replace('{$listingTitle}', $listingTitle, $prefix) . $matches[2]; } } return $result ? join(', ', $result) : $string; }
public static function get($action, $params) { if (SJB_System::getSystemSettings('isDemo')) { return new SJB_LanguageAction(); } $i18n = SJB_I18N::getInstance(); $lang = isset($params['languageId']) ? $params['languageId'] : null; switch ($action) { case 'set_default_language': return new SJB_SetDefaultLanguageAction($i18n, $lang); break; case 'add_language': return new SJB_AddLanguageAction($i18n, $params); break; case 'update_language': return new SJB_UpdateLanguageAction($i18n, $params); break; case 'delete_language': return new SJB_DeleteLanguageAction($i18n, $lang); break; case 'import_language': return new SJB_ImportLanguageAction($i18n, $params); break; case 'export_language': return new SJB_ExportLanguageAction($i18n, $lang); break; default: return new SJB_LanguageAction(); } }
function isValid() { $value = $this->property_info['value']; $i18n = SJB_I18N::getInstance(); if ($i18n->isValidInteger($value)) { $value = $i18n->getInput('integer', $value); } else { return 'NOT_INT_VALUE'; } if (!empty($this->minimum) && is_numeric($this->minimum) && $this->minimum > $value) { return 'OUT_OF_RANGE'; } if (!empty($this->maximum) && is_numeric($this->maximum) && $this->maximum < $value) { return 'OUT_OF_RANGE'; } if (!empty($this->property_info['validators'])) { foreach ($this->property_info['validators'] as $validator) { $isValid = $validator::isValid($this); if ($isValid !== true) { return $isValid; } } } return true; }
public function __construct($defaultSortingField, $defaultSortingOrder, $defaultItemsPerPage) { $this->sortingField = $this->getPaginationParameter('sortingField', $defaultSortingField); $this->sortingOrder = $this->getPaginationParameter('sortingOrder', $defaultSortingOrder); $this->itemsPerPage = $this->getPaginationParameter('itemsPerPage', $defaultItemsPerPage); $this->currentPage = $this->getPaginationParameter('page', 1); $i18N = SJB_I18N::getInstance(); $this->translatedText['chooseAction'] = $i18N->gettext('Backend', 'Please, choose an action'); $this->translatedText['chooseItem'] = $i18N->gettext('Backend', 'Please, select ' . $this->item . ' first'); $this->translatedText['delete'] = $i18N->gettext('Backend', 'Are you sure you want to delete selected ' . $this->item . '?'); }
public static function getTaxAmount($invoice_sum, $tax_rate, $price_includes_taxes = false) { $i18n = SJB_I18N::getInstance(); $lang_data = $i18n->getLanguageData($i18n->getCurrentLanguage()); if ($price_includes_taxes) { $amount = round($invoice_sum - $invoice_sum / ($tax_rate / 100 + 1), $lang_data['decimals']); } else { $amount = round($invoice_sum * $tax_rate / 100, $lang_data['decimals']); } return $amount; }
public function saveFeed($feed, $action = '') { $networkSocialMedia = new SJB_FacebookSocialMedia(); $accessToken = $networkSocialMedia->getAccessToken(); $user = $networkSocialMedia->getAccountInfo($feed->getSID()); $accountName = !empty($user['account_name']) ? $user['account_name'] : ''; $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => $accessToken, 'is_system' => true)); $feed->addProperty(array('id' => 'account_name', 'type' => 'text', 'value' => $accountName, 'is_system' => true)); $feed->addProperty(array('id' => 'expiration_date', 'type' => 'date', 'value' => SJB_I18N::getInstance()->getDate(date('Y-m-d', time() + 60 * 24 * 60 * 60)), 'is_system' => true)); parent::saveFeed($feed); }
public function execute() { $result = false; $error = ''; try { $builderData = new SJB_FormBuilderData($_REQUEST); $result = SJB_FormBuilderManager::save($builderData); } catch (Exception $e) { $error = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage()); } echo json_encode(array('success' => $result, 'message' => $error)); exit; }
public function execute() { $ou = SJB_UserManager::getOnlineUsers(); $onlineUsers = array(); $totalOnlineUsers = 0; $userGroups = SJB_UserGroupManager::createTemplateStructureForUserGroups(); foreach ($userGroups as $userGroup) { $onlineUsers[$userGroup["id"]]["count"] = 0; $onlineUsers[$userGroup["id"]]["caption"] = $userGroup["caption"]; } foreach ($ou as $value) { $onlineUsers[$value["type"]]["count"]++; $totalOnlineUsers++; } $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default'); $themePath = SJB_TemplatePathManager::getAbsoluteThemePath($theme); // FLAGGED LISTINGS $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo(); $totalFlagsNum = array(); foreach ($allListingTypes as $type) { $totalFlagsNum[$type['id']] = SJB_ListingManager::getFlagsNumberByListingTypeSID($type['sid'], $filter = null, $groupByListingSID = true); } $files = $this->getCssFiles($themePath); $tp = SJB_System::getTemplateProcessor(); $tp->assign('totalFlagsNum', $totalFlagsNum); $tp->assign('usersInfo', SJB_UserManager::getUsersInfo()); $tp->assign('groupsInfo', SJB_UserManager::getGroupsInfo()); $tp->assign('listingsInfo', SJB_ListingManager::getListingsInfo()); $tp->assign('listingTypesInfo', SJB_ListingTypeManager::getAllListingTypesInfo()); $tp->assign('invoicesInfo', SJB_InvoiceManager::getInvoicesInfo()); $tp->assign('unpaidInvoices', SJB_InvoiceManager::getTotalUnpaidInvoices()); $tp->assign('totalInvoices', SJB_InvoiceManager::getTotalInvoices()); $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $tp->assign("today", strftime($lang['date_format'], time())); // ранее были данные за период: месяц (последние 30 дней), неделя (последние 7 дней) // теперь - текущий месяц и текущая неделя $currMonth = strftime($lang['date_format'], mktime(0, 0, 0, date("m"), 1, date("Y"))); $currWeek = strftime($lang['date_format'], mktime(0, 0, 0, date("m"), date("d") - date("N") + 1, date("Y"))); $tp->assign("weekAgo", $currWeek); $tp->assign("monthAgo", $currMonth); $tp->assign('onlineUsers', $onlineUsers); $tp->assign('totalOnlineUsers', $totalOnlineUsers); if (count($files) > 0) { $tp->assign("file", $files[0]); } $tp->display("index.tpl"); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $sid = false; if (isset($_REQUEST['passed_parameters_via_uri'])) { $passed_parameters_via_uri = SJB_UrlParamProvider::getParams(); $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null; } $cu = SJB_UserManager::getCurrentUser(); if (!isset($cu->user_group_sid)) { $userGroupSID = 0; } else { $userGroupSID = $cu->user_group_sid; } $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; if ($sid && SJB_PollsManager::isActive($sid, $userGroupSID, $langId)) { $countVotes = SJB_PollsManager::getCountVotesBySID($sid); $pollResults = SJB_PollsManager::getPollResultsBySID($sid); $result = array(); $i = 0; $colors = array('613978', 'aad434', 'f55c00', 'f9c635', 'f97c9e', '870000', '0ec300', '6f6f6f', '0400a5', '6eeffb', '000000', 'ff00ff'); foreach ($pollResults as $poll) { $result[$i]['vote'] = $countVotes > 0 ? round(100 / $countVotes * $poll['count'], 2) : 0; $result[$i]['value'] = $poll['question']; $result[$i]['color'] = $colors[$i]; $i++; } $pollInfo = SJB_PollsManager::getPollInfoBySID($sid); $tp->assign('pollInfo', $pollInfo); $tp->assign('result', $result); $tp->assign('width', count($pollResults) * 40 + (count($pollResults) - 1) * 3); $tp->assign('show_total_votes', isset($pollInfo['show_total_votes']) ? $pollInfo['show_total_votes'] : 0); $tp->assign('count_vote', $countVotes); } else { $pollInfo = SJB_PollsManager::getPollInfoBySID($sid); if ($pollInfo['language'] != $langId) { $errors[] = 'This poll is not available for this language'; } } $tp->assign('errors', $errors); $tp->display('poll_results.tpl'); }
/** * Check 'sort_by_alphabet' flag for field, and sort values if needed * * @param $values */ private function getSortedValues($values) { $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($this->field['sid']); if (SJB_Array::get($fieldInfo, 'sort_by_alphabet') > 0) { $i18n = SJB_I18N::getInstance(); // translate captions to current language $translates = array(); foreach ($values as $value) { $translates[] = $i18n->gettext('', $value); } // we need to recover keys for $values after array_multisort $keys = array_keys($values); // sort $keys and $values order by $translates sort array_multisort($translates, SORT_STRING, $keys, $values); // restore keys for $values $values = array_combine($keys, $values); } return $values; }
public function execute() { set_time_limit(0); $i18n = SJB_I18N::getInstance(); $this->lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $this->currentDate = strftime($this->lang['date_format'], time()); // Do Autobackup $autoBackup = new SJB_Autobackup(); $autoBackup->doBackup(); $this->tp = SJB_System::getTemplateProcessor(); if (time() - SJB_Settings::getSettingByName('task_scheduler_last_executed_time_hourly') > 3600) { $this->runHourlyTaskScheduler(); SJB_Settings::updateSetting('task_scheduler_last_executed_time_hourly', time()); } if (time() - SJB_Settings::getSettingByName('task_scheduler_last_executed_time_daily') > 86400) { $this->runDailyTaskScheduler(); SJB_Settings::updateSetting('task_scheduler_last_executed_time_daily', time()); } $this->runTaskScheduler(); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; // params $count = SJB_Settings::getSettingByName('number_news_on_main_page'); $result = SJB_NewsManager::getLatestNews($count, $langId, SJB_Settings::getSettingByName('main_page_news_display_mode')); $articles = array(); foreach ($result as $article) { $articles[] = SJB_NewsManager::createTemplateStructureForNewsArticle($article); } // clear unnecessary data unset($result); $tp->assign('count', $count); $tp->assign('articles_count', count($articles)); $tp->assign('articles', $articles); $tp->display('news.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $pollSID = SJB_Request::getVar('sid', 0, null, 'int'); $cu = SJB_UserManager::getCurrentUser(); $i18n = SJB_I18N::getInstance(); $lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $langId = $lang['id']; if (!$pollSID) { $pollSID = SJB_PollsManager::getPollForDisplay($cu->user_group_sid, $langId); } if ($pollSID) { if (SJB_PollsManager::isActive($pollSID, $cu->user_group_sid, $langId)) { $action = SJB_Request::getVar('action', false); $IP = $_SERVER['REMOTE_ADDR']; $isVoted = SJB_PollsManager::isVoted($pollSID, $IP); switch ($action) { case 'save': $value = SJB_Request::getVar('poll', false); if ($value && $pollSID && !$isVoted) { SJB_PollsManager::addPollResult($pollSID, $value, $IP); $isVoted = true; } break; } $poll_info = SJB_PollsManager::getPollInfoBySID($pollSID); $poll = new SJB_UserPollsManager($poll_info); $poll->setSID($poll_info['sid']); $edit_form = new SJB_Form($poll); $edit_form->registerTags($tp); $form_fields = $edit_form->getFormFieldsInfo(); $tp->assign('display_results', $poll_info['display_results']); $tp->assign('question', trim(strip_tags($poll_info['question']))); $tp->assign('isVoted', $isVoted); $tp->assign('form_fields', $form_fields); $tp->assign('sid', $pollSID); $tp->display('polls.tpl'); } } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $form_submitted = SJB_Request::getVar('action'); $page = SJB_Request::getVar('page'); if ($form_submitted) { if (SJB_System::getSystemSettings("isDemo")) { $errors[] = "You don't have permissions for it. This is a Demo version of the software."; } else { if (!empty($_REQUEST['bad_words'])) { $_REQUEST['bad_words'] = trim($_REQUEST['bad_words']); } SJB_Settings::updateSettings($_REQUEST); } if ($form_submitted == 'apply_settings') { $tp->assign("page", $page); } } $i18n = SJB_I18N::getInstance(); $tp->assign("settings", SJB_Settings::getSettings()); $ds = DIRECTORY_SEPARATOR; $path = SJB_BASE_DIR . "system{$ds}cache{$ds}agents_bots.txt"; $disable_bots = file_get_contents($path); $tp->assign("disable_bots", $disable_bots); $tp->assign("timezones", timezone_identifiers_list()); if (!SJB_SubAdmin::getSubAdminSID()) { $tp->assign("subadmins", SJB_SubAdminManager::getAllSubAdminsInfo()); } $tp->assign("errors", $errors); $tp->assign("i18n_domains", $i18n->getDomainsData()); $tp->assign("i18n_languages", $i18n->getActiveLanguagesData()); $tp->assign("countries", SJB_CountriesManager::getAllCountriesCodesAndNames()); $tp->assign('listingEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_LISTING)); $tp->assign('productEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_PRODUCT)); $tp->assign('userEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_USER)); $tp->assign('otherEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_OTHER)); $tp->display("settings.tpl"); }
public function execute() { $page_id = SJB_Request::getVar('pageid', null); if ($page_id) { $tp = SJB_System::getTemplateProcessor(); $i18n = SJB_I18N::getInstance(); $lang = SJB_Request::getVar('lang', $i18n->getCurrentLanguage()); $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $lang); if (empty($staticContent)) { $def_lang = SJB_System::getSettingByName('i18n_default_language'); $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $def_lang); } if (!empty($staticContent)) { if ($page_id == '404') { $isLoggedIn = SJB_Authorization::isUserLoggedIn(); if ($isLoggedIn) { $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo(); $currentUserInfo = SJB_Authorization::getCurrentUserInfo(); $userGroupinfo = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']); $acl = SJB_Acl::getInstance(); $tp->assign('acl', $acl); $tp->assign('listingTypesInfo', $listingTypesInfo); $tp->assign('userGroupInfo', $userGroupinfo); } $staticContent['content'] = htmlspecialchars_decode($staticContent['content']); $tp->assign('isLoggedIn', $isLoggedIn); } if (empty($staticContent['content'])) { // Null создаёт ошибку в smarty $staticContent['content'] = ''; } $tp->assign('staticContent', $staticContent['content']); $tp->display('static_content.tpl'); } } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', 'search'); $filter = SJB_Request::getVar('filter', array()); $template = SJB_Request::getVar('template', 'general_statistics.tpl'); $errors = array(); switch ($action) { case 'export': $period = SJB_Request::getVar('period', false); $groupBy = SJB_Request::getVar('group_by', 'day'); $statistics = SJB_Statistics::getGeneralStatistics($period, $groupBy, $filter); if (!empty($statistics['errors'])) { $errors[] = $statistics['errors']; } if (!$errors && $statistics) { $type = SJB_Request::getVar('type', 'csv'); $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType(); $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(); SJB_StatisticsExportController::createExportDirectory(); switch ($type) { case 'csv': $exportData = SJB_StatisticsExportController::getGeneralExportData($statistics, $userGroups, $listingTypes, $filter); $fileName = 'general_statistics.csv'; SJB_StatisticsExportController::makeCSVExportFile($exportData, $fileName, 'General Statistics'); SJB_StatisticsExportController::archiveAndSendExportFile('general_statistics', 'csv'); break; case 'xls': $exportData = SJB_StatisticsExportController::getGeneralExportData($statistics, $userGroups, $listingTypes, $filter); $fileName = 'general_statistics.xls'; SJB_StatisticsExportController::makeXLSExportFile($exportData, $fileName, 'General Statistics'); SJB_StatisticsExportController::archiveAndSendExportFile('general_statistics', 'xls'); break; } break; } case 'search': $search = SJB_Request::getVar('search', false); $period = SJB_Request::getVar('period', false); $groupBy = SJB_Request::getVar('group_by', 'day'); $statistics = array(); if ($search) { $i18n = SJB_I18N::getInstance(); $from = $i18n->getInput('date', $period['from']); $to = $i18n->getInput('date', $period['to']); if (!empty($period['from']) && !empty($period['to']) && strtotime($from) > strtotime($to)) { $errors[] = 'SELECTED_PERIOD_IS_INCORRECT'; } else { if (count($filter) > 1) { $statistics = SJB_Statistics::getGeneralStatistics($period, $groupBy, $filter); if (!empty($statistics['errors'])) { $errors[] = $statistics['errors']; } } else { $errors[] = 'EMPTY_PARAMETER'; } } } $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType(); $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(); $listPlugins = SJB_PluginManager::getAllPluginsList(); $tp->assign('listPlugins', $listPlugins); $tp->assign('countItems', count($statistics) + 2); $tp->assign('userGroups', $userGroups); $tp->assign('listingTypes', $listingTypes); $tp->assign('errors', $errors); $tp->assign('groupBy', $groupBy); $tp->assign('statistics', $statistics); $tp->assign('period', $period); break; } $tp->assign('filter', $filter); $tp->assign('action', $action); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $userSID = SJB_Request::getVar('user_sid', false); $includeTax = SJB_Request::getVar('include_tax', SJB_Settings::getSettingByName('enable_taxes')); $errors = array(); $invoiceErrors = array(); $template = 'add_invoice.tpl'; $userInfo = SJB_UserManager::getUserInfoBySID($userSID); if ($userInfo) { if (!empty($userInfo['parent_sid'])) { $parent_sid = $userInfo['parent_sid']; $username = $userInfo['username'] . '/' . $userInfo['email']; } else { $parent_sid = $userSID; $username = $userInfo['FirstName'] . ' ' . $userInfo['LastName'] . ' ' . $userInfo['ContactName'] . ' ' . $userInfo['CompanyName'] . '/' . $userInfo['email']; } $formSubmitted = SJB_Request::getVar('action', '') == 'save'; $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userInfo['user_group_sid']); $products = array(); foreach ($productsSIDs as $key => $productSID) { $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') { $volumeBasedPricing = $productInfo['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]['number_of_listings'] = $i; for ($j = 1; $j <= count($volumeBasedPricing['listings_range_from']); $j++) { if ($i >= $volumeBasedPricing['listings_range_from'][$j] && $i <= $volumeBasedPricing['listings_range_to'][$j]) { $countListings[$i]['price'] = $volumeBasedPricing['price_per_unit'][$j]; } } } $productInfo['count_listings'] = $countListings; } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') { unset($productInfo['volume_based_pricing']); } $products[$key] = $productInfo; } $total = SJB_I18N::getInstance()->getInput('float', SJB_Request::getVar('total', 0)); $taxInfo = SJB_TaxesManager::getTaxInfoByUserSidAndPrice($parent_sid, $total); $invoice = new SJB_Invoice($_REQUEST); $addForm = new SJB_Form($invoice); $addForm->registerTags($tp); if ($formSubmitted) { $invoiceErrors = $invoice->isValid(); if (empty($invoiceErrors) && $addForm->isDataValid($errors)) { $invoice->setFloatNumbersIntoValidFormat(); $invoice->setPropertyValue('success_page_url', SJB_System::getSystemSettings('USER_SITE_URL') . '/create-contract/'); SJB_InvoiceManager::saveInvoice($invoice); if (SJB_Request::getVar('send_invoice', false)) { SJB_Notifications::sendInvoiceToCustomer($invoice->getSID(), $userSID); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/manage-invoices/'); } else { $invoiceDate = SJB_I18N::getInstance()->getInput('date', $invoice->getPropertyValue('date')); $invoice->setPropertyValue('date', $invoiceDate); } } else { $invoice->setPropertyValue('date', date('Y-m-d')); $invoice->setPropertyValue('status', SJB_Invoice::INVOICE_STATUS_UNPAID); } $invoice->setFloatNumbersIntoValidFormat(); $tp->assign('username', $username); $tp->assign('user_sid', $userSID); $tp->assign('products', $products); $tp->assign('tax', $taxInfo); $tp->assign('include_tax', $includeTax); } else { $errors[] = 'CUSTOMER_NOT_SELECTED'; $tp->assign('action', 'add'); $template = 'errors.tpl'; } $tp->assign("errors", array_merge($errors, $invoiceErrors)); $tp->display($template); }
public function __construct() { $i18n = SJB_I18N::getInstance(); $this->lang = $i18n->getLanguageData($i18n->getCurrentLanguage()); $this->sign = SJB_Settings::getValue('transaction_currency'); }
public function execute() { ini_set('max_execution_time', 0); $tp = SJB_System::getTemplateProcessor(); $file_info = isset($_FILES['import_file']) ? $_FILES['import_file'] : null; $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8'); $listingTypeID = SJB_Request::getVar('listing_type_id', null); $productSID = SJB_Request::getVar('product_sid', 0); $errors = array(); if ($listingTypeID && $productSID) { $acl = SJB_Acl::getInstance(); $resource = 'post_' . strtolower($listingTypeID); if (!$acl->isAllowed($resource, $productSID, 'product')) { $errors[] = 'You cannot import listings of this type under the selected product'; } } if (!empty($file_info)) { $extension = SJB_Request::getVar('file_type'); if (!SJB_ImportFile::isValidFileExtensionByFormat($extension, $file_info)) { $errors['DO_NOT_MATCH_SELECTED_FILE_FORMAT'] = true; } } if (empty($file_info) || $file_info['error'] || $errors) { if (isset($file_info['error']) && $file_info['error'] > 0) { $errors[SJB_UploadFileManager::getErrorId($file_info['error'])] = 1; } $listing_types = SJB_ListingTypeManager::getAllListingTypesInfo(); $products = SJB_ProductsManager::getProductsByProductType('post_listings'); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->assign('listing_types', $listing_types); $tp->assign('products', $products); $tp->assign('errors', $errors); $tp->assign('charSets', SJB_HelperFunctions::getCharSets()); $tp->display('import_listings.tpl'); } else { $i18n = SJB_I18N::getInstance(); $csv_delimiter = SJB_Request::getVar('csv_delimiter', null); $activeStatus = SJB_Request::getVar('active', 0); $activationDate = SJB_Request::getVar('activation_date', date('Y-m-d')); $activationDate = $i18n->getInput('date', $activationDate); $non_existed_values_flag = SJB_Request::getVar('non_existed_values', null); $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (empty($productInfo['listing_duration'])) { $expirationDate = ''; } else { $timestamp = strtotime($activationDate . ' + ' . $productInfo['listing_duration'] . ' days'); $expirationDate = $i18n->getDate(date('Y-m-d', $timestamp)); } $extension = $_REQUEST['file_type']; if ($extension == 'xls') { $import_file = new SJB_ImportFileXLS($file_info); } elseif ($extension == 'csv') { $import_file = new SJB_ImportFileCSV($file_info, $csv_delimiter); } $import_file->parse($encodingFromCharset); $listing = $this->CreateListing(array(), $listingTypeID); $imported_data = $import_file->getData(); $isFileImported = true; $count = 0; $addedListingsSids = array(); $nonExistentUsers = array(); foreach ($imported_data as $key => $importedColumn) { if ($key == 1) { $imported_data_processor = new SJB_ImportedDataProcessor($importedColumn, $listing); continue; } if (!$importedColumn) { continue; } $count++; $listingInfo = $imported_data_processor->getData($non_existed_values_flag, $importedColumn); $doc = new DOMDocument(); foreach ($listing->getProperties() as $property) { if ($property->getType() == 'complex' && !empty($listingInfo[$property->id])) { $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid); $doc->loadXML($listingInfo[$property->id]); $results = $doc->getElementsByTagName($property->id . 's'); $listingInfo[$property->id] = array(); foreach ($results as $complexparent) { $i = 1; foreach ($complexparent->getElementsByTagName($property->id) as $result) { $resultXML = simplexml_import_dom($result); foreach ($childFields as $childField) { if (isset($resultXML->{$childField}['id'])) { $listingInfo[$property->id][$childField['id']][$i] = XML_Util::reverseEntities((string) $resultXML->{$childField}['id']); } } $i++; } } } elseif ($property->getType() == 'monetary' && !empty($listingInfo[$property->id])) { $value = $listingInfo[$property->id]; $listingInfo[$property->id] = array(); $listingInfo[$property->id]['value'] = $value; $defaultCurrency = SJB_CurrencyManager::getDefaultCurrency(); $currencyCode = !empty($listingInfo[$property->id . "Currency"]) ? $listingInfo[$property->id . "Currency"] : $defaultCurrency['currency_code']; $currency = SJB_CurrencyManager::getCurrencyByCurrCode($currencyCode); $listingInfo[$property->id]['add_parameter'] = !empty($currency['sid']) ? $currency['sid'] : ''; if (isset($listingInfo[$property->id . "Currency"])) { unset($listingInfo[$property->id . "Currency"]); } } elseif ($property->getType() == 'location') { $locationFields = array($property->id . '.Country', $property->id . '.State', $property->id . '.City', $property->id . '.ZipCode'); $locationFieldAdded = array(); foreach ($locationFields as $locationField) { if (array_key_exists($locationField, $listingInfo)) { switch ($locationField) { case $property->id . '.Country': $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]); if (!$value) { $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]); } break; case $property->id . '.State': $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]); if (!$value) { $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]); } break; default: $value = $listingInfo[$locationField]; break; } $listingInfo[$property->id][str_replace($property->id . '.', '', $locationField)] = $value; $locationFieldAdded[] = str_replace($property->id . '.', '', $locationField); } } if ($property->id == 'Location') { $locationFields = array('Country', 'State', 'City', 'ZipCode'); foreach ($locationFields as $locationField) { if (array_key_exists($locationField, $listingInfo) && !in_array($locationField, $locationFieldAdded) && !$listing->getProperty($locationField)) { switch ($locationField) { case 'Country': $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]); if (!$value) { $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]); } break; case 'State': $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]); if (!$value) { $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]); } break; default: $value = $listingInfo[$locationField]; break; } $listingInfo[$property->id][$locationField] = $value; } } } } } $listing = $this->CreateListing($listingInfo, $listingTypeID); $pictures = array(); if (isset($listingInfo['pictures'])) { $listing->addPicturesProperty(); $explodedPictures = explode(';', $listingInfo['pictures']); foreach ($explodedPictures as $picture) { if (!empty($picture)) { $pictures[] = $picture; } } $listing->setPropertyValue('pictures', count($pictures)); } $listing->addActiveProperty($activeStatus); $listing->addActivationDateProperty($activationDate); $listing->addExpirationDateProperty($expirationDate); SJB_ListingDBManager::setListingExpirationDateBySid($listing->sid); $listing->setProductInfo(SJB_ProductsManager::getProductExtraInfoBySID($productSID)); $listing->setPropertyValue('access_type', 'everyone'); $listing->setPropertyValue('status', 'approved'); foreach ($listing->getProperties() as $property) { if ($property->getType() == 'tree' && $property->value !== '') { try { $treeImportHelper = new SJB_FieldTreeImportHelper($property->value); $treeValues = $treeImportHelper->parseAndGetValues(); $listing->setPropertyValue($property->id, $treeValues); $listing->details->properties[$property->id]->type->property_info['value'] = $treeValues; } catch (Exception $e) { $listing->setPropertyValue($property->id, ''); $listing->details->properties[$property->id]->type->property_info['value'] = ''; SJB_Error::writeToLog('Listing Import. Tree Field Value Error: ' . $e->getMessage()); } } elseif ($property->id == 'ApplicationSettings' && !empty($listingInfo['ApplicationSettings'])) { if (preg_match("^[a-z0-9\\._-]+@[a-z0-9\\._-]+\\.[a-z]{2,}\$^iu", $listingInfo['ApplicationSettings'])) { $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 1); } elseif (preg_match("^(https?:\\/\\/)^", $listingInfo['ApplicationSettings'])) { $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 2); } else { $listingInfo['ApplicationSettings'] = array('value' => '', 'add_parameter' => ''); } //put empty if not valid email or url $listing->details->properties[$property->id]->type->property_info['value'] = $listingInfo['ApplicationSettings']; } elseif ($property->getType() == 'complex') { $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid); $complexChildValues = $property->value; foreach ($childFields as $childField) { if ($childField['type'] == 'complexfile' && !empty($complexChildValues[$childField['id']])) { $fieldInfo = SJB_ListingComplexFieldManager::getFieldInfoBySID($childField['sid']); if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo, $property->id)) { $isFileImported = false; } } if ($property->type->complex->details->properties[$childField['id']]->value == null) { $property->type->complex->details->properties[$childField['id']]->value = array(1 => ''); $property->type->complex->details->properties[$childField['id']]->type->property_info['value'] = array(1 => ''); } } } // The import of files at import of listings if (in_array($property->getType(), array('file', 'logo', 'video')) && $property->value !== '') { $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($property->id); if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo)) { $isFileImported = false; } } } if ($non_existed_values_flag == 'add') { $this->UpdateListValues($listing); } if ($listing->getUserSID()) { SJB_ListingManager::saveListing($listing); $listingSid = $listing->getSID(); SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listingSid); SJB_ListingManager::activateListingBySID($listingSid, false); if (!$this->fillGallery($listingSid, $pictures)) { $isFileImported = false; } $addedListingsSids[] = $listingSid; } else { $nonExistentUsers[] = $listingInfo['username']; $count--; } } SJB_BrowseDBManager::addListings($addedListingsSids); SJB_ProductsManager::incrementPostingsNumber($productSID, count($addedListingsSids)); if ($isFileImported && file_exists(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY'))) { SJB_Filesystem::delete(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY')); } $tp->assign('imported_listings_count', $count); $tp->assign('nonExistentUsers', $nonExistentUsers); $tp->display('import_listings_result.tpl'); } }
public static function html2pdf($html, $filename, $footerText = false) { for ($i = 0; $i < ob_get_level(); $i++) { ob_end_clean(); } $pdf = new ExceptionThrowingTCPDF(); $pdf->SetCreator(PDF_CREATOR); $pdf->setPrintHeader(false); if ($footerText != false) { $pdf->footerText = $footerText; $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); } else { $pdf->setPrintFooter(false); } switch (SJB_I18N::getInstance()->getCurrentLanguage()) { case 'ja': $font = 'cid0jp'; break; case 'zh': $font = 'cid0cs'; break; case 'hi': $font = 'akshar'; break; case 'fr': case 'pt': $html = str_replace('à', 'à', $html); default: $font = 'dejavusans'; } $pdf->SetFont($font, '', 14, '', true); $pdf->AddPage(); $pdf->writeHTML($html, true, false, false, false, ''); $pdf->Output($filename, 'D'); }
public function execute() { $formToken = SJB_Request::getVar('form_token'); $tp = SJB_System::getTemplateProcessor(); $tp->assign('form_token', $formToken); $post_max_size_orig = ini_get('post_max_size'); $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null; // get post_max_size in bytes $val = trim($post_max_size_orig); $tmp = substr($val, strlen($val) - 1); $tmp = strtolower($tmp); switch ($tmp) { case 'g': $val *= 1024; break; case 'm': $val *= 1024; break; case 'k': $val *= 1024; break; } $post_max_size = $val; $errors = array(); if (SJB_Request::getVar('from-preview', false, 'POST') && !SJB_Request::getVar('action_add', false, 'POST')) { $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int'); $previewListingId = SJB_Session::getValue('preview_listing_sid'); if ($previewListingId && SJB_ListingManager::isListingExists($previewListingId)) { $listingId = $previewListingId; } } else { $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int'); } $template = SJB_Request::getVar('edit_template', 'edit_listing.tpl'); $filename = SJB_Request::getVar('filename', false); if ($filename) { SJB_UploadFileManager::openFile($filename, $listingId); // if file not found - set error here $errors['NO_SUCH_FILE'] = true; } if (empty($_POST) && $server_content_length > $post_max_size) { $errors['MAX_FILE_SIZE_EXCEEDED'] = 1; $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int'); $tp->assign('post_max_size', $post_max_size_orig); } $current_user = SJB_UserManager::getCurrentUser(); $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); // for listing preview $formSubmittedFromPreview = false; if (empty($listingInfo)) { $listingId = SJB_Session::getValue('preview_listing_sid'); $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId); if (!empty($listingInfo)) { // if on preview page 'POST' button was pressed $formSubmittedFromPreview = SJB_Request::getVar('action_add', false, 'POST') && SJB_Request::getVar('from-preview', false, 'POST'); if ($formSubmittedFromPreview) { $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']); $properties = $listing->getProperties(); foreach ($properties as $fieldID => $property) { switch ($property->getType()) { case 'date': if (!empty($listingInfo[$fieldID])) { $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]); } break; case 'complex': $complex = $property->type->complex; $complexProperties = $complex->getProperties(); foreach ($complexProperties as $complexfieldID => $complexProperty) { if ($complexProperty->getType() == 'date') { $values = $complexProperty->getValue(); foreach ($values as $index => $value) { if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) { $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]); } } } } break; } } } } else { $listingId = null; SJB_Session::unsetValue('preview_listing_sid'); } } // if preview button was pressed $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST'); if (SJB_UserManager::isUserLoggedIn()) { if ($listingInfo['user_sid'] != $current_user->getID()) { $errors['NOT_OWNER_OF_LISTING'] = $listingId; } elseif (!is_null($listingInfo)) { $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingInfo['listing_type_sid']); $form_is_submitted = SJB_Request::getVar('action', '') == 'save_info' || SJB_Request::getVar('action', '') == 'add' || $isPreviewListingRequested || $formSubmittedFromPreview; if (!$form_is_submitted && !SJB_Request::getVar('from-preview', false, 'POST')) { SJB_Session::unsetValue('previewListingId'); SJB_Session::unsetValue('preview_listing_sid_or'); } // fill listing from an array of social data if allowed $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']); $listingTypeID = $listing_type_info['id']; $aAutoFillData = array('formSubmitted' => $form_is_submitted, 'listingTypeID' => $listingTypeID); SJB_Event::dispatch('SocialSynchronization', $aAutoFillData); $listingInfo = array_merge($listingInfo, $_REQUEST); $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']); $listing->deleteProperty('ListingLogo'); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('status'); $list_emp_ids = SJB_Request::getVar('list_emp_ids'); $listing->setSID($listingId); $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($current_user->getSID()); if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) { $value = SJB_Request::getVar('screening_questionnaire'); $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : ''; $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($current_user->getSID()), 'is_system' => true)); } else { $listing->deleteProperty('screening_questionnaire'); } //--->CLT-2637 $properties = $listing->getProperties(); $listing_fields_by_page = array(); foreach ($pages as $page) { $listing_fields_by_page = array_merge(SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']), $listing_fields_by_page); } foreach ($properties as $property) { if (!in_array($property->getID(), array_keys($listing_fields_by_page))) { $listing->deleteProperty($property->getID()); } } //--->CLT-2637 // if user is not registered using linkedin , delete linkedin sync property, also if sync is turned off in admin part $aAutoFillData = array('oListing' => &$listing, 'userSID' => $current_user->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo); SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData); $listing_edit_form = new SJB_Form($listing); $listing_edit_form->registerTags($tp); $extraInfo = $listingInfo['product_info']; if ($extraInfo) { $extraInfo = unserialize($extraInfo); $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0; $listingSidForPictures = SJB_Session::getValue('preview_listing_sid_or') ? SJB_Session::getValue('preview_listing_sid_or') : $listingId; $tp->assign('pic_limit', $numberOfPictures); $tp->assign('listingSidForPictures', $listingSidForPictures); } if ($form_is_submitted) { $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true)); } $field_errors = array(); if ($form_is_submitted && ($formSubmittedFromPreview || $listing_edit_form->isDataValid($field_errors))) { $or_listing_id = SJB_Session::getValue('preview_listing_sid_or'); /* preview listing */ if ($isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') != $listing->getSID()) { SJB_Session::setValue('preview_listing_sid_or', $listing->getSID()); $listing->setSID(null); } elseif (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listing->getSID() && $or_listing_id && $or_listing_id != $listingId) { $listing->setSID($or_listing_id); } if ($isPreviewListingRequested) { $listing->addProperty(array('id' => 'preview', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } else { $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true)); } if ($isPreviewListingRequested) { $listing->product_info = $extraInfo; if (SJB_Session::getValue('previewListingId')) { $listing->setSID(SJB_Session::getValue('previewListingId')); } } else { SJB_BrowseDBManager::deleteListings($listing->getID()); } $listingSidsForCopy = array('filesFrom' => $listingId, 'picturesFrom' => $isPreviewListingRequested && (!$or_listing_id || $or_listing_id === $listingId) ? $listingId : null); SJB_ListingManager::saveListing($listing, $listingSidsForCopy); if (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listingId && $or_listing_id && $or_listing_id != $listingId) { SJB_Session::unsetValue('preview_listing_sid'); SJB_ListingManager::deleteListingBySID($listingId); } $listingInfo = SJB_ListingManager::getListingInfoBySID($listing->getSID()); if ($listingInfo['active']) { SJB_ListingManager::activateListingKeywordsBySID($listing->getSID()); SJB_BrowseDBManager::addListings($listing->getID()); } // >>> SJB-1197 // SET VALUES FROM TEMPORARY SESSION STORAGE $formToken = SJB_Request::getVar('form_token'); $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage'); $tempFieldsData = SJB_Array::getPath($sessionFileStorage, $formToken); if (is_array($tempFieldsData)) { foreach ($tempFieldsData as $fieldId => $fieldData) { $isComplex = false; if (strpos($fieldId, ':') !== false) { $isComplex = true; } $tmpUploadedFileId = $fieldData['file_id']; // rename it to real listing field value $newFileId = $fieldId . "_" . $listing->getSID(); SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId); if ($isComplex) { list($parentField, $subField, $complexStep) = explode(':', $fieldId); $parentProp = $listing->getProperty($parentField); $parentValue = $parentProp->getValue(); // look for complex property with current $fieldID and set it to new value of property if (!empty($parentValue)) { foreach ($parentValue as $id => $value) { if ($id == $subField) { $parentValue[$id][$complexStep] = $newFileId; } } $listing->setPropertyValue($parentField, $parentValue); } } else { $listing->setPropertyValue($fieldId, $newFileId); } } SJB_ListingManager::saveListing($listing); // recreate form object for saved listing // it fix display of complex file fields $listing = SJB_ListingManager::getObjectBySID($listing->getSID()); $listing->deleteProperty('featured'); $listing->deleteProperty('priority'); $listing->deleteProperty('reject_reason'); $listing->deleteProperty('status'); $listing_edit_form = new SJB_Form($listing); $listing_edit_form->registerTags($tp); } // <<< SJB-1197 if ($isPreviewListingRequested) { SJB_Session::setValue('previewListingId', $listing->getSID()); } /* preview listing */ if ($isPreviewListingRequested) { $listing->setUserSID($current_user->getSID()); SJB_Session::setValue('preview_listing_sid', $listing->getSID()); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/'); } else { /* normal */ $listingSid = $listing->getSID(); SJB_Event::dispatch('listingEdited', $listingSid); $tp->assign('display_preview', 1); SJB_Session::unsetValue('preview_listing_sid'); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-' . strtolower($listingTypeID) . '-details/' . $listing->getSID() . '/'); } } $listing->deleteProperty('access_list'); $tp->assign('form_is_submitted', $form_is_submitted); $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing); $form_fields = $listing_edit_form->getFormFieldsInfo(); $listing_fields_by_page = array(); foreach ($pages as $page) { $listing_fields_by_page[$page['page_name']] = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']); foreach (array_keys($listing_fields_by_page[$page['page_name']]) as $field) { if (!$listing->propertyIsSet($field)) { unset($listing_fields_by_page[$page['page_name']][$field]); } } } // delete sync fields from posting pages that are not in array $form_fields $aAutoFillData = array('listing_fields_by_page' => &$listing_fields_by_page, 'pages' => &$pages, 'form_fields' => $form_fields); SJB_Event::dispatch('SocialSynchronizationFieldsOnPostingPages', $aAutoFillData); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); if (!isset($listing_structure['access_type'])) { $listing_structure['access_type'] = 'everyone'; } $listing_access_list = SJB_ListingManager::getListingAccessList($listingId, $listing->getPropertyValue('access_type')); $tp->assign('contract_id', $listingInfo['contract_id']); $tp->assign('extraInfo', $extraInfo); $tp->assign('listing', $listing_structure); $tp->assign('pages', $listing_fields_by_page); $tp->assign('countPages', count($listing_fields_by_page)); $tp->assign('field_errors', $field_errors); $tp->assign('listing_access_list', $listing_access_list); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('expired', SJB_ListingManager::getIfListingHasExpiredBySID($listing->getSID())); // only for Resume listing types $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $current_user->getSID()); SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData); } } else { $errors['NOT_LOGGED_IN'] = 1; } $tp->assign('errors', $errors); $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $errors = array(); $info = ''; $to = SJB_Request::getVar('to', '', 'GET'); // POST and check for errors form_to form_subject form_message if (isset($_POST['act'])) { $to_user_name = SJB_Request::getVar('form_to', '', 'POST'); $to_user_info = null; if (intval($to_user_name)) { $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name); } // в функции compose private message функцию отправки // сообщения по имени пользователя оставить рабочей if (is_null($to_user_info)) { $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); } $cc = SJB_Request::getVar('cc', false); if ($cc !== false) { if (intval($cc)) { $cc_info = SJB_UserManager::getUserInfoBySID($cc); } // в функции compose private message функцию отправки // сообщения по имени пользователя оставить рабочей if (is_null($cc_info)) { $cc_info = SJB_UserManager::getUserInfoByUserName($cc); } if (!empty($cc_info)) { $cc = $cc_info['sid']; } } $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0; $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : ''; $message = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : ''; $save = isset($_POST['form_save']) ? $_POST['form_save'] == 1 ? true : false : false; if ($to_user == 0) { $errors['form_to'] = 'Please enter correct username'; } if (empty($subject)) { $errors['form_subject'] = 'Please, enter message subject'; } if (empty($message)) { $errors['form_message'] = 'Please, enter message'; } if (count($errors) == 0) { $anonym = SJB_Request::getVar('anonym'); SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $message, $save, false, $cc, $anonym); // save to contacts if (!$anonym) { SJB_PrivateMessage::saveContact($user_id, $to_user); SJB_PrivateMessage::saveContact($to_user, $user_id); } echo '<p class="message">' . SJB_I18N::getInstance()->gettext(null, 'The message was sent successfully') . '</p>'; exit; } } $display_to = ''; // get display name for 'Message to' field SJB_UserManager::getComposeDisplayName($to, $display_to); $tp->assign('errors', $errors); $tp->assign('info', $info); $tp->assign('to', $to); $tp->assign('display_to', $display_to); $tp->assign('anonym', SJB_Request::getVar('anonym')); $tp->assign('cc', SJB_Request::getVar('cc', '')); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('new_message_ajax.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $tp->assign('ajaxRelocate', true); $tp->display('../users/login.tpl'); } }
public static function displayBlogContent() { if (SJB_System::getSettingByName('display_blog_on_homepage') && SJB_System::getSettingByName('rss_url_for_wordpress') !== '') { $url = SJB_System::getSettingByName('rss_url_for_wordpress'); try { $feed = Zend_Feed::import($url); } catch (Exception $ex) { $feed = array(); } $i18n = SJB_I18N::getInstance(); $items = array(); foreach ($feed as $feedItem) { $date = new Zend_Date($feedItem->pubDate(), DATE_RSS, 'en_US'); $item = array('date' => $feedItem->pubDate() ? $i18n->getDate($date->toString()) : '', 'title' => $feedItem->title(), 'description' => $feedItem->description(), 'link' => $feedItem->link()); $items[] = $item; } return $items; } }
public function getTranslatedMessage($message, $param = '') { $message = SJB_I18N::getInstance()->gettext('Backend', $message); if (!empty($param)) { $message .= ' ' . $param; } return $message; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action', 'search'); $template = SJB_Request::getVar('template', 'listings_statistics.tpl'); $errors = array(); $userGroups = SJB_UserGroupManager::getAllUserGroupsIDsAndCaptions(); foreach ($userGroups as $key => $userGroup) { unset($userGroups[$key]); $userGroups[$userGroup['id']] = $userGroup; } switch ($action) { case 'export': $period = SJB_Request::getVar('period', array()); $filter = SJB_Request::getVar('filter', false); $listingTypeSID = SJB_Request::getVar('listingTypeSID', false); $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSID); $sorting_field = SJB_Request::getVar('sorting_field', 'total'); $sorting_order = SJB_Request::getVar('sorting_order', 'DESC'); $statistics = array(); if ($filter) { $statistics = SJB_Statistics::getListingsStatistics($period, $listingTypeSID, $filter, $sorting_field, $sorting_order); if (!empty($statistics['errors'])) { $errors = $statistics['errors']; } } else { $errors[] = 'EMPTY_PARAMETER'; } $columnTitle = ''; if (strstr($filter, 'userGroup_')) { $userGroupSID = str_replace('userGroup_', '', $filter); if ($userGroups[$userGroupSID]['key'] == 'Employer') { $columnTitle = 'Company Name'; } else { $columnTitle = $userGroups[$userGroupSID]['caption'] . ' Name'; } } else { $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($filter); $columnTitle = $fieldInfo['caption']; } if (!$errors && $statistics) { $type = SJB_Request::getVar('type', 'csv'); $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType(); SJB_StatisticsExportController::createExportDirectory(); $exportProperties['title'] = $columnTitle; $exportProperties['regular'] = ''; if ($listingTypeID == 'Job') { $exportProperties['featured'] = ''; } $exportProperties['priority'] = ''; $exportProperties['total'] = 'Total'; $exportProperties['percent'] = '%'; foreach ($listingTypes as $listingType) { if ($listingType['id'] == $listingTypeSID) { switch ($listingType['key']) { case 'Job': $featuredTitle = "Number of Featured {$listingType['key']}s Posted"; $exportProperties['featured'] = $featuredTitle; case 'Resume': $regularTitle = "Number of Regular {$listingType['key']}s Posted"; $exportProperties['regular'] = $regularTitle; $priorityTitle = "Number of Priority {$listingType['key']}s Posted"; $exportProperties['priority'] = $priorityTitle; break; default: $regularTitle = 'Number of Regular "' . $listingType['caption'] . '" Listings Posted'; $exportProperties['regular'] = $regularTitle; $priorityTitle = 'Number of Priority "' . $listingType['caption'] . '" Listings Posted'; $exportProperties['priority'] = $priorityTitle; break; } } } switch ($type) { case 'csv': $exportData = SJB_StatisticsExportController::getListingExportData($statistics, $listingTypeID); $fileName = strtolower($listingTypeID) . '_statistics.csv'; SJB_StatisticsExportController::makeCSVExportFile($exportData, $fileName, "{$listingTypeID} Statistics"); SJB_StatisticsExportController::archiveAndSendExportFile(strtolower($listingTypeID) . '_statistics', 'csv'); break; case 'xls': $exportData = SJB_StatisticsExportController::getListingExportData($statistics, $listingTypeID); $fileName = strtolower($listingTypeID) . '_statistics.xls'; SJB_StatisticsExportController::makeXLSExportFile($exportData, $fileName, "{$listingTypeID} Statistics"); SJB_StatisticsExportController::archiveAndSendExportFile(strtolower($listingTypeID) . '_statistics', 'xls'); break; } break; } case 'search': $search = SJB_Request::getVar('search', false); $period = SJB_Request::getVar('period', array()); $filter = SJB_Request::getVar('filter', false); $listingTypeSID = SJB_Request::getVar('listingTypeSID', false); $sorting_field = SJB_Request::getVar('sorting_field', 'total'); $sorting_order = SJB_Request::getVar('sorting_order', 'DESC'); $statistics = array(); if ($search) { $i18n = SJB_I18N::getInstance(); $from = $i18n->getInput('date', $period['from']); $to = $i18n->getInput('date', $period['to']); if (!empty($period['from']) && !empty($period['to']) && strtotime($from) > strtotime($to)) { $errors[] = 'SELECTED_PERIOD_IS_INCORRECT'; } else { if ($filter) { $statistics = SJB_Statistics::getListingsStatistics($period, $listingTypeSID, $filter, $sorting_field, $sorting_order); if (!empty($statistics['errors'])) { $errors = $statistics['errors']; } } else { $errors[] = 'EMPTY_PARAMETER'; } } } $columnTitle = ''; if (strstr($filter, 'userGroup_')) { $userGroupSID = str_replace('userGroup_', '', $filter); if ($userGroups[$userGroupSID]['key'] == 'Employer') { $columnTitle = 'Company Name'; } else { $columnTitle = $userGroups[$userGroupSID]['caption'] . ' Name'; } $tp->assign('link', 'user'); } else { if (in_array($filter, array('Location_Country', 'Location_State', 'Location_City'))) { $fieldInfo = SJB_ListingFieldDBManager::getLocationFieldsInfoById($filter); } else { $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($filter); } $columnTitle = $fieldInfo['caption']; } $i18n = SJB_I18N::getInstance(); $periodView = array(); foreach ($period as $key => $value) { $periodView[$key] = $i18n->getInput('date', $period[$key]); } $tp->assign('filter', $filter); $tp->assign('search', $search); $tp->assign('columnTitle', $columnTitle); $tp->assign('listingTypeSID', $listingTypeSID); $tp->assign('period', $period); $tp->assign('periodView', $periodView); $tp->assign('statistics', $statistics); $tp->assign('countResult', count($statistics)); $tp->assign('sorting_field', $sorting_field); $tp->assign('sorting_order', $sorting_order); break; } $listingTypes = SJB_ListingTypeManager::getListingAllTypesForListType(); $products = SJB_ProductsManager::getAllProductsInfo(); $acl = SJB_Acl::getInstance(); foreach ($listingTypes as $key => $listingType) { $userGroup = array(); foreach ($products as $productInfo) { if ($acl->isAllowed('post_' . strtolower($listingType['key']), $productInfo['sid'], 'product') && !in_array($productInfo['user_group_sid'], $userGroup)) { $userGroup[] = $productInfo['user_group_sid']; } } $listingTypes[$listingType['id']] = $listingType; $listingTypes[$listingType['id']]['userGroups'] = $userGroup; unset($listingTypes[$key]); } $tp->assign('userGroups', $userGroups); $tp->assign('listingTypes', $listingTypes); $tp->assign('errors', $errors); $tp->assign('action', $action); $tp->display($template); }
public static function getCaptchaProperties($properties) { $captcha_type = SJB_Settings::getSettingByName('captcha_type'); switch ($captcha_type) { case 'reCaptcha': $reCaptchaPubkey = SJB_Settings::getSettingByName('reCaptchaPubkey'); $reCaptchaPrivkey = SJB_Settings::getSettingByName('reCaptchaPrivkey'); if ($reCaptchaPubkey && $reCaptchaPrivkey) { $i18n = SJB_I18N::getInstance(); $lang = $i18n->getCurrentLanguage(); $theme = SJB_Settings::getSettingByName('reCaptchaTheme'); $theme = $theme ? $theme : 'white'; $reCaptcha = new SJB_ReCaptcha(); $reCaptcha->setPubkey($reCaptchaPubkey); $reCaptcha->setPrivkey($reCaptchaPrivkey); $reCaptcha->setOption('lang', $lang); $reCaptcha->setOption('theme', $theme); $reCaptchaView = $reCaptcha->render(null, null, $properties['windowType']); $properties['type'] = 'reCaptcha'; $properties['captchaView'] = $reCaptchaView; } break; case 'customCaptcha': $customCaptcha = new SJB_CustomCaptcha(); $fonts = self::getFonts(); $font = SJB_Settings::getSettingByName('custCaptchaFont') ? SJB_Settings::getSettingByName('custCaptchaFont') : 'arial'; $fontSize = SJB_Settings::getSettingByName('custCaptchaFontSize') ? SJB_Settings::getSettingByName('custCaptchaFontSize') : 36; $width = SJB_Settings::getSettingByName('custCaptchaWidth') ? SJB_Settings::getSettingByName('custCaptchaWidth') : 200; $height = SJB_Settings::getSettingByName('custCaptchaHeight') ? SJB_Settings::getSettingByName('custCaptchaHeight') : 100; $wordlen = SJB_Settings::getSettingByName('custCaptchaWordlen') ? SJB_Settings::getSettingByName('custCaptchaWordlen') : 5; $dotNoise = SJB_Settings::getSettingByName('custDotNoiseLevel') ? SJB_Settings::getSettingByName('custDotNoiseLevel') : 100; $lineNoise = SJB_Settings::getSettingByName('custLineNoiseLevel') ? SJB_Settings::getSettingByName('custLineNoiseLevel') : 5; $customCaptcha->setFont(SJB_BASE_DIR . "system/plugins/captcha/fonts/" . $fonts[$font]); $customCaptcha->setFontSize($fontSize); $customCaptcha->setImgDir(SJB_BASE_DIR . 'system/cache/captcha/'); $customCaptcha->setImgUrl(str_replace('admin', '', SJB_System::getSystemSettings('SITE_URL')) . '/system/cache/captcha/'); $customCaptcha->setWidth($width); $customCaptcha->setHeight($height); $customCaptcha->setWordlen($wordlen); $customCaptcha->setDotNoiseLevel($dotNoise); $customCaptcha->setLineNoiseLevel($lineNoise); $customCaptcha->setKeepSession(true); $customCaptcha->generate(); $customCaptchaView = $customCaptcha->render(); $properties['type'] = 'customCaptcha'; $properties['captchaView'] = $customCaptchaView; $properties['id'] = $customCaptcha->getId(); break; } return $properties; }
public function execute() { $bannersObj = new SJB_Banners(); $params = $_REQUEST; $bannerId = $params['bannerId']; if (SJB_Request::isAjax()) { $response = array('success' => $bannersObj->deleteBannerImage($bannerId), 'error' => SJB_I18N::getInstance()->gettext('Backend', $bannersObj->bannersError)); die(json_encode($response)); } $tp = SJB_System::getTemplateProcessor(); $errors = array(); $banner = array_merge($bannersObj->getBannerProperties($bannerId), $params); $form_submitted = SJB_Request::getVar('submit'); $filesDir = SJB_System::getSystemSettings('FILES_DIR'); if (isset($_REQUEST['action'])) { $action_name = $_REQUEST['action']; switch ($action_name) { case 'edit': // ERRORS if ($params['title'] == '') { $errors[] = 'Banner Title is empty.'; } if ($params['link'] == '' && $params['bannerType'] != 'code') { $errors[] = 'Banner link mismatched!'; } if ($params['bannerType'] == 'code' && $params['code'] == '') { $errors[] = 'Banner code is empty.'; } if ($params['bannerType'] == 'file' && $_FILES['image']['name'] == '' && empty($params['imagePath'])) { $errors[] = 'No image attached!'; } if ($_FILES['image']['name'] && $_FILES['image']['error']) { $errors[SJB_UploadFileManager::getErrorId($_FILES['image']['error'])] = 1; } if ($errors) { break; } // if image changed - save it if ($_FILES['image']['name'] != '' && $_FILES['image']['tmp_name'] != '') { $hashName = md5(time() * $_FILES['image']['size'] . "_" . $_FILES['image']['name']); $ext = preg_match("|\\.(\\w{3})\\b|", $_FILES['image']['name'], $arr); $bannerFilePath = $filesDir . "banners/" . $hashName . "." . $arr[1]; // move file from temporary folder, and fill banner info to DB $copy = copy($_FILES['image']['tmp_name'], $bannerFilePath); if (!$copy) { $errors = 'Cannot copy file from TMP dir to Banners Dir'; break; } if ($_FILES['image']['type'] != 'application/x-shockwave-flash') { // array of bannerInfo // [0] - width // [1] - height // [2] - ?? // [3] - width & height in next view: width="104" height="150" // [bits] - bit size of image // [channels] // [mime] - type, (image/jpeg, image/gif, image/png ) $bannerInfo = getimagesize($bannerFilePath); if ($params['width'] != '' && $params['height'] != '') { $sx = $params['width']; $sy = $params['height']; } else { $sx = $bannerInfo[0]; $sy = $bannerInfo[1]; } $type = $bannerInfo['mime']; } else { if ($params['width'] == '' || $params['height'] == '') { $errors[] = 'SIZE_PARAMETER_MISMATCHED'; break; } $sx = $params['width']; $sy = $params['height']; $type = $_FILES['image']['type']; } $bannerFilePath = "/" . str_replace("../", "/", str_replace(SJB_BASE_DIR, '', $bannerFilePath)); // now delete old banner image $bannersObj->deleteBannerImage($bannerId); } else { // if image not changed - leave it as is $bannerOldInfo = $bannersObj->getBannerProperties($params['bannerId']); $sx = $bannerOldInfo['width']; $sy = $bannerOldInfo['height']; if ($params['width'] != '' && $params['height'] != '') { if ($params['width'] != $sx || $params['height'] != $sy) { $sx = $params['width']; $sy = $params['height']; } } $type = $bannerOldInfo['type']; $bannerFilePath = $bannerOldInfo['image_path']; } $title = $params['title']; $link = $params['link']; $active = $params['active']; $group = $params['groupSID']; // check 'link' for correct. If it hasn't 'http://' or 'https://' - add them $expr = preg_match("/^(https?:\\/\\/)/", $link); if ($expr != true && $params['bannerType'] != 'code') { $link = "http://" . $link; } if ($params['bannerType'] == 'code') { $bannersObj->deleteBannerImage($bannerId); } $result = $bannersObj->updateBanner($params['bannerId'], $title, $link, $bannerFilePath, $sx, $sy, $type, $active, $group, $params); if ($form_submitted == 'save_banner') { $site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner-group/?groupSID={$group}"; } else { $site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner/?bannerId=" . $bannerId; } SJB_HelperFunctions::redirect($site_url); break; } } $banner_fields = $bannersObj->getBannersMeta(); $tp->assign("banner_fields", $banner_fields); $tp->assign("banner", $banner); $tp->assign('errors', $errors); $tp->assign('bannersPath', SJB_Banners::getSiteUrl()); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display("edit_banner.tpl"); }
public function execute() { $errors = array(); $field_errors = array(); $tp = SJB_System::getTemplateProcessor(); $loggedIn = SJB_UserManager::isUserLoggedIn(); $current_user_sid = SJB_UserManager::getCurrentUserSID(); $controller = new SJB_SendListingInfoController($_REQUEST); $isDataSubmitted = false; $jobInfo = SJB_ListingManager::getListingInfoBySID($controller->getListingID()); if ($controller->isListingSpecified()) { if ($controller->isDataSubmitted()) { if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors)) { // получим уникальный id для файла в uploaded_files $file_id_current = 'application_' . md5(microtime()); $upload_manager = new SJB_UploadFileManager(); $upload_manager->setFileGroup('files'); $upload_manager->setUploadedFileID($file_id_current); $file_name = $upload_manager->uploadFile('file_tmp'); $id_file = $upload_manager->fileId; $post = $controller->getData(); $listingId = 0; $post['submitted_data']['questionnaire'] = ''; if (isset($post['submitted_data']['id_resume'])) { $listingId = $post['submitted_data']['id_resume']; } $mimeType = isset($_FILES['file_tmp']['type']) ? $_FILES['file_tmp']['type'] : ''; if (isset($_FILES['file_tmp']['size']) && $file_name != '' && $_FILES['file_tmp']['size'] == 0) { $errors['FILE_IS_EMPTY'] = 'The uploaded file should not be blank'; } if (!empty($_FILES['file_tmp']['name'])) { $fileFormats = explode(',', SJB_System::getSettingByName('file_valid_types')); $fileInfo = pathinfo($_FILES['file_tmp']['name']); if (!isset($fileInfo['extension']) || !in_array(strtolower($fileInfo['extension']), $fileFormats)) { $errors['NOT_SUPPORTED_FILE_FORMAT'] = strtolower($fileInfo['extension']) . ' ' . SJB_I18N::getInstance()->gettext(null, 'is not in an acceptable file format'); } } if ($file_name == '' && $listingId == 0) { $canAppplyWithoutResume = false; SJB_Event::dispatch('CanApplyWithoutResume', $canAppplyWithoutResume); if (!$canAppplyWithoutResume) { $errors['APPLY_INPUT_ERROR'] = 'Please select file or resume'; } } else { if (SJB_Applications::isApplied($post['submitted_data']['listing_id'], $current_user_sid) && !is_null($current_user_sid)) { $errors['APPLY_APPLIED_ERROR'] = 'You already applied'; } } $res = false; $listing_info = ''; $notRegisterUserData = $_POST; $score = 0; // для зарегестрированного пользователя получим поля email и name // для незарегестрированных - поля name и email приходят с формы if ($loggedIn === true) { $userData = SJB_UserManager::getCurrentUserInfo(); $post['submitted_data']['username'] = isset($userData['username']) ? $userData['username'] : ''; $post['submitted_data']['LastName'] = isset($userData['LastName']) ? $userData['LastName'] : ''; $post['submitted_data']['FirstName'] = isset($userData['FirstName']) ? $userData['FirstName'] : ''; $post['submitted_data']['name'] = $post['submitted_data']['FirstName'] . ' ' . $post['submitted_data']['LastName']; $post['submitted_data']['email'] = $userData['email']; } if (!empty($jobInfo['screening_questionnaire'])) { $questions = new SJB_Questions($_REQUEST, $jobInfo['screening_questionnaire']); $add_form = new SJB_Form($questions); $add_form->registerTags($tp); $add_form->isDataValid($field_errors); $tp->assign('field_errors', $field_errors); if (!$field_errors) { $result = array(); $properties = $questions->getProperties(); $countAnswers = 0; foreach ($properties as $key => $val) { if ($val->type->property_info['type'] == 'boolean') { switch ($val->value) { case 0: $val->value = 'No'; break; case 1: $val->value = 'Yes'; break; } } $result[$val->caption] = $val->value; if (isset($val->type->property_info['list_values'])) { foreach ($val->type->property_info['list_values'] as $list_values) { if (is_array($val->value)) { foreach ($val->value as $value) { if ($value == $list_values['id'] && $list_values['score'] != 'no') { $score += $list_values['score']; $countAnswers++; } } } else { if ($val->value == $list_values['id'] && $list_values['score'] != 'no') { $score += $list_values['score']; $countAnswers++; } } } } } if ($countAnswers === 0) { $score = 0.0; } else { $score = round($score / $countAnswers, 2); } $post['submitted_data']['questionnaire'] = serialize($result); } } if (count($errors) == 0 && count($field_errors) == 0) { $res = SJB_Applications::create($post['submitted_data']['listing_id'], $current_user_sid, isset($post['submitted_data']['id_resume']) ? $post['submitted_data']['id_resume'] : '', $post['submitted_data']['comments'], $file_name, $mimeType, $id_file, isset($post['submitted_data']['anonymous']) ? $post['submitted_data']['anonymous'] : '0', $notRegisterUserData, $post['submitted_data']['questionnaire'], $score); if ($res) { SJB_Statistics::addStatistics('apply', $post['submitted_data']['listing_id'], $res); } if (isset($post['submitted_data']['id_resume']) && $post['submitted_data']['id_resume'] != 0) { $listing_info = SJB_ListingManager::getListingInfoBySID($post['submitted_data']['id_resume']); $emp_sid = SJB_ListingManager::getUserSIDByListingSID($post['submitted_data']['listing_id']); $accessible = SJB_ListingManager::isListingAccessableByUser($post['submitted_data']['id_resume'], $emp_sid); if (!$accessible) { SJB_ListingManager::setListingAccessibleToUser($post['submitted_data']['id_resume'], $emp_sid); } } if (!empty($file_name)) { $file_name = 'files/files/' . $file_name; } SJB_Notifications::sendApplyNow($post, $file_name, $listing_info, $current_user_sid, $notRegisterUserData, $score); if (!empty($jobInfo['screening_questionnaire'])) { $questionnaire = SJB_ScreeningQuestionnaires::getInfoBySID($jobInfo['screening_questionnaire']); if ($questionnaire) { $passing_score = 0; switch ($questionnaire['passing_score']) { case 'acceptable': $passing_score = 1; break; case 'good': $passing_score = 2; break; case 'very_good': $passing_score = 3; break; case 'excellent': $passing_score = 4; break; } } if ($score >= $passing_score && $questionnaire['send_auto_reply_more'] == 1) { if (!empty($questionnaire['email_text_more'])) { SJB_Notifications::userAutoReply($jobInfo, $current_user_sid, $questionnaire['email_text_more'], $notRegisterUserData); } } elseif ($score < $passing_score && $questionnaire['send_auto_reply_less'] == 1) { if (!empty($questionnaire['email_text_less'])) { SJB_Notifications::userAutoReply($jobInfo, $current_user_sid, $questionnaire['email_text_less'], $notRegisterUserData); } } } } if ($res === false) { $errors['APPLY_ERROR'] = 'Cannot apply'; } $isDataSubmitted = true; } } if (!empty($jobInfo['screening_questionnaire'])) { $questions = new SJB_Questions($_REQUEST, $jobInfo['screening_questionnaire']); $add_form = new SJB_Form($questions); $add_form->registerTags($tp); $form_fields = $add_form->getFormFieldsInfo(); $tp->assign('form_fields', $form_fields); $tp->assign('questionsObject', $questions); } if ($loggedIn) { $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID('Resume'); $wait_approve = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid); $approve_status = ''; if ($wait_approve) { $approve_status = "AND `l`.`status` = 'approved'"; } $result = SJB_DB::query("SELECT `l`.`sid` , `l`.`Title` FROM `listings` as `l`\n\t\t\t\tLEFT JOIN `listing_types` as `lt` ON (`lt`.`sid` = `l`.`listing_type_sid`)\n\t\t\t\tWHERE `lt`.`id` = 'Resume' {$approve_status} AND `l`.`user_sid` = {$current_user_sid} AND `l`.`active`"); $resume = array(); foreach ($result as $val) { $resume[$val['sid']] = $val['Title']; } $tp->assign('resume', $resume); } $tp->assign('listing', $jobInfo); } else { $errors['UNDEFINED_LISTING_ID'] = true; } $tp->assign('request', $_REQUEST); $tp->assign('errors', $errors); $tp->assign('listing_id', $controller->getListingID()); $tp->assign('is_data_submitted', $isDataSubmitted); $tp->display('apply_now.tpl'); }
private function getSortedResults($values) { if (!empty($values)) { $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($this->field['sid']); if (SJB_Array::get($fieldInfo, 'sort_by_alphabet') > 0) { $i18n = SJB_I18N::getInstance(); $parents = array(); // in this place we have 'caption' with ids of children items, like '300,301,302,305' etc. // need to get real caption value (for children and parent) and sort by it foreach ($values as $parent => $items) { if (!is_array($items)) { $items = array(); } $sids = array_keys($items); $parentSid = SJB_ListingFieldTreeManager::getParentSID($parent); $parentInfo = SJB_ListingFieldTreeManager::getTreeItemInfoBySID($parentSid); $parents[] = $i18n->gettext('', $parentInfo['caption']); // sort children by alphabet $children = array(); foreach ($sids as $sid) { $info = SJB_ListingFieldTreeManager::getTreeItemInfoBySID($sid); $children[] = $i18n->gettext('', $info['caption']); } array_multisort($children, SORT_STRING, $sids); $sids = array_fill_keys($sids, 1); // set to sorted sids $values[$parent] = $sids; } // sort parent by alphabet $keys = array_keys($values); array_multisort($parents, SORT_ASC, SORT_STRING, $keys, $values); $values = array_combine($keys, $values); } } return $values; }