예제 #1
0
 public function sync()
 {
     $listingInfo = SJB_ListingManager::getListingInfoBySID($this->listingSID);
     $oCurListing = SJB_ObjectMother::createListing($listingInfo, SJB_ListingTypeManager::getListingTypeSIDByID('Resume'));
     $this->facebookSocialPlugin->fillObjectOutSocialData($oCurListing);
     $oCurListing->setSID($this->listingSID);
     SJB_ListingManager::saveListing($oCurListing);
 }
예제 #2
0
 public static function createListing($listing_type_id)
 {
     $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
     $listing = new SJB_Listing(array(), $listing_type_sid);
     $listing->addUsernameProperty();
     $listing->addListingTypeIDProperty();
     $listing->addActivationDateProperty();
     $listing->addExpirationDateProperty();
     return $listing;
 }
예제 #3
0
파일: create.php 프로젝트: Maxlander/shixi
 /**
  * @param SJB_GuestAlert $guestAlert
  * @param SJB_TemplateProcessor $tp
  */
 public function saveNewGuestAlert(SJB_GuestAlert $guestAlert, SJB_TemplateProcessor $tp)
 {
     $guestAlert->addDataProperty(serialize($this->criteriaData));
     $guestAlert->addListingTypeIDProperty($this->listingTypeID);
     $guestAlert->save();
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
     SJB_GuestAlertStatistics::saveEventSubscribed($listingTypeSID, $guestAlert->getSID());
     SJB_Notifications::sendConfirmationEmailForGuest($guestAlert);
     $tp->assign('email', $guestAlert->getAlertEmail());
     $this->template = 'alert_created.tpl';
 }
예제 #4
0
 public function execute()
 {
     $template_processor = SJB_System::getTemplateProcessor();
     $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int');
     $listingType = SJB_Request::getVar('listing_type', null);
     if (!$listingType) {
         if ($listingId) {
             $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
             $listingType = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
         } else {
             $listingType = 'job';
         }
     }
     $displayForm = SJB_Request::getVar('displayForm', false);
     $error = null;
     if (!SJB_Acl::getInstance()->isAllowed('save_' . trim($listingType))) {
         $error = 'DENIED_SAVE_LISTING';
     }
     if (SJB_UserManager::isUserLoggedIn()) {
         if (!$error) {
             if (!is_null($listingId)) {
                 if (SJB_UserManager::isUserLoggedIn()) {
                     SJB_SavedListings::saveListingOnDB($listingId, SJB_UserManager::getCurrentUserSID());
                     SJB_Statistics::addStatistics('saveListing', SJB_ListingTypeManager::getListingTypeSIDByID($listingType), $listingId);
                 } else {
                     SJB_SavedListings::saveListingInCookie($listingId);
                 }
                 $template_processor->assign('saved_listing', SJB_SavedListings::getSavedListingsByUserAndListingSid(SJB_UserManager::getCurrentUserSID(), $listingId));
             } else {
                 $error = 'LISTING_ID_NOT_SPECIFIED';
             }
         }
         $params = SJB_Request::getVar('params', false);
         $searchId = SJB_Request::getVar('searchId', false);
         $page = SJB_Request::getVar('page', false);
         $template_processor->assign("params", $params);
         $template_processor->assign("searchId", $searchId);
         $template_processor->assign("page", $page);
         $template_processor->assign("listing_type", $listingType);
         $template_processor->assign("listing_sid", $listingId);
         $template_processor->assign("from_login", SJB_Request::getVar("from_login", false));
         $template_processor->assign("error", $error);
         $template_processor->assign("displayForm", $displayForm);
         $template_processor->assign("view", SJB_Request::getVar('view'));
         $template_processor->display("save_listing.tpl");
     } else {
         $template_processor->assign("return_url", base64_encode(SJB_Navigator::getURIThis() . "&from_login=1"));
         $template_processor->assign("ajaxRelocate", true);
         $template_processor->display("../users/login.tpl");
     }
 }
예제 #5
0
 private function searchListings($requested_data, $listing_type_id)
 {
     $criteria_saver = new SJB_ListingCriteriaSaver();
     $found_listings_sids = array();
     $listing_type_sid = !empty($listing_type_id) ? SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id) : 0;
     $requireApprove = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid);
     if ($requireApprove) {
         $requested_data['status']['equal'] = 'approved';
     }
     $requested_data['active']['equal'] = '1';
     $criteria_saver->setSessionForCriteria(array_merge($criteria_saver->getCriteria(), $requested_data));
     $found_listings_sids = $this->getListingSidCollectionFromRequest($requested_data, $listing_type_sid, $criteria_saver);
     return $found_listings_sids;
 }
예제 #6
0
 /**
  * @param SJB_FormBuilderData $builderData
  * @return bool
  * @throws Exception
  */
 public static function save(SJB_FormBuilderData $builderData)
 {
     $listingTypeID = $builderData->getListingTypeID();
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
     if (!$listingTypeSID) {
         throw new Exception('Wrong listing type ID is specified');
     }
     $fieldsHolders = $builderData->getFieldsHoldersData();
     SJB_FieldsHolder::saveProcess($listingTypeSID, $fieldsHolders);
     if ($builderData->getType() == SJB_FormBuilderManager::FORM_BUILDER_TYPE_DISPLAY) {
         self::saveLayout($listingTypeID, $builderData);
     }
     return true;
 }
예제 #7
0
 public static function saveSearchOnDB($requested_data, $search_name, $user_sid, $enableNotify = false, $isAlert = false, $emailFrequency = false)
 {
     $is_alert = 0;
     if ($isAlert) {
         $is_alert = 1;
     }
     if ($enableNotify) {
         $sid = SJB_DB::query("INSERT INTO saved_searches SET user_sid = ?n, name = ?s, data = ?s, is_alert = ?s, auto_notify = '1', last_send = CURDATE(), email_frequency=?s", $user_sid, $search_name, serialize($requested_data), $is_alert, $emailFrequency);
     } else {
         $sid = SJB_DB::query("INSERT INTO saved_searches SET user_sid = ?n, name = ?s, data = ?s, is_alert = ?s, last_send = CURDATE(), email_frequency=?s", $user_sid, $search_name, serialize($requested_data), $is_alert, $emailFrequency);
     }
     if ($isAlert && $sid) {
         $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($requested_data['listing_type']['equal']);
         SJB_Statistics::addStatistics('addAlert', $listingTypeSID, $sid);
     }
 }
예제 #8
0
 public function __construct($requested_data, $listing_type_id, $relevance = false, $useRefine = false)
 {
     $this->_filter_data($requested_data, 'sorting_field', '/^[_\\w\\d]+$/');
     $this->_filter_data($requested_data, 'sorting_order', '/(^DESC$)|(^ASC$)/i');
     $this->_filter_data($requested_data, 'default_sorting_field', '/^[_\\w\\d]+$/');
     $this->_filter_data($requested_data, 'default_sorting_order', '/(^DESC$)|(^ASC$)/i');
     $this->requested_data = $requested_data;
     $this->listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
     $this->listing_type_id = $listing_type_id;
     $this->relevance = $relevance;
     $this->useRefine = $useRefine;
     $this->searchId = microtime(true);
     if (isset($requested_data['searchId'])) {
         $this->searchId = strip_tags($requested_data['searchId']);
     }
     $this->criteria_saver = new SJB_ListingCriteriaSaver($this->searchId);
     $this->found_listings_sids = array();
 }
예제 #9
0
 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');
 }
예제 #10
0
 public function export()
 {
     $period = SJB_Request::getVar('period', array());
     $statisticEvent = SJB_Request::getVar('filter', false);
     $listingTypeID = SJB_Request::getVar('listingTypeID', false);
     $sorting_field = SJB_Request::getVar('sorting_field', 'total');
     $sorting_order = SJB_Request::getVar('sorting_order', 'DESC');
     if (empty($statisticEvent)) {
         throw new Exception('EMPTY_PARAMETER');
     }
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
     $statistics = SJB_Statistics::getGuestAlertsStatistics($period, $listingTypeSID, $statisticEvent, $sorting_field, $sorting_order);
     if (empty($statistics)) {
         throw new Exception('NOTHING_TO_EXPORT');
     }
     SJB_StatisticsExportController::createExportDirectory();
     $i18N = SJB_I18N::getInstance();
     $exportProperties['title'] = $i18N->gettext('Backend', 'Guest Email');
     $exportProperties['total'] = $i18N->gettext('Backend', 'Total');
     $exportProperties['percent'] = '%';
     $type = SJB_Request::getVar('type', 'csv');
     $fileName = 'guest_' . strtolower($listingTypeID . '_' . $statisticEvent) . '_statistics';
     $exportData = SJB_StatisticsExportController::getGuestAlertsExportData($statistics);
     switch ($type) {
         case 'csv':
             $ext = 'csv';
             SJB_StatisticsExportController::makeCSVExportFile($exportData, $fileName . '.' . $ext, "Guest {$listingTypeID} Alerts Statistics");
             break;
         default:
         case 'xls':
             $ext = 'xls';
             SJB_StatisticsExportController::makeXLSExportFile($exportData, $fileName . '.' . $ext, "Guest {$listingTypeID} Alerts Statistics");
             break;
     }
     SJB_StatisticsExportController::archiveAndSendExportFile($fileName, $ext);
 }
예제 #11
0
 private function sendSearchedNotifications()
 {
     $savedSearches = SJB_SavedSearches::getAutoNotifySavedSearches();
     $listing = new SJB_Listing();
     $this->notifiedSavedSearchesSID = array();
     $notificationsLimit = (int) SJB_Settings::getSettingByName('num_of_listings_sent_in_email_alerts');
     foreach ($savedSearches as $savedSearch) {
         $searcher = new SJB_ListingSearcher();
         $listing->addActivationDateProperty();
         $dataSearch = unserialize($savedSearch['data']);
         $dataSearch['active']['equal'] = 1;
         $dateArray = explode('-', $savedSearch['last_send']);
         $savedSearch['last_send'] = strftime($this->lang['date_format'], mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0]));
         $dataSearch['activation_date']['not_less'] = $savedSearch['last_send'];
         $dataSearch['activation_date']['not_more'] = $this->currentDate;
         $listingTypeSID = 0;
         if ($dataSearch['listing_type']['equal']) {
             $listingTypeID = $dataSearch['listing_type']['equal'];
             $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
             if (SJB_ListingTypeManager::getWaitApproveSettingByListingType($listingTypeSID)) {
                 $dataSearch['status']['equal'] = 'approved';
             }
         }
         $idAliasInfo = $listing->addIDProperty();
         $usernameAliasInfo = $listing->addUsernameProperty();
         $listingTypeIDInfo = $listing->addListingTypeIDProperty();
         $aliases = new SJB_PropertyAliases();
         $aliases->addAlias($idAliasInfo);
         $aliases->addAlias($usernameAliasInfo);
         $aliases->addAlias($listingTypeIDInfo);
         $dataSearch['access_type'] = array('accessible' => $savedSearch['user_sid']);
         $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($dataSearch, $listing);
         $searcher->found_object_sids = array();
         $searcher->setLimit($notificationsLimit);
         $foundListingsIDs = $searcher->getObjectsSIDsByCriteria($criteria, $aliases);
         if (count($foundListingsIDs)) {
             $savedSearch['activation_date'] = $savedSearch['last_send'];
             if (SJB_Notifications::sendUserNewListingsFoundLetter($foundListingsIDs, $savedSearch['user_sid'], $savedSearch, $listingTypeSID)) {
                 SJB_Statistics::addStatistics('sentAlert', $listingTypeSID, $savedSearch['sid']);
                 SJB_DB::query('UPDATE `saved_searches` SET `last_send` = CURDATE() WHERE `sid` = ?n', $savedSearch['sid']);
             }
             $this->notifiedSavedSearchesSID[] = $savedSearch['sid'];
         }
     }
 }
