Ejemplo n.º 1
0
 public function execute()
 {
     $errors = array();
     $template_processor = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $action = SJB_PhraseActionFactory::get($action_name, $_REQUEST, $template_processor);
         if ($action->canPerform()) {
             $action->perform();
             $template_processor->display('refresh_opener_and_close_popup.tpl');
             return;
         } else {
             $errors = $action->getErrors();
         }
     }
     $phrase_id = SJB_Request::getVar('phrase', null);
     $domain_id = SJB_Request::getVar('domain', null);
     $i18n = SJB_ObjectMother::createI18N();
     $langs = $i18n->getLanguagesData();
     $template_processor->assign('langs', $langs);
     $template_processor->assign('errors', $errors);
     if (!$i18n->phraseExists($phrase_id, $domain_id)) {
         $domains = $i18n->getDomainsData();
         $template_processor->assign('domains', $domains);
         $template_processor->assign('request_data', $_REQUEST);
         $template_processor->display('add_phrase.tpl');
     } else {
         $phrase_data = $i18n->getPhraseData($phrase_id, $domain_id);
         $template_processor->assign('phrase', $phrase_data);
         $template_processor->display('update_phrase.tpl');
     }
 }
Ejemplo n.º 2
0
 public function execute()
 {
     $uri = parse_url($_SERVER['REQUEST_URI']);
     if (!preg_match("/\\/\$/", $uri['path'])) {
         $uri = parse_url($_SERVER['REQUEST_URI']);
         $query = isset($uri['query']) ? '?' . $uri['query'] : '';
         SJB_HelperFunctions::redirect($uri['path'] . '/' . $query);
     } else {
         $uri = SJB_Request::getVar('browseUrl', $this->getUri());
     }
     $listingTypeId = SJB_Request::getVar('listing_type_id', '');
     $browseManager = SJB_ObjectMother::createBrowseManager($listingTypeId, $this->parameters);
     $browseItems = array();
     if ($browseManager->canBrowse()) {
         if (SJB_Settings::getValue('enableBrowseByCounter')) {
             $browseItems = $browseManager->getItemsFromDB($uri, true);
         } else {
             $browseItems = $browseManager->getItems($this->parameters, true);
         }
     }
     $tp = $this->getTemplateProcessor($browseManager, $listingTypeId);
     $tp->assign('browseItems', $browseItems);
     $tp->assign('recordsNumToDisplay', SJB_Request::getVar('recordsNumToDisplay', 20));
     $tp->assign('user_page_uri', $uri);
     $tp->assign('sitePageUri', SJB_HelperFunctions::getSiteUrl() . $this->getUri());
     $tp->assign('browse_level', $browseManager->getLevel() + 1);
     $tp->assign('browse_navigation_elements', $browseManager->getNavigationElements($uri));
     $tp->display(SJB_Request::getVar('browse_template', 'browse_items_and_results.tpl'));
 }
Ejemplo n.º 3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $listingTypeID = SJB_Request::getVar('listing_type_id', '');
     if (SJB_UserManager::isUserLoggedIn()) {
         if (!SJB_Acl::getInstance()->isAllowed('save_' . trim($listingTypeID))) {
             $errors[] = 'DENIED_VIEW_SAVED_LISTING';
         }
         if (!$errors) {
             $userSid = SJB_UserManager::getCurrentUserSID();
             if (SJB_Request::getVar('action', '') == 'delete') {
                 $listing_id = SJB_Request::getVar('listing_id', null);
                 if (!is_null($listing_id)) {
                     foreach ($listing_id as $key => $value) {
                         SJB_SavedListings::deleteListingFromDBBySID($key, $userSid);
                     }
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . SJB_Navigator::getURI());
                 }
             }
             $saved_listings_id = SJB_SavedListings::getSavedListingsFromDB($userSid);
             $listings_structure = array();
             $listing_structure_meta_data = array();
             foreach ($saved_listings_id as $saved_listing) {
                 $saved_listing_id = $saved_listing['listing_sid'];
                 $listing = SJB_ListingManager::getObjectBySID($saved_listing_id);
                 if (is_null($listing)) {
                     continue;
                 }
                 $listing->addPicturesProperty();
                 $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
                 $listings_structure[$listing->getID()] = $listing_structure;
                 $listings_structure[$listing->getID()]['saved_listing'] = $saved_listing;
                 if (isset($listing_structure['METADATA'])) {
                     $listing_structure_meta_data = array_merge($listing_structure_meta_data, $listing_structure['METADATA']);
                 }
             }
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure_meta_data)));
             $tp->assign("listings", $listings_structure);
             $tp->assign("listing_type_id", $listingTypeID);
             $tp->display("saved_listings.tpl");
         } else {
             $tp->assign("errors", $errors);
             $tp->display("save_search_failed.tpl");
         }
     } else {
         $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/system/classifieds" . SJB_System::getURI());
         switch ($listingTypeID) {
             case 'job':
                 $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/saved-jobs/");
                 break;
             case 'resume':
                 $url = base64_encode(SJB_System::getSystemSettings("SITE_URL") . "/saved-resumes/");
                 break;
         }
         $tp->assign("return_url", $url);
         $tp->display("../users/login.tpl");
     }
 }
Ejemplo n.º 4
0
 public function execute()
 {
     $errors = array();
     $params = array();
     $lang_id = SJB_Request::getVar('languageId', null);
     $i18n = SJB_ObjectMother::createI18N();
     if ($i18n->languageExists($lang_id)) {
         $params = $i18n->getLanguageData($lang_id);
         $params['languageId'] = $lang_id;
         if (isset($_REQUEST['action'])) {
             $action_name = $_REQUEST['action'];
             $form_submitted = SJB_Request::getVar('submit');
             $params = array_merge($params, $_REQUEST);
             $action = SJB_LanguageActionFactory::get($action_name, $params);
             if ($action->canPerform()) {
                 $action->perform();
                 if ($form_submitted == 'save') {
                     SJB_WrappedFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-languages/');
                 }
             } else {
                 $errors = $action->getErrors();
             }
         }
     } else {
         $errors[] = 'LANGUAGE_DOES_NOT_EXIST';
     }
     $template_editor = SJB_ObjectMother::createTemplateEditor();
     $themes = $template_editor->getThemeList();
     $template_processor = SJB_System::getTemplateProcessor();
     $template_processor->assign('themes', $themes);
     $template_processor->assign('lang', $params);
     $template_processor->assign('errors', $errors);
     $template_processor->display('update_language.tpl');
 }
Ejemplo n.º 5
0
 public function execute()
 {
     $errors = array();
     $params = array();
     $template_processor = SJB_System::getTemplateProcessor();
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $params = $_REQUEST;
         $action = SJB_PhraseActionFactory::get($action_name, $params, $template_processor);
         if ($action->canPerform()) {
             $action->perform();
             SJB_WrappedFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-phrases/?action=remember_previous_state&result=' . $action->result);
         } else {
             $errors = $action->getErrors();
         }
     }
     $i18n = SJB_ObjectMother::createI18N();
     $domains = $i18n->getDomainsData();
     $langs = $i18n->getLanguagesData();
     $template_processor->assign('domains', $domains);
     $template_processor->assign('langs', $langs);
     $template_processor->assign('request_data', $_REQUEST);
     $template_processor->assign('errors', $errors);
     $template_processor->display('add_phrase.tpl');
 }
