Example #1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $isFormSubmitted = SJB_Request::getVar('action');
     $guestAlert = new SJB_GuestAlert($_REQUEST);
     $form = new SJB_Form($guestAlert);
     $form->registerTags($tp);
     $errors = array();
     if ($isFormSubmitted && $form->isDataValid($errors)) {
         $this->saveNewGuestAlert($guestAlert, $tp);
     } else {
         $form_fields = $form->getFormFieldsInfo();
         $tp->assign('form_fields', $form_fields);
         $tp->assign('searchId', $this->searchID);
         if ($this->isDuplicateEmailError($errors)) {
             $email = $guestAlert->getAlertEmail();
             $unSubscribedGuestAlertSID = SJB_GuestAlertManager::isGuestAlertUnSubscribedByEmail($email);
             if ($unSubscribedGuestAlertSID > 0) {
                 SJB_GuestAlertManager::deleteGuestAlertBySID($unSubscribedGuestAlertSID);
                 $this->saveNewGuestAlert($guestAlert, $tp);
             } else {
                 $this->template = 'replace.tpl';
             }
         } else {
             $tp->assign('errors', $errors);
             $this->template = 'create.tpl';
         }
     }
     $tp->display($this->template);
 }
Example #2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $user = SJB_UserManager::getCurrentUser();
     if ($user) {
         $userNotificationsManager = new SJB_UserNotificationsManager($user);
         $userNotificationsInfo = $userNotificationsManager->getUserNotificationsInfo();
         $userNotificationsInfo = array_merge($userNotificationsInfo, $_REQUEST);
         $userNotifications = new SJB_UserNotifications($userNotificationsInfo);
         $userNotificationsForm = new SJB_Form($userNotifications);
         $userNotificationsForm->registerTags($tp);
         $userNotificationsFields = $userNotificationsForm->getFormFieldsInfo();
         $tp->assign('form_fields', $userNotificationsFields);
         if (SJB_Request::getVar('action') === 'save') {
             $errors = array();
             if ($userNotificationsForm->isDataValid($errors)) {
                 $userNotifications->update();
                 $tp->assign('isSaved', true);
             }
             $tp->assign('errors', $errors);
         }
         $tp->assign('userNotificationGroups', $userNotificationsManager->getNotificationGroups()->getGroups());
         $tp->assign('userNotifications', $userNotificationsManager->getEnabledForGroupUserNotifications());
         $listingTypes = SJB_ListingTypeManager::getListingTypeByUserSID($user->getSID());
         $approveSetting = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listingTypes);
         $tp->assign('approve_setting', $approveSetting);
         $tp->display('user_notifications.tpl');
     } else {
         $tp->display('login.tpl');
     }
 }
 public function execute()
 {
     $user_group_sid = isset($_REQUEST['user_group_sid']) ? $_REQUEST['user_group_sid'] : null;
     $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
     $user_profile_field = new SJB_UserProfileField($_REQUEST);
     $user_profile_field->setUserGroupSID($user_group_sid);
     //infill instructions field
     //$user_profile_field->addInfillInstructions(SJB_Request::getVar('instructions'));
     $add_user_profile_field_form = new SJB_Form($user_profile_field);
     $form_is_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'add';
     $errors = null;
     if ($form_is_submitted && $add_user_profile_field_form->isDataValid($errors)) {
         SJB_UserProfileFieldManager::saveUserProfileField($user_profile_field);
         if (SJB_Request::getVar('type', '') == 'youtube') {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/instruction_user_profile_field/?user_group_sid=" . $user_group_sid . "&user_field_sid=" . $user_profile_field->sid);
         } else {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/edit-user-profile/?user_group_sid=" . $user_group_sid);
         }
     } else {
         $template_processor = SJB_System::getTemplateProcessor();
         $add_user_profile_field_form->registerTags($template_processor);
         $template_processor->assign("form_fields", $add_user_profile_field_form->getFormFieldsInfo());
         $template_processor->assign("user_group_sid", $user_group_sid);
         $template_processor->assign("errors", $errors);
         $template_processor->assign("user_group_info", $user_group_info);
         $template_processor->display("add_user_profile_field.tpl");
     }
 }
Example #4
0
 public function execute()
 {
     $user_group = new SJB_UserGroup($_REQUEST);
     $add_user_group_form = new SJB_Form($user_group);
     $form_is_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'add';
     $errors = null;
     $tp = SJB_System::getTemplateProcessor();
     if ($form_is_submitted && $add_user_group_form->isDataValid($errors)) {
         SJB_UserGroupManager::saveUserGroup($user_group);
         $page = array('uri' => '/' . mb_strtolower($user_group->getPropertyValue('id'), 'UTF-8') . '-products/', 'module' => 'payment', 'function' => 'user_products', 'access_type' => 'user', 'parameters' => 'userGroupID=' . $user_group->getID());
         $userPage = new SJB_UserPage();
         $page_data = SJB_UserPage::extractPageData($page);
         $userPage->setPageData($page_data);
         $userPage->save();
         $this->addLocationField($user_group->getSID());
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/user-groups/");
     } else {
         $add_user_group_form->registerTags($tp);
         $tp->assign('notifications', $user_group->getNotifications());
         $tp->assign('notificationGroups', $user_group->getNotificationsGroups());
         $tp->assign('form_fields', $add_user_group_form->getFormFieldsInfo());
         $tp->assign('errors', $errors);
         $tp->display('add_user_group.tpl');
     }
 }
Example #5
0
 public function execute()
 {
     $listing_field = new SJB_ListingField($_REQUEST);
     /**
      * add infilll instructions field
      */
     //$listing_field->addInfillInstructions(SJB_Request::getVar('instructions'));
     $template_processor = SJB_System::getTemplateProcessor();
     $add_listing_field_form = new SJB_Form($listing_field);
     $add_listing_field_form->registerTags($template_processor);
     $form_is_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'add';
     $errors = null;
     $pages = SJB_PostingPagesManager::getFirstPageEachListingType();
     if ($form_is_submitted && $add_listing_field_form->isDataValid($errors)) {
         $pages = SJB_PostingPagesManager::getFirstPageEachListingType();
         SJB_ListingFieldManager::saveListingField($listing_field, $pages);
         $listing_sid = $listing_field->getSID();
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/attention-listing-type-field/?listing_sid={$listing_sid}");
     } else {
         $pagesNum = SJB_PostingPagesManager::getNumAllPages();
         $pageCount = 0;
         foreach ($pagesNum as $val) {
             if ($val['num'] > 1) {
                 $pageCount = 1;
             }
         }
         $template_processor->assign("pageCount", $pageCount);
         $template_processor->assign("errors", $errors);
         $add_listing_field_form->registerTags($template_processor);
         $template_processor->assign("form_fields", $add_listing_field_form->getFormFieldsInfo());
         $template_processor->display("add_listing_field.tpl");
     }
 }
Example #6
0
 function getPropertyVariablesToAssign()
 {
     $form = new SJB_Form($this->complex);
     $form_fields = $form->getFormFieldsInfo();
     $propertyVariables = parent::getPropertyVariablesToAssign();
     $complexElements = array(1 => '');
     $newPropertyVariables = array('form_fields' => $form_fields, 'caption' => $this->property_info['caption'], 'complexElements' => $complexElements);
     $propertyVariables = array_merge($newPropertyVariables, $propertyVariables);
     if (!empty($propertyVariables['value'])) {
         if (is_string($propertyVariables['value'])) {
             $propertyVariables['value'] = unserialize($propertyVariables['value']);
         }
         if (is_array($propertyVariables['value'])) {
             foreach ($propertyVariables['value'] as $complexElement) {
                 if (is_array($complexElement)) {
                     foreach ($complexElement as $key => $val) {
                         if (!isset($complexElements[$key])) {
                             $complexElements[$key] = '';
                         }
                     }
                 }
             }
         }
         $propertyVariables['complexElements'] = $complexElements;
     }
     return $propertyVariables;
 }
Example #7
0
 function getPropertyVariablesToAssign()
 {
     $form = new SJB_Form($this->child);
     $form_fields = $form->getFormFieldsInfo();
     $propertyVariables = parent::getPropertyVariablesToAssign();
     $properties = $this->child->getProperties();
     $propertyVariables['value'] = array();
     foreach ($properties as $name => $property) {
         $variablesToAssign = $property->getPropertyVariablesToAssign();
         $form_fields[$name]['hidden'] = $variablesToAssign['hidden'];
         if ($variablesToAssign['value'] === '') {
             continue;
         } else {
             if (empty($variablesToAssign['value']) && !empty($variablesToAssign['profile_field_as_dv'])) {
                 $propertyVariables['value'][$name] = $variablesToAssign['profile_field_as_dv'];
             } else {
                 if (empty($variablesToAssign['value']) && !empty($variablesToAssign['default_value'])) {
                     $propertyVariables['value'][$name] = $variablesToAssign['default_value'];
                 } else {
                     $propertyVariables['value'][$name] = $variablesToAssign['value'];
                 }
             }
         }
     }
     $newPropertyVariables = array('form_fields' => $form_fields, 'caption' => $this->property_info['caption'], 'parentID' => $this->property_info['id'], 'useAutocomplete' => $this->property_info['use_autocomplete'], 'type' => $this->property_info['type'], 'isClassifieds' => $this->property_info['is_classifieds'], 'enable_search_by_radius' => $this->property_info['enable_search_by_radius']);
     $propertyVariables = array_merge($newPropertyVariables, $propertyVariables);
     return $propertyVariables;
 }