예제 #12
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listing_type_id = SJB_Request::getVar('listing_type_id', false);
     $action = SJB_Request::getVar('action', false);
     $type = SJB_Request::getVar('type', false);
     $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8');
     $supportedFormats = array('xlsx', 'xls', 'csv');
     $warning = false;
     $error = '';
     if ($action == 'example' && $type) {
         $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
         $listing_field_manager = new SJB_ListingFieldManager();
         $common_details = $listing_field_manager->getCommonListingFieldsInfo();
         $extra_details = $listing_field_manager->getListingFieldsInfoByListingType($listing_type_sid);
         $listing_fields = array_merge($common_details, $extra_details);
         $directory_to_export = SJB_System::getSystemSettings('EXPORT_FILES_DIRECTORY');
         $export_properties = array();
         $export_data = array();
         foreach ($listing_fields as $listing_field) {
             $export_properties[$listing_field['id']] = $listing_field['id'];
             $export_data[0][$listing_field['id']] = '';
         }
         SJB_ExportController::createExportDirectoriesForExample();
         switch ($type) {
             case 'exl':
                 SJB_ExportController::makeExportFile($export_data, 'example.xls');
                 $export_files_dir = SJB_Path::combine($directory_to_export, 'example.xls');
                 for ($i = 0; $i < ob_get_level(); $i++) {
                     ob_end_clean();
                 }
                 header('Content-type: application/vnd.ms-excel');
                 header('Content-disposition: attachment; filename=example.xls');
                 header('Content-Length: ' . filesize($export_files_dir));
                 readfile($export_files_dir);
                 break;
             case 'csv':
                 $export_files_dir = SJB_Path::combine($directory_to_export, 'example.csv');
                 $fp = fopen($export_files_dir, 'w');
                 fputcsv($fp, explode(',', implode(',', $export_properties)));
                 fclose($fp);
                 for ($i = 0; $i < ob_get_level(); $i++) {
                     ob_end_clean();
                 }
                 header('Content-type: application/vnd.ms-excel');
                 header('Content-disposition: attachment; filename=example.csv');
                 header('Content-Length: ' . filesize($export_files_dir));
                 readfile($export_files_dir);
                 break;
         }
         SJB_Filesystem::delete($directory_to_export);
         exit;
     }
     if ($productsInfo = $this->canCurrentUserAddListing($error)) {
         $acl = SJB_Acl::getInstance();
         if ($acl->isAllowed('bulk_job_import') == true) {
             $fileInfo = null;
             if (isset($_FILES['import_file'])) {
                 $extension = strtolower(substr(strrchr($_FILES['import_file']['name'], '.'), 1));
                 if (empty($_FILES['import_file']['name']) || !in_array($extension, $supportedFormats)) {
                     $warning = 'Please choose Excel or csv file';
                 } else {
                     $fileInfo = $_FILES['import_file'];
                 }
             }
             $contractID = SJB_Request::getVar('contract_id', false);
             $current_user = SJB_UserManager::getCurrentUser();
             if ($contractID) {
                 $contract = new SJB_Contract(array('contract_id' => $contractID));
             } elseif (count($productsInfo) == 1) {
                 $productInfo = array_pop($productsInfo);
                 $contractID = $productInfo['contract_id'];
                 $contract = new SJB_Contract(array('contract_id' => $contractID));
             } else {
                 $tp->assign("products_info", $productsInfo);
                 $tp->assign("listing_type_id", $listing_type_id);
                 $tp->display("listing_product_choice.tpl");
             }
             if ($contractID && $listing_type_id) {
                 $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
                 if ($fileInfo) {
                     switch ($extension) {
                         case 'xls':
                         case 'xlsx':
                             $import_file = new SJB_ImportFileXLS($fileInfo);
                             break;
                         case 'csv':
                             $import_file = new SJB_ImportFileCSV($fileInfo, ',');
                             break;
                     }
                     $import_file->parse($encodingFromCharset);
                     $bulkPermissionParam = $this->acl->getPermissionParams('post_' . $listing_type_id, $contract->getID(), 'contract');
                     $imported_data = $import_file->getData();
                     $countData = 0;
                     foreach ($imported_data as $val) {
                         if ($val) {
                             $countData++;
                         }
                     }
                     if (empty($bulkPermissionParam) || $bulkPermissionParam - $contract->getPostingsNumber() - ($countData - 1) >= 0) {
                         $listing = new SJB_Listing(array(), $listing_type_sid);
                         $count = 0;
                         $listingSIDs = array();
                         foreach ($imported_data as $key => $importedColumn) {
                             if ($key == 1) {
                                 $imported_data_processor = new SJB_ImportedDataProcessor($importedColumn, $listing);
                                 continue;
                             }
                             if (!$importedColumn) {
                                 continue;
                             }
                             $count++;
                             $listing_info = $imported_data_processor->getData('ignore', $importedColumn);
                             $doc = new DOMDocument();
                             foreach ($listing->getProperties() as $property) {
                                 if ($property->getType() == 'complex' && !empty($listing_info[$property->id])) {
                                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                                     $doc->loadXML($listing_info[$property->id]);
                                     $results = $doc->getElementsByTagName($property->id . 's');
                                     $listing_info[$property->id] = array();
                                     foreach ($results as $complexparent) {
                                         $i = 0;
                                         foreach ($complexparent->getElementsByTagName($property->id) as $result) {
                                             $resultXML = simplexml_import_dom($result);
                                             foreach ($childFields as $childField) {
                                                 if (isset($resultXML->{$childField}['id'])) {
                                                     $listing_info[$property->id][$childField['id']][$i] = (string) $resultXML->{$childField}['id'];
                                                 }
                                             }
                                             $i++;
                                         }
                                     }
                                 } elseif ($property->getType() == 'location') {
                                     $locationFields = array($property->id . '.Country', $property->id . '.State', $property->id . '.City', $property->id . '.ZipCode');
                                     $locationFieldAdded = array();
                                     foreach ($locationFields as $locationField) {
                                         if (array_key_exists($locationField, $listing_info)) {
                                             switch ($locationField) {
                                                 case $property->id . '.Country':
                                                     $value = SJB_CountriesManager::getCountrySIDByCountryName($listing_info[$locationField]);
                                                     if (!$value) {
                                                         $value = SJB_CountriesManager::getCountrySIDByCountryCode($listing_info[$locationField]);
                                                     }
                                                     break;
                                                 case $property->id . '.State':
                                                     $value = SJB_StatesManager::getStateSIDByStateName($listing_info[$locationField]);
                                                     if (!$value) {
                                                         $value = SJB_StatesManager::getStateSIDByStateCode($listing_info[$locationField]);
                                                     }
                                                     break;
                                                 default:
                                                     $value = $listing_info[$locationField];
                                                     break;
                                             }
                                             $listing_info[$property->id][str_replace($property->id . '.', '', $locationField)] = $value;
                                             $locationFieldAdded[] = str_replace($property->id . '.', '', $locationField);
                                         }
                                     }
                                     if ($property->id == 'Location') {
                                         $locationFields = array('Country', 'State', 'City', 'ZipCode');
                                         foreach ($locationFields as $locationField) {
                                             if (array_key_exists($locationField, $listing_info) && !in_array($locationField, $locationFieldAdded) && !$listing->getProperty($locationField)) {
                                                 switch ($locationField) {
                                                     case 'Country':
                                                         $value = SJB_CountriesManager::getCountrySIDByCountryName($listing_info[$locationField]);
                                                         if (!$value) {
                                                             $value = SJB_CountriesManager::getCountrySIDByCountryCode($listing_info[$locationField]);
                                                         }
                                                         break;
                                                     case 'State':
                                                         $value = SJB_StatesManager::getStateSIDByStateName($listing_info[$locationField]);
                                                         if (!$value) {
                                                             $value = SJB_StatesManager::getStateSIDByStateCode($listing_info[$locationField]);
                                                         }
                                                         break;
                                                     default:
                                                         $value = $listing_info[$locationField];
                                                         break;
                                                 }
                                                 $listing_info[$property->id][$locationField] = $value;
                                             }
                                         }
                                     }
                                 }
                             }
                             $field_info = null;
                             $listing = new SJB_Listing($listing_info, $listing_type_sid);
                             foreach ($listing->getProperties() as $property) {
                                 if ($property->getType() == 'tree' && $property->value !== '') {
                                     $treeValues = explode(',', $property->value);
                                     $treeSIDs = array();
                                     foreach ($treeValues as $treeValue) {
                                         $info = SJB_ListingFieldTreeManager::getItemInfoByCaption($property->sid, trim($treeValue));
                                         $treeSIDs[] = $info['sid'];
                                     }
                                     $listing->setPropertyValue($property->id, implode(',', $treeSIDs));
                                     $listing->details->properties[$property->id]->type->property_info['value'] = implode(',', $treeSIDs);
                                 } elseif ($property->getType() == 'monetary') {
                                     $currency = SJB_CurrencyManager::getDefaultCurrency();
                                     $listing->details->properties[$property->id]->type->property_info['value']['add_parameter'] = $currency['sid'];
                                 } elseif ($property->id == 'ApplicationSettings' && !empty($listing_info['ApplicationSettings'])) {
                                     if (preg_match("^[a-z0-9\\._-]+@[a-z0-9\\._-]+\\.[a-z]{2,}\$^iu", $listing_info['ApplicationSettings'])) {
                                         $listing_info['ApplicationSettings'] = array('value' => $listing_info['ApplicationSettings'], 'add_parameter' => 1);
                                     } elseif (preg_match("^(https?:\\/\\/)^iu", $listing_info['ApplicationSettings'])) {
                                         $listing_info['ApplicationSettings'] = array('value' => $listing_info['ApplicationSettings'], 'add_parameter' => 2);
                                     } else {
                                         $listing_info['ApplicationSettings'] = array('value' => '', 'add_parameter' => '');
                                     }
                                     $listing->details->properties[$property->id]->type->property_info['value'] = $listing_info['ApplicationSettings'];
                                 } elseif ($property->getType() == 'complex' && is_array($property->value)) {
                                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                                     $complexChildValues = $property->value;
                                     foreach ($childFields as $childField) {
                                         if ($childField['type'] == 'complexfile' && !empty($complexChildValues[$childField['id']])) {
                                             $field_info = SJB_ListingComplexFieldManager::getFieldInfoBySID($childField['sid']);
                                             if (isset($listing_info[$property->id][$field_info['id']]) && file_exists($listing_info[$property->id][$field_info['id']])) {
                                                 SJB_UploadFileManager::fileImport($listing_info, $field_info, $property->id);
                                             }
                                         }
                                     }
                                 }
                                 // The import of files at import of listings
                                 if (in_array($property->getType(), array('file', 'logo', 'picture', 'video')) && $property->value !== '') {
                                     $field_info = SJB_ListingFieldDBManager::getListingFieldInfoByID($property->id);
                                     if (isset($listing_info[$field_info['id']]) && file_exists($listing_info[$field_info['id']])) {
                                         SJB_UploadFileManager::fileImport($listing_info, $field_info);
                                     }
                                 }
                             }
                             $listing->deleteProperty('featured');
                             $listing->deleteProperty('priority');
                             $listing->deleteProperty('status');
                             $listing->deleteProperty('reject_reason');
                             $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contract->getID(), 'is_system' => true));
                             $extraInfo = $contract->extra_info;
                             $listing->setProductInfo($extraInfo);
                             $listing->setPropertyValue('access_type', 'everyone');
                             $listing->setUserSID($current_user->sid);
                             if ($current_user->isSubuser()) {
                                 $subuserInfo = $current_user->getSubuserInfo();
                                 $listing->addSubuserProperty($subuserInfo['sid']);
                             }
                             SJB_ListingManager::saveListing($listing);
                             SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']);
                             $contract->incrementPostingsNumber();
                             SJB_ProductsManager::incrementPostingsNumber($contract->product_sid);
                             if (!empty($extraInfo['featured'])) {
                                 SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                             }
                             if (!empty($extraInfo['priority'])) {
                                 SJB_ListingManager::makePriorityBySID($listing->getSID());
                             }
                             $this->FillGallery($listing, $listing_info);
                             $listingSIDs[] = $listing->getSID();
                         }
                         SJB_ListingManager::activateListingBySID($listingSIDs);
                         $tp->assign('listingsNum', count($listingSIDs));
                         $tp->display('job_import_complete.tpl');
                     } else {
                         $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
                         $error = 'LISTINGS_NUMBER_LIMIT_EXCEEDED';
                         $tp->assign('listing_type_id', $listing_type_id);
                         $tp->assign('error', $error);
                         $tp->display('job_import.tpl');
                     }
                 } else {
                     $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
                     $tp->assign('warning', $warning);
                     $tp->assign('contract_id', $contractID);
                     $tp->assign('listing_type_id', $listing_type_id);
                     $tp->display('job_import.tpl');
                 }
             }
         } else {
             $error = $acl->getPermissionMessage('bulk_job_import');
             if (empty($error)) {
                 $error = 'This action is not allowed within your current product';
             }
             $tp->assign('error', $error);
             $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
             $tp->assign('listing_type_id', $listing_type_id);
             $tp->display('job_import.tpl');
         }
     } else {
         if ($error == 'NO_CONTRACT') {
             if ($_GET) {
                 $getParam = '?';
                 foreach ($_GET as $key => $val) {
                     $getParam .= $key . '=' . $val . '&';
                 }
                 $getParam = substr($getParam, 0, -1);
             }
             $page = base64_encode(SJB_System::getURI() . $getParam);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-products/?page=' . $page);
         }
         $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
         $tp->assign('listing_type_id', $listing_type_id);
         $tp->assign('error', $error);
         $tp->display('job_import.tpl');
     }
 }