Ejemplo n.º 6
0
 public function execute()
 {
     $count_listing = SJB_Request::getVar('count_listing', 10);
     $listings_structure = array();
     $listing_structure_meta_data = array();
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_sid = SJB_UserManager::getCurrentUserSID();
         $viewed_listings = SJB_UserManager::getRecentlyViewedListingsByUserSid($user_sid, $count_listing);
         if (count($viewed_listings)) {
             foreach ($viewed_listings as $viewed_listing) {
                 $listing = SJB_ListingManager::getObjectBySID($viewed_listing['listing_sid']);
                 if (empty($listing)) {
                     continue;
                 }
                 $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
                 $listings_structure[] = $listing_structure;
                 if (isset($listing_structure['METADATA'])) {
                     $listing_structure_meta_data = array_merge($listing_structure_meta_data, $listing_structure['METADATA']);
                 }
             }
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign("METADATA", array("listing" => $metaDataProvider->getMetaData($listing_structure_meta_data)));
             $tp->assign("listings", $listings_structure);
         }
         $tp->display('recently_viewed_listings.tpl');
     }
 }
Ejemplo n.º 7
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);
 }
Ejemplo n.º 8
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $subAdminSID = SJB_Request::getVar('subadmin', 0);
     if (!empty($subAdminSID) && ($adminInfo = SJB_SubAdminManager::getSubAdminInfoBySID($subAdminSID))) {
         $editedSubAdminInfo = $_REQUEST;
         $subAdminInfo = array_merge($adminInfo, $editedSubAdminInfo);
         // create subAdmin object
         $oSubAdmin = SJB_ObjectMother::createSubAdmin($subAdminInfo);
         $oSubAdmin->setSID($adminInfo['sid']);
         $oSubAdmin->makePropertyNotRequired("password");
         // permissions
         $acl = SJB_SubAdminAcl::getInstance();
         $type = 'subadmin';
         $resources = $acl->getResources();
         $perms = SJB_SubAdminAcl::getAllPermissions($type, $oSubAdmin->getSID());
         // /permissions
         SJB_SubAdminAcl::mergePermissionsWithResources($resources, $perms);
         $registration_form = SJB_ObjectMother::createForm($oSubAdmin);
         $action = SJB_Request::getVar('action', '');
         $registration_form->registerTags($tp);
         $errors = array();
         if ('save' == $action || $action == 'apply') {
             if ($adminInfo['username'] == $subAdminInfo['username']) {
                 $oSubAdmin->deleteProperty('username');
             }
             if ($adminInfo['email'] == $subAdminInfo['email']) {
                 $oSubAdmin->deleteProperty('email');
             }
             if ($registration_form->isDataValid($errors)) {
                 $password_value = $oSubAdmin->getPropertyValue('password');
                 if (empty($password_value['original'])) {
                     $oSubAdmin->deleteProperty('password');
                 }
                 // save subAdmin
                 SJB_SubAdminManager::saveSubAdmin($oSubAdmin);
                 $role = $oSubAdmin->getSID();
                 SJB_Acl::clearPermissions($type, $role);
                 foreach ($resources as $name => $resource) {
                     SJB_SubAdminAcl::allow($name, $type, $role, SJB_SubAdminAcl::definePermission($name), SJB_Array::get($resource, 'params', ''));
                 }
                 SJB_FlashMessages::getInstance()->addMessage('CHANGES_SAVED');
                 if ($action == 'save') {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-subadmins/");
                 }
             }
             SJB_SubAdminAcl::mergePermissionsWithRequest($resources);
         }
         SJB_SubAdminAcl::prepareSubPermissions($resources);
         $tp->assign("errors", $errors);
         $tp->assign("form_fields", $registration_form->getFormFieldsInfo());
         $tp->assign('groups', SJB_SubAdminAcl::getPermissionGroups());
         $tp->assign('resources', $resources);
         $tp->assign('type', $type);
         $tp->assign('sid', $subAdminInfo['sid']);
         $tp->display('add_subadmin.tpl');
     }
 }
Ejemplo n.º 9
0
 function _format_value_with_signs_num()
 {
     $i18n = SJB_ObjectMother::createI18N();
     $value = $i18n->getInput('float', $this->property_info['value']);
     if (isset($this->property_info['signs_num']) && is_numeric($this->property_info['signs_num'])) {
         return sprintf("%0." . $this->property_info['signs_num'] . "f", $value);
     }
     return $value;
 }
Ejemplo n.º 10
0
 function getSQLValue()
 {
     $i18n = SJB_ObjectMother::createI18N();
     $value = $this->property_info['value']['value'];
     if ($i18n->isValidFloat($value)) {
         return $i18n->getInput('float', $this->property_info['value']['value']);
     }
     return $this->property_info['value']['value'];
 }
Ejemplo n.º 11
0
 /**
  * Search listing|listings which fits "browse" page parameters
  * @param array $page full parammeters of site page with function "browse"
  * @param bool  $decorate false means return only array with values:
  * page /browse-by-occupations/ would return array('Bank Teller' = 14, 'Electrician' = 8...)
  * true means return ready html or processed values:
  * page /browse-by-occupations/ would return "<label><a href='/browse-by-occupations/334/Bank-Teller'>Bank Teller(349)</a>..."
  * @param array|int $listingSids if not empty search only among passed listing sids
  * @return array|string array with found values or ready html code
  */
 private static function getItems($page, $decorate = false, array $listingSids = array())
 {
     if (!SJB_Settings::getValue('enableBrowseByCounter')) {
         return array();
     }
     $parameters = unserialize($page['parameters']);
     $browseManager = SJB_ObjectMother::createBrowseManager($parameters['listing_type_id'], $parameters);
     return $browseManager->getItems($parameters, $decorate, $listingSids);
 }
Ejemplo n.º 12
0
 protected function _decorateItems($items)
 {
     $listingFieldListItemManager = SJB_ObjectMother::createListingFieldListItemManager();
     $values = $listingFieldListItemManager->getHashedListItemsByFieldSID($this->field['sid']);
     $values = $this->getSortedValues($values);
     $listData = array();
     foreach ($values as $id => $value) {
         $listData[$value] = isset($items[$id]) ? $items[$id] : 0;
     }
     return $listData;
 }
Ejemplo n.º 13
0
 public static function getDetails()
 {
     // GET LANGUAGES LIST
     $i18N = SJB_ObjectMother::createI18N();
     $frontEndLanguages = $i18N->getActiveFrontendLanguagesData();
     $languages = array();
     foreach ($frontEndLanguages as $lang) {
         $languages[] = array('id' => $lang['id'], 'caption' => $lang['caption']);
     }
     $details = array(array('id' => 'title', 'caption' => 'Title', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => 0), array('id' => 'language', 'caption' => 'Language', 'type' => 'list', 'length' => '30', 'is_required' => false, 'is_system' => true, 'order' => 1, 'list_values' => $languages), array('id' => 'brief', 'caption' => 'Brief Text', 'type' => 'text', 'length' => '1000', 'is_required' => true, 'is_system' => true, 'order' => 2), array('id' => 'text', 'caption' => 'Full Text', 'type' => 'text', 'length' => '64535', 'is_required' => false, 'is_system' => true, 'order' => 3), array('id' => 'keywords', 'caption' => 'Keywords', 'type' => 'string', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 4), array('id' => 'description', 'caption' => 'Description', 'type' => 'string', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 5), array('id' => 'link', 'caption' => 'Redirect To URL:', 'type' => 'string', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 6), array('id' => 'date', 'caption' => 'Publication Date', 'type' => 'date', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => 7), array('id' => 'expiration_date', 'caption' => 'Expiration Date', 'type' => 'date', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => 8), array('id' => 'image', 'caption' => 'Image', 'type' => 'picture', 'length' => '255', 'is_required' => false, 'is_system' => true, 'order' => 9, 'width' => 100, 'height' => 100), array('id' => 'category_id', 'caption' => 'Category', 'type' => 'id', 'length' => '20', 'is_required' => false, 'is_system' => true, 'order' => 10), array('id' => 'active', 'caption' => 'Active', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 11));
     return $details;
 }
