コード例 #1
0
ファイル: Acl.php プロジェクト: Maxlander/shixi
 /**
  * @return array
  */
 public function getResources($type = 'all', $role = '')
 {
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $resources = array('open_search_by_company_form' => array('title' => 'Open search by company form', 'group' => 'general', 'type' => 'guest'));
     foreach ($listingTypes as $listingType) {
         $typeId = strtolower($listingType['id']);
         $resources = array_merge($resources, array("open_{$typeId}_search_form" => array('title' => "Open {$listingType['name']} search form", 'limitable' => true, 'group' => $listingType['id'], 'type' => 'guest'), "view_{$typeId}_search_results" => array('title' => "View {$listingType['name']} search results", 'limitable' => true, 'group' => $listingType['id'], 'type' => 'guest'), "view_{$typeId}_details" => array('title' => "View {$listingType['name']} details", 'limitable' => true, 'group' => $listingType['id'], 'type' => 'guest'), "flag_{$typeId}" => array('title' => "Flag {$listingType['name']}", 'limitable' => false, 'optional' => true, 'group' => $listingType['id'], 'type' => 'guest'), "view_{$typeId}_contact_info" => array('title' => "View {$listingType['name']} Contact Info", 'limitable' => true, 'optional' => true, 'group' => $listingType['id'], 'type' => 'group'), "use_{$typeId}_alerts" => array('title' => "Use {$listingType['name']} alerts", 'group' => $listingType['id'], 'optional' => true, 'type' => 'group')));
         if ($typeId == 'job') {
             $resources = array_merge($resources, array('apply_for_a_job' => array('title' => 'Apply for a job', 'group' => $listingType['id'], 'optional' => true, 'type' => 'guest')));
         }
     }
     if ($type == 'guest') {
         return $resources;
     }
     $resources = array_merge($resources, array('delete_user_profile' => array('title' => 'Delete user profile', 'group' => 'general', 'optional' => true, 'type' => 'group'), 'use_private_messages' => array('title' => 'Use private messages', 'group' => 'general', 'optional' => true, 'type' => 'group'), "save_searches" => array('title' => "Save searches", 'group' => 'general', 'optional' => true, 'type' => 'group'), "use_screening_questionnaires" => array('title' => "Use Screening Questionnaires", 'group' => 'general', 'optional' => true, 'type' => 'group'), 'create_sub_accounts' => array('title' => 'Create Sub Accounts', 'group' => 'general', 'optional' => true, 'type' => 'group')));
     foreach ($listingTypes as $listingType) {
         $typeId = strtolower($listingType['id']);
         $resources = array_merge($resources, array("save_{$typeId}" => array('title' => "Save {$listingType['name']}", 'group' => $listingType['id'], 'optional' => true, 'type' => 'group'), "add_{$typeId}_comments" => array('title' => "Add {$listingType['name']} comments", 'group' => $listingType['id'], 'optional' => true, 'type' => 'group'), "add_{$typeId}_ratings" => array('title' => "Add {$listingType['name']} ratings", 'group' => $listingType['id'], 'type' => 'group')));
     }
     $resources['post_jobs_on_social_networks'] = array('title' => 'Post Jobs on Social Networks', 'group' => 'Job', 'type' => 'group');
     if ($type == 'group') {
         return $resources;
     }
     $resources = array_merge($resources, array('add_featured_listings' . $role => array('title' => 'Add featured listings', 'group' => 'general', 'optional' => true, 'type' => 'plan'), 'add_priority_listings' . $role => array('title' => 'Add priority listings', 'group' => 'general', 'optional' => true, 'type' => 'plan')));
     foreach ($listingTypes as $listingType) {
         $typeId = strtolower($listingType['id']);
         $resources = array_merge($resources, array("post_{$typeId}" => array('title' => "Post {$listingType['name']}", 'limitable' => true, 'group' => $listingType['id'], 'type' => 'plan')));
     }
     $resources = array_merge($resources, array('bulk_job_import' . $role => array('title' => 'Bulk Job Import', 'group' => 'Job', 'optional' => true, 'type' => 'plan'), 'post_jobs_on_social_networks' . $role => array('title' => 'Post Jobs on Social Networks', 'group' => 'Job', 'type' => 'plan')));
     return $resources;
 }
コード例 #2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listing_field_sid = SJB_Request::getVar('listing_sid', null);
     $errors = array();
     $listingTypes = array();
     if (!is_null($listing_field_sid)) {
         $listing_field = SJB_ListingFieldManager::getFieldInfoBySID($listing_field_sid);
         $listing_type_id = 'Job/Resume';
         if ($listing_field['listing_type_sid'] != 0) {
             $listing_type_id = SJB_ListingTypeManager::getListingTypeIDBySID($listing_field['listing_type_sid']);
             array_push($listingTypes, SJB_ListingTypeManager::getListingTypeInfoBySID(SJB_Array::get($listing_field, 'listing_type_sid')));
         } else {
             $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
         }
         $tp->assign('listingTypesInfo', $listingTypes);
         $tp->assign('listing_type_id', $listing_type_id);
         $tp->assign('listing_sid', $listing_field_sid);
         $tp->assign('listing_field_info', $listing_field);
         $tp->assign('listing_type_sid', $listing_field['listing_type_sid']);
     } else {
         $errors[] = 'The system cannot proceed as Listing SID is not set';
     }
     $tp->assign('errors', $errors);
     $tp->display('attention_listing_type_field.tpl');
 }
コード例 #3
0
ファイル: form_builders.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $aListingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('listingTypesInfo', $aListingTypesInfo);
     $tp->display('form_builder.tpl');
 }
コード例 #4
0
ファイル: count_listings.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listing_types = SJB_ListingTypeManager::getAllListingTypesInfo();
     $countListings = array();
     foreach ($listing_types as $type) {
         $requested_data = array();
         $requested_data['action'] = 'search';
         $requested_data['active']['equal'] = '1';
         $requested_data['listing_type']['equal'] = $type['id'];
         $requireApprove = SJB_ListingTypeManager::getWaitApproveSettingByListingType($type['sid']);
         if ($requireApprove) {
             $requested_data['status']['equal'] = 'approved';
         }
         $listing = new SJB_Listing(array(), $type['sid']);
         $id_alias_info = $listing->addIDProperty();
         $listing->addActivationDateProperty();
         $username_alias_info = $listing->addUsernameProperty();
         $listing_type_id_info = $listing->addListingTypeIDProperty();
         $listing->addCompanyNameProperty();
         if ($type['id'] == 'Resume') {
             $requested_data['access_type'] = array('accessible' => SJB_UserManager::getCurrentUserSID());
         }
         $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($requested_data, $listing);
         $aliases = new SJB_PropertyAliases();
         $aliases->addAlias($id_alias_info);
         $aliases->addAlias($username_alias_info);
         $aliases->addAlias($listing_type_id_info);
         $searcher = new SJB_ListingSearcher();
         $countListings[$type['id']] = $searcher->countRowsByCriteria($criteria, $aliases);
     }
     $tp->assign('listings_types', $countListings);
     $tp->display('count_listings.tpl');
 }
コード例 #5
0
ファイル: Products.php プロジェクト: Maxlander/shixi
 /**
  * @return array
  */
 public function getAccessPermissions()
 {
     $permissions = array('apply_for_a_job');
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     foreach ($listingTypes as $listingType) {
         $typeId = strtolower($listingType['id']);
         $permissions = array_merge($permissions, array("open_{$typeId}_search_form", "view_{$typeId}_search_results", "view_{$typeId}_details", "view_{$typeId}_contact_info", "use_{$typeId}_alerts"));
     }
     return $permissions;
 }
コード例 #6
0
ファイル: sharethis_plugin.php プロジェクト: Maxlander/shixi
 function pluginSettings()
 {
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $listingPages = array();
     foreach ($listingTypes as $listingType) {
         $listingPages[] = array('id' => 'display_on_' . strtolower($listingType['id']) . '_page', 'caption' => 'Display for ' . $listingType['name'] . ' details', 'type' => 'boolean', 'length' => '50', 'order' => null);
     }
     $currentFirlds = array(array('id' => 'header_code', 'caption' => 'ShareThis Button Header Code', 'type' => 'text', 'length' => '50', 'order' => null), array('id' => 'code', 'caption' => 'ShareThis Button Code', 'type' => 'text', 'comment' => 'To get a code for a button with different type and style, <a href="http://sharethis.com/publishers/get-sharing-button" target="_blank">click here</a><br/>The received code you will need to paste to the text areas above. ', 'length' => '50', 'order' => null), array('id' => 'display_for_all_pages', 'caption' => 'Display for All Pages', 'type' => 'boolean', 'length' => '50', 'order' => null), array('id' => 'display_on_news_page', 'caption' => 'Display for News', 'type' => 'boolean', 'length' => '50', 'order' => null));
     return array_merge($currentFirlds, $listingPages);
 }
コード例 #7
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listingTypeSID = SJB_Request::getVar('listing_type');
     if (!empty($listingTypeSID)) {
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/flagged-listings/?listing_type_sid=" . $listingTypeSID);
     }
     $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $tp->assign('listing_types', $allListingTypes);
     $tp->display('select_flagged_listing_type.tpl');
 }
コード例 #8
0
 public static function getListingTypeByUserSID($sid)
 {
     if (empty($sid)) {
         return false;
     }
     $types = array();
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     foreach ($listingTypes as $listingType) {
         if (SJB_Acl::getInstance()->isAllowed('post_' . $listingType['id'], $sid)) {
             $types[] = $listingType['sid'];
         }
     }
     return $types;
 }