예제 #13
0
 public function execute()
 {
     if (!function_exists('_filter_data')) {
         function _filter_data(&$array, $key, $pattern)
         {
             if (isset($array[$key])) {
                 if (!preg_match($pattern, $array[$key])) {
                     unset($array[$key]);
                 }
             }
         }
     }
     _filter_data($_REQUEST, 'sorting_field', "/^[_\\w\\d]+\$/");
     _filter_data($_REQUEST, 'sorting_order', "/(^DESC\$)|(^ASC\$)/i");
     _filter_data($_REQUEST, 'default_sorting_field', "/^[_\\w\\d]+\$/");
     _filter_data($_REQUEST, 'default_sorting_order', "/(^DESC\$)|(^ASC\$)/i");
     $tp = SJB_System::getTemplateProcessor();
     if (!SJB_UserManager::isUserLoggedIn()) {
         $errors['NOT_LOGGED_IN'] = true;
         $tp->assign("ERRORS", $errors);
         $tp->display("error.tpl");
         return;
     }
     $this->defineRequestedListingTypeID();
     if (!$this->listingTypeID) {
         $tp->assign('listingTypes', SJB_ListingTypeManager::getAllListingTypesInfo());
         $tp->display('my_available_listing_types.tpl');
         return;
     }
     $this->listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
     if (!$this->listingTypeSID) {
         SJB_HelperFunctions::redirect(SJB_HelperFunctions::getSiteUrl() . '/my-listings/');
         return;
     }
     $currentUser = SJB_UserManager::getCurrentUser();
     $userSID = $currentUser->getSID();
     $this->requestCriteria = array('user_sid' => array('equal' => $userSID), 'listing_type_sid' => array('equal' => $this->listingTypeSID));
     $acl = SJB_Acl::getInstance();
     if ($currentUser->isSubuser()) {
         $subUserInfo = $currentUser->getSubuserInfo();
         if (!$acl->isAllowed('subuser_manage_listings', $subUserInfo['sid'])) {
             $this->requestCriteria['subuser_sid'] = array('equal' => $subUserInfo['sid']);
         }
     }
     SJB_ListingManager::deletePreviewListingsByUserSID($userSID);
     $searcher = new SJB_ListingSearcher();
     // to save criteria in the session different from search_results
     $criteriaSaver = new SJB_ListingCriteriaSaver('MyListings');
     if (isset($_REQUEST['restore'])) {
         $_REQUEST = array_merge($_REQUEST, $criteriaSaver->getCriteria());
     }
     if (isset($_REQUEST['listings'])) {
         $listingsSIDs = $_REQUEST['listings'];
         if (isset($_REQUEST['action_deactivate'])) {
             $this->executeAction($listingsSIDs, 'deactivate');
         } elseif (isset($_REQUEST['action_activate'])) {
             $redirectToShoppingCard = false;
             $activatedListings = array();
             foreach ($listingsSIDs as $listingSID => $value) {
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingSID);
                 $productInfo = !empty($listingInfo['product_info']) ? unserialize($listingInfo['product_info']) : array();
                 if ($listingInfo['active']) {
                     continue;
                 } else {
                     if (SJB_ListingManager::getIfListingHasExpiredBySID($listingSID) && isset($productInfo['renewal_price']) && $productInfo['renewal_price'] > 0) {
                         $redirectToShoppingCard = true;
                         $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
                         $newProductName = "Reactivation of \"{$listingInfo['Title']}\" {$listingTypeId}";
                         $newProductInfo = SJB_ShoppingCart::createInfoForCustomProduct($userSID, $productInfo['product_sid'], $listingSID, $productInfo['renewal_price'], $newProductName, 'activateListing');
                         SJB_ShoppingCart::createCustomProduct($newProductInfo, $userSID);
                     } else {
                         if ($listingInfo['checkouted'] == 0) {
                             $redirectToShoppingCard = true;
                         } else {
                             if (SJB_ListingManager::activateListingBySID($listingSID, false)) {
                                 $listing = SJB_ListingManager::getObjectBySID($listingSID);
                                 SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID());
                                 $activatedListings[] = $listingSID;
                             }
                         }
                     }
                 }
             }
             SJB_BrowseDBManager::addListings($activatedListings);
             if ($redirectToShoppingCard) {
                 $shoppingUrl = SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/';
                 SJB_HelperFunctions::redirect($shoppingUrl);
             }
         } else {
             if (isset($_REQUEST['action_delete'])) {
                 $this->executeAction($listingsSIDs, 'delete');
                 $allowedPostBeforeCheckout = SJB_Settings::getSettingByName('allow_to_post_before_checkout');
                 foreach ($listingsSIDs as $listingSID => $value) {
                     if ($allowedPostBeforeCheckout == true) {
                         $this->deleteCheckoutedListingFromShopCart($listingSID, $userSID);
                     }
                 }
             } elseif (isset($_REQUEST['action_sendToApprove'])) {
                 $processListingsIds = array();
                 foreach ($listingsSIDs as $listingSID => $value) {
                     $processListingsIds[] = $listingSID;
                 }
                 SJB_ListingManager::setListingApprovalStatus($processListingsIds, 'pending');
             }
         }
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/my-listings/{$this->listingTypeID}/");
     }
     $listing = new SJB_Listing(array(), $this->listingTypeSID);
     $idAliasInfo = $listing->addIDProperty();
     $listing->addActivationDateProperty();
     $listing->addKeywordsProperty();
     $listing->addPicturesProperty();
     $listingTypeIdAliasInfo = $listing->addListingTypeIDProperty();
     $sortingFields = array();
     $innerJoin = array();
     $sortingField = SJB_Request::getVar("sorting_field", null);
     $sortingOrder = SJB_Request::getVar("sorting_order", null);
     if (isset($sortingField, $sortingOrder)) {
         $orderInfo = array('sorting_field' => $sortingField, 'sorting_order' => $sortingOrder);
     } else {
         $orderInfo = $criteriaSaver->getOrderInfo();
     }
     if ($orderInfo['sorting_field'] == 'applications') {
         $innerJoin['applications'] = array('count' => 'count(`applications`.id) as appCount', 'join' => 'LEFT JOIN', 'join_field' => 'listing_id', 'join_field2' => 'sid', 'main_table' => 'listings');
         $sortingFields['appCount'] = $orderInfo['sorting_order'];
         $searcher->setGroupByField(array('listings' => 'sid'));
     } else {
         if ($orderInfo['sorting_field'] == 'id') {
             $sortingFields['sid'] = $orderInfo['sorting_order'];
         } else {
             if ($orderInfo['sorting_field'] == 'subuser_sid') {
                 $innerJoin['users'] = array('join' => 'LEFT JOIN', 'join_field' => 'sid', 'join_field2' => 'subuser_sid', 'main_table' => 'listings');
                 $sortingFields['username'] = $orderInfo['sorting_order'];
             } else {
                 $property = $listing->getProperty($sortingField);
                 if (!empty($property) && $property->isSystem()) {
                     $sortingFields[$orderInfo['sorting_field']] = $orderInfo['sorting_order'];
                 } else {
                     $sortingFields['activation_date'] = 'DESC';
                 }
             }
         }
     }
     $this->requestCriteria['sorting_field'] = $orderInfo['sorting_field'];
     $this->requestCriteria['sorting_order'] = $orderInfo['sorting_order'];
     $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData(array_merge($_REQUEST, $this->requestCriteria), $listing);
     $aliases = new SJB_PropertyAliases();
     $aliases->addAlias($idAliasInfo);
     $aliases->addAlias($listingTypeIdAliasInfo);
     $foundListingsSIDs = $searcher->getObjectsSIDsByCriteria($criteria, $aliases, $sortingFields, $innerJoin);
     $searchFormBuilder = new SJB_SearchFormBuilder($listing);
     $searchFormBuilder->registerTags($tp);
     $searchFormBuilder->setCriteria($criteria);
     // получим информацию о имеющихся листингах
     $listingsInfo = array();
     $currentUserInfo = SJB_UserManager::getCurrentUserInfo();
     $contractInfo['extra_info']['listing_amount'] = 0;
     if ($acl->isAllowed('post_' . $this->listingTypeID)) {
         $permissionParam = $acl->getPermissionParams('post_' . $this->listingTypeID);
         if (empty($permissionParam)) {
             $contractInfo['extra_info']['listing_amount'] = 'unlimited';
         } else {
             $contractInfo['extra_info']['listing_amount'] = $permissionParam;
         }
     }
     $currentUser = SJB_UserManager::getCurrentUser();
     $contractsSIDs = $currentUser->getContractID();
     $listingsInfo['listingsNum'] = SJB_ContractManager::getListingsNumberByContractSIDsListingType($contractsSIDs, $this->listingTypeID);
     $listingsInfo['listingsMax'] = $contractInfo['extra_info']['listing_amount'];
     if ($listingsInfo['listingsMax'] === 'unlimited') {
         $listingsInfo['listingsLeft'] = 'unlimited';
     } else {
         $listingsInfo['listingsLeft'] = $listingsInfo['listingsMax'] - $listingsInfo['listingsNum'];
         $listingsInfo['listingsLeft'] = $listingsInfo['listingsLeft'] < 0 ? 0 : $listingsInfo['listingsLeft'];
     }
     $tp->assign('listingTypeID', $this->listingTypeID);
     $tp->assign('listingTypeName', SJB_ListingTypeManager::getListingTypeNameBySID($this->listingTypeSID));
     $tp->assign('listingsInfo', $listingsInfo);
     $tp->display('my_listings_form.tpl');
     $page = SJB_Request::getVar('page', 1);
     $listingsPerPage = $criteriaSaver->getListingsPerPage();
     //save 'listings per page' in the session
     if (empty($listingsPerPage)) {
         $listingsPerPage = 10;
     }
     $listingsPerPage = SJB_Request::getVar('listings_per_page', $listingsPerPage);
     $criteriaSaver->setSessionForListingsPerPage($listingsPerPage);
     $criteriaSaver->setSessionForCurrentPage($page);
     $criteriaSaver->setSessionForCriteria($_REQUEST);
     $criteriaSaver->setSessionForOrderInfo($orderInfo);
     $criteriaSaver->setSessionForObjectSIDs($foundListingsSIDs);
     // get Applications
     $appsGroups = SJB_Applications::getAppGroupsByEmployer($currentUserInfo['sid']);
     $apps = array();
     foreach ($appsGroups as $group) {
         $apps[$group['listing_id']] = $group['count'];
     }
     $searchCriteriaStructure = $criteriaSaver->createTemplateStructureForCriteria();
     $listingSearchStructure = $criteriaSaver->createTemplateStructureForSearch();
     /**************** P A G I N G *****************/
     if ($listingSearchStructure['current_page'] > $listingSearchStructure['pages_number']) {
         $listingSearchStructure['current_page'] = $listingSearchStructure['pages_number'];
     }
     if ($listingSearchStructure['current_page'] < 1) {
         $listingSearchStructure['current_page'] = 1;
     }
     $sortedFoundListingsSIDsByPages = array_chunk($foundListingsSIDs, $listingSearchStructure['listings_per_page'], true);
     /************* S T R U C T U R E **************/
     $listingsStructure = array();
     $listingStructureMetaData = array();
     if (isset($sortedFoundListingsSIDsByPages[$listingSearchStructure['current_page'] - 1])) {
         foreach ($sortedFoundListingsSIDsByPages[$listingSearchStructure['current_page'] - 1] as $sid) {
             $listing = SJB_ListingManager::getObjectBySID($sid);
             $listing->addPicturesProperty();
             $listingStructure = SJB_ListingManager::createTemplateStructureForListing($listing);
             $listingsStructure[$listing->getID()] = $listingStructure;
             if (isset($listingStructure['METADATA'])) {
                 $listingStructureMetaData = array_merge($listingStructureMetaData, $listingStructure['METADATA']);
             }
         }
     }
     /*************** D I S P L A Y ****************/
     $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
     $metadata = array();
     $metadata['listing'] = $metaDataProvider->getMetaData($listingStructureMetaData);
     $waitApprove = SJB_ListingTypeManager::getWaitApproveSettingByListingType($this->listingTypeSID);
     $tp->assign('show_rates', SJB_Settings::getSettingByName('show_rates'));
     $tp->assign('show_comments', SJB_Settings::getSettingByName('show_comments'));
     $tp->assign('METADATA', $metadata);
     $tp->assign('sorting_field', $listingSearchStructure['sorting_field']);
     $tp->assign('sorting_order', $listingSearchStructure['sorting_order']);
     $tp->assign('property', $this->getSortableProperties());
     $tp->assign('listing_search', $listingSearchStructure);
     $tp->assign('search_criteria', $searchCriteriaStructure);
     $tp->assign('listings', $listingsStructure);
     $tp->assign('waitApprove', $waitApprove);
     $tp->assign('apps', $apps);
     $hasSubusersWithListings = false;
     $subusers = SJB_UserManager::getSubusers($currentUserInfo['sid']);
     foreach ($subusers as $subuser) {
         if ($acl->isAllowed('subuser_add_listings', $subuser['sid']) || $acl->isAllowed('subuser_manage_listings', $subuser['sid'])) {
             $hasSubusersWithListings = true;
             break;
         }
     }
     $tp->assign('hasSubusersWithListings', $hasSubusersWithListings);
     $tp->display('my_listings.tpl');
 }
예제 #14
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template = SJB_Request::getVar('display_template');
     $page = 1;
     $searchId = strip_tags(SJB_Request::getVar('searchId', time()));
     if (!empty($_REQUEST["page"])) {
         $page = intval($_REQUEST["page"]);
     }
     $items_per_page = SJB_Request::getVar('companies_per_page', false);
     $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($_REQUEST["listing_type_id"]);
     $alphabets = SJB_AlphabetManager::getAlphabetsForDisplay();
     $abArr = array();
     foreach ($alphabets as $alphabet) {
         $abArr[] = explode(' ', $alphabet['value']);
     }
     $action = SJB_Request::getVar('action', 'search_form');
     if (SJB_Request::getVar('first_char')) {
         $action = 'search';
         $_REQUEST['CompanyName']['first_char_like'] = SJB_Request::getVar('first_char');
     } elseif (!isset($_REQUEST['CompanyName']) || $_REQUEST['CompanyName']['like'] == '') {
         $_REQUEST['CompanyName']['not_empty'] = true;
     }
     $userGroupSid = SJB_UserGroupManager::getUserGroupSIDByID('Employer');
     $userGroupFields = SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($userGroupSid);
     foreach ($userGroupFields as $key => $userGroupField) {
         if ($userGroupField['type'] == 'location') {
             $userGroupFields[$key]['fields'] = array();
             $userGroupFields[$key]['fields'][$userGroupField['sid']] = $userGroupField;
         }
     }
     $user = new SJB_User(array(), $userGroupSid);
     $_REQUEST['active']['equal'] = 1;
     $search_form_builder = new SJB_SearchFormBuilder($user);
     $criteria_saver = new SJB_UserCriteriaSaver($searchId);
     $criteria_saver->setSessionForOrderInfo($_REQUEST);
     if (isset($_REQUEST['searchId'])) {
         $action = 'search';
         $criteria = $criteria_saver->getCriteria();
         if (!empty($_REQUEST['sorting_field'])) {
             unset($criteria['sorting_field']);
         } else {
             $orderInfo = $criteria_saver->getOrderInfo();
             if (!empty($orderInfo['sorting_order'])) {
                 $criteria['sorting_order'] = $orderInfo['sorting_order'];
             }
         }
         $_REQUEST = array_merge($_REQUEST, $criteria);
         if (!$items_per_page) {
             $items_per_page = $criteria_saver->listings_per_page;
         }
     }
     $items_per_page = $items_per_page ? $items_per_page : 10;
     $criteria = $search_form_builder->extractCriteriaFromRequestData(array_merge($_REQUEST, array('username' => array('not_equal' => 'jobg8'))), $user);
     if ($items_per_page) {
         $criteria_saver->setSessionForListingsPerPage($items_per_page);
     }
     $search_form_builder->setCriteria($criteria);
     $search_form_builder->registerTags($tp);
     $form_fields = $search_form_builder->getFormFieldsInfo();
     $tp->assign('form_fields', $form_fields);
     $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
     $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
     $tp->assign('userGroupFields', $userGroupFields);
     $tp->assign('action', $action);
     $tp->assign('alphabets', $abArr);
     if ($action == 'search') {
         $sorting_field = SJB_Request::getVar('sorting_field', false);
         $sorting_order = SJB_Request::getVar('sorting_order', false);
         if (isset($_REQUEST['searchId']) && !$sorting_field) {
             $order_info = $criteria_saver->order_info;
             if ($order_info) {
                 $sorting_field = $order_info['sorting_field'];
                 $sorting_order = $order_info['sorting_order'];
             }
         }
         if (!$sorting_field) {
             $sorting_field = 'CompanyName';
             $sorting_order = 'ASC';
         }
         $inner_join = array();
         if ($sorting_field == 'number_of_jobs') {
             if (SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid) == 1) {
                 $count = "sum( if( `listings`.`status` = 'approved', `listings`.`active`, 0 ) )";
             } else {
                 $count = "sum(`listings`.`active`)";
             }
             $inner_join = array('listings' => array('sort_field' => $count, 'noPresix' => true, 'join_field' => 'user_sid', 'join_field2' => 'sid', 'join' => 'LEFT JOIN', 'groupBy' => '`users`.`sid`'));
         } elseif ($sorting_field == 'Location_State') {
             $inner_join = array('states' => array('sort_field' => 'state_name', 'noPresix' => true, 'join_field' => 'sid', 'join_field2' => 'Location_State', 'join' => 'LEFT JOIN'));
         }
         $searcher = new SJB_UserSearcher(false, $sorting_field, $sorting_order, $inner_join, array('limit' => ($page - 1) * $items_per_page, 'num_rows' => $items_per_page));
         $found_users = array();
         $found_users_sids = array();
         $found_users_by_criteria = $searcher->getObjectsByCriteria($criteria, null, array(), true);
         $foundObjectSIDs = $searcher->getFoundObjectSIDs();
         // display search form
         $tp->display($template);
         $criteria_saver->setSession($_REQUEST, $foundObjectSIDs);
         if (count($foundObjectSIDs) > 0) {
             $listingType = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_type_sid);
             $countListings = SJB_ListingDBManager::getActiveAndApproveJobsNumberForUsers($foundObjectSIDs, $listingType);
         }
         foreach ($found_users_by_criteria as $id => $user) {
             $listingsNumber = isset($countListings[$id]) ? $countListings[$id] : 0;
             $user->addProperty(array('id' => 'countListings', 'type' => 'string', 'value' => $listingsNumber));
             if ($user->getProperty('CompanyName')) {
                 $found_users_sids[$user->getSID()] = $user->getSID();
                 $found_users[$id] = $user;
             }
         }
         $usersCount = $searcher->getAffectedRows();
         $form_collection = new SJB_FormCollection($found_users);
         $form_collection->registerTags($tp);
         $pages = array();
         for ($i = $page - 3; $i < $page + 3; $i++) {
             if ($i > 0) {
                 $pages[] = $i;
             }
             if ($i * $items_per_page > $usersCount) {
                 break;
             }
         }
         $totalPages = ceil($usersCount / $items_per_page);
         if (empty($totalPages)) {
             $totalPages = 1;
         }
         if (array_search(1, $pages) === false) {
             array_unshift($pages, 1);
         }
         if (array_search($totalPages, $pages) === false) {
             array_push($pages, $totalPages);
         }
         $tp->assign("sorting_order", $sorting_order);
         $tp->assign("sorting_field", $sorting_field);
         $tp->assign("found_users_sids", $found_users_sids);
         $tp->assign("companies_per_page", $items_per_page);
         $tp->assign("searchId", $searchId);
         $tp->assign("usersCount", $usersCount);
         $tp->assign("current_page", $page);
         $tp->assign("pages_number", $totalPages);
         $tp->display('search_result_company.tpl');
     } else {
         // display search form
         $tp->display($template);
     }
 }
