public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $errors = array(); $id = SJB_Request::getInt('id', 0, 'GET'); $action = SJB_Request::getVar('action', '', 'GET'); if ($id > 0) { // read message if (SJB_PrivateMessage::isMyMessage($id)) { if ($action == 'delete') { SJB_PrivateMessage::delete(array($id)); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/'); } $message = SJB_PrivateMessage::readMessage($id); SJB_Authorization::updateCurrentUserSession(); $current_user_info = SJB_UserManager::createTemplateStructureForCurrentUser(); $current_user_info['logged_in'] = true; $current_user_info['new_messages'] = SJB_PrivateMessage::getCountUnreadMessages($current_user_info['id']); SJB_System::setCurrentUserInfo($current_user_info); $tp->assign('message', $message); $tp->assign('include', 'message_detail.tpl'); } else { $errors['NOT_EXISTS_MESSAGE'] = 1; } } $tp->assign('errors', $errors); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('main.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $tp->display('../users/login.tpl'); } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); if (SJB_Request::getVar('pm_action', '', SJB_Request::METHOD_POST) == 'delete') { $checked = SJB_Request::getVar('pm_check', array(), SJB_Request::METHOD_POST); SJB_PrivateMessage::delete($checked); } $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET)); $messagesPerPage = SJB_Request::getInt('messagesPerPage', 10); $total = SJB_PrivateMessage::getTotalOutbox($user_id); $totalPages = ceil($total / $messagesPerPage); if ($totalPages == 0) { $totalPages = 1; } if (empty($page) || $page <= 0) { $page = 1; } if ($totalPages < $page) { SJB_HelperFunctions::redirect("?page={$totalPages}"); } $list = SJB_PrivateMessage::getListOutbox($user_id, $page, $messagesPerPage); $tp->assign('message_list', $list); $tp->assign('messagesPerPage', $messagesPerPage); $tp->assign('page', $page); $tp->assign('totalPages', $totalPages); $tp->assign('include', 'list_outbox.tpl'); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); } $tp->display('main.tpl'); }
public function execute() { if (class_exists('SJB_SocialPlugin') && in_array('linkedin', SJB_SocialPlugin::getAvailablePlugins()) && SJB_Settings::getSettingByName('li_memberProfileWidget')) { $userSID = SJB_Request::getInt('profileSID', ''); if ($userSID && ($profilePublicUrl = SJB_SocialPlugin::getProfilePublicUrlByProfileID($userSID))) { $tp = SJB_System::getTemplateProcessor(); $tp->assign('inPublicUrl', $profilePublicUrl); $tp->display('linkedin_member_profile_widget.tpl'); } } }
private function jsRate() { if (!SJB_UserManager::isUserLoggedIn()) { exit; } $listing_sid = SJB_Request::getInt('listing', 0, SJB_Request::METHOD_POST); $rate = SJB_Request::getInt('rate', 0, SJB_Request::METHOD_POST); $new_rating = SJB_Rating::setRaiting($rate, $listing_sid, SJB_UserManager::getCurrentUserSID()); if (isset($new_rating['rating'])) { echo $new_rating['rating']; } }
public function execute() { if (SJB_Request::isAjax()) { die(json_encode($this->getPayPalStateList())); } $getInvoiceId = SJB_Request::getInt('payment_id', 0, 'GET'); $this->invoice = SJB_InvoiceManager::getObjectBySID($getInvoiceId); if ($this->invoiceValidation($this->invoice)) { if ($this->isPayNowButtonPressed()) { $this->processPayNowButtonClick(); } else { $this->displayForm(); } } }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $userSID = SJB_UserManager::getCurrentUserSID(); $action = SJB_Request::getVar('pm_action', null); if ($action) { $checked = SJB_Request::getVar('pm_check', array(), 'POST'); switch ($action) { case 'delete': SJB_PrivateMessage::deleteContact($userSID, $checked); break; case 'save_contact': $error = ''; $contactSID = SJB_Request::getInt('user_id', 0); SJB_PrivateMessage::saveContact($userSID, $contactSID, $error); $tp->assign('error', $error); $tp->display('contact_save.tpl'); return true; break; default: break; } } $page = SJB_Request::getInt('page', 1, 'GET'); $contactsPerPage = SJB_Request::getInt('contactsPerPage', 10); SJB_PrivateMessage::deleteNonexistentContacts($userSID); $total = SJB_PrivateMessage::getTotalContacts($userSID); $totalPages = ceil($total / $contactsPerPage); if ($totalPages == 0) { $totalPages = 1; } if (empty($page) || $page <= 0) { $page = 1; } if ($totalPages < $page) { SJB_HelperFunctions::redirect("?page={$totalPages}"); } $tp->assign('message_list', SJB_PrivateMessage::getContacts($userSID, $page, $contactsPerPage)); $tp->assign('contactsPerPage', $contactsPerPage); $tp->assign('page', $page); $tp->assign('totalPages', $totalPages); $tp->assign('include', 'contacts.tpl'); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($userSID)); } $tp->display('main.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $action = SJB_Request::getVar('pm_action', SJB_Request::METHOD_POST, false); if ($action) { $checked = SJB_Request::getVar('pm_check', SJB_Request::METHOD_POST, array()); switch ($action) { case 'mark': SJB_PrivateMessage::markAsRead($checked); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/'); break; case 'delete': SJB_PrivateMessage::delete($checked); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/'); break; default: break; } } $page = SJB_Request::getInt('page', 1, 'GET'); $messagesPerPage = SJB_Request::getInt('messagesPerPage', 10); $total = SJB_PrivateMessage::getTotalInbox($user_id); $totalPages = ceil($total / $messagesPerPage); if ($totalPages == 0) { $totalPages = 1; } if (empty($page) || $page <= 0) { $page = 1; } if ($totalPages < $page) { SJB_HelperFunctions::redirect("?page={$totalPages}"); } $tp->assign('message_list', SJB_PrivateMessage::getListInbox($user_id, $page, $messagesPerPage)); $tp->assign('include', 'list_inbox.tpl'); $tp->assign('messagesPerPage', $messagesPerPage); $tp->assign('page', $page); $tp->assign('totalPages', $totalPages); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); } $tp->display('main.tpl'); }
public function execute() { $this->tp = SJB_System::getTemplateProcessor(); $passedParametersViaUri = SJB_UrlParamProvider::getParams(); $promotionSID = array_shift($passedParametersViaUri); $promotionCodeInfo = SJB_PromotionsManager::getCodeInfoBySID($promotionSID); $this->tp->assign('promotionInfo', $promotionCodeInfo); if (!$promotionCodeInfo) { array_push($this->errors, 'INVALID_ID'); } $page = SJB_Request::getInt('page', 1); $itemsPerPage = SJB_Request::getInt('items_per_page', 50); $itemsCount = SJB_PromotionsManager::getHistoryCountBySID($promotionSID); $this->assignParametersForPagination($page, $itemsPerPage, $itemsCount); $promotions = SJB_PromotionsManager::getHistoryBySID($promotionSID, $page, $itemsPerPage); SJB_PromotionsManager::preparePromotionsInfoForLog($promotions); $currency = SJB_CurrencyManager::getDefaultCurrency(); $this->tp->assign('currency', $currency); $this->tp->assign('promotions', $promotions); $this->tp->assign('errors', $this->errors); $this->tp->display('promotions_log.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); $action = SJB_Request::getVar('action_name', false); $action = $action ? $action : 'list'; $template = 'manage_polls.tpl'; $errors = array(); switch ($action) { case 'new': $template = 'input_form_poll.tpl'; $_REQUEST['start_date'] = date('Y-m-d'); $field = new SJB_PollsManager($_REQUEST); $form = new SJB_Form($field); $form->registerTags($tp); $tp->assign('form_fields', $form->getFormFieldsInfo()); break; case 'save': $sid = SJB_Request::getVar('sid'); $_REQUEST['value'] = strip_tags(SJB_Request::getVar('value')); $_REQUEST['user_group_sid'] = SJB_Request::getInt('user_group_sid', 0); $field = new SJB_PollsManager($_REQUEST); if ($sid) { $field->setSID($sid); } $form = new SJB_Form($field); if ($form->isDataValid($errors)) { SJB_PollsManager::savePoll($field); $_REQUEST['sid'] = $field->sid; $save = SJB_Request::getVar('save', false); $action = 'edit'; if ($save) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/manage-polls/'); break; } } else { $action = 'new'; if ($sid) { $action = 'edit'; } $template = 'input_form_poll.tpl'; $field->setSID($sid); $form->registerTags($tp); $tp->assign('form_fields', $form->getFormFieldsInfo()); $tp->assign('errors', $errors); $tp->assign('sid', $sid); break; } case 'edit': $sid = SJB_Request::getVar('sid'); $info = SJB_PollsManager::getPollInfoBySID($sid); $field = new SJB_PollsManager($info); $edit_form = new SJB_Form($field); $edit_form->registerTags($tp); $field->setSID($sid); $tp->assign('form_fields', $edit_form->getFormFieldsInfo()); $tp->assign('sid', $sid); $tp->assign('action', 'edit'); $template = 'input_form_poll.tpl'; break; case 'edit_answer': $sid = SJB_Request::getVar('sid'); $_REQUEST['field_sid'] = $sid; $event = SJB_Request::getVar('event'); $pollInfo = SJB_PollsManager::getPollInfoBySID($sid); $edit_list_controller = new SJB_PollsEditListController($_REQUEST, $pollInfo); switch ($event) { case 'add': $item_sid = SJB_Request::getVar('item_sid'); if ($edit_list_controller->isValidValueSubmitted()) { if ($item_sid) { $pollItemManager = new SJB_PollsListItemManager(); $list_item = $pollItemManager->getListItemBySID($item_sid); $list_item->setValue(trim($_REQUEST['list_item_value'])); $pollItemManager->saveListItem($list_item); } else { if (!$edit_list_controller->saveItem()) { $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS'); } } } else { $tp->assign('error', 'LIST_VALUE_IS_EMPTY'); } break; case 'edit': $item_sid = SJB_Request::getVar('item_sid'); $pollItemManager = new SJB_PollsListItemManager(); $list_item = $pollItemManager->getListItemBySID($item_sid); $tp->assign('item_sid', $list_item->sid); $tp->assign('item_value', $list_item->value); $tp->assign('item_action', 'edit'); break; case 'add_multiple': if ($edit_list_controller->isValidMultiValueSubmitted()) { if (!$edit_list_controller->saveItem(true)) { $tp->assign('error', 'LIST_VALUE_ALREADY_EXISTS'); } } else { $tp->assign('error', 'LIST_VALUE_IS_EMPTY'); } break; case 'delete': $item_sid = SJB_Request::getVar('item_sid'); if (is_array($item_sid)) { foreach ($item_sid as $sid => $val) { $edit_list_controller->deleteItem($sid); } } else { $edit_list_controller->deleteItem(); } break; case 'move_up': $edit_list_controller->moveUpItem(); break; case 'move_down': $edit_list_controller->moveDownItem(); break; case 'save_order': if ($item_order = SJB_Request::getVar('item_order', false)) { $edit_list_controller->saveNewItemsOrder($item_order); } break; case 'sort': $edit_list_controller->sortItems(SJB_Request::getVar('field_sid'), SJB_Request::getVar('sorting_order')); $tp->assign('sorting_order', SJB_Request::getVar('sorting_order')); break; } $display_list_controller = new SJB_PollsDisplayListController($_REQUEST, $pollInfo); $display_list_controller->setTemplateProcessor($tp); $display_list_controller->display('edit_answer.tpl'); break; case 'delete': $sid = SJB_Request::getVar('sid', false); $sids = SJB_Request::getVar('polls', false); if ($sid) { SJB_PollsManager::deletePollBySID($sid); } else { if ($sids) { foreach ($sids as $sid => $val) { SJB_PollsManager::deletePollBySID($sid); } } else { $errors[] = 'NO_POLLS_SELECTED'; } } $action = 'list'; break; case 'activate': $sids = SJB_Request::getVar('polls'); if (is_array($sids)) { foreach ($sids as $sid => $val) { SJB_PollsManager::activatePollBySID($sid); } } else { $errors[] = 'NO_POLLS_SELECTED'; } $action = 'list'; break; case 'deactivate': $sids = SJB_Request::getVar('polls'); if (is_array($sids)) { foreach ($sids as $sid => $val) { SJB_PollsManager::deactivatePollBySID($sid); } } else { $errors[] = 'NO_POLLS_SELECTED'; } $action = 'list'; break; case 'save_display_setting': $settings = SJB_Request::getVar('settings'); SJB_Settings::updateSettings($settings); $action = 'list'; break; case 'view_results': $sid = SJB_Request::getVar('sid', 0); $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]['width'] = $countVotes > 0 ? round(300 / $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('count_vote', $countVotes); $template = 'view_result.tpl'; break; } if ($action == 'list') { $paginator = new SJB_PollsManagePagination(); $pollsCount = 0; $pollsInfo = SJB_PollsManager::getPollsInfo($paginator->sortingField, $paginator->sortingOrder, ($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage, $pollsCount); $paginator->setItemsCount($pollsCount); $showPollsOnMainPage = SJB_Settings::getSettingByName('show_polls_on_main_page'); $tp->assign('errors', $errors); $tp->assign('frontendLanguages', SJB_ObjectMother::createI18N()->getActiveFrontendLanguagesData()); $tp->assign('pollsInfo', $pollsInfo); $tp->assign('show_polls_on_main_page', $showPollsOnMainPage); $tp->assign('paginationInfo', $paginator->getPaginationInfo()); } if ($action !== 'edit_answer') { $tp->assign('action', $action); $tp->assign('polls', 1); $tp->display($template); } }
public function execute() { $field_sid = isset($_REQUEST['field_sid']) ? $_REQUEST['field_sid'] : null; $field_info = SJB_UserProfileFieldManager::getFieldInfoBySID($field_sid); $node_sid = isset($_REQUEST['node_sid']) ? $_REQUEST['node_sid'] : 0; $user_group_sid = isset($_REQUEST['user_group_sid']) ? $_REQUEST['user_group_sid'] : null; $user_group_info = SJB_UserGroupManager::getUserGroupInfoBySID($user_group_sid); if (empty($field_info)) { $errors['INVALID_FIELD_SID'] = 1; } else { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { $tree_item_value = $_REQUEST['tree_item_value']; $order = $_REQUEST['order']; if ($tree_item_value == '') { $field_errors['Value'] = 'EMPTY_VALUE'; } else { if ($order == 'begin') { SJB_UserProfileFieldManager::addTreeItemToBeginByParentSID($field_sid, $node_sid, $tree_item_value); } elseif ($order == 'end') { SJB_UserProfileFieldManager::addTreeItemToEndByParentSID($field_sid, $node_sid, $tree_item_value); } elseif ($order == 'after') { $after_tree_item_sid = $_REQUEST['after_tree_item_sid']; SJB_UserProfileFieldManager::addTreeItemAfterByParentSID($field_sid, $node_sid, $tree_item_value, $after_tree_item_sid); } $treeLevelsNumber = SJB_UserProfileFieldTreeManager::getTreeDepthBySID($field_sid); SJB_UserProfileFieldManager::addLevelField($treeLevelsNumber); } } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'save') { $tree_item_value = $_REQUEST['tree_item_value']; if (empty($tree_item_value)) { $field_errors['Value'] = 'EMPTY_VALUE'; } else { SJB_UserProfileFieldManager::updateTreeItemBySID($node_sid, $tree_item_value); $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : null; if ($order == 'begin') { SJB_UserProfileFieldManager::moveTreeItemToBeginBySID($node_sid); } elseif ($order == 'end') { SJB_UserProfileFieldManager::moveTreeItemToEndBySID($node_sid); } elseif ($order == 'after') { $after_tree_item_sid = $_REQUEST['after_tree_item_sid']; SJB_UserProfileFieldManager::moveTreeItemAfterBySID($node_sid, $after_tree_item_sid); } } } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { $item_sid = isset($_REQUEST['item_sid']) ? $_REQUEST['item_sid'] : null; SJB_UserProfileFieldManager::deleteTreeItemBySID($item_sid); } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'move_up') { $item_sid = isset($_REQUEST['item_sid']) ? $_REQUEST['item_sid'] : null; SJB_UserProfileFieldManager::moveUpTreeItem($item_sid); } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'move_down') { $item_sid = isset($_REQUEST['item_sid']) ? $_REQUEST['item_sid'] : null; SJB_UserProfileFieldManager::moveDownTreeItem($item_sid); } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add_multiple') { $node_sid = isset($_REQUEST['node_sid']) ? SJB_Request::getInt('node_sid') : 0; $item_sid = SJB_Request::getVar('field_sid'); $tree_item_value = SJB_Request::getVar('tree_multiItem_value', false); $after_tree_item_sid = SJB_Request::getVar('after_tree_item_sid', 0); $order = SJB_Request::getVar('order', false); if ($tree_item_value == '') { $field_errors['Value'] = 'EMPTY_VALUE'; } SJB_UserProfileFieldTreeManager::addMultupleTreeItem($item_sid, $node_sid, $tree_item_value, $order, $after_tree_item_sid); } $tree_items = SJB_UserProfileFieldManager::getTreeValuesByParentSID($field_sid, $node_sid); $parent_sid = SJB_UserProfileFieldManager::getTreeParentSID($node_sid); $tree_parent_items = SJB_UserProfileFieldManager::getTreeValuesByParentSID($field_sid, $parent_sid); } $tp = SJB_System::getTemplateProcessor(); $tp->assign("field_sid", $field_sid); $tp->assign("node_sid", $node_sid); $tp->assign("user_group_sid", $user_group_sid); $tp->assign("user_group_info", $user_group_info); $tp->assign("field_info", $field_info); $tp->assign("tree_parent_items", $tree_parent_items); $tp->assign("tree_items", $tree_items); $node_info = SJB_UserProfileFieldManager::getTreeItemInfoBySID($node_sid); $node_path = SJB_UserProfileFieldManager::getTreeNodePath($node_sid); $node_path[0] = array('caption' => 'Root', 'sid' => 0); $node_info['node_path'] = $node_path; $tp->assign("node_info", $node_info); $current_level = isset($node_info['level']) ? $node_info['level'] : 0; $tp->assign("current_level", $current_level); $tp->assign("errors", isset($errors) ? $errors : null); $tp->assign("field_errors", isset($field_errors) ? $field_errors : null); $tp->display("edit_tree.tpl"); }
public function execute() { $field_sid = SJB_Request::getVar('field_sid', null); $field_info = SJB_ListingFieldManager::getFieldInfoBySID($field_sid); $node_sid = SJB_Request::getVar('node_sid', 0); $action = SJB_Request::getVar('action'); $template_processor = SJB_System::getTemplateProcessor(); if (empty($field_info)) { $errors['INVALID_FIELD_SID'] = 1; } else { switch ($action) { case 'add': $tree_item_value = $_REQUEST['tree_item_value']; $order = $_REQUEST['order']; if ($tree_item_value == '') { $field_errors['Value'] = 'EMPTY_VALUE'; } else { if ($order == 'begin') { SJB_ListingFieldManager::addTreeItemToBeginByParentSID($field_sid, $node_sid, $tree_item_value); } elseif ($order == 'end') { SJB_ListingFieldManager::addTreeItemToEndByParentSID($field_sid, $node_sid, $tree_item_value); } elseif ($order == 'after') { $after_tree_item_sid = $_REQUEST['after_tree_item_sid']; SJB_ListingFieldManager::addTreeItemAfterByParentSID($field_sid, $node_sid, $tree_item_value, $after_tree_item_sid); } $treeLevelsNumber = SJB_ListingFieldTreeManager::getTreeDepthBySID($field_sid); SJB_ListingFieldManager::addLevelField($treeLevelsNumber); } break; case 'save': $tree_item_value = $_REQUEST['tree_item_value']; if (empty($tree_item_value)) { $field_errors['Value'] = 'EMPTY_VALUE'; } else { SJB_ListingFieldManager::updateTreeItemBySID($node_sid, $tree_item_value); $order = SJB_Request::getVar('order', null); if ($order == 'begin') { SJB_ListingFieldManager::moveTreeItemToBeginBySID($node_sid); } elseif ($order == 'end') { SJB_ListingFieldManager::moveTreeItemToEndBySID($node_sid); } elseif ($order == 'after') { $after_tree_item_sid = $_REQUEST['after_tree_item_sid']; SJB_ListingFieldManager::moveTreeItemAfterBySID($node_sid, $after_tree_item_sid); } } break; case 'delete': $item_sid = SJB_Request::getVar('item_sid'); if (is_array($item_sid)) { foreach ($item_sid as $sid => $val) { SJB_ListingFieldManager::deleteTreeItemBySID($sid); } } else { if (isset($item_sid)) { SJB_ListingFieldManager::deleteTreeItemBySID($item_sid); } } break; case 'move_up': $item_sid = SJB_Request::getVar('item_sid'); SJB_ListingFieldManager::moveUpTreeItem($item_sid); break; case 'move_down': $item_sid = SJB_Request::getVar('item_sid'); SJB_ListingFieldManager::moveDownTreeItem($item_sid); break; case 'save_order': $item_order = SJB_Request::getVar('item_order', array()); SJB_ListingFieldManager::saveNewTreeItemsOrder($item_order); break; case 'sort': $node_sid = isset($_REQUEST['node_sid']) ? SJB_Request::getInt('node_sid') : 0; SJB_ListingFieldManager::sortTreeItems(SJB_Request::getVar('field_sid'), $node_sid, SJB_Request::getVar('sorting_order')); $template_processor->assign("sorting_order", SJB_Request::getVar('sorting_order')); break; case 'add_multiple': $node_sid = isset($_REQUEST['node_sid']) ? SJB_Request::getInt('node_sid') : 0; $item_sid = SJB_Request::getVar('field_sid'); $tree_item_value = SJB_Request::getVar('tree_multiItem_value', false); $after_tree_item_sid = SJB_Request::getVar('after_tree_item_sid', 0); $order = SJB_Request::getVar('order', false); if ($tree_item_value == '') { $field_errors['Value'] = 'EMPTY_VALUE'; } SJB_ListingFieldTreeManager::addMultupleTreeItem($item_sid, $node_sid, $tree_item_value, $order, $after_tree_item_sid); break; } $tree_items = SJB_ListingFieldManager::getTreeValuesByParentSID($field_sid, $node_sid); $parent_sid = SJB_ListingFieldManager::getTreeParentSID($node_sid); $tree_parent_items = SJB_ListingFieldManager::getTreeValuesByParentSID($field_sid, $parent_sid); } $template_processor->assign("field_sid", $field_sid); $template_processor->assign("node_sid", $node_sid); $template_processor->assign("field_info", $field_info); $template_processor->assign("tree_parent_items", $tree_parent_items); $template_processor->assign("tree_items", $tree_items); $node_info = SJB_ListingFieldManager::getTreeItemInfoBySID($node_sid); $node_path = SJB_ListingFieldManager::getTreeNodePath($node_sid); $node_path[0] = array('caption' => 'Root', 'sid' => 0); $node_info['node_path'] = $node_path; $template_processor->assign("node_info", $node_info); $current_level = isset($node_info['level']) ? $node_info['level'] : 0; $template_processor->assign("current_level", $current_level); $template_processor->assign("type_sid", $field_info['listing_type_sid']); $listing_type_info = SJB_ListingTypeManager::getListingTypeInfoBySID($field_info['listing_type_sid']); $template_processor->assign("type_info", $listing_type_info); $template_processor->assign("errors", isset($errors) ? $errors : null); $template_processor->assign("field_errors", isset($field_errors) ? $field_errors : null); $template_processor->display("edit_tree.tpl"); }
public function execute() { set_time_limit(0); ini_set('memory_limit', -1); $tp = SJB_System::getTemplateProcessor(); $user_groups_info = SJB_UserGroupManager::getAllUserGroupsInfo(); $user_group_info = reset($user_groups_info); $user_group_sid = $user_group_info['sid']; $fields_info = SJB_UserProfileFieldManager::getFieldsInfoByUserGroupSID($user_group_sid); $fields = array(); $tp->assign('test_message', SJB_Request::getVar('test_message', false)); $tp->assign('undeliveredMailingsForTest', SJB_Request::getVar('undeliveredMailingsForTest', false)); foreach ($fields_info as $key => $val) { if ($val['id'] == 'Location') { foreach ($val['fields'] as $field) { if ($field['id'] == 'Country') { $fields['country'] = SJB_CountriesManager::getAllCountriesCodesAndNames(); } elseif ($field['id'] == 'State') { $fields['state'] = SJB_StatesManager::getStatesNamesByCountry(); } } } } $tp->assign('fields', $fields); $errors = array(); $errorId = SJB_Request::getVar('error', null, 'GET'); if ($errorId) { $errors[$errorId] = 1; } if (isset($_REQUEST['submit']) && $_FILES['file_mail']['name'] && $_FILES['file_mail']['error']) { $errorId = SJB_UploadFileManager::getErrorId($_FILES['file_mail']['error']); if ($_REQUEST['submit'] != 'save') { $mailID = SJB_Request::getVar('mail_id', 0); $parameter = $mailID ? '?edit=' . $mailID : ''; SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/' . $parameter . '&error=' . $errorId); } $errors[$errorId] = 1; } else { if (isset($_REQUEST['submit'])) { SJB_DB::query("DELETE FROM uploaded_files WHERE id = 'file_mail'"); $upload_manager = new SJB_UploadFileManager(); $upload_manager->setFileGroup('files'); $upload_manager->setUploadedFileID('file_mail'); $upload_manager->uploadFile('file_mail'); $file_name = ''; if (!isset($_REQUEST['delete_file']) && isset($_REQUEST['old_file']) && !$upload_manager->getUploadedFileName('file_mail')) { $file_name = $_REQUEST['old_file']; } elseif ($upload_manager->getUploadedFileName('file_mail')) { $file_name = "files/files/" . $upload_manager->getUploadedSavedFileName('file_mail'); } $language = SJB_Request::getVar('language', 'any'); $users = SJB_Request::getVar('users', 'any'); $without_cv = SJB_Request::getVar('without_cv', false); $country = SJB_Request::getVar('country', ''); $state = SJB_Request::getVar('state', ''); $city = SJB_Request::getVar('city', ''); $products = SJB_Request::getVar('products', array()); $user_status = SJB_Request::getVar('user_status', ''); $registration_date = SJB_Request::getVar('registration_date', array()); $param = serialize(array('language' => $language, 'users' => $users, 'without_cv' => $without_cv, 'products' => $products, 'country' => $country, 'state' => $state, 'city' => $city, 'status' => $user_status, 'registration' => $registration_date)); $email = ''; $mailSubject = SJB_Request::getVar('subject', ''); $mailText = stripcslashes(SJB_Request::getVar('text', '')); $mailID = SJB_Request::getVar('mail_id', 0); if ($mailID) { SJB_DB::query('UPDATE `mailing` SET `subject` = ?s, `text` = ?s, `email` = ?s, `file` = ?s, `param` = ?s WHERE `id` = ?s', $mailSubject, $mailText, $email, $file_name, $param, $mailID); } else { $query = "INSERT INTO mailing ( email , subject , text , file, param) VALUES ( ?s, ?s, ?s, ?s, ?s)"; SJB_DB::query($query, $email, $mailSubject, $mailText, $file_name, $param); } if ($_REQUEST['submit'] == 'save') { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/'); } else { $parameter = $mailID ? '?edit=' . $mailID : ''; SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/' . $parameter); } } } if (SJB_Request::getVar('delete')) { $mailings = SJB_Request::getVar('mailing'); if (is_array($mailings)) { foreach ($mailings as $id => $value) { SJB_DB::query('DELETE FROM `mailing` WHERE `id` = ?n', $id); SJB_DB::query('DELETE FROM `mailing_info` WHERE `mailing_id` = ?n', $id); } } else { $idToDelete = SJB_Request::getInt('delete', 0); SJB_DB::query('DELETE FROM `mailing` WHERE `id` = ?n', $idToDelete); SJB_DB::query('DELETE FROM `mailing_info` WHERE `mailing_id` = ?n', $idToDelete); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/'); } if (isset($_REQUEST['edit'])) { $idToEdit = SJB_Request::getInt('edit', 0); $mail_arr = SJB_DB::query('SELECT * FROM mailing WHERE id = ?n', $idToEdit); $tp->assign("mail_id", $mail_arr[0]['id']); $tp->assign("subject", $mail_arr[0]['subject']); $tp->assign("text", $mail_arr[0]['text']); $tp->assign("file", $mail_arr[0]['file']); $tp->assign("file_url", $mail_arr[0]['file']); $tp->assign("param", unserialize($mail_arr[0]['param'])); } // get products by UserGroup ID if (SJB_Request::isAjax()) { $userGroupID = SJB_Request::getVar('usergr', 0); if ($userGroupID > 0) { $products = SJB_ProductsManager::getProductsInfoByUserGroupSID($userGroupID); } else { $products = SJB_ProductsManager::getAllProductsInfo(); } $tp->assign("products", $products); $tp->display("mailing_products.tpl"); exit; } $mail_list = SJB_DB::query('SELECT * FROM mailing'); foreach ($mail_list as $key => $var) { $param = unserialize($mail_list[$key]['param']); $where = ''; $join = ''; $numSentEmails = SJB_DB::queryValue('SELECT count(*) FROM `mailing_info` WHERE `mailing_id` = ?n AND `status`=0', $var['id']); if ($param["language"] != 'any') { $where .= " and language='{$param['language']}'"; } if ($param["users"] != '0') { $where .= ' and u.user_group_sid=' . $param['users']; } if ($param["without_cv"]) { $join = "left join listings l on l.user_sid = u.sid"; $where .= " and l.sid is null"; } // user status if (!empty($param['status'])) { $where .= ' and `u`.`active`=' . (int) $param['status']; } // registration date if (!empty($param['registration']) && is_array($param['registration'])) { $i18n = SJB_I18N::getInstance(); if (!empty($param['registration']['not_less'])) { $where .= ' AND `u`.`registration_date` > \'' . $i18n->getInput('date', $param['registration']['not_less']) . '\''; } if (!empty($param['registration']['not_more'])) { $where .= ' AND `u`.`registration_date` < \'' . $i18n->getInput('date', $param['registration']['not_more']) . '\''; } } // products if (!empty($param['products'])) { $join .= "\n LEFT JOIN contracts ON u.sid = contracts.user_sid\n LEFT JOIN products ON products.sid = contracts.product_sid\n "; $whereProduct = array(); foreach ($param['products'] as $theProduct) { $theProduct = (int) $theProduct; if (!empty($theProduct)) { $whereProduct[] .= "products.sid = '{$theProduct}'"; } else { $whereProduct[] .= 'products.sid IS NULL'; } } if (!empty($whereProduct)) { $where .= ' AND (' . implode(' OR ', $whereProduct) . ')'; } } /// products if (!empty($param['country']) || !empty($param['state'])) { if (!empty($param['country'])) { $where_country = array(); foreach ($param['country'] as $the_country) { if (!empty($the_country)) { $where_country[] .= "`u`.`Location_Country` = '{$the_country}'"; } else { $where_country[] .= "`u`.`Location_Country` IS NULL"; } } if (!empty($where_country)) { $where .= ' AND (' . implode(' OR ', $where_country) . ')'; } } if (!empty($param['state'])) { $where_state = array(); foreach ($param['state'] as $the_state) { if (!empty($the_state)) { $where_state[] .= "`u`.`Location_State` = '{$the_state}'"; } else { $where_state[] .= "`u`.`Location_State` IS NULL"; } } } if (!empty($where_state)) { $where .= ' AND (' . implode(' OR ', $where_state) . ')'; } if (!empty($param['city'])) { $where .= " AND `u`.`Location_City` = '{$param['city']}'"; } } $mail_list[$key]['not_send'] = $numSentEmails; $mail_list[$key]['mail_arr'] = SJB_DB::query("\n SELECT u.sid as sid, u.username, u.user_group_sid, u.language\n FROM users u\n {$join}\n WHERE u.sendmail = 0\n {$where}\n GROUP BY `u`.`sid`"); $mail_list[$key]['count'] = count($mail_list[$key]['mail_arr']); } /* * test sending */ $testMailingID = SJB_Request::getVar('test_send', 0); if ($testMailingID) { if ($this->isTestEmailValid()) { $testSendResult = false; $oMailing = new SJB_Mailing($testMailingID); $mailings = SJB_Request::getVar('mailing'); if (is_array($mailings)) { foreach ($mailings as $id => $value) { $oMailing->setMailingID($id); $oMailing->setMailingList($mail_list); if ($oMailing->testSend()) { $testSendResult = true; } } } else { $oMailing->setMailingList($mail_list); $testSendResult = $oMailing->testSend(); } if ($testSendResult) { SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/mailing/?test_message=1'); } else { $email = urlencode(SJB_Request::getString('email', false)); SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/mailing/?undeliveredMailingsForTest={$email}"); } } else { $tp->assign('testEmailNotValid', true); } } // general sending $sendToMailingID = SJB_Request::getVar('sending', 0); $sendResult = false; if ($sendToMailingID) { $oMailing = new SJB_Mailing($sendToMailingID); $mailings = SJB_Request::getVar('mailing'); $undeliveredMailingsInfo = array(); if (is_array($mailings)) { foreach ($mailings as $id => $value) { $oMailing->setMailingID($id); $oMailing->setMailingList($mail_list); $countOfSendMailings = $oMailing->send(); if ($countOfSendMailings != 0) { $sendResult = true; } $undeliveredMailingsInfo = array_merge($oMailing->getUndeliveredMailingsInfo(), $undeliveredMailingsInfo); } } else { $oMailing->setMailingList($mail_list); $countOfSendMailings = $oMailing->send(); if ($countOfSendMailings != 0) { $sendResult = true; } $undeliveredMailingsInfo = $oMailing->getUndeliveredMailingsInfo(); } if ($sendResult) { $tp->assign('send_result', $sendResult); } if (count($undeliveredMailingsInfo)) { $tp->assign("UndeliveredMailings", $oMailing->getUndeliveredMailingsInfo()); } } // send mailing to undelivered $sendToUndeliveredMailingID = SJB_Request::getVar('sendToUndeliveredEmails', 0); if (!empty($sendToUndeliveredMailingID)) { $oMailing = new SJB_Mailing($sendToUndeliveredMailingID); $oMailing->setMailingList($mail_list); $oMailing->sendToUndelivered(); if ($oMailing->getUndeliveredMailingsInfo()) { $tp->assign("UndeliveredMailings", $oMailing->getUndeliveredMailingsInfo()); } } $groups = SJB_DB::query("SELECT * FROM `user_groups`"); $products = SJB_ProductsManager::getAllProductsInfo(); $testEmail = SJB_Settings::getSettingByName('test_email'); $tp->assign('test_email', $testEmail); $tp->assign("products", $products); $tp->assign("groups", $groups); $tp->assign("mail_list", $mail_list); $tp->assign('errors', $errors); $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize()); $tp->display("mailing.tpl"); }
public function displayAsSelectBoxes() { $parentSID = SJB_Request::getInt('parentSID'); $this->_treeValues = $this->_treeManager->getTreeItemsByParentSIDAndFieldSID($this->_fieldSID, $parentSID); if (!empty($this->_treeValues)) { $level = $this->_treeValues[$parentSID][0]['level']; $aLevel = $this->_treeManager->getTreePropertyByTreeSID($this->_fieldSID); $levelCaption = SJB_Array::get($aLevel, 'level_' . $level); } else { return false; } // TRANSLATE & Order BY Alphabet $this->translateAndMakeOrderTreeValues(); $this->prepareValuesForDisplayAsTreeSearchForm(); $tp = SJB_System::getTemplateProcessor(); $tp->assign('tree_values', $this->_treeValues); $tp->assign('levelName', $levelCaption); $tp->assign('level', $level); $tp->assign('has_child', true); $tp->assign('fieldSID', $this->_fieldSID); $tp->assign('name', $this->_fieldName); $tp->assign('checked', $this->_checked); $tp->display('tree_display_as_select.tpl'); }
public function execute() { $tp = SJB_System::getTemplateProcessor(); if (SJB_UserManager::isUserLoggedIn()) { $user_id = SJB_UserManager::getCurrentUserSID(); $id = SJB_Request::getInt('id', 0, 'GET'); if ($id > 0) { $errors = array(); if (isset($_POST['form_to'])) { $to_user_name = isset($_POST['form_to']) ? strip_tags($_POST['form_to']) : ''; $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name); $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0; $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : ''; $text = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : ''; $save = isset($_POST['form_save']) ? true : false; $reply_id = isset($_POST['reply_id']) ? $_POST['reply_id'] : false; if ($to_user == 0) { $errors['form_to'] = 'You specified wrong username'; } if (empty($subject)) { $errors['form_subject'] = 'Please, enter message subject'; } if (empty($text)) { $errors['form_message'] = 'Please, enter message'; } if (count($errors) == 0) { $anonym = SJB_Request::getVar('anonym'); SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $text, $save, $reply_id, false, $anonym); // save to contacts if (!$anonym) { SJB_PrivateMessage::saveContact($user_id, $to_user); SJB_PrivateMessage::saveContact($to_user, $user_id); } SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/'); } else { $message['to_name'] = htmlentities($to_user_name, ENT_QUOTES, "UTF-8"); $message['subject'] = htmlentities($subject, ENT_QUOTES, "UTF-8"); $message['message'] = $text; $tp->assign('save', $save); } } else { if (SJB_PrivateMessage::isMyMessage($id)) { $message = SJB_PrivateMessage::readMessage($id); } else { $errors['NOT_EXISTS_MESSAGE'] = 1; $message = ''; } if ($message) { $message['to_name'] = htmlentities($message['from_name'], ENT_QUOTES, "UTF-8"); $message['subject'] = 'RE: ' . htmlentities($message['subject'], ENT_QUOTES, "UTF-8"); $message['message'] = '<p> </p><blockquote class="pmQuote">' . $message['message'] . '</blockquote>'; } $tp->assign('reply_id', $id); } } $tp->assign('errors', $errors); $tp->assign('include', 'reply_message.tpl'); $tp->assign('message', $message); $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id)); $tp->display('main.tpl'); } else { $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis())); $tp->display('../users/login.tpl'); } }
private function setPaymentStatus() { $invoiceSid = SJB_Request::getInt('item_number', null); if (is_null($invoiceSid)) { $this->errors['INVOICE_ID_IS_NOT_SET'] = 1; return null; } $invoice = SJB_InvoiceManager::getObjectBySID($invoiceSid); $status = false; if (is_null($invoice)) { $this->errors['NONEXISTED_INVOICE_ID_SPECIFIED'] = 1; return null; } if ($invoice->isRecurring()) { foreach ($this->httpParsedResponseOfRecurring as $key => $response) { if (in_array(strtoupper($response['ACK']), array('SUCCESS', 'SUCCESSWITHWARNING'))) { $status = true; } } if ($status == true) { $invoice->setStatus(SJB_Invoice::INVOICE_STATUS_PENDING); } else { $invoice->setStatus(SJB_Invoice::INVOICE_STATUS_UNPAID); } SJB_InvoiceManager::saveInvoice($invoice); } else { $invoice->setCallbackData($this->httpParsedResponseAr); if (in_array(strtoupper($this->httpParsedResponseAr['ACK']), array('SUCCESS', 'SUCCESSWITHWARNING'))) { $invoice->setStatus(SJB_Invoice::INVOICE_STATUS_VERIFIED); } else { $invoice->setStatus(SJB_Invoice::INVOICE_STATUS_UNPAID); } SJB_InvoiceManager::saveInvoice($invoice); } }