Ejemplo n.º 14
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $oSubAdmin = SJB_ObjectMother::createSubAdmin($_REQUEST);
     $registration_form = SJB_ObjectMother::createForm($oSubAdmin);
     $registration_form->registerTags($tp);
     $form_submitted = SJB_Request::getVar('action', '') == 'add';
     $errors = array();
     $acl = SJB_SubAdminAcl::getInstance();
     $type = 'subadmin';
     $resources = $acl->getResources();
     SJB_SubAdminAcl::mergePermissionsWithResources($resources);
     switch (SJB_Request::getVar('action')) {
         case 'save':
             if ($registration_form->isDataValid($errors)) {
                 SJB_SubAdminManager::saveSubAdmin($oSubAdmin);
                 $role = $oSubAdmin->getSID();
                 SJB_Acl::clearPermissions($type, $role);
                 foreach ($resources as $name => $resource) {
                     SJB_SubAdminAcl::allow($name, $type, $role, SJB_SubAdminAcl::definePermission($name), SJB_Request::getVar($name . '_params'));
                 }
                 // get new defined permissions for notification letter
                 $permissions = SJB_SubAdminAcl::getAllPermissions($type, $role);
                 $resources = $acl->getResources();
                 SJB_SubAdminAcl::mergePermissionsWithResources($resources, $permissions);
                 SJB_Notifications::sendSubAdminRegistrationLetter($oSubAdmin, SJB_Request::get(), $resources);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-subadmins/');
             }
             break;
         case 'delete':
             $subadmins = SJB_Request::getVar('subadmin', array());
             foreach ($subadmins as $subadmin_sid) {
                 $username = SJB_SubAdminManager::getUserNameBySubAdminSID($subadmin_sid);
                 SJB_SubAdminManager::deleteSubAdminByUserName($username);
             }
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-subadmins/');
             break;
         default:
             break;
     }
     $tp->assign('errors', $errors);
     $tp->assign('form_fields', $registration_form->getFormFieldsInfo());
     $aPermissionGroups = SJB_SubAdminAcl::getPermissionGroups();
     if ('save' == SJB_Request::getVar('action', '')) {
         SJB_SubAdminAcl::mergePermissionsWithRequest($resources);
     }
     SJB_SubAdminAcl::prepareSubPermissions($resources);
     $tp->assign('groups', $aPermissionGroups);
     $tp->assign('resources', $resources);
     $tp->assign('type', $type);
     $tp->assign('role', 0);
     $tp->display('add_subadmin.tpl');
 }
Ejemplo n.º 15
0
 /**
  * Constructor explains our requirements to Smarty
  *
  * @param SJB_TemplateSupplier $templatesupplier instatance of SJB_TemplateSupplier class
  * @return SJB_TemplateProcessor
  */
 function __construct($templatesupplier)
 {
     $this->htmlTagConverter = SJB_ObjectMother::createHTMLTagConverterInArray();
     $this->compile_check = true;
     $this->module_name = $templatesupplier->getModuleName();
     parent::__construct();
     $this->error_reporting = E_ALL ^ E_NOTICE;
     $this->setCompileDir(SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR') . SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') . '/' . $templatesupplier->getTheme());
     if (!@is_dir($this->getCompileDir())) {
         @mkdir($this->getCompileDir(), 0777, true);
     }
     $this->setCacheDir(SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR') . '/smarty_cache');
     if (!@is_dir($this->getCacheDir())) {
         @mkdir($this->getCacheDir(), 0777, true);
     }
     /**
      * Check for 'cache_control_file.cache' in compile dir. If exists - clear compile dir.
      * Then if 'highlight_templates' mode is ON, and user is 'admin' - create 'cache_control_file'.
      */
     $cacheControlFile = $this->compile_dir . '/cache_control_file.cache';
     if (file_exists($cacheControlFile)) {
         $this->clearAllCache();
         $this->clearCompiledTemplate();
     }
     if (SJB_Settings::getSettingByName('highlight_templates') == 1 && SJB_Request::getVar('admin_mode', false, 'COOKIE')) {
         $fp = fopen($cacheControlFile, 'w');
         fclose($fp);
     }
     /////////////////////////
     $this->registerPlugin('function', 'module', array(&$this, 'module'));
     $this->registerPlugin('function', 'hidden_form_fields', array(&$this, 'hidden_form_fields'));
     $this->registerPlugin('function', 'url', array(&$this, 'get_module_function_url'));
     $this->registerPlugin('function', 'event', array(&$this, 'dispatch_event'));
     $currencyFormatter = new SJB_CurrencyFormatter();
     $this->registerPlugin('function', 'currencyFormat', array($currencyFormatter, 'currencyFormat'));
     $this->registerPlugin('function', 'locationFormat', 'SJB_LocationManager::locationFormat');
     /////////////////////////
     $this->registerPlugin('block', 'title', array(&$this, '_tpl_title'));
     $this->registerPlugin('block', 'keywords', array(&$this, '_tpl_keywords'));
     $this->registerPlugin('block', 'description', array(&$this, '_tpl_description'));
     $this->registerPlugin('block', 'head', array(&$this, '_tpl_head'));
     $this->registerPlugin('block', 'breadcrumbs', array(&$this, '_tpl_breadcrumbs'));
     $this->registerFilter('pre', array(&$this, '_replace_translation_alias'));
     $this->registerPlugin('block', 'tr', array(&$this, 'translate'));
     $templatesupplier->registerResources($this);
     $this->templateSupplier = $templatesupplier;
     $this->registerPlugin('function', 'set_token_field', array(&$this, 'tpl_set_token_field'));
     $this->registerGlobalVariables();
 }
Ejemplo n.º 16
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $contact_form = SJB_ObjectMother::createContactForm();
     $contact_form->parseRequestedData($_REQUEST);
     if ($contact_form->isFormSubmitted()) {
         $errors = !$contact_form->isDataValid() ? $contact_form->getFieldErrors() : array();
         SJB_Captcha::getInstance($tp, $_REQUEST)->isValid($errors);
         if (!$errors) {
             $contact_form->sendMessage();
             $tp->assign('message_sent', true);
         } else {
             $tp->assign('field_errors', $errors);
         }
     }
     $contact_form->assignTemplateVariables($tp);
     $tp->display('contact_form.tpl');
 }
Ejemplo n.º 17
0
 public function execute()
 {
     $errors = array();
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $action = SJB_LanguageActionFactory::get($action_name, $_REQUEST);
         if ($action->canPerform()) {
             $action->perform();
         } else {
             $errors = $action->getErrors();
         }
     }
     $i18n = SJB_ObjectMother::createI18N();
     $langs_data = $i18n->getLanguagesData();
     $template_processor = SJB_System::getTemplateProcessor();
     $template_processor->assign('langs', $langs_data);
     $template_processor->assign('errors', $errors);
     $template_processor->display('languages.tpl');
 }
Ejemplo n.º 18
0
 protected function _decorateItems($items)
 {
     if (!empty($this->field['parent']) && in_array($this->field['field'], array($this->field['parent'] . '_State', $this->field['parent'] . '_Country'))) {
         $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($this->field['sid']);
         if ($this->field['field'] == $this->field['parent'] . '_State') {
             $values = SJB_StatesManager::getHashedListItems($fieldInfo['display_as']);
         } elseif ($this->field['field'] == $this->field['parent'] . '_Country') {
             $values = SJB_CountriesManager::getHashedListItems($fieldInfo['display_as']);
         }
     } else {
         $listingFieldListItemManager = SJB_ObjectMother::createListingFieldListItemManager();
         $values = $listingFieldListItemManager->getHashedListItemsByFieldSID($this->field['sid']);
     }
     $values = $this->getSortedValues($values);
     $listData = array();
     foreach ($values as $id => $value) {
         $listData[$value] = isset($items[$id]) ? $items[$id] : 0;
     }
     return $listData;
 }