예제 #15
0
 private function _getRequestdata(array $parameters)
 {
     $res = array();
     for ($i = 0; $i < $this->getLevel(); $i++) {
         $value = $this->_getValue($i);
         $filterItem = $this->schema[$i];
         $field = $filterItem['field'];
         $parent = isset($parameters['parent']) ? $parameters['parent'] : false;
         $this->type = $filterItem['type'];
         switch ($filterItem['type']) {
             case 'tree':
                 $sids = SJB_ListingFieldTreeManager::getChildrenSIDBySID($value);
                 $sids = array_merge($sids, array($value));
                 $sids = implode(",", $sids);
                 $res[$field]['tree'] = $sids;
                 break;
             case 'string':
             case 'integer':
                 $res[$field]['equal'] = $value;
             case 'list':
             case 'multilist':
                 if ($parent && in_array($field, array($parent . '_State', $parent . '_Country'))) {
                     $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($filterItem['sid']);
                     if ($field == $parent . '_State') {
                         $listValues = SJB_StatesManager::getHashedListItems($fieldInfo['display_as']);
                     } elseif ($field == $parent . '_Country') {
                         $listValues = SJB_CountriesManager::getHashedListItems($fieldInfo['display_as']);
                     }
                 } else {
                     $listingFieldListItemManager = SJB_ObjectMother::createListingFieldListItemManager();
                     $listValues = $listingFieldListItemManager->getHashedListItemsByFieldSID($filterItem['sid']);
                 }
                 foreach ($listValues as $id => $val) {
                     if (strtolower($val) == strtolower($value)) {
                         $value = $id;
                     }
                 }
                 if ($filterItem['type'] == 'multilist') {
                     $res[$field]['multi_like'][] = $value;
                 } else {
                     $res[$field]['equal'] = $value;
                 }
                 break;
         }
     }
     $res['active']['equal'] = 1;
     if (!empty($this->listing_type_id)) {
         $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($this->listing_type_id);
         if (!$listing_type_sid) {
             trigger_error("Can't set filter by listing type for unknown type: '" . $this->listing_type_id . "'.", E_USER_WARNING);
         }
         $res['listing_type_sid']['equal'] = $listing_type_sid;
         if (SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid)) {
             $res['status']['equal'] = 'approved';
         }
     }
     return $res;
 }
예제 #16
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $current_user = SJB_UserManager::getCurrentUser();
         if ($current_user->isSubuser()) {
             // У саб-юзера должны быть свои алерты
             $current_user = $current_user->getSubuserInfo();
         } else {
             $current_user = SJB_UserManager::getCurrentUserInfo();
         }
         $listing_type_id = '';
         /************************************************************/
         $tp = SJB_System::getTemplateProcessor();
         $tp->assign('action', 'list');
         $errors = array();
         $redirectUri = '/saved-searches/';
         if (isset($_REQUEST['is_alert'])) {
             if (isset($_REQUEST['listing_type_id'])) {
                 $listing_type_id = $_REQUEST['listing_type_id'];
                 SJB_Session::setValue('listing_type_id', $listing_type_id);
             } elseif (isset($_REQUEST['restore'])) {
                 $listing_type_id = SJB_Session::getValue('listing_type_id');
             } else {
                 SJB_Session::setValue('listing_type_id', null);
             }
             if (!SJB_Acl::getInstance()->isAllowed("use_{$listing_type_id}_alerts")) {
                 $errors = array('NOT_SUBSCRIBE' => true);
                 $tp->assign('ERRORS', $errors);
                 $tp->display('error.tpl');
                 return;
             } else {
                 $redirectUri = '/' . strtolower($listing_type_id) . '-alerts/';
             }
         } else {
             if (isset($_REQUEST['listing_type_id'])) {
                 $listing_type_id = $_REQUEST['listing_type_id'];
             }
             if (!SJB_Acl::getInstance()->isAllowed('save_searches')) {
                 $errors = array('NOT_SUBSCRIBE' => true);
                 $tp->assign('ERRORS', $errors);
                 $tp->display('error.tpl');
                 return;
             }
         }
         $isSubmittedForm = SJB_Request::getVar('submit', false);
         $listing_type_sid = !empty($listing_type_id) ? SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id) : 0;
         if (!isset($_REQUEST['listing_type']['equal']) && isset($listing_type_id)) {
             $_REQUEST['listing_type']['equal'] = $listing_type_id;
         }
         $action = SJB_Request::getVar('action', 'list');
         switch ($action) {
             case 'save':
                 if ($isSubmittedForm) {
                     $search_name = SJB_Request::getVar('name');
                     $emailFrequency = SJB_Request::getVar('email_frequency');
                     if (empty($search_name['equal'])) {
                         $errors['EMPTY_VALUE'] = 1;
                         $tp->assign('action', 'save');
                     } else {
                         unset($_REQUEST['name']);
                         unset($_REQUEST['email_frequency']);
                         if ($emailFrequency) {
                             $emailFrequency = array_pop($emailFrequency);
                             $emailFrequency = '&email_frequency=' . array_pop($emailFrequency);
                         } else {
                             $emailFrequency = '';
                         }
                         $search_name = $search_name['equal'];
                         $searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id);
                         $tp = $searchResultsTP->getChargedTemplateProcessor();
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/save-search/?alert=true&url=' . $redirectUri . '&action=save&search_name=' . $search_name . '&searchId=' . $searchResultsTP->searchId . $emailFrequency);
                     }
                 } else {
                     $tp->assign('action', 'save');
                 }
                 break;
             case 'edit':
                 if (isset($_REQUEST['id_saved'])) {
                     if ($isSubmittedForm) {
                         $id_saved = $_REQUEST['id_saved'];
                         $name = $_REQUEST['name'];
                         $search_name = SJB_Request::getVar('name');
                         $emailFrequency = SJB_Request::getVar('email_frequency');
                         if (empty($search_name['equal'])) {
                             $errors['EMPTY_VALUE'] = 1;
                         } else {
                             unset($_REQUEST['name']);
                             unset($_REQUEST['email_frequency']);
                             if ($emailFrequency) {
                                 $emailFrequency = array_pop($emailFrequency);
                                 $emailFrequency = array_pop($emailFrequency);
                             } else {
                                 $emailFrequency = 'daily';
                             }
                             $searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id);
                             $tp = $searchResultsTP->getChargedTemplateProcessor();
                             $criteria_saver = new SJB_ListingCriteriaSaver($searchResultsTP->searchId);
                             $requested_data = $criteria_saver->getCriteria();
                             SJB_SavedSearches::updateSearchOnDB($requested_data, $id_saved, $current_user['sid'], $name['equal'], $emailFrequency);
                         }
                         if (!empty($errors)) {
                             $tp->assign('action', 'edit');
                             $tp->assign('id_saved', $_REQUEST['id_saved']);
                         } else {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . $redirectUri . '?alert=is_update');
                         }
                     } else {
                         $tp->assign('action', 'edit');
                         $tp->assign('id_saved', $_REQUEST['id_saved']);
                     }
                 }
                 break;
             case 'edit_alert':
                 $tp->assign('action', 'edit');
                 $tp->assign('id_saved', $_REQUEST['id_saved']);
                 break;
             case 'edit_search':
                 $tp->assign('action', 'edit');
                 $tp->assign('id_saved', $_REQUEST['id_saved']);
                 $_REQUEST['form_template'] = SJB_Request::getVar('formTemplateNem');
                 break;
             case 'new':
                 $tp->assign('action', 'save');
                 break;
             case 'delete':
                 if (isset($_REQUEST['search_id'])) {
                     $search_id = $_REQUEST['search_id'];
                     SJB_SavedSearches::deleteSearchFromDBBySID($search_id);
                 }
                 break;
             case 'disable_notify':
                 if (isset($_REQUEST['search_id'])) {
                     SJB_SavedSearches::disableSearchAutoNotify($current_user['sid'], $_REQUEST['search_id']);
                 }
                 break;
             case 'enable_notify':
                 if (isset($_REQUEST['search_id'])) {
                     SJB_SavedSearches::enableSearchAutoNotify($current_user['sid'], $_REQUEST['search_id']);
                 }
                 break;
         }
         if ($action != 'new' && $action != 'edit_alert') {
             $saved_searches = SJB_SavedSearches::getSavedSearchesFromDB($current_user['sid']);
             if (isset($_REQUEST['is_alert'])) {
                 $saved_searches = SJB_SavedSearches::getSavedJobAlertFromDB($current_user['sid']);
             }
             foreach ($saved_searches as $key => $saved_search) {
                 $saved_searches[$key]['data'] = SJB_SavedSearches::buildCriteriaFields($saved_search['data']);
                 if (isset($saved_search['data']['listing_type']['equal'])) {
                     $saved_searches[$key]['listing_type'] = $saved_search['data']['listing_type']['equal'];
                 }
             }
             $tp->assign('saved_searches', $saved_searches);
         }
         $listing = new SJB_Listing(array(), $listing_type_sid);
         $listing->addIDProperty();
         $listing->addActivationDateProperty();
         $listing->addUsernameProperty();
         $listing->addKeywordsProperty();
         $listing->addPicturesProperty();
         $listing->addEmailFrequencyProperty();
         $listing->addListingTypeIDProperty();
         $listing->addPostedWithinProperty();
         $search_form_builder = new SJB_SearchFormBuilder($listing);
         $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
         $search_form_builder->setCriteria($criteria);
         $search_form_builder->registerTags($tp);
         $form_fields = $search_form_builder->getFormFieldsInfo();
         $tp->assign('form_fields', $form_fields);
         if (!empty($_REQUEST['name'])) {
             $tp->assign('search_name', $_REQUEST['name']);
         }
         if (!empty($_REQUEST['email_frequency'])) {
             $tp->assign('email_frequency', $_REQUEST['email_frequency']);
         }
         $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
         $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
         $form_template = SJB_Request::getVar('form_template', 'search_form.tpl');
         switch (SJB_Request::getVar('alert')) {
             case 'added':
                 $tp->assign('alert_added', 'added');
                 break;
             case 'is_update':
                 $tp->assign('alert_update', 'update');
                 break;
         }
         if (!$listing_type_id && isset($saved_search['data']['listing_type']['equal'])) {
             $listing_type_id = $saved_search['data']['listing_type']['equal'];
         }
         $tp->assign('errors', $errors);
         $tp->assign('user_logged_in', true);
         $tp->assign('listing_type_id', $listing_type_id);
         $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_SEARCH, $listing_type_id);
         $formBuilder->setChargedTemplateProcessor($tp);
         $tp->display($form_template);
     } else {
         $tp->assign("ERROR", "NOT_LOGIN");
         $tp->display("../miscellaneous/error.tpl");
         return;
     }
 }
예제 #17
0
 /**
  * @param int $listingTypeSID
  * @return array
  */
 public function getInactiveFields()
 {
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->getListingTypeID());
     $aFields = array();
     if ($listingTypeSID) {
         $aFields = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeSID);
         $aFields = array_merge(SJB_ListingFieldManager::getCommonListingFieldsInfo(), $aFields);
         $this->addCustomFields($aFields);
         self::deleteActiveAndUnsearchableFields($aFields);
     }
     return $aFields;
 }
예제 #18
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['listing_type_id'])) {
         $listing_type_id = $_REQUEST['listing_type_id'];
         SJB_Session::setValue('listing_type_id', $listing_type_id);
     } elseif (isset($_REQUEST['restore'])) {
         $listing_type_id = SJB_Session::getValue('listing_type_id');
     } else {
         SJB_Session::setValue('listing_type_id', null);
     }
     $listing_type_sid = 0;
     if (!empty($listing_type_id)) {
         $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
     }
     if (!isset($_REQUEST['listing_type']['equal']) && isset($listing_type_id)) {
         $_REQUEST['listing_type']['equal'] = $listing_type_id;
     }
     if (isset($_REQUEST['searchId'])) {
         $criteria_saver = new SJB_ListingCriteriaSaver($_REQUEST['searchId']);
         $_REQUEST = array_merge($_REQUEST, $criteria_saver->getCriteria());
     }
     $empty_listing = new SJB_Listing(array(), $listing_type_sid);
     $empty_listing->addIDProperty();
     $empty_listing->addActivationDateProperty();
     $empty_listing->addUsernameProperty();
     $empty_listing->addKeywordsProperty();
     $empty_listing->addPicturesProperty();
     $empty_listing->addListingTypeIDProperty();
     $empty_listing->addPostedWithinProperty();
     $search_form_builder = new SJB_SearchFormBuilder($empty_listing);
     $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
     $properties = $empty_listing->getProperties();
     foreach ($properties as $propertyName => $property) {
         if ($property->getType() == 'location') {
             $propertyInfo = $property->type->property_info;
             if ($propertyInfo['enable_search_by_radius'] == 1) {
                 if (!isset($criteria['system'][$propertyName])) {
                     $value = array('value' => '', 'radius' => '10');
                     $criterion = SJB_SearchCriterion::getCriterionByType('location');
                     $criterion->setProperty($property);
                     $criterion->setPropertyName($propertyName);
                     $criterion->setValue($value);
                     $criteria['system'][$propertyName][] = $criterion;
                 }
             }
         }
     }
     $search_form_builder->setCriteria($criteria);
     $search_form_builder->registerTags($tp);
     $form_fields = $search_form_builder->getFormFieldsInfo();
     $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
     $template = SJB_Request::getVar('form_template', 'search_form.tpl');
     $formBuilder = SJB_FormBuilderManager::getFormBuilder(SJB_FormBuilderManager::FORM_BUILDER_TYPE_SEARCH, $listing_type_id);
     $formBuilder->setChargedTemplateProcessor($tp);
     if ($template == 'quick_search.tpl') {
         $fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('Location');
         if ($fieldSID) {
             $fields = SJB_ListingFieldManager::getFieldInfoBySID($fieldSID);
             if (!empty($fields['fields'])) {
                 foreach ($fields['fields'] as $field) {
                     $form_fields[$fields['id'] . '_' . $field['id']] = $field;
                 }
             }
             $tp->assign('locationFields', array($fields));
         }
     }
     $tp->assign('form_fields', $form_fields);
     $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
     $tp->display($template);
 }
예제 #19
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');
     }
 }