コード例 #9
0
ファイル: startup_admin.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $GLOBALS['LEFT_ADMIN_MENU']['Listing Configuration'] = array(array('title' => 'Common Fields', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/listing-fields/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-listing-field/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/', SJB_System::getSystemsettings('SITE_URL') . '/delete-listing-field/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-tree/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-list/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-list-item/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-location-fields/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-fields/'), 'perm_label' => 'manage_common_listing_fields'), array('title' => 'Listing Types', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/listing-types/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-listing-type/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-type/', SJB_System::getSystemsettings('SITE_URL') . '/delete-listing-type/', SJB_System::getSystemsettings('SITE_URL') . '/add-listing-type-field/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-type-field/', SJB_System::getSystemsettings('SITE_URL') . '/delete-listing-type-field/', SJB_System::getSystemsettings('SITE_URL') . '/posting-pages/', SJB_System::getSystemsettings('SITE_URL') . '/attention-listing-type-field/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-tree/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-list/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-list-item/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-location-fields/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing-field/edit-fields/'), 'perm_label' => array('manage_listing_types_and_specific_listing_fields', 'set_posting_pages')));
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     usort($listingTypes, function ($listingType) {
         return $listingType['id'] == 'Job' || $listingType['id'] == 'Resume' ? true : false;
     });
     $listingTypes = array_reverse($listingTypes);
     foreach ($listingTypes as $listingType) {
         if (!in_array($listingType['id'], array('Resume', 'Job'))) {
             $title = "'{$listingType['name']}' Listings";
             $link = strtolower($listingType['id']) . '-listings/';
             $permLabel = strtolower($listingType['id']) . '_listings';
         } else {
             $title = "{$listingType['name']}s";
             $link = strtolower($listingType['id']) . 's/';
             $permLabel = strtolower($listingType['id']) . 's';
         }
         $manageListings[] = array('title' => 'Manage ' . $title, 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-' . $link, 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-listing/', SJB_System::getSystemsettings('SITE_URL') . '/edit-listing/', SJB_System::getSystemsettings('SITE_URL') . '/display-listing/', SJB_System::getSystemsettings('SITE_URL') . '/manage-pictures/', SJB_System::getSystemsettings('SITE_URL') . '/edit-picture/'), 'perm_label' => 'manage_' . $permLabel);
     }
     $listingsManagement = array(array('title' => 'Import Listings', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/import-listings/', 'highlight' => array(), 'perm_label' => 'import_listings'), array('title' => 'Export Listings', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/export-listings/', 'highlight' => array(), 'perm_label' => 'export_listings'), array('title' => 'XML Feeds', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/listing-feeds/', 'highlight' => array(), 'perm_label' => 'set_xml_feeds'), array('title' => 'XML Import', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/show-import/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-import/', SJB_System::getSystemsettings('SITE_URL') . '/edit-import/', SJB_System::getSystemsettings('SITE_URL') . '/run-import/'), 'perm_label' => 'set_xml_import'), array('title' => 'Flagged Listings', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/flagged-listings/', 'highlight' => array(), 'perm_label' => 'manage_flagged_listings'));
     $GLOBALS['LEFT_ADMIN_MENU']['Listing Management'] = array_merge($manageListings, $listingsManagement);
     $userGroup = array(array('title' => 'User Groups', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/user-groups/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-user-group/', SJB_System::getSystemsettings('SITE_URL') . '/edit-user-group/', SJB_System::getSystemsettings('SITE_URL') . '/delete-user-group/', SJB_System::getSystemsettings('SITE_URL') . '/edit-user-profile/', SJB_System::getSystemsettings('SITE_URL') . '/add-user-profile-field/', SJB_System::getSystemsettings('SITE_URL') . '/edit-user-profile-field/', SJB_System::getSystemsettings('SITE_URL') . '/edit-user-profile-field/edit-location-fields/', SJB_System::getSystemsettings('SITE_URL') . '/edit-user-profile-field/edit-tree/', SJB_System::getSystemsettings('SITE_URL') . '/edit-user-profile-field/edit-list/', SJB_System::getSystemsettings('SITE_URL') . '/edit-user-profile-field/edit-list-item/', SJB_System::getSystemsettings('SITE_URL') . '/system/users/acl/'), 'perm_label' => array('manage_user_groups', 'manage_user_groups_permissions')));
     $userGroups = SJB_UserGroupManager::getAllUserGroupsInfo();
     $manageUsers = array();
     foreach ($userGroups as $userGroups) {
         $userGroupId = mb_strtolower($userGroups['id'], 'utf8');
         if (in_array($userGroups['id'], array('JobSeeker', 'Employer'))) {
             $name = "{$userGroups['name']}s";
         } else {
             $name = "'{$userGroups['name']}' Users";
         }
         $link = 'manage-users/' . $userGroupId . '/';
         $manageUsers[] = array('title' => "Manage {$name}", 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/' . $link, 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/edit-user/', SJB_System::getSystemsettings('SITE_URL') . '/add-user/', SJB_System::getSystemsettings('SITE_URL') . '/manage-users/', SJB_System::getSystemsettings('SITE_URL') . '/email-log/', SJB_System::getSystemsettings('SITE_URL') . '/user-products/', SJB_System::getSystemsettings('SITE_URL') . '/private-messages/pm-main/', SJB_System::getSystemsettings('SITE_URL') . '/private-messages/pm-inbox/', SJB_System::getSystemsettings('SITE_URL') . '/private-messages/pm-outbox/', SJB_System::getSystemsettings('SITE_URL') . '/system/applications/view/', SJB_System::getSystemsettings('SITE_URL') . '/system/users/acl/'), 'perm_label' => 'manage_' . $userGroupId);
     }
     $GLOBALS['LEFT_ADMIN_MENU']['Users'] = array_merge($userGroup, $manageUsers);
     $users = array(array('title' => 'Import Users', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/import-users/', 'highlight' => array(), 'perm_label' => 'import_users'), array('title' => 'Export Users', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/export-users/', 'highlight' => array(), 'perm_label' => 'export_users'), array('title' => 'Mass Mailing', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/mailing/', 'highlight' => array(), 'perm_label' => 'create_and_send_mass_mailings'), array('title' => 'Guest Email Alerts', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/guest-alerts/', 'highlight' => array(), 'perm_label' => 'manage_guest_email_alerts'), array('title' => 'Banned IPs', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/banned-ips/', 'perm_label' => 'manage_banned_ips'));
     $GLOBALS['LEFT_ADMIN_MENU']['Users'] = array_merge($GLOBALS['LEFT_ADMIN_MENU']['Users'], $users);
     $GLOBALS['LEFT_ADMIN_MENU']['Layout and Content'] = array(array('title' => 'Form Builder', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/form-builders/', 'perm_label' => 'edit_form_builder'), array('title' => 'System Templates', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/edit-templates/', 'perm_label' => 'edit_templates_and_themes'), array('title' => 'Email Templates', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/edit-email-templates/', 'perm_label' => 'edit_templates_and_themes'), array('title' => 'Themes', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/edit-themes/', 'perm_label' => 'edit_templates_and_themes'), array('title' => 'Site Pages', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/user-pages/', 'perm_label' => 'manage_site_pages'), array('title' => 'Static Content', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/stat-pages/', 'perm_label' => 'manage_static_content'), array('title' => 'Banners', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-banner-groups/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-banner-group/', SJB_System::getSystemsettings('SITE_URL') . '/edit-banner-group/', SJB_System::getSystemsettings('SITE_URL') . '/edit-banner/', SJB_System::getSystemsettings('SITE_URL') . '/add-banner/'), 'perm_label' => 'manage_banners'), array('title' => 'News', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/news-categories/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/manage-news/'), 'perm_label' => 'manage_news'), array('title' => 'Polls', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-polls/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/poll-answers/', SJB_System::getSystemsettings('SITE_URL') . '/poll-results/'), 'perm_label' => 'manage_polls'));
     $GLOBALS['LEFT_ADMIN_MENU']['Billing'] = array(array('title' => 'Invoices', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-invoices/', 'perm_label' => 'manage_invoices', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-invoice/', SJB_System::getSystemsettings('SITE_URL') . '/edit-invoice/')), array('title' => 'Products', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/products/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/edit-product/', SJB_System::getSystemsettings('SITE_URL') . '/add-product/'), 'perm_label' => 'manage_products'), array('title' => 'Promotions', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/promotions/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-promotion-code/', SJB_System::getSystemsettings('SITE_URL') . '/edit-promotion-code/', SJB_System::getSystemsettings('SITE_URL') . '/promotions/log/'), 'perm_label' => 'manage_promotions'), array('title' => 'Tax Rules', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-taxes/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-tax/', SJB_System::getSystemsettings('SITE_URL') . '/edit-tax/'), 'perm_label' => 'manage_tax_rules'), array('title' => 'Payment Gateways', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/system/payment/gateways/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/configure-gateway/'), 'perm_label' => 'manage_payment_gateways'), array('title' => 'Transaction History', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/payments/', 'perm_label' => 'transaction_history'), array('title' => 'Payment Log', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/payment-log/', 'perm_label' => 'payment_log'));
     $GLOBALS['LEFT_ADMIN_MENU']['Reports'] = array(array('title' => 'General Statistics', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/general-statistics/', 'perm_label' => 'general_statistics'), array('title' => 'Listings', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/listings-statistics/', 'perm_label' => 'listings_reports'), array('title' => 'Applications and Views', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/applications-and-views/', 'perm_label' => 'applications_and_views_reports'), array('title' => 'Sales', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/sales/', 'perm_label' => 'sales_reports'), array('title' => 'Guest Alerts', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/statistics/guest-alerts/', 'perm_label' => 'guest_alerts_reports'), array('title' => 'Promotions Usage', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/statistics/promotions/', 'perm_label' => 'promotions_statistics'));
     $GLOBALS['LEFT_ADMIN_MENU']['System Configuration'] = array(array('title' => 'System Settings', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/settings/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/alphabet-letters/', SJB_System::getSystemsettings('SITE_URL') . '/view-error-log/'), 'perm_label' => 'configure_system_settings'), array('title' => 'Social Media', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/social-media/', 'perm_label' => 'social_media', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/social-media/bitly/', SJB_System::getSystemsettings('SITE_URL') . '/social-media/facebook', SJB_System::getSystemsettings('SITE_URL') . '/social-media/linkedin', SJB_System::getSystemsettings('SITE_URL') . '/social-media/twitter', SJB_System::getSystemsettings('SITE_URL') . '/social-media/googleplus')), array('title' => 'Admin Password', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/adminpswd/'), array('title' => 'Admin Sub Accounts', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-subadmins/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-subadmin/', SJB_System::getSystemsettings('SITE_URL') . '/edit-subadmin/')), array('title' => 'ZipCode Database', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/geographic-data/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/geographic-data/import-data/', SJB_System::getSystemsettings('SITE_URL') . '/geographic-data/edit-location/'), 'perm_label' => 'edit_zipcode_database'), array('title' => 'Countries', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/countries/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-country/', SJB_System::getSystemsettings('SITE_URL') . '/import-countries/', SJB_System::getSystemsettings('SITE_URL') . '/edit-country/'), 'perm_label' => 'manage_countries'), array('title' => 'States/Regions', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/states/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-state/', SJB_System::getSystemsettings('SITE_URL') . '/edit-state/', SJB_System::getSystemsettings('SITE_URL') . '/import-states/'), 'perm_label' => 'manage_states_or_regions'), array('title' => 'Manage Currencies', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/currency-list/', 'perm_label' => 'manage_currencies'), array('title' => 'Refine Search Settings', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/refine-search-settings/', 'perm_label' => 'set_refine_search_parameters'), array('title' => 'Flag Listing Settings', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/flag-listing-settings/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/flag/', SJB_System::getSystemsettings('SITE_URL') . '/flag/'), 'perm_label' => 'edit_flag_listing_settings'), array('title' => 'Breadcrumbs Config', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-breadcrumbs/', 'perm_label' => 'configure_breadcrumbs'), array('title' => 'HTML filters', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/filters/', 'perm_label' => 'set_html_filters'), array('title' => 'Task Scheduler', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/task-scheduler-settings/', 'perm_label' => 'set_task_scheduler'), array('title' => 'Plugins', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/system/miscellaneous/plugins/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/system/miscellaneous/fb_app_settings/'), 'perm_label' => array('manage_plug-ins', 'set_phpbb_plug-in', 'set_facebook_plug-in', 'set_linkedin_plug-in', 'set_twitter_plug-in', 'set_wordpress_plug-in', 'set_sharethisplugin', 'set_captchaplugin', 'set_indeedplugin', 'set_jujuplugin', 'set_simplyhiredplugin', 'set_googleplugin', 'set_googleplusplugin', 'set_googleanalyticsplugin', 'set_beyondplugin')), array('title' => 'Backup/Restore', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/backup/', 'perm_label' => 'create_and_restore_backups'), array('title' => 'Email Log', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/email-log/', 'perm_label' => 'email_log'));
     $GLOBALS['LEFT_ADMIN_MENU']['Language Management'] = array(array('title' => 'Manage Languages', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-languages/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-language/', SJB_System::getSystemsettings('SITE_URL') . '/edit-language/'), 'perm_label' => 'manage_languages'), array('title' => 'Translate Phrases', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/manage-phrases/', 'highlight' => array(SJB_System::getSystemsettings('SITE_URL') . '/add-phrase/'), 'perm_label' => 'translate_phrases'), array('title' => 'Import Language', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/import-language/', 'perm_label' => 'import_languages'), array('title' => 'Export Language', 'reference' => SJB_System::getSystemsettings('SITE_URL') . '/export-language/', 'perm_label' => 'export_languages'));
     // set subadmin mode
     if (SJB_SubAdmin::getSubAdminSID()) {
         $GLOBALS['subadmin_id'] = SJB_SubAdmin::getSubAdminSID();
     }
 }
コード例 #10
0
ファイル: index.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $ou = SJB_UserManager::getOnlineUsers();
     $onlineUsers = array();
     $totalOnlineUsers = 0;
     $userGroups = SJB_UserGroupManager::createTemplateStructureForUserGroups();
     foreach ($userGroups as $userGroup) {
         $onlineUsers[$userGroup["id"]]["count"] = 0;
         $onlineUsers[$userGroup["id"]]["caption"] = $userGroup["caption"];
     }
     foreach ($ou as $value) {
         $onlineUsers[$value["type"]]["count"]++;
         $totalOnlineUsers++;
     }
     $theme = SJB_Settings::getValue('TEMPLATE_USER_THEME', 'default');
     $themePath = SJB_TemplatePathManager::getAbsoluteThemePath($theme);
     // FLAGGED LISTINGS
     $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $totalFlagsNum = array();
     foreach ($allListingTypes as $type) {
         $totalFlagsNum[$type['id']] = SJB_ListingManager::getFlagsNumberByListingTypeSID($type['sid'], $filter = null, $groupByListingSID = true);
     }
     $files = $this->getCssFiles($themePath);
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('totalFlagsNum', $totalFlagsNum);
     $tp->assign('usersInfo', SJB_UserManager::getUsersInfo());
     $tp->assign('groupsInfo', SJB_UserManager::getGroupsInfo());
     $tp->assign('listingsInfo', SJB_ListingManager::getListingsInfo());
     $tp->assign('listingTypesInfo', SJB_ListingTypeManager::getAllListingTypesInfo());
     $tp->assign('invoicesInfo', SJB_InvoiceManager::getInvoicesInfo());
     $tp->assign('unpaidInvoices', SJB_InvoiceManager::getTotalUnpaidInvoices());
     $tp->assign('totalInvoices', SJB_InvoiceManager::getTotalInvoices());
     $i18n = SJB_I18N::getInstance();
     $lang = $i18n->getLanguageData($i18n->getCurrentLanguage());
     $tp->assign("today", strftime($lang['date_format'], time()));
     // ранее были данные за период: месяц (последние 30 дней), неделя (последние 7 дней)
     // теперь - текущий месяц и текущая неделя
     $currMonth = strftime($lang['date_format'], mktime(0, 0, 0, date("m"), 1, date("Y")));
     $currWeek = strftime($lang['date_format'], mktime(0, 0, 0, date("m"), date("d") - date("N") + 1, date("Y")));
     $tp->assign("weekAgo", $currWeek);
     $tp->assign("monthAgo", $currMonth);
     $tp->assign('onlineUsers', $onlineUsers);
     $tp->assign('totalOnlineUsers', $totalOnlineUsers);
     if (count($files) > 0) {
         $tp->assign("file", $files[0]);
     }
     $tp->display("index.tpl");
 }
コード例 #11
0
ファイル: ListingDBManager.php プロジェクト: Maxlander/shixi
 public static function getActiveAndApproveListingsNumberByUserSID($user_sid)
 {
     $approved = '';
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     foreach ($listingTypes as $listingType) {
         if (!empty($approved)) {
             $approved .= ' OR ';
         }
         if ($listingType['waitApprove']) {
             $approved .= "(`listing_type_sid` = {$listingType['sid']} AND `status` = 'approved')";
         } else {
             $approved .= "(`listing_type_sid` = {$listingType['sid']})";
         }
     }
     return SJB_DB::queryValue("SELECT COUNT(*) FROM `listings` WHERE `active` = 1 AND `user_sid` = ?n AND ({$approved})", $user_sid);
 }
コード例 #12
0
ファイル: user_menu.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $user_menu_template = 'user_menu.tpl';
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_info = SJB_Authorization::getCurrentUserInfo();
         if (!empty($user_info)) {
             $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']);
             if (!empty($user_group_info['user_menu_template']) && $tp->templateExists($user_group_info['user_menu_template'])) {
                 $user_menu_template = $user_group_info['user_menu_template'];
             }
             $tp->assign("user_group_info", $user_group_info);
             $tp->assign('listingTypesInfo', SJB_ListingTypeManager::getAllListingTypesInfo());
         }
     }
     $tp->assign("account_activated", SJB_Request::getVar('account_activated', ''));
     $tp->display($user_menu_template);
 }
コード例 #13
0
 public function execute()
 {
     $page_id = SJB_Request::getVar('pageid', null);
     if ($page_id) {
         $tp = SJB_System::getTemplateProcessor();
         $i18n = SJB_I18N::getInstance();
         $lang = SJB_Request::getVar('lang', $i18n->getCurrentLanguage());
         $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $lang);
         if (empty($staticContent)) {
             $def_lang = SJB_System::getSettingByName('i18n_default_language');
             $staticContent = SJB_StaticContent::getStaticContentByIDAndLang($page_id, $def_lang);
         }
         if (!empty($staticContent)) {
             if ($page_id == '404') {
                 $isLoggedIn = SJB_Authorization::isUserLoggedIn();
                 if ($isLoggedIn) {
                     $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
                     $currentUserInfo = SJB_Authorization::getCurrentUserInfo();
                     $userGroupinfo = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']);
                     $acl = SJB_Acl::getInstance();
                     $tp->assign('acl', $acl);
                     $tp->assign('listingTypesInfo', $listingTypesInfo);
                     $tp->assign('userGroupInfo', $userGroupinfo);
                 }
                 $staticContent['content'] = htmlspecialchars_decode($staticContent['content']);
                 $tp->assign('isLoggedIn', $isLoggedIn);
             }
             if (empty($staticContent['content'])) {
                 // Null создаёт ошибку в smarty
                 $staticContent['content'] = '';
             }
             $tp->assign('staticContent', $staticContent['content']);
             $tp->display('static_content.tpl');
         }
     }
 }
