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
|
|
|
|
*
|
|
|
|
---------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Класс обработки УРЛа вида /comments/
|
|
|
|
*
|
|
|
|
*/
|
2011-06-22 12:11:05 +03:00
|
|
|
class ActionAdmin extends Action {
|
|
|
|
|
2010-01-08 22:01:40 +02:00
|
|
|
/**
|
|
|
|
* Главное меню
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $sMenuHeadItemSelect='admin';
|
2011-06-22 12:11:05 +03:00
|
|
|
|
2010-02-06 02:09:44 +02:00
|
|
|
public function Init() {
|
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;
|
|
|
|
}
|
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');
|
|
|
|
$this->AddEvent('restorecomment','EventRestoreComment');
|
2011-06-22 12:11:05 +03:00
|
|
|
$this->AddEvent('userfields','EventUserfields');
|
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
|
|
|
*/
|
2011-07-08 10:42:23 +03:00
|
|
|
|
2011-08-28 19:08:23 +03:00
|
|
|
protected function EventIndex() {
|
|
|
|
|
|
|
|
}
|
2011-06-22 12:11:05 +03:00
|
|
|
|
2010-09-19 13:09:31 +03:00
|
|
|
protected function EventRestoreComment() {
|
2010-09-19 13:36:17 +03:00
|
|
|
set_time_limit(0);
|
2010-09-19 13:09:31 +03:00
|
|
|
$this->Comment_RestoreTree();
|
2010-09-19 13:36:17 +03:00
|
|
|
$this->Cache_Clean();
|
2011-08-28 19:08:23 +03:00
|
|
|
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('admin_comment_restore_tree'),$this->Lang_Get('attention'));
|
|
|
|
$this->SetTemplateAction('index');
|
2010-09-19 13:09:31 +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
|
|
|
/**
|
|
|
|
* Получаем название плагина и действие
|
|
|
|
*/
|
2010-01-08 22:01:40 +02:00
|
|
|
if($sPlugin=getRequest('plugin',null,'get') and $sAction=getRequest('action',null,'get')) {
|
|
|
|
return $this->SubmitManagePlugin($sPlugin,$sAction);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Передан ли номер страницы
|
2011-06-22 12:11:05 +03:00
|
|
|
*/
|
2010-01-08 22:01:40 +02:00
|
|
|
$iPage= preg_match("/^\d+$/i",$this->GetEventMatch(2)) ? $this->GetEventMatch(2) : 1;
|
|
|
|
/**
|
|
|
|
* Получаем список блогов
|
|
|
|
*/
|
|
|
|
$aPlugins=$this->Plugin_GetList();
|
|
|
|
/**
|
|
|
|
* Загружаем переменные в шаблон
|
2011-06-22 12:11:05 +03:00
|
|
|
*/
|
2010-01-08 22:01:40 +02:00
|
|
|
$this->Viewer_Assign("aPlugins",$aPlugins);
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('plugins_administartion_title'));
|
|
|
|
/**
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
*/
|
|
|
|
$this->SetTemplateAction('plugins');
|
|
|
|
}
|
2011-06-22 12:11:05 +03:00
|
|
|
|
|
|
|
protected function EventUserFields()
|
|
|
|
{
|
|
|
|
switch(getRequest('action')) {
|
|
|
|
case 'add':
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2011-07-05 10:18:54 +03:00
|
|
|
if (!$this->checkUserField()) {
|
2011-06-22 12:11:05 +03:00
|
|
|
return;
|
|
|
|
}
|
2011-07-08 10:42:23 +03:00
|
|
|
$oField = Engine::GetEntity('User_Field');
|
|
|
|
$oField->setName(getRequest('name'));
|
|
|
|
$oField->setTitle(getRequest('title'));
|
|
|
|
$oField->setPattern(getRequest('pattern'));
|
|
|
|
|
|
|
|
$iId = $this->User_addUserField($oField);
|
2011-06-22 12:11:05 +03:00
|
|
|
if(!$iId) {
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->Viewer_AssignAjax('id', $iId);
|
|
|
|
$this->Viewer_AssignAjax('lang_delete', $this->Lang_Get('user_field_delete'));
|
2011-07-05 10:18:54 +03:00
|
|
|
$this->Viewer_AssignAjax('lang_edit', $this->Lang_Get('user_field_update'));
|
2011-06-22 12:11:05 +03:00
|
|
|
$this->Message_AddNotice($this->Lang_Get('user_field_added'),$this->Lang_Get('attention'));
|
|
|
|
break;
|
|
|
|
case 'delete':
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
if (!getRequest('id')) {
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->User_deleteUserField(getRequest('id'));
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('user_field_deleted'),$this->Lang_Get('attention'));
|
|
|
|
break;
|
2011-07-05 10:18:54 +03:00
|
|
|
case 'update':
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
if (!getRequest('id')) {
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!$this->User_userFieldExistsById(getRequest('id'))) {
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!$this->checkUserField()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-07-08 10:42:23 +03:00
|
|
|
$oField = Engine::GetEntity('User_Field');
|
|
|
|
$oField->setId(getRequest('id'));
|
|
|
|
$oField->setName(getRequest('name'));
|
|
|
|
$oField->setTitle(getRequest('title'));
|
|
|
|
$oField->setPattern(getRequest('pattern'));
|
|
|
|
|
|
|
|
if ($this->User_updateUserField($oField)) {
|
2011-07-05 10:18:54 +03:00
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('user_field_updated'),$this->Lang_Get('attention'));
|
|
|
|
break;
|
2011-06-22 12:11:05 +03:00
|
|
|
default:
|
2011-07-24 14:48:08 +03:00
|
|
|
/**
|
|
|
|
* Загружаем в шаблон JS текстовки
|
|
|
|
*/
|
|
|
|
$this->Lang_AddLangJs(array('user_field_delete_confirm'));
|
|
|
|
|
2011-06-22 12:11:05 +03:00
|
|
|
$aUserFields = $this->User_getUserFields();
|
|
|
|
$this->Viewer_Assign('aUserFields',$aUserFields);
|
|
|
|
$this->SetTemplateAction('user_fields');
|
2011-07-05 11:01:36 +03:00
|
|
|
$this->Viewer_AppendScript(Config::Get('path.static.skin').'/js/userfield.js');
|
2011-06-22 12:11:05 +03:00
|
|
|
}
|
|
|
|
}
|
2011-07-05 10:18:54 +03:00
|
|
|
public function checkUserField()
|
|
|
|
{
|
|
|
|
if (!getRequest('title')) {
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_field_error_add_no_title'),$this->Lang_Get('error'));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!getRequest('name')) {
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_field_error_add_no_name'),$this->Lang_Get('error'));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ($this->User_userFieldExistsByName(getRequest('name'), getRequest('id'))) {
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_field_error_name_exists'),$this->Lang_Get('error'));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-22 12:11:05 +03:00
|
|
|
|
2010-01-08 22:01:40 +02:00
|
|
|
/**
|
|
|
|
* Активация\деактивация плагина
|
|
|
|
*
|
|
|
|
* @param string $sPlugin
|
|
|
|
* @param string $sAction
|
|
|
|
*/
|
|
|
|
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'))) {
|
2010-01-12 21:02:29 +02:00
|
|
|
$this->Message_AddError($this->Lang_Get('plugins_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)) {
|
2011-06-22 12:11:05 +03:00
|
|
|
$this->Message_AddNotice($this->Lang_Get('plugins_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/');
|
|
|
|
}
|
2011-06-22 12:11:05 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|