예제 #1
0
 public static function editCaptcha($info)
 {
     $captchaType = !empty($info['type']) ? $info['type'] : '';
     $info['template'] = '../../../system/plugins/captcha/edit_captcha.tpl';
     $event = !empty($info['event']) ? $info['event'] : false;
     $settings = array();
     $errors = array();
     switch ($captchaType) {
         case 'reCaptcha':
             if ($event == 'save' && !empty($info['settings'])) {
                 foreach ($info['settings'] as $setting => $val) {
                     if ($val == '') {
                         $errors[$setting] = 'empty';
                     }
                 }
                 if (!$errors) {
                     SJB_Settings::updateSettings($info['settings']);
                     if (SJB_Request::getVar('submit') == 'save') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/system/miscellaneous/plugins/?action=settings&plugin=CaptchaPlugin');
                     }
                 }
             }
             $settings = array(array('id' => 'reCaptchaPubkey', 'caption' => 'Public Key', 'type' => 'string', 'length' => '50', 'order' => null, 'comment' => 'To get these Keys go to http://google.com/recaptcha/admin/create,<br/> register/sign in and then create a reCAPTCHA key following the given instructions.'), array('id' => 'reCaptchaPrivkey', 'caption' => 'Private Key', 'type' => 'string', 'length' => '50', 'order' => null, 'comment' => 'To get these Keys go to http://google.com/recaptcha/admin/create,<br/> register/sign in and then create a reCAPTCHA key following the given instructions.'), array('id' => 'reCaptchaTheme', 'caption' => 'Theme', 'type' => 'list', 'list_values' => array(array('id' => 'red', 'caption' => 'red'), array('id' => 'white', 'caption' => 'white'), array('id' => 'blackglass', 'caption' => 'blackglass'), array('id' => 'clean', 'caption' => 'clean')), 'length' => '50', 'order' => null));
             break;
         case 'customCaptcha':
             if ($event == 'save' && !empty($info['settings'])) {
                 foreach ($info['settings'] as $setting => $val) {
                     if ($val == '') {
                         $errors[$setting] = 'empty';
                     }
                 }
                 if (!$errors) {
                     SJB_Settings::updateSettings($info['settings']);
                     if (SJB_Request::getVar('submit') == 'save') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/system/miscellaneous/plugins/?action=settings&plugin=CaptchaPlugin');
                     }
                 }
             }
             $fontsDir = dir(SJB_BASE_DIR . "system/plugins/captcha/fonts");
             $fonts = array();
             $i = 0;
             while (false !== ($entry = $fontsDir->read())) {
                 if (strstr($entry, '.ttf') || strstr($entry, '.TTF')) {
                     $fonts[$i]['id'] = $fonts[$i]['caption'] = str_replace('.TTF', '', str_replace('.ttf', '', $entry));
                     $i++;
                 }
             }
             $settings = array(array('id' => 'custCaptchaFont', 'caption' => 'Font', 'type' => 'list', 'length' => '50', 'list_values' => $fonts, 'order' => null), array('id' => 'custCaptchaFontSize', 'caption' => 'Font Size', 'type' => 'integer', 'length' => '50', 'comment' => 'Allow you to specify the font size in pixels for generating the CAPTCHA. The default is 24px.', 'order' => null), array('id' => 'custCaptchaHeight', 'caption' => 'Height', 'type' => 'integer', 'length' => '50', 'order' => null), array('id' => 'custCaptchaWidth', 'caption' => 'Width', 'type' => 'integer', 'length' => '50', 'order' => null), array('id' => 'custCaptchaWordlen', 'caption' => 'Word Length', 'type' => 'integer', 'comment' => 'Allow you to specify the length of the generated "word" in characters.', 'length' => '50', 'order' => null), array('id' => 'custDotNoiseLevel', 'caption' => 'Dot Noise Level', 'type' => 'integer', 'length' => '50', 'order' => null), array('id' => 'custLineNoiseLevel', 'caption' => 'Line Noise Level', 'type' => 'integer', 'length' => '50', 'order' => null));
             break;
     }
     $info['fieldErrors'] = $errors;
     $info['savedSettings'] = SJB_Settings::getSettings();
     $info['settings'] = $settings;
     return $info;
 }
예제 #2
0
파일: bitly.php 프로젝트: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $formSubmitted = SJB_Request::getVar('action');
     $bitlyInfo = new SJB_Bitly($_REQUEST);
     $bitlyForm = new SJB_Form($bitlyInfo);
     if ($formSubmitted == 'saveSettings') {
         $bitlyForm->isDataValid($errors);
         if (!$errors) {
             SJB_Settings::updateSettings($_REQUEST);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/social-media/bitly/");
         }
     }
     $tp->assign("settings", SJB_Settings::getSettings());
     $tp->assign("errors", $errors);
     $tp->display("bitly.tpl");
 }