예제 #20
0
 public function execute()
 {
     header('Content-Type: text/html; charset=utf-8');
     $requestUri = $_SERVER['REQUEST_URI'];
     preg_match('(.*/autocomplete/([a-zA-Z0-9:_]*)/?)', $requestUri, $fieldParam);
     $field = !empty($fieldParam[1]) ? $fieldParam[1] : '';
     preg_match("(.*/autocomplete/{$field}/([a-zA-Z]*)/?)", $requestUri, $fieldType);
     $fieldType = !empty($fieldType[1]) ? $fieldType[1] : '';
     preg_match("(.*/autocomplete/{$field}/{$fieldType}/([a-zA-Z]*)/?)", $requestUri, $tablePrefix);
     $tablePrefix = SJB_DB::quote(!empty($tablePrefix[1]) ? $tablePrefix[1] : '');
     preg_match("(.*/autocomplete/{$field}/{$fieldType}/{$tablePrefix}/([a-zA-Z]*)/?)", $requestUri, $viewType);
     $viewType = SJB_DB::quote(!empty($viewType[1]) ? $viewType[1] : '');
     preg_match("(.*/autocomplete/{$field}/{$fieldType}/{$tablePrefix}/{$viewType}/([a-zA-Z]*)/?)", $requestUri, $listingTypeID);
     $listingTypeID = SJB_DB::quote(!empty($listingTypeID[1]) ? $listingTypeID[1] : '');
     $query = SJB_Request::getVar('q', false);
     if (!empty($query) && $field && $fieldType && $tablePrefix && $viewType && $listingTypeID) {
         $queryCriterion = $query . '%';
         if ($fieldType == 'text' && $field == 'keywords') {
             $result = SJB_DB::query('SELECT `keywords` as `value`, COUNT(*) `count` FROM `listings_keywords` WHERE `keywords` LIKE ?s AND `active` = 1 GROUP BY `keywords` ORDER BY `count` DESC LIMIT 0 , 5', $queryCriterion);
         } elseif ($fieldType == 'geo') {
             $result = SJB_DB::query('SELECT DISTINCT `name` as `value`, COUNT(*) `count` FROM `locations` WHERE `name` <> \'\' AND `name` LIKE ?s GROUP BY `value` LIMIT 0 , 100', $queryCriterion);
         } elseif ($fieldType == 'location') {
             if (preg_match('/[a-z\\d]+\\d+/i', $query)) {
                 $result = SJB_DB::query('SELECT DISTINCT `name` as `value`, `city`, `state_code`, COUNT(*) `count` FROM `locations` WHERE `name` <> \'\' AND `name` LIKE ?s GROUP BY `value`, `country_sid` LIMIT 0 , 10', $queryCriterion);
             } else {
                 $country = SJB_DB::query("SELECT `country_name` as `value` FROM `countries` WHERE `country_code` = ?s AND `active` = 1", $query);
                 $countries = SJB_DB::query("SELECT `country_name` as `value` FROM `countries` WHERE `country_name` LIKE ?s AND `country_code` != ?s AND `active` = 1", $queryCriterion, $query);
                 $countries = array_merge($country, $countries);
                 $states = SJB_DB::query("SELECT `state_name` as `value` FROM `states` INNER JOIN `countries` ON `states`.`country_sid` = `countries`.`sid` WHERE `countries`.`active` = 1 AND `states`.`state_name` LIKE ?s AND `states`.`active` = 1", $queryCriterion);
                 foreach ($states as $key => $state) {
                     $state = trim(preg_replace('/(\\s+|[^\'"_\\w\\dÀ-ÿ])/ui', '', strip_tags($state['value'])));
                     $states[$state] = $states[$key];
                     unset($states[$key]);
                 }
                 $cities = SJB_DB::query("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t`locations`.`state_code`, `city` as `value`\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t`locations`\n\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t`countries` ON `locations`.`country_sid` = `countries`.`sid`\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t\t`states` ON `locations`.`state_code` = `states`.`state_code`\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t`countries`.`active` = 1 AND\n\t\t\t\t\t\t\t`locations`.`city` LIKE ?s AND\n\t\t\t\t\t\t\t(`states`.`active` = 1 OR\n\t\t\t\t\t\t\tLENGTH(`locations`.`state_code`) = 0)", $queryCriterion);
                 foreach ($cities as $key => $city) {
                     $state = trim(preg_replace('/(\\s+|[^\'"_\\w\\dÀ-ÿ])/ui', '', strip_tags($city['state_code'])));
                     $city = trim(preg_replace('/(\\s+|[^\'"_\\w\\dÀ-ÿ])/ui', '', strip_tags($city['value'])));
                     $cities[$city][$state] = $cities[$key];
                     unset($cities[$key]);
                 }
                 $result = array();
                 $i = 0;
                 foreach ($states as $key => $state) {
                     $result[$i] = $state;
                     $i++;
                     if (isset($cities[$key])) {
                         $result[$i] = $cities[$key];
                         unset($cities[$key]);
                         $i++;
                     }
                 }
                 $result = array_merge($countries, $result);
                 $result = array_merge($result, $cities);
             }
         } elseif ($fieldType == 'string') {
             $additionalCondition = '';
             $fieldParents = explode('_', $field);
             $fieldName = array_pop($fieldParents);
             if ($fieldName == 'City') {
                 if ($viewType == 'input') {
                     $tablePrefix = 'locations';
                     $field = 'City';
                 } elseif ($viewType == 'search' && $tablePrefix == 'listings') {
                     $listingTypeSid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
                     $additionalCondition = '`listing_type_sid` = ' . $listingTypeSid . ' AND';
                 }
             }
             $result = SJB_DB::query("SELECT DISTINCT `{$field}` as `value`, COUNT(*) `count` FROM `{$tablePrefix}` WHERE " . $additionalCondition . " `{$field}` LIKE ?s GROUP BY `{$field}` ORDER BY `count` DESC LIMIT 0 , 5", $queryCriterion);
         }
         if (!empty($result)) {
             foreach ($result as $rowBase) {
                 if (empty($rowBase['value']) && is_array($rowBase)) {
                     foreach ($rowBase as $rowBase) {
                         $res = strpos(strtolower($rowBase['value']), strtolower($query));
                         if ($res !== false || $fieldType == 'location') {
                             $rowBase['value'] = trim($rowBase['value']);
                             if (isset($rowBase['city']) && isset($rowBase['state_code'])) {
                                 print $rowBase['value'] . ', ' . $rowBase['city'] . ', ' . $rowBase['state_code'] . "\n";
                             } elseif (!empty($rowBase['state_code'])) {
                                 print $rowBase['value'] . ', ' . $rowBase['state_code'] . "\n";
                             } elseif (!isset($rowBase['count'])) {
                                 print $rowBase['value'] . "\n";
                             } else {
                                 print $rowBase['value'] . '|' . $rowBase['count'] . "\n";
                             }
                         }
                     }
                 } else {
                     $res = strpos(strtolower($rowBase['value']), strtolower($query));
                     if ($res !== false || $fieldType == 'location') {
                         $rowBase['value'] = trim($rowBase['value']);
                         if (isset($rowBase['city']) && isset($rowBase['state_code'])) {
                             print $rowBase['value'] . ', ' . $rowBase['city'] . ', ' . $rowBase['state_code'] . "\n";
                         } elseif (!empty($rowBase['state_code'])) {
                             print $rowBase['value'] . ', ' . $rowBase['state_code'] . "\n";
                         } elseif (!isset($rowBase['count'])) {
                             print $rowBase['value'] . "\n";
                         } else {
                             print $rowBase['value'] . '|' . $rowBase['count'] . "\n";
                         }
                     }
                 }
             }
         }
     }
 }
예제 #21
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $template = SJB_Request::getVar('input_template', 'input_form.tpl');
     $error = null;
     $listingTypeID = SJB_Request::getVar('listing_type_id', false);
     $passed_parameters_via_uri = SJB_Request::getVar('passed_parameters_via_uri', false);
     $pageID = false;
     if ($passed_parameters_via_uri) {
         $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
         $listingTypeID = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : $listingTypeID;
         $pageID = isset($passed_parameters_via_uri[1]) ? $passed_parameters_via_uri[1] : false;
         $listing_id = isset($passed_parameters_via_uri[2]) ? $passed_parameters_via_uri[2] : false;
     }
     if (SJB_UserManager::isUserLoggedIn()) {
         $post_max_size_orig = ini_get('post_max_size');
         $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null;
         $fromPreview = SJB_Request::getVar('from-preview', false);
         // get post_max_size in bytes
         $val = trim($post_max_size_orig);
         $tmp = substr($val, strlen($val) - 1);
         $tmp = strtolower($tmp);
         /* if ini value is K - then multiply to 1024
          * if ini value is M - then multiply twice: in case 'm', and case 'k'
          * if ini value is G - then multiply tree times: in 'g', 'm', 'k'
          * out value - in bytes!
          */
         switch ($tmp) {
             case 'g':
                 $val *= 1024;
             case 'm':
                 $val *= 1024;
             case 'k':
                 $val *= 1024;
         }
         $post_max_size = $val;
         $filename = SJB_Request::getVar('filename', false);
         if ($filename) {
             $file = SJB_UploadFileManager::openFile($filename, $listing_id);
             $errors['NO_SUCH_FILE'] = true;
         }
         if (empty($_POST) && $server_content_length > $post_max_size) {
             $errors['MAX_FILE_SIZE_EXCEEDED'] = 1;
             $tp->assign('post_max_size', $post_max_size_orig);
         }
         $listingInfo = SJB_ListingManager::getListingInfoBySID($listing_id);
         $currentUser = SJB_UserManager::getCurrentUser();
         $contractID = $listingInfo['contract_id'];
         if ($contractID == 0) {
             $extraInfo = unserialize($listingInfo['product_info']);
             $productSID = $extraInfo['product_sid'];
         } else {
             $contract = new SJB_Contract(array('contract_id' => $contractID));
             $extraInfo = $contract->extra_info;
         }
         if ($listingInfo['user_sid'] != SJB_UserManager::getCurrentUserSID()) {
             $errors['NOT_OWNER_OF_LISTING'] = $listing_id;
         } else {
             $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
             $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listing_type_sid);
             if (!$pageID) {
                 $pageID = $pages[0]['page_id'];
             }
             $pageSID = SJB_PostingPagesManager::getPostingPageSIDByID($pageID, $listing_type_sid);
             $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listing_type_sid);
             // preview listing
             $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
             $form_submitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested;
             // fill listing from an array of social data if allowed
             $aAutoFillData = array('formSubmitted' => &$form_submitted, 'listingTypeID' => &$listingTypeID);
             SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
             $listingInfo = array_merge($listingInfo, $_REQUEST);
             $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID);
             if ($fromPreview) {
                 if ($form_submitted) {
                     $properties = $listing->getProperties();
                     foreach ($properties as $fieldID => $property) {
                         switch ($property->getType()) {
                             case 'date':
                                 if (!empty($listing_info[$fieldID])) {
                                     $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]);
                                 }
                                 break;
                             case 'complex':
                                 $complex = $property->type->complex;
                                 $complexProperties = $complex->getProperties();
                                 foreach ($complexProperties as $complexfieldID => $complexProperty) {
                                     if ($complexProperty->getType() == 'date') {
                                         $values = $complexProperty->getValue();
                                         foreach ($values as $index => $value) {
                                             if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) {
                                                 $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]);
                                             }
                                         }
                                     }
                                 }
                                 break;
                         }
                     }
                     $listing = new SJB_Listing($listingInfo, $listing_type_sid, $pageSID);
                 }
             }
             $previousComplexFields = $this->processComplexFields($listing, $listingInfo);
             $listing->deleteProperty('featured');
             $listing->deleteProperty('priority');
             $listing->deleteProperty('status');
             $listing->deleteProperty('reject_reason');
             $listing->deleteProperty('ListingLogo');
             $listing->setSID($listing_id);
             $access_type = $listing->getProperty('access_type');
             if ($form_submitted && !empty($access_type)) {
                 $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true));
             }
             $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID());
             if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) {
                 $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
                 if ($issetQuestionnairyField) {
                     $value = SJB_Request::getVar('screening_questionnaire');
                     $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
                     $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true));
                 }
             } else {
                 $listing->deleteProperty('screening_questionnaire');
             }
             /* social plugin
              * "synchronization"
              * if user is not registered using linkedin , delete linkedin sync property
              * also deletes it if sync is turned off in admin part
              */
             if ($pages[0]['page_id'] == $pageID) {
                 $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo);
                 SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
             }
             $add_listing_form = new SJB_Form($listing);
             $add_listing_form->registerTags($tp);
             $field_errors = array();
             if ($form_submitted && (SJB_Session::getValue(self::PREVIEW_LISTING_SID) == $listing_id || $add_listing_form->isDataValid($field_errors))) {
                 /* delete temp preview listing sid */
                 SJB_Session::unsetValue(self::PREVIEW_LISTING_SID);
                 if ($isPageLast) {
                     $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 }
                 $listing->setUserSID($currentUser->getSID());
                 if (empty($access_type->value)) {
                     $listing->setPropertyValue('access_type', 'everyone');
                 }
                 if (isset($_SESSION['tmp_file_storage'])) {
                     foreach ($_SESSION['tmp_file_storage'] as $k => $v) {
                         SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s', $listing->getSID(), $v['picture_saved_name']);
                         SJB_DB::query('UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s', $listing->getSID(), $v['thumb_saved_name']);
                     }
                     SJB_Session::unsetValue('tmp_file_storage');
                 }
                 // >>> SJB-1197
                 // check temporary uploaded storage for listing uploads and assign it to saved listing
                 $formToken = SJB_Request::getVar('form_token');
                 $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken);
                 if (!empty($uploadedFields)) {
                     foreach ($uploadedFields as $fieldId => $fieldValue) {
                         // get field of listing
                         $isComplex = false;
                         if (strpos($fieldId, ':') !== false) {
                             $isComplex = true;
                         }
                         $tmpUploadedFileId = $fieldValue['file_id'];
                         // rename it to real listing field value
                         $newFileId = $fieldId . "_" . $listing->getSID();
                         SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                         if ($isComplex) {
                             list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                             $parentProp = $listing->getProperty($parentField);
                             $parentValue = $parentProp->getValue();
                             // look for complex property with current $fieldID and set it to new value of property
                             if (!empty($parentValue)) {
                                 foreach ($parentValue as $id => $value) {
                                     if ($id == $subField) {
                                         $parentValue[$id][$complexStep] = $newFileId;
                                     }
                                 }
                                 $listing->setPropertyValue($parentField, $parentValue);
                             }
                         } else {
                             $listing->setPropertyValue($fieldId, $newFileId);
                         }
                         // unset value from session temporary storage
                         $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}");
                     }
                     //and remove token key from temporary storage
                     $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}");
                     SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage);
                 }
                 // <<< SJB-1197
                 SJB_ListingManager::saveListing($listing);
                 foreach ($previousComplexFields as $propertyId) {
                     $listing->deleteProperty($propertyId);
                 }
                 if ($isPageLast && !$isPreviewListingRequested) {
                     $listingSID = $listing->getSID();
                     $listing = SJB_ListingManager::getObjectBySID($listingSID);
                     $listing->setSID($listingSID);
                     $keywords = $listing->getKeywords();
                     SJB_ListingManager::updateKeywords($keywords, $listing->getSID());
                     // Start Event
                     $listingSid = $listing->getSID();
                     SJB_Event::dispatch('listingSaved', $listingSid);
                     // is listing featured by default
                     if ($extraInfo['featured']) {
                         SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                     }
                     if ($extraInfo['priority']) {
                         SJB_ListingManager::makePriorityBySID($listing->getSID());
                     }
                     if ($contractID) {
                         if (SJB_ListingManager::activateListingBySID($listing->getSID())) {
                             SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID());
                         }
                         // notify administrator
                         SJB_AdminNotifications::sendAdminListingAddedLetter($listing);
                         if (isset($_REQUEST['action_add_pictures'])) {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-pictures/?listing_id=" . $listing->getSID());
                         } else {
                             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($listingTypeID) . '/?listing_id=' . $listing->getSID());
                         }
                     } else {
                         SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID());
                         $this->proceedToCheckout($currentUser->getSID(), $productSID);
                     }
                 } elseif ($isPageLast && $isPreviewListingRequested) {
                     // for listing preview
                     SJB_Session::setValue(self::PREVIEW_LISTING_SID, $listing->getSID());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/');
                 } else {
                     // listing steps (pages)
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . '/' . $listing->getSID());
                 }
             } else {
                 foreach ($previousComplexFields as $propertyId) {
                     $listing->deleteProperty($propertyId);
                 }
                 $listing->deleteProperty('access_list');
                 $listing->deleteProperty('contract_id');
                 $add_listing_form = new SJB_Form($listing);
                 if (SJB_Request::get('action_add') == 'Next') {
                     $add_listing_form->setUseDefaultValues();
                 }
                 if ($form_submitted) {
                     $add_listing_form->isDataValid($field_errors);
                 }
                 $add_listing_form->registerTags($tp);
                 $form_fields = $add_listing_form->getFormFieldsInfo();
                 $employers_list = SJB_Request::getVar('list_emp_ids', false);
                 $employers = array();
                 if (is_array($employers_list)) {
                     foreach ($employers_list as $emp) {
                         $currEmp = SJB_UserManager::getUserInfoBySID($emp);
                         $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']);
                     }
                     sort($employers);
                 } else {
                     $access_type = $listing->getPropertyValue('access_type');
                     $employers = SJB_ListingManager::getListingAccessList($listing_id, $access_type);
                 }
                 $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
                 $tp->assign('pic_limit', $numberOfPictures);
                 $tp->assign('listing_sid', $listing_id);
                 $tp->assign('listing_id', $listing_id);
                 $tp->assign('listingSID', $listing->getSID());
                 $tp->assign('listing_access_list', $employers);
                 $tp->assign('listingTypeID', $listingTypeID);
                 $tp->assign('contract_id', $contractID);
                 $tp->assign('field_errors', $field_errors);
                 $tp->assign('form_fields', $form_fields);
                 $tp->assign("extraInfo", $extraInfo);
                 $tp->assign('pages', $pages);
                 $tp->assign('pageSID', $pageSID);
                 $tp->assign('currentPage', SJB_PostingPagesManager::getPageInfoBySID($pageSID));
                 $tp->assign('isPageLast', $isPageLast);
                 $tp->assign('nextPage', SJB_PostingPagesManager::getNextPage($pageSID));
                 $tp->assign('prevPage', SJB_PostingPagesManager::getPrevPage($pageSID));
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
                 // social plugin  only for Resume listing types
                 $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $currentUser->getSID());
                 SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData);
                 SJB_Session::unsetValue(self::PREVIEW_LISTING_SID);
                 $tp->display($template);
             }
         }
     } else {
         $tp->assign('listingTypeID', $listingTypeID);
         $tp->assign('error', 'NOT_LOGGED_IN');
         $tp->display('add_listing_error.tpl');
     }
 }
