public function execute() { $tp = SJB_System::getTemplateProcessor(); $listingSID = SJB_Request::getVar('listing_id'); $template = 'flag_listing.tpl'; $errors = array(); if ($listingSID) { // Flag listing $reason = SJB_Request::getVar('reason'); $comment = SJB_Request::getVar('comment'); $formSubmitted = SJB_Request::getVar('action'); if ($formSubmitted) { SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors); } $listing = SJB_ListingManager::getObjectBySID($listingSID); if (!empty($listing)) { $listingInfo = SJB_ListingManager::createTemplateStructureForListing($listing); } else { $errors['WRONG_LISTING_ID_SPECIFIED'] = 'Listing does not exist'; } if ($formSubmitted == 'flag' && empty($errors)) { SJB_ListingManager::flagListingBySID($listingSID, $reason, $comment); // notify admin SJB_AdminNotifications::sendAdminListingFlaggedLetter($listing); $template = 'flag_listing_sended.tpl'; } elseif (!empty($listing)) { // Show form to reason $reasons = array(); if (is_numeric($listingSID) && is_numeric($listing->getListingTypeSID())) { $reasons = SJB_DB::query("SELECT * FROM `flag_listing_settings` WHERE FIND_IN_SET(?n, `listing_type_sid`)", $listing->getListingTypeSID()); } $tp->assign('flag_types', $reasons); } $tp->assign('listing_id', $listingSID); if (!empty($listingInfo)) { $tp->assign('listing_type_id', strtolower($listingInfo['type']['id'])); } if (!empty($errors)) { $tp->assign('errors', $errors); $tp->assign('reason', $reason); $tp->assign('comment', $comment); } } $tp->display($template); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $contact_form = SJB_ObjectMother::createContactForm(); $contact_form->parseRequestedData($_REQUEST); if ($contact_form->isFormSubmitted()) { $errors = !$contact_form->isDataValid() ? $contact_form->getFieldErrors() : array(); SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors); if (!$errors) { $contact_form->sendMessage(); $tp->assign('message_sent', true); } else { $tp->assign('field_errors', $errors); } } $contact_form->assignTemplateVariables($tp); $tp->display('contact_form.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $fatal_errors = array(); $isDataSubmitted = false; try { $controller = new SJB_SendListingInfoController($_REQUEST); } catch (Exception $e) { $controller = false; } if (empty($controller)) { $fatal_errors['LISTING_ID_IS_NOT_NUMERIC'] = $e->getMessage(); } elseif ($controller->isListingSpecified()) { if ($controller->isDataSubmitted()) { SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors); if (!preg_match('^[a-zA-Z0-9\\._-]+@[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,}$^', $_REQUEST['friend_email'])) { $errors['NOT_VALID_EMAIL_FORMAT'] = true; } if (empty($errors)) { $data_to_send = $controller->getData(); if (!SJB_Notifications::sendTellFriendLetter($data_to_send)) { $errors['SEND_ERROR'] = true; } $isDataSubmitted = true; } } $tp->assign('listing_info', SJB_ListingManager::createTemplateStructureForListing(SJB_ListingManager::getObjectBySID($controller->getListingID()))); } else { $fatal_errors['UNDEFINED_LISTING_ID'] = true; } $tp->assign('fatal_errors', $fatal_errors); $tp->assign('errors', $errors); $tp->assign('info', SJB_Request::get()); $tp->assign('is_data_submitted', $isDataSubmitted); $tp->display('tell_friend.tpl'); }
/** * authorizing administrator * * Function checks if there's active administrator. * If it is, then it return true. If it's not it outputs * form for logging into system untill administrator logins system * * @return bool 'true' administrator has authorized or 'false' otherwise */ public static function admin_auth() { $error = array(); $tp = SJB_System::getTemplateProcessor(); $params = SJB_HelperFunctions::form(array('action' => 'login') + SJB_HelperFunctions::get_request_data_params()); if (SJB_Request::getVar('action') == 'login') { if (!SJB_Admin::isAdminExist(SJB_Request::getVar('username', ''), SJB_Request::getVar('password')) && !SJB_SubAdmin::isSubAdminExist()) { if (is_null(SJB_Session::getValue('adminLoginCounter'))) { SJB_Session::setValue('adminLoginCounter', 1); } else { SJB_Session::setValue('adminLoginCounter', SJB_Session::getValue('adminLoginCounter') + 1); } $error['LOGIN_PASS_NOT_CORRECT'] = true; } if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($error) && empty($error)) { return SJB_SubAdmin::isSubAdminExist() ? SJB_SubAdmin::admin_auth() : SJB_Admin::admin_login(SJB_Request::getVar('username', '')); } } header('Content-type: text/html;charset=utf-8', true); $tp->assign('form_hidden_params', $params); $tp->assign('ERROR', $error); $tp->display('auth.tpl'); return false; }
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'); }
public function execute() { $logged_in = false; $tp = SJB_System::getTemplateProcessor(); $shoppingCart = SJB_Request::getVar('shopping_cart', false); $proceedToPosting = SJB_Request::getVar('proceed_to_posting', false); $productSID = SJB_Request::getVar('productSID', false); $listingTypeID = SJB_Request::getVar('listing_type_id', false); $errors = array(); if (SJB_Authorization::isUserLoggedIn() && !isset($_REQUEST['as_user'])) { $tp->display('already_logged_in.tpl'); } else { $template = SJB_Request::getVar('template', 'login.tpl'); $page_config = SJB_System::getPageConfig(SJB_System::getURI()); if (SJB_Request::getVar('action', false) == 'login') { $username = SJB_Request::getVar('username'); $password = SJB_Request::getVar('password'); $keep_signed = SJB_Request::getVar('keep', false); $login_as_user = false; if (isset($_REQUEST['as_user'])) { $login_as_user = true; if (SJB_UserManager::getCurrentUserSID()) { SJB_Authorization::logout(); } } // redirect user to the home page if it's login page or to the same page otherwise if (SJB_Request::getVar('return_url', false) != false) { $redirect_url = base64_decode(SJB_Request::getVar('return_url')); if (!empty($proceedToPosting)) { $redirect_url .= '&proceed_to_posting=1&productSID=' . $productSID; } } else { if ($page_config->module == 'users' && $page_config->function == 'login') { $redirect_url = SJB_System::getSystemSettings("SITE_URL") . "/my-account/"; } else { $redirect_url = SJB_System::getSystemSettings("SITE_URL") . SJB_System::getURI(); } } if (SJB_UserManager::getCurrentUserSID()) { $logged_in = true; } else { SJB_UserManager::login($username, $password, $errors, false, $login_as_user); if ($errors) { if (is_null(SJB_Session::getValue('userLoginCounter'))) { SJB_Session::setValue('userLoginCounter', 1); } else { SJB_Session::setValue('userLoginCounter', SJB_Session::getValue('userLoginCounter') + 1); } } if (SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors) && empty($errors)) { $logged_in = SJB_Authorization::login($username, $password, $keep_signed, $errors, $login_as_user); } } if ($logged_in && !$shoppingCart) { SJB_HelperFunctions::redirect($redirect_url); } $tp->assign('logged_in', $logged_in); } $return_url = SJB_Request::getVar('return_url', $page_config->function != 'login' && $page_config->function != 'search_form' ? base64_encode(SJB_Navigator::getURIThis()) : false); if (!filter_var(SJB_System::getSystemSettings("SITE_URL") . base64_decode($return_url), FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) { $return_url = ''; } $tp->assign('shopping_cart', $shoppingCart); $tp->assign('proceedToPosting', $proceedToPosting); $tp->assign('productSID', $productSID); $tp->assign('listingTypeID', $listingTypeID); $tp->assign('return_url', $return_url); $tp->assign('ajaxRelocate', SJB_Request::getVar('ajaxRelocate', false)); $tp->assign('errors', $errors); $tp->assign('adminEmail', SJB_System::getSettingByName('system_email')); $tp->display($template); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); SJB_Captcha::getInstance($tp)->display(); }