コード例 #14
0
ファイル: add_listing.php プロジェクト: Maxlander/shixi
 /**
  * @param $listingSID
  * @param $contractID
  * @param $productSID
  */
 public function addListing($listingSID, $contractID = false, $productSID = false)
 {
     if ($productSID != false) {
         $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID);
         $extraInfo['product_sid'] = (string) $extraInfo['product_sid'];
     } else {
         $contract = new SJB_Contract(array('contract_id' => $contractID));
         $extraInfo = $contract->extra_info;
     }
     $numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
     $this->tp->assign("pic_limit", $numberOfPictures);
     $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
     if (!$this->listingTypeID && count($listingTypesInfo) == 1) {
         $listingTypeInfo = array_pop($listingTypesInfo);
         $this->listingTypeID = $listingTypeInfo['id'];
     }
     $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
     $pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
     $pageSID = $this->getPageSID($pages, $listingTypeSID);
     $isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listingTypeSID);
     $isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
     if (($contractID || !empty($this->buttonPressedPostToProceed)) && $this->listingTypeID) {
         $formSubmitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested;
         /*
          * social plugin
          * complete listing of data from an array of social data
          * if is allowed
          */
         $aAutoFillData = array('formSubmitted' => &$formSubmitted, 'listingTypeID' => &$this->listingTypeID);
         SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
         /*
          * end of "social plugin"
          */
         $listing = new SJB_Listing($_REQUEST, $listingTypeSID, $pageSID);
         $listing->deleteProperty('featured');
         $listing->deleteProperty('priority');
         $listing->deleteProperty('status');
         $listing->deleteProperty('reject_reason');
         $listing->deleteProperty('ListingLogo');
         $access_type = $listing->getProperty('access_type');
         if ($formSubmitted) {
             if (!empty($access_type)) {
                 $listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true));
             }
             $listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contractID, 'is_system' => true));
         }
         $currentUser = SJB_UserManager::getCurrentUser();
         $screeningQuestionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID());
         if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screeningQuestionnaires) {
             $issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
             if ($issetQuestionnairyField) {
                 $value = SJB_Request::getVar("screening_questionnaire");
                 $listingInfo = $_REQUEST;
                 $value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
                 $listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true));
             }
         } else {
             $listing->deleteProperty('screening_questionnaire');
         }
         /*
          * social plugin
          * "synchronization"
          * if user is not registered using linkedin , delete linkedin sync property
          * also if sync is turned off in admin part
          */
         $aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $this->listingTypeID, 'listing_info' => $_REQUEST);
         SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
         /*
          * end of social plugin "sync"
          */
         $listingFormAdd = new SJB_Form($listing);
         $listingFormAdd->registerTags($this->tp);
         $fieldErrors = array();
         if ($formSubmitted && ($this->formSubmittedFromPreview || $listingFormAdd->isDataValid($fieldErrors))) {
             if ($isPageLast) {
                 $listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
             }
             $listing->setUserSID($currentUser->getSID());
             $listing->setProductInfo($extraInfo);
             if (empty($access_type->value)) {
                 $listing->setPropertyValue('access_type', 'everyone');
             }
             if ($currentUser->isSubuser()) {
                 $subuserInfo = $currentUser->getSubuserInfo();
                 $listing->addSubuserProperty($subuserInfo['sid']);
             }
             /**
              * >>>>> listing preview @author still
              */
             if (!empty($listingSID)) {
                 $listing->setSID($listingSID);
             }
             /*
              * <<<<< listing preview
              */
             SJB_ListingManager::saveListing($listing);
             if (!empty($this->buttonPressedPostToProceed)) {
                 SJB_ListingManager::unmakeCheckoutedBySID($listing->getSID());
             }
             SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listing->getSID(), false, $extraInfo['featured'], $extraInfo['priority']);
             if ($contractID) {
                 $contract = new SJB_Contract(array('contract_id' => $contractID));
                 $contract->incrementPostingsNumber();
                 SJB_ProductsManager::incrementPostingsNumber($contract->product_sid);
             }
             if (SJB_Session::getValue('tmp_file_storage')) {
                 foreach ($_SESSION['tmp_file_storage'] as $v) {
                     SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `picture_saved_name` = ?s", $listing->getSID(), $v['picture_saved_name']);
                     SJB_DB::query("UPDATE `listings_pictures` SET `listing_sid` = ?n WHERE `thumb_saved_name` = ?s", $listing->getSID(), $v['thumb_saved_name']);
                 }
                 SJB_Session::unsetValue('tmp_file_storage');
             }
             // >>> SJB-1197
             // check temporary uploaded storage for listing uploads and assign it to saved listing
             $formToken = SJB_Request::getVar('form_token');
             $sessionFilesStorage = SJB_Session::getValue('tmp_uploads_storage');
             $uploadedFields = SJB_Array::getPath($sessionFilesStorage, $formToken);
             if (!empty($uploadedFields)) {
                 foreach ($uploadedFields as $fieldId => $fieldValue) {
                     // get field of listing
                     $isComplex = false;
                     if (strpos($fieldId, ':') !== false) {
                         $isComplex = true;
                     }
                     $tmpUploadedFileId = $fieldValue['file_id'];
                     // rename it to real listing field value
                     $newFileId = $fieldId . "_" . $listing->getSID();
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` =?s", $newFileId, $tmpUploadedFileId);
                     if ($isComplex) {
                         list($parentField, $subField, $complexStep) = explode(':', $fieldId);
                         $parentProp = $listing->getProperty($parentField);
                         $parentValue = $parentProp->getValue();
                         // look for complex property with current $fieldID and set it to new value of property
                         if (!empty($parentValue)) {
                             foreach ($parentValue as $id => $value) {
                                 if ($id == $subField) {
                                     $parentValue[$id][$complexStep] = $newFileId;
                                 }
                             }
                             $listing->setPropertyValue($parentField, $parentValue);
                         }
                     } else {
                         $listing->setPropertyValue($fieldId, $newFileId);
                     }
                     // unset value from session temporary storage
                     $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}/{$fieldId}");
                 }
                 //and remove token key from temporary storage
                 $sessionFilesStorage = SJB_Array::unsetValueByPath($sessionFilesStorage, "{$formToken}");
                 SJB_Session::setValue('tmp_uploads_storage', $sessionFilesStorage);
                 SJB_ListingManager::saveListing($listing);
                 $keywords = $listing->getKeywords();
                 SJB_ListingManager::updateKeywords($keywords, $listing->getSID());
             }
             // <<< SJB-1197
             if ($isPageLast && !$isPreviewListingRequested) {
                 /* delete temp preview listing sid */
                 SJB_Session::unsetValue('preview_listing_sid_for_add');
                 // Start Event
                 $listingSid = $listing->getSID();
                 SJB_Event::dispatch('listingSaved', $listingSid);
                 if ($extraInfo['featured']) {
                     SJB_ListingManager::makeFeaturedBySID($listing->getSID());
                 }
                 if ($extraInfo['priority']) {
                     SJB_ListingManager::makePriorityBySID($listing->getSID());
                 }
                 if (!empty($this->buttonPressedPostToProceed)) {
                     $this->proceedToCheckout($currentUser->getSID(), $productSID);
                 } else {
                     if (SJB_ListingManager::activateListingBySID($listing->getSID())) {
                         SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID());
                     }
                     // notify administrator
                     SJB_AdminNotifications::sendAdminListingAddedLetter($listing);
                     if (isset($_REQUEST['action_add_pictures'])) {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-pictures/?listing_id=" . $listing->getSID());
                     } else {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-' . strtolower($this->listingTypeID) . '/?listing_id=' . $listing->getSID());
                     }
                 }
             } elseif ($isPageLast && $isPreviewListingRequested) {
                 // for listing preview
                 SJB_Session::setValue('preview_listing_sid_for_add', $listing->getSID());
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/' . strtolower($this->listingTypeID) . '-preview/' . $listing->getSID() . '/');
             } else {
                 // listing steps (pages)
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/add-listing/{$this->listingTypeID}/" . SJB_PostingPagesManager::getNextPage($pageSID) . "/" . $listing->getSID());
             }
         } else {
             $listing->deleteProperty('access_list');
             $listing->deleteProperty('contract_id');
             $listingFormAdd = new SJB_Form($listing);
             if ($formSubmitted) {
                 $listingFormAdd->isDataValid($fieldErrors);
             }
             $listingFormAdd->registerTags($this->tp);
             $template = isset($_REQUEST['input_template']) ? $_REQUEST['input_template'] : "input_form.tpl";
             $formFields = $listingFormAdd->getFormFieldsInfo();
             $employersList = SJB_Request::getVar('list_emp_ids', false);
             $employers = array();
             if (is_array($employersList)) {
                 foreach ($employersList as $emp) {
                     $currEmp = SJB_UserManager::getUserInfoBySID($emp);
                     $employers[] = array('user_id' => $emp, 'value' => $currEmp['CompanyName']);
                 }
                 sort($employers);
             }
             $this->tp->assign('form_token', SJB_Request::getVar('form_token'));
             $this->tp->assign("account_activated", SJB_Request::getVar('account_activated', ''));
             $this->tp->assign("contract_id", $contractID);
             $this->tp->assign("listing_access_list", $employers);
             $this->tp->assign("listingTypeID", $this->listingTypeID);
             $this->tp->assign('listingTypeStructure', SJB_ListingTypeManager::createTemplateStructure(SJB_ListingTypeManager::getListingTypeInfoBySID($listing->listing_type_sid)));
             $this->tp->assign("field_errors", $fieldErrors);
             $this->tp->assign("form_fields", $formFields);
             $this->tp->assign("pages", $pages);
             $this->tp->assign("pageSID", $pageSID);
             $this->tp->assign("extraInfo", $extraInfo);
             $this->tp->assign("currentPage", SJB_PostingPagesManager::getPageInfoBySID($pageSID));
             $this->tp->assign("isPageLast", $isPageLast);
             $this->tp->assign("nextPage", SJB_PostingPagesManager::getNextPage($pageSID));
             $this->tp->assign("prevPage", SJB_PostingPagesManager::getPrevPage($pageSID));
             $metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
             $this->tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($formFields)));
             /*
              * social plugin
              * only for Resume listing types
              */
             $aAutoFillData = array('tp' => &$this->tp, 'listingTypeID' => &$this->listingTypeID, 'userSID' => $currentUser->getSID());
             SJB_Event::dispatch('SocialSynchronizationForm', $aAutoFillData);
             /*
              * social plugin
              */
             $this->tp->display($template);
         }
     }
 }
コード例 #15
0
ファイル: my_listings.php プロジェクト: Maxlander/shixi
 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');
 }
コード例 #16
0
ファイル: acl.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $acl = SJB_Acl::getInstance();
     $type = SJB_Request::getVar('type', '');
     $role = SJB_Request::getVar('role', '');
     $tp = SJB_System::getTemplateProcessor();
     $resources = $acl->getResources();
     $form_submitted = SJB_Request::getVar('action');
     if ($form_submitted) {
         SJB_Acl::clearPermissions($type, $role);
         foreach ($resources as $name => $resource) {
             $params = SJB_Request::getVar($name . '_params');
             $message = '';
             if (SJB_Request::getVar($name) == 'deny') {
                 $params = SJB_Request::getVar($name . '_params1');
                 if ($params == 'message') {
                     $message = SJB_Request::getVar($name . '_message');
                 }
             }
             SJB_Acl::allow($name, $type, $role, SJB_Request::getVar($name, ''), $params, SJB_Request::getVar($name . '_message'));
         }
         if ($type == 'plan' && SJB_Request::getVar('update_users', 0) == 1) {
             $contracts = SJB_ContractManager::getAllContractsByMemebershipPlanSID($role);
             foreach ($contracts as $contract_id) {
                 SJB_Acl::clearPermissions('contract', $contract_id['id']);
                 SJB_DB::query("insert into `permissions` (`type`, `role`, `name`, `value`, `params`, `message`)" . " select 'contract', ?s, `name`, `value`, `params`, `message` from `permissions` " . " where `type` = 'plan' and `role` = ?s", $contract_id['id'], $role);
             }
         }
         if ($form_submitted == 'save') {
             switch ($type) {
                 case 'group':
                     $parameter = "/edit-user-group/?sid=" . $role;
                     break;
                 case 'guest':
                     $parameter = "/user-groups/";
                     break;
             }
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . $parameter);
         }
     }
     $acl = SJB_Acl::getInstance(true);
     $resources = $acl->getResources($type);
     $perms = SJB_DB::query('select * from `permissions` where `type` = ?s and `role` = ?s', $type, $role);
     foreach ($resources as $key => $resource) {
         $resources[$key]['value'] = 'inherit';
         $resources[$key]['name'] = $key;
         foreach ($perms as $perm) {
             if ($key == $perm['name']) {
                 $resources[$key]['value'] = $perm['value'];
                 $resources[$key]['params'] = $perm['params'];
                 $resources[$key]['message'] = $perm['message'];
                 break;
             }
         }
     }
     $tp->assign('resources', $resources);
     $tp->assign('type', $type);
     $tp->assign('listingTypes', SJB_ListingTypeManager::getAllListingTypesInfo());
     $tp->assign('role', $role);
     switch ($type) {
         case 'group':
             $tp->assign('userGroupInfo', SJB_UserGroupManager::getUserGroupInfoBySID($role));
             break;
         case 'user':
             $userInfo = SJB_UserManager::getUserInfoBySID($role);
             $tp->assign('userGroupInfo', SJB_UserGroupManager::getUserGroupInfoBySID($userInfo['user_group_sid']));
             break;
     }
     $tp->display('acl.tpl');
 }
コード例 #17
0
 public function execute()
 {
     $ajaxAction = SJB_Request::getVar('ajax_action', '', 'GET');
     $formToken = SJB_Request::getVar('form_token', '');
     // save token date in session. In some code we needs to get list of it, and clean old tokens data from
     // session.
     self::setTokenDateToSession($formToken);
     switch ($ajaxAction) {
         // UPLOAD USER PROFILE VIDEO
         case 'upload_profile_video':
         case 'upload_profile_logo':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             // get field by user group return not all fields of profile.
             // but now we use getAllFieldsInfo() to check fields
             $userProfileFields = SJB_UserProfileFieldManager::getAllFieldsInfo();
             $fieldSid = null;
             foreach ($userProfileFields as $field) {
                 if ($field['id'] != $uploadedFieldId) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             if ($fieldSid == null) {
                 echo "Wrong profile field specified";
                 exit;
             }
             $fieldInfo = SJB_UserProfileFieldManager::getFieldInfoBySID($fieldSid);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId);
             if ($validation === true) {
                 // video file already uploaded after isValid checks
                 // but for 'Logo' - we need some actions to make save picture
                 if ($fieldInfo['type'] == 'logo') {
                     $upload_manager = new SJB_UploadPictureManager();
                     $upload_manager->setUploadedFileID($this->fileUniqueId);
                     $upload_manager->setHeight($fieldInfo['height']);
                     $upload_manager->setWidth($fieldInfo['width']);
                     $upload_manager->uploadPicture($fieldInfo['id'], $fieldInfo);
                     // and set value of file id to property
                     $this->property->setValue($this->fileUniqueId);
                     $this->propertyValue = $this->property->getValue();
                 }
                 // set uploaded video to temporary value
                 if ($fieldInfo['type'] == 'video' && isset($this->propertyValue['file_id'])) {
                     $uploadedID = $this->propertyValue['file_id'];
                     // rename it to unique value
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $this->fileUniqueId, $uploadedID);
                     // fill session data for tmp storage
                     $fieldValue = array('file_id' => $this->fileUniqueId, 'file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'saved_file_name' => $this->propertyValue['saved_file_name']);
                     $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                     $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fieldValue);
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 } elseif ($fieldInfo['type'] == 'logo') {
                     // for Logo - we already have file_url data and file_thumb data, without file_id
                     // just add this to session storage
                     // fill session data for tmp storage
                     $fieldValue = array('file_id' => $this->fileUniqueId, 'file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'thumb_file_url' => $this->propertyValue['thumb_file_url'], 'thumb_file_name' => $this->propertyValue['thumb_file_name']);
                     $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                     $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fieldValue);
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
                 $tp->assign(array('id' => $uploadedFieldId, 'value' => $fieldValue));
             }
             $template = '';
             switch ($fieldInfo['type']) {
                 case 'video':
                     $template = '../field_types/input/video_profile.tpl';
                     break;
                 case 'logo':
                     $template = '../field_types/input/logo.tpl';
                     break;
                 default:
                     break;
             }
             $tp->assign('form_token', $formToken);
             $tp->assign('errors', $this->errors);
             $tp->display($template);
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'delete_profile_video':
         case 'delete_profile_logo':
             $userSid = SJB_Request::getVar('user_sid', null);
             if (empty($userSid)) {
                 $userInfo = SJB_UserManager::getCurrentUserInfo();
             } else {
                 $userInfo = SJB_UserManager::getUserInfoBySID($userSid);
             }
             $fieldId = SJB_Request::getVar('field_id', null);
             // check session value
             $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
             $sessionFileId = SJB_Array::getPath($sessionFileStorage, "{$formToken}/{$fieldId}/file_id");
             if (is_null($fieldId)) {
                 $this->errors['PARAMETERS_MISSED'] = 1;
             } elseif (!empty($userInfo) && !isset($userInfo[$fieldId]) && empty($sessionFileId)) {
                 echo json_encode(array('result' => 'success'));
                 exit;
             } else {
                 if (!empty($userInfo)) {
                     $uploaded_file_id = $userInfo[$fieldId];
                     SJB_UploadFileManager::deleteUploadedFileByID($uploaded_file_id);
                 }
                 if (!empty($sessionFileId)) {
                     $formFileId = SJB_Request::getVar('file_id');
                     if ($sessionFileId == $formFileId) {
                         SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                         $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                         SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                     }
                 }
             }
             if (empty($this->errors)) {
                 echo json_encode(array('result' => 'success'));
             } else {
                 echo json_encode(array('result' => 'error', 'errors' => $this->errors));
             }
             exit;
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
             // UPLOAD LISTIG FILES
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         // UPLOAD LISTIG FILES
         case 'upload_classifieds_video':
         case 'upload_file':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             // OK. For listings form we have 'listing_id' and optional field (for new listings with temporary id) - listing_type_id
             $listingId = SJB_Request::getVar('listing_id');
             $listingTypeId = SJB_Request::getVar('listing_type_id');
             if (empty($listingTypeId)) {
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
             }
             $listingTypeSid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeId);
             $commonListingFields = SJB_ListingFieldManager::getCommonListingFieldsInfo();
             $listingFieldsByType = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeSid);
             $listingFields = array_merge($commonListingFields, $listingFieldsByType);
             $fieldSid = null;
             foreach ($listingFields as $field) {
                 if ($field['id'] != $uploadedFieldId) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($fieldSid);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId);
             if (!$validation) {
                 $tp->assign(array('listing_id' => $listingId, 'listing' => array('id' => $listingId)));
             } else {
                 // video file already uploaded after isValid checks
                 // but for 'Logo' - we need some actions to make save picture
                 if ($this->property->getType() == 'file') {
                     if ($_FILES[$uploadedFieldId]['error']) {
                         $this->errors[SJB_UploadFileManager::getErrorId($_FILES[$uploadedFieldId]['error'])] = 1;
                     }
                     $upload_manager = new SJB_UploadFileManager();
                     $upload_manager->setUploadedFileID($this->fileUniqueId);
                     $upload_manager->setFileGroup('files');
                     $upload_manager->uploadFile($fieldInfo['id']);
                     // and set value of file id to property
                     $this->property->setValue($this->fileUniqueId);
                 }
                 $this->propertyValue = $this->property->getValue();
                 // set uploaded video to temporary value
                 if (isset($this->propertyValue['file_id'])) {
                     $uploadedID = $this->propertyValue['file_id'];
                     // rename it to unique value
                     SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $this->fileUniqueId, $uploadedID);
                     // SET VALUE TO TEMPORARY SESSION STORAGE
                     $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                     $fileValue = array('file_id' => $this->fileUniqueId, 'saved_name' => $this->propertyValue['saved_file_name']);
                     $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fileValue);
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                     // update listing property
                     $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                     $listing = isset($listingInfo['listing_type_sid']) ? new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']) : new SJB_Listing($listingInfo);
                     $listingProperties = $listing->getProperties();
                     $propertyInfo = array('id' => $uploadedFieldId, 'type' => 'string', 'value' => $this->fileUniqueId, 'is_system' => true);
                     foreach ($listingProperties as $property) {
                         if ($property->getID() == $uploadedFieldId) {
                             $listing->addProperty($propertyInfo);
                         }
                     }
                     $listing->setSID($listingId);
                     SJB_ListingManager::saveListing($listing);
                     $tp->assign(array('id' => $uploadedFieldId, 'value' => array('file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'saved_file_name' => $this->propertyValue['saved_file_name'], 'file_id' => $this->fileUniqueId), 'listing_id' => $listingId, 'listing' => array('id' => $listingId)));
                 }
             }
             switch ($this->property->getType()) {
                 case 'video':
                     $template = '../field_types/input/video.tpl';
                     break;
                 case 'file':
                     $template = '../field_types/input/file.tpl';
                     break;
                 default:
                     $template = '../field_types/input/video.tpl';
                     break;
             }
             $tp->assign('errors', $this->errors);
             $tp->assign('form_token', $formToken);
             $tp->display($template);
             self::cleanOldTokensFromSession();
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'delete_classifieds_video':
         case 'delete_file':
             $listingId = SJB_Request::getVar('listing_id', null);
             $fieldId = SJB_Request::getVar('field_id', null);
             $formFileId = SJB_Request::getVar('file_id');
             $this->errors = array();
             // check session value
             $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
             $sessionFileId = SJB_Array::getPath($sessionFileStorage, "{$formToken}/{$fieldId}/file_id");
             // if empty listing id - check end empty temporary storage
             if (strlen($listingId) == strlen(time())) {
                 if ($sessionFileId == $formFileId) {
                     SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                     // remove field from temporary storage
                     if (!is_null($sessionFileStorage)) {
                         $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                         SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                     }
                 }
             } else {
                 // we change existing listing
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 if ((is_null($listingInfo) || !isset($listingInfo[$fieldId])) && empty($sessionFileId)) {
                     $this->errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
                 } else {
                     if (!$this->isOwner($listingId)) {
                         $this->errors['NOT_OWNER'] = 1;
                     } else {
                         $uploadedFileId = $listingInfo[$fieldId];
                         if (!empty($uploadedFileId)) {
                             SJB_UploadFileManager::deleteUploadedFileByID($uploadedFileId);
                         }
                         SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                         $listingInfo[$fieldId] = '';
                         $listing = isset($listingInfo['listing_type_sid']) ? new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']) : new SJB_Listing($listingInfo);
                         // remove all non-changed properties and save only changed property in listing
                         $props = $listing->getProperties();
                         foreach ($props as $prop) {
                             if ($prop->getID() !== $fieldId) {
                                 $listing->deleteProperty($prop->getID());
                             }
                         }
                         $listing->setSID($listingId);
                         SJB_ListingManager::saveListing($listing);
                         // remove field from temporary storage
                         $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                         if (!is_null($sessionFileStorage)) {
                             $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                             SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                         }
                     }
                 }
             }
             if (empty($this->errors)) {
                 echo json_encode(array('result' => 'success'));
             } else {
                 echo json_encode(array('result' => 'error', 'errors' => $this->errors));
             }
             exit;
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'get_classifieds_video_data':
         case 'get_file_field_data':
             $fieldId = isset($_REQUEST['field_id']) ? $_REQUEST['field_id'] : null;
             $listingId = SJB_Request::getVar('listing_id');
             $filesFromTmpStorage = SJB_Session::getValue('tmp_uploads_storage');
             $fileUniqueId = SJB_Array::getPath($filesFromTmpStorage, "{$formToken}/{$fieldId}/file_id");
             // if no temporary files uploaded, return empty string
             if (empty($fileUniqueId)) {
                 return '';
             }
             $tp = SJB_System::getTemplateProcessor();
             $upload_manager = new SJB_UploadFileManager();
             $fileInfo = array('id' => $fieldId, 'value' => array('file_url' => $upload_manager->getUploadedFileLink($fileUniqueId), 'file_name' => $upload_manager->getUploadedFileName($fileUniqueId), 'saved_file_name' => $upload_manager->getUploadedSavedFileName($fileUniqueId), 'file_id' => $fileUniqueId), 'listing_id' => $listingId, 'listing' => array('id' => $listingId));
             $tp->assign($fileInfo);
             $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($fieldId);
             $fieldType = $fieldInfo['type'];
             $template = '';
             switch ($fieldType) {
                 case 'video':
                     $template = '../field_types/input/video.tpl';
                     break;
                 case 'file':
                     $template = '../field_types/input/file.tpl';
                     break;
                 case 'logo':
                     $template = '../field_types/input/logo_listing.tpl';
                     break;
                 default:
                     break;
             }
             $uploadedFilesize = $upload_manager->getUploadedFileSize($fileUniqueId);
             $filesizeInfo = SJB_HelperFunctions::getFileSizeAndSizeToken($uploadedFilesize);
             $tp->assign(array('filesize' => $filesizeInfo['filesize'], 'size_token' => $filesizeInfo['size_token']));
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             $tp->assign('form_token', $formToken);
             $tp->display($template);
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'upload_file_complex':
         case 'upload_classifieds_video_complex':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             list($parentField, $subFieldId, $complexStep) = explode(':', $uploadedFieldId);
             // OK. For listings form we have 'listing_id' and optional field (for new listings with temporary id) - listing_type_id
             $listingId = SJB_Request::getVar('listing_id');
             $listingTypeId = SJB_Request::getVar('listing_type_id');
             if (empty($listingTypeId)) {
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingInfo['listing_type_sid']);
             }
             $listingTypeSid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeId);
             $commonListingFields = SJB_ListingFieldManager::getCommonListingFieldsInfo();
             $listingFieldsByType = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeSid);
             $listingFields = array_merge($commonListingFields, $listingFieldsByType);
             // check parent field
             $fieldSid = null;
             foreach ($listingFields as $field) {
                 if ($field['id'] != $parentField) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             $complexFieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($fieldSid);
             $subFields = SJB_Array::get($complexFieldInfo, 'fields');
             if (empty($subFields)) {
                 echo 'wrong field ID';
                 exit;
             }
             // check field
             $fieldInfo = '';
             foreach ($subFields as $subField) {
                 if ($subField['id'] != $subFieldId) {
                     continue;
                 }
                 $fieldInfo = $subField;
             }
             $complexParameters = array('parentField' => $parentField, 'subFieldId' => $subFieldId, 'complexStep' => $complexStep);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId, $complexParameters);
             $upload_manager = new SJB_UploadFileManager();
             $upload_manager->setUploadedFileID($this->fileUniqueId);
             $upload_manager->setFileGroup('files');
             $upload_manager->uploadFile($fieldInfo['id'], $parentField);
             $this->property->setValue($this->fileUniqueId);
             $this->propertyValue = $this->property->getPropertyVariablesToAssign();
             // set uploaded video to temporary value
             if ((isset($this->propertyValue['value']['file_id']) || isset($this->propertyValue['value'][$complexStep]['file_id'])) && $validation) {
                 // fix for FILE type in complex field
                 if (isset($this->propertyValue['value'][$complexStep]['file_id'])) {
                     $this->propertyValue['value'] = $this->propertyValue['value'][$complexStep];
                 }
                 $filesInfo = array($complexStep => $this->propertyValue['value']);
                 $uploadedID = $this->propertyValue['value']['file_id'];
                 // rename it to unique value
                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $this->fileUniqueId, $uploadedID);
                 // SET VALUE TO TEMPORARY SESSION STORAGE
                 $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $fileValue = array('file_id' => $this->fileUniqueId, 'saved_name' => $this->propertyValue['value']['saved_file_name']);
                 $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fileValue);
                 SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 $tp->assign(array('id' => $subFieldId, 'value' => $this->propertyValue['value']['file_name'], 'filesInfo' => $filesInfo, 'complexField' => $parentField, 'complexStep' => $complexStep, 'listing_id' => $listingId, 'listing' => array('id' => $listingId)));
             } else {
                 $tp->assign(array('id' => $subFieldId, 'complexField' => $parentField, 'complexStep' => $complexStep, 'listing_id' => $listingId, 'listing' => array('id' => $listingId)));
             }
             switch ($this->property->getType()) {
                 case 'video':
                     $template = '../field_types/input/video.tpl';
                     break;
                 case 'file':
                 case 'complexfile':
                     $template = '../field_types/input/file.tpl';
                     break;
                 default:
                     $template = '../field_types/input/video.tpl';
                     break;
             }
             $tp->assign('form_token', $formToken);
             $tp->assign('errors', $this->errors);
             $tp->display($template);
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'delete_file_complex':
             $listingId = SJB_Request::getVar('listing_id', null);
             $fieldId = SJB_Request::getVar('field_id', null);
             $formFileId = SJB_Request::getVar('file_id');
             $this->errors = array();
             // check session value
             $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
             $sessionFileId = SJB_Array::getPath($sessionFileStorage, "{$formToken}/{$fieldId}/file_id");
             // if empty listing id - check and empty temporary storage
             if (strlen($listingId) == strlen(time())) {
                 if ($sessionFileId == $formFileId) {
                     SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                     // remove field from temporary storage
                     $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                     SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                 }
             } else {
                 // we change existing listing
                 $listingInfo = SJB_ListingManager::getListingInfoBySID($listingId);
                 list($complexField, $subField, $complexStep) = explode(':', $fieldId);
                 $fieldValue = SJB_Array::getPath($listingInfo, "{$complexField}/{$subField}/{$complexStep}");
                 // if field value not present in listing and not present in temporary storage - throw error
                 if ((is_null($listingInfo) || $fieldValue === null) && empty($sessionFileId)) {
                     $this->errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
                 } else {
                     if (!$this->isOwner($listingId)) {
                         $this->errors['NOT_OWNER'] = 1;
                     } else {
                         $uploadedFileId = $fieldValue;
                         if (!empty($uploadedFileId)) {
                             SJB_UploadFileManager::deleteUploadedFileByID($uploadedFileId);
                         }
                         SJB_UploadFileManager::deleteUploadedFileByID($formFileId);
                         $listingInfo = SJB_Array::setPathValue($listingInfo, "{$complexField}/{$subField}/{$complexStep}", '');
                         $listing = new SJB_Listing($listingInfo, $listingInfo['listing_type_sid']);
                         // remove all non-changed properties and save only changed property in listing
                         $props = $listing->getProperties();
                         foreach ($props as $prop) {
                             if ($prop->getID() !== $fieldId) {
                                 $listing->deleteProperty($prop->getID());
                             }
                         }
                         $listing->setSID($listingId);
                         SJB_ListingManager::saveListing($listing);
                         // remove field from temporary storage
                         $sessionFileStorage = SJB_Session::getValue('tmp_uploads_storage');
                         if (!empty($sessionFileStorage)) {
                             $sessionFileStorage = SJB_Array::unsetValueByPath($sessionFileStorage, "{$formToken}/{$fieldId}");
                             SJB_Session::setValue('tmp_uploads_storage', $sessionFileStorage);
                         }
                     }
                 }
             }
             if (empty($this->errors)) {
                 echo json_encode(array('result' => 'success'));
             } else {
                 echo json_encode(array('result' => 'error', 'errors' => $this->errors));
             }
             exit;
             break;
             ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         ////////////////////////////////////////////////////////////////////////////////////////////////////////////
         case 'get_complexfile_field_data':
             $listingId = SJB_Request::getVar('listing_id', null);
             $fieldId = SJB_Request::getVar('field_id', null);
             $listingTypeId = SJB_Request::getVar('listing_type_id');
             $listingTypeSid = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeId);
             $uploadFileManager = new SJB_UploadFileManager();
             // replace square brackets in complex field name
             $fieldId = str_replace("][", ":", $fieldId);
             $fieldId = str_replace("[", ":", $fieldId);
             $fieldId = str_replace("]", "", $fieldId);
             list($parentField, $subFieldId, $complexStep) = explode(':', $fieldId);
             $filesFromTmpStorage = SJB_Session::getValue('tmp_uploads_storage');
             //$fileUniqueId = SJB_Array::getPath($filesFromTmpStorage, "listings/{$listingId}/{$fieldId}/file_id");
             $fileUniqueId = SJB_Array::getPath($filesFromTmpStorage, "{$formToken}/{$fieldId}/file_id");
             // if no temporary files uploaded, return empty string
             if (empty($fileUniqueId)) {
                 return '';
             }
             // get list of fields for all listing types
             $listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
             $allFields = array();
             foreach ($listingTypesInfo as $listingTypeInfo) {
                 $typeFields = SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingTypeInfo['sid']);
                 $allFields = array_merge($allFields, $typeFields);
             }
             // NEED TO GET COMPLEX SUBFIELD PROPERTY
             $commonListingFields = SJB_ListingFieldManager::getCommonListingFieldsInfo();
             $listingFieldsByType = $allFields;
             $listingFields = array_merge($commonListingFields, $listingFieldsByType);
             // check parent field
             $fieldSid = null;
             foreach ($listingFields as $field) {
                 if ($field['id'] != $parentField) {
                     continue;
                 }
                 $fieldSid = $field['sid'];
             }
             // parent complex field
             $complexFieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($fieldSid);
             $subFields = SJB_Array::get($complexFieldInfo, 'fields');
             if (empty($subFields)) {
                 echo 'wrong field ID';
                 exit;
             }
             // check field for subfield
             $complexSubFieldInfo = '';
             foreach ($subFields as $subField) {
                 if ($subField['id'] != $subFieldId) {
                     continue;
                 }
                 $complexSubFieldInfo = $subField;
             }
             if (empty($complexSubFieldInfo)) {
                 echo 'Wrong field info';
                 exit;
             }
             // OK. COMPLEX SUBFIELD WE HAVE
             $complexSubFieldProperty = new SJB_ObjectProperty($complexSubFieldInfo);
             // complex file fields contents array of values, not just string filename
             $complexSubFieldProperty->setValue(array($complexStep => $fileUniqueId));
             $valueToAssign = $complexSubFieldProperty->getPropertyVariablesToAssign();
             $additionalInfo = array('listing_id' => $listingId, 'listing' => array('id' => $listingId), 'complexField' => $parentField, 'complexStep' => $complexStep);
             $tp = SJB_System::getTemplateProcessor();
             $tp->assign($valueToAssign);
             $tp->assign($additionalInfo);
             $template = '';
             switch ($complexSubFieldProperty->getType()) {
                 case 'complexfile':
                     $template = '../field_types/input/file.tpl';
                     break;
                 default:
                     break;
             }
             $uploadedFilesize = $uploadFileManager->getUploadedFileSize($fileUniqueId);
             $filesizeInfo = SJB_HelperFunctions::getFileSizeAndSizeToken($uploadedFilesize);
             $tp->assign(array('filesize' => $filesizeInfo['filesize'], 'size_token' => $filesizeInfo['size_token']));
             $tp->assign('form_token', $formToken);
             $tp->display($template);
             break;
         case 'upload_listing_logo':
             $uploadedFieldId = SJB_Request::getVar('uploaded_field_name', '', 'GET');
             $listingSid = SJB_Request::getVar('listing_id', null);
             $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($uploadedFieldId);
             $tp = SJB_System::getTemplateProcessor();
             $validation = $this->validationManager($fieldInfo, $tp, $uploadedFieldId);
             if ($validation === true) {
                 $upload_manager = new SJB_UploadPictureManager();
                 $upload_manager->setUploadedFileID($this->fileUniqueId);
                 $upload_manager->setHeight($fieldInfo['height']);
                 $upload_manager->setWidth($fieldInfo['width']);
                 $upload_manager->uploadPicture($fieldInfo['id'], $fieldInfo);
                 // and set value of file id to property
                 $this->property->setValue($this->fileUniqueId);
                 $this->propertyValue = $this->property->getValue();
                 // for Logo - we already have file_url data and file_thumb data, without file_id
                 // just add this to session storage
                 // fill session data for tmp storage
                 $fieldValue = array('file_id' => $this->fileUniqueId, 'file_url' => $this->propertyValue['file_url'], 'file_name' => $this->propertyValue['file_name'], 'thumb_file_url' => $this->propertyValue['thumb_file_url'], 'thumb_file_name' => $this->propertyValue['thumb_file_name']);
                 $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
                 $tmpUploadsStorage = SJB_Array::setPathValue($tmpUploadsStorage, "{$formToken}/{$uploadedFieldId}", $fieldValue);
                 SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 $tp->assign(array('id' => $uploadedFieldId, 'value' => $fieldValue));
             }
             $template = '../field_types/input/logo_listing.tpl';
             $tp->assign('form_token', $formToken);
             $tp->assign('errors', $this->errors);
             $tp->assign('listing_id', $listingSid);
             $tp->display($template);
             break;
         default:
             echo "Action not defined!";
             break;
     }
     exit;
 }
コード例 #18
0
ファイル: refine_search.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action');
     $field_id = SJB_Request::getVar('field_id', false);
     if ($field_id || $action == 'save_setting') {
         switch ($action) {
             case 'save':
                 $listing_type_sid = SJB_Request::getVar('listing_type_sid', false);
                 $userField = 0;
                 if ($listing_type_sid) {
                     if (strstr($field_id, 'user_')) {
                         $field_id = str_replace('user_', '', $field_id);
                         $userField = 1;
                     }
                     if (!SJB_RefineSearch::getFieldByFieldSIDListingTypeSID($field_id, $listing_type_sid, $userField)) {
                         SJB_RefineSearch::addField($field_id, $listing_type_sid, $userField);
                     }
                 }
                 break;
             case 'save_setting':
                 $listing_type_id = SJB_Request::getVar('listing_type_id', false);
                 $refine_search_items_limit = SJB_Request::getVar('refine_search_items_limit', false);
                 if ($listing_type_id) {
                     $settingValue = SJB_Request::getVar('turn_on_refine_search_' . $listing_type_id, 0);
                     if (SJB_Settings::getSettingByName('turn_on_refine_search_' . $listing_type_id) === false) {
                         SJB_Settings::addSetting('turn_on_refine_search_' . $listing_type_id, $settingValue);
                     } else {
                         SJB_Settings::updateSetting('turn_on_refine_search_' . $listing_type_id, $settingValue);
                     }
                 } elseif ($refine_search_items_limit) {
                     if (SJB_Settings::getSettingByName('refine_search_items_limit') === false) {
                         SJB_Settings::addSetting('refine_search_items_limit', $refine_search_items_limit);
                     } else {
                         SJB_Settings::updateSetting('refine_search_items_limit', $refine_search_items_limit);
                     }
                 }
                 break;
             case 'delete':
                 SJB_RefineSearch::removeField($field_id);
                 break;
             case 'move_up':
                 $listing_type_sid = SJB_Request::getVar('listing_type_sid', false);
                 if ($listing_type_sid) {
                     SJB_RefineSearch::moveUpFieldBySID($field_id, $listing_type_sid);
                 }
                 break;
             case 'move_down':
                 $listing_type_sid = SJB_Request::getVar('listing_type_sid', false);
                 if ($listing_type_sid) {
                     SJB_RefineSearch::moveDownFieldBySID($field_id, $listing_type_sid);
                 }
                 break;
         }
     }
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     foreach ($listingTypes as $key => $listingType) {
         $fields = array_merge(SJB_ListingFieldManager::getCommonListingFieldsInfo(), SJB_ListingFieldManager::getListingFieldsInfoByListingType($listingType['sid']));
         foreach ($fields as $field_key => $field) {
             if ($field['type'] == 'location') {
                 if (is_array($field['fields'])) {
                     $fields = array_merge($fields, $field['fields']);
                 }
             }
             if (!in_array($field['type'], array('list', 'multilist', 'string', 'boolean', 'tree')) || in_array($field['id'], array('ApplicationSettings', 'access_type', 'anonymous', 'screening_questionnaire'))) {
                 foreach ($fields as $fieldKey => $searchField) {
                     if ($searchField['id'] == $field['id']) {
                         unset($fields[$fieldKey]);
                     }
                 }
             }
         }
         $listingTypes[$key]['fields'] = $fields;
         if ($key == 'Job') {
             $userFieldSID = SJB_DB::queryValue("SELECT `sid` FROM `user_profile_fields` WHERE `id` = 'CompanyName'");
             if (!empty($userFieldSID)) {
                 $listingTypes[$key]['user_fields'] = SJB_UserProfileFieldManager::getFieldInfoBySID($userFieldSID);
             }
         }
         $listingTypes[$key]['saved_fields'] = SJB_RefineSearch::getFieldsByListingTypeSID($listingType['sid']);
         $listingTypes[$key]['setting'] = SJB_Settings::getSettingByName('turn_on_refine_search_' . $listingType['id']);
     }
     $tp->assign('refine_search_items_limit', SJB_Settings::getSettingByName('refine_search_items_limit'));
     $tp->assign('listingTypes', $listingTypes);
     $tp->display('refine_search.tpl');
 }
コード例 #19
0
ファイル: flagged_listings.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $listingTypeID = SJB_Request::getVar('listing_type_id');
     $listingTypeSID = SJB_Request::getVar('listing_type');
     if ($listingTypeID !== null) {
         $listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($listingTypeID);
     }
     // SET PAGINATION AND SORTING VALUES
     $restore = SJB_Request::getVar('restore', false);
     $paginator = new SJB_FlaggedListingsPagination();
     // FILTERS
     $filters = array();
     $filters['title'] = SJB_Request::getVar('filter_title');
     $filters['username'] = SJB_Request::getVar('filter_user');
     $filters['flag'] = SJB_Request::getVar('filter_flag');
     // check session for pagination settings
     $sessionFlaggedSettings = !is_null(SJB_Session::getValue('flagged_settings')) ? SJB_Session::getValue('flagged_settings') : false;
     if ($sessionFlaggedSettings !== false) {
         if (!$restore) {
             SJB_Session::setValue('flagged_settings', array('filters' => $filters));
         } else {
             if (!$listingTypeSID && !empty($sessionFlaggedSettings['listing_type_sid'])) {
                 $listingTypeSID = $sessionFlaggedSettings['listing_type_sid'];
             }
             $filters = $sessionFlaggedSettings['filters'];
         }
     } else {
         SJB_Session::setValue('flagged_settings', array('filters' => $filters));
     }
     // DEFAULT SORTING
     // resolve flag to it text value for search
     $filterFlag = $filters['flag'];
     if (!empty($filterFlag) && is_numeric($filterFlag)) {
         $result = SJB_DB::query('SELECT * FROM `flag_listing_settings` WHERE `sid` = ?n LIMIT 1', $filterFlag);
         if (!empty($result)) {
             $filters['flag_reason'] = $result[0]['value'];
         }
     }
     //////////////////////  ACTIONS
     $action = SJB_Request::getVar('action_name');
     $flagSIDs = SJB_Request::getVar('flagged');
     if (!empty($flagSIDs)) {
         switch ($action) {
             case 'remove':
                 foreach ($flagSIDs as $sid => $val) {
                     SJB_ListingManager::removeFlagBySID($sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
                 break;
             case 'deactivate':
                 foreach ($flagSIDs as $sid => $val) {
                     SJB_ListingManager::deactivateListingByFlagSID($sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
                 break;
             case 'delete':
                 foreach ($flagSIDs as $sid => $val) {
                     SJB_ListingManager::deleteListingByFlagSID($sid);
                 }
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
                 break;
         }
     }
     //////////////////////// OUTPUT
     $allListingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $allFlags = SJB_ListingManager::getAllFlags();
     $countFlaggedListings = SJB_ListingManager::getFlagsNumberByListingTypeSID($listingTypeSID, $filters);
     $paginator->setItemsCount($countFlaggedListings);
     $flaggedListings = SJB_ListingManager::getFlaggedListings($listingTypeSID, $paginator->currentPage, $paginator->itemsPerPage, $paginator->sortingField, $paginator->sortingOrder, $filters);
     if (empty($flaggedListings) && $paginator->currentPage != 1) {
         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flagged-listings/?page=1');
     }
     foreach ($flaggedListings as $key => $val) {
         $listingInfo = SJB_ListingManager::getListingInfoBySID($val['listing_sid']);
         $listingUser = SJB_UserManager::getUserInfoBySID($listingInfo['user_sid']);
         $flaggedUser = SJB_UserManager::getUserInfoBySID($val['user_sid']);
         $flaggedListings[$key]['listing_info'] = $listingInfo;
         $flaggedListings[$key]['user_info'] = $listingUser;
         $flaggedListings[$key]['flagged_user'] = $flaggedUser;
     }
     $tp->assign('paginationInfo', $paginator->getPaginationInfo());
     $tp->assign('listing_types', $allListingTypes);
     $tp->assign('listings', $flaggedListings);
     $tp->assign('listing_type_sid', $listingTypeSID);
     $tp->assign('all_flags', $allFlags);
     $tp->assign('filters', $filters);
     $tp->display('flagged_listings.tpl');
 }
コード例 #20
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $userGroupSid = SJB_Request::getVar('user_group_sid', false);
     $productType = SJB_Request::getVar('product_type', false);
     $permissions_type = SJB_Request::getVar('permissions_type', 'additional');
     $addedPermissions = false;
     $role = SJB_Request::getVar('role', false);
     $type = 'product';
     $acl = SJB_Acl::getInstance(true);
     $resources = $acl->getResources($type);
     $product = new SJB_Product(array(), $productType);
     $additionalPermissions = $product->getAdditionalPermissions();
     $accessPermissions = $product->getAccessPermissions();
     $perms = SJB_DB::query('select * from `permissions` where `type` = ?s and `role` = ?s', $type, $role);
     $countGeneralPermissions = 0;
     foreach ($resources as $key => $resource) {
         switch ($permissions_type) {
             case 'additional':
                 if (!in_array($key, $additionalPermissions)) {
                     unset($resources[$key]);
                     continue;
                 }
                 break;
             case 'access':
                 if (!in_array($key, $accessPermissions)) {
                     unset($resources[$key]);
                     continue;
                 }
                 break;
         }
         $resources[$key]['value'] = 'inherit';
         $resources[$key]['name'] = $key;
         foreach ($perms as $perm) {
             if ($key == $perm['name']) {
                 $resources[$key]['value'] = $perm['value'];
                 $resources[$key]['params'] = $perm['params'];
                 $resources[$key]['message'] = $perm['message'];
                 break;
             }
         }
         if (!empty($addedPermissions[$key])) {
             $params = isset($addedPermissions[$key . '_params']) ? $addedPermissions[$key . '_params'] : '';
             $params1 = isset($addedPermissions[$key . '_params1']) ? $addedPermissions[$key . '_params1'] : '';
             $message = isset($addedPermissions[$key . '_message']) ? $addedPermissions[$key . '_message'] : '';
             if ($addedPermissions[$key] == 'deny' && $params1) {
                 $params = $params1;
             }
             $resources[$key]['value'] = $addedPermissions[$key];
             $resources[$key]['params'] = $params;
             $resources[$key]['message'] = $message;
         }
         if (isset($resources[$key]['group']) && $resources[$key]['group'] == 'general') {
             $countGeneralPermissions++;
         }
     }
     $tp->assign('countGeneralPermissions', $countGeneralPermissions);
     $tp->assign('resources', $resources);
     $tp->assign('listingTypes', SJB_ListingTypeManager::getAllListingTypesInfo());
     $tp->assign('role', $role);
     $tp->assign('type', $type);
     $tp->assign('user_group_sid', $userGroupSid);
     $tp->display('product_permissions.tpl');
 }
コード例 #21
0
ファイル: my_products.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (!SJB_UserManager::isUserLoggedIn()) {
         $errors['NOT_LOGGED_IN'] = true;
         $tp->assign("ERRORS", $errors);
         $tp->display("../classifieds/error.tpl");
         return;
     }
     if (SJB_Request::getVar('subscriptionComplete') == 'false') {
         $this->errors['SUBSCRIPTION_IS_FAIL'] = 1;
     }
     $currentUser = SJB_UserManager::getCurrentUser();
     $contractsInfo = SJB_ContractManager::getAllContractsInfoByUserSID($currentUser->getSID());
     $cancelRecurringContract = SJB_Request::getVar('cancelRecurringContract', false);
     if ($cancelRecurringContract) {
         $tp->assign('cancelRecurringContractId', $cancelRecurringContract);
     }
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $contractSIDs = array();
     foreach ($contractsInfo as $key => $contractInfo) {
         $contractInfo['extra_info'] = unserialize($contractInfo['serialized_extra_info']);
         $contractInfo['avalaibleViews'] = array();
         $contractInfo['avalaibleContactViews'] = array();
         $contractInfo['listingAmount'] = array();
         foreach ($listingTypes as $listingType) {
             $listingTypeID = $listingType['id'];
             if ($this->acl->isAllowed('view_' . $listingTypeID . '_details', $contractInfo['id'], 'contract')) {
                 $contractInfo['avalaibleViews'][$listingTypeID]['name'] = $listingType['name'];
                 $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_details', $contractInfo['id'], 'contract');
                 $contractInfo['avalaibleViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractInfo['id']), false, $listingType['sid']);
                 if (empty($permissionParam)) {
                     $contractInfo['avalaibleViews'][$listingTypeID]['count'] = 'unlimited';
                     $contractInfo['avalaibleViews'][$listingTypeID]['viewsLeft'] = 'unlimited';
                 } else {
                     $contractInfo['avalaibleViews'][$listingTypeID]['count'] = $permissionParam;
                     $contractInfo['avalaibleViews'][$listingTypeID]['viewsLeft'] = $permissionParam - $contractInfo['avalaibleViews'][$listingTypeID]['numOfViews'];
                 }
             }
             if ($this->acl->isAllowed('post_' . $listingTypeID, $contractInfo['id'], 'contract')) {
                 $contractInfo['listingAmount'][$listingTypeID]['name'] = $listingType['name'];
                 $permissionParam = $this->acl->getPermissionParams('post_' . $listingTypeID, $contractInfo['id'], 'contract');
                 $contractInfo['listingAmount'][$listingTypeID]['numPostings'] = $contractInfo['number_of_postings'];
                 if (empty($permissionParam)) {
                     $contractInfo['listingAmount'][$listingTypeID]['count'] = 'unlimited';
                     $contractInfo['listingAmount'][$listingTypeID]['listingsLeft'] = 'unlimited';
                 } else {
                     $contractInfo['listingAmount'][$listingTypeID]['count'] = $permissionParam;
                     $contractInfo['listingAmount'][$listingTypeID]['listingsLeft'] = max($contractInfo['listingAmount'][$listingTypeID]['count'] - $contractInfo['listingAmount'][$listingTypeID]['numPostings'], 0);
                 }
             }
             if ($this->acl->isAllowed('view_' . $listingTypeID . '_contact_info', $contractInfo['id'], 'contract')) {
                 $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info', $contractInfo['id'], 'contract');
                 $contractInfo['avalaibleContactViews'][$listingTypeID]['name'] = $listingType['name'];
                 $contractInfo['avalaibleContactViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractInfo['id']), 'view_' . $listingTypeID . '_contact_info');
                 if (empty($permissionParam)) {
                     $contractInfo['avalaibleContactViews'][$listingTypeID]['count'] = 'unlimited';
                     $contractInfo['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = 'unlimited';
                 } else {
                     $contractInfo['avalaibleContactViews'][$listingTypeID]['count'] = $permissionParam;
                     $contractInfo['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = $contractInfo['avalaibleContactViews'][$listingTypeID]['count'] - $contractInfo['avalaibleContactViews'][$listingTypeID]['numOfViews'];
                 }
             }
         }
         $contractsInfo[$key] = $contractInfo;
         $contractsInfo[$key]['product_info'] = SJB_ProductsManager::getProductInfoBySID($contractInfo['extra_info']['product_sid']);
         $contractSIDs[] = $contractInfo['id'];
     }
     $statistics = array();
     foreach ($listingTypes as $listingType) {
         $listingTypeID = $listingType['id'];
         if ($this->acl->isAllowed('view_' . $listingTypeID . '_details')) {
             $statistics['avalaibleViews'][$listingTypeID]['name'] = $listingType['name'];
             $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_details');
             $statistics['avalaibleViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractSIDs, false, $listingType['sid']);
             if (empty($permissionParam)) {
                 $statistics['avalaibleViews'][$listingTypeID]['count'] = 'unlimited';
                 $statistics['avalaibleViews'][$listingTypeID]['viewsLeft'] = 'unlimited';
             } else {
                 $statistics['avalaibleViews'][$listingTypeID]['count'] = $permissionParam;
                 $statistics['avalaibleViews'][$listingTypeID]['viewsLeft'] = $statistics['avalaibleViews'][$listingTypeID]['count'] - $statistics['avalaibleViews'][$listingTypeID]['numOfViews'];
             }
         }
         if ($this->acl->isAllowed('post_' . $listingTypeID)) {
             $statistics['listingAmount'][$listingTypeID]['name'] = $listingType['name'];
             $permissionParam = $this->acl->getPermissionParams('post_' . $listingTypeID);
             $statistics['listingAmount'][$listingTypeID]['numPostings'] = SJB_ContractManager::getListingsNumberByContractSIDsListingType($contractSIDs, $listingTypeID);
             if (empty($permissionParam)) {
                 $statistics['listingAmount'][$listingTypeID]['count'] = 'unlimited';
                 $statistics['listingAmount'][$listingTypeID]['listingsLeft'] = 'unlimited';
             } else {
                 $statistics['listingAmount'][$listingTypeID]['count'] = $permissionParam;
                 $statistics['listingAmount'][$listingTypeID]['listingsLeft'] = $statistics['listingAmount'][$listingTypeID]['count'] - $statistics['listingAmount'][$listingTypeID]['numPostings'];
             }
         }
         if ($this->acl->isAllowed('view_' . $listingTypeID . '_contact_info')) {
             $permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info');
             $statistics['avalaibleContactViews'][$listingTypeID]['name'] = $listingType['name'];
             $statistics['avalaibleContactViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractSIDs, 'view_' . $listingTypeID . '_contact_info');
             if (empty($permissionParam)) {
                 $statistics['avalaibleContactViews'][$listingTypeID]['count'] = 'unlimited';
                 $statistics['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = 'unlimited';
             } else {
                 $statistics['avalaibleContactViews'][$listingTypeID]['count'] = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info');
                 $statistics['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = $statistics['avalaibleContactViews'][$listingTypeID]['count'] - $statistics['avalaibleContactViews'][$listingTypeID]['numOfViews'];
             }
         }
     }
     $productsFailedList = urldecode(SJB_Request::getVar('failedProducts'));
     if ($productsFailedList != '') {
         $productsFailedArray = explode(',', $productsFailedList);
         if (!empty($productsFailedArray)) {
             $tp->assign('productsFailed', $productsFailedArray);
         }
     }
     $tp->assign('statistics', $statistics);
     $tp->assign("contracts_info", $contractsInfo);
     $tp->assign('errors', $this->errors);
     $tp->display("my_products.tpl");
 }
コード例 #22
0
ファイル: add_import.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $errors = array();
     if (SJB_Request::isAjax()) {
         $response = null;
         $user_type = SJB_Request::getVar('user_type');
         $user_name = SJB_Request::getVar('parser_user');
         $products = SJB_XmlImport::getProducts($user_type, $user_name, $errors);
         $response = array('products' => empty($products) ? '' : SJB_XmlImport::translateProductsName($products), 'error' => empty($errors) ? '' : array_pop($errors));
         die(json_encode($response));
     }
     $tp = SJB_System::getTemplateProcessor();
     $add_level = SJB_Request::getVar('add_level', 1);
     // check for errors
     if ($add_level == '3') {
         $selectUserType = SJB_Request::getVar('selectUserType');
         $addNewUser = 0;
         if ($selectUserType == 'username') {
             $usr_name = isset($_REQUEST['parser_user']) ? SJB_DB::quote($_REQUEST['parser_user']) : '';
             $usr_id = SJB_UserManager::getUserSIDbyUsername($usr_name);
             if (empty($usr_name)) {
                 $errors[] = 'Please enter user name of existing user to the "User Name" field';
                 $usr_name = '';
             } else {
                 $user_sid_exists = SJB_UserManager::getUserSIDbyUsername($usr_name);
                 if (empty($user_sid_exists)) {
                     $errors[] = 'User "' . $usr_name . '" not exists. Please enter user name of existing user to the "User Name" field';
                     $usr_name = '';
                 }
             }
         } elseif ($selectUserType == 'group') {
             $userGroupSid = isset($_REQUEST['parser_user']) ? $_REQUEST['parser_user'] : 0;
             $usr_id = $userGroupSid;
             $usr_name = SJB_UserGroupManager::getUserGroupIDBySID($usr_id);
             $addNewUser = 1;
         }
         if ($errors) {
             $add_level = 2;
         }
     }
     $listings_type = SJB_ListingTypeManager::getAllListingTypesInfo();
     $types = array();
     foreach ($listings_type as $one) {
         $types[$one['sid']] = $one['id'];
     }
     $tp->assign('types', $types);
     $selected_logo_options = null;
     switch ($add_level) {
         case '1':
             $template = 'add_step_one.tpl';
             /*
             $types = array();
             foreach ( $listings_type as $one ) {
             					  $types[$one['sid']] = $one['id'];
             }
             $tp->assign('types', $types);
             */
             $tp->display('add_step_one.tpl');
             break;
         case '2':
             $template = 'add_step_two.tpl';
             $original_xml = SJB_Request::getVar('xml');
             $xml = $original_xml;
             $tree = '';
             $listing_fields = array();
             $logo_options_array = array('not_logo' => 'Do Not Import Logo', 'import_logo' => 'Import Logo with Listings', 'upload_logo' => 'Upload Logo for Imported Listings');
             $parsing_name = SJB_Request::getVar('parser_name');
             $usr_name = SJB_Request::getVar('parser_user');
             $pars_url = SJB_Request::getVar('parser_url');
             $form_description = SJB_Request::getVar('form_description', '', 'POST');
             $type_id = SJB_Request::getVar('type_id', '', 'POST');
             $selectedLogoOption = SJB_Request::getVar('logo_options');
             $selectedLogoField = SJB_Request::getVar('import_logo_field');
             $selectedProduct = SJB_Request::getVar('postUnderProduct');
             $id = SJB_Request::getVar('id', 0, 'GET');
             $selected = array();
             $a_selected = array();
             if (!empty($_REQUEST['xml']) || $id > 0) {
                 // step 2 OR edit exist
                 if ($id > 0) {
                     // load exist parser
                     $parser_from_id = SJB_XmlImport::getSystemParsers($id);
                     if (isset($parser_from_id[0]['name'])) {
                         $parser_from_id = $parser_from_id[0];
                     }
                     $parsing_name = $parser_from_id['name'];
                     $usr_id = $parser_from_id['usr_id'];
                     $usr_name = $parser_from_id['usr_name'];
                     $form_description = $parser_from_id['description'];
                     $pars_url = $parser_from_id['url'];
                     $type_id = $parser_from_id['type_id'];
                     $selected_logo_options = unserialize($parser_from_id['logo_options']);
                     $selectedLogoOption = $selected_logo_options['option'];
                     $selectedLogoField = $selected_logo_options['field'];
                     $selectedProduct = $parser_from_id['product_sid'];
                     $xml = $parser_from_id['xml'];
                     $xml = SJB_XmlImport::cleanXmlFromImport($xml);
                     $map = unserialize($parser_from_id['maper']);
                     $selected = array_values($map);
                     $a_selected = array_keys($map);
                 } else {
                     $xml = SJB_XmlImport::cleanXmlFromImport($_REQUEST['xml']);
                 }
                 $sxml = new simplexml();
                 $tree = $sxml->xml_load_file($xml, 'array');
                 if (isset($tree['@content'])) {
                     $tree = $tree[0];
                 }
                 if (is_array($tree)) {
                     $tree = SJB_XmlImport::convertArray($tree);
                     foreach ($tree as $key => $val) {
                         unset($tree[$key]);
                         // replace '@' and ':'
                         $key = SJB_XmlImport::encodeSpecialEntities($key);
                         $tree[$key]['val'] = $val;
                         $tree[$key]['key'] = $key;
                     }
                     $field_types = array(0, $type_id);
                     $listing_fields = array();
                     $i = 0;
                     foreach ($field_types as $type) {
                         $listing_fields_info = SJB_ListingFieldManager::getListingFieldsInfoByListingType($type);
                         foreach ($listing_fields_info as $listing_field_info) {
                             if ($listing_field_info['type'] == 'location') {
                                 foreach ($listing_field_info['fields'] as $fieldInfo) {
                                     $listing_field = new SJB_ListingField($fieldInfo);
                                     $listing_field->setSID($fieldInfo['sid']);
                                     $listing_fields[$i]['id'] = $listing_field_info['id'] . '_' . $listing_field->details->properties['id']->value;
                                     $listing_fields[$i]['caption'] = $listing_field->details->properties['id']->value;
                                     $i++;
                                 }
                             } else {
                                 $listing_field = new SJB_ListingField($listing_field_info);
                                 $listing_field->setSID($listing_field_info['sid']);
                                 $listing_fields[$i]['id'] = $listing_field->details->properties['id']->value;
                                 $listing_fields[$i]['caption'] = $listing_field->details->properties['id']->value;
                                 $i++;
                             }
                         }
                     }
                     $listing_fields[$i]['id'] = $listing_fields[$i]['caption'] = "date";
                     $i++;
                     $listing_fields[$i]['id'] = $listing_fields[$i]['caption'] = "url";
                     $i++;
                     $listing_fields[$i]['id'] = $listing_fields[$i]['caption'] = "external_id";
                 } else {
                     $errors[] = 'XML syntaxis error.';
                     $template = 'add_step_one.tpl';
                 }
             } else {
                 $errors[] = 'Please input correct xml';
                 $template = 'add_step_one.tpl';
             }
             $tp->assign('id', $id);
             $tp->assign('selected', $selected);
             $tp->assign('a_selected', $a_selected);
             $tp->assign('xml', htmlspecialchars($xml));
             $tp->assign('xmlToUser', $xml);
             $tp->assign('user_groups', SJB_UserGroupManager::getAllUserGroupsInfo());
             $tp->assign('form_name', $parsing_name);
             $tp->assign('form_user', $usr_name);
             $tp->assign('form_url', $pars_url);
             $tp->assign('form_description', $form_description);
             $type_name = SJB_ListingTypeManager::getListingTypeIDBySID($type_id);
             $tp->assign('type_id', $type_id);
             $tp->assign('type_name', $type_name);
             $tp->assign('errors', $errors);
             $tp->assign('tree', $tree);
             $tp->assign("fields", $listing_fields);
             $tp->assign('logo_options', $logo_options_array);
             $tp->assign('selectedLogoOption', $selectedLogoOption);
             $tp->assign('selectedLogoField', $selectedLogoField);
             $tp->assign('selectedProduct', $selectedProduct);
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             $tp->display($template);
             break;
         case '3':
             $parsing_name = isset($_REQUEST['parser_name']) ? SJB_DB::quote($_REQUEST['parser_name']) : '';
             $pars_url = isset($_POST['parser_url']) ? SJB_DB::quote($_POST['parser_url']) : '';
             $selectedLogoOption = isset($_POST['logo_options']) ? $_POST['logo_options'] : '';
             $selectedLogoField = isset($_POST['import_logo_field']) ? $_POST['import_logo_field'] : '';
             $form_description = isset($_REQUEST['form_description']) ? SJB_DB::quote($_REQUEST['form_description']) : "";
             $type_id = isset($_POST['type_id']) ? intval($_POST['type_id']) : "";
             $script = isset($_POST['custom_script']) && !empty($_POST['custom_script']) ? SJB_DB::quote($_POST['custom_script']) : "";
             $script_users = SJB_DB::quote(SJB_Request::getVar('custom_script_users', '', SJB_Request::METHOD_POST));
             $defaultValue = SJB_Request::getVar('default_value', false);
             $defaultValueUser = SJB_Request::getVar('user_default_value', false);
             $selectedProduct = SJB_Request::getVar('postUnderProduct');
             $importType = SJB_Request::getVar('import_type', 'increment');
             if ($defaultValue) {
                 foreach ($defaultValue as $key => $val) {
                     $defaultValue[$key] = htmlspecialchars($val, ENT_QUOTES, 'UTF-8');
                 }
             }
             if ($defaultValueUser) {
                 foreach ($defaultValueUser as $key => $val) {
                     $defaultValueUser[$key] = htmlspecialchars($val, ENT_QUOTES, 'UTF-8');
                 }
             }
             $original_xml = !empty($_POST['xml']) ? SJB_DB::quote($_POST['xml']) : '';
             $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
             $addQuery = '';
             $username = SJB_XmlImport::decodeSpecialEntities(SJB_Request::getVar('username', ''));
             $external_id = str_replace('_dog_', '@', SJB_Request::getVar('external_id', ''));
             $site_url = SJB_System::getSystemSettings("SITE_URL");
             if ($addNewUser == 1 && empty($_REQUEST['mapped_user'])) {
                 $error = 'Required user profile fields are not mapped';
                 SJB_HelperFunctions::redirect($site_url . '/edit-import/?id=' . $id . '&save_error=' . base64_encode($error));
             }
             if (!empty($_REQUEST['mapped']) && is_array($_REQUEST['mapped']) && !empty($original_xml) && empty($errors)) {
                 // make map
                 $map1 = array();
                 $map2 = array();
                 $serUserMap = '';
                 foreach ($_REQUEST['mapped'] as $one) {
                     $tmp = explode(':', $one);
                     $map1[] = $tmp[0];
                     $map2[] = $tmp[1];
                 }
                 if ($addNewUser == 1 && !empty($_REQUEST['mapped_user']) && is_array($_REQUEST['mapped_user'])) {
                     // make map
                     $mapUser1 = array();
                     $mapUser2 = array();
                     foreach ($_REQUEST['mapped_user'] as $one) {
                         $tmp = explode(':', $one);
                         $mapUser1[] = str_replace('user_', '', $tmp[0]);
                         $mapUser2[] = $tmp[1];
                     }
                     foreach ($mapUser1 as $key => $val) {
                         $val = SJB_XmlImport::decodeSpecialEntities($val);
                         $mapUser[$val] = $mapUser2[$key];
                     }
                     $serUserMap = serialize($mapUser);
                 }
                 //$map = array_combine($map1, $map2); // PHP5
                 foreach ($map1 as $key => $val) {
                     $val = SJB_XmlImport::decodeSpecialEntities($val);
                     $map[$val] = $map2[$key];
                 }
                 if ($selectedLogoOption && $selectedLogoOption != 'not_logo') {
                     //get real data without any cache
                     if (!SJB_ListingFieldDBManager::getListingFieldInfoByID('ListingLogo')) {
                         $listing_field_info = array('id' => 'ListingLogo', 'type' => 'logo', 'is_system' => false, 'is_required' => false, 'caption' => 'Listing Logo');
                         $listing_field = new SJB_ListingField($listing_field_info, $type_id);
                         $pages = SJB_PostingPagesManager::getFirstPageEachListingType();
                         SJB_ListingFieldManager::saveListingField($listing_field, $pages);
                     }
                     if ($key = array_search('ListingLogo', $map) !== false) {
                         unset($map[$key]);
                     }
                 }
                 if ($defaultValue) {
                     foreach ($defaultValue as $key => $val) {
                         if ($val == '') {
                             unset($defaultValue[$key]);
                         }
                     }
                     $defaultValue = SJB_db::quote(serialize($defaultValue));
                     $addQuery .= ", default_value = '" . $defaultValue . "'";
                 }
                 if ($defaultValueUser) {
                     foreach ($defaultValueUser as $keyuser => $valuser) {
                         if ($valuser == '') {
                             unset($defaultValueUser[$keyuser]);
                         }
                     }
                     $defaultValueUser = SJB_db::quote(serialize($defaultValueUser));
                     $addQuery .= ", default_value_user = '******'";
                 }
                 $queryParsUrl = SJB_DB::quote($pars_url);
                 $queryImportType = SJB_DB::quote($importType);
                 $queryId = intval($id);
                 $query = "SET\n\t\t\t\t\t\t\t`custom_script_users` = ?s,\n\t\t\t\t\t\t\t`custom_script` = ?s,\n\t\t\t\t\t\t\t`type_id` = ?n,\n\t\t\t\t\t\t\t`name` = ?s,\n\t\t\t\t\t\t\t`description` = ?s,\n\t\t\t\t\t\t\t`url` = ?s,\n\t\t\t\t\t\t\t`usr_id` = ?n,\n\t\t\t\t\t\t\t`usr_name` = ?s,\n\t\t\t\t\t\t\t`maper_user` = ?s,\n\t\t\t\t\t\t\t`xml` = ?s,\n\t\t\t\t\t\t\t`add_new_user` = ?n,\n\t\t\t\t\t\t\t`username` = ?s,\n\t\t\t\t\t\t\t`external_id` = ?s,\n\t\t\t\t\t\t\t`product_sid` = ?n,\n\t\t\t\t\t\t\t`import_type` = ?s\n\t\t\t\t\t\t\t{$addQuery}";
                 if ($id > 0) {
                     SJB_DB::query("UPDATE `parsers` {$query} WHERE id = ?n", $script_users, $script, $type_id, $parsing_name, $form_description, $queryParsUrl, $usr_id, $usr_name, $serUserMap, $original_xml, $addNewUser, $username, $external_id, $selectedProduct, $queryImportType, $queryId);
                 } else {
                     $id = SJB_DB::query("INSERT INTO `parsers` {$query}", $script_users, $script, $type_id, $parsing_name, $form_description, $queryParsUrl, $usr_id, $usr_name, $serUserMap, $original_xml, $addNewUser, $username, $external_id, $selectedProduct, $queryImportType);
                 }
                 $errorFile = '';
                 $xml_logo = null;
                 switch ($selectedLogoOption) {
                     case 'import_logo':
                         $map[$selectedLogoField] = 'ListingLogo';
                         break;
                     case 'upload_logo':
                         if (!empty($_FILES['upload_logo_file'])) {
                             if ($_FILES['upload_logo_file']['error']) {
                                 $errorFile = SJB_UploadFileManager::getErrorId($_FILES['upload_logo_file']['error']);
                             } else {
                                 $width = SJB_Settings::getSettingByName('listing_picture_width');
                                 $height = SJB_Settings::getSettingByName('listing_picture_height');
                                 $property_info['second_width'] = SJB_Settings::getSettingByName('listing_thumbnail_width');
                                 $property_info['second_height'] = SJB_Settings::getSettingByName('listing_thumbnail_height');
                                 $picture = new SJB_UploadPictureManager();
                                 $picture->setWidth($width);
                                 $picture->setHeight($height);
                                 if ($picture->isValidUploadedPictureFile('upload_logo_file')) {
                                     $xml_logo = "XMLImportLogo_{$id}";
                                     $picture->setUploadedFileID($xml_logo);
                                     $picture->uploadPicture('upload_logo_file', $property_info);
                                 }
                             }
                         }
                         break;
                 }
                 $logo_options = serialize(array('option' => $selectedLogoOption, 'field' => $selectedLogoField));
                 $serMap = serialize($map);
                 if ($xml_logo) {
                     SJB_DB::query("UPDATE `parsers` SET maper = ?s, `xml_logo` = ?s, logo_options = ?s  WHERE id = ?n", $serMap, $xml_logo, $logo_options, $id);
                 } else {
                     SJB_DB::query("UPDATE `parsers` SET maper = ?s, logo_options = ?s  WHERE id = ?n", $serMap, $logo_options, $id);
                 }
                 $form_submitted = SJB_Request::getVar('form_action');
                 if ($form_submitted == 'save_info') {
                     SJB_HelperFunctions::redirect($site_url . '/show-import/');
                 } elseif ($form_submitted == 'apply_info') {
                     $getterParameters = '?id=' . $id;
                     if ($errorFile) {
                         $getterParameters .= '&error=' . $errorFile;
                     }
                     SJB_HelperFunctions::redirect($site_url . '/edit-import/' . $getterParameters);
                 }
             } else {
                 if (empty($errors)) {
                     $errors[] = 'No data to save';
                 }
                 $tp->assign('errors', $errors);
                 $tp->assign('xml', htmlspecialchars($original_xml));
                 $tp->assign('xmlToUser', $original_xml);
                 $tp->assign('form_name', $parsing_name);
                 $tp->assign('form_user', $usr_name);
                 $tp->assign('form_url', $pars_url);
                 $tp->assign('form_description', $form_description);
                 $tp->display('add_step_three.tpl');
             }
             break;
     }
 }
コード例 #23
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $template = 'flag_listing_settings.tpl';
     $form_submitted = SJB_Request::getVar('submit');
     $action = SJB_Request::getVar('action');
     $itemSID = SJB_Request::getVar('item_sid');
     switch ($action) {
         case 'save':
             $saveValue = trim(SJB_Request::getVar('new_value'));
             $listingTypesArray = SJB_Request::getVar('flag_listing_types');
             $typesForSave = '';
             // make string to save
             if (!empty($listingTypesArray)) {
                 $typesForSave = implode(',', $listingTypesArray);
             }
             if (empty($saveValue)) {
                 $errors['PLEASE_ENTER_FLAG_REASON'] = 'Please enter flag reason';
             }
             if (empty($errors) && empty($typesForSave)) {
                 $errors['PLEASE_SELECT_LISTING_TYPE'] = 'Please select listing type';
             }
             if (empty($errors)) {
                 if (!$itemSID) {
                     // ADD NEW ITEM
                     $result = SJB_DB::query('SELECT `sid` FROM `flag_listing_settings` WHERE `listing_type_sid` = ?s AND `value` = ?s LIMIT 1', $typesForSave, $saveValue);
                     if (!empty($result)) {
                         $errors['THIS_FLAG_REASON_ALREADY_EXISTS_IN_THE_SYSTEM'] = 'This flag reason already exists in the system';
                     } else {
                         SJB_DB::queryExec('INSERT INTO `flag_listing_settings` SET `listing_type_sid` = ?s, `value` = ?s', $typesForSave, $saveValue);
                     }
                 } else {
                     // UPDATE ITEM
                     SJB_DB::queryExec('UPDATE `flag_listing_settings` SET `value` = ?s, `listing_type_sid` = ?s WHERE `sid` = ?n', $saveValue, $typesForSave, $itemSID);
                 }
                 if ($form_submitted == 'save') {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flag-listing-settings/');
                 } elseif ($form_submitted == 'apply') {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flag-listing-settings/?item_sid=' . $itemSID . '&action=edit');
                 }
             }
             break;
         case 'delete':
             SJB_DB::query('DELETE FROM `flag_listing_settings` WHERE `sid` = ?n', $itemSID);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/flag-listing-settings/');
             break;
         case 'edit':
             $currentItem = SJB_DB::query('SELECT * FROM `flag_listing_settings` WHERE `sid` = ?n LIMIT 1', $itemSID);
             $template = 'flag_listing_settings_edit.tpl';
             if ($currentItem) {
                 $currentItem = array_pop($currentItem);
                 $typesArray = explode(',', $currentItem['listing_type_sid']);
                 $currentItem['listing_type_sid'] = $typesArray;
             }
             $tp->assign('current_setting', $currentItem);
             break;
     }
     // Need to select listing type
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     $types = array();
     foreach ($listingTypes as $elem) {
         $types[$elem['sid']] = $elem;
     }
     $listingTypes = $types;
     $tp->assign('listing_types', $listingTypes);
     $settings = SJB_DB::query('SELECT * FROM `flag_listing_settings`');
     foreach ($settings as $key => $elem) {
         $settings[$key]['listing_type_sid'] = explode(',', $elem['listing_type_sid']);
     }
     $tp->assign('settings', $settings);
     $tp->assign('errors', $errors);
     $tp->display($template);
 }
コード例 #24
0
ファイル: ListingDetails.php プロジェクト: Maxlander/shixi
 function addListingTypeIDProperty($type_id)
 {
     if (SJB_MemoryCache::has('listingTypesInfo')) {
         $listing_types_info = SJB_MemoryCache::get('listingTypesInfo');
     } else {
         $listing_types_info = SJB_ListingTypeManager::getAllListingTypesInfo();
         SJB_MemoryCache::set('listingTypesInfo', $listing_types_info);
     }
     $list_values = array();
     foreach ($listing_types_info as $type_info) {
         $list_values[] = array('id' => $type_info['id'], 'caption' => $type_info['name']);
     }
     $this->addProperty(array('id' => 'listing_type', 'type' => 'list', 'value' => $type_id, 'is_system' => true, 'list_values' => $list_values));
     return array('id' => 'listing_type', 'real_id' => 'listing_type_sid', 'transform_function' => 'SJB_ListingTypeManager::getListingTypeSIDByID');
 }
コード例 #25
0
ファイル: ContractSQL.php プロジェクト: Maxlander/shixi
 public static function updateAllContractsExtraInfoByProductSID($contractsSIDs, $productSID)
 {
     $productExtraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID);
     $currentPermissions = array();
     SJB_DB::query("delete from `permissions` where `type` = 'contract' and `role` in ({$contractsSIDs})");
     foreach (explode(',', $contractsSIDs) as $contractSID) {
         $contractInfo = self::selectInfoByID($contractSID);
         if ($contractInfo['status'] == 'active') {
             SJB_DB::query("INSERT INTO `permissions` (`type`, `role`, `name`, `value`, `params`, `message`)\n\t\t\t\t\t\t\t\tSELECT 'contract', ?s, `name`, `value`, `params`, `message`\n\t\t\t\t\t\t\t\tFROM `permissions`\n\t\t\t\t\t\t\t\tWHERE `type` = 'product' AND `role` = ?s", $contractSID, $productSID);
         }
         $extraInfo = !empty($contractInfo['serialized_extra_info']) ? unserialize($contractInfo['serialized_extra_info']) : array();
         $contractExtraInfo = $productExtraInfo;
         if (!empty($extraInfo['pricing_type']) && $extraInfo['pricing_type'] == 'volume_based') {
             $numberOfListings = $extraInfo['number_of_listings'];
             $numberOfPostings[$contractSID] = $numberOfListings;
             $volumeBasedPricing = !empty($productExtraInfo['volume_based_pricing']) ? $productExtraInfo['volume_based_pricing'] : array();
             if (!empty($volumeBasedPricing['listings_range_from'])) {
                 for ($i = 1; $i <= count($volumeBasedPricing['listings_range_from']); $i++) {
                     if ($numberOfListings >= $volumeBasedPricing['listings_range_from'][$i] && $numberOfListings <= $volumeBasedPricing['listings_range_to'][$i]) {
                         $contractExtraInfo['listings_range_from'] = $volumeBasedPricing['listings_range_from'][$i];
                         $contractExtraInfo['listings_range_to'] = $volumeBasedPricing['listings_range_to'][$i];
                         $contractExtraInfo['price_per_unit'] = $volumeBasedPricing['price_per_unit'][$i];
                         $contractExtraInfo['renewal_price'] = $volumeBasedPricing['renewal_price_per_listing'][$i];
                         $contractExtraInfo['number_of_listings'] = $numberOfListings;
                         break;
                     }
                 }
                 unset($contractExtraInfo['volume_based_pricing']);
             }
         }
         SJB_DB::query("UPDATE `contracts` SET `serialized_extra_info` = ?s WHERE `id` = ?n", serialize($contractExtraInfo), $contractSID);
     }
     if (isset($productExtraInfo['pricing_type'])) {
         $currentPermissions = SJB_DB::query("SELECT * FROM `permissions` WHERE `type` = 'contract' AND `role` in ({$contractsSIDs})");
     }
     foreach ($currentPermissions as $key => $permission) {
         $currentPermissions[$permission['name']] = $permission;
         unset($currentPermissions[$key]);
     }
     if ($currentPermissions && !empty($numberOfPostings) || isset($productExtraInfo['number_of_listings'])) {
         foreach (explode(',', $contractsSIDs) as $contractSID) {
             $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
             foreach ($listingTypes as $listingType) {
                 if (isset($currentPermissions['post_' . strtolower($listingType['id'])])) {
                     $permission = $currentPermissions['post_' . strtolower($listingType['id'])];
                     if ($permission['value'] == 'allow') {
                         SJB_DB::query("UPDATE `permissions` SET `params` = ?n WHERE `type` = 'contract' AND  `role` = ?s AND `name` = ?s", !empty($numberOfPostings) ? $numberOfPostings[$contractSID] : $productExtraInfo['number_of_listings'], $contractSID, 'post_' . strtolower($listingType['id']));
                     }
                 }
             }
         }
     }
 }
コード例 #26
0
ファイル: import_listings.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     ini_set('max_execution_time', 0);
     $tp = SJB_System::getTemplateProcessor();
     $file_info = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
     $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8');
     $listingTypeID = SJB_Request::getVar('listing_type_id', null);
     $productSID = SJB_Request::getVar('product_sid', 0);
     $errors = array();
     if ($listingTypeID && $productSID) {
         $acl = SJB_Acl::getInstance();
         $resource = 'post_' . strtolower($listingTypeID);
         if (!$acl->isAllowed($resource, $productSID, 'product')) {
             $errors[] = 'You cannot import listings of this type under the selected product';
         }
     }
     if (!empty($file_info)) {
         $extension = SJB_Request::getVar('file_type');
         if (!SJB_ImportFile::isValidFileExtensionByFormat($extension, $file_info)) {
             $errors['DO_NOT_MATCH_SELECTED_FILE_FORMAT'] = true;
         }
     }
     if (empty($file_info) || $file_info['error'] || $errors) {
         if (isset($file_info['error']) && $file_info['error'] > 0) {
             $errors[SJB_UploadFileManager::getErrorId($file_info['error'])] = 1;
         }
         $listing_types = SJB_ListingTypeManager::getAllListingTypesInfo();
         $products = SJB_ProductsManager::getProductsByProductType('post_listings');
         $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
         $tp->assign('listing_types', $listing_types);
         $tp->assign('products', $products);
         $tp->assign('errors', $errors);
         $tp->assign('charSets', SJB_HelperFunctions::getCharSets());
         $tp->display('import_listings.tpl');
     } else {
         $i18n = SJB_I18N::getInstance();
         $csv_delimiter = SJB_Request::getVar('csv_delimiter', null);
         $activeStatus = SJB_Request::getVar('active', 0);
         $activationDate = SJB_Request::getVar('activation_date', date('Y-m-d'));
         $activationDate = $i18n->getInput('date', $activationDate);
         $non_existed_values_flag = SJB_Request::getVar('non_existed_values', null);
         $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID);
         if (empty($productInfo['listing_duration'])) {
             $expirationDate = '';
         } else {
             $timestamp = strtotime($activationDate . ' + ' . $productInfo['listing_duration'] . ' days');
             $expirationDate = $i18n->getDate(date('Y-m-d', $timestamp));
         }
         $extension = $_REQUEST['file_type'];
         if ($extension == 'xls') {
             $import_file = new SJB_ImportFileXLS($file_info);
         } elseif ($extension == 'csv') {
             $import_file = new SJB_ImportFileCSV($file_info, $csv_delimiter);
         }
         $import_file->parse($encodingFromCharset);
         $listing = $this->CreateListing(array(), $listingTypeID);
         $imported_data = $import_file->getData();
         $isFileImported = true;
         $count = 0;
         $addedListingsSids = array();
         $nonExistentUsers = array();
         foreach ($imported_data as $key => $importedColumn) {
             if ($key == 1) {
                 $imported_data_processor = new SJB_ImportedDataProcessor($importedColumn, $listing);
                 continue;
             }
             if (!$importedColumn) {
                 continue;
             }
             $count++;
             $listingInfo = $imported_data_processor->getData($non_existed_values_flag, $importedColumn);
             $doc = new DOMDocument();
             foreach ($listing->getProperties() as $property) {
                 if ($property->getType() == 'complex' && !empty($listingInfo[$property->id])) {
                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                     $doc->loadXML($listingInfo[$property->id]);
                     $results = $doc->getElementsByTagName($property->id . 's');
                     $listingInfo[$property->id] = array();
                     foreach ($results as $complexparent) {
                         $i = 1;
                         foreach ($complexparent->getElementsByTagName($property->id) as $result) {
                             $resultXML = simplexml_import_dom($result);
                             foreach ($childFields as $childField) {
                                 if (isset($resultXML->{$childField}['id'])) {
                                     $listingInfo[$property->id][$childField['id']][$i] = XML_Util::reverseEntities((string) $resultXML->{$childField}['id']);
                                 }
                             }
                             $i++;
                         }
                     }
                 } elseif ($property->getType() == 'monetary' && !empty($listingInfo[$property->id])) {
                     $value = $listingInfo[$property->id];
                     $listingInfo[$property->id] = array();
                     $listingInfo[$property->id]['value'] = $value;
                     $defaultCurrency = SJB_CurrencyManager::getDefaultCurrency();
                     $currencyCode = !empty($listingInfo[$property->id . "Currency"]) ? $listingInfo[$property->id . "Currency"] : $defaultCurrency['currency_code'];
                     $currency = SJB_CurrencyManager::getCurrencyByCurrCode($currencyCode);
                     $listingInfo[$property->id]['add_parameter'] = !empty($currency['sid']) ? $currency['sid'] : '';
                     if (isset($listingInfo[$property->id . "Currency"])) {
                         unset($listingInfo[$property->id . "Currency"]);
                     }
                 } elseif ($property->getType() == 'location') {
                     $locationFields = array($property->id . '.Country', $property->id . '.State', $property->id . '.City', $property->id . '.ZipCode');
                     $locationFieldAdded = array();
                     foreach ($locationFields as $locationField) {
                         if (array_key_exists($locationField, $listingInfo)) {
                             switch ($locationField) {
                                 case $property->id . '.Country':
                                     $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]);
                                     if (!$value) {
                                         $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]);
                                     }
                                     break;
                                 case $property->id . '.State':
                                     $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]);
                                     if (!$value) {
                                         $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]);
                                     }
                                     break;
                                 default:
                                     $value = $listingInfo[$locationField];
                                     break;
                             }
                             $listingInfo[$property->id][str_replace($property->id . '.', '', $locationField)] = $value;
                             $locationFieldAdded[] = str_replace($property->id . '.', '', $locationField);
                         }
                     }
                     if ($property->id == 'Location') {
                         $locationFields = array('Country', 'State', 'City', 'ZipCode');
                         foreach ($locationFields as $locationField) {
                             if (array_key_exists($locationField, $listingInfo) && !in_array($locationField, $locationFieldAdded) && !$listing->getProperty($locationField)) {
                                 switch ($locationField) {
                                     case 'Country':
                                         $value = SJB_CountriesManager::getCountrySIDByCountryName($listingInfo[$locationField]);
                                         if (!$value) {
                                             $value = SJB_CountriesManager::getCountrySIDByCountryCode($listingInfo[$locationField]);
                                         }
                                         break;
                                     case 'State':
                                         $value = SJB_StatesManager::getStateSIDByStateName($listingInfo[$locationField]);
                                         if (!$value) {
                                             $value = SJB_StatesManager::getStateSIDByStateCode($listingInfo[$locationField]);
                                         }
                                         break;
                                     default:
                                         $value = $listingInfo[$locationField];
                                         break;
                                 }
                                 $listingInfo[$property->id][$locationField] = $value;
                             }
                         }
                     }
                 }
             }
             $listing = $this->CreateListing($listingInfo, $listingTypeID);
             $pictures = array();
             if (isset($listingInfo['pictures'])) {
                 $listing->addPicturesProperty();
                 $explodedPictures = explode(';', $listingInfo['pictures']);
                 foreach ($explodedPictures as $picture) {
                     if (!empty($picture)) {
                         $pictures[] = $picture;
                     }
                 }
                 $listing->setPropertyValue('pictures', count($pictures));
             }
             $listing->addActiveProperty($activeStatus);
             $listing->addActivationDateProperty($activationDate);
             $listing->addExpirationDateProperty($expirationDate);
             SJB_ListingDBManager::setListingExpirationDateBySid($listing->sid);
             $listing->setProductInfo(SJB_ProductsManager::getProductExtraInfoBySID($productSID));
             $listing->setPropertyValue('access_type', 'everyone');
             $listing->setPropertyValue('status', 'approved');
             foreach ($listing->getProperties() as $property) {
                 if ($property->getType() == 'tree' && $property->value !== '') {
                     try {
                         $treeImportHelper = new SJB_FieldTreeImportHelper($property->value);
                         $treeValues = $treeImportHelper->parseAndGetValues();
                         $listing->setPropertyValue($property->id, $treeValues);
                         $listing->details->properties[$property->id]->type->property_info['value'] = $treeValues;
                     } catch (Exception $e) {
                         $listing->setPropertyValue($property->id, '');
                         $listing->details->properties[$property->id]->type->property_info['value'] = '';
                         SJB_Error::writeToLog('Listing Import. Tree Field Value Error: ' . $e->getMessage());
                     }
                 } elseif ($property->id == 'ApplicationSettings' && !empty($listingInfo['ApplicationSettings'])) {
                     if (preg_match("^[a-z0-9\\._-]+@[a-z0-9\\._-]+\\.[a-z]{2,}\$^iu", $listingInfo['ApplicationSettings'])) {
                         $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 1);
                     } elseif (preg_match("^(https?:\\/\\/)^", $listingInfo['ApplicationSettings'])) {
                         $listingInfo['ApplicationSettings'] = array('value' => $listingInfo['ApplicationSettings'], 'add_parameter' => 2);
                     } else {
                         $listingInfo['ApplicationSettings'] = array('value' => '', 'add_parameter' => '');
                     }
                     //put empty if not valid email or url
                     $listing->details->properties[$property->id]->type->property_info['value'] = $listingInfo['ApplicationSettings'];
                 } elseif ($property->getType() == 'complex') {
                     $childFields = SJB_ListingComplexFieldManager::getListingFieldsInfoByParentSID($property->sid);
                     $complexChildValues = $property->value;
                     foreach ($childFields as $childField) {
                         if ($childField['type'] == 'complexfile' && !empty($complexChildValues[$childField['id']])) {
                             $fieldInfo = SJB_ListingComplexFieldManager::getFieldInfoBySID($childField['sid']);
                             if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo, $property->id)) {
                                 $isFileImported = false;
                             }
                         }
                         if ($property->type->complex->details->properties[$childField['id']]->value == null) {
                             $property->type->complex->details->properties[$childField['id']]->value = array(1 => '');
                             $property->type->complex->details->properties[$childField['id']]->type->property_info['value'] = array(1 => '');
                         }
                     }
                 }
                 // The import of files at import of listings
                 if (in_array($property->getType(), array('file', 'logo', 'video')) && $property->value !== '') {
                     $fieldInfo = SJB_ListingFieldDBManager::getListingFieldInfoByID($property->id);
                     if (!SJB_UploadFileManager::fileImport($listingInfo, $fieldInfo)) {
                         $isFileImported = false;
                     }
                 }
             }
             if ($non_existed_values_flag == 'add') {
                 $this->UpdateListValues($listing);
             }
             if ($listing->getUserSID()) {
                 SJB_ListingManager::saveListing($listing);
                 $listingSid = $listing->getSID();
                 SJB_Statistics::addStatistics('addListing', $listing->getListingTypeSID(), $listingSid);
                 SJB_ListingManager::activateListingBySID($listingSid, false);
                 if (!$this->fillGallery($listingSid, $pictures)) {
                     $isFileImported = false;
                 }
                 $addedListingsSids[] = $listingSid;
             } else {
                 $nonExistentUsers[] = $listingInfo['username'];
                 $count--;
             }
         }
         SJB_BrowseDBManager::addListings($addedListingsSids);
         SJB_ProductsManager::incrementPostingsNumber($productSID, count($addedListingsSids));
         if ($isFileImported && file_exists(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY'))) {
             SJB_Filesystem::delete(SJB_System::getSystemSettings('IMPORT_FILES_DIRECTORY'));
         }
         $tp->assign('imported_listings_count', $count);
         $tp->assign('nonExistentUsers', $nonExistentUsers);
         $tp->display('import_listings_result.tpl');
     }
 }
コード例 #27
0
ファイル: edit_user.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $parent_name = null;
     $user_sid = SJB_Request::getVar('user_sid', false);
     if (!is_null($user_sid)) {
         $user_info = SJB_UserManager::getUserInfoBySID($user_sid);
         $user_info = array_merge($user_info, $_REQUEST);
         $form_submitted = SJB_Request::getVar('action_name');
         $user = new SJB_User($user_info, $user_info['user_group_sid']);
         if (!empty($user_info['parent_sid'])) {
             $props = $user->getProperties();
             $allowedProperties = array('username', 'email', 'password');
             foreach ($props as $prop) {
                 if (!in_array($prop->getID(), $allowedProperties)) {
                     $user->deleteProperty($prop->getID());
                 }
             }
             $parent_name = SJB_UserManager::getUserNameByUserSID($user_info['parent_sid']);
         }
         $user->setSID($user_info['sid']);
         $user->getProperty('email')->type->disableEmailConfirmation();
         $user->deleteProperty("active");
         $user->makePropertyNotRequired("password");
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) {
             if ($form_submitted) {
                 $email = $user->getPropertyValue('email');
                 if (is_array($email)) {
                     $email = $email['original'];
                 }
                 $user->setPropertyValue('username', $email);
             }
         }
         $user->addExtUserIDProperty($user_info['extUserID']);
         $edit_user_form = new SJB_Form($user);
         $errors = array();
         if ($form_submitted && $edit_user_form->isDataValid($errors)) {
             $password_value = $user->getPropertyValue('password');
             $properties = null;
             if (empty($password_value['original'])) {
                 $properties = $user->getProperties();
                 $user->deleteProperty('password');
             }
             SJB_UserManager::saveUser($user);
             // >>> SJB-1197
             // needs to check session for ajax-uploaded files, and set it to user profile
             $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage');
             $formToken = SJB_Request::getVar('form_token');
             if (!empty($formToken)) {
                 $tmpUploadedFields = SJB_Array::getPath($tmpUploadsStorage, $formToken);
                 if (!is_null($tmpUploadsStorage) && is_array($tmpUploadedFields)) {
                     // prepare user profile fields array
                     $userProfileFieldsInfo = SJB_UserProfileFieldManager::getAllFieldsInfo();
                     $userProfileFields = array();
                     foreach ($userProfileFieldsInfo as $field) {
                         $userProfileFields[$field['id']] = $field;
                     }
                     // look for temporary values
                     foreach ($tmpUploadedFields as $fieldId => $fieldInfo) {
                         // check field ID for valid ID in user profile fields
                         if (!array_key_exists($fieldId, $userProfileFields) || empty($fieldInfo)) {
                             continue;
                         }
                         $fieldType = $userProfileFields[$fieldId]['type'];
                         $profilePropertyId = $fieldId . '_' . $user->getSID();
                         switch (strtolower($fieldType)) {
                             case 'video':
                             case 'file':
                                 // change temporary file ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             case 'logo':
                                 // change temporary file ID and thumb ID
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId, $fieldInfo['file_id']);
                                 SJB_DB::query("UPDATE `uploaded_files` SET `id` = ?s WHERE `id` = ?s", $profilePropertyId . '_thumb', $fieldInfo['file_id'] . '_thumb');
                                 // set value of user property to new uploaded file
                                 $user->setPropertyValue($fieldId, $profilePropertyId);
                                 break;
                             default:
                                 break;
                         }
                         $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}/{$fieldId}");
                     }
                     // and save user with new fields data
                     SJB_UserManager::saveUser($user);
                     SJB_Authorization::updateCurrentUserSession();
                     // clean temporary storage
                     $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}");
                     // CLEAR TEMPORARY SESSION STORAGE
                     SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage);
                 }
             }
             // <<< SJB-1197
             if (SJB_Request::isAjax()) {
                 echo "<p class=\"green\">User Saved</p>";
                 exit;
             }
             if ($form_submitted == 'save_info') {
                 $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-users/" . mb_strtolower($userGroupInfo['id'], 'utf8'));
             }
             if (!empty($properties)) {
                 $user->details->properties = $properties;
             }
         }
         if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_info['user_group_sid'])) {
             $user->deleteProperty("username");
         }
         $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
         $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($user_info['user_group_sid']);
         $allowedListingTypes = array();
         foreach ($products as $product) {
             if (!empty($product['listing_type_sid']) && empty($allowedListingTypes[$product['listing_type_sid']])) {
                 foreach ($listingTypes as $listingType) {
                     if ($product['listing_type_sid'] == $listingType['sid']) {
                         $allowedListingTypes[$product['listing_type_sid']] = $listingType;
                     }
                 }
             }
         }
         $edit_user_form = SJB_ObjectMother::createForm($user);
         $edit_user_form->registerTags($tp);
         $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user_info['user_group_sid']);
         if (SJB_UserManager::checkBan($errors, $user_info['ip'])) {
             $user_info['ip_is_banned'] = 1;
         }
         $tp->assign("form_fields", $edit_user_form->getFormFieldsInfo());
         $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
         $tp->assign("errors", $errors);
         $tp->assign("listingTypes", $allowedListingTypes);
         $tp->assign("user_info", $user_info);
         $tp->assign("user_group_info", $userGroupInfo);
         $tp->assign('userTree', true);
         $tp->assign("parent_name", $parent_name);
         $tp->assign("restore", preg_match('/manage-(jobseekers)|(employers)|([a-z0-9\\_]-users)/', SJB_Request::getVar('HTTP_REFERER', '', 'SERVER')));
         SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']);
         $tp->display("edit_user.tpl");
     }
 }
コード例 #28
0
ファイル: top_menu_block.php プロジェクト: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $tp->assign('listingTypesInfo', SJB_ListingTypeManager::getAllListingTypesInfo());
     $tp->display('top.tpl');
 }
コード例 #29
0
 private function prepareTplVarsForListing()
 {
     $listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
     foreach ($listingTypes as &$listingType) {
         $listing = SJB_ObjectMother::createListing(array(), $listingType['sid']);
         $fields = SJB_ListingManager::createTemplateStructureForListing($listing);
         unset($fields['METADATA']);
         unset($fields['user']);
         $listingType['fields'] = $this->echoVars($fields);
     }
     $this->tp->assign('listingTypes', $listingTypes);
 }