Ejemplo n.º 19
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');
 }
Ejemplo n.º 20
0
 public function execute()
 {
     $errors = array();
     $result = '';
     $paginator = new SJB_ManagePhrasesPagination();
     $template_processor = SJB_System::getTemplateProcessor();
     $foundPhrases = '';
     if (isset($_REQUEST['action'])) {
         $action_name = $_REQUEST['action'];
         $paginator->setUniqueUrlParams($_REQUEST);
         $params = $_REQUEST;
         $action = SJB_PhraseActionFactory::get($action_name, $params, $template_processor);
         if ($action->canPerform()) {
             $action->perform();
             $result = isset($_REQUEST['result']) ? $_REQUEST['result'] : $action->result;
             $total = $this->getPhrasesCount();
             $paginator->setItemsCount($total);
             if ($paginator->itemsPerPage == 'all') {
                 $foundPhrases = self::$phrases;
             } else {
                 $foundPhrases = $this->getPhrasesByPage($paginator->currentPage, $paginator->itemsPerPage);
             }
         } else {
             $errors = $action->getErrors();
         }
     } else {
         $template_processor->assign('criteria', $_REQUEST);
     }
     $i18n = SJB_ObjectMother::createI18N();
     $domains = $i18n->getDomainsData();
     $languages = $i18n->getLanguagesData();
     $template_processor->assign('paginationInfo', $paginator->getPaginationInfo());
     $template_processor->assign('result', $result);
     $template_processor->assign('domains', $domains);
     $template_processor->assign('languages', $languages);
     $template_processor->assign('errors', $errors);
     $template_processor->assign('found_phrases', $foundPhrases);
     $template_processor->display('manage_phrases.tpl');
 }
Ejemplo n.º 21
0
 public function execute()
 {
     $errors = array();
     $phrase_data = array();
     $result = '';
     $phrase_id = isset($_REQUEST['phrase']) ? $_REQUEST['phrase'] : null;
     $domain_id = isset($_REQUEST['domain']) ? $_REQUEST['domain'] : null;
     $lang_id = isset($_REQUEST['current_lang']) ? $_REQUEST['current_lang'] : null;
     $i18n = SJB_ObjectMother::createI18N();
     $template_processor = SJB_System::getTemplateProcessor();
     if ($i18n->phraseExists($phrase_id, $domain_id)) {
         $phrase_data = $i18n->getPhraseData($phrase_id, $domain_id);
         if (isset($_REQUEST['action'])) {
             $action_name = $_REQUEST['action'];
             $params = $_REQUEST;
             $action = SJB_PhraseActionFactory::get($action_name, $params, $template_processor);
             if ($action->canPerform()) {
                 $action->perform();
                 $result = $action->result;
             } else {
                 $errors = $action->getErrors();
                 $phrase_data = array_merge($phrase_data, $_REQUEST);
             }
         }
     } else {
         $errors[] = 'PHRASE_NOT_EXISTS';
     }
     $domains = $i18n->getDomainsData();
     $langs = $i18n->getLanguagesData();
     $template_processor->assign('result', $result);
     $template_processor->assign('phrase', $phrase_data);
     $template_processor->assign('domains', $domains);
     $template_processor->assign('langs', $langs);
     $template_processor->assign('chosen_lang', $lang_id);
     $template_processor->assign('errors', $errors);
     $template_processor->display('update_phrase.tpl');
 }
Ejemplo n.º 22
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action_name', false);
     $action = $action ? $action : 'list';
     $template = 'manage_polls.tpl';
     $errors = array();
     switch ($action) {
         case 'new':
             $template = 'input_form_poll.tpl';
             $_REQUEST['start_date'] = date('Y-m-d');
             $field = new SJB_PollsManager($_REQUEST);
             $form = new SJB_Form($field);
             $form->registerTags($tp);
             $tp->assign('form_fields', $form->getFormFieldsInfo());
             break;
         case 'save':
             $sid = SJB_Request::getVar('sid');
             $_REQUEST['value'] = strip_tags(SJB_Request::getVar('value'));
             $_REQUEST['user_group_sid'] = SJB_Request::getInt('user_group_sid', 0);
             $field = new SJB_PollsManager($_REQUEST);
             if ($sid) {
                 $field->setSID($sid);
             }
             $form = new SJB_Form($field);
             if ($form->isDataValid($errors)) {
                 SJB_PollsManager::savePoll($field);
                 $_REQUEST['sid'] = $field->sid;
                 $save = SJB_Request::getVar('save', false);
                 $action = 'edit';
                 if ($save) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-polls/');
                     break;
                 }
             } else {
                 $action = 'new';
                 if ($sid) {
                     $action = 'edit';
                 }
                 $template = 'input_form_poll.tpl';
                 $field->setSID($sid);
                 $form->registerTags($tp);
                 $tp->assign('form_fields', $form->getFormFieldsInfo());
                 $tp->assign('errors', $errors);
                 $tp->assign('sid', $sid);
                 break;
             }
         case 'edit':
             $sid = SJB_Request::getVar('sid');
             $info = SJB_PollsManager::getPollInfoBySID($sid);
             $field = new SJB_PollsManager($info);
             $edit_form = new SJB_Form($field);
             $edit_form->registerTags($tp);
             $field->setSID($sid);
             $tp->assign('form_fields', $edit_form->getFormFieldsInfo());
             $tp->assign('sid', $sid);
             $tp->assign('action', 'edit');
             $template = 'input_form_poll.tpl';
             break;
         case 'edit_answer':
             $sid = SJB_Request::getVar('sid');
             $_REQUEST['field_sid'] = $sid;
             $event = SJB_Request::getVar('event');
             $pollInfo = SJB_PollsManager::getPollInfoBySID($sid);
             $edit_list_controller = new SJB_PollsEditListController($_REQUEST, $pollInfo);
             switch ($event) {
                 case 'add':
                     $item_sid = SJB_Request::getVar('item_sid');
                     if ($edit_list_controller->isValidValueSubmitted()) {
                         if ($item_sid) {
                             $pollItemManager = new SJB_PollsListItemManager();
                             $list_item = $pollItemManager->getListItemBySID($item_sid);
                             $list_item->setValue(trim($_REQUEST['list_item_value']));
                             $pollItemManager->saveListItem($list_item);
                         } else {
                             if (!$edit_list_controller->saveItem()) {
                                 $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS');
                             }
                         }
                     } else {
                         $tp->assign('error', 'LIST_VALUE_IS_EMPTY');
                     }
                     break;
                 case 'edit':
                     $item_sid = SJB_Request::getVar('item_sid');
                     $pollItemManager = new SJB_PollsListItemManager();
                     $list_item = $pollItemManager->getListItemBySID($item_sid);
                     $tp->assign('item_sid', $list_item->sid);
                     $tp->assign('item_value', $list_item->value);
                     $tp->assign('item_action', 'edit');
                     break;
                 case 'add_multiple':
                     if ($edit_list_controller->isValidMultiValueSubmitted()) {
                         if (!$edit_list_controller->saveItem(true)) {
                             $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS');
                         }
                     } else {
                         $tp->assign('error', 'LIST_VALUE_IS_EMPTY');
                     }
                     break;
                 case 'delete':
                     $item_sid = SJB_Request::getVar('item_sid');
                     if (is_array($item_sid)) {
                         foreach ($item_sid as $sid => $val) {
                             $edit_list_controller->deleteItem($sid);
                         }
                     } else {
                         $edit_list_controller->deleteItem();
                     }
                     break;
                 case 'move_up':
                     $edit_list_controller->moveUpItem();
                     break;
                 case 'move_down':
                     $edit_list_controller->moveDownItem();
                     break;
                 case 'save_order':
                     if ($item_order = SJB_Request::getVar('item_order', false)) {
                         $edit_list_controller->saveNewItemsOrder($item_order);
                     }
                     break;
                 case 'sort':
                     $edit_list_controller->sortItems(SJB_Request::getVar('field_sid'), SJB_Request::getVar('sorting_order'));
                     $tp->assign('sorting_order', SJB_Request::getVar('sorting_order'));
                     break;
             }
             $display_list_controller = new SJB_PollsDisplayListController($_REQUEST, $pollInfo);
             $display_list_controller->setTemplateProcessor($tp);
             $display_list_controller->display('edit_answer.tpl');
             break;
         case 'delete':
             $sid = SJB_Request::getVar('sid', false);
             $sids = SJB_Request::getVar('polls', false);
             if ($sid) {
                 SJB_PollsManager::deletePollBySID($sid);
             } else {
                 if ($sids) {
                     foreach ($sids as $sid => $val) {
                         SJB_PollsManager::deletePollBySID($sid);
                     }
                 } else {
                     $errors[] = 'NO_POLLS_SELECTED';
                 }
             }
             $action = 'list';
             break;
         case 'activate':
             $sids = SJB_Request::getVar('polls');
             if (is_array($sids)) {
                 foreach ($sids as $sid => $val) {
                     SJB_PollsManager::activatePollBySID($sid);
                 }
             } else {
                 $errors[] = 'NO_POLLS_SELECTED';
             }
             $action = 'list';
             break;
         case 'deactivate':
             $sids = SJB_Request::getVar('polls');
             if (is_array($sids)) {
                 foreach ($sids as $sid => $val) {
                     SJB_PollsManager::deactivatePollBySID($sid);
                 }
             } else {
                 $errors[] = 'NO_POLLS_SELECTED';
             }
             $action = 'list';
             break;
         case 'save_display_setting':
             $settings = SJB_Request::getVar('settings');
             SJB_Settings::updateSettings($settings);
             $action = 'list';
             break;
         case 'view_results':
             $sid = SJB_Request::getVar('sid', 0);
             $countVotes = SJB_PollsManager::getCountVotesBySID($sid);
             $pollResults = SJB_PollsManager::getPollResultsBySID($sid);
             $result = array();
             $i = 0;
             $colors = array('613978', 'aad434', 'f55c00', 'f9c635', 'f97c9e', '870000', '0ec300', '6f6f6f', '0400a5', '6eeffb', '000000', 'ff00ff');
             foreach ($pollResults as $poll) {
                 $result[$i]['vote'] = $countVotes > 0 ? round(100 / $countVotes * $poll['count'], 2) : 0;
                 $result[$i]['width'] = $countVotes > 0 ? round(300 / $countVotes * $poll['count'], 2) : 0;
                 $result[$i]['value'] = $poll['question'];
                 $result[$i]['color'] = $colors[$i];
                 $i++;
             }
             $pollInfo = SJB_PollsManager::getPollInfoBySID($sid);
             $tp->assign('pollInfo', $pollInfo);
             $tp->assign('result', $result);
             $tp->assign('width', count($pollResults) * 40 + (count($pollResults) - 1) * 3);
             $tp->assign('count_vote', $countVotes);
             $template = 'view_result.tpl';
             break;
     }
     if ($action == 'list') {
         $paginator = new SJB_PollsManagePagination();
         $pollsCount = 0;
         $pollsInfo = SJB_PollsManager::getPollsInfo($paginator->sortingField, $paginator->sortingOrder, ($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage, $pollsCount);
         $paginator->setItemsCount($pollsCount);
         $showPollsOnMainPage = SJB_Settings::getSettingByName('show_polls_on_main_page');
         $tp->assign('errors', $errors);
         $tp->assign('frontendLanguages', SJB_ObjectMother::createI18N()->getActiveFrontendLanguagesData());
         $tp->assign('pollsInfo', $pollsInfo);
         $tp->assign('show_polls_on_main_page', $showPollsOnMainPage);
         $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     }
     if ($action !== 'edit_answer') {
         $tp->assign('action', $action);
         $tp->assign('polls', 1);
         $tp->display($template);
     }
 }