Example #8
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $user_group_sid = SJB_Request::getVar('sid', null);
     $errors = array();
     if (!is_null($user_group_sid)) {
         $action = SJB_Request::getVar("action", false);
         $product_sid = SJB_Request::getVar("product_sid", false);
         if ($action && $product_sid !== false) {
             switch ($action) {
                 case 'move_up':
                     SJB_ProductsManager::moveUpProductBySID($product_sid, $user_group_sid);
                     break;
                 case 'move_down':
                     SJB_ProductsManager::moveDownProductBySID($product_sid, $user_group_sid);
                     break;
                 case 'set_default_product':
                     SJB_UserGroupManager::setDefaultProduct($user_group_sid, $product_sid);
                     break;
             }
         }
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user_group_info = array_merge($user_group_info, $_REQUEST);
         $userGroup = new SJB_UserGroup($user_group_info);
         $userGroup->setSID($user_group_sid);
         $edit_user_group_form = new SJB_Form($userGroup);
         $form_is_submitted = SJB_Request::getVar('submit');
         if ($form_is_submitted && $edit_user_group_form->isDataValid($errors)) {
             SJB_UserGroupManager::saveUserGroup($userGroup);
             if ($form_is_submitted == 'save_info') {
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/user-groups/');
             }
         }
         $productSIDs = SJB_ProductsManager::getProductsInfoByUserGroupSID($user_group_sid);
         $productsInfo = array();
         $user_sids_in_group = SJB_UserManager::getUserSIDsByUserGroupSID($user_group_sid);
         $user_group_product_user_number = array();
         foreach ($productSIDs as $product) {
             $productsInfo[] = $product;
             $user_sids_in_product = SJB_UserManager::getUserSIDsByProductSID($product['sid']);
             $user_number = count(array_intersect($user_sids_in_group, $user_sids_in_product));
             $user_group_product_user_number[$product['sid']] = $user_number;
         }
         $edit_user_group_form->registerTags($tp);
         $tp->assign('object_sid', $userGroup->getSID());
         $tp->assign('notifications', $userGroup->getNotifications());
         $tp->assign('notificationGroups', $userGroup->getNotificationsGroups());
         $tp->assign('user_group_sid', $user_group_sid);
         $tp->assign('user_group_products_info', $productsInfo);
         $tp->assign('user_group_product_user_number', $user_group_product_user_number);
         $tp->assign('form_fields', $edit_user_group_form->getFormFieldsInfo());
     } else {
         $errors['USER_GROUP_SID_NOT_SET'] = 1;
     }
     $tp->assign('user_group_info', isset($user_group_info) ? $user_group_info : null);
     $tp->assign('errors', $errors);
     $tp->assign('object_sid', $user_group_sid);
     $tp->display('edit_user_group.tpl');
 }
Example #9
0
 public function execute()
 {
     $templateProcessor = SJB_System::getTemplateProcessor();
     $errors = array();
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
     $gateway_id = isset($_REQUEST['gateway']) ? $_REQUEST['gateway'] : null;
     $formSubmitted = SJB_Request::getVar('submit');
     $gateway_sid = SJB_PaymentGatewayManager::getSIDByID($gateway_id);
     if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($action)) {
         if ($action == 'deactivate') {
             SJB_PaymentGatewayManager::deactivateByID($gateway_id);
         } elseif ($action == 'activate') {
             SJB_PaymentGatewayManager::activateByID($gateway_id);
         }
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $gateway = SJB_PaymentGatewayManager::createObjectByID($gateway_id, $_REQUEST);
         $gateway->dontSaveProperty('id');
         $gateway->dontSaveProperty('caption');
         $gateway->setSID($gateway_sid);
         if ($gateway->isValid()) {
             if (SJB_PaymentGatewayManager::saveGateway($gateway) !== false) {
                 $templateProcessor->assign('gatewaySaved', true);
                 if ($formSubmitted == 'save_gateway') {
                     $siteUrl = SJB_System::getSystemsettings('SITE_URL') . '/system/payment/gateways/?gatewaySaved=1';
                     SJB_HelperFunctions::redirect($siteUrl);
                 }
             } else {
                 $errors['SETTINGS_SAVED_WITH_PROBLEMS'] = 1;
             }
         } else {
             $errors = $gateway->getErrors();
         }
     }
     $gateway = SJB_PaymentGatewayManager::getObjectByID($gateway_id);
     $gateway_form = new SJB_Form($gateway);
     $gateway_form->registerTags($templateProcessor);
     $gateway_form->makeDisabled('id');
     $gateway_form->makeDisabled('caption');
     $countryCode = $gateway->getPropertyValue('country');
     if (empty($countryCode)) {
         $countryValue = SJB_CountriesManager::getCountrySIDByCountryCode('US');
         $gateway->setPropertyValue('country', $countryValue);
     }
     if (empty($gateway)) {
         $errors['GATEWAY_NOT_FOUND'] = 1;
         $templateProcessor->assign('errors', $errors);
         $templateProcessor->display('configure_gateway.tpl');
         return;
     }
     $gateway_info = SJB_PaymentGatewayManager::getInfoBySID($gateway_sid);
     $form_fields = $gateway_form->getFormFieldsInfo();
     $templateProcessor->assign('gateway', $gateway_info);
     $templateProcessor->assign('form_fields', $form_fields);
     $templateProcessor->assign('errors', $errors);
     $templateProcessor->display('configure_gateway.tpl');
 }
Example #10
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $listingTypeSID = isset($_REQUEST['sid']) ? $_REQUEST['sid'] : null;
     if (!is_null($listingTypeSID)) {
         $form_submitted = SJB_Request::getVar('action', '');
         $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSID);
         $approveSettingChanged = $listing_type_info['waitApprove'] != SJB_Request::getVar('waitApprove');
         $listing_type_info = array_merge($listing_type_info, $_REQUEST);
         $listingType = new SJB_ListingType($listing_type_info);
         $listingType->setSID($listingTypeSID);
         $edit_form = new SJB_Form($listingType);
         $listingTypeEmailAlert = $listingType->getPropertyValue('email_alert');
         if (empty($listingTypeEmailAlert)) {
             $listingType->setPropertyValue('email_alert', 0);
         }
         $listingTypeEmailAlertForGuests = $listingType->getPropertyValue('guest_alert_email');
         if (empty($listingTypeEmailAlertForGuests)) {
             $listingType->setPropertyValue('guest_alert_email', 0);
         }
         $errors = array();
         if ($form_submitted && $edit_form->isDataValid($errors)) {
             SJB_Breadcrumbs::updateBreadcrumbsByListingTypeSID($listingTypeSID, $listingType->getPropertyValue('name'));
             SJB_PageManager::updatePagesByListingTypeSID($listingTypeSID, $listingType->getPropertyValue('name'));
             SJB_ListingTypeManager::saveListingType($listingType);
             if ($approveSettingChanged) {
                 SJB_BrowseDBManager::rebuildBrowses();
             }
             if ($form_submitted == 'save_info') {
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/listing-types/');
             }
         }
         $template_processor->assign('errors', $errors);
         $template_processor->assign('listing_type_sid', $listingTypeSID);
         $listing_fields_info = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeSID);
         $listing_fields = array();
         $listing_field_sids = array();
         foreach ($listing_fields_info as $listing_field_info) {
             if ($listing_field_info['type'] == 'logo') {
                 continue;
             }
             $listing_field = new SJB_ListingField($listing_field_info);
             $listing_field->setSID($listing_field_info['sid']);
             $listing_fields[] = $listing_field;
             $listing_field_sids[] = $listing_field_info['sid'];
         }
         $edit_form->registerTags($template_processor);
         $template_processor->assign("listing_type_info", $listing_type_info);
         $template_processor->assign("form_fields", $edit_form->getFormFieldsInfo());
         $template_processor->display("edit_listing_type.tpl");
         $form_collection = new SJB_FormCollection($listing_fields);
         $form_collection->registerTags($template_processor);
         $template_processor->assign("listing_field_sids", $listing_field_sids);
         $template_processor->display("listing_type_fields.tpl");
     }
 }
