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