Ejemplo n.º 23
0
 private static function _deleteListingBySID($listing_sid)
 {
     SJB_Event::dispatch('beforeListingDelete', $listing_sid);
     $gallery = SJB_ObjectMother::createListingGallery();
     $gallery->setListingSID($listing_sid);
     $gallery->deleteImages();
     SJB_UploadFileManager::deleteUploadedFilesByListingSID($listing_sid);
     SJB_CommentManager::deleteCommentsToListing($listing_sid);
     SJB_ListingManager::deleteListingIDFromSendedNotificationsTable($listing_sid);
     //delete listing keywords
     SJB_ListingDBManager::deleteListingKeywords($listing_sid);
     SJB_Cache::getInstance()->clean('matchingAnyTag', array(SJB_Cache::TAG_LISTINGS));
     SJB_ListingDBManager::deleteListingBySID($listing_sid);
 }
Ejemplo n.º 24
0
 function importLangFile($file_name, $file_path)
 {
     $languageID = $this->fileHelper->getLanguageIDForImportFile($file_name);
     $file_paths = $this->fileHelper->getFilePathToLangFiles($languageID);
     $trAdminFactory = new Translation2AdminFactory();
     $trAdmin = $trAdminFactory->createTrAdmin($file_path, true, true, $file_path);
     $trAdmin->getLanguagePages();
     // set new lang paths
     $trAdmin->storage->setFileName($file_paths['languages']);
     $trAdmin->storage->setPagesFileNameOption($file_paths['pages']);
     //check meta separators
     if (isset($trAdmin->storage->_data['languages'][$languageID]['meta'])) {
         $meta = unserialize($trAdmin->storage->_data['languages'][$languageID]['meta']);
         if (isset($meta['decimal_separator']) && isset($meta['thousands_separator'])) {
             if (!$meta['decimal_separator']) {
                 $meta['decimal_separator'] = !$meta['thousands_separator'] || $meta['thousands_separator'] == ',' ? '.' : ',';
             }
             if (!$meta['thousands_separator']) {
                 $meta['thousands_separator'] = !$meta['decimal_separator'] || $meta['decimal_separator'] == ',' ? '.' : ',';
             }
         } else {
             $meta['decimal_separator'] = '.';
             $meta['thousands_separator'] = ',';
         }
         $trAdmin->storage->_data['languages'][$languageID]['meta'] = serialize($meta);
     }
     $trAdmin->storage->_saveData();
     $fileSystem = SJB_ObjectMother::createFileSystem();
     $fileSystem->deleteFile($file_path);
     return true;
 }
Ejemplo n.º 25
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);
 }