Example #11
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $productType = SJB_Request::getVar('product_type', false);
     $action = SJB_Request::getVar('action', false);
     $errors = array();
     $productErrors = array();
     if ($productType) {
         if ($productType == 'featured_user') {
             $_REQUEST['user_group_sid'] = SJB_UserGroupManager::getUserGroupSIDByID('Employer');
         }
         $product = new SJB_Product($_REQUEST, $productType);
         $pages = $product->getProductPages();
         $addProductForm = new SJB_Form($product);
         $addProductForm->registerTags($tp);
         $form_submitted = SJB_Request::getVar('action', '') == 'save';
         if ($form_submitted) {
             $productErrors = $product->isValid($product);
             if (in_array($productType, array('access_listings', 'featured_user', 'banners', 'custom_product'))) {
                 $periodName = $product->getPropertyValue('period_name');
                 if ($periodName == 'unlimited') {
                     $product->makePropertyNotRequired('period');
                 }
             }
         }
         if ($form_submitted && $addProductForm->isDataValid($errors) && !$productErrors) {
             $product->addProperty(array('id' => 'product_type', 'type' => 'string', 'value' => $productType, 'is_system' => true));
             $product->saveProduct($product, $_REQUEST);
             $product->savePermissions($_REQUEST);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/products/');
         }
         $errors = array_merge($errors, $productErrors);
         $formFieldsInfo = $addProductForm->getFormFieldsInfo();
         $formFields = array();
         foreach ($pages as $pageID => $page) {
             foreach ($formFieldsInfo as $formFieldInfo) {
                 if (in_array($formFieldInfo['id'], $page['fields'])) {
                     $formFields[$pageID][] = $formFieldInfo;
                 }
             }
             if (!isset($formFields[$pageID])) {
                 $formFields[$pageID] = array();
             }
         }
         $tp->assign('form_fields', $formFields);
         $tp->assign('product_type', $productType);
         $tp->assign('request', $_REQUEST);
         $tp->assign('params', http_build_query($_REQUEST));
         $tp->assign('pages', $pages);
         $tp->assign('pageTab', SJB_Request::getVar('page', false));
         $tp->assign("errors", $errors);
         $tp->display('add_product.tpl');
     } else {
         $tp->display('select_product_type.tpl');
     }
 }
Example #12
0
 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()
 {
     $listing_type_sid = isset($_REQUEST['listing_type_sid']) ? $_REQUEST['listing_type_sid'] : null;
     if (!is_null($listing_type_sid)) {
         $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid);
         $pages_list = array();
         if (count($pages) > 1) {
             $pages_list[] = array('id' => 'no', 'caption' => 'Don’t add to a page');
             foreach ($pages as $page) {
                 $pages_list[] = array('id' => $page['sid'], 'caption' => $page['page_name']);
             }
         }
         $listing_field = new SJB_ListingField($_REQUEST, $listing_type_sid, $pages_list);
         /**
          * add infilll instructions field
          */
         //	$listing_field->addInfillInstructions(SJB_Request::getVar('instructions'));
         $add_listing_field_form = new SJB_Form($listing_field);
         $form_is_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'add';
         $errors = null;
         if ($form_is_submitted && $add_listing_field_form->isDataValid($errors)) {
             $page = array();
             if (count($pages) == 1) {
                 $pages = array_pop($pages);
                 $page = array(array('sid' => $pages['sid'], 'listing_type_sid' => $listing_type_sid));
             } else {
                 $posting_page = $listing_field->getProperty('posting_page');
                 $listing_field->deleteProperty('posting_page');
                 if ($posting_page->value != "no") {
                     $page = array(array('sid' => $posting_page->value, 'listing_type_sid' => $listing_type_sid));
                 }
             }
             SJB_ListingFieldManager::saveListingField($listing_field, $page);
             $listing_sid = $listing_field->getSID();
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/attention-listing-type-field/?listing_sid={$listing_sid}");
         } else {
             $template_processor = SJB_System::getTemplateProcessor();
             $template_processor->assign("errors", $errors);
             $template_processor->assign("listing_type_sid", $listing_type_sid);
             $template_processor->assign("listing_type_info", SJB_ListingTypeManager::getListingTypeInfoBySID($listing_type_sid));
             $add_listing_field_form->registerTags($template_processor);
             $template_processor->assign("form_fields", $add_listing_field_form->getFormFieldsInfo());
             $template_processor->display("add_listing_type_field.tpl");
         }
     } else {
         echo 'The system cannot proceed as Listing Type SID is not set';
     }
 }
Example #14
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $formSubmitted = SJB_Request::getVar('action');
     $bitlyInfo = new SJB_Bitly($_REQUEST);
     $bitlyForm = new SJB_Form($bitlyInfo);
     if ($formSubmitted == 'saveSettings') {
         $bitlyForm->isDataValid($errors);
         if (!$errors) {
             SJB_Settings::updateSettings($_REQUEST);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/social-media/bitly/");
         }
     }
     $tp->assign("settings", SJB_Settings::getSettings());
     $tp->assign("errors", $errors);
     $tp->display("bitly.tpl");
 }
Example #15
0
 /**
  * @param array $errors
  * @return bool
  */
 public function isValid(array &$errors = array())
 {
     if (SJB_Request::getMethod() == 'POST' && $this->isCaptcha) {
         if ($this->isNotValidate) {
             return false;
         }
         $this->captchaForm->isDataValid($this->captchaError);
         $errors = array_merge(array_flip($this->captchaError), $errors);
     }
     return $this->captchaError ? false : true;
 }
Example #16
0
 public function execute()
 {
     $listing_type = new SJB_ListingType($_REQUEST);
     $add_listing_type_form = new SJB_Form($listing_type);
     $form_is_submitted = SJB_Request::getVar('action') == 'add';
     $errors = null;
     if ($form_is_submitted && $add_listing_type_form->isDataValid($errors)) {
         SJB_ListingTypeManager::saveListingType($listing_type);
         $this->createListingTypePage($listing_type);
         $listingTypeID = $listing_type->getID();
         if (in_array($listingTypeID, array('Job', 'Resume'))) {
             $title = $listing_type->getPropertyValue('name');
         } else {
             $title = $listing_type->getPropertyValue('name') . ' Listing';
         }
         $pageInfo = array('page_id' => 'Post' . $listingTypeID, 'page_name' => 'Post ' . $title);
         $page = new SJB_PostingPages($pageInfo, $listing_type->getSID());
         SJB_PostingPagesManager::savePage($page);
         SJB_PageManager::addPage(array('uri' => '/' . strtolower($listingTypeID) . '-preview/', 'module' => 'classifieds', 'function' => 'display_my_listing', 'template' => '', 'title' => $title . ' Preview', 'access_type' => 'user', 'parameters' => array('display_template' => 'display_listing.tpl'), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 1));
         SJB_PageManager::addPage(array('uri' => '/my-' . strtolower($listingTypeID) . '-details/', 'module' => 'classifieds', 'function' => 'display_my_listing', 'template' => '', 'title' => 'My ' . $title . ' Details', 'access_type' => 'user', 'parameters' => array('display_template' => 'display_listing.tpl'), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 1));
         SJB_PageManager::addPage(array('uri' => '/print-my-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'display_my_listing', 'template' => 'blank.tpl', 'title' => 'Print ' . $title, 'access_type' => 'user', 'parameters' => array('display_template' => 'print_listing.tpl', 'listing_type_id' => $listingTypeID), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 0));
         SJB_PageManager::addPage(array('uri' => '/print-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'display_listing', 'template' => 'blank.tpl', 'title' => 'Print ' . $title, 'access_type' => 'user', 'parameters' => array('display_template' => 'print_listing.tpl', 'listing_type_id' => $listingTypeID), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 0));
         SJB_PageManager::addPage(array('uri' => '/manage-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'manage_listing', 'template' => '', 'title' => 'Manage ' . $title, 'access_type' => 'user', 'parameters' => array(), 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 1));
         SJB_PageManager::addPage(array('uri' => '/edit-' . strtolower($listingTypeID) . '/', 'module' => 'classifieds', 'function' => 'edit_listing', 'template' => '', 'title' => 'Edit ' . $title, 'access_type' => 'user', 'parameters' => '', 'keywords' => '', 'description' => '', 'pass_parameters_via_uri' => 0));
         $breadCrumbs = new SJB_Breadcrumbs();
         $parentId = $breadCrumbs->getElementByUri('/my-listings/');
         $uri = '/my-listings/' . $listingTypeID . '/';
         $breadCrumbs->addElement('My ' . $title . 's', $uri, $parentId);
         $newBreadcrumbId = $breadCrumbs->getElementByUri($uri);
         $breadCrumbs->addElement('My ' . $title . ' Preview', '/my-' . strtolower($listingTypeID) . '-details/', $newBreadcrumbId);
         $breadCrumbs->addElement('Edit ' . $title, '/edit-' . strtolower($listingTypeID) . '/', $newBreadcrumbId);
         $breadCrumbs->addElement('Manage ' . $title, '/manage-' . strtolower($listingTypeID) . '/', $newBreadcrumbId);
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/listing-types/");
     } else {
         $template_processor = SJB_System::getTemplateProcessor();
         $template_processor->assign("errors", $errors);
         $add_listing_type_form->registerTags($template_processor);
         $template_processor->assign("form_fields", $add_listing_type_form->getFormFieldsInfo());
         $template_processor->display("add_listing_type.tpl");
     }
 }
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $listingTypeSID = 0;
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $params = SJB_FixedUrlParamProvider::getParams($_REQUEST);
         if ($params) {
             $listingTypeID = array_pop($params);
             $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
         }
     }
     if (!$listingTypeSID) {
         $errors['WRONG_LISTING_TYPE_ID_SPECIFIED'] = true;
     } else {
         $listing = new SJB_Listing(array(), $listingTypeSID);
         $listing->addIDProperty();
         $listing->addActivationDateProperty();
         $listing->addUsernameProperty();
         $listing->addKeywordsProperty();
         $listing->addPicturesProperty();
         $listing->addListingTypeIDProperty();
         $listing->addPostedWithinProperty();
         $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($listing->listing_type_sid);
         $display_form = new SJB_Form($listing);
         $display_form->registerTags($tp);
         $form_fields = $display_form->getFormFieldsInfo();
         $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $tp->assign('form_fields', $form_fields);
         $tp->filterThenAssign('listing', $listing_structure);
         $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY, $listingTypeID);
         $formBuilder->setChargedTemplateProcessor($tp);
         $tp->assign('listingTypeInfo', SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSID));
         $tp->assign('currentTheme', SJB_TemplateSupplier::getUserCurrentTheme());
     }
     $tp->assign('errors', $errors);
     $tp->display('bf_displaylisting.tpl');
 }
Example #18
0
 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');
         }
     }
 }