예제 #22
0
 /**
  * @param SJB_User $user
  * @return SJB_User
  */
 public static function addListingFieldsIntoRegistration(SJB_User $user)
 {
     if (self::getProfileObject() && !empty(self::$aListingFields)) {
         if ('JobSeeker' == SJB_Request::getVar(self::REQUEST_USER_GROUP_ID_KEY)) {
             $listing_type_id = 'Resume';
             $listing = SJB_ObjectMother::createListing($_REQUEST, SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id));
             foreach (self::$aListingFields as $field) {
                 $user->addProperty($listing->getProperty($field));
             }
         }
     }
     return $user;
 }
예제 #23
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);
 }
예제 #24
0
 /**
  * @param $listingSID
  * @param $contractID
  * @param $productSID
  */
 public function addListing($listingSID, $contractID = false, $productSID = false)
 {
     if ($productSID != false) {
         $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID);
         $extraInfo['product_sid'] = (string) $extraInfo['product_sid'];
     } else {
         $contract = new SJB_Contract(array('contract_id' => $contractID));
         $extraInfo = $contract->extra_info;
     }
     $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
     $this->tp->assign("pic_limit", $numberOfPictures);
     $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
     if (!$this->listingTypeID && count($listingTypesInfo) == 1) {
         $listingTypeInfo = array_pop($listingTypesInfo);
         $this->listingTypeID = $listingTypeInfo['id'];
     }
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
     $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
     $pageSID = $this->getPageSID($pages, $listingTypeSID);
     $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listingTypeSID);
     $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
     if (($contractID || !empty($this->buttonPressedPostToProceed)) && $this->listingTypeID) {
         $formSubmitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested;
         /*
          * social plugin
          * complete listing of data from an array of social data
          * if is allowed
          */
         $aAutoFillData = array('formSubmitted' => &$formSubmitted, 'listingTypeID' => &$this->listingTypeID);
         SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
         /*
          * end of "social plugin"
          */
         $listing = new SJB_Listing($_REQUEST, $listingTypeSID, $pageSID);
         $listing->deleteProperty('featured');
         $listing->deleteProperty('priority');
         $listing->deleteProperty('status');
         $listing->deleteProperty('reject_reason');
         $listing->deleteProperty('ListingLogo');
         $access_type = $listing->getProperty('access_type');
         if ($formSubmitted) {
             if (!empty($access_type)) {
                 $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true));
             }
             $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contractID, 'is_system' => true));
         }
         $currentUser = SJB_UserManager::getCurrentUser();
         $screeningQuestionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID());
         if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screeningQuestionnaires) {
             $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
             if ($issetQuestionnairyField) {
                 $value = SJB_Request::getVar("screening_questionnaire");
                 $listingInfo = $_REQUEST;
                 $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
                 $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true));
             }
         } else {
             $listing->deleteProperty('screening_questionnaire');
         }
         /*
          * social plugin
          * "synchronization"
          * if user is not registered using linkedin , delete linkedin sync property
          * also if sync is turned off in admin part
          */
         $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $this->listingTypeID, 'listing_info' => $_REQUEST);
         SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
         /*
          * end of social plugin "sync"
          */
         $listingFormAdd = new SJB_Form($listing);
         $listingFormAdd->registerTags($this->tp);
         $fieldErrors = array();
         if ($formSubmitted && ($this->formSubmittedFromPreview || $listingFormAdd->isDataValid($fieldErrors))) {
             if ($isPageLast) {
                 $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
             }
             $listing->setUserSID($currentUser->getSID());
             $listing->setProductInfo($extraInfo);
             if (empty($access_type->value)) {
                 $listing->setPropertyValue('access_type', 'everyone');
             }
             if ($currentUser->isSubuser()) {
                 $subuserInfo = $currentUser->getSubuserInfo();
                 $listing->addSubuserProperty($subuserInfo['sid']);
             }
             /**
              * >>>>> listing preview @author still
              */
             if (!empty($listingSID)) {
                 $listing->setSID($listingSID);
             }
             /*
              * <<<<< listing preview
              */
             SJB_ListingManager::saveListing($listing);
             if (!empty($this->buttonPressedPostToProceed)) {
                 SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID());
             }
             SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']);
             if ($contractID) {
                 $contract = new SJB_Contract(array('contract_id' => $contractID));
                 $contract->incrementPostingsNumber();
                 SJB_ProductsManager::incrementPostingsNumber($contract->product_sid);
             }
             if (SJB_Session::getValue('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');
             }
             // >>> SJB-1197
             // check temporary uploaded storage for listing uploads and assign it to saved listing
             $formToken = SJB_Request::getVar('form_token');
             $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
             $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken);
             if (!empty($uploadedFields)) {
                 foreach ($uploadedFields as $fieldId => $fieldValue) {
                     // get field of listing
                     $isComplex = false;
                     if (strpos($fieldId, ':') !== false) {
                         $isComplex = true;
                     }
                     $tmpUploadedFileId = $fieldValue['file_id'];
                     // rename it to real listing field value
                     $newFileId = $fieldId . "_" . $listing->getSID();
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                     if ($isComplex) {
                         list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                         $parentProp = $listing->getProperty($parentField);
                         $parentValue = $parentProp->getValue();
                         // look for complex property with current $fieldID and set it to new value of property
                         if (!empty($parentValue)) {
                             foreach ($parentValue as $id => $value) {
                                 if ($id == $subField) {
                                     $parentValue[$id][$complexStep] = $newFileId;
                                 }
                             }
                             $listing->setPropertyValue($parentField, $parentValue);
                         }
                     } else {
                         $listing->setPropertyValue($fieldId, $newFileId);
                     }
                     // unset value from session temporary storage
                     $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}");
                 }
                 //and remove token key from temporary storage
                 $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}");
                 SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage);
                 SJB_ListingManager::saveListing($listing);
                 $keywords = $listing->getKeywords();
                 SJB_ListingManager::updateKeywords($keywords, $listing->getSID());
             }
             // <<< SJB-1197
             if ($isPageLast && !$isPreviewListingRequested) {
                 /* delete temp preview listing sid */
                 SJB_Session::unsetValue('preview_listing_sid_for_add');
                 // Start Event
                 $listingSid = $listing->getSID();
                 SJB_Event::dispatch('listingSaved', $listingSid);
                 if ($extraInfo['featured']) {
                     SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                 }
                 if ($extraInfo['priority']) {
                     SJB_ListingManager::makePriorityBySID($listing->getSID());
                 }
                 if (!empty($this->buttonPressedPostToProceed)) {
                     $this->proceedToCheckout($currentUser->getSID(), $productSID);
                 } else {
                     if (SJB_ListingManager::activateListingBySID($listing->getSID())) {
                         SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID());
                     }
                     // notify administrator
                     SJB_AdminNotifications::sendAdminListingAddedLetter($listing);
                     if (isset($_REQUEST['action_add_pictures'])) {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-pictures/?listing_id=" . $listing->getSID());
                     } else {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($this->listingTypeID) . '/?listing_id=' . $listing->getSID());
                     }
                 }
             } elseif ($isPageLast && $isPreviewListingRequested) {
                 // for listing preview
                 SJB_Session::setValue('preview_listing_sid_for_add', $listing->getSID());
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($this->listingTypeID) . '-preview/' . $listing->getSID() . '/');
             } else {
                 // listing steps (pages)
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$this->listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . "/" . $listing->getSID());
             }
         } else {
             $listing->deleteProperty('access_list');
             $listing->deleteProperty('contract_id');
             $listingFormAdd = new SJB_Form($listing);
             if ($formSubmitted) {
                 $listingFormAdd->isDataValid($fieldErrors);
             }
             $listingFormAdd->registerTags($this->tp);
             $template = isset($_REQUEST['input_template']) ? $_REQUEST['input_template'] : "input_form.tpl";
             $formFields = $listingFormAdd->getFormFieldsInfo();
             $employersList = SJB_Request::getVar('list_emp_ids', false);
             $employers = array();
             if (is_array($employersList)) {
                 foreach ($employersList as $emp) {
                     $currEmp = SJB_UserManager::getUserInfoBySID($emp);
                     $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']);
                 }
                 sort($employers);
             }
             $this->tp->assign('form_token', SJB_Request::getVar('form_token'));
             $this->tp->assign("account_activated", SJB_Request::getVar('account_activated', ''));
             $this->tp->assign("contract_id", $contractID);
             $this->tp->assign("listing_access_list", $employers);
             $this->tp->assign("listingTypeID", $this->listingTypeID);
             $this->tp->assign('listingTypeStructure', SJB_ListingTypeManager::createTemplateStructure(SJB_ListingTypeManager::getListingTypeInfoBySID($listing->listing_type_sid)));
             $this->tp->assign("field_errors", $fieldErrors);
             $this->tp->assign("form_fields", $formFields);
             $this->tp->assign("pages", $pages);
             $this->tp->assign("pageSID", $pageSID);
             $this->tp->assign("extraInfo", $extraInfo);
             $this->tp->assign("currentPage", SJB_PostingPagesManager::getPageInfoBySID($pageSID));
             $this->tp->assign("isPageLast", $isPageLast);
             $this->tp->assign("nextPage", SJB_PostingPagesManager::getNextPage($pageSID));
             $this->tp->assign("prevPage", SJB_PostingPagesManager::getPrevPage($pageSID));
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $this->tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($formFields)));
             /*
              * social plugin
              * only for Resume listing types
              */
             $aAutoFillData = array('tp' => &$this->tp, 'listingTypeID' => &$this->listingTypeID, 'userSID' => $currentUser->getSID());
             SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData);
             /*
              * social plugin
              */
             $this->tp->display($template);
         }
     }
 }
예제 #25
0
 private function CreateListing($listing_info, $listing_type_id)
 {
     $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
     $listing = new SJB_Listing($listing_info, $listing_type_sid);
     $userInfo = array();
     if (!empty($listing_info['extUserID'])) {
         $userInfo = SJB_UserManager::getUserInfoByExtUserID($listing_info['extUserID'], $listing_type_id);
         if ($userInfo) {
             $listing->setUserSID($userInfo['sid']);
         }
     }
     if (!$userInfo && !empty($listing_info['username'])) {
         $userInfo = SJB_UserManager::getUserInfoByUserName($listing_info['username']);
         $listing->setUserSID($userInfo['sid']);
     }
     return $listing;
 }