예제 #3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $form_submitted = SJB_Request::getVar('action');
     $page = SJB_Request::getVar('page');
     if ($form_submitted) {
         if (SJB_System::getSystemSettings("isDemo")) {
             $errors[] = "You don't have permissions for it. This is a Demo version of the software.";
         } else {
             if (!empty($_REQUEST['bad_words'])) {
                 $_REQUEST['bad_words'] = trim($_REQUEST['bad_words']);
             }
             SJB_Settings::updateSettings($_REQUEST);
         }
         if ($form_submitted == 'apply_settings') {
             $tp->assign("page", $page);
         }
     }
     $i18n = SJB_I18N::getInstance();
     $tp->assign("settings", SJB_Settings::getSettings());
     $ds = DIRECTORY_SEPARATOR;
     $path = SJB_BASE_DIR . "system{$ds}cache{$ds}agents_bots.txt";
     $disable_bots = file_get_contents($path);
     $tp->assign("disable_bots", $disable_bots);
     $tp->assign("timezones", timezone_identifiers_list());
     if (!SJB_SubAdmin::getSubAdminSID()) {
         $tp->assign("subadmins", SJB_SubAdminManager::getAllSubAdminsInfo());
     }
     $tp->assign("errors", $errors);
     $tp->assign("i18n_domains", $i18n->getDomainsData());
     $tp->assign("i18n_languages", $i18n->getActiveLanguagesData());
     $tp->assign("countries", SJB_CountriesManager::getAllCountriesCodesAndNames());
     $tp->assign('listingEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_LISTING));
     $tp->assign('productEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_PRODUCT));
     $tp->assign('userEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_USER));
     $tp->assign('otherEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_OTHER));
     $tp->display("settings.tpl");
 }
예제 #4
0
 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);
     }
 }
예제 #5
0
파일: Email.php 프로젝트: Maxlander/shixi
 function emailScheduling($cron = false)
 {
     $email_scheduling = SJB_Settings::getSettingByName('email_scheduling');
     $number_emails = SJB_Settings::getSettingByName('number_emails');
     if ($email_scheduling && $number_emails) {
         $send_emails = SJB_Settings::getSettingByName('send_emails');
         $time_sending_emails = SJB_Settings::getSettingByName('time_sending_emails');
         if (!$time_sending_emails) {
             SJB_Settings::updateSettings(array('time_sending_emails' => time()));
         } else {
             $now = time();
             $period = $now - $time_sending_emails;
             if ($period > 3600) {
                 $send_emails = 0;
                 SJB_Settings::updateSettings(array('time_sending_emails' => 0));
             }
         }
         if (!$send_emails) {
             SJB_Settings::updateSettings(array('send_emails' => 1));
             return true;
         } else {
             if ($send_emails < $number_emails) {
                 $send_emails++;
                 SJB_Settings::updateSettings(array('send_emails' => $send_emails));
                 return true;
             } else {
                 if (!$cron) {
                     SJB_DB::query("INSERT INTO email_scheduling (email , subject , text , file) VALUES ( ?s, ?s, ?s, ?s)", $this->recipient_email, $this->subject, $this->text, ltrim($this->fileAttachment, './'));
                 }
             }
             return false;
         }
     }
     return true;
 }