Example #19
0
 public function execute()
 {
     $action = SJB_Request::getVar('action', '');
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $formSubmitted = !empty($action) ? true : false;
     $adminCurrentDetails = SJB_AdminPasswordManager::getCurrentAdminDetails();
     $adminDetails = array_merge($adminCurrentDetails, $_REQUEST);
     $admin = new SJB_AdminPassword($adminDetails);
     $admin->setSID($adminCurrentDetails['sid']);
     $adminPasswordForm = new SJB_Form($admin);
     $adminPasswordForm->registerTags($tp);
     $formFields = $adminPasswordForm->getFormFieldsInfo();
     if ($formSubmitted) {
         if (SJB_System::getSystemSettings("isDemo")) {
             $errors['PERMISSION_DENIED'] = "You don't have permissions for it. This is a Demo version of the software.";
         } else {
             if ($action == 'change_admin_account' && $adminPasswordForm->isDataValid($errors)) {
                 $oldPassword = $admin->getPropertyValue('password');
                 $newPassword = SJB_AdminPasswordManager::getNewPasswordValue($adminDetails);
                 if ($adminCurrentDetails['password'] != md5($oldPassword)) {
                     $errors['Password'] = '******';
                 } else {
                     if ($newPassword) {
                         $admin->setPropertyValue('password', $newPassword);
                     }
                     $admin->deleteProperty('new_password');
                     SJB_AdminPasswordManager::saveAdmin($admin);
                     SJB_Session::setValue('username', $admin->getPropertyValue('username'));
                 }
             }
         }
     }
     $tp->assign('action', $action);
     $tp->assign('errors', $errors);
     $tp->assign('adminInfo', SJB_AdminPasswordManager::getCurrentAdminDetails());
     $tp->assign("form_fields", $formFields);
     $tp->display("adminpswd.tpl");
 }
Example #20
0
 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);
 }
Example #21
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action_name', false);
     $action = $action ? $action : 'list';
     $template = 'manage_polls.tpl';
     $errors = array();
     switch ($action) {
         case 'new':
             $template = 'input_form_poll.tpl';
             $_REQUEST['start_date'] = date('Y-m-d');
             $field = new SJB_PollsManager($_REQUEST);
             $form = new SJB_Form($field);
             $form->registerTags($tp);
             $tp->assign('form_fields', $form->getFormFieldsInfo());
             break;
         case 'save':
             $sid = SJB_Request::getVar('sid');
             $_REQUEST['value'] = strip_tags(SJB_Request::getVar('value'));
             $_REQUEST['user_group_sid'] = SJB_Request::getInt('user_group_sid', 0);
             $field = new SJB_PollsManager($_REQUEST);
             if ($sid) {
                 $field->setSID($sid);
             }
             $form = new SJB_Form($field);
             if ($form->isDataValid($errors)) {
                 SJB_PollsManager::savePoll($field);
                 $_REQUEST['sid'] = $field->sid;
                 $save = SJB_Request::getVar('save', false);
                 $action = 'edit';
                 if ($save) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-polls/');
                     break;
                 }
             } else {
                 $action = 'new';
                 if ($sid) {
                     $action = 'edit';
                 }
                 $template = 'input_form_poll.tpl';
                 $field->setSID($sid);
                 $form->registerTags($tp);
                 $tp->assign('form_fields', $form->getFormFieldsInfo());
                 $tp->assign('errors', $errors);
                 $tp->assign('sid', $sid);
                 break;
             }
         case 'edit':
             $sid = SJB_Request::getVar('sid');
             $info = SJB_PollsManager::getPollInfoBySID($sid);
             $field = new SJB_PollsManager($info);
             $edit_form = new SJB_Form($field);
             $edit_form->registerTags($tp);
             $field->setSID($sid);
             $tp->assign('form_fields', $edit_form->getFormFieldsInfo());
             $tp->assign('sid', $sid);
             $tp->assign('action', 'edit');
             $template = 'input_form_poll.tpl';
             break;
         case 'edit_answer':
             $sid = SJB_Request::getVar('sid');
             $_REQUEST['field_sid'] = $sid;
             $event = SJB_Request::getVar('event');
             $pollInfo = SJB_PollsManager::getPollInfoBySID($sid);
             $edit_list_controller = new SJB_PollsEditListController($_REQUEST, $pollInfo);
             switch ($event) {
                 case 'add':
                     $item_sid = SJB_Request::getVar('item_sid');
                     if ($edit_list_controller->isValidValueSubmitted()) {
                         if ($item_sid) {
                             $pollItemManager = new SJB_PollsListItemManager();
                             $list_item = $pollItemManager->getListItemBySID($item_sid);
                             $list_item->setValue(trim($_REQUEST['list_item_value']));
                             $pollItemManager->saveListItem($list_item);
                         } else {
                             if (!$edit_list_controller->saveItem()) {
                                 $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS');
                             }
                         }
                     } else {
                         $tp->assign('error', 'LIST_VALUE_IS_EMPTY');
                     }
                     break;
                 case 'edit':
                     $item_sid = SJB_Request::getVar('item_sid');
                     $pollItemManager = new SJB_PollsListItemManager();
                     $list_item = $pollItemManager->getListItemBySID($item_sid);
                     $tp->assign('item_sid', $list_item->sid);
                     $tp->assign('item_value', $list_item->value);
                     $tp->assign('item_action', 'edit');
                     break;
                 case 'add_multiple':
                     if ($edit_list_controller->isValidMultiValueSubmitted()) {
                         if (!$edit_list_controller->saveItem(true)) {
                             $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS');
                         }
                     } else {
                         $tp->assign('error', 'LIST_VALUE_IS_EMPTY');
                     }
                     break;
                 case 'delete':
                     $item_sid = SJB_Request::getVar('item_sid');
                     if (is_array($item_sid)) {
                         foreach ($item_sid as $sid => $val) {
                             $edit_list_controller->deleteItem($sid);
                         }
                     } else {
                         $edit_list_controller->deleteItem();
                     }
                     break;
                 case 'move_up':
                     $edit_list_controller->moveUpItem();
                     break;
                 case 'move_down':
                     $edit_list_controller->moveDownItem();
                     break;
                 case 'save_order':
                     if ($item_order = SJB_Request::getVar('item_order', false)) {
                         $edit_list_controller->saveNewItemsOrder($item_order);
                     }
                     break;
                 case 'sort':
                     $edit_list_controller->sortItems(SJB_Request::getVar('field_sid'), SJB_Request::getVar('sorting_order'));
                     $tp->assign('sorting_order', SJB_Request::getVar('sorting_order'));
                     break;
             }
             $display_list_controller = new SJB_PollsDisplayListController($_REQUEST, $pollInfo);
             $display_list_controller->setTemplateProcessor($tp);
             $display_list_controller->display('edit_answer.tpl');
             break;
         case 'delete':
             $sid = SJB_Request::getVar('sid', false);
             $sids = SJB_Request::getVar('polls', false);
             if ($sid) {
                 SJB_PollsManager::deletePollBySID($sid);
             } else {
                 if ($sids) {
                     foreach ($sids as $sid => $val) {
                         SJB_PollsManager::deletePollBySID($sid);
                     }
                 } else {
                     $errors[] = 'NO_POLLS_SELECTED';
                 }
             }
             $action = 'list';
             break;
         case 'activate':
             $sids = SJB_Request::getVar('polls');
             if (is_array($sids)) {
                 foreach ($sids as $sid => $val) {
                     SJB_PollsManager::activatePollBySID($sid);
                 }
             } else {
                 $errors[] = 'NO_POLLS_SELECTED';
             }
             $action = 'list';
             break;
         case 'deactivate':
             $sids = SJB_Request::getVar('polls');
             if (is_array($sids)) {
                 foreach ($sids as $sid => $val) {
                     SJB_PollsManager::deactivatePollBySID($sid);
                 }
             } else {
                 $errors[] = 'NO_POLLS_SELECTED';
             }
             $action = 'list';
             break;
         case 'save_display_setting':
             $settings = SJB_Request::getVar('settings');
             SJB_Settings::updateSettings($settings);
             $action = 'list';
             break;
         case 'view_results':
             $sid = SJB_Request::getVar('sid', 0);
             $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]['width'] = $countVotes > 0 ? round(300 / $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('count_vote', $countVotes);
             $template = 'view_result.tpl';
             break;
     }
     if ($action == 'list') {
         $paginator = new SJB_PollsManagePagination();
         $pollsCount = 0;
         $pollsInfo = SJB_PollsManager::getPollsInfo($paginator->sortingField, $paginator->sortingOrder, ($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage, $pollsCount);
         $paginator->setItemsCount($pollsCount);
         $showPollsOnMainPage = SJB_Settings::getSettingByName('show_polls_on_main_page');
         $tp->assign('errors', $errors);
         $tp->assign('frontendLanguages', SJB_ObjectMother::createI18N()->getActiveFrontendLanguagesData());
         $tp->assign('pollsInfo', $pollsInfo);
         $tp->assign('show_polls_on_main_page', $showPollsOnMainPage);
         $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     }
     if ($action !== 'edit_answer') {
         $tp->assign('action', $action);
         $tp->assign('polls', 1);
         $tp->display($template);
     }
 }
