public function execute() { $tp = SJB_System::getTemplateProcessor(); $bannersObj = new SJB_Banners(); $action = SJB_Request::getVar('action'); if (isset($action)) { $groupID = SJB_Request::getVar('groupID'); switch ($action) { case 'add': if ($groupID == '') { SJB_FlashMessages::getInstance()->addWarning('EMPTY_VALUE', array('fieldCaption' => 'Group ID')); break; } $result = $bannersObj->addBannerGroup($groupID); if ($result === false) { SJB_FlashMessages::getInstance()->addWarning('ERROR_ADD_BANNER_GROUP'); break; } $site_url = SJB_System::getSystemsettings('SITE_URL') . "/manage-banner-groups/"; header("Location: {$site_url}"); break; } } $tp->display("add_banner_group.tpl"); }
public function execute() { $templateProcessor = SJB_System::getTemplateProcessor(); $errors = array(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $gateway_id = isset($_REQUEST['gateway']) ? $_REQUEST['gateway'] : null; $formSubmitted = SJB_Request::getVar('submit'); $gateway_sid = SJB_PaymentGatewayManager::getSIDByID($gateway_id); if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($action)) { if ($action == 'deactivate') { SJB_PaymentGatewayManager::deactivateByID($gateway_id); } elseif ($action == 'activate') { SJB_PaymentGatewayManager::activateByID($gateway_id); } } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $gateway = SJB_PaymentGatewayManager::createObjectByID($gateway_id, $_REQUEST); $gateway->dontSaveProperty('id'); $gateway->dontSaveProperty('caption'); $gateway->setSID($gateway_sid); if ($gateway->isValid()) { if (SJB_PaymentGatewayManager::saveGateway($gateway) !== false) { $templateProcessor->assign('gatewaySaved', true); if ($formSubmitted == 'save_gateway') { $siteUrl = SJB_System::getSystemsettings('SITE_URL') . '/system/payment/gateways/?gatewaySaved=1'; SJB_HelperFunctions::redirect($siteUrl); } } else { $errors['SETTINGS_SAVED_WITH_PROBLEMS'] = 1; } } else { $errors = $gateway->getErrors(); } } $gateway = SJB_PaymentGatewayManager::getObjectByID($gateway_id); $gateway_form = new SJB_Form($gateway); $gateway_form->registerTags($templateProcessor); $gateway_form->makeDisabled('id'); $gateway_form->makeDisabled('caption'); $countryCode = $gateway->getPropertyValue('country'); if (empty($countryCode)) { $countryValue = SJB_CountriesManager::getCountrySIDByCountryCode('US'); $gateway->setPropertyValue('country', $countryValue); } if (empty($gateway)) { $errors['GATEWAY_NOT_FOUND'] = 1; $templateProcessor->assign('errors', $errors); $templateProcessor->display('configure_gateway.tpl'); return; } $gateway_info = SJB_PaymentGatewayManager::getInfoBySID($gateway_sid); $form_fields = $gateway_form->getFormFieldsInfo(); $templateProcessor->assign('gateway', $gateway_info); $templateProcessor->assign('form_fields', $form_fields); $templateProcessor->assign('errors', $errors); $templateProcessor->display('configure_gateway.tpl'); }
public function execute() { $templateProcessor = SJB_System::getTemplateProcessor(); $listingSid = isset($_REQUEST['listing_id']) ? $_REQUEST['listing_id'] : null; $listing = SJB_ListingManager::getObjectBySID($listingSid); if (!is_null($listing) && !$listing->isActive()) { $listingInfo = SJB_ListingManager::getListingInfoBySID($listingSid); $productInfo = !empty($listingInfo['product_info']) ? unserialize($listingInfo['product_info']) : array(); if (isset($listingInfo['complete']) && $listingInfo['complete'] == 1 && $listingInfo['checkouted'] == 1) { $subTotalPrice = 0; // проверить истек ли листинг, если истек , прайс прировнять к renewal_price if (SJB_ListingManager::getIfListingHasExpiredBySID($listing->getID()) && isset($productInfo['renewal_price'])) { $subTotalPrice = $productInfo['renewal_price']; } $userSid = $listing->getUserSID(); $productSid = $productInfo['product_sid']; $listingTitle = $listing->getProperty('Title')->getValue(); $listingTypeSid = $listing->getListingTypeSID(); $listingTypeId = SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSid); $newProductName = "Reactivation of \"{$listingTitle}\" {$listingTypeId}"; $newProductInfo = SJB_ShoppingCart::createInfoForCustomProduct($userSid, $productSid, $listingSid, $subTotalPrice, $newProductName, 'activateListing'); if ($subTotalPrice <= 0) { if (SJB_ListingManager::activateListingBySID($listing->getSID())) { SJB_Notifications::sendUserListingActivatedLetter($listing, $listing->getUserSID()); } } else { SJB_ShoppingCart::createCustomProduct($newProductInfo, $userSid); $shoppingUrl = SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/'; SJB_HelperFunctions::redirect($shoppingUrl); } $templateProcessor->assign('listingTypeID', SJB_ListingTypeManager::getListingTypeIDBySID($listingTypeSid)); } elseif ($listingInfo['checkouted'] == 0) { $productsInfoFromShopppingCart = SJB_ShoppingCart::getProductsInfoFromCartByProductSID($productInfo['product_sid'], $listing->getUserSID()); if (empty($productsInfoFromShopppingCart)) { $productInfoToShopCart = SJB_ProductsManager::getProductInfoBySID($productInfo['product_sid']); $productInfo['number_of_listings'] = 1; $productObj = new SJB_Product($productInfoToShopCart, $productInfoToShopCart['product_type']); $productObj->setNumberOfListings($productInfoToShopCart['number_of_listings']); $productInfoToShopCart['price'] = $productObj->getPrice(); SJB_ShoppingCart::addToShoppingCart($productInfoToShopCart, $listing->getUserSID()); } SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/'); } else { $errors['LISTING_IS_NOT_COMPLETE'] = 1; } } elseif (is_null($listingSid)) { $errors['INVALID_LISTING_ID'] = 1; } elseif (!is_null($listing) && $listing->isActive()) { $errors['LISTING_ALREADY_ACTIVE'] = 1; } else { $errors['WRONG_LISTING_ID_SPECIFIED'] = 1; } $templateProcessor->assign("errors", isset($errors) ? $errors : null); $templateProcessor->display("pay_for_listing.tpl"); }
/** * Get site URL * * @return string */ public static function getSiteUrl() { $siteUrl = SJB_System::getSystemSettings('USER_SITE_URL'); if (!empty($siteUrl)) { return $siteUrl; } $siteUrl = SJB_System::getSystemsettings('SITE_URL'); $siteUrl = str_replace('/admin/', '', $siteUrl); $siteUrl = str_replace('/admin', '', $siteUrl); return $siteUrl; }
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() { $bannersObj = new SJB_Banners(); $errors = array(); $tp = SJB_System::getTemplateProcessor(); if (isset($_REQUEST['action'])) { $action_name = $_REQUEST['action']; $params = $_REQUEST; switch ($action_name) { case 'delete_banner_group': $result = $bannersObj->deleteBannerGroup($params['groupSID']); if ($result === false) { $errors[] = 'ERROR_DELETING_BANNER_GROUP'; } break; } $site_url = SJB_System::getSystemsettings('SITE_URL') . '/manage-banner-groups/'; header("Location: {$site_url}"); } $bannerGroups = $bannersObj->getAllBannerGroups(); $tp->assign('errors', $errors); $tp->assign('bannerGroups', $bannerGroups); $tp->display('manage_banner_groups.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $bannersObj = new SJB_Banners(); $errors = array(); $groupSID = SJB_Request::getVar('groupSID', false); $form_submitted = SJB_Request::getVar('submit'); if (isset($_REQUEST['action'])) { $action_name = $_REQUEST['action']; $params = $_REQUEST; switch ($action_name) { case 'edit': if ($params['groupID'] == '') { $errors[] = 'GROUP_ID_MISMATCHED'; } if ($groupSID === false) { $errors[] = 'BANNER_GROUP_SID_NOT_DEFINED'; } if ($errors) { break; } $result = $bannersObj->updateBannerGroup($params['groupSID'], $params['groupID'], $params['number_banners_display_at_once']); if ($result === false) { $errors[] = 'ERROR_UPDATE_BANNER_GROUP'; break; } if ($form_submitted == 'save_banner') { $site_url = SJB_System::getSystemsettings('SITE_URL') . '/manage-banner-groups/'; SJB_HelperFunctions::redirect($site_url); } break; case 'delete_banner': if (!isset($params['bannerId'])) { $banners_sids = SJB_Request::getVar('banners', false); if (count($banners_sids) > 0) { $keys = array_keys($banners_sids); $groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]); foreach ($banners_sids as $b_sid => $keys) { $deleteBanner = $bannersObj->deleteBanner($b_sid); if ($deleteBanner === false) { $errors[] = $bannersObj->bannersError; } } } } else { $groupSID = $bannersObj->getBannerGroupSIDByBannerSID($params['bannerId']); $deleteBanner = $bannersObj->deleteBanner($params['bannerId']); if ($deleteBanner === false) { $errors[] = $bannersObj->bannersError; break; } } $site_url = SJB_System::getSystemsettings('SITE_URL') . '/edit-banner-group/?groupSID=' . $groupSID; SJB_HelperFunctions::redirect($site_url); break; case 'activate': $banners_sids = SJB_Request::getVar('banners', false); if ($banners_sids) { $keys = array_keys($banners_sids); $groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]); foreach ($banners_sids as $b_sid => $keys) { $deleteBanner = $bannersObj->updateActiveStatus($b_sid, true); if ($deleteBanner === false) { $errors[] = 'Can\'t activate banner. ID: ' . $b_sid; } } } break; case 'deactivate': $banners_sids = SJB_Request::getVar('banners', false); if ($banners_sids) { $keys = array_keys($banners_sids); $groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]); foreach ($banners_sids as $b_sid => $keys) { $deleteBanner = $bannersObj->updateActiveStatus($b_sid, false); if ($deleteBanner === false) { $errors[] = 'Can\'t deactivate banner. ID: ' . $b_sid; } } } break; case 'approve': $banners_sids = SJB_Request::getVar('banners', false); if ($banners_sids) { $keys = array_keys($banners_sids); $groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]); foreach ($banners_sids as $b_sid => $keys) { $bannerInfo = $bannersObj->getBannerProperties($b_sid); $contractSID = !empty($bannerInfo['contract_sid']) ? $bannerInfo['contract_sid'] : false; $approveBanner = $bannersObj->updateStatus($b_sid, 'approved'); if ($approveBanner === false) { $errors[] = 'Can\'t approved banner. ID: ' . $b_sid; } else { $bannersObj->updateActiveStatus($b_sid, true); if ($contractSID) { SJB_ContractManager::updateExpirationPeriod($contractSID); } } } } break; case 'reject': $banners_sids = SJB_Request::getVar('banners', false); if ($banners_sids) { $keys = array_keys($banners_sids); $groupSID = $bannersObj->getBannerGroupSIDByBannerSID($keys[0]); $reject = SJB_Request::getVar('rejection_reason', ''); foreach ($banners_sids as $b_sid => $keys) { $approveBanner = $bannersObj->updateStatus($b_sid, 'rejected'); if ($approveBanner === false) { $errors[] = 'Can\'t rejected banner. ID: ' . $b_sid; } else { $bannersObj->updateActiveStatus($b_sid, false); if ($bannersObj->getBannerUserSID($b_sid)) { $bannerInfo = $bannersObj->getBannerProperties($b_sid); SJB_Notifications::sendBannerRejectedLetter($bannerInfo, $bannersObj->getBannerUserSID($b_sid), $reject); } } } } break; } } $bannerGroup = $bannersObj->getBannerGroupBySID($groupSID); $banners = $bannersObj->getBannersByGroupSID($groupSID); $tp->assign('form_submitted', $form_submitted); $tp->assign('bannerGroup', $bannerGroup); $tp->assign('errors', $errors); $tp->display('edit_banner_group.tpl'); $tp->assign('banners', $banners); $tp->assign('bannersPath', SJB_Banners::getSiteUrl()); $tp->display('manage_banners.tpl'); }
public function execute() { $bannersObj = new SJB_Banners(); $params = $_REQUEST; $bannerId = $params['bannerId']; if (SJB_Request::isAjax()) { $response = array('success' => $bannersObj->deleteBannerImage($bannerId), 'error' => SJB_I18N::getInstance()->gettext('Backend', $bannersObj->bannersError)); die(json_encode($response)); } $tp = SJB_System::getTemplateProcessor(); $errors = array(); $banner = array_merge($bannersObj->getBannerProperties($bannerId), $params); $form_submitted = SJB_Request::getVar('submit'); $filesDir = SJB_System::getSystemSettings('FILES_DIR'); if (isset($_REQUEST['action'])) { $action_name = $_REQUEST['action']; switch ($action_name) { case 'edit': // ERRORS if ($params['title'] == '') { $errors[] = 'Banner Title is empty.'; } if ($params['link'] == '' && $params['bannerType'] != 'code') { $errors[] = 'Banner link mismatched!'; } if ($params['bannerType'] == 'code' && $params['code'] == '') { $errors[] = 'Banner code is empty.'; } if ($params['bannerType'] == 'file' && $_FILES['image']['name'] == '' && empty($params['imagePath'])) { $errors[] = 'No image attached!'; } if ($_FILES['image']['name'] && $_FILES['image']['error']) { $errors[SJB_UploadFileManager::getErrorId($_FILES['image']['error'])] = 1; } if ($errors) { break; } // if image changed - save it if ($_FILES['image']['name'] != '' && $_FILES['image']['tmp_name'] != '') { $hashName = md5(time() * $_FILES['image']['size'] . "_" . $_FILES['image']['name']); $ext = preg_match("|\\.(\\w{3})\\b|", $_FILES['image']['name'], $arr); $bannerFilePath = $filesDir . "banners/" . $hashName . "." . $arr[1]; // move file from temporary folder, and fill banner info to DB $copy = copy($_FILES['image']['tmp_name'], $bannerFilePath); if (!$copy) { $errors = 'Cannot copy file from TMP dir to Banners Dir'; break; } if ($_FILES['image']['type'] != 'application/x-shockwave-flash') { // array of bannerInfo // [0] - width // [1] - height // [2] - ?? // [3] - width & height in next view: width="104" height="150" // [bits] - bit size of image // [channels] // [mime] - type, (image/jpeg, image/gif, image/png ) $bannerInfo = getimagesize($bannerFilePath); if ($params['width'] != '' && $params['height'] != '') { $sx = $params['width']; $sy = $params['height']; } else { $sx = $bannerInfo[0]; $sy = $bannerInfo[1]; } $type = $bannerInfo['mime']; } else { if ($params['width'] == '' || $params['height'] == '') { $errors[] = 'SIZE_PARAMETER_MISMATCHED'; break; } $sx = $params['width']; $sy = $params['height']; $type = $_FILES['image']['type']; } $bannerFilePath = "/" . str_replace("../", "/", str_replace(SJB_BASE_DIR, '', $bannerFilePath)); // now delete old banner image $bannersObj->deleteBannerImage($bannerId); } else { // if image not changed - leave it as is $bannerOldInfo = $bannersObj->getBannerProperties($params['bannerId']); $sx = $bannerOldInfo['width']; $sy = $bannerOldInfo['height']; if ($params['width'] != '' && $params['height'] != '') { if ($params['width'] != $sx || $params['height'] != $sy) { $sx = $params['width']; $sy = $params['height']; } } $type = $bannerOldInfo['type']; $bannerFilePath = $bannerOldInfo['image_path']; } $title = $params['title']; $link = $params['link']; $active = $params['active']; $group = $params['groupSID']; // check 'link' for correct. If it hasn't 'http://' or 'https://' - add them $expr = preg_match("/^(https?:\\/\\/)/", $link); if ($expr != true && $params['bannerType'] != 'code') { $link = "http://" . $link; } if ($params['bannerType'] == 'code') { $bannersObj->deleteBannerImage($bannerId); } $result = $bannersObj->updateBanner($params['bannerId'], $title, $link, $bannerFilePath, $sx, $sy, $type, $active, $group, $params); if ($form_submitted == 'save_banner') { $site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner-group/?groupSID={$group}"; } else { $site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner/?bannerId=" . $bannerId; } SJB_HelperFunctions::redirect($site_url); break; } } $banner_fields = $bannersObj->getBannersMeta(); $tp->assign("banner_fields", $banner_fields); $tp->assign("banner", $banner); $tp->assign('errors', $errors); $tp->assign('bannersPath', SJB_Banners::getSiteUrl()); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display("edit_banner.tpl"); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $current_user = SJB_UserManager::getCurrentUser(); $action = SJB_Request::getVar('action', 'productList'); $productSID = SJB_Request::getVar('product_sid', 0, 'default', 'int'); $template = 'products.tpl'; $availableProducts = array(); $errors = array(); switch ($action) { case 'productList': if (SJB_UserManager::isUserLoggedIn()) { $postingProductsOnly = SJB_Request::getVar('postingProductsOnly', false); $availableProducts = SJB_ProductsManager::getProductsByUserGroupSID($current_user->getUserGroupSID(), $current_user->getSID()); $trialProduncts = $current_user->getTrialProductSIDByUserSID(); foreach ($availableProducts as $key => $availableProduct) { if (in_array($availableProduct['sid'], $trialProduncts) || $postingProductsOnly && $availableProduct['product_type'] != "post_listings" && $availableProduct['product_type'] != "mixed_product") { unset($availableProducts[$key]); } } if ($postingProductsOnly) { $tp->assign('postingProductsOnly', $postingProductsOnly); } } elseif ($userGroupID = SJB_Request::getVar('userGroupID', false)) { $userGroupSID = SJB_UserGroupManager::getUserGroupSIDByID($userGroupID); $availableProducts = SJB_ProductsManager::getProductsByUserGroupSID($userGroupSID, 0); } else { $availableProducts = SJB_ProductsManager::getAllActiveProducts(); } foreach ($availableProducts as $key => $availableProductInfo) { if (SJB_ProductsManager::isProductTrialAndAlreadyInCart($availableProductInfo, $current_user)) { unset($availableProducts[$key]); continue; } $availableProduct = new SJB_Product($availableProductInfo, $availableProductInfo['product_type']); $availableProduct->setNumberOfListings(1); $availableProducts[$key]['price'] = $availableProduct->getPrice(); if (isset($availableProducts[$key]['listing_type_sid'])) { $availableProducts[$key]['listing_type_id'] = SJB_ListingTypeDBManager::getListingTypeIDBySID($availableProducts[$key]['listing_type_sid']); } } SJB_Event::dispatch('RedefineTemplateName', $template, true); SJB_Event::dispatch('RedefineProductsDisplayInfo', $availableProducts, true); $tp->assign("account_activated", SJB_Request::getVar('account_activated', '')); $tp->assign("availableProducts", $availableProducts); break; case 'view_product_detail': $template = 'view_product_detail.tpl'; if (!SJB_UserManager::isUserLoggedIn() || $current_user->mayChooseProduct($productSID, $errors)) { $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (in_array($productInfo['product_type'], array('post_listings', 'mixed_product'))) { $productInfo['listingTypeID'] = SJB_ListingTypeManager::getListingTypeIDBySID($productInfo['listing_type_sid']); } $event = SJB_Request::getVar('event', false); if ($event) { if ($productInfo) { switch ($productInfo['product_type']) { case 'banners': $params = $_REQUEST; if (empty($params['title'])) { $errors[] = "Banner Title is empty."; } if (empty($params['link'])) { $errors[] = "Banner link mismatched!"; } if (empty($_FILES['image']['name'])) { $errors[] = "No file attached!"; } elseif ($_FILES['image']['error']) { switch ($_FILES['image']['error']) { case '1': $errors[] = 'UPLOAD_ERR_INI_SIZE'; break; case '2': $errors[] = 'UPLOAD_ERR_FORM_SIZE'; break; case '3': $errors[] = 'UPLOAD_ERR_PARTIAL'; break; case '4': $errors[] = 'UPLOAD_ERR_NO_FILE'; break; default: $errors[] = 'NOT_UPLOAD_FILE'; break; } } else { $imageInfo = @getimagesize($_FILES['image']['tmp_name']); if (!$imageInfo || $imageInfo['2'] < 1 && $imageInfo['2'] > 3) { $errors[] = 'Image format is not supported'; } elseif (!empty($productInfo['width']) && $imageInfo[0] != $productInfo['width']) { $errors[] = "Your banner dimensions exceed the required size. Please upload an appropriate banner."; } elseif (!empty($productInfo['height']) && $imageInfo[1] != $productInfo['height']) { $errors[] = "Your banner dimensions exceed the required size. Please upload an appropriate banner."; } } if ($errors) { break; } //add banner $title = $params['title']; $link = $params['link']; $expr = preg_match("/(http:\\/\\/)/", $link, $matches); if ($expr != true) { $link = "http://" . $link; } $filesDir = SJB_System::getSystemSettings('FILES_DIR'); $ext = preg_match("|\\.(\\w{3})\\b|u", $_FILES['image']['name'], $arr); $fileName = preg_replace("|\\.(\\w{3})\\b|u", "", $_FILES['image']['name']); $hashName = md5(time() * $_FILES['image']['size']) . "_" . $fileName; $bannerFilePath = $filesDir . "banners/" . $hashName . "." . $arr[1]; $copy = move_uploaded_file($_FILES['image']['tmp_name'], $bannerFilePath); if (!$copy) { $errors[] = 'Cannot copy file from TMP dir to Banners Dir'; break; } if ($_FILES['image']['type'] != 'application/x-shockwave-flash') { $bannerInfo = getimagesize($bannerFilePath); if ($productInfo['width'] != '' && $productInfo['height'] != '') { $sx = $productInfo['width']; $sy = $productInfo['height']; } else { $sx = $bannerInfo[0]; $sy = $bannerInfo[1]; } $type = $bannerInfo['mime']; } else { if ($productInfo['width'] == '' || $productInfo['height'] == '') { $errors[] = 'Your banner dimensions exceed the required size. Please upload an appropriate banner.'; break; } $sx = $productInfo['width']; $sy = $productInfo['height']; $type = $_FILES['image']['type']; } $active = 0; $group = $productInfo['banner_group_sid']; $params['bannerFilePath'] = "/" . str_replace("../", "/", str_replace(SJB_BASE_DIR, '', $bannerFilePath)); $params['openBannerIn'] = ''; $params['bannerType'] = 'file'; $params['code'] = ''; $params['title'] = $title; $params['link'] = $link; $params['type'] = $type; $params['sx'] = $sx; $params['sy'] = $sy; $params['banner_group_sid'] = $group; $productInfo['banner_info'] = $params; break; } if (!$errors) { $numberOfListings = SJB_Request::getVar('number_of_listings'); $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID); if (!empty($extraInfo['pricing_type']) && $extraInfo['pricing_type'] == 'volume_based' && $numberOfListings) { $productInfo['number_of_listings'] = $numberOfListings; $productObj = new SJB_Product($productInfo, $productInfo['product_type']); $number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1; $productObj->setNumberOfListings($number_of_listings); $productInfo['price'] = $productObj->getPrice(); } if (SJB_UserManager::isUserLoggedIn()) { SJB_ShoppingCart::addToShoppingCart($productInfo, $current_user->getSID()); } else { if (isset($_SESSION['products'])) { foreach ($_SESSION['products'] as $addedProduct) { $addedProductInfo = unserialize($addedProduct['product_info']); if ($addedProductInfo['user_group_sid'] != $productInfo['user_group_sid']) { $errors[] = 'You are trying to add products of different User Groups in your Shopping Cart. You сan add only products belonging to one User Group. If you want to add this product in the Shopping Cart please go back to the Shopping Cart and remove products of other User Groups.'; break; } } } if (!$errors) { $id = time(); $_SESSION['products'][$id]['product_info'] = serialize($productInfo); $_SESSION['products'][$id]['sid'] = $id; $_SESSION['products'][$id]['user_sid'] = 0; } } if (!$errors) { SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/'); } } } } if (!empty($productInfo['expiration_period']) && !is_numeric($productInfo['expiration_period'])) { $productInfo['period'] = ucwords($productInfo['expiration_period']); } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based' && !empty($productInfo['volume_based_pricing'])) { $volumeBasedPricing = $productInfo['volume_based_pricing']; $price = array(); $firstPrice = 0; if (!empty($volumeBasedPricing['listings_range_from'])) { for ($i = 1; $i <= count($volumeBasedPricing['listings_range_from']); $i++) { if ($volumeBasedPricing['listings_range_from'][$i] == $volumeBasedPricing['listings_range_to'][$i]) { $price[$i]['range']['from'] = $volumeBasedPricing['listings_range_from'][$i]; } else { $price[$i]['range']['from'] = $volumeBasedPricing['listings_range_from'][$i]; $price[$i]['range']['to'] = $volumeBasedPricing['listings_range_to'][$i]; } $price[$i]['price'] = $volumeBasedPricing['price_per_unit'][$i]; if ($i > 1 && $firstPrice > $volumeBasedPricing['price_per_unit'][$i]) { $price[$i]['savings'] = round(100 - 100 / $firstPrice * $volumeBasedPricing['price_per_unit'][$i]); } else { $firstPrice = $volumeBasedPricing['price_per_unit'][$i]; } } } $productInfo['volume_based_pricing'] = $price; $minListings = min($volumeBasedPricing['listings_range_from']); $maxListings = max($volumeBasedPricing['listings_range_to']); $countListings = array(); for ($i = $minListings; $i <= $maxListings; $i++) { $countListings[] = $i; } $productInfo['count_listings'] = $countListings; } elseif (!empty($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') { $productInfo['fixed_period'] = 1; } if ($productInfo['product_type'] == 'banners') { $params = $_REQUEST; $bannersObj = new SJB_Banners(); $banner_fields = $bannersObj->getBannersMeta(); foreach ($banner_fields as $key => $banner_field) { $banner_fields[$banner_field['id']] = $banner_field; if (!empty($params[$banner_field['id']])) { $banner_fields[$banner_field['id']]['value'] = $params[$banner_field['id']]; } unset($banner_fields[$key]); } if (!empty($params['errors'])) { $tp->assign("errors", $params['errors']); } $tp->assign("banner_fields", $banner_fields); } $userGroupID = SJB_UserGroupDBManager::getUserGroupIDBySID($productInfo['user_group_sid']); $tp->assign('productInfo', $productInfo); $tp->assign('userGroupID', $userGroupID); $tp->assign('productSID', $productSID); $tp->assign('mayChooseProduct', true); } $tp->assign('errors', $errors); break; } $tp->display($template); }
/** * @param int $currentUserID * @param int $productSID * @return bool|int|mixed */ public function proceedToCheckout($currentUserID, $productSID) { $errors = array(); $productInfo = SJB_ProductsManager::getProductInfoBySID($productSID); if (SJB_UserManager::isUserLoggedIn()) { $numberOfListings = SJB_ListingDBManager::getNumberOfCheckoutedListingsByProductSID($productSID, $currentUserID); $extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID); $shoppingCartProducts = SJB_ShoppingCart::getProductsInfoFromCartByProductSID($productSID, $currentUserID); if (!empty($shoppingCartProducts)) { if ($productInfo['product_type'] == 'mixed_product' || isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'fixed') { if ($numberOfListings / (count($shoppingCartProducts) * $productInfo['number_of_listings']) > 1) { SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID); } } if (isset($productInfo['pricing_type']) && $productInfo['pricing_type'] == 'volume_based') { if ($numberOfListings / (count($shoppingCartProducts) * end($productInfo['volume_based_pricing']['listings_range_to'])) > 1) { $productInfo['number_of_listings'] = 1; $productObj = new SJB_Product($productInfo, $productInfo['product_type']); $productObj->setNumberOfListings($productInfo['number_of_listings']); $productInfo['price'] = $productObj->getPrice(); SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID); } else { foreach ($shoppingCartProducts as $shoppingCartProduct) { $unserializedProductInfoFromShopCart = unserialize($shoppingCartProduct['product_info']); if ($unserializedProductInfoFromShopCart['number_of_listings'] < end($unserializedProductInfoFromShopCart['volume_based_pricing']['listings_range_to'])) { $unserializedProductInfoFromShopCart['number_of_listings'] += 1; SJB_ShoppingCart::updateItemBySID($shoppingCartProduct['sid'], $unserializedProductInfoFromShopCart); break; } } } } } else { if (!empty($extraInfo['pricing_type']) && $extraInfo['pricing_type'] == 'volume_based') { $productInfo['number_of_listings'] = 1; $productObj = new SJB_Product($productInfo, $productInfo['product_type']); $productObj->setNumberOfListings($productInfo['number_of_listings']); $productInfo['price'] = $productObj->getPrice(); } SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUserID); } } else { $products = SJB_Session::getValue('products'); if (isset($products)) { foreach ($products as $addedProduct) { $addedProductInfo = unserialize($addedProduct['product_info']); if ($addedProductInfo['user_group_sid'] != $productInfo['user_group_sid']) { $errors[] = 'You are trying to add products of different User Groups in your Shopping Cart. You сan add only products belonging to one User Group. If you want to add this product in the Shopping Cart please go back to the Shopping Cart and remove products of other User Groups.'; break; } } } if (!$errors) { $id = time(); $products[$id]['product_info'] = serialize($productInfo); $products[$id]['sid'] = $id; $products[$id]['user_sid'] = 0; SJB_Session::setValue('products', $products); } } if (!$errors) { SJB_HelperFunctions::redirect(SJB_System::getSystemsettings('SITE_URL') . '/shopping-cart/'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $bannersObj = new SJB_Banners(); $filesDir = SJB_System::getSystemSettings('FILES_DIR'); // set null values, to initialize $errors = array(); $groupSID = SJB_Request::getVar('groupSID', false); $params = $_REQUEST; if (isset($_REQUEST['action'])) { $action_name = $_REQUEST['action']; switch ($action_name) { case 'add': // ERRORS if ($params['title'] == '') { $errors[] = 'Banner Title is empty.'; } if ($params['link'] == '' && $params['bannerType'] != 'code') { $errors[] = 'Banner link mismatched!'; } if ($params['bannerType'] == 'code' && $params['code'] == '') { $errors[] = 'Banner code is empty.'; } if ($_FILES['image']['name'] == '' && $params['bannerType'] == 'file') { $errors[] = 'No image attached!'; } if ($_FILES['image']['name'] && $_FILES['image']['error']) { $errors[SJB_UploadFileManager::getErrorId($_FILES['image']['error'])] = 1; } if ($errors) { break; } // ok. All input fields presented $title = $params['title']; $link = $params['link']; // check 'link' for correct. If it hasn't 'http://' or 'https://' and bannerType != code - add them $expr = preg_match("/^(https?:\\/\\/)/", $link); if ($expr != true && $params['bannerType'] != 'code') { $link = 'http://' . $link; } if ($params['bannerType'] == 'file') { // make filename preg_match("|\\.(\\w{3})\\b|u", $_FILES['image']['name'], $arr); $fileName = preg_replace("|\\.(\\w{3})\\b|u", '', $_FILES['image']['name']); $hashName = md5(time() * $_FILES['image']['size']) . '_' . $fileName; $bannerFilePath = $filesDir . 'banners/' . $hashName . '.' . $arr[1]; // move file from temporary folder, and fill banner info to DB $copy = copy($_FILES['image']['tmp_name'], $bannerFilePath); if (!$copy) { $errors[] = 'Cannot copy file from TMP dir to Banners Dir'; break; } if ($_FILES['image']['type'] != 'application/x-shockwave-flash') { // array of bannerInfo // [0] - width // [1] - height // [2] - ?? // [3] - width & height in next view: width="104" height="150" // [bits] - bit size of image // [channels] // [mime] - type, (image/jpeg, image/gif, image/png ) $bannerInfo = getimagesize($bannerFilePath); if ($params['width'] != '' && $params['height'] != '') { $sx = $params['width']; $sy = $params['height']; } else { $sx = $bannerInfo[0]; $sy = $bannerInfo[1]; } $type = $bannerInfo['mime']; } else { if ($params['width'] == '' || $params['height'] == '') { $errors[] = 'SIZE_PARAMETER_MISMATCHED'; break; } $sx = $params['width']; $sy = $params['height']; $type = $_FILES['image']['type']; } $active = $params['active']; $group = $params['groupSID']; $bannerFilePath = '/' . str_replace('../', '/', str_replace(SJB_BASE_DIR, '', $bannerFilePath)); } else { $sx = $params['width']; $sy = $params['height']; $type = ''; $active = $params['active']; $group = $params['groupSID']; $bannerFilePath = ''; } $bannersObj->addBanner($title, $link, $bannerFilePath, $sx, $sy, $type, $active, $group, $params); $site_url = SJB_System::getSystemsettings('SITE_URL') . "/edit-banner-group/?groupSID={$groupSID}"; header("Location: {$site_url}"); break; } } $banner_fields = $bannersObj->getBannersMeta(); $bannerGroup = $bannersObj->getBannerGroupBySID($groupSID); $tp->assign('params', $params); $tp->assign('errors', $errors); $tp->assign('banner_fields', $banner_fields); $tp->assign('bannerGroup', $bannerGroup); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display('add_banner.tpl'); }