예제 #26
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listingTypeID = SJB_Request::getVar('listing_type_id');
     $listingTypeSID = SJB_Request::getVar('listing_type');
     if ($listingTypeID !== null) {
         $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
     }
     // SET PAGINATION AND SORTING VALUES
     $restore = SJB_Request::getVar('restore', false);
     $paginator = new SJB_FlaggedListingsPagination();
     // FILTERS
     $filters = array();
     $filters['title'] = SJB_Request::getVar('filter_title');
     $filters['username'] = SJB_Request::getVar('filter_user');
     $filters['flag'] = SJB_Request::getVar('filter_flag');
     // check session for pagination settings
     $sessionFlaggedSettings = !is_null(SJB_Session::getValue('flagged_settings')) ? SJB_Session::getValue('flagged_settings') : false;
     if ($sessionFlaggedSettings !== false) {
         if (!$restore) {
             SJB_Session::setValue('flagged_settings', array('filters' => $filters));
         } else {
             if (!$listingTypeSID && !empty($sessionFlaggedSettings['listing_type_sid'])) {
                 $listingTypeSID = $sessionFlaggedSettings['listing_type_sid'];
             }
             $filters = $sessionFlaggedSettings['filters'];
         }
     } else {
         SJB_Session::setValue('flagged_settings', array('filters' => $filters));
     }
     // DEFAULT SORTING
     // resolve flag to it text value for search
     $filterFlag = $filters['flag'];
     if (!empty($filterFlag) && is_numeric($filterFlag)) {
         $result = SJB_DB::query('SELECT * FROM `flag_listing_settings` WHERE `sid` = ?n LIMIT 1', $filterFlag);
         if (!empty($result)) {
             $filters['flag_reason'] = $result[0]['value'];
         }
     }
     //////////////////////  ACTIONS
     $action = SJB_Request::getVar('action_name');
     $flagSIDs = SJB_Request::getVar('flagged');
     if (!empty($flagSIDs)) {
         switch ($action) {
             case 'remove':
                 foreach ($flagSIDs as $sid => $val) {
                     SJB_ListingManager::removeFlagBySID($sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
                 break;
             case 'deactivate':
                 foreach ($flagSIDs as $sid => $val) {
                     SJB_ListingManager::deactivateListingByFlagSID($sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
                 break;
             case 'delete':
                 foreach ($flagSIDs as $sid => $val) {
                     SJB_ListingManager::deleteListingByFlagSID($sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
                 break;
         }
     }
     //////////////////////// OUTPUT
     $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $allFlags = SJB_ListingManager::getAllFlags();
     $countFlaggedListings = SJB_ListingManager::getFlagsNumberByListingTypeSID($listingTypeSID, $filters);
     $paginator->setItemsCount($countFlaggedListings);
     $flaggedListings = SJB_ListingManager::getFlaggedListings($listingTypeSID, $paginator->currentPage, $paginator->itemsPerPage, $paginator->sortingField, $paginator->sortingOrder, $filters);
     if (empty($flaggedListings) && $paginator->currentPage != 1) {
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
     }
     foreach ($flaggedListings as $key => $val) {
         $listingInfo = SJB_ListingManager::getListingInfoBySID($val['listing_sid']);
         $listingUser = SJB_UserManager::getUserInfoBySID($listingInfo['user_sid']);
         $flaggedUser = SJB_UserManager::getUserInfoBySID($val['user_sid']);
         $flaggedListings[$key]['listing_info'] = $listingInfo;
         $flaggedListings[$key]['user_info'] = $listingUser;
         $flaggedListings[$key]['flagged_user'] = $flaggedUser;
     }
     $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     $tp->assign('listing_types', $allListingTypes);
     $tp->assign('listings', $flaggedListings);
     $tp->assign('listing_type_sid', $listingTypeSID);
     $tp->assign('all_flags', $allFlags);
     $tp->assign('filters', $filters);
     $tp->display('flagged_listings.tpl');
 }
예제 #27
0
 /**
  * this function is used to receive some listing SID,
  * for Display Listing FIelds Builder.
  * 
  * @param int $listing_type_id
  * @return int
  */
 public static function getListingIDByListingTypeID($listing_type_id)
 {
     $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
     return SJB_DB::queryValue('SELECT `sid` FROM `listings` WHERE `listing_type_sid` = ?n AND `active` = 1 LIMIT 1', $listing_type_sid);
 }
예제 #28
0
 public static function getApplicationsAndViewsStatistics($period, $filter, $sortingField, $sorting_order)
 {
     $where = '';
     if (!empty($period['from'])) {
         $period['from'] = SJB_I18N::getInstance()->getInput('date', $period['from']);
         $time = "00:00:00";
         $where .= " AND s.`date` >= '{$period['from']} {$time}' ";
     }
     if (!empty($period['to'])) {
         $period['to'] = SJB_I18N::getInstance()->getInput('date', $period['to']);
         $time = "23:59:59";
         $where .= " AND s.`date` <= '{$period['to']} {$time}' ";
     }
     $join = '';
     $mainGroupBy = '';
     $from = '';
     if (in_array($filter, array('Location_Country', 'Location_State', 'Location_City'))) {
         $fieldInfo = SJB_ListingFieldDBManager::getLocationFieldsInfoById($filter);
     } else {
         $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($filter);
     }
     if (strstr($filter, 'userGroup_')) {
         $userGroupSID = str_replace('userGroup_', '', $filter);
         $userGroupID = SJB_UserGroupManager::getUserGroupIDBySID($userGroupSID);
         $mainGroupBy = 'user_sid';
         if ($userGroupID == 'JobSeeker') {
             $join = ' INNER JOIN `users` u ON s.`user_sid` = u.`sid` ';
             $query = ", u.`FirstName`, u.`LastName`, u.`sid` as {$mainGroupBy} ";
         } else {
             $join = ' INNER JOIN `users` u ON l.`user_sid` = u.`sid` ';
             $query = ", u.`CompanyName`, u.`sid` as {$mainGroupBy} ";
         }
         $where .= " AND u.`user_group_sid` = '{$userGroupSID}'";
         $groupBy = ' u.`sid`';
     } elseif (!empty($fieldInfo['type']) && $fieldInfo['type'] == 'list' && empty($fieldInfo['parent_sid'])) {
         $join = " INNER JOIN `listing_field_list` lfl ON l.`{$filter}` = lfl.`sid` ";
         $groupBy = " `{$filter}` ";
         $query = ", lfl.`value` as {$filter} ";
     } elseif (!empty($fieldInfo['type']) && $fieldInfo['type'] == 'list' && !empty($fieldInfo['parent_sid'])) {
         $mainGroupBy = $filter;
         if ($filter == 'Location_Country') {
             $join = " INNER JOIN `countries` c ON l.`{$filter}` = c.`sid` ";
             $query = ", c.`country_name` as {$filter} ";
         } else {
             $join = " INNER JOIN `states` st ON l.`{$filter}` = st.`sid` ";
             $query = ", st.`state_name` as {$filter} ";
         }
         $groupBy = " `{$filter}` ";
     } elseif ($filter == 'sid') {
         $mainGroupBy = 'listing_sid';
         $join = " INNER JOIN `users` u ON l.`user_sid` = u.`sid` ";
         $groupBy = " l.`{$filter}` ";
         $query = ", l.`sid`, l.`Title`, l.`sid` as {$mainGroupBy} , u.`CompanyName`, u.`username` ";
     } else {
         $mainGroupBy = $filter;
         $where .= " AND l.`{$filter}` != '' AND l.`{$filter}` IS NOT NULL ";
         $groupBy = " l.`{$filter}` ";
         $query = ', l.* ';
     }
     $orderBy = '';
     if (empty($sortingField)) {
         $orderBy = "ORDER BY totalApply DESC, totalView DESC ";
     } else {
         if ($sortingField == 'username') {
             if (strstr($filter, 'userGroup_')) {
                 if ($userGroupID == 'Employer') {
                     $sortingField = 'CompanyName';
                     $orderBy = "ORDER BY `CompanyName` {$sorting_order}";
                 } else {
                     $sortingField = 'FirstName,LastName';
                     $orderBy = "ORDER BY `FirstName`, `LastName` {$sorting_order}";
                 }
             }
         } else {
             $orderBy = "ORDER BY {$sortingField} {$sorting_order}";
         }
     }
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID('Job');
     if (!empty($fieldInfo['type']) && $fieldInfo['type'] == 'multilist') {
         $statisticsInfo = self::executeApplicationsAndViewsMultylistStatistics($from, $join, $where, $groupBy, $orderBy, $filter, $listingTypeSID);
     } else {
         $statisticsInfo = self::executeApplicationsAndViewsStatistics($mainGroupBy, $query, $join, $where, $groupBy, $sortingField, $sorting_order, $listingTypeSID, 10);
     }
     $statistics = array();
     foreach ($statisticsInfo as $key => $statisticInfo) {
         $statistics[$key] = $statisticInfo;
         if (isset($statisticInfo['other'])) {
             $statistics[$key]['generalColumn'] = 'Other';
         } elseif (strstr($filter, 'userGroup_')) {
             if ($userGroupID == 'Employer') {
                 $statistics[$key]['generalColumn'] = !empty($statisticInfo['CompanyName']) ? $statisticInfo['CompanyName'] : $statisticInfo['username'];
             } else {
                 $statistics[$key]['generalColumn'] = !empty($statisticInfo['FirstName']) && !empty($statisticInfo['LastName']) ? $statisticInfo['FirstName'] . " " . $statisticInfo['LastName'] : $statisticInfo['username'];
             }
         } elseif ($filter == 'sid') {
             $statistics[$key]['generalColumn'] = $statisticInfo['Title'];
         } else {
             $statistics[$key]['generalColumn'] = $statisticInfo[$filter];
         }
     }
     return $statistics;
 }
예제 #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');
 }
예제 #30
0
 public function execute()
 {
     $ajaxAction = SJB_Request::getVar('ajax_action', '', 'GET');
     $formToken = SJB_Request::getVar('form_token', '');
     // save token date in session. In some code we needs to get list of it, and clean old tokens data from
     // session.
     self::setTokenDateToSession($formToken);
     switch ($ajaxAction) {
         // UPLOAD USER PROFILE VIDEO
         case 'upload_profile_video':
         case 'upload_profile_logo':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             // get field by user group return not all fields of profile.
             // but now we use getAllFieldsInfo() to check fields
             $userProfileFields = SJB_UserProfileFieldManager::getAllFieldsInfo();
             $fieldSid = null;
             foreach ($userProfileFields as $field) {
                 if ($field['id'] != $uploadedFieldId) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             if ($fieldSid == null) {
                 echo "Wrong profile field specified";
                 exit;
             }
             $fieldInfo = SJB_UserProfileFieldManager::getFieldInfoBySID($fieldSid);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId);
             if ($validation === true) {
                 // video file already uploaded after isValid checks
                 // but for 'Logo' - we need some actions to make save picture
                 if ($fieldInfo['type'] == 'logo') {
                     $upload_manager = new SJB_UploadPictureManager();
                     $upload_manager->setUploadedFileID($this->fileUniqueId);
                     $upload_manager->setHeight($fieldInfo['height']);
                     $upload_manager->setWidth($fieldInfo['width']);
                     $upload_manager->uploadPicture($fieldInfo['id'], $fieldInfo);
                     // and set value of file id to property
                     $this->property->setValue($this->fileUniqueId);
                     $this->propertyValue = $this->property->getValue();
                 }
                 // set uploaded video to temporary value
                 if ($fieldInfo['type'] == 'video' && isset($this->propertyValue['file_id'])) {
                     $uploadedID = $this->propertyValue['file_id'];
                     // rename it to unique value
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $this->fileUniqueId, $uploadedID);
                     // fill session data for tmp storage
                     $fieldValue = array('file_id' => $this->fileUniqueId, 'file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'saved_file_name' => $this->propertyValue['saved_file_name']);
                     $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                     $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fieldValue);
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 } elseif ($fieldInfo['type'] == 'logo') {
                     // for Logo - we already have file_url data and file_thumb data, without file_id
                     // just add this to session storage
                     // fill session data for tmp storage
                     $fieldValue = array('file_id' => $this->fileUniqueId, 'file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'thumb_file_url' => $this->propertyValue['thumb_file_url'], 'thumb_file_name' => $this->propertyValue['thumb_file_name']);
                     $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                     $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fieldValue);
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
                 $tp->assign(array('id' => $uploadedFieldId, 'value' => $fieldValue));
             }
             $template = '';
             switch ($fieldInfo['type']) {
                 case 'video':
                     $template = '../field_types/input/video_profile.tpl';
                     break;
                 case 'logo':
                     $template = '../field_types/input/logo.tpl';
                     break;
                 default:
                     break;
             }
             $tp->assign('form_token', $formToken);
             $tp->assign('errors', $this->errors);
             $tp->display($template);
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'delete_profile_video':
         case 'delete_profile_logo':
             $userSid = SJB_Request::getVar('user_sid', null);
             if (empty($userSid)) {
                 $userInfo = SJB_UserManager::getCurrentUserInfo();
             } else {
                 $userInfo = SJB_UserManager::getUserInfoBySID($userSid);
             }
             $fieldId = SJB_Request::getVar('field_id', null);
             // check session value
             $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
             $sessionFileId = SJB_Array::getPath($sessionFileStorage, "{$formToken}/{$fieldId}/file_id");
             if (is_null($fieldId)) {
                 $this->errors['PARAMETERS_MISSED'] = 1;
             } elseif (!empty($userInfo) && !isset($userInfo[$fieldId]) && empty($sessionFileId)) {
                 echo json_encode(array('result' => 'success'));
                 exit;
             } else {
                 if (!empty($userInfo)) {
                     $uploaded_file_id = $userInfo[$fieldId];
                     SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id);
                 }
                 if (!empty($sessionFileId)) {
                     $formFileId = SJB_Request::getVar('file_id');
                     if ($sessionFileId == $formFileId) {
                         SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                         $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                         SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                     }
                 }
             }
             if (empty($this->errors)) {
                 echo json_encode(array('result' => 'success'));
             } else {
                 echo json_encode(array('result' => 'error', 'errors' => $this->errors));
             }
             exit;
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
             // UPLOAD LISTIG FILES
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         // UPLOAD LISTIG FILES
         case 'upload_classifieds_video':
         case 'upload_file':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             // OK. For listings form we have 'listing_id' and optional field (for new listings with temporary id) - listing_type_id
             $listingId = SJB_Request::getVar('listing_id');
             $listingTypeId = SJB_Request::getVar('listing_type_id');
             if (empty($listingTypeId)) {
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
             }
             $listingTypeSid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeId);
             $commonListingFields = SJB_ListingFieldManager::getCommonListingFieldsInfo();
             $listingFieldsByType = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeSid);
             $listingFields = array_merge($commonListingFields, $listingFieldsByType);
             $fieldSid = null;
             foreach ($listingFields as $field) {
                 if ($field['id'] != $uploadedFieldId) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($fieldSid);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId);
             if (!$validation) {
                 $tp->assign(array('listing_id' => $listingId, 'listing' => array('id' => $listingId)));
             } else {
                 // video file already uploaded after isValid checks
                 // but for 'Logo' - we need some actions to make save picture
                 if ($this->property->getType() == 'file') {
                     if ($_FILES[$uploadedFieldId]['error']) {
                         $this->errors[SJB_UploadFileManager::getErrorId($_FILES[$uploadedFieldId]['error'])] = 1;
                     }
                     $upload_manager = new SJB_UploadFileManager();
                     $upload_manager->setUploadedFileID($this->fileUniqueId);
                     $upload_manager->setFileGroup('files');
                     $upload_manager->uploadFile($fieldInfo['id']);
                     // and set value of file id to property
                     $this->property->setValue($this->fileUniqueId);
                 }
                 $this->propertyValue = $this->property->getValue();
                 // set uploaded video to temporary value
                 if (isset($this->propertyValue['file_id'])) {
                     $uploadedID = $this->propertyValue['file_id'];
                     // rename it to unique value
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $this->fileUniqueId, $uploadedID);
                     // SET VALUE TO TEMPORARY SESSION STORAGE
                     $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                     $fileValue = array('file_id' => $this->fileUniqueId, 'saved_name' => $this->propertyValue['saved_file_name']);
                     $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fileValue);
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                     // update listing property
                     $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                     $listing = isset($listingInfo['listing_type_sid']) ? new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']) : new SJB_Listing($listingInfo);
                     $listingProperties = $listing->getProperties();
                     $propertyInfo = array('id' => $uploadedFieldId, 'type' => 'string', 'value' => $this->fileUniqueId, 'is_system' => true);
                     foreach ($listingProperties as $property) {
                         if ($property->getID() == $uploadedFieldId) {
                             $listing->addProperty($propertyInfo);
                         }
                     }
                     $listing->setSID($listingId);
                     SJB_ListingManager::saveListing($listing);
                     $tp->assign(array('id' => $uploadedFieldId, 'value' => array('file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'saved_file_name' => $this->propertyValue['saved_file_name'], 'file_id' => $this->fileUniqueId), 'listing_id' => $listingId, 'listing' => array('id' => $listingId)));
                 }
             }
             switch ($this->property->getType()) {
                 case 'video':
                     $template = '../field_types/input/video.tpl';
                     break;
                 case 'file':
                     $template = '../field_types/input/file.tpl';
                     break;
                 default:
                     $template = '../field_types/input/video.tpl';
                     break;
             }
             $tp->assign('errors', $this->errors);
             $tp->assign('form_token', $formToken);
             $tp->display($template);
             self::cleanOldTokensFromSession();
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'delete_classifieds_video':
         case 'delete_file':
             $listingId = SJB_Request::getVar('listing_id', null);
             $fieldId = SJB_Request::getVar('field_id', null);
             $formFileId = SJB_Request::getVar('file_id');
             $this->errors = array();
             // check session value
             $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
             $sessionFileId = SJB_Array::getPath($sessionFileStorage, "{$formToken}/{$fieldId}/file_id");
             // if empty listing id - check end empty temporary storage
             if (strlen($listingId) == strlen(time())) {
                 if ($sessionFileId == $formFileId) {
                     SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                     // remove field from temporary storage
                     if (!is_null($sessionFileStorage)) {
                         $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                         SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                     }
                 }
             } else {
                 // we change existing listing
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 if ((is_null($listingInfo) || !isset($listingInfo[$fieldId])) && empty($sessionFileId)) {
                     $this->errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
                 } else {
                     if (!$this->isOwner($listingId)) {
                         $this->errors['NOT_OWNER'] = 1;
                     } else {
                         $uploadedFileId = $listingInfo[$fieldId];
                         if (!empty($uploadedFileId)) {
                             SJB_UploadFileManager::deleteUploadedFileByID($uploadedFileId);
                         }
                         SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                         $listingInfo[$fieldId] = '';
                         $listing = isset($listingInfo['listing_type_sid']) ? new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']) : new SJB_Listing($listingInfo);
                         // remove all non-changed properties and save only changed property in listing
                         $props = $listing->getProperties();
                         foreach ($props as $prop) {
                             if ($prop->getID() !== $fieldId) {
                                 $listing->deleteProperty($prop->getID());
                             }
                         }
                         $listing->setSID($listingId);
                         SJB_ListingManager::saveListing($listing);
                         // remove field from temporary storage
                         $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                         if (!is_null($sessionFileStorage)) {
                             $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                             SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                         }
                     }
                 }
             }
             if (empty($this->errors)) {
                 echo json_encode(array('result' => 'success'));
             } else {
                 echo json_encode(array('result' => 'error', 'errors' => $this->errors));
             }
             exit;
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'get_classifieds_video_data':
         case 'get_file_field_data':
             $fieldId = isset($_REQUEST['field_id']) ? $_REQUEST['field_id'] : null;
             $listingId = SJB_Request::getVar('listing_id');
             $filesFromTmpStorage = SJB_Session::getValue('tmp_uploads_storage');
             $fileUniqueId = SJB_Array::getPath($filesFromTmpStorage, "{$formToken}/{$fieldId}/file_id");
             // if no temporary files uploaded, return empty string
             if (empty($fileUniqueId)) {
                 return '';
             }
             $tp = SJB_System::getTemplateProcessor();
             $upload_manager = new SJB_UploadFileManager();
             $fileInfo = array('id' => $fieldId, 'value' => array('file_url' => $upload_manager->getUploadedFileLink($fileUniqueId), 'file_name' => $upload_manager->getUploadedFileName($fileUniqueId), 'saved_file_name' => $upload_manager->getUploadedSavedFileName($fileUniqueId), 'file_id' => $fileUniqueId), 'listing_id' => $listingId, 'listing' => array('id' => $listingId));
             $tp->assign($fileInfo);
             $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($fieldId);
             $fieldType = $fieldInfo['type'];
             $template = '';
             switch ($fieldType) {
                 case 'video':
                     $template = '../field_types/input/video.tpl';
                     break;
                 case 'file':
                     $template = '../field_types/input/file.tpl';
                     break;
                 case 'logo':
                     $template = '../field_types/input/logo_listing.tpl';
                     break;
                 default:
                     break;
             }
             $uploadedFilesize = $upload_manager->getUploadedFileSize($fileUniqueId);
             $filesizeInfo = SJB_HelperFunctions::getFileSizeAndSizeToken($uploadedFilesize);
             $tp->assign(array('filesize' => $filesizeInfo['filesize'], 'size_token' => $filesizeInfo['size_token']));
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             $tp->assign('form_token', $formToken);
             $tp->display($template);
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'upload_file_complex':
         case 'upload_classifieds_video_complex':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             list($parentField, $subFieldId, $complexStep) = explode(':', $uploadedFieldId);
             // OK. For listings form we have 'listing_id' and optional field (for new listings with temporary id) - listing_type_id
             $listingId = SJB_Request::getVar('listing_id');
             $listingTypeId = SJB_Request::getVar('listing_type_id');
             if (empty($listingTypeId)) {
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
             }
             $listingTypeSid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeId);
             $commonListingFields = SJB_ListingFieldManager::getCommonListingFieldsInfo();
             $listingFieldsByType = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeSid);
             $listingFields = array_merge($commonListingFields, $listingFieldsByType);
             // check parent field
             $fieldSid = null;
             foreach ($listingFields as $field) {
                 if ($field['id'] != $parentField) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             $complexFieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($fieldSid);
             $subFields = SJB_Array::get($complexFieldInfo, 'fields');
             if (empty($subFields)) {
                 echo 'wrong field ID';
                 exit;
             }
             // check field
             $fieldInfo = '';
             foreach ($subFields as $subField) {
                 if ($subField['id'] != $subFieldId) {
                     continue;
                 }
                 $fieldInfo = $subField;
             }
             $complexParameters = array('parentField' => $parentField, 'subFieldId' => $subFieldId, 'complexStep' => $complexStep);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId, $complexParameters);
             $upload_manager = new SJB_UploadFileManager();
             $upload_manager->setUploadedFileID($this->fileUniqueId);
             $upload_manager->setFileGroup('files');
             $upload_manager->uploadFile($fieldInfo['id'], $parentField);
             $this->property->setValue($this->fileUniqueId);
             $this->propertyValue = $this->property->getPropertyVariablesToAssign();
             // set uploaded video to temporary value
             if ((isset($this->propertyValue['value']['file_id']) || isset($this->propertyValue['value'][$complexStep]['file_id'])) && $validation) {
                 // fix for FILE type in complex field
                 if (isset($this->propertyValue['value'][$complexStep]['file_id'])) {
                     $this->propertyValue['value'] = $this->propertyValue['value'][$complexStep];
                 }
                 $filesInfo = array($complexStep => $this->propertyValue['value']);
                 $uploadedID = $this->propertyValue['value']['file_id'];
                 // rename it to unique value
                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $this->fileUniqueId, $uploadedID);
                 // SET VALUE TO TEMPORARY SESSION STORAGE
                 $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $fileValue = array('file_id' => $this->fileUniqueId, 'saved_name' => $this->propertyValue['value']['saved_file_name']);
                 $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fileValue);
                 SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 $tp->assign(array('id' => $subFieldId, 'value' => $this->propertyValue['value']['file_name'], 'filesInfo' => $filesInfo, 'complexField' => $parentField, 'complexStep' => $complexStep, 'listing_id' => $listingId, 'listing' => array('id' => $listingId)));
             } else {
                 $tp->assign(array('id' => $subFieldId, 'complexField' => $parentField, 'complexStep' => $complexStep, 'listing_id' => $listingId, 'listing' => array('id' => $listingId)));
             }
             switch ($this->property->getType()) {
                 case 'video':
                     $template = '../field_types/input/video.tpl';
                     break;
                 case 'file':
                 case 'complexfile':
                     $template = '../field_types/input/file.tpl';
                     break;
                 default:
                     $template = '../field_types/input/video.tpl';
                     break;
             }
             $tp->assign('form_token', $formToken);
             $tp->assign('errors', $this->errors);
             $tp->display($template);
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'delete_file_complex':
             $listingId = SJB_Request::getVar('listing_id', null);
             $fieldId = SJB_Request::getVar('field_id', null);
             $formFileId = SJB_Request::getVar('file_id');
             $this->errors = array();
             // check session value
             $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
             $sessionFileId = SJB_Array::getPath($sessionFileStorage, "{$formToken}/{$fieldId}/file_id");
             // if empty listing id - check and empty temporary storage
             if (strlen($listingId) == strlen(time())) {
                 if ($sessionFileId == $formFileId) {
                     SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                     // remove field from temporary storage
                     $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                     SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                 }
             } else {
                 // we change existing listing
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 list($complexField, $subField, $complexStep) = explode(':', $fieldId);
                 $fieldValue = SJB_Array::getPath($listingInfo, "{$complexField}/{$subField}/{$complexStep}");
                 // if field value not present in listing and not present in temporary storage - throw error
                 if ((is_null($listingInfo) || $fieldValue === null) && empty($sessionFileId)) {
                     $this->errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
                 } else {
                     if (!$this->isOwner($listingId)) {
                         $this->errors['NOT_OWNER'] = 1;
                     } else {
                         $uploadedFileId = $fieldValue;
                         if (!empty($uploadedFileId)) {
                             SJB_UploadFileManager::deleteUploadedFileByID($uploadedFileId);
                         }
                         SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                         $listingInfo = SJB_Array::setPathValue($listingInfo, "{$complexField}/{$subField}/{$complexStep}", '');
                         $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']);
                         // remove all non-changed properties and save only changed property in listing
                         $props = $listing->getProperties();
                         foreach ($props as $prop) {
                             if ($prop->getID() !== $fieldId) {
                                 $listing->deleteProperty($prop->getID());
                             }
                         }
                         $listing->setSID($listingId);
                         SJB_ListingManager::saveListing($listing);
                         // remove field from temporary storage
                         $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                         if (!empty($sessionFileStorage)) {
                             $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                             SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                         }
                     }
                 }
             }
             if (empty($this->errors)) {
                 echo json_encode(array('result' => 'success'));
             } else {
                 echo json_encode(array('result' => 'error', 'errors' => $this->errors));
             }
             exit;
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'get_complexfile_field_data':
             $listingId = SJB_Request::getVar('listing_id', null);
             $fieldId = SJB_Request::getVar('field_id', null);
             $listingTypeId = SJB_Request::getVar('listing_type_id');
             $listingTypeSid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeId);
             $uploadFileManager = new SJB_UploadFileManager();
             // replace square brackets in complex field name
             $fieldId = str_replace("][", ":", $fieldId);
             $fieldId = str_replace("[", ":", $fieldId);
             $fieldId = str_replace("]", "", $fieldId);
             list($parentField, $subFieldId, $complexStep) = explode(':', $fieldId);
             $filesFromTmpStorage = SJB_Session::getValue('tmp_uploads_storage');
             //$fileUniqueId = SJB_Array::getPath($filesFromTmpStorage, "listings/{$listingId}/{$fieldId}/file_id");
             $fileUniqueId = SJB_Array::getPath($filesFromTmpStorage, "{$formToken}/{$fieldId}/file_id");
             // if no temporary files uploaded, return empty string
             if (empty($fileUniqueId)) {
                 return '';
             }
             // get list of fields for all listing types
             $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
             $allFields = array();
             foreach ($listingTypesInfo as $listingTypeInfo) {
                 $typeFields = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeInfo['sid']);
                 $allFields = array_merge($allFields, $typeFields);
             }
             // NEED TO GET COMPLEX SUBFIELD PROPERTY
             $commonListingFields = SJB_ListingFieldManager::getCommonListingFieldsInfo();
             $listingFieldsByType = $allFields;
             $listingFields = array_merge($commonListingFields, $listingFieldsByType);
             // check parent field
             $fieldSid = null;
             foreach ($listingFields as $field) {
                 if ($field['id'] != $parentField) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             // parent complex field
             $complexFieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($fieldSid);
             $subFields = SJB_Array::get($complexFieldInfo, 'fields');
             if (empty($subFields)) {
                 echo 'wrong field ID';
                 exit;
             }
             // check field for subfield
             $complexSubFieldInfo = '';
             foreach ($subFields as $subField) {
                 if ($subField['id'] != $subFieldId) {
                     continue;
                 }
                 $complexSubFieldInfo = $subField;
             }
             if (empty($complexSubFieldInfo)) {
                 echo 'Wrong field info';
                 exit;
             }
             // OK. COMPLEX SUBFIELD WE HAVE
             $complexSubFieldProperty = new SJB_ObjectProperty($complexSubFieldInfo);
             // complex file fields contents array of values, not just string filename
             $complexSubFieldProperty->setValue(array($complexStep => $fileUniqueId));
             $valueToAssign = $complexSubFieldProperty->getPropertyVariablesToAssign();
             $additionalInfo = array('listing_id' => $listingId, 'listing' => array('id' => $listingId), 'complexField' => $parentField, 'complexStep' => $complexStep);
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign($valueToAssign);
             $tp->assign($additionalInfo);
             $template = '';
             switch ($complexSubFieldProperty->getType()) {
                 case 'complexfile':
                     $template = '../field_types/input/file.tpl';
                     break;
                 default:
                     break;
             }
             $uploadedFilesize = $uploadFileManager->getUploadedFileSize($fileUniqueId);
             $filesizeInfo = SJB_HelperFunctions::getFileSizeAndSizeToken($uploadedFilesize);
             $tp->assign(array('filesize' => $filesizeInfo['filesize'], 'size_token' => $filesizeInfo['size_token']));
             $tp->assign('form_token', $formToken);
             $tp->display($template);
             break;
         case 'upload_listing_logo':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             $listingSid = SJB_Request::getVar('listing_id', null);
             $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($uploadedFieldId);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId);
             if ($validation === true) {
                 $upload_manager = new SJB_UploadPictureManager();
                 $upload_manager->setUploadedFileID($this->fileUniqueId);
                 $upload_manager->setHeight($fieldInfo['height']);
                 $upload_manager->setWidth($fieldInfo['width']);
                 $upload_manager->uploadPicture($fieldInfo['id'], $fieldInfo);
                 // and set value of file id to property
                 $this->property->setValue($this->fileUniqueId);
                 $this->propertyValue = $this->property->getValue();
                 // for Logo - we already have file_url data and file_thumb data, without file_id
                 // just add this to session storage
                 // fill session data for tmp storage
                 $fieldValue = array('file_id' => $this->fileUniqueId, 'file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'thumb_file_url' => $this->propertyValue['thumb_file_url'], 'thumb_file_name' => $this->propertyValue['thumb_file_name']);
                 $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fieldValue);
                 SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 $tp->assign(array('id' => $uploadedFieldId, 'value' => $fieldValue));
             }
             $template = '../field_types/input/logo_listing.tpl';
             $tp->assign('form_token', $formToken);
             $tp->assign('errors', $this->errors);
             $tp->assign('listing_id', $listingSid);
             $tp->display($template);
             break;
         default:
             echo "Action not defined!";
             break;
     }
     exit;
 }