Example #22
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $sid = SJB_Request::getVar('sid', null, null, 'int');
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
     }
     $request['field_sid'] = $sid;
     $display_list_controller = new SJB_ScreeningQuestionnairesDisplayListController($request);
     $questionInfo = SJB_ScreeningQuestionnairesFieldManager::getFieldInfoBySID($sid);
     if (!empty($questionInfo['questionnaire_sid']) && SJB_ScreeningQuestionnaires::isUserOwnerQuestionnaire(SJB_UserManager::getCurrentUserSID(), $questionInfo['questionnaire_sid'])) {
         $questionInfo = array_merge($questionInfo, $_REQUEST);
         $questionnaire_field = new SJB_ScreeningQuestionnairesField($questionInfo);
         $questionnaire_field->deleteProperty('maxlength');
         $questionnaire_field->deleteProperty('template');
         $add_questionnaire_field_form = new SJB_Form($questionnaire_field);
         $add_questionnaire_field_form->registerTags($tp);
         $form_is_submitted = SJB_Request::getVar('action', '') == 'add';
         $errors = null;
         $type = SJB_Request::getVar('type', false);
         $savedType = $display_list_controller->field->getProperty('type')->value;
         $type = $type ? $type : $savedType;
         $answers = SJB_Request::getVar('answer', false);
         $score = SJB_Request::getVar('score', false);
         $answer_boolean = SJB_Request::getVar('answer_boolean', false);
         $score_boolean = SJB_Request::getVar('score_boolean', false);
         if ($type != 'string') {
             $answers = $answers ? $answers : $display_list_controller->list_items['answer'];
             $score = $score ? $score : $display_list_controller->list_items['score'];
             $answer_boolean = $answer_boolean ? $answer_boolean : $display_list_controller->list_items['answer'];
             $score_boolean = $score_boolean ? $score_boolean : $display_list_controller->list_items['score'];
         }
         if ($answer_boolean && $score_boolean) {
             foreach ($answer_boolean as $key => $val) {
                 $score_boolean[strtolower($val)] = $score_boolean[$key];
             }
         }
         if ($form_is_submitted && $add_questionnaire_field_form->isDataValid($errors)) {
             $questionnaire_field->addProperty(array('id' => 'questionnaire_sid', 'type' => 'id', 'value' => $questionInfo['questionnaire_sid'], 'is_system' => true));
             $id = $questionnaire_field->getProperty('caption');
             $questionnaire_field->addProperty(array('id' => 'id', 'type' => 'string', 'value' => md5($id->value), 'is_system' => true));
             $questionnaire_field->setSID($sid);
             $questionnairesListItemManager = new SJB_ScreeningQuestionnairesListItemManager();
             $questionnairesListItemManager->deleteItemsByFieldSID($sid);
             SJB_ScreeningQuestionnairesFieldManager::saveQuestion($questionnaire_field);
             if ($type == 'boolean') {
                 $request['list_multiItem_value'] = $answer_boolean;
                 $request['field_sid'] = $questionnaire_field->sid;
                 $request['score'] = $score_boolean;
                 $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request);
                 if ($edit_list_controller->isvalidFieldSID()) {
                     $edit_list_controller->saveItem(true);
                 }
             } elseif ($type != 'string') {
                 $request['list_multiItem_value'] = $answers;
                 $request['field_sid'] = $questionnaire_field->sid;
                 $request['score'] = $score;
                 $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request);
                 if ($edit_list_controller->isvalidFieldSID()) {
                     $edit_list_controller->saveItem(true);
                 }
             }
             $questionnaire_sid = $questionnaire_field->getSID();
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-questions/{$questionInfo['questionnaire_sid']}/?edit=1");
         } else {
             switch ($type) {
                 case 'boolean':
                     $tp->assign('answer_boolean', $answer_boolean);
                     $tp->assign('score_boolean', $score_boolean);
                     break;
                 case 'multilist':
                 case 'list':
                     $tp->assign('answers', $answers);
                     $tp->assign('score', $score);
                     break;
             }
             $tp->assign('errors', $errors);
             $tp->assign('action', 'edit');
             $tp->assign('questionnaire_sid', $questionInfo['questionnaire_sid']);
             $add_questionnaire_field_form->registerTags($tp);
             $tp->assign('form_fields', $add_questionnaire_field_form->getFormFieldsInfo());
             $tp->display('add_questions.tpl');
         }
     }
 }
Example #23
0
 private function getFormFieldsInfo(SJB_Form $addListingFieldForm)
 {
     $fields = $addListingFieldForm->getFormFieldsInfo();
     if (isset($fields['use_autocomplete'])) {
         unset($fields['use_autocomplete']);
     }
     return $fields;
 }
Example #24
0
 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);
 }