예제 #6
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $networkFeeds = array();
     $template = 'social_media.tpl';
     $formSubmitted = SJB_Request::getVar('submit');
     $action = SJB_Request::getVar('action');
     $subAction = SJB_Request::getVar('sub_action');
     $sid = SJB_Request::getVar('sid');
     $groups = array();
     $accountInfo = null;
     $messages = array();
     $savedSettings = array();
     if (SJB_Request::getVar('error', false)) {
         $errors[] = SJB_Request::getVar('error', false);
     }
     if (SJB_Request::getVar('message', false)) {
         $messages[] = SJB_Request::getVar('message', false);
     }
     $socNetworks = array('facebook' => array('name' => 'Facebook'), 'linkedin' => array('name' => 'Linkedin'), 'twitter' => array('name' => 'Twitter'), 'googleplus' => array('name' => 'Google+'), 'bitly' => array('name' => 'Bitly'));
     $network = SJB_Request::getVar('passed_parameters_via_uri');
     if (empty($network)) {
         $network = SJB_Request::getVar('soc_network');
     }
     switch ($network) {
         case 'facebook':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_FacebookSocial';
             break;
         case 'linkedin':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_LinkedInSocial';
             break;
         case 'twitter':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_TwitterSocial';
             break;
         case 'googleplus':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_GooglePlusSocial';
             break;
         default:
             $network = '';
             $action = '';
             $objectName = '';
             break;
     }
     switch ($action) {
         case 'add_feed':
             SJB_Session::unsetValue($network);
             SJB_Session::unsetValue($network . 'Feed');
             $template = 'feed_input_form.tpl';
             $accountID = SJB_Request::getVar('account_id', false);
             $isAuthorized = SJB_Request::getVar('authorized', false);
             if ($accountID) {
                 $tp->assign('accountID', $accountID);
             }
             $feed = new $objectName();
             $addForm = new SJB_Form($feed);
             $addForm->registerTags($tp);
             $searchFormBuilder = new SJB_SearchFormBuilder($feed);
             $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
             $searchFormBuilder->setCriteria($criteria);
             $searchFormBuilder->registerTags($tp);
             $systemFields = $feed->details->systemFields;
             $postingFields = $feed->details->postingFields;
             $listingFields = $feed->details->commonFields;
             $tp->assign('authorized', $isAuthorized);
             $tp->assign('listingFields', $listingFields);
             $tp->assign('postingFields', $postingFields);
             $tp->assign('systemFields', $systemFields);
             $tp->assign('action', $action);
             break;
         case 'save_feed':
             $template = 'feed_input_form.tpl';
             $fieldErrors = array();
             $mediaObject = $objectName . 'Media';
             $networkSocialMedia = new $mediaObject();
             $isAuthorized = SJB_Request::getVar('authorized', false);
             $actionFeed = SJB_Request::getVar('action_feed');
             if ($actionFeed != 'add_feed' && $network != 'twitter') {
                 try {
                     $accountInfo = $networkSocialMedia->getAccountInfo($sid);
                 } catch (Exception $e) {
                     $isAuthorized = false;
                     $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
                 }
             }
             $isGroupsExist = !empty($accountInfo['groups']);
             if (SJB_Request::getVar('process_token', false)) {
                 $_REQUEST = unserialize(SJB_Session::getValue($network . 'Feed'));
                 $_REQUEST['process_token'] = 1;
             }
             $feed = new $objectName($_REQUEST, $isGroupsExist, $isAuthorized);
             if ($isGroupsExist) {
                 $groups = $accountInfo['groups'];
             }
             if ($sid) {
                 $feed->setSID($sid);
                 $tp->assign('feed_sid', $sid);
             }
             $criteriaSaver = new SJB_ListingCriteriaSaver();
             $criteriaSaver->setSessionForCriteria($_REQUEST);
             $requestedData = $criteriaSaver->getCriteria();
             $searchFormBuilder = new SJB_SearchFormBuilder($feed);
             $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
             $searchFormBuilder->setCriteria($criteria);
             $searchFormBuilder->registerTags($tp);
             $properties = $feed->getProperties();
             foreach ($properties as $key => $property) {
                 if (!$property->isSystem()) {
                     $feed->deleteProperty($key);
                 }
             }
             $this->checkToken($tp, $networkSocialMedia, $errors, array(), $network, $sid);
             $addForm = new SJB_Form($feed);
             $addForm->registerTags($tp);
             if ($addForm->isDataValid($fieldErrors)) {
                 if ($network == 'twitter') {
                     try {
                         $accessToken = $networkSocialMedia->getAccessToken($sid, $action, $errors);
                     } catch (Exception $e) {
                         $accessToken = false;
                         $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
                     }
                     if (empty($errors) && $accessToken != false) {
                         $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => serialize($accessToken), 'is_system' => true));
                     }
                 } else {
                     if ($network == 'facebook' && !empty($accountInfo)) {
                         $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => serialize($accountInfo['access_token']), 'is_system' => true));
                         $feed->addProperty(array('id' => 'account_name', 'type' => 'text', 'value' => serialize($accountInfo['account_name']), 'is_system' => true));
                     }
                 }
                 if (empty($errors)) {
                     unset($requestedData['groups']);
                     $feed->addProperty(array('id' => 'search_data', 'type' => 'text', 'value' => serialize($requestedData), 'is_system' => true));
                     $feed->saveFeed($feed, $action);
                     if ($formSubmitted == 'save') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs');
                     }
                     $tp->assign('feed_sid', $feed->getSID());
                 }
             }
             $systemFields = $feed->details->systemFields;
             $postingFields = $feed->details->postingFields;
             $listingFields = $feed->details->commonFields;
             $changeAccountUrl = "action=authorize&sid={$sid}&sub_action=change_account&soc_network={$network}";
             $tp->assign('field_errors', $fieldErrors);
             $tp->assign('change_url', $changeAccountUrl);
             $tp->assign('listingFields', $listingFields);
             $tp->assign('postingFields', $postingFields);
             $tp->assign('systemFields', $systemFields);
             $tp->assign('action', $actionFeed);
             $tp->assign('authorized', $isAuthorized);
             $tp->assign('allGroups', $groups);
             break;
         case 'grant':
             $mediaObject = $objectName . 'Media';
             $networkSocialMedia = new $mediaObject();
             $error = '';
             try {
                 $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction);
             } catch (Exception $e) {
                 $tp->assign('authorized', false);
                 $error = $e->getMessage();
             }
             if (empty($error)) {
                 $networkSocialMedia->updateAccessToken($sid, $accountInfo['account_id'], $accountInfo['account_name']);
                 $logoutUrl = SJB_System::getSystemSettings('SITE_URL') . "/social-media/{$network}?message=ACCOUNT_UPDATED#postJobs";
             } else {
                 $logoutUrl = SJB_System::getSystemSettings('SITE_URL') . "/social-media/{$network}?error={$error}#postJobs";
             }
             // After clicking the 'Grant Permission' button and login to Facebook we are redirected to the feeds list.
             SJB_HelperFunctions::redirect($logoutUrl);
             break;
         case 'edit_feed':
             if (!SJB_Request::getVar('oauth_token', false)) {
                 SJB_Session::unsetValue($network);
             }
             if (!SJB_Request::getVar('process_token', false)) {
                 SJB_Session::unsetValue($network . 'Feed');
             }
             if ($sid) {
                 $changeAccountUrl = "action=authorize&sid={$sid}&sub_action=change_account&soc_network={$network}";
                 $feedInfo = $objectName::getFeedInfoByNetworkIdAndSID($network, $sid);
                 $feedInfo = array_merge($feedInfo, $_REQUEST);
                 $criteriaInfo = $feedInfo['search_data'] ? unserialize($feedInfo['search_data']) : '';
                 $mediaObject = $objectName . 'Media';
                 $networkSocialMedia = new $mediaObject();
                 $isAuthorized = true;
                 if ($network != 'twitter') {
                     try {
                         $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction);
                     } catch (Exception $e) {
                         $isAuthorized = false;
                         $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
                     }
                 }
                 $isGroupsExist = !empty($accountInfo['groups']);
                 if ($isGroupsExist) {
                     $groups = $accountInfo['groups'];
                 }
                 if ($accountInfo && $subAction == 'changed') {
                     $feedInfo = array_merge($feedInfo, $accountInfo);
                 }
                 $feed = new $objectName($feedInfo, $isGroupsExist, $isAuthorized);
                 $editForm = new SJB_Form($feed);
                 $editForm->registerTags($tp);
                 $searchFormBuilder = new SJB_SearchFormBuilder($feed);
                 $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($criteriaInfo);
                 $searchFormBuilder->setCriteria($criteria);
                 $searchFormBuilder->registerTags($tp);
                 $systemFields = $feed->details->systemFields;
                 $postingFields = $feed->details->postingFields;
                 $listingFields = $feed->details->commonFields;
                 $this->checkToken($tp, $networkSocialMedia, $errors, $feedInfo, $network, $sid);
                 $tp->assign('listingFields', $listingFields);
                 $tp->assign('postingFields', $postingFields);
                 $tp->assign('systemFields', $systemFields);
                 $tp->assign('feed_sid', $sid);
                 $tp->assign('authorized', $isAuthorized);
                 $tp->assign('allGroups', $groups);
                 $tp->assign('action', $action);
                 $tp->assign('change_url', $changeAccountUrl);
                 $template = 'feed_input_form.tpl';
             }
             break;
         case 'authorize':
             if (!SJB_Request::getVar('oauth_token', false)) {
                 SJB_Session::unsetValue($network);
             }
             $mediaObject = $objectName . 'Media';
             $networkSocialMedia = new $mediaObject();
             try {
                 if ($network == 'twitter') {
                     $accessToken = $networkSocialMedia->getAccessToken($sid, $subAction, $errors);
                     $networkSocialMedia->updateFeedToken($sid, $accessToken);
                     if (SJB_Request::getVar('sub_action', null, 'GET') == 'grant') {
                         if (empty($errors)) {
                             $messages[] = 'Account is successfully updated.';
                         }
                         break;
                     }
                 } else {
                     $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction);
                 }
             } catch (Exception $e) {
                 $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
             }
             $changeAccountUrl = "action=authorize&sub_action=change_account&soc_network={$network}";
             $template = 'feed_input_form.tpl';
             $isAuthorized = isset($accountInfo['account_id']);
             $isGroupsExist = !empty($accountInfo['groups']);
             $feed = new $objectName($accountInfo, $isGroupsExist, $isAuthorized);
             if ($isGroupsExist) {
                 $groups = $accountInfo['groups'];
             }
             $addForm = new SJB_Form($feed);
             $addForm->registerTags($tp);
             $searchFormBuilder = new SJB_SearchFormBuilder($feed);
             $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
             $searchFormBuilder->setCriteria($criteria);
             $searchFormBuilder->registerTags($tp);
             $systemFields = $feed->details->systemFields;
             $postingFields = $feed->details->postingFields;
             $listingFields = $feed->details->commonFields;
             $tp->assign('listingFields', $listingFields);
             $tp->assign('postingFields', $postingFields);
             $tp->assign('systemFields', $systemFields);
             $tp->assign('action', $action);
             $tp->assign('authorized', $isAuthorized);
             $tp->assign('change_url', $changeAccountUrl);
             $tp->assign('allGroups', $groups);
             break;
         case 'delete_feed':
             $sid = SJB_Request::getVar('sid');
             if ($sid) {
                 $feed = new $objectName();
                 $feed->deleteFeed($sid);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs');
             }
             break;
         case 'status':
             $sid = SJB_Request::getVar('sid');
             $active = SJB_Request::getVar('active');
             $feedInfo = $objectName::getFeedInfoByNetworkIdAndSID($network, $sid);
             if ($feedInfo != null && ($active == '1' || $active == '0')) {
                 $objectName::updateFeedStatus($network . '_feeds', $active, $sid);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs');
             } else {
                 $errors[] = 'Feed does not exist';
             }
             break;
         case 'save_settings':
             $request = $_REQUEST;
             $error = $this->checkFields($request, $objectName);
             if (!$error) {
                 SJB_Settings::updateSettings($request);
                 if ($formSubmitted == 'save') {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/');
                 } else {
                     if ($formSubmitted == 'apply') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network);
                     }
                 }
             }
             $savedSettings = $request;
             break;
     }
     if ($network) {
         if (empty($savedSettings)) {
             $savedSettings = SJB_Settings::getSettings();
         }
         SJB_Event::dispatch('RedefineSavedSetting', $savedSettings, true);
         if ($network != 'googleplus' && $action != 'edit_feed' && $action != 'add_feed' && $action != 'save_feed') {
             $networkFeeds = SJB_SocialMedia::getFeedsInfoByNetworkID($network);
             $currentDate = date('Y-m-d', time());
             foreach ($networkFeeds as $key => $feed) {
                 if (SJB_SocialMedia::isFeedExpired($feed, $currentDate)) {
                     $networkFeeds[$key]['expired'] = true;
                 }
             }
         }
         $tp->assign('network', $network);
         $tp->assign('savedSettings', $savedSettings);
         $tp->assign('networkFeeds', $networkFeeds);
         $tp->assign('networkName', $socNetworks[$network]['name']);
         if ($network != 'twitter') {
             $networkObject = new $objectName();
             $settings = $networkObject->getConnectSettings();
             $tp->assign('settings', $settings);
         }
     } else {
         $tp->assign('socNetworks', $socNetworks);
     }
     $tp->assign('networkFeeds', $networkFeeds);
     $tp->assign('socNetworks', $socNetworks);
     $tp->assign('errors', $errors);
     $tp->assign('messages', $messages);
     $tp->display($template);
 }
