public function execute() { $tp = SJB_System::getTemplateProcessor(); $userGroupsInfo = SJB_UserGroupManager::getAllUserGroupsInfo(); $tp->assign('userGroupsInfo', $userGroupsInfo); $tp->display('choose_user_group.tpl'); }
public function execute() { ini_set('max_execution_time', 0); $tp = SJB_System::getTemplateProcessor(); $userGroupID = SJB_Request::getVar('user_group_id', 0); $user = SJB_UsersExportController::createUser($userGroupID); $searchFormBuilder = new SJB_SearchFormBuilder($user); $criteria = $searchFormBuilder->extractCriteriaFromRequestData($_REQUEST, $user); $searchFormBuilder->registerTags($tp); $searchFormBuilder->setCriteria($criteria); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $exportProperties = SJB_Request::getVar('export_properties', array()); if (empty($exportProperties)) { SJB_FlashMessages::getInstance()->addWarning('EMPTY_EXPORT_PROPERTIES'); } else { $innerJoin = false; if (isset($_REQUEST['product']['multi_like']) && $_REQUEST['product']['multi_like'] != '') { $products = $_REQUEST['product']['multi_like']; if (is_array($products)) { $products = implode(',', $products); } $whereParam = implode(',', explode(',', SJB_DB::quote($products))); $innerJoin = array('contracts' => array('join_field' => 'user_sid', 'join_field2' => 'sid', 'join' => 'INNER JOIN', 'where' => "AND FIND_IN_SET(`contracts`.`product_sid`, '{$whereParam}')")); unset($criteria['system']['product']); } $searcher = new SJB_UserSearcher(false, 'parent_sid', 'ASC', $innerJoin); $searchAliases = SJB_UsersExportController::getSearchPropertyAliases(); $foundUsersSid = $searcher->getObjectsSIDsByCriteria($criteria, $searchAliases); if (!empty($foundUsersSid)) { $result = SJB_UsersExportController::createExportDirectories(); if ($result === true) { $exportProperties['extUserID'] = 1; $exportProperties['parent_sid'] = 1; $exportAliases = SJB_UsersExportController::getExportPropertyAliases(); $exportData = SJB_UsersExportController::getExportData($foundUsersSid, $exportProperties, $exportAliases); $fileName = 'users.xls'; SJB_UsersExportController::makeExportFile($exportData, $fileName); if (!file_exists(SJB_System::getSystemSettings('EXPORT_FILES_DIRECTORY') . "/{$fileName}")) { SJB_FlashMessages::getInstance()->addWarning('CANT_CREATE_EXPORT_FILES'); } else { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/users/archive-and-send-export-data/"); } } } else { SJB_FlashMessages::getInstance()->addWarning('EMPTY_EXPORT_DATA'); } } } $userSystemProperties = SJB_UserManager::getAllUserSystemProperties(); $userGroups = SJB_UserGroupManager::getAllUserGroupsInfo(); $userCommonProperties = array(); foreach ($userGroups as $userGroup) { $userGroupProperties = SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($userGroup['sid']); $userCommonProperties[$userGroup['id']] = $userGroupProperties; } $tp->assign('userSystemProperties', $userSystemProperties); $tp->assign('userCommonProperties', $userCommonProperties); $tp->assign('selected_user_group_id', $userGroupID); $tp->display('export_users.tpl'); }
/** * @return array */ public function getResources($type = 'all', $role = '') { $listingsTypes = SJB_ListingTypeDBManager::getAllListingTypesInfo(); /* sort by resume, job then others */ usort($listingsTypes, function ($listingType) { return $listingType['id'] == 'Job' || $listingType['id'] == 'Resume' ? true : false; }); $listingsTypes = array_reverse($listingsTypes); $listingsTypesResources = array(); foreach ($listingsTypes as $listingType) { $listingType['name'] = !in_array($listingType['name'], array('Resume', 'Job')) ? "'{$listingType['name']}' Listings" : $listingType['name'] . 's'; $listingType['id'] = !in_array($listingType['id'], array('Resume', 'Job')) ? "{$listingType['id']}_listings" : $listingType['id'] . 's'; $listingsTypesResources['manage_' . mb_strtolower($listingType['id'], 'UTF-8')] = array('title' => "Manage {$listingType['name']}", 'group' => 'listings', 'type' => 'subadmin'); $listingsTypesResources['get_notifications_on_' . mb_strtolower($listingType['id'], 'UTF-8') . '_added'] = array('title' => 'Get Notifications on ' . $listingType['name'] . ' Added', 'group' => 'listings', 'type' => 'subadmin', 'parent' => 'manage_' . mb_strtolower($listingType['id'], 'UTF-8'), 'notification' => true); $listingsTypesResources['get_notifications_on_' . mb_strtolower($listingType['id'], 'UTF-8') . '_expiration'] = array('title' => 'Get Notifications on ' . $listingType['name'] . ' Expiration', 'group' => 'listings', 'type' => 'subadmin', 'parent' => 'manage_' . mb_strtolower($listingType['id'], 'UTF-8'), 'notification' => true); } $resources = array('manage_common_listing_fields' => array('title' => 'Manage Common Listing Fields', 'group' => 'listings', 'type' => 'subadmin'), 'manage_listing_types_and_specific_listing_fields' => array('title' => 'Manage Listing Types and Specific Listing Fields', 'group' => 'listings', 'type' => 'subadmin'), 'set_posting_pages' => array('title' => 'Set Posting Pages', 'group' => 'listings', 'type' => 'subadmin'), 'import_listings' => array('title' => 'Import Listings', 'group' => 'listings', 'type' => 'subadmin'), 'export_listings' => array('title' => 'Export Listings', 'group' => 'listings', 'type' => 'subadmin'), 'set_xml_feeds' => array('title' => 'Set XML Feeds', 'group' => 'listings', 'type' => 'subadmin'), 'set_xml_import' => array('title' => 'Set XML Import', 'group' => 'listings', 'type' => 'subadmin'), 'manage_flagged_listings' => array('title' => 'Manage Flagged Listings', 'group' => 'listings', 'type' => 'subadmin'), 'get_notifications_on_listing_flagged' => array('title' => 'Get Notifications on Listing Flagged', 'group' => 'listings', 'type' => 'subadmin', 'parent' => 'manage_flagged_listings', 'notification' => true), 'manage_user_groups' => array('title' => 'Manage User Groups', 'group' => 'users', 'type' => 'subadmin'), 'manage_user_groups_permissions' => array('title' => 'Manage User Groups Permissions', 'group' => 'users', 'type' => 'subadmin', 'parent' => 'manage_user_groups'), 'edit_user_groups_profile_fields' => array('title' => 'Edit User Groups Profile Fields', 'group' => 'users', 'type' => 'subadmin', 'parent' => 'manage_user_groups'), 'import_users' => array('title' => 'Import Users', 'group' => 'users', 'type' => 'subadmin'), 'export_users' => array('title' => 'Export Users', 'group' => 'users', 'type' => 'subadmin'), 'create_and_send_mass_mailings' => array('title' => 'Create and Send Mass Mailings', 'group' => 'users', 'type' => 'subadmin'), 'manage_guest_email_alerts' => array('title' => 'Manage Guest Email Alerts', 'group' => 'users', 'type' => 'subadmin'), 'manage_banned_ips' => array('title' => 'Manage Banned IPs', 'group' => 'users', 'type' => 'subadmin'), 'edit_form_builder' => array('title' => 'Use Form Bulider', 'group' => 'layout and content', 'type' => 'subadmin'), 'edit_templates_and_themes' => array('title' => 'Edit Templates and Themes', 'group' => 'layout and content', 'type' => 'subadmin'), 'manage_banners' => array('title' => 'Manage Banners', 'group' => 'layout and content', 'type' => 'subadmin'), 'manage_site_pages' => array('title' => 'Manage Site Pages', 'group' => 'layout and content', 'type' => 'subadmin'), 'manage_static_content' => array('title' => 'Manage Static Content', 'group' => 'layout and content', 'type' => 'subadmin'), 'manage_news' => array('title' => 'Manage News', 'group' => 'layout and content', 'type' => 'subadmin'), 'manage_polls' => array('title' => 'Manage Polls', 'group' => 'layout and content', 'type' => 'subadmin'), 'configure_system_settings' => array('title' => 'Configure System Settings', 'group' => 'system configuration', 'type' => 'subadmin'), 'social_media' => array('title' => 'Social Media', 'group' => 'system configuration', 'type' => 'subadmin'), 'social_media_bitly' => array('title' => 'Bitly Settings', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'social_media'), 'edit_zipcode_database' => array('title' => 'Edit ZipCode Database', 'group' => 'system configuration', 'type' => 'subadmin'), 'manage_countries' => array('title' => 'Manage Countries', 'group' => 'system configuration', 'type' => 'subadmin'), 'manage_states_or_regions' => array('title' => 'Manage States/Regions', 'group' => 'system configuration', 'type' => 'subadmin'), 'configure_breadcrumbs' => array('title' => 'Configure Breadcrumbs', 'group' => 'system configuration', 'type' => 'subadmin'), 'set_html_filters' => array('title' => 'Set HTML filters', 'group' => 'system configuration', 'type' => 'subadmin'), 'manage_currencies' => array('title' => 'Manage Currencies', 'group' => 'system configuration', 'type' => 'subadmin'), 'set_task_scheduler' => array('title' => 'Set Task Scheduler', 'group' => 'system configuration', 'type' => 'subadmin'), 'manage_plug-ins' => array('title' => 'Manage Plug-ins', 'group' => 'system configuration', 'type' => 'subadmin'), 'set_phpbb_plug-in' => array('title' => 'Set PhpBB Plug-in', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_facebook_plug-in' => array('title' => 'Set Facebook Plug-in', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_linkedin_plug-in' => array('title' => 'Set Linkedin Plug-in', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_wordpress_plug-in' => array('title' => 'Set WordPress Plug-in', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_twitter_plug-in' => array('title' => 'Set Twitter Plug-in', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_sharethisplugin' => array('title' => 'Set ShareThisPlugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_captchaplugin' => array('title' => 'Set CaptchaPlugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_indeedplugin' => array('title' => 'Set IndeedPlugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_jujuplugin' => array('title' => 'Set JujuPlugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_simplyhiredplugin' => array('title' => 'Set SimplyHiredPlugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_googleplugin' => array('title' => 'Set Google Social Plugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_googleanalyticsplugin' => array('title' => 'Set Google Analytics Plugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_beyondplugin' => array('title' => 'Set Beyond Plugin', 'group' => 'system configuration', 'type' => 'subadmin', 'parent' => 'manage_plug-ins'), 'set_refine_search_parameters' => array('title' => 'Set Refine Search Parameters', 'group' => 'system configuration', 'type' => 'subadmin'), 'create_and_restore_backups' => array('title' => 'Create and Restore Backups', 'group' => 'system configuration', 'type' => 'subadmin'), 'edit_flag_listing_settings' => array('title' => 'Edit Flag Listing Settings', 'group' => 'system configuration', 'type' => 'subadmin'), 'email_log' => array('title' => 'View Email Log', 'group' => 'system configuration', 'type' => 'subadmin'), 'manage_invoices' => array('title' => 'Manage Invoices', 'group' => 'billing', 'type' => 'subadmin'), 'manage_products' => array('title' => 'Manage Products', 'group' => 'billing', 'type' => 'subadmin'), 'manage_promotions' => array('title' => 'Manage Promotions', 'group' => 'billing', 'type' => 'subadmin'), 'manage_tax_rules' => array('title' => 'Manage Tax Rules', 'group' => 'billing', 'type' => 'subadmin'), 'manage_payment_gateways' => array('title' => 'Manage Payment Gateways', 'group' => 'billing', 'type' => 'subadmin'), 'transaction_history' => array('title' => 'View Transaction History', 'group' => 'billing', 'type' => 'subadmin'), 'payment_log' => array('title' => 'View Payment Log', 'group' => 'billing', 'type' => 'subadmin'), 'general_statistics' => array('title' => 'View General Statistics', 'group' => 'reports', 'type' => 'subadmin'), 'listings_reports' => array('title' => 'View Listings Reports', 'group' => 'reports', 'type' => 'subadmin'), 'applications_and_views_reports' => array('title' => 'View Applications and Views Reports', 'group' => 'reports', 'type' => 'subadmin'), 'sales_reports' => array('title' => 'View Sales Reports', 'group' => 'reports', 'type' => 'subadmin'), 'guest_alerts_reports' => array('title' => 'View Guest Alerts Reports', 'group' => 'reports', 'type' => 'subadmin'), 'manage_languages' => array('title' => 'Manage Languages', 'group' => 'languages', 'type' => 'subadmin'), 'translate_phrases' => array('title' => 'Translate Phrases', 'group' => 'languages', 'type' => 'subadmin'), 'import_languages' => array('title' => 'Import Languages', 'group' => 'languages', 'type' => 'subadmin'), 'export_languages' => array('title' => 'Export Languages', 'group' => 'languages', 'type' => 'subadmin')); $resources = array_merge($listingsTypesResources, $resources); $userGroups = SJB_UserGroupManager::getAllUserGroupsInfo(); foreach ($userGroups as $userGroup) { $userGroupId = mb_strtolower($userGroup['id'], 'UTF-8'); $userGroupName = $userGroup['name']; if ($userGroup['name'] == 'Job Seeker' || $userGroup['name'] == 'Employer') { $titleEdition = $userGroup['name'] . 's'; } else { $titleEdition = '\'$permission.groupName\' users'; } $resources['manage_' . $userGroupId] = array('title' => 'Manage ' . $titleEdition, 'groupName' => $userGroupName, 'group' => 'users', 'type' => 'subadmin'); $resources['get_notifications_on_' . $userGroupId . '_registration'] = array('title' => 'Get Notifications on Registration of ' . $titleEdition, 'groupName' => $userGroupName, 'group' => 'users', 'type' => 'subadmin', 'parent' => 'manage_' . $userGroupId, 'notification' => true); $resources['get_notifications_on_' . $userGroupId . '_subscription_expiration'] = array('title' => 'Get Notifications on Products Expiration of ' . $titleEdition, 'groupName' => $userGroupName, 'group' => 'users', 'type' => 'subadmin', 'parent' => 'manage_' . $userGroupId, 'notification' => true); $resources['get_notifications_on_deleting_' . $userGroupId . '_profile'] = array('title' => 'Get Notifications on Profile Deletion of ' . $titleEdition, 'groupName' => $userGroupName, 'group' => 'users', 'type' => 'subadmin', 'parent' => 'manage_' . $userGroupId, 'notification' => true); } return $resources; }
public static function getDetails() { $listing_info = array(); foreach (SJB_UserGroupManager::getAllUserGroupsInfo() as $key => $val) { array_push($listing_info, array('id' => $val['sid'], 'caption' => $val['name'])); } $system_details = array(array('id' => 'fb_appID', 'caption' => 'Facebook App ID', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => -1, 'comment' => 'To get these credentials you need to create an application in <a href="https://developers.facebook.com/" target="_blank">Facebook Developers Console</a>.<br /><br />Follow the <a target="_blank" href="http://wiki.smartjobboard.com/display/sjb42/Facebook#Facebook-GettingFacebookCredentials">User Manual instructions</a> on how to do this.'), array('id' => 'fb_appSecret', 'caption' => 'Facebook App Secret', 'type' => 'string', 'length' => '255', 'is_required' => true, 'is_system' => true, 'order' => -0), array('id' => 'facebook_userGroup', 'caption' => 'User Group', 'type' => 'multilist', 'list_values' => $listing_info, 'is_required' => false, 'is_system' => true, 'order' => 1, 'comment' => 'Please select user groups which will use Facebook connect'), array('id' => 'facebook_resumeAutoFillSync', 'caption' => 'Allow Resume auto filling/synchronizing for Job Seekers', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 1), array('id' => 'fb_likeJob', 'caption' => 'Display “Like” FaceBook icon for Jobs', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 1), array('id' => 'fb_likeResume', 'caption' => 'Display “Like” FaceBook icon for Resumes', 'type' => 'boolean', 'is_required' => false, 'is_system' => true, 'order' => 1)); return $system_details; }
public function addUserGroupProperty($groupID = null) { $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo(); $list_values = array(); foreach ($user_groups_info as $user_group) { $list_values[] = array('id' => $user_group['id'], 'caption' => $user_group['name']); } $this->addProperty(array('id' => 'user_group', 'type' => 'list', 'value' => $groupID, 'is_system' => true, 'list_values' => $list_values)); return array('id' => 'user_group', 'real_id' => 'user_group_sid', 'transform_function' => 'SJB_UserGroupManager::getUserGroupSIDByID'); }
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(); } }
public function execute() { $current_user_info = array('logged_in' => false); if (SJB_UserManager::isUserLoggedIn()) { SJB_Authorization::updateCurrentUserSession(); $current_user_info = SJB_UserManager::createTemplateStructureForCurrentUser(); $current_user_info['logged_in'] = true; $current_user_info['new_messages'] = SJB_PrivateMessage::getCountUnreadMessages($current_user_info['id']); } else { // social plugin $userGroups = SJB_UserGroupManager::getAllUserGroupsInfo(); SJB_System::setCurrentUserGroupsInfo($userGroups); SJB_Event::dispatch('Login_Plugin'); } SJB_System::setCurrentUserInfo($current_user_info); }
public function execute() { set_time_limit(0); ini_set('memory_limit', -1); $tp = SJB_System::getTemplateProcessor(); $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo(); $user_group_info = reset($user_groups_info); $user_group_sid = $user_group_info['sid']; $fields_info = SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($user_group_sid); $fields = array(); $tp->assign('test_message', SJB_Request::getVar('test_message', false)); $tp->assign('undeliveredMailingsForTest', SJB_Request::getVar('undeliveredMailingsForTest', false)); foreach ($fields_info as $key => $val) { if ($val['id'] == 'Location') { foreach ($val['fields'] as $field) { if ($field['id'] == 'Country') { $fields['country'] = SJB_CountriesManager::getAllCountriesCodesAndNames(); } elseif ($field['id'] == 'State') { $fields['state'] = SJB_StatesManager::getStatesNamesByCountry(); } } } } $tp->assign('fields', $fields); $errors = array(); $errorId = SJB_Request::getVar('error', null, 'GET'); if ($errorId) { $errors[$errorId] = 1; } if (isset($_REQUEST['submit']) && $_FILES['file_mail']['name'] && $_FILES['file_mail']['error']) { $errorId = SJB_UploadFileManager::getErrorId($_FILES['file_mail']['error']); if ($_REQUEST['submit'] != 'save') { $mailID = SJB_Request::getVar('mail_id', 0); $parameter = $mailID ? '?edit=' . $mailID : ''; SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/' . $parameter . '&error=' . $errorId); } $errors[$errorId] = 1; } else { if (isset($_REQUEST['submit'])) { SJB_DB::query("DELETE FROM uploaded_files WHERE id = 'file_mail'"); $upload_manager = new SJB_UploadFileManager(); $upload_manager->setFileGroup('files'); $upload_manager->setUploadedFileID('file_mail'); $upload_manager->uploadFile('file_mail'); $file_name = ''; if (!isset($_REQUEST['delete_file']) && isset($_REQUEST['old_file']) && !$upload_manager->getUploadedFileName('file_mail')) { $file_name = $_REQUEST['old_file']; } elseif ($upload_manager->getUploadedFileName('file_mail')) { $file_name = "files/files/" . $upload_manager->getUploadedSavedFileName('file_mail'); } $language = SJB_Request::getVar('language', 'any'); $users = SJB_Request::getVar('users', 'any'); $without_cv = SJB_Request::getVar('without_cv', false); $country = SJB_Request::getVar('country', ''); $state = SJB_Request::getVar('state', ''); $city = SJB_Request::getVar('city', ''); $products = SJB_Request::getVar('products', array()); $user_status = SJB_Request::getVar('user_status', ''); $registration_date = SJB_Request::getVar('registration_date', array()); $param = serialize(array('language' => $language, 'users' => $users, 'without_cv' => $without_cv, 'products' => $products, 'country' => $country, 'state' => $state, 'city' => $city, 'status' => $user_status, 'registration' => $registration_date)); $email = ''; $mailSubject = SJB_Request::getVar('subject', ''); $mailText = stripcslashes(SJB_Request::getVar('text', '')); $mailID = SJB_Request::getVar('mail_id', 0); if ($mailID) { SJB_DB::query('UPDATE `mailing` SET `subject` = ?s, `text` = ?s, `email` = ?s, `file` = ?s, `param` = ?s WHERE `id` = ?s', $mailSubject, $mailText, $email, $file_name, $param, $mailID); } else { $query = "INSERT INTO mailing ( email , subject , text , file, param) VALUES ( ?s, ?s, ?s, ?s, ?s)"; SJB_DB::query($query, $email, $mailSubject, $mailText, $file_name, $param); } if ($_REQUEST['submit'] == 'save') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/'); } else { $parameter = $mailID ? '?edit=' . $mailID : ''; SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/' . $parameter); } } } if (SJB_Request::getVar('delete')) { $mailings = SJB_Request::getVar('mailing'); if (is_array($mailings)) { foreach ($mailings as $id => $value) { SJB_DB::query('DELETE FROM `mailing` WHERE `id` = ?n', $id); SJB_DB::query('DELETE FROM `mailing_info` WHERE `mailing_id` = ?n', $id); } } else { $idToDelete = SJB_Request::getInt('delete', 0); SJB_DB::query('DELETE FROM `mailing` WHERE `id` = ?n', $idToDelete); SJB_DB::query('DELETE FROM `mailing_info` WHERE `mailing_id` = ?n', $idToDelete); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/'); } if (isset($_REQUEST['edit'])) { $idToEdit = SJB_Request::getInt('edit', 0); $mail_arr = SJB_DB::query('SELECT * FROM mailing WHERE id = ?n', $idToEdit); $tp->assign("mail_id", $mail_arr[0]['id']); $tp->assign("subject", $mail_arr[0]['subject']); $tp->assign("text", $mail_arr[0]['text']); $tp->assign("file", $mail_arr[0]['file']); $tp->assign("file_url", $mail_arr[0]['file']); $tp->assign("param", unserialize($mail_arr[0]['param'])); } // get products by UserGroup ID if (SJB_Request::isAjax()) { $userGroupID = SJB_Request::getVar('usergr', 0); if ($userGroupID > 0) { $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($userGroupID); } else { $products = SJB_ProductsManager::getAllProductsInfo(); } $tp->assign("products", $products); $tp->display("mailing_products.tpl"); exit; } $mail_list = SJB_DB::query('SELECT * FROM mailing'); foreach ($mail_list as $key => $var) { $param = unserialize($mail_list[$key]['param']); $where = ''; $join = ''; $numSentEmails = SJB_DB::queryValue('SELECT count(*) FROM `mailing_info` WHERE `mailing_id` = ?n AND `status`=0', $var['id']); if ($param["language"] != 'any') { $where .= " and language='{$param['language']}'"; } if ($param["users"] != '0') { $where .= ' and u.user_group_sid=' . $param['users']; } if ($param["without_cv"]) { $join = "left join listings l on l.user_sid = u.sid"; $where .= " and l.sid is null"; } // user status if (!empty($param['status'])) { $where .= ' and `u`.`active`=' . (int) $param['status']; } // registration date if (!empty($param['registration']) && is_array($param['registration'])) { $i18n = SJB_I18N::getInstance(); if (!empty($param['registration']['not_less'])) { $where .= ' AND `u`.`registration_date` > \'' . $i18n->getInput('date', $param['registration']['not_less']) . '\''; } if (!empty($param['registration']['not_more'])) { $where .= ' AND `u`.`registration_date` < \'' . $i18n->getInput('date', $param['registration']['not_more']) . '\''; } } // products if (!empty($param['products'])) { $join .= "\n LEFT JOIN contracts ON u.sid = contracts.user_sid\n LEFT JOIN products ON products.sid = contracts.product_sid\n "; $whereProduct = array(); foreach ($param['products'] as $theProduct) { $theProduct = (int) $theProduct; if (!empty($theProduct)) { $whereProduct[] .= "products.sid = '{$theProduct}'"; } else { $whereProduct[] .= 'products.sid IS NULL'; } } if (!empty($whereProduct)) { $where .= ' AND (' . implode(' OR ', $whereProduct) . ')'; } } /// products if (!empty($param['country']) || !empty($param['state'])) { if (!empty($param['country'])) { $where_country = array(); foreach ($param['country'] as $the_country) { if (!empty($the_country)) { $where_country[] .= "`u`.`Location_Country` = '{$the_country}'"; } else { $where_country[] .= "`u`.`Location_Country` IS NULL"; } } if (!empty($where_country)) { $where .= ' AND (' . implode(' OR ', $where_country) . ')'; } } if (!empty($param['state'])) { $where_state = array(); foreach ($param['state'] as $the_state) { if (!empty($the_state)) { $where_state[] .= "`u`.`Location_State` = '{$the_state}'"; } else { $where_state[] .= "`u`.`Location_State` IS NULL"; } } } if (!empty($where_state)) { $where .= ' AND (' . implode(' OR ', $where_state) . ')'; } if (!empty($param['city'])) { $where .= " AND `u`.`Location_City` = '{$param['city']}'"; } } $mail_list[$key]['not_send'] = $numSentEmails; $mail_list[$key]['mail_arr'] = SJB_DB::query("\n SELECT u.sid as sid, u.username, u.user_group_sid, u.language\n FROM users u\n {$join}\n WHERE u.sendmail = 0\n {$where}\n GROUP BY `u`.`sid`"); $mail_list[$key]['count'] = count($mail_list[$key]['mail_arr']); } /* * test sending */ $testMailingID = SJB_Request::getVar('test_send', 0); if ($testMailingID) { if ($this->isTestEmailValid()) { $testSendResult = false; $oMailing = new SJB_Mailing($testMailingID); $mailings = SJB_Request::getVar('mailing'); if (is_array($mailings)) { foreach ($mailings as $id => $value) { $oMailing->setMailingID($id); $oMailing->setMailingList($mail_list); if ($oMailing->testSend()) { $testSendResult = true; } } } else { $oMailing->setMailingList($mail_list); $testSendResult = $oMailing->testSend(); } if ($testSendResult) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/?test_message=1'); } else { $email = urlencode(SJB_Request::getString('email', false)); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/mailing/?undeliveredMailingsForTest={$email}"); } } else { $tp->assign('testEmailNotValid', true); } } // general sending $sendToMailingID = SJB_Request::getVar('sending', 0); $sendResult = false; if ($sendToMailingID) { $oMailing = new SJB_Mailing($sendToMailingID); $mailings = SJB_Request::getVar('mailing'); $undeliveredMailingsInfo = array(); if (is_array($mailings)) { foreach ($mailings as $id => $value) { $oMailing->setMailingID($id); $oMailing->setMailingList($mail_list); $countOfSendMailings = $oMailing->send(); if ($countOfSendMailings != 0) { $sendResult = true; } $undeliveredMailingsInfo = array_merge($oMailing->getUndeliveredMailingsInfo(), $undeliveredMailingsInfo); } } else { $oMailing->setMailingList($mail_list); $countOfSendMailings = $oMailing->send(); if ($countOfSendMailings != 0) { $sendResult = true; } $undeliveredMailingsInfo = $oMailing->getUndeliveredMailingsInfo(); } if ($sendResult) { $tp->assign('send_result', $sendResult); } if (count($undeliveredMailingsInfo)) { $tp->assign("UndeliveredMailings", $oMailing->getUndeliveredMailingsInfo()); } } // send mailing to undelivered $sendToUndeliveredMailingID = SJB_Request::getVar('sendToUndeliveredEmails', 0); if (!empty($sendToUndeliveredMailingID)) { $oMailing = new SJB_Mailing($sendToUndeliveredMailingID); $oMailing->setMailingList($mail_list); $oMailing->sendToUndelivered(); if ($oMailing->getUndeliveredMailingsInfo()) { $tp->assign("UndeliveredMailings", $oMailing->getUndeliveredMailingsInfo()); } } $groups = SJB_DB::query("SELECT * FROM `user_groups`"); $products = SJB_ProductsManager::getAllProductsInfo(); $testEmail = SJB_Settings::getSettingByName('test_email'); $tp->assign('test_email', $testEmail); $tp->assign("products", $products); $tp->assign("groups", $groups); $tp->assign("mail_list", $mail_list); $tp->assign('errors', $errors); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display("mailing.tpl"); }
public function execute() { $errors = array(); if (SJB_Request::isAjax()) { $response = null; if ($logoId = SJB_Request::getVar('logo_id')) { SJB_UploadFileManager::deleteUploadedFileByID($logoId, 'logo'); $parsersId = SJB_Request::getVar('id'); SJB_DB::query("UPDATE `parsers` SET `xml_logo` = NULL WHERE id = ?n", $parsersId); } elseif ($userName = SJB_Request::getVar('parser_user')) { $userType = SJB_Request::getVar('user_type'); $products = SJB_XmlImport::getProducts($userType, $userName, $errors); $response = array('products' => empty($products) ? '' : SJB_XmlImport::translateProductsName($products), 'error' => empty($errors) ? '' : array_pop($errors)); $response = json_encode($response); } die($response); } $tp = SJB_System::getTemplateProcessor(); $original_xml = !empty($_REQUEST['xml']) ? $_REQUEST['xml'] : ''; $xml = $original_xml; $tree = ''; $listing_fields = array(); $parsing_name = isset($_REQUEST['parser_name']) ? $_REQUEST['parser_name'] : ''; $usr_name = isset($_REQUEST['parser_user']) ? $_REQUEST['parser_user'] : ''; $pars_url = isset($_REQUEST['parser_url']) ? $_REQUEST['parser_url'] : ''; $form_description = isset($_POST['form_description']) ? $_POST['form_description'] : ""; $type_id = isset($_POST['type_id']) ? intval($_POST['type_id']) : ""; $custom_script = SJB_Request::getVar('custom_script', ''); $custom_script_users = SJB_Request::getVar('custom_script_users', ''); $add_new_user = isset($_POST['add_new_user']) ? intval($_POST['add_new_user']) : 0; $username = SJB_Request::getVar('username', ''); $external_id = SJB_Request::getVar('external_id', ''); $defaultValue = array(); $logo_options_array = array('not_logo' => 'Do Not Import Logo', 'import_logo' => 'Import Logo with Listings', 'upload_logo' => 'Upload Logo for Imported Listings'); $id = isset($_GET['id']) ? intval($_GET['id']) : 0; $selected = array(); $a_selected = array(); $selectedLogoOption = null; $selectedLogoField = null; $xml_logo = null; $selectedProduct = SJB_Request::getVar('postUnderProduct'); $save_error = SJB_Request::getVar('save_error'); if ($save_error) { $errors[] = base64_decode($save_error); } 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']; $custom_script = $parser_from_id['custom_script']; $custom_script_users = $parser_from_id['custom_script_users']; $add_new_user = $parser_from_id['add_new_user']; $importType = $parser_from_id['import_type']; $xml = $parser_from_id['xml']; $xml_logo = $parser_from_id['xml_logo']; $xml = SJB_XmlImport::cleanXmlFromImport($xml); $defaultValue = $parser_from_id['default_value'] != '' ? unserialize($parser_from_id['default_value']) : array(); $username = $parser_from_id['username']; $map = unserialize($parser_from_id['maper']); $external_id = str_replace('@', '_dog_', $parser_from_id['external_id']); $selected_logo_options = unserialize($parser_from_id['logo_options']); $selectedLogoOption = $selected_logo_options['option']; $selectedLogoField = $selected_logo_options['field']; if ($selected_logo_options['option'] == 'upload_logo') { $upload_manager = new SJB_UploadPictureManager(); $upload_manager->getUploadedPictureInfo($xml_logo . '_thumb'); $logo_link = $upload_manager->getUploadedFileLink($xml_logo . '_thumb'); $tp->assign('logo_link', $logo_link); } foreach ($map as $key => $val) { unset($map[$key]); $key = SJB_XmlImport::encodeSpecialEntities($key); $map[$key] = $val; } $selected = array_values($map); $a_selected = array_keys($map); $selectedProduct = $parser_from_id['product_sid']; } else { $xml = SJB_XmlImport::cleanXmlFromImport($_REQUEST['xml']); } $sxml = new simplexml(); $xml = stripslashes($xml); $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]); $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.'; } } else { $errors[] = 'Please input correct xml'; } if (empty($selectedProduct)) { $errors[] = 'Please select a product'; } if (!filter_var($pars_url, FILTER_VALIDATE_URL)) { $errors[] = 'Please input correct URL'; } $error = SJB_Request::getVar('error', false, 'GET'); if ($error) { $errors[$error] = true; } $userType = empty($add_new_user) ? 'username' : 'group'; if ($userType == 'group') { $userName = SJB_UserGroupManager::getUserGroupSIDByID($usr_name); } else { $userName = $usr_name; } $products = SJB_XmlImport::getProducts($userType, $userName, $errors); $tp->assign('id', $id); $tp->assign('selected', $selected); $tp->assign('a_selected', $a_selected); $tp->assign('xml', htmlspecialchars($xml)); $tp->assign('xml_logo', $xml_logo); $tp->assign('xmlToUser', $xml); $tp->assign('default_value', $defaultValue); $tp->assign('form_name', $parsing_name); $tp->assign('form_user', $usr_name); $tp->assign('form_user_sid', $usr_id); $tp->assign('form_url', $pars_url); $tp->assign('form_description', $form_description); $tp->assign('custom_script', $custom_script); $tp->assign('custom_script_users', $custom_script_users); $tp->assign('username', $username); $tp->assign('external_id', $external_id); $tp->assign('import_type', $importType); $tp->assign('user_groups', SJB_UserGroupManager::getAllUserGroupsInfo()); $type_name = SJB_ListingTypeManager::getListingTypeIDBySID($type_id); $tp->assign('add_new_user', $add_new_user); $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('products', $products); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display('add_step_two.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $listing_field_sid = SJB_Request::getVar('sid', null); if (!is_null($listing_field_sid)) { $listingFieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($listing_field_sid); $old_listing_field_id = $listingFieldInfo['id']; $listingFieldInfo = array_merge($listingFieldInfo, $_REQUEST); $listing_field = new SJB_ListingField($listingFieldInfo, $listingFieldInfo['listing_type_sid']); $listing_field->setSID($listing_field_sid); $formSubmitted = SJB_Request::getVar('action', ''); if (!in_array($listing_field->field_type, array('video', 'picture', 'file', 'complex'))) { $profileField = SJB_Request::getVar('profile_field', false); if ($formSubmitted) { if ($profileField) { $listingFieldInfo['default_value'] = ''; } else { $listingFieldInfo['profile_field_as_dv'] = ''; } } $default_value = array('id' => 'default_value', 'sid' => isset($listingFieldInfo['sid']) ? $listingFieldInfo['sid'] : '', 'caption' => 'Default Value', 'value' => isset($listingFieldInfo['default_value']) ? $listingFieldInfo['default_value'] : '', 'type' => $listing_field->field_type, 'length' => '', 'is_required' => false, 'is_system' => true); $additionalParameters = array(); switch ($listing_field->field_type) { case 'list': if (isset($listingFieldInfo['list_values'])) { $additionalParameters = array('list_values' => $listingFieldInfo['list_values']); } break; case 'multilist': if (isset($listingFieldInfo['list_values'])) { $additionalParameters = array('list_values' => $listingFieldInfo['list_values']); } if (!is_array($default_value['value'])) { if (strpos($default_value['value'], ',')) { $default_value['value'] = explode(',', $default_value['value']); } else { $default_value['value'] = array($default_value['value']); } } break; case 'tree': if (isset($listingFieldInfo['tree_values'])) { $additionalParameters = array('tree_values' => $listingFieldInfo['tree_values']); } break; case 'monetary': if (isset($listingFieldInfo['currency_values'])) { $default_value['currency_values'] = $listingFieldInfo['currency_values']; } break; } $default_value = array_merge($default_value, $additionalParameters); $listing_field->addProperty($default_value); $user_groups = SJB_UserGroupManager::getAllUserGroupsInfo(); $list_values = array(); foreach ($user_groups as $user_group) { $list_values = array_merge($list_values, SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($user_group['sid'])); } $profile_field_as_dv = array('id' => 'profile_field_as_dv', 'caption' => 'Default Value', 'value' => isset($listingFieldInfo['profile_field_as_dv']) ? $listingFieldInfo['profile_field_as_dv'] : '', 'type' => 'list', 'list_values' => $list_values, 'length' => '', 'is_required' => false, 'is_system' => true); $listing_field->addProperty($profile_field_as_dv); if (in_array($listing_field->field_type, array('tree', 'multilist', 'list'))) { $sort_by_alphabet = array('id' => 'sort_by_alphabet', 'caption' => 'Sort Values By Alphabet', 'value' => isset($listingFieldInfo['sort_by_alphabet']) ? $listingFieldInfo['sort_by_alphabet'] : '', 'type' => 'boolean', 'lenght' => '', 'is_required' => false, 'is_system' => true); $listing_field->addProperty($sort_by_alphabet); } $tp->assign('profileFieldAsDV', !empty($listingFieldInfo['profile_field_as_dv'])); } if (in_array($listing_field->field_type, array('multilist', 'list'))) { $listing_field->addDisplayAsProperty($listingFieldInfo['display_as']); } // infil instructions should be the last element in form if (!in_array($listing_field->getFieldType(), array('complex', 'tree', 'location')) && 'ApplicationSettings' != $listing_field->getPropertyValue('id')) { if ($formSubmitted) { $listing_field->addInfillInstructions(SJB_Request::getVar('instructions')); } else { $listing_field->addInfillInstructions(isset($listingFieldInfo['instructions']) ? $listingFieldInfo['instructions'] : ''); } } /** * "Display as" options for TREE TYPE */ if ('tree' == $listing_field->getFieldType()) { $listing_field->addProperty(SJB_TreeType::getDisplayAsDetail(isset($listingFieldInfo['display_as_select_boxes']) ? $listingFieldInfo['display_as_select_boxes'] : '')); $treeLevelsNumber = SJB_ListingFieldTreeManager::getTreeDepthBySID($listing_field_sid); $tp->assign('tree_levels_number', $treeLevelsNumber); // treee levels captions for ($i = 1; $i <= $treeLevelsNumber; $i++) { $levelID = 'level_' . $i; $listing_field->addProperty(array('id' => $levelID, 'caption' => $i . ' Level Name', 'value' => isset($listingFieldInfo[$levelID]) ? $listingFieldInfo[$levelID] : '', 'type' => 'string', 'length' => '250', 'is_required' => false, 'is_system' => true)); } } /* * end of ""Display as" options for TREE TYPE" */ $edit_form = new SJB_Form($listing_field); $edit_form->makeDisabled("type"); $errors = array(); if ($formSubmitted && $edit_form->isDataValid($errors)) { SJB_ListingFieldManager::saveListingField($listing_field); SJB_ListingFieldManager::changeListingPropertyIDs($listingFieldInfo['id'], $old_listing_field_id); if ($formSubmitted == 'save_info') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings("SITE_URL") . "/edit-listing-type/?sid=" . $listing_field->getListingTypeSID()); } } $edit_form->registerTags($tp); $tp->assign("form_fields", $edit_form->getFormFieldsInfo()); $tp->assign("errors", $errors); $tp->assign("listing_type_sid", $listing_field->getListingTypeSID()); $tp->assign("field_type", $listing_field->getFieldType()); $tp->assign("field_sid", $listing_field->getSID()); $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_field->getListingTypeSID()); $tp->assign("listing_type_info", $listing_type_info); $tp->assign("listing_field_info", $listingFieldInfo); $tp->display("edit_listing_type_field.tpl"); } }
public static function createTemplateStructureForUserGroups() { $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo(); $structure = array(); foreach ($user_groups_info as $user_group_info) { $structure[$user_group_info['id']] = array('sid' => $user_group_info['sid'], 'id' => $user_group_info['id'], 'caption' => $user_group_info['name'], 'user_number' => SJB_UserManager::getUsersNumberByGroupSID($user_group_info['sid']), 'reg_form_template' => $user_group_info['reg_form_template']); } return $structure; }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $errors = array(); $registration_form_template = 'registration_form.tpl'; if (SJB_Authorization::isUserLoggedIn()) { $tp->display('already_logged_in.tpl'); return; } $tp->assign('terms_of_use_check', SJB_System::getSettingByName('terms_of_use_check')); $user_group_id = SJB_Request::getVar('user_group_id', null); if (!is_null($user_group_id)) { $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id); if (empty($user_group_sid)) { $errors['NO_SUCH_USER_GROUP_IN_THE_SYSTEM'] = 1; } } $this->setSessionValueForRedirectAfterRegister(); if (!is_null($user_group_id) && empty($errors)) { $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid); $user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid); if (SJB_Request::isAjax() || 'true' == SJB_Request::getVar('isajaxrequest')) { $field = SJB_Request::getVar('type'); if ('email' == $field) { $user->getProperty($field)->type->disableEmailConfirmation(); } echo $user->getProperty($field)->isValid(); exit; } $user->deleteProperty('active'); $user->deleteProperty('featured'); $form_submitted = SJB_Request::getVar('action', false) == 'register'; if (class_exists('MobilePlugin') && MobilePlugin::isMobileThemeOn()) { $user->prepareRegistrationFields(); } $registration_form = SJB_ObjectMother::createForm($user); $registration_form->registerTags($tp); if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) { $email = $user->getPropertyValue('email'); if (is_array($email)) { $email = $email['original']; } $user->setPropertyValue('username', $email); } if ($form_submitted && $registration_form->isDataValid($errors)) { $user->deleteProperty('captcha'); $defaultProduct = SJB_UserGroupManager::getDefaultProduct($user_group_sid); SJB_UserManager::saveUser($user); SJB_Statistics::addStatistics('addUser', $user->getUserGroupSID(), $user->getSID()); $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($user_group_sid); if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) { $contract = new SJB_Contract(array('product_sid' => $defaultProduct)); $contract->setUserSID($user->getSID()); $contract->saveInDB(); } // >>> SJB-1197 // needs to check session for ajax-uploaded files, and set it to user profile $formToken = SJB_Request::getVar('form_token'); $tmpUploadsStorage = SJB_Session::getValue('tmp_uploads_storage'); 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}"); } // save user with new values SJB_UserManager::saveUser($user); // clean temporary storage $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}"); // CLEAR TEMPORARY SESSION STORAGE SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage); } } // <<< SJB-1197 // notifying administrator SJB_AdminNotifications::sendAdminUserRegistrationLetter($user); // Activation $isSendActivationEmail = SJB_UserGroupManager::isSendActivationEmail($user_group_sid); $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid); if ($isApproveByAdmin) { SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending'); } if ($isSendActivationEmail) { $fromAnonymousShoppingCart = SJB_Session::getValue('fromAnonymousShoppingCart'); SJB_Session::unsetValue('fromAnonymousShoppingCart'); $isSent = SJB_Notifications::sendUserActivationLetter($user->getSID(), $fromAnonymousShoppingCart ? true : false); if ($isSent) { $registration_form_template = 'registration_confirm.tpl'; } else { SJB_FlashMessages::getInstance()->addWarning('ERROR_SEND_ACTIVATION_EMAIL'); $registration_form_template = 'registration_failed_to_send_activation_email.tpl'; } } else { if (!$isSendActivationEmail && $isApproveByAdmin) { SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending'); $registration_form_template = 'registration_pending.tpl'; } else { SJB_UserManager::activateUserByUserName($user->getUserName()); if (!SJB_SocialPlugin::getProfileSocialID($user->getSID())) { SJB_Notifications::sendUserWelcomeLetter($user->getSID()); } SJB_Authorization::login($user->getUserName(), $_REQUEST['password']['original'], false, $errors); $proceedToPosting = SJB_Session::getValue('proceed_to_posting'); if ($proceedToPosting) { $redirectUrl = SJB_HelperFunctions::getSiteUrl() . '/add-listing/?listing_type_id=' . SJB_Session::getValue('listing_type_id') . '&proceed_to_posting=' . $proceedToPosting . '&productSID=' . SJB_Session::getValue('productSID'); } else { $pageId = !empty($user_group_info['after_registration_redirect_to']) ? $user_group_info['after_registration_redirect_to'] : ''; $redirectUrl = SJB_UserGroupManager::getRedirectUrlByPageID($pageId); } SJB_HelperFunctions::redirect($redirectUrl); } } } else { if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) { $user->deleteProperty('username'); } $registration_form = SJB_ObjectMother::createForm($user); $registration_form->registerTags($tp); $registration_form_template = 'registration_form.tpl'; if (isset($_REQUEST['reg_form_template'])) { $registration_form_template = $_REQUEST['reg_form_template']; } elseif (!empty($user_group_info['reg_form_template'])) { $registration_form_template = $user_group_info['reg_form_template']; } $form_fields = $registration_form->getFormFieldsInfo(); // define default template with ajax checking $registration_form->setDefaultTemplateByFieldName('email', 'email_ajaxchecking.tpl'); $registration_form->setDefaultTemplateByFieldName('username', 'unique_string.tpl'); // use specific template for user profile video $registration_form->setDefaultTemplateByFieldName('video', 'video_profile.tpl'); $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid); $tp->assign('user_group_info', $user_group_info); $tp->assign('errors', $errors); $tp->assign('form_fields', $form_fields); $metaDataProvider = SJB_ObjectMother::getMetaDataProvider(); $tp->assign('METADATA', array('form_fields' => $metaDataProvider->getFormFieldsMetadata($form_fields))); } } else { $registration_form_template = 'registration_choose_user_group.tpl'; $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo(); $tp->assign('user_groups_info', $user_groups_info); } $tp->assign('userTree', true); $tp->assign('errors', $errors); $tp->display($registration_form_template); }
public static function preparePluginsThatAreAvailableForRegistration(&$aAvailablePlugins, $userGroupID = null) { $aAvailableUserGroups = SJB_UserGroupManager::getAllUserGroupsInfo(); foreach ($aAvailablePlugins as $socialKey => $socNetwork) { $aAvailableUserGroupsTemp = $aAvailableUserGroups; $aResolvedUserGroups = self::getResolvedUserGroupsByNetwork($socNetwork); if (empty($aResolvedUserGroups)) { unset($aAvailablePlugins[$socialKey]); continue; } foreach ($aAvailableUserGroupsTemp as $key => $aUserGroupInfo) { if (!in_array($aUserGroupInfo['sid'], $aResolvedUserGroups) || $userGroupID && $userGroupID !== $aUserGroupInfo['id']) { unset($aAvailableUserGroupsTemp[$key]); } } if (empty($aAvailableUserGroupsTemp)) { unset($aAvailablePlugins[$socialKey]); } } }
public function execute() { ini_set('max_execution_time', 0); $template_processor = SJB_System::getTemplateProcessor(); $errors = array(); $encodingFromCharset = SJB_Request::getVar('encodingFromCharset', 'UTF-8'); $file_info = isset($_FILES['import_file']) ? $_FILES['import_file'] : null; if (!empty($file_info)) { $extension = $_REQUEST['file_type']; if (!SJB_ImportFile::isValidFileExtensionByFormat($extension, $file_info)) { $errors['DO_NOT_MATCH_SELECTED_FILE_FORMAT'] = true; } } if (empty($file_info) || $file_info['error'] || !empty($errors)) { if (isset($file_info['error']) && $file_info['error'] > 0) { $errors[SJB_UploadFileManager::getErrorId($file_info['error'])] = 1; } $user_groups = SJB_UserGroupManager::getAllUserGroupsInfo(); $template_processor->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $template_processor->assign('user_groups', $user_groups); $template_processor->assign('errors', $errors); $template_processor->assign('charSets', SJB_HelperFunctions::getCharSets()); $template_processor->display('import_users.tpl'); } else { $csv_delimiter = SJB_Request::getVar('csv_delimiter', null); $user_group_id = SJB_Request::getVar('user_group_id', null); $user_group_sid = SJB_UserGroupManager::getUserGroupSIDByID($user_group_id); 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); $user = $this->CreateUser(array(), $user_group_id); $imported_data = $import_file->getData(); $count = 0; $import_file_url = false; $usersID = array(); foreach ($imported_data as $key => $importedColumn) { if ($key == 1) { $imported_user_processor = new SJB_ImportedUserProcessor($importedColumn, $user); continue; } if (!$importedColumn) { continue; } $userInfo = $imported_user_processor->getData($importedColumn); $extUserID = isset($userInfo['extUserID']) ? $userInfo['extUserID'] : ''; $user = $this->CreateUser(array(), $user_group_id); $user->addExtUserIDProperty(); $doc = new DOMDocument(); foreach ($user->getProperties() as $property) { if ($property->id == 'active') { $property->type->property_info['value'] = $property->value; } elseif ($property->getType() == 'location') { $locationFields = array($property->id . '.Country', $property->id . '.State', $property->id . '.City', $property->id . '.ZipCode', $property->id . '.Address'); $locationFieldAdded = array(); foreach ($locationFields as $locationField) { if (array_key_exists($locationField, $userInfo)) { switch ($locationField) { case $property->id . '.Country': $value = SJB_CountriesManager::getCountrySIDByCountryName($userInfo[$locationField]); if (!$value) { $value = SJB_CountriesManager::getCountrySIDByCountryCode($userInfo[$locationField]); } break; case $property->id . '.State': $value = SJB_StatesManager::getStateSIDByStateName($userInfo[$locationField]); if (!$value) { $value = SJB_StatesManager::getStateSIDByStateCode($userInfo[$locationField]); } break; default: $value = $userInfo[$locationField]; break; } unset($userInfo[$locationField]); $userInfo[$property->id][str_replace($property->id . '.', '', $locationField)] = $value; $locationFieldAdded[] = str_replace($property->id . '.', '', $locationField); } } if ($property->id == 'Location') { $locationFields = array('Country', 'State', 'City', 'ZipCode', 'Address'); foreach ($locationFields as $locationField) { if (array_key_exists($locationField, $userInfo) && !in_array($locationField, $locationFieldAdded) && !$user->getProperty($locationField)) { switch ($locationField) { case 'Country': $value = SJB_CountriesManager::getCountrySIDByCountryName($userInfo[$locationField]); if (!$value) { $value = SJB_CountriesManager::getCountrySIDByCountryCode($userInfo[$locationField]); } break; case 'State': $value = SJB_StatesManager::getStateSIDByStateName($userInfo[$locationField]); if (!$value) { $value = SJB_StatesManager::getStateSIDByStateCode($userInfo[$locationField]); } break; default: $value = $userInfo[$locationField]; break; } $userInfo[$property->id][$locationField] = $value; unset($userInfo[$locationField]); } } } } } $user = $this->CreateUser($userInfo, $user_group_id); $user->addExtUserIDProperty($extUserID); $username = SJB_Array::get($userInfo, 'username'); if (empty($username)) { $errors[] = 'Empty username is not allowed, record ignored.'; } elseif (!is_null(SJB_UserManager::getUserSIDbyUsername($username))) { $errors[] = '\'' . $userInfo['username'] . '\' - this user name already exists, record ignored.'; } else { $originalMd5Password = $user->getPropertyValue('password'); SJB_UserManager::saveUser($user); $this->extraProperties($user, $userInfo, $usersID); if (!empty($originalMd5Password)) { SJB_UserManager::saveUserPassword($user->getSID(), $originalMd5Password); } $isApproveByAdmin = SJB_UserGroupManager::isApproveByAdmin($user_group_sid); if ($isApproveByAdmin) { SJB_UserManager::setApprovalStatusByUserName($user->getUserName(), 'Pending'); } $count++; } } if ($import_file_url) { SJB_Filesystem::delete(SJB_System::getSystemSettings("IMPORT_FILES_DIRECTORY")); } $template_processor->assign('imported_users_count', $count); $template_processor->assign('errors', $errors); $template_processor->display('import_users_result.tpl'); } }
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; } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $extUserID = SJB_Request::getVar('extUserID', null); $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $userGroupID = $passedParametersViaUri ? array_shift($passedParametersViaUri) : false; if (!$userGroupID) { $userGroupsInfo = SJB_UserGroupManager::getAllUserGroupsInfo(); $tp->assign('user_groups_info', $userGroupsInfo); $tp->display('add_user_choose_user_group.tpl'); } else { $userGroupSID = SJB_UserGroupManager::getUserGroupSIDByID($userGroupID); $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($userGroupSID); $user = SJB_ObjectMother::createUser($_REQUEST, $userGroupSID); $user->deleteProperty('active'); $user->addExtUserIDProperty($extUserID); $registration_form = SJB_ObjectMother::createForm($user); $registration_form->registerTags($tp); $form_submitted = SJB_Request::getVar('action', '') == 'add'; $errors = array(); if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($userGroupSID) && $form_submitted) { $email = $user->getPropertyValue('email'); if (is_array($email)) { $email = $email['original']; } $user->setPropertyValue('username', $email); } if ($form_submitted && $registration_form->isDataValid($errors)) { 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); // clean temporary storage $tmpUploadsStorage = SJB_Array::unsetValueByPath($tmpUploadsStorage, "{$formToken}"); // CLEAR TEMPORARY SESSION STORAGE SJB_Session::setValue('tmp_uploads_storage', $tmpUploadsStorage); } } // <<< SJB-1197 SJB_UserManager::activateUserByUserName($user->getUserName()); $defaultProduct = SJB_UserGroupManager::getDefaultProduct($userGroupSID); $availableProductIDs = SJB_ProductsManager::getProductsIDsByUserGroupSID($userGroupSID); if ($defaultProduct && in_array($defaultProduct, $availableProductIDs)) { $contract = new SJB_Contract(array('product_sid' => $defaultProduct)); $contract->setUserSID($user->getSID()); $contract->saveInDB(); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/manage-users/" . mb_strtolower($userGroupInfo['id'], 'utf8')); } else { if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($userGroupSID)) { $user->deleteProperty('username'); } $registration_form = SJB_ObjectMother::createForm($user); $registration_form->registerTags($tp); $tp->assign("errors", $errors); $tp->assign("user_group", $userGroupInfo); $tp->assign('userTree', true); $tp->assign("form_fields", $registration_form->getFormFieldsInfo()); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display("add_user.tpl"); } } }