Example #25
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $displayForm = new SJB_Form();
     $displayForm->registerTags($tp);
     $invoiceSid = SJB_Request::getVar('sid', false);
     if (SJB_Request::getVar('error', false)) {
         SJB_FlashMessages::getInstance()->addWarning('TCPDF_ERROR');
     }
     $action = SJB_Request::getVar('action', false);
     $paymentGateway = SJB_Request::getVar('payment_gateway', false);
     $template = 'print_invoice.tpl';
     $currentUserSID = SJB_UserManager::getCurrentUserSID();
     $invoiceInfo = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSid);
     if ($invoiceInfo) {
         if ($currentUserSID == $invoiceInfo['user_sid']) {
             $taxInfo = SJB_TaxesManager::getTaxInfoBySID($invoiceInfo['tax_info']['sid']);
             $invoiceInfo = array_merge($invoiceInfo, $_REQUEST);
             if (is_array($taxInfo)) {
                 $taxInfo = array_merge($invoiceInfo['tax_info'], $taxInfo);
             } else {
                 $taxInfo = $invoiceInfo['tax_info'];
             }
             $invoice = new SJB_Invoice($invoiceInfo);
             $invoice->setSID($invoiceSid);
             $userInfo = SJB_UserManager::getUserInfoBySID($currentUserSID);
             $username = $userInfo['CompanyName'] . ' ' . $userInfo['FirstName'] . ' ' . $userInfo['LastName'];
             $user = SJB_UserManager::getObjectBySID($currentUserSID);
             $productsSIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userInfo['user_group_sid']);
             $products = array();
             foreach ($productsSIDs as $key => $productSID) {
                 $product = SJB_ProductsManager::getProductInfoBySID($productSID);
                 $products[$key] = $product;
             }
             $displayForm = new SJB_Form($invoice);
             $displayForm->registerTags($tp);
             $show = true;
             if ($action == 'download_pdf_version' || $action == 'print') {
                 $show = false;
             }
             $tp->assign('show', $show);
             $tp->assign('products', $products);
             $tp->assign('invoice_sid', $invoiceSid);
             $tp->assign('invoice_status', $invoiceInfo['status']);
             $tp->assign('username', trim($username));
             $tp->assign('user_sid', $currentUserSID);
             $tp->assign('tax', $taxInfo);
             $userStructure = SJB_UserManager::createTemplateStructureForUser($user);
             $tp->assign('user', $userStructure);
             $tp->assign('include_tax', $invoiceInfo['include_tax']);
             if ($action == 'download_pdf_version') {
                 $template = 'invoice_to_pdf.tpl';
                 $filename = 'invoice_' . $invoiceSid . '.pdf';
                 try {
                     SJB_HelperFunctions::html2pdf($tp->fetch($template), $filename);
                     exit;
                 } catch (Exception $e) {
                     SJB_Error::writeToLog($e->getMessage());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . '/print-invoice/?sid=' . $invoiceSid . '&action=print&error=TCPDF_ERROR');
                 }
             }
         } else {
             SJB_FlashMessages::getInstance()->addError('NOT_OWNER');
         }
     } else {
         SJB_FlashMessages::getInstance()->addError('WRONG_INVOICE_ID_SPECIFIED');
     }
     if ($paymentGateway) {
         $gatewaySID = SJB_PaymentGatewayManager::getSIDByID($paymentGateway);
         $gatewayInfo = SJB_PaymentGatewayManager::getInfoBySID($gatewaySID);
         $tp->assign('gatewayInfo', $gatewayInfo);
     }
     $tp->assign('paymentError', SJB_Request::getVar('payment_error', false));
     $tp->display($template);
 }
Example #26
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', false);
     $sid = SJB_Request::getVar('sid', null, null, 'int');
     $edit = SJB_Request::getVar('edit', false);
     if (isset($_REQUEST['passed_parameters_via_uri'])) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
         $questionSID = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : false;
     }
     if (SJB_ScreeningQuestionnaires::isUserOwnerQuestionnaire(SJB_UserManager::getCurrentUserSID(), $sid)) {
         switch ($action) {
             case 'delete':
                 if ($questionSID) {
                     SJB_ScreeningQuestionnairesFieldManager::deleteQuestionBySID($questionSID);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-questions/{$sid}/");
                 break;
             case 'move_up':
                 $questionSID = SJB_Request::getVar('question', false);
                 if ($questionSID) {
                     SJB_ScreeningQuestionnairesFieldManager::moveUpFieldBySID($questionSID);
                 }
                 break;
             case 'move_down':
                 $questionSID = SJB_Request::getVar('question', false);
                 if ($questionSID) {
                     SJB_ScreeningQuestionnairesFieldManager::moveDownFieldBySID($questionSID);
                 }
                 break;
         }
         $questionnaire_field = new SJB_ScreeningQuestionnairesField($_REQUEST);
         $questions = array();
         if ($sid) {
             $questions = SJB_ScreeningQuestionnairesFieldManager::getFieldsInfoByQuestionnairesSID($sid);
             $tp->assign('questionnarieInfo', SJB_ScreeningQuestionnaires::getInfoBySID($sid));
         }
         $add_questionnaire_field_form = new SJB_Form($questionnaire_field);
         $add_questionnaire_field_form->registerTags($tp);
         $form_is_submitted = SJB_Request::getVar('action', '') == 'add';
         $errors = null;
         $answers = SJB_Request::getVar('answer', false);
         $score = SJB_Request::getVar('score', false);
         $answer_boolean = SJB_Request::getVar('answer_boolean', false);
         $score_boolean = SJB_Request::getVar('score_boolean', false);
         $type = SJB_Request::getVar('type', false);
         if (is_array($answers)) {
             foreach ($answers as $key => $val) {
                 if ($key != 0 && $val == null) {
                     unset($answers[$key]);
                 }
             }
         }
         if ($form_is_submitted && $add_questionnaire_field_form->isDataValid($errors)) {
             $questionnaire_field->addProperty(array('id' => 'questionnaire_sid', 'type' => 'id', 'value' => $sid, 'is_system' => true));
             $id = $questionnaire_field->getProperty('caption');
             $questionnaire_field->addProperty(array('id' => 'id', 'type' => 'string', 'value' => md5($id->value), 'is_system' => true));
             SJB_ScreeningQuestionnairesFieldManager::saveQuestion($questionnaire_field);
             if ($type == 'boolean') {
                 $request['list_multiItem_value'] = $answer_boolean;
                 $request['field_sid'] = $questionnaire_field->sid;
                 $request['score'] = $score_boolean;
                 $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request);
                 if ($edit_list_controller->isvalidFieldSID()) {
                     $edit_list_controller->saveItem(true);
                 }
             } elseif ($type != 'string') {
                 $request['list_multiItem_value'] = $answers;
                 $request['field_sid'] = $questionnaire_field->sid;
                 $request['score'] = $score;
                 $edit_list_controller = new SJB_ScreeningQuestionnairesListController($request);
                 if ($edit_list_controller->isvalidFieldSID()) {
                     $edit_list_controller->saveItem(true);
                 }
             }
             $questionnaire_sid = $questionnaire_field->getSID();
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-questions/{$sid}/");
         } else {
             switch ($type) {
                 case 'boolean':
                     $tp->assign('answer_boolean', $answer_boolean);
                     $tp->assign('score_boolean', $score_boolean);
                     break;
                 case 'multilist':
                 case 'list':
                     $tp->assign('answers', $answers);
                     $tp->assign('score', $score);
                     break;
             }
             $tp->assign('edit', $edit);
             $tp->assign('sid', $sid);
             $tp->assign('questions', $questions);
             $tp->assign('action', 'edit');
             $tp->assign('errors', $errors);
             $add_questionnaire_field_form->registerTags($tp);
             $tp->assign('form_fields', $add_questionnaire_field_form->getFormFieldsInfo());
             $tp->display('edit_questions.tpl');
         }
     }
 }