Ejemplo n.º 26
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $template = 'sub_accounts.tpl';
     $currentUserInfo = SJB_UserManager::getCurrentUserInfo();
     $listSubusers = false;
     if (!empty($currentUserInfo['subuser']) && SJB_Request::getVar('action_name') != 'edit' && SJB_Request::getVar('user_id', 0) != $currentUserInfo['subuser']['sid']) {
         $errors['ACCESS_DENIED'] = 'ACCESS_DENIED';
     }
     switch (SJB_Request::getVar('action_name')) {
         case 'new':
             $form_submitted = SJB_Request::getMethod() === SJB_Request::METHOD_POST;
             $user_group_sid = $currentUserInfo['user_group_sid'];
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $_REQUEST['user_group_id'] = $user_group_info['id'];
             $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
             $props = $user->getProperties();
             $allowedProperties = array('username', 'email', 'password');
             foreach ($props as $prop) {
                 if (!in_array($prop->getID(), $allowedProperties)) {
                     $user->deleteProperty($prop->getID());
                 }
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             $registration_form->registerTags($tp);
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) {
                 $email = $user->getPropertyValue('email');
                 if (is_array($email)) {
                     $email = $email['original'];
                 }
                 $user->setPropertyValue('username', $email);
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             if ($form_submitted && $registration_form->isDataValid($errors)) {
                 $user->addParentProperty($currentUserInfo['sid']);
                 $subuserPermissions = array('subuser_add_listings' => array('title' => 'Add new listings', 'value' => 'deny'), 'subuser_manage_listings' => array('title' => 'Manage listings and applications of other sub users', 'value' => 'deny'), 'subuser_manage_subscription' => array('title' => 'View and update subscription', 'value' => 'deny'), 'subuser_use_screening_questionnaires' => array('title' => 'Manage Questionnaries', 'value' => 'deny'));
                 SJB_UserManager::saveUser($user);
                 SJB_Statistics::addStatistics('addSubAccount', $user->getUserGroupSID(), $user->getSID());
                 SJB_Acl::clearPermissions('user', $user->getSID());
                 foreach ($subuserPermissions as $permissionID => $permission) {
                     $allowDeny = SJB_Request::getVar($permissionID, 'deny');
                     $subuserPermissions[$permissionID]['value'] = $allowDeny;
                     SJB_Acl::allow($permissionID, 'user', $user->getSID(), $allowDeny);
                 }
                 SJB_UserManager::activateUserByUserName($user->getUserName());
                 SJB_Notifications::sendSubuserRegistrationLetter($user, SJB_Request::get(), $subuserPermissions);
                 $tp->assign('isSubuserRegistered', true);
                 $listSubusers = true;
             } else {
                 if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                     $user->deleteProperty("username");
                 }
                 $registration_form = SJB_ObjectMother::createForm($user);
                 if ($form_submitted) {
                     $registration_form->isDataValid($errors);
                 }
                 $registration_form->registerTags($tp);
                 $form_fields = $registration_form->getFormFieldsInfo();
                 $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
                 $tp->assign("user_group_info", $user_group_info);
                 $tp->assign("errors", $errors);
                 $tp->assign("form_fields", $form_fields);
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
                 $tp->display('subuser_registration_form.tpl');
             }
             break;
         case 'edit':
             $userInfo = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_id', 0));
             if (!empty($userInfo) && $userInfo['parent_sid'] === $currentUserInfo['sid']) {
                 $userInfo = array_merge($userInfo, $_REQUEST);
                 $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']);
                 $user = new SJB_User($userInfo, $userInfo['user_group_sid']);
                 $user->setSID($userInfo['sid']);
                 $user->addParentProperty($currentUserInfo['sid']);
                 $props = $user->getProperties();
                 $allowedProperties = array('username', 'email', 'password');
                 foreach ($props as $prop) {
                     if (!in_array($prop->getID(), $allowedProperties)) {
                         $user->deleteProperty($prop->getID());
                     }
                 }
                 $user->makePropertyNotRequired("password");
                 $edit_profile_form = SJB_ObjectMother::createForm($user);
                 $edit_profile_form->registerTags($tp);
                 $edit_profile_form->makeDisabled("username");
                 $form_submitted = SJB_Request::getMethod() == SJB_Request::METHOD_POST;
                 if (empty($errors) && $form_submitted && $edit_profile_form->isDataValid($errors)) {
                     $password_value = $user->getPropertyValue('password');
                     if (empty($password_value['original'])) {
                         $user->deleteProperty('password');
                     }
                     $currentUser = SJB_UserManager::getCurrentUser();
                     if (!$currentUser->isSubuser()) {
                         $subuserPermissions = array('subuser_add_listings', 'subuser_manage_listings', 'subuser_manage_subscription', 'subuser_use_screening_questionnaires');
                         SJB_Acl::clearPermissions('user', $user->getSID());
                         foreach ($subuserPermissions as $permission) {
                             SJB_Acl::allow($permission, 'user', $user->getSID(), SJB_Request::getVar($permission, 'deny'));
                         }
                     }
                     SJB_UserManager::saveUser($user);
                     $tp->assign("form_is_submitted", true);
                 } else {
                     $tp->assign("errors", $errors);
                 }
                 $form_fields = $edit_profile_form->getFormFieldsInfo();
                 $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
                 $tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
                 $tp->assign("form_fields", $form_fields);
                 $tp->assign('user_info', $userInfo);
                 $tp->display('edit_subuser_profile.tpl');
             }
             break;
         case 'delete':
             $users = SJB_Request::getVar('user_id', array());
             foreach ($users as $user) {
                 SJB_UserManager::deleteUserById($user);
             }
             $listSubusers = true;
             break;
         default:
             $listSubusers = true;
             break;
     }
     if ($listSubusers) {
         $tp->assign('errors', $errors);
         $tp->assign('subusers', SJB_UserManager::getSubusers($currentUserInfo['sid']));
         $tp->assign('isEmailAsUsername', SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($currentUserInfo['user_group_sid']));
         $tp->display($template);
     }
 }
