2010-01-08 22:01:40 +02:00
|
|
|
|
<?php
|
|
|
|
|
/*-------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* LiveStreet Engine Social Networking
|
|
|
|
|
* Copyright © 2008 Mzhelskiy Maxim
|
|
|
|
|
*
|
|
|
|
|
*--------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* Official site: www.livestreet.ru
|
|
|
|
|
* Contact e-mail: rus.engine@gmail.com
|
|
|
|
|
*
|
|
|
|
|
* GNU General Public License, version 2:
|
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
|
*
|
|
|
|
|
---------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2012-04-29 17:58:36 +03:00
|
|
|
|
* Экшен обработки УРЛа вида /admin/
|
2010-01-08 22:01:40 +02:00
|
|
|
|
*
|
2012-04-29 17:58:36 +03:00
|
|
|
|
* @package actions
|
|
|
|
|
* @since 1.0
|
2010-01-08 22:01:40 +02:00
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
class ActionAdmin extends Action {
|
2012-04-29 17:58:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Текущий пользователь
|
|
|
|
|
*
|
|
|
|
|
* @var ModuleUser_EntityUser|null
|
|
|
|
|
*/
|
|
|
|
|
protected $oUserCurrent=null;
|
2010-01-08 22:01:40 +02:00
|
|
|
|
/**
|
|
|
|
|
* Главное меню
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $sMenuHeadItemSelect='admin';
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2012-04-29 17:58:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Инициализация
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-02-06 02:09:44 +02:00
|
|
|
|
public function Init() {
|
2012-04-29 17:58:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Если нет прав доступа - перекидываем на 404 страницу
|
|
|
|
|
*/
|
2010-01-08 22:01:40 +02:00
|
|
|
|
if(!$this->User_IsAuthorization() or !$oUserCurrent=$this->User_GetUserCurrent() or !$oUserCurrent->isAdministrator()) {
|
|
|
|
|
return parent::EventNotFound();
|
|
|
|
|
}
|
2011-08-28 19:08:23 +03:00
|
|
|
|
$this->SetDefaultEvent('index');
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2010-01-08 22:01:40 +02:00
|
|
|
|
$this->oUserCurrent=$oUserCurrent;
|
|
|
|
|
}
|
2012-04-29 17:58:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Регистрация евентов
|
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
protected function RegisterEvent() {
|
2011-07-08 10:42:23 +03:00
|
|
|
|
$this->AddEvent('index','EventIndex');
|
2010-09-19 13:09:31 +03:00
|
|
|
|
$this->AddEvent('plugins','EventPlugins');
|
2010-01-08 22:01:40 +02:00
|
|
|
|
}
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
|
|
|
|
|
2010-01-08 22:01:40 +02:00
|
|
|
|
/**********************************************************************************
|
|
|
|
|
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
|
|
|
|
|
**********************************************************************************
|
2011-06-22 12:11:05 +03:00
|
|
|
|
*/
|
2012-04-10 09:31:15 +03:00
|
|
|
|
|
2012-04-29 17:58:36 +03:00
|
|
|
|
/**
|
|
|
|
|
* Отображение главной страницы админки
|
|
|
|
|
*/
|
2011-08-28 19:08:23 +03:00
|
|
|
|
protected function EventIndex() {
|
2014-08-04 07:58:22 +03:00
|
|
|
|
/**
|
|
|
|
|
* Определяем доступность установки расширенной админ-панели
|
|
|
|
|
*/
|
|
|
|
|
$aPluginsAll=func_list_plugins(true);
|
|
|
|
|
if (in_array('admin',$aPluginsAll)) {
|
|
|
|
|
$this->Viewer_Assign('bAvailableAdminPlugin',true);
|
|
|
|
|
}
|
2012-03-10 09:02:55 +02:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Страница со списком плагинов
|
|
|
|
|
*
|
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
protected function EventPlugins() {
|
2010-01-08 22:01:40 +02:00
|
|
|
|
$this->sMenuHeadItemSelect='plugins';
|
|
|
|
|
/**
|
|
|
|
|
* Обработка удаления плагинов
|
|
|
|
|
*/
|
|
|
|
|
if (isPost('submit_plugins_del')) {
|
|
|
|
|
$this->Security_ValidateSendForm();
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
2010-05-02 11:45:46 +03:00
|
|
|
|
$aPluginsDelete=getRequest('plugin_del');
|
2010-01-08 22:01:40 +02:00
|
|
|
|
if (is_array($aPluginsDelete)) {
|
2010-01-12 21:02:29 +02:00
|
|
|
|
$this->Plugin_Delete(array_keys($aPluginsDelete));
|
2010-01-08 22:01:40 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-12 21:02:29 +02:00
|
|
|
|
/**
|
|
|
|
|
* Получаем название плагина и действие
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if($sPlugin=getRequestStr('plugin',null,'get') and $sAction=getRequestStr('action',null,'get')) {
|
2010-01-08 22:01:40 +02:00
|
|
|
|
return $this->SubmitManagePlugin($sPlugin,$sAction);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список блогов
|
|
|
|
|
*/
|
2012-04-10 09:31:15 +03:00
|
|
|
|
$aPlugins=$this->Plugin_GetList(array('order'=>'name'));
|
2010-01-08 22:01:40 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем переменные в шаблон
|
2011-06-22 12:11:05 +03:00
|
|
|
|
*/
|
2010-01-08 22:01:40 +02:00
|
|
|
|
$this->Viewer_Assign("aPlugins",$aPlugins);
|
2014-08-12 19:48:36 +03:00
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('admin.plugins.title'));
|
2010-01-08 22:01:40 +02:00
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('plugins');
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Активация\деактивация плагина
|
|
|
|
|
*
|
2012-04-29 17:58:36 +03:00
|
|
|
|
* @param string $sPlugin Имя плагина
|
|
|
|
|
* @param string $sAction Действие
|
2010-01-08 22:01:40 +02:00
|
|
|
|
*/
|
|
|
|
|
protected function SubmitManagePlugin($sPlugin,$sAction) {
|
2011-04-10 20:04:18 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
2010-01-08 22:01:40 +02:00
|
|
|
|
if(!in_array($sAction,array('activate','deactivate'))) {
|
2014-08-12 19:48:36 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('admin.plugins.notices.unknown_action'),$this->Lang_Get('error'),true);
|
2010-01-08 22:01:40 +02:00
|
|
|
|
Router::Location(Router::GetPath('plugins'));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Активируем\деактивируем плагин
|
|
|
|
|
*/
|
|
|
|
|
if($bResult=$this->Plugin_Toggle($sPlugin,$sAction)) {
|
2014-08-12 19:48:36 +03:00
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('admin.plugins.notices.action_ok'),$this->Lang_Get('attention'),true);
|
2010-01-08 22:01:40 +02:00
|
|
|
|
} else {
|
2011-06-22 12:11:05 +03:00
|
|
|
|
if(!($aMessages=$this->Message_GetErrorSession()) or !count($aMessages)) $this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'),true);
|
2010-01-08 22:01:40 +02:00
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Возвращаем на страницу управления плагинами
|
|
|
|
|
*/
|
|
|
|
|
Router::Location(Router::GetPath('admin').'plugins/');
|
|
|
|
|
}
|
2012-04-10 09:31:15 +03:00
|
|
|
|
/**
|
2010-01-08 22:01:40 +02:00
|
|
|
|
* Выполняется при завершении работы экшена
|
|
|
|
|
*
|
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
|
public function EventShutdown() {
|
2010-01-08 22:01:40 +02:00
|
|
|
|
/**
|
|
|
|
|
* Загружаем в шаблон необходимые переменные
|
|
|
|
|
*/
|
2010-02-06 02:09:44 +02:00
|
|
|
|
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
|
2010-01-08 22:01:40 +02:00
|
|
|
|
}
|
2014-05-28 08:37:30 +03:00
|
|
|
|
}
|