예제 #7
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'list');
     $errors = array();
     $template = 'countries.tpl';
     $paginator = new SJB_CountriesPagination();
     switch ($action) {
         case 'move_country':
         case 'save_order':
             $template = 'move_country.tpl';
             $itemSIDs = SJB_Request::getVar('item_order', array());
             try {
                 SJB_CountriesManager::saveItemsOrder($paginator->currentPage, $paginator->itemsPerPage, $itemSIDs);
                 $tp->assign('action', $action);
             } catch (Exception $e) {
                 $errors['SAVING_ORDER'] = $e->getMessage();
             }
             $countries = SJB_CountriesManager::getAllCountries();
             $tp->assign('countries', $countries);
             break;
         case 'activate':
             $countriesSIDs = array_keys(SJB_Request::getVar('countries', array()));
             foreach ($countriesSIDs as $countrySID) {
                 SJB_CountriesManager::activateCountryBySID($countrySID);
             }
             $action = 'list';
             break;
         case 'deactivate':
             $countriesSIDs = array_keys(SJB_Request::getVar('countries', array()));
             $defaultCountry = SJB_Settings::getSettingByName('default_country');
             foreach ($countriesSIDs as $countrySID) {
                 if ($defaultCountry == $countrySID) {
                     $errors['DEFAULT_DEACTIVATE'] = SJB_CountriesManager::getCountryInfoBySID($countrySID);
                 } else {
                     SJB_CountriesManager::deactivateCountryBySID($countrySID);
                 }
             }
             $action = 'list';
             break;
         case 'delete':
             $countriesSIDs = array_keys(SJB_Request::getVar('countries', array()));
             $defaultCountry = SJB_Settings::getSettingByName('default_country');
             foreach ($countriesSIDs as $countrySID) {
                 if ($defaultCountry == $countrySID) {
                     $errors['DEFAULT_DELETE'] = SJB_CountriesManager::getCountryInfoBySID($countrySID);
                 } else {
                     SJB_CountriesManager::deleteCountryBySID($countrySID);
                 }
             }
             $action = 'list';
             break;
         case 'add_country':
             $template = 'add_country.tpl';
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $country = new SJB_Country($_REQUEST);
             $addCountryForm = new SJB_Form($country);
             $addCountryForm->registerTags($tp);
             if ($formSubmitted && $addCountryForm->isDataValid($errors)) {
                 SJB_CountriesManager::saveCountry($country);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/countries/");
             } else {
                 $formFields = $addCountryForm->getFormFieldsInfo();
                 $tp->assign('form_fields', $formFields);
             }
             break;
         case 'edit_country':
             $template = 'edit_country.tpl';
             $countrySID = SJB_Request::getVar('country_id', false);
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $countryInfo = SJB_CountriesManager::getCountryInfoBySID($countrySID);
             if ($countryInfo) {
                 $countryInfo = array_merge($countryInfo, $_REQUEST);
                 $country = new SJB_Country($countryInfo);
                 $addCountryForm = new SJB_Form($country);
                 $addCountryForm->registerTags($tp);
                 $country->setSID($countrySID);
                 if ($formSubmitted && $addCountryForm->isDataValid($errors)) {
                     SJB_CountriesManager::saveCountry($country);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/countries/");
                 } else {
                     $formFields = $addCountryForm->getFormFieldsInfo();
                     $tp->assign('form_fields', $formFields);
                     $tp->assign('country_id', $countrySID);
                 }
             } else {
                 $tp->assign('action', 'edit');
                 $errors['WRONG_COUNTRY_ID_SPECIFIED'] = 'WRONG_COUNTRY_ID_SPECIFIED';
                 $template = 'country_errors.tpl';
             }
             break;
         case 'import_countries':
             $template = 'import_countries.tpl';
             $fileInfo = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             if ($fileInfo['error']) {
                 $errors[] = SJB_UploadFileManager::getErrorId($fileInfo['error']);
             } elseif ($fileInfo) {
                 $fileFormats = array('csv', 'xls', 'xlsx');
                 $pathInfo = pathinfo($fileInfo['name']);
                 $fileExtension = isset($pathInfo['extension']) ? strtolower($pathInfo['extension']) : '';
                 if (!in_array(strtolower($fileExtension), $fileFormats)) {
                     $errors[] = 'Please choose Excel or csv file';
                 } else {
                     $importFile = new SJB_ImportFileXLS($fileInfo);
                     $importFile->parse();
                     $importedData = $importFile->getData();
                     $country = new SJB_Country();
                     $count = 0;
                     foreach ($importedData as $key => $importedColumn) {
                         if ($key == 1) {
                             $data = array_merge(array(array('country_code', 'country_name')), array($importedColumn));
                             $importedProcessor = new SJB_ImportedCountryProcessor($data, $country);
                         }
                         if (!$importedColumn) {
                             continue;
                         }
                         $countryInfo = $importedProcessor->getData($importedColumn);
                         if (!empty($countryInfo['country_code']) && !empty($countryInfo['country_name'])) {
                             $country = new SJB_Country($countryInfo);
                             $country->setPropertyValue('active', 1);
                             $countrySID = SJB_CountriesManager::getCountrySIDByCountryCode($countryInfo['country_code']);
                             if ($countrySID) {
                                 $country->setSID($countrySID);
                             }
                             SJB_CountriesManager::saveCountry($country);
                             if (!$countrySID) {
                                 $count++;
                             }
                         }
                     }
                     $tp->assign('imported_countries_count', $count);
                     $template = 'import_countries_result.tpl';
                 }
             }
             break;
         case 'change_setting':
             $action = 'list';
             $countrySID = SJB_Request::getVar('default_country');
             SJB_Settings::updateSettings(array('default_country' => $countrySID));
             break;
     }
     if ($action == 'list') {
         $countries = SJB_CountriesManager::getAllCountries(($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage);
         $countriesForDefault = SJB_CountriesManager::getAllActiveCountries();
         $paginator->setItemsCount(SJB_CountriesManager::countCountries());
         $tp->assign('paginationInfo', $paginator->getPaginationInfo());
         $tp->assign('countries', $countries);
         $tp->assign('countriesForDefault', $countriesForDefault);
         $tp->assign("settings", SJB_Settings::getSettings());
     }
     $tp->assign("errors", $errors);
     $tp->display($template);
 }
