public function execute() { $tp = SJB_System::getTemplateProcessor(); $user = SJB_UserManager::getCurrentUser(); if ($user) { $userNotificationsManager = new SJB_UserNotificationsManager($user); $userNotificationsInfo = $userNotificationsManager->getUserNotificationsInfo(); $userNotificationsInfo = array_merge($userNotificationsInfo, $_REQUEST); $userNotifications = new SJB_UserNotifications($userNotificationsInfo); $userNotificationsForm = new SJB_Form($userNotifications); $userNotificationsForm->registerTags($tp); $userNotificationsFields = $userNotificationsForm->getFormFieldsInfo(); $tp->assign('form_fields', $userNotificationsFields); if (SJB_Request::getVar('action') === 'save') { $errors = array(); if ($userNotificationsForm->isDataValid($errors)) { $userNotifications->update(); $tp->assign('isSaved', true); } $tp->assign('errors', $errors); } $tp->assign('userNotificationGroups', $userNotificationsManager->getNotificationGroups()->getGroups()); $tp->assign('userNotifications', $userNotificationsManager->getEnabledForGroupUserNotifications()); $listingTypes = SJB_ListingTypeManager::getListingTypeByUserSID($user->getSID()); $approveSetting = SJB_ListingTypeManager::getWaitApproveSettingByListingType($listingTypes); $tp->assign('approve_setting', $approveSetting); $tp->display('user_notifications.tpl'); } else { $tp->display('login.tpl'); } }
public static function getRedirectUrlByPageID($pageId) { $error = ''; if (!is_null(SJB_Session::getValue('fromAnonymousShoppingCart'))) { SJB_Session::unsetValue('fromAnonymousShoppingCart'); return SJB_System::getSystemSettings('SITE_URL') . '/shopping-cart/?'; } $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/my-account/?'; if (empty($pageId)) { return $redirectUrl; } if ($pageId == 'posting_page') { $user = SJB_UserManager::getCurrentUser(); $userGroupId = SJB_UserGroupManager::getUserGroupIDBySID($user->getUserGroupSID()); $listingTypeSid = SJB_ListingTypeManager::getListingTypeByUserSID($user->getSID()); $listingTypeId = !empty($listingTypeSid) ? SJB_ListingTypeManager::getListingTypeIDBySID(array_pop($listingTypeSid)) : ''; if ($user->hasContract() && SJB_ListingManager::canCurrentUserAddListing($error, $listingTypeId)) { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/add-listing/?listing_type_id=' . $listingTypeId . "&"; } elseif ($user->hasContract()) { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/my-account/?'; } else { $redirectUrl = SJB_System::getSystemSettings('SITE_URL') . '/' . mb_strtolower($userGroupId) . '-products/?postingProductsOnly=1&'; } } return $redirectUrl; }