Example #27
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listingTypeID = SJB_Request::getVar('listing_type_id', null);
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
     $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listingTypeSID);
     $productSID = SJB_Request::getVar('product_sid', false);
     $editUser = SJB_Request::getVar('edit_user', false);
     $action = SJB_Request::getVar('action', false);
     $username = SJB_Request::getVar('username', false);
     $errors = array();
     if ($username && ($userSID = SJB_UserManager::getUserSIDbyUsername($username))) {
         $userInfo = SJB_UserManager::getUserInfoBySID($userSID);
         $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']);
         if (!$productSID) {
             $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($userGroupInfo['sid']);
             foreach ($products as $key => $product) {
                 if (empty($product['listing_type_sid']) || $product['listing_type_sid'] != $listingTypeSID) {
                     unset($products[$key]);
                 }
             }
             if ($action == 'productVerify') {
                 $errors['PRODUCT_NOT_SELECTED'] = 1;
             }
             $tp->assign('errors', $errors);
             $tp->assign('username', $username);
             $tp->assign('products', $products);
             $tp->assign('edit_user', $editUser);
             $tp->assign('userSID', $userSID);
             $tp->assign('userGroupInfo', $userGroupInfo);
             $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
             $tp->display('select_product.tpl');
         } else {
             $form_submitted = SJB_Request::getVar('action', '') == 'add';
             $tmp_listing_id_from_request = SJB_Request::getVar('listing_id', false, 'default', 'int');
             if (!empty($tmp_listing_id_from_request)) {
                 $tmp_listing_sid = $tmp_listing_id_from_request;
             } elseif (!$tmp_listing_id_from_request) {
                 $tmp_listing_sid = time();
             }
             $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
             $extraInfo = is_null($productInfo['serialized_extra_info']) ? null : unserialize($productInfo['serialized_extra_info']);
             if (!empty($extraInfo)) {
                 $extraInfo['product_sid'] = $productSID;
             }
             $_REQUEST['featured'] = !empty($_REQUEST['featured']) ? $_REQUEST['featured'] : $productInfo['featured'];
             $_REQUEST['priority'] = !empty($_REQUEST['priority']) ? $_REQUEST['priority'] : $productInfo['priority'];
             $listing = new SJB_Listing($_REQUEST, $listingTypeSID);
             $properties = $listing->getPropertyList();
             foreach ($properties as $property) {
                 $propertyInfo = $listing->getPropertyInfo($property);
                 $propertyInfo['user_sid'] = $userSID;
                 if ($propertyInfo['type'] == 'location') {
                     $child = $listing->getChild($property);
                     $childProperties = $child->getPropertyList();
                     foreach ($childProperties as $childProperty) {
                         $childPropertyInfo = $child->getPropertyInfo($childProperty);
                         $childPropertyInfo['user_sid'] = $userSID;
                         $child->setPropertyInfo($childProperty, $childPropertyInfo);
                     }
                 }
                 $listing->setPropertyInfo($property, $propertyInfo);
             }
             $listing->deleteProperty('status');
             $listing->deleteProperty('reject_reason');
             $access_type = $listing->getProperty('access_type');
             if ($form_submitted) {
                 if (!empty($access_type)) {
                     $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true));
                 }
             }
             $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($userSID);
             if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) {
                 $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
                 if ($issetQuestionnairyField) {
                     $value = SJB_Request::getVar("screening_questionnaire");
                     $listing_info = $_REQUEST;
                     $value = $value ? $value : isset($listing_info['screening_questionnaire']) ? $listing_info['screening_questionnaire'] : '';
                     $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($userSID), 'is_system' => true));
                 }
             } else {
                 $listing->deleteProperty('screening_questionnaire');
             }
             if ($listing->getProperty('captcha')) {
                 $listing->deleteProperty('captcha');
             }
             $add_listing_form = new SJB_Form($listing);
             $add_listing_form->registerTags($tp);
             $field_errors = array();
             if ($form_submitted && $add_listing_form->isDataValid($field_errors)) {
                 $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 $listing->setUserSID($userSID);
                 $listing->setProductInfo($extraInfo);
                 if (empty($access_type->value)) {
                     $listing->setPropertyValue('access_type', 'everyone');
                 }
                 SJB_ListingManager::saveListing($listing);
                 SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $_REQUEST['featured'], $_REQUEST['priority'], $userSID);
                 if (isset($_SESSION['tmp_file_storage'])) {
                     foreach ($_SESSION['tmp_file_storage'] as $v) {
                         SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s", $listing->getSID(), $v['picture_saved_name']);
                         SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s", $listing->getSID(), $v['thumb_saved_name']);
                     }
                     SJB_Session::unsetValue('tmp_file_storage');
                 }
                 $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_ListingManager::activateListingBySID($listing->getSID());
                 SJB_ProductsManager::incrementPostingsNumber($productSID);
                 $listingSid = $listing->getSID();
                 SJB_Event::dispatch('listingSaved', $listingSid);
                 if ($editUser) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/edit-user/?user_sid=" . $userSID);
                 } else {
                     if ($listingTypeID == 'resume' || $listingTypeID == 'job') {
                         $link = "manage-" . strtolower($listingTypeID) . "s";
                     } else {
                         $link = "manage-" . strtolower($listingTypeID) . "-listings";
                     }
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/{$link}/?action=search&listing_type_sid=" . $listingTypeSID);
                 }
             } else {
                 $listing->deleteProperty('access_list');
                 $listing->deleteProperty('contract_id');
                 $add_listing_form = new SJB_Form($listing);
                 if ($form_submitted) {
                     $add_listing_form->isDataValid($field_errors);
                 }
                 $add_listing_form->registerTags($tp);
                 $form_fields = $add_listing_form->getFormFieldsInfo();
                 $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
                 $formFieldsSorted = array();
                 $formFieldsSorted['featured'] = $form_fields['featured'];
                 $formFieldsSorted['priority'] = $form_fields['priority'];
                 foreach ($pages as $page) {
                     $listing_fields = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']);
                     foreach (array_keys($listing_fields) as $field) {
                         if ($listing->propertyIsSet($field)) {
                             $formFieldsSorted[$field] = $form_fields[$field];
                         }
                     }
                 }
                 $form_fields = $formFieldsSorted;
                 //SJB_HelperFunctions::d($form_fields);
                 $employers_list = SJB_Request::getVar('list_emp_ids', false);
                 $employers = array();
                 if (is_array($employers_list)) {
                     foreach ($employers_list as $emp) {
                         $currEmp = SJB_UserManager::getUserInfoBySID($emp);
                         $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']);
                     }
                     sort($employers);
                 }
                 $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
                 $tp->assign("pic_limit", $numberOfPictures);
                 $tp->assign("listing_id", $tmp_listing_sid);
                 $tp->assign("listing_access_list", $employers);
                 $tp->assign("errors", $field_errors);
                 $tp->assign("form_fields", $form_fields);
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
             }
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             $tp->assign('edit_user', $editUser);
             $tp->assign('productInfo', $productInfo);
             $tp->assign('username', $username);
             $tp->assign('product_sid', $productSID);
             $tp->assign('userSID', $userSID);
             $tp->assign('userGroupInfo', $userGroupInfo);
             $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
             $tp->display('input_form.tpl');
         }
     } else {
         if ($username && !$userSID) {
             $errors['USER_NOT_FOUND'] = 1;
         } elseif ($action == 'userVerify') {
             $errors['USER_NOT_SELECTED'] = 1;
         }
         $tp->assign('errors', $errors);
         $tp->assign('username', $username);
         $tp->assign('listingType', SJB_ListingTypeManager::createTemplateStructure($listingTypeInfo));
         $tp->display('select_user.tpl');
     }
 }
Example #28
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false);
     $listing_type_id = '';
     $action = SJB_Request::getVar('action', 'list');
     $pageSID = SJB_Request::getVar('page_sid', 0);
     if ($passed_parameters_via_uri) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $listing_type_id = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
         $action = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : $action;
         $pageSID = isset($passed_parameters_via_uri[2]) ? $passed_parameters_via_uri[2] : $pageSID;
     }
     $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
     $submit = SJB_Request::getVar('submit', false);
     $errors = array();
     $template = 'posting_pages.tpl';
     if ($listing_type_sid) {
         $listingTypeInfo = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_type_sid);
         switch ($action) {
             case 'new':
                 $page = new SJB_PostingPages($_REQUEST, $listing_type_sid);
                 $form = new SJB_Form($page);
                 $form->registerTags($tp);
                 $form_fields = $form->getFormFieldsInfo();
                 if ($submit) {
                     $addValidParam = array('field' => 'listing_type_sid', 'value' => $listing_type_sid);
                     if ($form->isDataValid($errors, $addValidParam)) {
                         SJB_PostingPagesManager::savePage($page);
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/posting-pages/" . strtolower($listingTypeInfo['id']) . "/added");
                     }
                 }
                 $tp->assign("form_fields", $form_fields);
                 $template = 'input_page_form.tpl';
                 break;
             case 'edit':
                 $template = 'input_page_form.tpl';
                 $field_action = SJB_Request::getVar('field_action');
                 $pageInfo = SJB_PostingPagesManager::getPageInfoBySID($pageSID);
                 $pageInfo = array_merge($pageInfo, $_REQUEST);
                 $page = new SJB_PostingPages($pageInfo, $listing_type_sid);
                 $page->setSID($pageSID);
                 $form = new SJB_Form($page);
                 $form->registerTags($tp);
                 $form_fields = $form->getFormFieldsInfo();
                 if ($submit) {
                     $addValidParam = array('field' => 'listing_type_sid', 'value' => $listing_type_sid);
                     if ($form->isDataValid($errors, $addValidParam)) {
                         SJB_PostingPagesManager::savePage($page);
                         $pageInfo = SJB_PostingPagesManager::getPageInfoBySID($pageSID);
                         if ($submit == 'save') {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/posting-pages/" . $listing_type_id . "/");
                         }
                     }
                 }
                 //echo "field_action: $field_action<br>"; exit;
                 switch ($field_action) {
                     case 'add_fields':
                         $listing_fields = SJB_Request::getVar('listing_fields', array());
                         foreach ($listing_fields as $listing_field) {
                             SJB_PostingPagesManager::addListingFieldOnPage($listing_field, $pageSID, $listing_type_sid);
                         }
                         break;
                     case 'move_down':
                         $field_sid = SJB_Request::getVar('field_sid', null);
                         SJB_PostingPagesManager::moveDownFieldBySID($field_sid, $pageSID);
                         break;
                     case 'move_up':
                         $field_sid = SJB_Request::getVar('field_sid', null);
                         SJB_PostingPagesManager::moveUpFieldBySID($field_sid, $pageSID);
                         break;
                     case 'remove':
                         SJB_PostingPagesManager::removeFieldFromPageById(SJB_Request::getVar('relationId', null), $listing_type_sid);
                         break;
                     case 'move':
                         $field_sid = SJB_Request::getVar('field_sid', null);
                         $movePageID = SJB_Request::getVar('movePageID', false);
                         if ($movePageID !== false) {
                             SJB_PostingPagesManager::moveFieldToPade($field_sid, $movePageID, $listing_type_sid);
                         }
                         $template = 'move_field.tpl';
                         break;
                     case 'save_order':
                         $item_order = SJB_Request::getVar('item_order', null);
                         SJB_PostingPagesManager::saveNewJobFieldsOrder($item_order, $pageSID);
                         break;
                 }
                 $listing_fields = SJB_PostingPagesManager::getListingFieldsInfo($listing_type_sid);
                 $fieldsOnPage = SJB_PostingPagesManager::getAllFieldsByPageSID($pageSID);
                 $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid);
                 $tp->assign('pageInfo', $pageInfo);
                 $tp->assign('pages', $pages);
                 $tp->assign('countPages', count($pages));
                 $tp->assign("pageSID", $pageSID);
                 $tp->assign("fieldsOnPage", $fieldsOnPage);
                 $tp->assign("form_fields", $form_fields);
                 $tp->assign("listing_fields", $listing_fields);
                 break;
             case 'added':
                 $action = 'list';
                 break;
             case 'modified':
                 $action = 'list';
                 break;
             case 'move_up':
                 SJB_PostingPagesManager::moveUpPageBySID($pageSID);
                 $action = 'list';
                 break;
             case 'move_down':
                 SJB_PostingPagesManager::moveDownPageBySID($pageSID);
                 $action = 'list';
                 break;
             case 'delete':
                 $countPages = SJB_PostingPagesManager::getNumPagesByListingTypeSID($listing_type_sid);
                 if ($countPages > 1) {
                     SJB_PostingPagesManager::deletePageBySID($pageSID);
                 }
                 $action = 'list';
                 break;
         }
         if ($action == 'list') {
             $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid);
             $tp->assign('pages', $pages);
             $tp->assign('countPages', count($pages));
             $template = 'posting_pages.tpl';
         }
         $tp->assign('listingTypeInfo', $listingTypeInfo);
     } else {
         $errors['UNDEFINED_LISTING_TYPE_ID'] = 1;
     }
     $tp->assign('action', $action);
     $tp->assign('errors', $errors);
     $tp->display($template);
 }