Ejemplo n.º 27
0
 public function execute()
 {
     $formToken = SJB_Request::getVar('form_token');
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('form_token', $formToken);
     $post_max_size_orig = ini_get('post_max_size');
     $server_content_length = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : null;
     // get post_max_size in bytes
     $val = trim($post_max_size_orig);
     $tmp = substr($val, strlen($val) - 1);
     $tmp = strtolower($tmp);
     switch ($tmp) {
         case 'g':
             $val *= 1024;
             break;
         case 'm':
             $val *= 1024;
             break;
         case 'k':
             $val *= 1024;
             break;
     }
     $post_max_size = $val;
     $errors = array();
     if (SJB_Request::getVar('from-preview', false, 'POST') && !SJB_Request::getVar('action_add', false, 'POST')) {
         $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int');
         $previewListingId = SJB_Session::getValue('preview_listing_sid');
         if ($previewListingId && SJB_ListingManager::isListingExists($previewListingId)) {
             $listingId = $previewListingId;
         }
     } else {
         $listingId = SJB_Request::getVar('listing_id', null, 'default', 'int');
     }
     $template = SJB_Request::getVar('edit_template', 'edit_listing.tpl');
     $filename = SJB_Request::getVar('filename', false);
     if ($filename) {
         SJB_UploadFileManager::openFile($filename, $listingId);
         // if file not found - set error here
         $errors['NO_SUCH_FILE'] = true;
     }
     if (empty($_POST) && $server_content_length > $post_max_size) {
         $errors['MAX_FILE_SIZE_EXCEEDED'] = 1;
         $listingId = SJB_Request::getVar('listing_id', null, 'GET', 'int');
         $tp->assign('post_max_size', $post_max_size_orig);
     }
     $current_user = SJB_UserManager::getCurrentUser();
     $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
     // for listing preview
     $formSubmittedFromPreview = false;
     if (empty($listingInfo)) {
         $listingId = SJB_Session::getValue('preview_listing_sid');
         $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
         if (!empty($listingInfo)) {
             // if on preview page 'POST' button was pressed
             $formSubmittedFromPreview = SJB_Request::getVar('action_add', false, 'POST') && SJB_Request::getVar('from-preview', false, 'POST');
             if ($formSubmittedFromPreview) {
                 $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']);
                 $properties = $listing->getProperties();
                 foreach ($properties as $fieldID => $property) {
                     switch ($property->getType()) {
                         case 'date':
                             if (!empty($listingInfo[$fieldID])) {
                                 $listingInfo[$fieldID] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID]);
                             }
                             break;
                         case 'complex':
                             $complex = $property->type->complex;
                             $complexProperties = $complex->getProperties();
                             foreach ($complexProperties as $complexfieldID => $complexProperty) {
                                 if ($complexProperty->getType() == 'date') {
                                     $values = $complexProperty->getValue();
                                     foreach ($values as $index => $value) {
                                         if (!empty($listingInfo[$fieldID][$complexfieldID][$index])) {
                                             $listingInfo[$fieldID][$complexfieldID][$index] = SJB_I18N::getInstance()->getDate($listingInfo[$fieldID][$complexfieldID][$index]);
                                         }
                                     }
                                 }
                             }
                             break;
                     }
                 }
             }
         } else {
             $listingId = null;
             SJB_Session::unsetValue('preview_listing_sid');
         }
     }
     // if preview button was pressed
     $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
     if (SJB_UserManager::isUserLoggedIn()) {
         if ($listingInfo['user_sid'] != $current_user->getID()) {
             $errors['NOT_OWNER_OF_LISTING'] = $listingId;
         } elseif (!is_null($listingInfo)) {
             $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingInfo['listing_type_sid']);
             $form_is_submitted = SJB_Request::getVar('action', '') == 'save_info' || SJB_Request::getVar('action', '') == 'add' || $isPreviewListingRequested || $formSubmittedFromPreview;
             if (!$form_is_submitted && !SJB_Request::getVar('from-preview', false, 'POST')) {
                 SJB_Session::unsetValue('previewListingId');
                 SJB_Session::unsetValue('preview_listing_sid_or');
             }
             // fill listing from an array of social data if allowed
             $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listingInfo['listing_type_sid']);
             $listingTypeID = $listing_type_info['id'];
             $aAutoFillData = array('formSubmitted' => $form_is_submitted, 'listingTypeID' => $listingTypeID);
             SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
             $listingInfo = array_merge($listingInfo, $_REQUEST);
             $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']);
             $listing->deleteProperty('ListingLogo');
             $listing->deleteProperty('featured');
             $listing->deleteProperty('priority');
             $listing->deleteProperty('reject_reason');
             $listing->deleteProperty('status');
             $list_emp_ids = SJB_Request::getVar('list_emp_ids');
             $listing->setSID($listingId);
             $screening_questionnaires = SJB_ScreeningQuestionnaires::getList($current_user->getSID());
             if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screening_questionnaires) {
                 $value = SJB_Request::getVar('screening_questionnaire');
                 $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
                 $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($current_user->getSID()), 'is_system' => true));
             } else {
                 $listing->deleteProperty('screening_questionnaire');
             }
             //--->CLT-2637
             $properties = $listing->getProperties();
             $listing_fields_by_page = array();
             foreach ($pages as $page) {
                 $listing_fields_by_page = array_merge(SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']), $listing_fields_by_page);
             }
             foreach ($properties as $property) {
                 if (!in_array($property->getID(), array_keys($listing_fields_by_page))) {
                     $listing->deleteProperty($property->getID());
                 }
             }
             //--->CLT-2637
             // if user is not registered using linkedin , delete linkedin sync property, also if sync is turned off in admin part
             $aAutoFillData = array('oListing' => &$listing, 'userSID' => $current_user->getSID(), 'listingTypeID' => $listingTypeID, 'listing_info' => $listingInfo);
             SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
             $listing_edit_form = new SJB_Form($listing);
             $listing_edit_form->registerTags($tp);
             $extraInfo = $listingInfo['product_info'];
             if ($extraInfo) {
                 $extraInfo = unserialize($extraInfo);
                 $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
                 $listingSidForPictures = SJB_Session::getValue('preview_listing_sid_or') ? SJB_Session::getValue('preview_listing_sid_or') : $listingId;
                 $tp->assign('pic_limit', $numberOfPictures);
                 $tp->assign('listingSidForPictures', $listingSidForPictures);
             }
             if ($form_is_submitted) {
                 $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar('list_emp_ids'), 'is_system' => true));
             }
             $field_errors = array();
             if ($form_is_submitted && ($formSubmittedFromPreview || $listing_edit_form->isDataValid($field_errors))) {
                 $or_listing_id = SJB_Session::getValue('preview_listing_sid_or');
                 /* preview listing */
                 if ($isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') != $listing->getSID()) {
                     SJB_Session::setValue('preview_listing_sid_or', $listing->getSID());
                     $listing->setSID(null);
                 } elseif (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listing->getSID() && $or_listing_id && $or_listing_id != $listingId) {
                     $listing->setSID($or_listing_id);
                 }
                 if ($isPreviewListingRequested) {
                     $listing->addProperty(array('id' => 'preview', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 } else {
                     $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
                 }
                 if ($isPreviewListingRequested) {
                     $listing->product_info = $extraInfo;
                     if (SJB_Session::getValue('previewListingId')) {
                         $listing->setSID(SJB_Session::getValue('previewListingId'));
                     }
                 } else {
                     SJB_BrowseDBManager::deleteListings($listing->getID());
                 }
                 $listingSidsForCopy = array('filesFrom' => $listingId, 'picturesFrom' => $isPreviewListingRequested && (!$or_listing_id || $or_listing_id === $listingId) ? $listingId : null);
                 SJB_ListingManager::saveListing($listing, $listingSidsForCopy);
                 if (!$isPreviewListingRequested && SJB_Session::getValue('preview_listing_sid') == $listingId && $or_listing_id && $or_listing_id != $listingId) {
                     SJB_Session::unsetValue('preview_listing_sid');
                     SJB_ListingManager::deleteListingBySID($listingId);
                 }
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listing->getSID());
                 if ($listingInfo['active']) {
                     SJB_ListingManager::activateListingKeywordsBySID($listing->getSID());
                     SJB_BrowseDBManager::addListings($listing->getID());
                 }
                 // >>> SJB-1197
                 // SET VALUES FROM TEMPORARY SESSION STORAGE
                 $formToken = SJB_Request::getVar('form_token');
                 $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $tempFieldsData = SJB_Array::getPath($sessionFileStorage, $formToken);
                 if (is_array($tempFieldsData)) {
                     foreach ($tempFieldsData as $fieldId => $fieldData) {
                         $isComplex = false;
                         if (strpos($fieldId, ':') !== false) {
                             $isComplex = true;
                         }
                         $tmpUploadedFileId = $fieldData['file_id'];
                         // rename it to real listing field value
                         $newFileId = $fieldId . "_" . $listing->getSID();
                         SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                         if ($isComplex) {
                             list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                             $parentProp = $listing->getProperty($parentField);
                             $parentValue = $parentProp->getValue();
                             // look for complex property with current $fieldID and set it to new value of property
                             if (!empty($parentValue)) {
                                 foreach ($parentValue as $id => $value) {
                                     if ($id == $subField) {
                                         $parentValue[$id][$complexStep] = $newFileId;
                                     }
                                 }
                                 $listing->setPropertyValue($parentField, $parentValue);
                             }
                         } else {
                             $listing->setPropertyValue($fieldId, $newFileId);
                         }
                     }
                     SJB_ListingManager::saveListing($listing);
                     // recreate form object for saved listing
                     // it fix display of complex file fields
                     $listing = SJB_ListingManager::getObjectBySID($listing->getSID());
                     $listing->deleteProperty('featured');
                     $listing->deleteProperty('priority');
                     $listing->deleteProperty('reject_reason');
                     $listing->deleteProperty('status');
                     $listing_edit_form = new SJB_Form($listing);
                     $listing_edit_form->registerTags($tp);
                 }
                 // <<< SJB-1197
                 if ($isPreviewListingRequested) {
                     SJB_Session::setValue('previewListingId', $listing->getSID());
                 }
                 /* preview listing */
                 if ($isPreviewListingRequested) {
                     $listing->setUserSID($current_user->getSID());
                     SJB_Session::setValue('preview_listing_sid', $listing->getSID());
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($listingTypeID) . '-preview/' . $listing->getSID() . '/');
                 } else {
                     /* normal */
                     $listingSid = $listing->getSID();
                     SJB_Event::dispatch('listingEdited', $listingSid);
                     $tp->assign('display_preview', 1);
                     SJB_Session::unsetValue('preview_listing_sid');
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-' . strtolower($listingTypeID) . '-details/' . $listing->getSID() . '/');
                 }
             }
             $listing->deleteProperty('access_list');
             $tp->assign('form_is_submitted', $form_is_submitted);
             $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
             $form_fields = $listing_edit_form->getFormFieldsInfo();
             $listing_fields_by_page = array();
             foreach ($pages as $page) {
                 $listing_fields_by_page[$page['page_name']] = SJB_PostingPagesManager::getAllFieldsByPageSIDForForm($page['sid']);
                 foreach (array_keys($listing_fields_by_page[$page['page_name']]) as $field) {
                     if (!$listing->propertyIsSet($field)) {
                         unset($listing_fields_by_page[$page['page_name']][$field]);
                     }
                 }
             }
             // delete sync fields from posting pages that are not in array $form_fields
             $aAutoFillData = array('listing_fields_by_page' => &$listing_fields_by_page, 'pages' => &$pages, 'form_fields' => $form_fields);
             SJB_Event::dispatch('SocialSynchronizationFieldsOnPostingPages', $aAutoFillData);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('listing' => $metaDataProvider->getMetaData($listing_structure['METADATA']), 'form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
             if (!isset($listing_structure['access_type'])) {
                 $listing_structure['access_type'] = 'everyone';
             }
             $listing_access_list = SJB_ListingManager::getListingAccessList($listingId, $listing->getPropertyValue('access_type'));
             $tp->assign('contract_id', $listingInfo['contract_id']);
             $tp->assign('extraInfo', $extraInfo);
             $tp->assign('listing', $listing_structure);
             $tp->assign('pages', $listing_fields_by_page);
             $tp->assign('countPages', count($listing_fields_by_page));
             $tp->assign('field_errors', $field_errors);
             $tp->assign('listing_access_list', $listing_access_list);
             $tp->assign('listingTypeID', $listingTypeID);
             $tp->assign('expired', SJB_ListingManager::getIfListingHasExpiredBySID($listing->getSID()));
             // only for Resume listing types
             $aAutoFillData = array('tp' => &$tp, 'listingTypeID' => $listingTypeID, 'userSID' => $current_user->getSID());
             SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData);
         }
     } else {
         $errors['NOT_LOGGED_IN'] = 1;
     }
     $tp->assign('errors', $errors);
     $tp->display($template);
 }
