本文整理汇总了PHP中SJB_UserManager::getCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP SJB_UserManager::getCurrentUser方法的具体用法?PHP SJB_UserManager::getCurrentUser怎么用?PHP SJB_UserManager::getCurrentUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SJB_UserManager
的用法示例。
在下文中一共展示了SJB_UserManager::getCurrentUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$listing_id = isset($_REQUEST['listing_id']) ? $_REQUEST['listing_id'] : null;
$listing = SJB_ListingManager::getObjectBySID($listing_id);
$current_user = SJB_UserManager::getCurrentUser();
$template_processor = SJB_System::getTemplateProcessor();
if (is_null($listing_id)) {
$errors['PARAMETERS_MISSED'] = 1;
} elseif (empty($current_user)) {
$errors['NOT_LOGGED_IN'] = 1;
} elseif (is_null($listing)) {
$errors['WRONG_PARAMETERS_SPECIFIED'] = 1;
} elseif ($listing->getUserSID() != $current_user->getSID()) {
$errors['NOT_OWNER'] = 1;
} else {
$productInfo = $listing->getProductInfo();
$listing_info = SJB_ListingManager::getListingInfoBySID($listing_id);
$listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($listing_info['listing_type_sid']);
$waitApprove = $listing_type_info['waitApprove'];
$listing_info['type'] = array('id' => $listing_type_info['id'], 'caption' => $listing_type_info['name']);
$listing_info['product'] = $productInfo;
$template_processor->assign("listing", $listing_info);
$contract_id = $listing_info['contract_id'];
$template_processor->assign("waitApprove", $waitApprove);
}
$template_processor->assign("errors", isset($errors) ? $errors : null);
$template_processor->display("manage_listing.tpl");
}
示例2: execute
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');
}
}
示例3: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$count_listing = SJB_Request::getVar('count_listing', 10, null, 'int');
$current_user = SJB_UserManager::getCurrentUser();
if (SJB_UserManager::isUserLoggedIn()) {
$lastAddedListing = SJB_ListingManager::getLastAddedListingByUserSID($current_user->getSID());
if ($lastAddedListing) {
$properties = $current_user->getProperties();
$phrase['title'] = $lastAddedListing->getPropertyValue('Title');
foreach ($properties as $property) {
if ($property->getType() == 'location') {
$fields = $property->type->child;
$childProperties = $fields->getProperties();
foreach ($childProperties as $childProperty) {
if (in_array($childProperty->getID(), array('City', 'State', 'Country'))) {
$value = $childProperty->getValue();
switch ($childProperty->getType()) {
case 'list':
if ($childProperty->getID() == 'State') {
$displayAS = $childProperty->display_as;
$displayAS = $displayAS ? $displayAS : 'state_name';
$listValues = SJB_StatesManager::getStatesNamesByCountry(false, true, $displayAS);
} else {
$listValues = $childProperty->type->list_values;
}
foreach ($listValues as $values) {
if ($value == $values['id']) {
$phrase[strtolower($childProperty->getID())] = $values['caption'];
}
}
break;
default:
$phrase[strtolower($childProperty->getID())] = $value;
break;
}
}
}
}
}
$phrase = array_diff($phrase, array(''));
$phrase = implode(" ", $phrase);
$listing_type_id = "Job";
$request['action'] = 'search';
$request['listing_type']['equal'] = $listing_type_id;
$request['default_listings_per_page'] = $count_listing;
$request['default_sorting_field'] = "activation_date";
$request['default_sorting_order'] = "DESC";
$request['keywords']['relevance'] = $phrase;
$searchResultsTP = new SJB_SearchResultsTP($request, $listing_type_id, array('field' => 'keywords', 'value' => $phrase));
$tp = $searchResultsTP->getChargedTemplateProcessor();
}
$tp->display('suggested_jobs.tpl');
}
}
示例4: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$errors = array();
$sid = false;
if (isset($_REQUEST['passed_parameters_via_uri'])) {
$passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
$sid = isset($passed_parameters_via_uri[0]) ? $passed_parameters_via_uri[0] : null;
}
$cu = SJB_UserManager::getCurrentUser();
if (!isset($cu->user_group_sid)) {
$userGroupSID = 0;
} else {
$userGroupSID = $cu->user_group_sid;
}
$i18n = SJB_I18N::getInstance();
$lang = $i18n->getLanguageData($i18n->getCurrentLanguage());
$langId = $lang['id'];
if ($sid && SJB_PollsManager::isActive($sid, $userGroupSID, $langId)) {
$countVotes = SJB_PollsManager::getCountVotesBySID($sid);
$pollResults = SJB_PollsManager::getPollResultsBySID($sid);
$result = array();
$i = 0;
$colors = array('613978', 'aad434', 'f55c00', 'f9c635', 'f97c9e', '870000', '0ec300', '6f6f6f', '0400a5', '6eeffb', '000000', 'ff00ff');
foreach ($pollResults as $poll) {
$result[$i]['vote'] = $countVotes > 0 ? round(100 / $countVotes * $poll['count'], 2) : 0;
$result[$i]['value'] = $poll['question'];
$result[$i]['color'] = $colors[$i];
$i++;
}
$pollInfo = SJB_PollsManager::getPollInfoBySID($sid);
$tp->assign('pollInfo', $pollInfo);
$tp->assign('result', $result);
$tp->assign('width', count($pollResults) * 40 + (count($pollResults) - 1) * 3);
$tp->assign('show_total_votes', isset($pollInfo['show_total_votes']) ? $pollInfo['show_total_votes'] : 0);
$tp->assign('count_vote', $countVotes);
} else {
$pollInfo = SJB_PollsManager::getPollInfoBySID($sid);
if ($pollInfo['language'] != $langId) {
$errors[] = 'This poll is not available for this language';
}
}
$tp->assign('errors', $errors);
$tp->display('poll_results.tpl');
}
示例5: execute
public function execute()
{
if (SJB_Authorization::isUserLoggedIn() && class_exists('SJB_SocialPlugin') && !SJB_SocialPlugin::getProfileObject() && ($socPlugins = SJB_SocialPlugin::getAvailablePlugins())) {
$tp = SJB_System::getTemplateProcessor();
$userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID(SJB_UserManager::getCurrentUser()->user_group_sid);
/**
* delete from plugins array plugins that are not allowed
* for this userGroup registration
*/
SJB_SocialPlugin::preparePluginsThatAreAvailableForRegistration($socPlugins, $userGroupInfo['id']);
if (empty($socPlugins)) {
return null;
}
$socialNetworks = SJB_SocialPlugin::getSocialNetworks($socPlugins);
$tp->assign('label', 'link');
$tp->assign('social_plugins', $socialNetworks);
$tp->display('social_plugins.tpl');
}
}
示例6: execute
public function execute()
{
$template = SJB_Request::getVar('display_template', 'my_reports.tpl');
$action = SJB_Request::getVar('action', 'quickStat');
$tp = SJB_System::getTemplateProcessor();
$errors = array();
$currentUser = SJB_UserManager::getCurrentUser();
if (empty($currentUser)) {
$tp->assign('ERROR', 'NOT_LOGIN');
$tp->display('../miscellaneous/error.tpl');
return;
} else {
if (SJB_UserGroupManager::getUserGroupIDBySID($currentUser->getUserGroupSID()) == 'Employer') {
switch ($action) {
case 'generalStat':
$generalStat = SJB_Statistics::getEmployerGeneralStatistics($currentUser->getSID());
$tp->assign('generalStat', $generalStat);
break;
case 'jobsStat':
$active = SJB_Request::getVar('active', 1);
$sortingField = SJB_Request::getVar('sortingField', 'postedDate');
$sortingOrder = SJB_Request::getVar('sortingOrder', 'DESC');
$jobsStat = SJB_Statistics::getEmployerJobsStatistics($currentUser->getSID(), $active, $sortingField, $sortingOrder);
$tp->assign('jobsStat', $jobsStat);
$tp->assign('active', $active);
$tp->assign('sortingField', $sortingField);
$tp->assign('sortingOrder', $sortingOrder);
break;
case 'quickStat':
$quickStat = SJB_Statistics::getEmployerQuickStatistics($currentUser->getSID());
$tp->assign('quickStat', $quickStat);
break;
default:
break;
}
} else {
$errors['NOT_EMPLOYER'] = true;
}
}
$tp->assign('errors', $errors);
$tp->display($template);
}
示例7: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$currentUser = SJB_UserManager::getCurrentUser();
$products = array();
if (!empty($_SESSION['products'])) {
$products = $_SESSION['products'];
}
if (SJB_UserManager::isUserLoggedIn()) {
foreach ($products as $product) {
if (!empty($product['product_info'])) {
$productInfo = unserialize($product['product_info']);
if ($currentUser->getUserGroupSID() != $productInfo['user_group_sid']) {
SJB_Session::unsetValue('products');
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/shopping-cart/?error=user_group");
} else {
SJB_ShoppingCart::addToShoppingCart($productInfo, $currentUser->getSID());
}
}
}
SJB_Session::unsetValue('products');
$products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
}
$total_price = 0;
foreach ($products as $product) {
$productInfo = unserialize($product['product_info']);
$product = new SJB_Product($productInfo, $productInfo['product_type']);
$number_of_listings = !empty($productInfo['number_of_listings']) ? $productInfo['number_of_listings'] : 1;
$product->setNumberOfListings($number_of_listings);
$productInfo['price'] = $product->getPrice();
$total_price += $productInfo['price'];
if ($productInfo['pricing_type'] != 'volume_based' && $productInfo['code_info']) {
$total_price += $productInfo['code_info']['promoAmount'];
}
}
$tp->assign('products_number', count($products));
$tp->assign('total_price', $total_price);
$tp->assign("currency", SJB_CurrencyManager::getDefaultCurrency());
$tp->display('show_shopping_cart.tpl');
}
示例8: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$pollSID = SJB_Request::getVar('sid', 0, null, 'int');
$cu = SJB_UserManager::getCurrentUser();
$i18n = SJB_I18N::getInstance();
$lang = $i18n->getLanguageData($i18n->getCurrentLanguage());
$langId = $lang['id'];
if (!$pollSID) {
$pollSID = SJB_PollsManager::getPollForDisplay($cu->user_group_sid, $langId);
}
if ($pollSID) {
if (SJB_PollsManager::isActive($pollSID, $cu->user_group_sid, $langId)) {
$action = SJB_Request::getVar('action', false);
$IP = $_SERVER['REMOTE_ADDR'];
$isVoted = SJB_PollsManager::isVoted($pollSID, $IP);
switch ($action) {
case 'save':
$value = SJB_Request::getVar('poll', false);
if ($value && $pollSID && !$isVoted) {
SJB_PollsManager::addPollResult($pollSID, $value, $IP);
$isVoted = true;
}
break;
}
$poll_info = SJB_PollsManager::getPollInfoBySID($pollSID);
$poll = new SJB_UserPollsManager($poll_info);
$poll->setSID($poll_info['sid']);
$edit_form = new SJB_Form($poll);
$edit_form->registerTags($tp);
$form_fields = $edit_form->getFormFieldsInfo();
$tp->assign('display_results', $poll_info['display_results']);
$tp->assign('question', trim(strip_tags($poll_info['question'])));
$tp->assign('isVoted', $isVoted);
$tp->assign('form_fields', $form_fields);
$tp->assign('sid', $pollSID);
$tp->display('polls.tpl');
}
}
}
示例9: execute
public function execute()
{
$invoiceSID = SJB_Request::getVar('invoice_sid', null, 'default', 'int');
$tp = SJB_System::getTemplateProcessor();
$action = SJB_Request::getVar('action', false);
$checkPaymentErrors = array();
$currentUser = SJB_UserManager::getCurrentUser();
if ($action == 'pay_for_products') {
$subscribe = SJB_Request::getVar('subscribe', false);
$subTotalPrice = SJB_Request::getVar('sub_total_price', 0);
$products = SJB_ShoppingCart::getAllProductsByUserSID($currentUser->getSID());
$codeInfo = array();
$index = 1;
$items = array();
foreach ($products as $product) {
$product_info = unserialize($product['product_info']);
$items['products'][$index] = $product_info['sid'];
$qty = !empty($product_info['number_of_listings']) ? $product_info['number_of_listings'] : null;
if ($qty > 0) {
$items['price'][$index] = round($product_info['price'] / $qty, 2);
} else {
$items['price'][$index] = round($product_info['price'], 2);
}
$items['amount'][$index] = $product_info['price'];
$items['custom_item'][$index] = "";
$items['qty'][$index] = $qty;
$items['custom_info'][$index]['shoppingCartRecord'] = $product['sid'];
if ($product_info['product_type'] == 'banners' && !empty($product_info['banner_info'])) {
$items['custom_info'][$index]['banner_info'] = $product_info['banner_info'];
}
$index++;
SJB_PromotionsManager::preparePromoCodeInfoByProductPromoCodeInfo($product_info, $codeInfo);
}
$userSID = $currentUser->getSID();
$invoiceSID = SJB_InvoiceManager::generateInvoice($items, $userSID, $subTotalPrice, SJB_System::getSystemSettings('SITE_URL') . "/create-contract/", (bool) $subscribe);
SJB_PromotionsManager::addCodeToHistory($codeInfo, $invoiceSID, $userSID);
}
$gatewayId = SJB_Request::getVar('gw', false);
if (SJB_Request::$method == SJB_Request::METHOD_POST && !$action && $gatewayId == 'authnet_sim') {
if (isset($_REQUEST['submit'])) {
$gateway = SJB_PaymentGatewayManager::getObjectByID($gatewayId, true);
$subscriptionResult = $gateway->createSubscription($_REQUEST);
if ($subscriptionResult !== true) {
$tp->assign('form_submit_url', $_SERVER['REQUEST_URI']);
$tp->assign('form_data_source', $_REQUEST);
$tp->assign('errors', $subscriptionResult);
$tp->display('recurring_payment_page.tpl');
} else {
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/my-products/?subscriptionComplete=true');
}
} else {
$tp->assign('form_submit_url', $_SERVER['REQUEST_URI']);
$tp->assign('form_data_source', $_REQUEST);
$tp->display('recurring_payment_page.tpl');
}
} else {
if (!is_null($invoiceSID)) {
$invoice_info = SJB_InvoiceManager::getInvoiceInfoBySID($invoiceSID);
$invoice = new SJB_Invoice($invoice_info);
if (SJB_PromotionsManager::isPromoCodeExpired($invoiceSID)) {
$checkPaymentErrors['PROMOTION_TOO_MANY_USES'] = true;
} else {
$invoice->setSID($invoiceSID);
if (count($invoice->isValid($invoiceSID)) == 0) {
$invoiceUserSID = $invoice->getPropertyValue('user_sid');
$currentUserSID = SJB_UserManager::getCurrentUserSID();
if ($invoiceUserSID === $currentUserSID) {
$payment_gateway_forms = SJB_InvoiceManager::getPaymentForms($invoice);
$tp->assign('productsNames', $invoice->getProductNames());
$tp->assign('gateways', $payment_gateway_forms);
$tp->assign('invoice_info', $invoice_info);
} else {
$checkPaymentErrors['NOT_OWNER'] = true;
}
} else {
$checkPaymentErrors['WRONG_INVOICE_PARAMETERS'] = true;
}
}
$tp->assign('checkPaymentErrors', $checkPaymentErrors);
$tp->display('invoice_payment_page.tpl');
} else {
$tp->display('recurring_payment_page.tpl');
}
}
}
示例10: getProfileInformation
public function getProfileInformation()
{
if (!$this->takeDataFromServer && ($oCurUser = SJB_UserManager::getCurrentUser())) {
$curUserSID = $oCurUser->getSID();
$profileSocialID = self::getProfileSocialID($curUserSID);
if ($profileSocialID) {
$aProfExpl = explode($this->getNetwork() . '_', $profileSocialID);
$linkedinID = SJB_Array::get($aProfExpl, 1);
$profileSocialInfo = $this->getProfileSocialSavedInfoBySocialID($linkedinID);
if ($profileSocialInfo) {
self::$oProfile = SJB_Array::get($profileSocialInfo, 'profile_info');
self::$oSocialPlugin = $this;
if (SJB_HelperFunctions::debugModeIsTurnedOn()) {
SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGIN');
}
return true;
}
}
}
if (self::$object) {
try {
$this->_getProfileInfoByAccessToken();
if (self::$oProfile) {
if (SJB_HelperFunctions::debugModeIsTurnedOn()) {
SJB_HelperFunctions::debugInfoPush(self::$oProfile, 'SOCIAL_PLUGINS');
}
return true;
} else {
SJB_Session::unsetValue('sn');
}
} catch (FacebookApiException $e) {
SJB_Error::writeToLog($e->getMessage());
}
}
return null;
}
示例11: execute
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'];
//.........这里部分代码省略.........
示例12: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
if (SJB_UserManager::isUserLoggedIn()) {
$current_user = SJB_UserManager::getCurrentUser();
if ($current_user->isSubuser()) {
// У саб-юзера должны быть свои алерты
$current_user = $current_user->getSubuserInfo();
} else {
$current_user = SJB_UserManager::getCurrentUserInfo();
}
$listing_type_id = '';
/************************************************************/
$tp = SJB_System::getTemplateProcessor();
$tp->assign('action', 'list');
$errors = array();
$redirectUri = '/saved-searches/';
if (isset($_REQUEST['is_alert'])) {
if (isset($_REQUEST['listing_type_id'])) {
$listing_type_id = $_REQUEST['listing_type_id'];
SJB_Session::setValue('listing_type_id', $listing_type_id);
} elseif (isset($_REQUEST['restore'])) {
$listing_type_id = SJB_Session::getValue('listing_type_id');
} else {
SJB_Session::setValue('listing_type_id', null);
}
if (!SJB_Acl::getInstance()->isAllowed("use_{$listing_type_id}_alerts")) {
$errors = array('NOT_SUBSCRIBE' => true);
$tp->assign('ERRORS', $errors);
$tp->display('error.tpl');
return;
} else {
$redirectUri = '/' . strtolower($listing_type_id) . '-alerts/';
}
} else {
if (isset($_REQUEST['listing_type_id'])) {
$listing_type_id = $_REQUEST['listing_type_id'];
}
if (!SJB_Acl::getInstance()->isAllowed('save_searches')) {
$errors = array('NOT_SUBSCRIBE' => true);
$tp->assign('ERRORS', $errors);
$tp->display('error.tpl');
return;
}
}
$isSubmittedForm = SJB_Request::getVar('submit', false);
$listing_type_sid = !empty($listing_type_id) ? SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id) : 0;
if (!isset($_REQUEST['listing_type']['equal']) && isset($listing_type_id)) {
$_REQUEST['listing_type']['equal'] = $listing_type_id;
}
$action = SJB_Request::getVar('action', 'list');
switch ($action) {
case 'save':
if ($isSubmittedForm) {
$search_name = SJB_Request::getVar('name');
$emailFrequency = SJB_Request::getVar('email_frequency');
if (empty($search_name['equal'])) {
$errors['EMPTY_VALUE'] = 1;
$tp->assign('action', 'save');
} else {
unset($_REQUEST['name']);
unset($_REQUEST['email_frequency']);
if ($emailFrequency) {
$emailFrequency = array_pop($emailFrequency);
$emailFrequency = '&email_frequency=' . array_pop($emailFrequency);
} else {
$emailFrequency = '';
}
$search_name = $search_name['equal'];
$searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id);
$tp = $searchResultsTP->getChargedTemplateProcessor();
SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/save-search/?alert=true&url=' . $redirectUri . '&action=save&search_name=' . $search_name . '&searchId=' . $searchResultsTP->searchId . $emailFrequency);
}
} else {
$tp->assign('action', 'save');
}
break;
case 'edit':
if (isset($_REQUEST['id_saved'])) {
if ($isSubmittedForm) {
$id_saved = $_REQUEST['id_saved'];
$name = $_REQUEST['name'];
$search_name = SJB_Request::getVar('name');
$emailFrequency = SJB_Request::getVar('email_frequency');
if (empty($search_name['equal'])) {
$errors['EMPTY_VALUE'] = 1;
} else {
unset($_REQUEST['name']);
unset($_REQUEST['email_frequency']);
if ($emailFrequency) {
$emailFrequency = array_pop($emailFrequency);
$emailFrequency = array_pop($emailFrequency);
} else {
$emailFrequency = 'daily';
}
$searchResultsTP = new SJB_SearchResultsTP($_REQUEST, $listing_type_id);
$tp = $searchResultsTP->getChargedTemplateProcessor();
$criteria_saver = new SJB_ListingCriteriaSaver($searchResultsTP->searchId);
$requested_data = $criteria_saver->getCriteria();
SJB_SavedSearches::updateSearchOnDB($requested_data, $id_saved, $current_user['sid'], $name['equal'], $emailFrequency);
//.........这里部分代码省略.........
示例13: addListing
/**
* @param $listingSID
* @param $contractID
* @param $productSID
*/
public function addListing($listingSID, $contractID = false, $productSID = false)
{
if ($productSID != false) {
$extraInfo = SJB_ProductsManager::getProductExtraInfoBySID($productSID);
$extraInfo['product_sid'] = (string) $extraInfo['product_sid'];
} else {
$contract = new SJB_Contract(array('contract_id' => $contractID));
$extraInfo = $contract->extra_info;
}
$numberOfPictures = isset($extraInfo['number_of_pictures']) ? $extraInfo['number_of_pictures'] : 0;
$this->tp->assign("pic_limit", $numberOfPictures);
$listingTypesInfo = SJB_ListingTypeManager::getAllListingTypesInfo();
if (!$this->listingTypeID && count($listingTypesInfo) == 1) {
$listingTypeInfo = array_pop($listingTypesInfo);
$this->listingTypeID = $listingTypeInfo['id'];
}
$listingTypeSID = SJB_ListingTypeManager::getListingTypeSIDByID($this->listingTypeID);
$pages = SJB_PostingPagesManager::getPagesByListingTypeSID($listingTypeSID);
$pageSID = $this->getPageSID($pages, $listingTypeSID);
$isPageLast = SJB_PostingPagesManager::isLastPageByID($pageSID, $listingTypeSID);
$isPreviewListingRequested = SJB_Request::getVar('preview_listing', false, 'POST');
if (($contractID || !empty($this->buttonPressedPostToProceed)) && $this->listingTypeID) {
$formSubmitted = isset($_REQUEST['action_add']) || isset($_REQUEST['action_add_pictures']) || $isPreviewListingRequested;
/*
* social plugin
* complete listing of data from an array of social data
* if is allowed
*/
$aAutoFillData = array('formSubmitted' => &$formSubmitted, 'listingTypeID' => &$this->listingTypeID);
SJB_Event::dispatch('SocialSynchronization', $aAutoFillData);
/*
* end of "social plugin"
*/
$listing = new SJB_Listing($_REQUEST, $listingTypeSID, $pageSID);
$listing->deleteProperty('featured');
$listing->deleteProperty('priority');
$listing->deleteProperty('status');
$listing->deleteProperty('reject_reason');
$listing->deleteProperty('ListingLogo');
$access_type = $listing->getProperty('access_type');
if ($formSubmitted) {
if (!empty($access_type)) {
$listing->addProperty(array('id' => 'access_list', 'type' => 'multilist', 'value' => SJB_Request::getVar("list_emp_ids"), 'is_system' => true));
}
$listing->addProperty(array('id' => 'contract_id', 'type' => 'id', 'value' => $contractID, 'is_system' => true));
}
$currentUser = SJB_UserManager::getCurrentUser();
$screeningQuestionnaires = SJB_ScreeningQuestionnaires::getList($currentUser->getSID());
if (SJB_Acl::getInstance()->isAllowed('use_screening_questionnaires') && $screeningQuestionnaires) {
$issetQuestionnairyField = $listing->getProperty('screening_questionnaire');
if ($issetQuestionnairyField) {
$value = SJB_Request::getVar("screening_questionnaire");
$listingInfo = $_REQUEST;
$value = $value ? $value : isset($listingInfo['screening_questionnaire']) ? $listingInfo['screening_questionnaire'] : '';
$listing->addProperty(array('id' => 'screening_questionnaire', 'type' => 'list', 'caption' => 'Screening Questionnaire', 'value' => $value, 'list_values' => SJB_ScreeningQuestionnaires::getListSIDsAndCaptions($currentUser->getSID()), 'is_system' => true));
}
} else {
$listing->deleteProperty('screening_questionnaire');
}
/*
* social plugin
* "synchronization"
* if user is not registered using linkedin , delete linkedin sync property
* also if sync is turned off in admin part
*/
$aAutoFillData = array('oListing' => &$listing, 'userSID' => $currentUser->getSID(), 'listingTypeID' => $this->listingTypeID, 'listing_info' => $_REQUEST);
SJB_Event::dispatch('SocialSynchronizationFields', $aAutoFillData);
/*
* end of social plugin "sync"
*/
$listingFormAdd = new SJB_Form($listing);
$listingFormAdd->registerTags($this->tp);
$fieldErrors = array();
if ($formSubmitted && ($this->formSubmittedFromPreview || $listingFormAdd->isDataValid($fieldErrors))) {
if ($isPageLast) {
$listing->addProperty(array('id' => 'complete', 'type' => 'integer', 'value' => 1, 'is_system' => true));
}
$listing->setUserSID($currentUser->getSID());
$listing->setProductInfo($extraInfo);
if (empty($access_type->value)) {
$listing->setPropertyValue('access_type', 'everyone');
}
if ($currentUser->isSubuser()) {
$subuserInfo = $currentUser->getSubuserInfo();
$listing->addSubuserProperty($subuserInfo['sid']);
}
/**
* >>>>> listing preview @author still
*/
if (!empty($listingSID)) {
$listing->setSID($listingSID);
}
/*
* <<<<< listing preview
*/
//.........这里部分代码省略.........
示例14: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
$errors = array();
$template = 'sub_accounts.tpl';
$currentUserInfo = SJB_UserManager::getCurrentUserInfo();
$listSubusers = false;
if (!empty($currentUserInfo['subuser']) && SJB_Request::getVar('action_name') != 'edit' && SJB_Request::getVar('user_id', 0) != $currentUserInfo['subuser']['sid']) {
$errors['ACCESS_DENIED'] = 'ACCESS_DENIED';
}
switch (SJB_Request::getVar('action_name')) {
case 'new':
$form_submitted = SJB_Request::getMethod() === SJB_Request::METHOD_POST;
$user_group_sid = $currentUserInfo['user_group_sid'];
$user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
$_REQUEST['user_group_id'] = $user_group_info['id'];
$user = SJB_ObjectMother::createUser($_REQUEST, $user_group_sid);
$props = $user->getProperties();
$allowedProperties = array('username', 'email', 'password');
foreach ($props as $prop) {
if (!in_array($prop->getID(), $allowedProperties)) {
$user->deleteProperty($prop->getID());
}
}
$registration_form = SJB_ObjectMother::createForm($user);
$registration_form->registerTags($tp);
if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid) && $form_submitted) {
$email = $user->getPropertyValue('email');
if (is_array($email)) {
$email = $email['original'];
}
$user->setPropertyValue('username', $email);
}
$registration_form = SJB_ObjectMother::createForm($user);
if ($form_submitted && $registration_form->isDataValid($errors)) {
$user->addParentProperty($currentUserInfo['sid']);
$subuserPermissions = array('subuser_add_listings' => array('title' => 'Add new listings', 'value' => 'deny'), 'subuser_manage_listings' => array('title' => 'Manage listings and applications of other sub users', 'value' => 'deny'), 'subuser_manage_subscription' => array('title' => 'View and update subscription', 'value' => 'deny'), 'subuser_use_screening_questionnaires' => array('title' => 'Manage Questionnaries', 'value' => 'deny'));
SJB_UserManager::saveUser($user);
SJB_Statistics::addStatistics('addSubAccount', $user->getUserGroupSID(), $user->getSID());
SJB_Acl::clearPermissions('user', $user->getSID());
foreach ($subuserPermissions as $permissionID => $permission) {
$allowDeny = SJB_Request::getVar($permissionID, 'deny');
$subuserPermissions[$permissionID]['value'] = $allowDeny;
SJB_Acl::allow($permissionID, 'user', $user->getSID(), $allowDeny);
}
SJB_UserManager::activateUserByUserName($user->getUserName());
SJB_Notifications::sendSubuserRegistrationLetter($user, SJB_Request::get(), $subuserPermissions);
$tp->assign('isSubuserRegistered', true);
$listSubusers = true;
} else {
if (SJB_UserGroupManager::isUserEmailAsUsernameInUserGroup($user_group_sid)) {
$user->deleteProperty("username");
}
$registration_form = SJB_ObjectMother::createForm($user);
if ($form_submitted) {
$registration_form->isDataValid($errors);
}
$registration_form->registerTags($tp);
$form_fields = $registration_form->getFormFieldsInfo();
$user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid);
$tp->assign("user_group_info", $user_group_info);
$tp->assign("errors", $errors);
$tp->assign("form_fields", $form_fields);
$metaDataProvider = SJB_ObjectMother::getMetaDataProvider();
$tp->assign("METADATA", array("form_fields" => $metaDataProvider->getFormFieldsMetadata($form_fields)));
$tp->display('subuser_registration_form.tpl');
}
break;
case 'edit':
$userInfo = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_id', 0));
if (!empty($userInfo) && $userInfo['parent_sid'] === $currentUserInfo['sid']) {
$userInfo = array_merge($userInfo, $_REQUEST);
$user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($currentUserInfo['user_group_sid']);
$user = new SJB_User($userInfo, $userInfo['user_group_sid']);
$user->setSID($userInfo['sid']);
$user->addParentProperty($currentUserInfo['sid']);
$props = $user->getProperties();
$allowedProperties = array('username', 'email', 'password');
foreach ($props as $prop) {
if (!in_array($prop->getID(), $allowedProperties)) {
$user->deleteProperty($prop->getID());
}
}
$user->makePropertyNotRequired("password");
$edit_profile_form = SJB_ObjectMother::createForm($user);
$edit_profile_form->registerTags($tp);
$edit_profile_form->makeDisabled("username");
$form_submitted = SJB_Request::getMethod() == SJB_Request::METHOD_POST;
if (empty($errors) && $form_submitted && $edit_profile_form->isDataValid($errors)) {
$password_value = $user->getPropertyValue('password');
if (empty($password_value['original'])) {
$user->deleteProperty('password');
}
$currentUser = SJB_UserManager::getCurrentUser();
if (!$currentUser->isSubuser()) {
$subuserPermissions = array('subuser_add_listings', 'subuser_manage_listings', 'subuser_manage_subscription', 'subuser_use_screening_questionnaires');
SJB_Acl::clearPermissions('user', $user->getSID());
foreach ($subuserPermissions as $permission) {
SJB_Acl::allow($permission, 'user', $user->getSID(), SJB_Request::getVar($permission, 'deny'));
}
//.........这里部分代码省略.........
示例15: execute
public function execute()
{
$tp = SJB_System::getTemplateProcessor();
if (!SJB_UserManager::isUserLoggedIn()) {
$errors['NOT_LOGGED_IN'] = true;
$tp->assign("ERRORS", $errors);
$tp->display("../classifieds/error.tpl");
return;
}
if (SJB_Request::getVar('subscriptionComplete') == 'false') {
$this->errors['SUBSCRIPTION_IS_FAIL'] = 1;
}
$currentUser = SJB_UserManager::getCurrentUser();
$contractsInfo = SJB_ContractManager::getAllContractsInfoByUserSID($currentUser->getSID());
$cancelRecurringContract = SJB_Request::getVar('cancelRecurringContract', false);
if ($cancelRecurringContract) {
$tp->assign('cancelRecurringContractId', $cancelRecurringContract);
}
$listingTypes = SJB_ListingTypeManager::getAllListingTypesInfo();
$contractSIDs = array();
foreach ($contractsInfo as $key => $contractInfo) {
$contractInfo['extra_info'] = unserialize($contractInfo['serialized_extra_info']);
$contractInfo['avalaibleViews'] = array();
$contractInfo['avalaibleContactViews'] = array();
$contractInfo['listingAmount'] = array();
foreach ($listingTypes as $listingType) {
$listingTypeID = $listingType['id'];
if ($this->acl->isAllowed('view_' . $listingTypeID . '_details', $contractInfo['id'], 'contract')) {
$contractInfo['avalaibleViews'][$listingTypeID]['name'] = $listingType['name'];
$permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_details', $contractInfo['id'], 'contract');
$contractInfo['avalaibleViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractInfo['id']), false, $listingType['sid']);
if (empty($permissionParam)) {
$contractInfo['avalaibleViews'][$listingTypeID]['count'] = 'unlimited';
$contractInfo['avalaibleViews'][$listingTypeID]['viewsLeft'] = 'unlimited';
} else {
$contractInfo['avalaibleViews'][$listingTypeID]['count'] = $permissionParam;
$contractInfo['avalaibleViews'][$listingTypeID]['viewsLeft'] = $permissionParam - $contractInfo['avalaibleViews'][$listingTypeID]['numOfViews'];
}
}
if ($this->acl->isAllowed('post_' . $listingTypeID, $contractInfo['id'], 'contract')) {
$contractInfo['listingAmount'][$listingTypeID]['name'] = $listingType['name'];
$permissionParam = $this->acl->getPermissionParams('post_' . $listingTypeID, $contractInfo['id'], 'contract');
$contractInfo['listingAmount'][$listingTypeID]['numPostings'] = $contractInfo['number_of_postings'];
if (empty($permissionParam)) {
$contractInfo['listingAmount'][$listingTypeID]['count'] = 'unlimited';
$contractInfo['listingAmount'][$listingTypeID]['listingsLeft'] = 'unlimited';
} else {
$contractInfo['listingAmount'][$listingTypeID]['count'] = $permissionParam;
$contractInfo['listingAmount'][$listingTypeID]['listingsLeft'] = max($contractInfo['listingAmount'][$listingTypeID]['count'] - $contractInfo['listingAmount'][$listingTypeID]['numPostings'], 0);
}
}
if ($this->acl->isAllowed('view_' . $listingTypeID . '_contact_info', $contractInfo['id'], 'contract')) {
$permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info', $contractInfo['id'], 'contract');
$contractInfo['avalaibleContactViews'][$listingTypeID]['name'] = $listingType['name'];
$contractInfo['avalaibleContactViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), array($contractInfo['id']), 'view_' . $listingTypeID . '_contact_info');
if (empty($permissionParam)) {
$contractInfo['avalaibleContactViews'][$listingTypeID]['count'] = 'unlimited';
$contractInfo['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = 'unlimited';
} else {
$contractInfo['avalaibleContactViews'][$listingTypeID]['count'] = $permissionParam;
$contractInfo['avalaibleContactViews'][$listingTypeID]['viewsLeft'] = $contractInfo['avalaibleContactViews'][$listingTypeID]['count'] - $contractInfo['avalaibleContactViews'][$listingTypeID]['numOfViews'];
}
}
}
$contractsInfo[$key] = $contractInfo;
$contractsInfo[$key]['product_info'] = SJB_ProductsManager::getProductInfoBySID($contractInfo['extra_info']['product_sid']);
$contractSIDs[] = $contractInfo['id'];
}
$statistics = array();
foreach ($listingTypes as $listingType) {
$listingTypeID = $listingType['id'];
if ($this->acl->isAllowed('view_' . $listingTypeID . '_details')) {
$statistics['avalaibleViews'][$listingTypeID]['name'] = $listingType['name'];
$permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_details');
$statistics['avalaibleViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractSIDs, false, $listingType['sid']);
if (empty($permissionParam)) {
$statistics['avalaibleViews'][$listingTypeID]['count'] = 'unlimited';
$statistics['avalaibleViews'][$listingTypeID]['viewsLeft'] = 'unlimited';
} else {
$statistics['avalaibleViews'][$listingTypeID]['count'] = $permissionParam;
$statistics['avalaibleViews'][$listingTypeID]['viewsLeft'] = $statistics['avalaibleViews'][$listingTypeID]['count'] - $statistics['avalaibleViews'][$listingTypeID]['numOfViews'];
}
}
if ($this->acl->isAllowed('post_' . $listingTypeID)) {
$statistics['listingAmount'][$listingTypeID]['name'] = $listingType['name'];
$permissionParam = $this->acl->getPermissionParams('post_' . $listingTypeID);
$statistics['listingAmount'][$listingTypeID]['numPostings'] = SJB_ContractManager::getListingsNumberByContractSIDsListingType($contractSIDs, $listingTypeID);
if (empty($permissionParam)) {
$statistics['listingAmount'][$listingTypeID]['count'] = 'unlimited';
$statistics['listingAmount'][$listingTypeID]['listingsLeft'] = 'unlimited';
} else {
$statistics['listingAmount'][$listingTypeID]['count'] = $permissionParam;
$statistics['listingAmount'][$listingTypeID]['listingsLeft'] = $statistics['listingAmount'][$listingTypeID]['count'] - $statistics['listingAmount'][$listingTypeID]['numPostings'];
}
}
if ($this->acl->isAllowed('view_' . $listingTypeID . '_contact_info')) {
$permissionParam = $this->acl->getPermissionParams('view_' . $listingTypeID . '_contact_info');
$statistics['avalaibleContactViews'][$listingTypeID]['name'] = $listingType['name'];
$statistics['avalaibleContactViews'][$listingTypeID]['numOfViews'] = SJB_ContractManager::getNumbeOfPagesViewed($currentUser->getSID(), $contractSIDs, 'view_' . $listingTypeID . '_contact_info');
if (empty($permissionParam)) {
//.........这里部分代码省略.........