예제 #8
0
파일: plugins.php 프로젝트: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $saved = false;
     $action = SJB_Request::getVar('action');
     $form_submitted = SJB_Request::getVar('submit');
     $template = 'plugins.tpl';
     $errors = array();
     if (SJB_Request::getVar('error', false)) {
         $errors[] = SJB_Request::getVar('error', false);
     }
     $messages = array();
     if (SJB_Request::getVar('message', false)) {
         $messages[] = SJB_Request::getVar('message', false);
     }
     switch ($action) {
         case 'save':
             $paths = SJB_Request::getVar('path');
             $active = SJB_Request::getVar('active');
             $subAdminSID = SJB_SubAdmin::getSubAdminSID();
             if (SJB_System::getSystemSettings('isDemo')) {
                 $errors[] = 'You don\'t have permissions for it. This is a Demo version of the software.';
             } else {
                 foreach ($paths as $key => $path) {
                     $config = SJB_PluginManager::getPluginConfigFromIniFile($path);
                     // check subadmins permissions
                     if ($subAdminSID) {
                         switch ($key) {
                             case 'FacebookSocialPlugin':
                                 if (!$this->acl->isAllowed('set_facebook_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'LinkedinSocialPlugin':
                                 if (!$this->acl->isAllowed('set_linkedin_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'PhpBBBridgePlugin':
                                 if (!$this->acl->isAllowed('set_phpbb_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'TwitterIntegrationPlugin':
                                 if (!$this->acl->isAllowed('set_twitter_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'WordPressBridgePlugin':
                                 if (!$this->acl->isAllowed('set_wordpress_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'ShareThisPlugin':
                                 if (!$this->acl->isAllowed('set_sharethisplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'CaptchaPlugin':
                                 if (!$this->acl->isAllowed('set_captchaplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'IndeedPlugin':
                                 if (!$this->acl->isAllowed('set_indeedplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'JujuPlugin':
                                 if (!$this->acl->isAllowed('set_jujuplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'SimplyHiredPlugin':
                                 if (!$this->acl->isAllowed('set_simplyhiredplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'GoogleAnalyticsPlugin':
                                 if (!$this->acl->isAllowed('set_googleanalyticsplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'BeyondPlugin':
                                 if (!$this->acl->isAllowed('set_beyondplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                         }
                     }
                     $config['active'] = $active[$key];
                     $saved = SJB_PluginManager::savePluginConfigIntoIniFile($path, $config);
                     if (!$saved) {
                         $errors[] = 'Failed to save ' . $key . ' settings';
                     }
                 }
             }
             SJB_PluginManager::reloadPlugins();
             break;
         case 'save_settings':
             $request = $_REQUEST;
             $request = self::checkRequiredFields($request);
             if (!isset($request['setting_errors'])) {
                 SJB_Settings::updateSettings($request);
                 if ($form_submitted == 'save') {
                     break;
                 } else {
                     if ($form_submitted == 'apply') {
                         $pluginName = SJB_Request::getVar('plugin');
                         SJB_HelperFunctions::redirect('?action=settings&plugin=' . $pluginName);
                     }
                 }
             } else {
                 unset($request['setting_errors']);
                 $errors = $request;
             }
         case 'settings':
             $pluginName = SJB_Request::getVar('plugin');
             $plugin = SJB_PluginManager::getPluginByName($pluginName);
             if (isset($plugin['name'])) {
                 $pluginObj = new $plugin['name']();
                 $settings = $pluginObj->pluginSettings();
                 $template = 'plugin_settings.tpl';
                 $savedSettings = SJB_Settings::getSettings();
                 SJB_Event::dispatch('RedefineSavedSetting', $savedSettings, true);
                 SJB_Event::dispatch('RedefineTemplateName', $template, true);
                 $tp->assign('plugin', $plugin);
                 $tp->assign('settings', $settings);
                 $tp->assign('savedSettings', $savedSettings);
             }
             break;
         case 'editCaptcha':
             $info = $_REQUEST;
             SJB_Event::dispatch('editCaptcha', $info, true);
             foreach ($info as $key => $val) {
                 $tp->assign($key, $val);
             }
             $template = $info['template'];
             break;
     }
     $listPlugins = SJB_PluginManager::getAllPluginsList();
     $plugins = array();
     foreach ($listPlugins as $key => $plugin) {
         $group = !empty($plugin['group']) ? $plugin['group'] : 'Common';
         $plugins[$group][$key] = $plugin;
         if (array_key_exists($key, $this->socialMediaPlugins)) {
             $plugins[$group][$key]['socialMedia'] = $this->socialMediaPlugins[$key];
         }
     }
     $tp->assign('saved', $saved);
     $tp->assign('groups', $plugins);
     $tp->assign('errors', $errors);
     $tp->assign('messages', $messages);
     $tp->display($template);
 }
예제 #9
0
 public function execute()
 {
     $errors = array();
     $messages = array();
     $action = SJB_Request::getVar('action', false);
     $tp = SJB_System::getTemplateProcessor();
     $archiveCategory = SJB_NewsManager::getCategoryByName('Archive');
     $tp->assign('archive_category', $archiveCategory);
     /****************** ACTIONS ***************************/
     switch ($action) {
         case 'save_display_setting':
             // save setting 'show_news_on_main_page'
             $settings = SJB_Request::getVar('settings');
             SJB_Settings::updateSettings($settings);
             $messages[] = 'NEWS_SETTINGS_SUCCESSFULLY_SAVED';
             break;
         case 'add':
             $categoryName = SJB_Request::getVar('category_name');
             if (empty($categoryName)) {
                 $errors['Category Name'] = 'EMPTY_VALUE';
                 break;
             }
             $isExists = SJB_NewsManager::checkExistsCategoryName($categoryName);
             if ($isExists) {
                 $errors['Category Name'] = 'NOT_UNIQUE_VALUE';
                 break;
             }
             if (SJB_NewsManager::addCategory($categoryName)) {
                 $messages[] = 'NEWS_CATEGORY_SUCCESSFULLY_ADDED';
             } else {
                 $errors[] = 'NEWS_CATEGORY_NOT_SAVED';
             }
             break;
         case 'edit':
             $categoryId = SJB_Request::getVar('category_sid');
             $formSubmitted = SJB_Request::getVar('submit');
             if ($formSubmitted) {
                 $newCategoryName = SJB_Request::getVar('category_name');
                 if (!empty($newCategoryName)) {
                     $isExists = SJB_NewsManager::checkExistsCategoryName($newCategoryName);
                     if (!$isExists) {
                         if (SJB_NewsManager::updateCategory($categoryId, $newCategoryName)) {
                             $messages[] = 'NEWS_CATEGORY_SUCCESSFULLY_SAVED';
                         } else {
                             $errors[] = 'NEWS_CATEGORY_NOT_SAVED';
                         }
                     } else {
                         $errors['Category Name'] = 'NOT_UNIQUE_VALUE';
                     }
                 } else {
                     $errors['Category Name'] = 'EMPTY_VALUE';
                 }
                 if ($formSubmitted == 'save_category' && empty($errors)) {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/news-categories/');
                 }
             }
             if (SJB_Request::getVar('newsAdded', false)) {
                 $messages[] = 'NEWS_SUCCESSFULLY_ADDED';
             }
             if (SJB_Request::getVar('newsDeleted', false)) {
                 $messages[] = 'NEWS_SUCCESSFULLY_DELETED';
             }
             if (SJB_Request::getVar('newsSaved', false)) {
                 $messages[] = 'NEWS_SUCCESSFULLY_SAVED';
             }
             $category = SJB_NewsManager::getCategoryBySid($categoryId);
             $paginator = new SJB_NewsPagination($categoryId, $category['name']);
             $paginator->setItemsCount(SJB_NewsManager::getAllNewsCount($categoryId));
             $articles = SJB_NewsManager::getArticlesByCategorySid($categoryId, $paginator->sortingField, $paginator->sortingOrder, $paginator->currentPage, $paginator->itemsPerPage);
             $i18N = SJB_ObjectMother::createI18N();
             $tp->assign('paginationInfo', $paginator->getPaginationInfo());
             $tp->assign('frontendLanguages', $i18N->getActiveFrontendLanguagesData());
             $tp->assign('messages', $messages);
             $tp->assign('errors', $errors);
             $tp->assign('category', $category);
             $tp->assign('articles', $articles);
             $tp->display('edit_category.tpl');
             break;
         case 'delete':
             $categorySID = SJB_Request::getVar('category_sid');
             if (!empty($categorySID)) {
                 if (SJB_NewsManager::deleteCategoryBySid($categorySID)) {
                     $messages[] = 'NEWS_CATEGORY_SUCCESSFULLY_DELETED';
                 } else {
                     $errors[] = 'NEWS_CATEGORY_NOT_DELETED';
                 }
             }
             break;
         case 'move_up':
             $categoryId = SJB_Request::getVar('category_sid');
             SJB_NewsManager::moveUpCategoryBySID($categoryId);
             break;
         case 'move_down':
             $categoryId = SJB_Request::getVar('category_sid');
             SJB_NewsManager::moveDownCategoryBySID($categoryId);
             break;
     }
     if ($action != 'edit') {
         $categories = SJB_NewsManager::getCategories();
         $showNewsOnMainPage = SJB_Settings::getSettingByName('show_news_on_main_page');
         // get number of news for categories
         foreach ($categories as $key => $category) {
             // remove archive from categories list
             if ($category['name'] == 'Archive') {
                 unset($categories[$key]);
                 continue;
             }
             $counter = SJB_NewsManager::getAllNewsCount($category['sid'], null);
             $categories[$key]['count'] = $counter;
         }
         $tp->assign('categories', $categories);
         $tp->assign('messages', $messages);
         $tp->assign('show_news_on_main_page', $showNewsOnMainPage);
         $tp->assign('number_news_on_main_page', SJB_Settings::getSettingByName('number_news_on_main_page'));
         $tp->assign('main_page_news_display_mode', SJB_Settings::getSettingByName('main_page_news_display_mode'));
         $tp->assign('errors', $errors);
         $tp->display('categories_list.tpl');
     }
 }