Ejemplo n.º 28
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');
     }
 }
Ejemplo n.º 29
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check'));
     $user_group_id = SJB_Request::getVar('user_group_id', null);
     $form_submitted = isset($_REQUEST['action']) && $_REQUEST['action'] == 'register';
     if (!is_null($user_group_id)) {
         $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id);
         /**
          * check if registration is allowed for this UserGroup
          */
         if (!SJB_SocialPlugin::ifRegistrationIsAllowedByUserGroupSID($user_group_sid)) {
             return null;
         }
         $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
         $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
         $user->deleteProperty('active');
         $user->deleteProperty('featured');
         $errors = array();
         // social plugin
         if ($form_submitted) {
             SJB_Event::dispatch('SocialPlugin_AddListingFieldsIntoRegistration', $user, true);
             SJB_Event::dispatch('MakeRegistrationFieldsNotRequired_SocialPlugin', $user, true);
         } else {
             SJB_Event::dispatch('PrepareRegistrationFields_SocialPlugin', $user, true);
             SJB_Event::dispatch('SocialPlugin_AddListingFieldsIntoRegistration', $user, true);
             SJB_Event::dispatch('FillRegistrationData_Plugin', $user, true);
         }
         $registration_form = SJB_ObjectMother::createForm($user);
         $registration_form->registerTags($tp);
         if ($form_submitted && $registration_form->isDataValid($errors)) {
             SJB_Event::dispatch('FillRegistrationData_Plugin', $user, true);
             SJB_Event::dispatch('AddReferencePluginDetails', $user, true);
             $user->deleteProperty('captcha');
             $user->deleteProperty('active');
             $user->deleteProperty('featured');
             SJB_UserManager::saveUser($user);
             SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID(), false, 0, 0, false, 0, SJB_SocialPlugin::getNetwork());
             SJB_Statistics::addStatistics('addUser' . SJB_SocialPlugin::getNetwork(), $user->getUserGroupSID(), $user->getSID(), false, 0, 0, false, 0, SJB_SocialPlugin::getNetwork());
             // subscribe user on default product
             $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid);
             $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid);
             if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) {
                 $contract = new SJB_Contract(array('product_sid' => $defaultProduct));
                 $contract->setUserSID($user->getSID());
                 $contract->saveInDB();
             }
             SJB_SocialPlugin::sendUserSocialRegistrationLetter($user);
             // notify administrator
             SJB_AdminNotifications::sendAdminUserRegistrationLetter($user);
             // Activation
             $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid);
             $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid);
             if ($isApproveByAdmin) {
                 SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
             }
             if ($isSendActivationEmail) {
                 $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID());
                 if ($isSent) {
                     $tp->display('../users/registration_confirm.tpl');
                 } else {
                     $tp->display('../users/registration_failed_to_send_activation_email.tpl');
                 }
             } else {
                 if (!$isSendActivationEmail && $isApproveByAdmin) {
                     SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending');
                     $tp->display('../users/registration_pending.tpl');
                 } else {
                     SJB_UserManager::activateUserByUserName($user->getUserName());
                     $errors = array();
                     SJB_Authorization::login($user->getUserName(), $user->getPropertyValue('password'), false, $errors, false);
                     // save access token, profile info for synchronization
                     SJB_SocialPlugin::postRegistration();
                     $tp->assign('socialNetwork', SJB_SocialPlugin::getNetwork());
                     $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : '';
                     $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId);
                     SJB_HelperFunctions::redirect($redirectUrl);
                 }
             }
         } else {
             // social plugin
             SJB_Event::dispatch('PrepareRegistrationFields_SocialPlugin', $user, true);
             if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
                 $user->deleteProperty('username');
             }
             $registration_form = SJB_ObjectMother::createForm($user);
             if ($form_submitted) {
                 $registration_form->isDataValid($errors);
             }
             $registration_form->registerTags($tp);
             $registration_form_template = '../users/registration_form.tpl';
             if (isset($_REQUEST['reg_form_template'])) {
                 $registration_form_template = $_REQUEST['reg_form_template'];
             } elseif (!empty($user_group_info['reg_form_template'])) {
                 $registration_form_template = $user_group_info['reg_form_template'];
             }
             $form_fields = $registration_form->getFormFieldsInfo();
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
             $tp->assign('user_group_info', $user_group_info);
             $tp->assign('errors', $errors);
             $tp->assign('user_group_id', $user_group_id);
             $tp->assign('form_fields', $form_fields);
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields)));
             $tp->assign('socialRegistration', true);
             $tp->assign('userTree', true);
             $tp->display($registration_form_template);
         }
     } else {
         $userGroupsSIDs = SJB_SocialPlugin::getResolvedUserGroupsByNetwork();
         $user_groups_info = array();
         foreach ($userGroupsSIDs as $groupSID) {
             array_push($user_groups_info, SJB_UserGroupManager::getUserGroupInfoBySID($groupSID));
         }
         /*
          * if there is only one group available for registration
          * redirect user directly on Registration Fields page
          */
         if (count($user_groups_info) === 1 && !empty($user_groups_info[0]['id'])) {
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/registration-social/?user_group_id=' . $user_groups_info[0]['id']);
         }
         $tp->assign('user_groups_info', $user_groups_info);
         $tp->display('registration_choose_user_group_social.tpl');
     }
 }
Ejemplo n.º 30
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');
 }