Example #29
0
 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');
 }
Example #30
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'list');
     $countrySID = SJB_Request::getVar('country_sid', false);
     $errors = array();
     $template = 'states.tpl';
     $countries = SJB_CountriesManager::getAllCountries();
     $paginator = new SJB_StatesPagination();
     switch ($action) {
         case 'move_state':
         case 'save_order':
             $template = 'move_state.tpl';
             $itemSIDs = SJB_Request::getVar('item_order', array());
             try {
                 SJB_StatesManager::saveItemsOrder($paginator->currentPage, $paginator->itemsPerPage, $itemSIDs);
                 $tp->assign('action', $action);
             } catch (Exception $e) {
                 $errors['SAVING_ORDER'] = $e->getMessage();
             }
             $states = SJB_StatesManager::getAllStates($countrySID);
             $tp->assign('states', $states);
             break;
         case 'activate':
             $statesSIDs = array_keys(SJB_Request::getVar('states', array()));
             foreach ($statesSIDs as $stateSID) {
                 SJB_StatesManager::activateStateBySID($stateSID);
             }
             $action = 'list';
             break;
         case 'deactivate':
             $statesSIDs = array_keys(SJB_Request::getVar('states', array()));
             foreach ($statesSIDs as $stateSID) {
                 SJB_StatesManager::deactivateStateBySID($stateSID);
             }
             $action = 'list';
             break;
         case 'delete':
             $statesSIDs = array_keys(SJB_Request::getVar('states', array()));
             foreach ($statesSIDs as $stateSID) {
                 SJB_StatesManager::deleteStateBySID($stateSID);
             }
             $action = 'list';
             break;
         case 'add_state':
             $template = 'add_state.tpl';
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $state = new SJB_State($_REQUEST);
             $addStateForm = new SJB_Form($state);
             $addStateForm->registerTags($tp);
             $addValidParam = array('field' => 'country_sid', 'value' => $countrySID);
             if ($formSubmitted && $addStateForm->isDataValid($errors, $addValidParam)) {
                 $state->addProperty(array('id' => 'country_sid', 'type' => 'list', 'value' => $countrySID, 'is_required' => true, 'is_system' => true));
                 SJB_StatesManager::saveState($state);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/states/?country_sid=" . $countrySID);
             } else {
                 $formFields = $addStateForm->getFormFieldsInfo();
                 $tp->assign('form_fields', $formFields);
             }
             break;
         case 'edit_state':
             $template = 'edit_state.tpl';
             $stateSID = SJB_Request::getVar('state_id', false);
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $stateInfo = SJB_StatesManager::getStateInfoBySID($stateSID);
             if ($stateInfo) {
                 $stateInfo = array_merge($stateInfo, $_REQUEST);
                 $state = new SJB_State($stateInfo);
                 $addStateForm = new SJB_Form($state);
                 $addStateForm->registerTags($tp);
                 $state->setSID($stateSID);
                 $addValidParam = array('field' => 'country_sid', 'value' => $stateInfo['country_sid']);
                 if ($formSubmitted && $addStateForm->isDataValid($errors, $addValidParam)) {
                     SJB_StatesManager::saveState($state);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/states/?country_sid=" . $stateInfo['country_sid']);
                 } else {
                     $formFields = $addStateForm->getFormFieldsInfo();
                     $tp->assign('form_fields', $formFields);
                     $tp->assign('state_id', $stateSID);
                 }
             } else {
                 $tp->assign('action', 'edit');
                 $errors['WRONG_STATE_ID_SPECIFIED'] = 'WRONG_STATE_ID_SPECIFIED';
                 $template = 'state_errors.tpl';
             }
             break;
         case 'import_states':
             $template = 'import_states.tpl';
             $fileInfo = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             if ($fileInfo['error']) {
                 $errors[] = SJB_UploadFileManager::getErrorId($fileInfo['error']);
             } elseif ($fileInfo) {
                 $fileFormats = array('csv', 'xls', 'xlsx');
                 $pathInfo = pathinfo($fileInfo['name']);
                 $fileExtension = isset($pathInfo['extension']) ? strtolower($pathInfo['extension']) : '';
                 if (!in_array(strtolower($fileExtension), $fileFormats)) {
                     $errors[] = 'Please choose Excel or csv file';
                 } else {
                     $importFile = new SJB_ImportFileXLS($fileInfo);
                     $importFile->parse();
                     $importedData = $importFile->getData();
                     $state = new SJB_State();
                     $count = 0;
                     foreach ($importedData as $key => $importedColumn) {
                         if ($key == 1) {
                             $data = array_merge(array(array('state_code', 'state_name')), array($importedColumn));
                             $importedProcessor = new SJB_ImportedStateProcessor($data, $state);
                         }
                         if (!$importedColumn) {
                             continue;
                         }
                         $stateInfo = $importedProcessor->getData($importedColumn);
                         if (!empty($stateInfo['state_code']) && !empty($stateInfo['state_name'])) {
                             $state = new SJB_State($stateInfo);
                             $state->addProperty(array('id' => 'country_sid', 'type' => 'list', 'value' => $countrySID, 'is_required' => true, 'is_system' => true));
                             $state->setPropertyValue('active', 1);
                             $stateSID = SJB_StatesManager::getStateSIDByStateCode($stateInfo['state_code'], $countrySID);
                             if ($stateSID) {
                                 $state->setSID($stateSID);
                             } else {
                                 $count++;
                             }
                             SJB_StatesManager::saveState($state);
                         }
                     }
                     $tp->assign('imported_states_count', $count);
                     $template = 'import_states_result.tpl';
                 }
             }
             break;
     }
     if ($action == 'list') {
         $countryCode = SJB_Settings::getSettingByName('default_country_code');
         if (!$countrySID) {
             $countrySID = SJB_CountriesManager::getCountrySIDByCountryCode($countryCode);
         }
         if (!$countrySID) {
             $allCountries = SJB_CountriesManager::getAllCountries();
             foreach ($allCountries as $country) {
                 $countrySID = $country['sid'];
                 break;
             }
         }
         $countryInfo = SJB_CountriesManager::getCountryInfoBySID($countrySID);
         if ($countryInfo && $countryInfo['country_code'] != $countryCode) {
             SJB_Settings::updateSetting('default_country_code', $countryInfo['country_code']);
         }
         $states = SJB_StatesManager::getAllStates($countrySID, ($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage);
         $paginator->setItemsCount(SJB_StatesManager::countStates($countrySID));
         $tp->assign('states', $states);
         $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     }
     $tp->assign("countries", $countries);
     $tp->assign("country_sid", $countrySID);
     $tp->assign("errors", $errors);
     $tp->display($template);
 }