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');
|
|
|
|
|
$this->AddEvent('restorecomment','EventRestoreComment');
|
2011-06-22 12:11:05 +03:00
|
|
|
|
$this->AddEvent('userfields','EventUserfields');
|
2011-10-09 20:23:38 +03:00
|
|
|
|
$this->AddEvent('recalcfavourite','EventRecalculateFavourite');
|
2012-03-10 07:45:19 +02:00
|
|
|
|
$this->AddEvent('recalcvote','EventRecalculateVote');
|
2012-03-10 09:02:55 +02:00
|
|
|
|
$this->AddEvent('recalctopic','EventRecalculateTopic');
|
2013-04-08 12:37:12 +03:00
|
|
|
|
$this->AddEventPreg('/^blogcategory$/i','/^modal-add$/i','EventBlogCategoryModalAdd');
|
|
|
|
|
$this->AddEventPreg('/^blogcategory$/i','/^modal-edit$/i','EventBlogCategoryModalEdit');
|
|
|
|
|
$this->AddEventPreg('/^blogcategory$/i','/^add$/i','EventBlogCategoryAdd');
|
|
|
|
|
$this->AddEventPreg('/^blogcategory$/i','/^edit$/i','EventBlogCategoryEdit');
|
|
|
|
|
$this->AddEvent('blogcategory','EventBlogCategory');
|
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
|
|
|
|
/**
|
|
|
|
|
* Отображение главной страницы админки
|
|
|
|
|
* Нет никакой логики, просто отображение дефолтного шаблона евента index.tpl
|
|
|
|
|
*/
|
2011-08-28 19:08:23 +03:00
|
|
|
|
protected function EventIndex() {
|
|
|
|
|
|
|
|
|
|
}
|
2013-04-08 12:37:12 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Список категорий блогов
|
|
|
|
|
*/
|
|
|
|
|
protected function EventBlogCategory() {
|
|
|
|
|
/**
|
|
|
|
|
* Обработка удаления
|
|
|
|
|
*/
|
|
|
|
|
if ($this->GetParam(0)=='delete' and $oCategory=$this->Blog_GetCategoryById($this->GetParam(1))) {
|
|
|
|
|
$this->Security_ValidateSendForm();
|
|
|
|
|
/**
|
|
|
|
|
* Получаем все дочернии категории
|
|
|
|
|
*/
|
|
|
|
|
$aCategoriesId=$this->Blog_GetChildrenCategoriesById($oCategory->getId(),true);
|
|
|
|
|
$aCategoriesId[]=$oCategory->getId();
|
|
|
|
|
/**
|
|
|
|
|
* У блогов проставляем category_id = null
|
|
|
|
|
*/
|
|
|
|
|
$this->Blog_ReplaceBlogsCategoryByCategoryId($aCategoriesId,null);
|
|
|
|
|
/**
|
|
|
|
|
* Удаляем категории
|
|
|
|
|
*/
|
|
|
|
|
$this->Blog_DeleteCategoryByArrayId($aCategoriesId);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Обработка изменения сортировки
|
|
|
|
|
*/
|
|
|
|
|
if ($this->GetParam(0)=='sort' and $oCategory=$this->Blog_GetCategoryById($this->GetParam(1))) {
|
|
|
|
|
$this->Security_ValidateSendForm();
|
|
|
|
|
$sWay=$this->GetParam(2)=='down' ? 'down' : 'up';
|
|
|
|
|
$iSortOld=$oCategory->getSort();
|
|
|
|
|
if ($oCategoryPrev=$this->Blog_GetNextCategoryBySort($iSortOld,$oCategory->getPid(),$sWay)) {
|
|
|
|
|
$iSortNew=$oCategoryPrev->getSort();
|
|
|
|
|
$oCategoryPrev->setSort($iSortOld);
|
|
|
|
|
$this->Blog_UpdateCategory($oCategoryPrev);
|
|
|
|
|
} else {
|
|
|
|
|
if ($sWay=='down') {
|
|
|
|
|
$iSortNew=$iSortOld-1;
|
|
|
|
|
} else {
|
|
|
|
|
$iSortNew=$iSortOld+1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Меняем значения сортировки местами
|
|
|
|
|
*/
|
|
|
|
|
$oCategory->setSort($iSortNew);
|
|
|
|
|
$this->Blog_UpdateCategory($oCategory);
|
|
|
|
|
}
|
|
|
|
|
$aCategories=$this->Blog_GetCategoriesTree();
|
|
|
|
|
$this->Viewer_Assign("aCategories",$aCategories);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Загружает модальное окно создания категории бога
|
|
|
|
|
*/
|
|
|
|
|
protected function EventBlogCategoryModalAdd() {
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
$aCategories=$this->Blog_GetCategoriesTree();
|
|
|
|
|
$oViewer=$this->Viewer_GetLocalViewer();
|
|
|
|
|
$oViewer->Assign('aCategories',$aCategories);
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем переменные для ajax ответа
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("actions/ActionAdmin/blogcategory_form_add.tpl"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Загружает модальное окно редактирования категории бога
|
|
|
|
|
*/
|
|
|
|
|
protected function EventBlogCategoryModalEdit() {
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
if (!($oCategory=$this->Blog_GetCategoryById(getRequestStr('id')))) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$aCategories=$this->Blog_GetCategoriesTree();
|
|
|
|
|
$oViewer=$this->Viewer_GetLocalViewer();
|
|
|
|
|
$oViewer->Assign('oCategory',$oCategory);
|
|
|
|
|
$oViewer->Assign('aCategories',$aCategories);
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем переменные для ajax ответа
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_AssignAjax('sText',$oViewer->Fetch("actions/ActionAdmin/blogcategory_form_add.tpl"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function EventBlogCategoryAdd() {
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Создаем категорию
|
|
|
|
|
*/
|
|
|
|
|
$oCategory=Engine::GetEntity('ModuleBlog_EntityBlogCategory');
|
|
|
|
|
$oCategory->setTitle(getRequestStr('title'));
|
|
|
|
|
$oCategory->setUrl(getRequestStr('url'));
|
|
|
|
|
$oCategory->setSort(getRequestStr('sort'));
|
|
|
|
|
$oCategory->setPid(getRequestStr('pid'));
|
|
|
|
|
|
|
|
|
|
if ($oCategory->_Validate()) {
|
|
|
|
|
if ($this->Blog_AddCategory($oCategory)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($oCategory->_getValidateError(),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function EventBlogCategoryEdit() {
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
|
|
|
|
|
if (!($oCategory=$this->Blog_GetCategoryById(getRequestStr('id')))) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Создаем категорию
|
|
|
|
|
*/
|
|
|
|
|
$oCategory->setTitle(getRequestStr('title'));
|
|
|
|
|
$oCategory->setUrl(getRequestStr('url'));
|
|
|
|
|
$oCategory->setSort(getRequestStr('sort'));
|
|
|
|
|
$oCategory->setPid(getRequestStr('pid'));
|
|
|
|
|
|
|
|
|
|
if ($oCategory->_Validate()) {
|
|
|
|
|
if ($this->Blog_UpdateCategory($oCategory)) {
|
|
|
|
|
/**
|
|
|
|
|
* Проверяем корректность вложений
|
|
|
|
|
*/
|
|
|
|
|
if (count($this->Blog_GetCategoriesTree())<$this->Blog_GetCountCategories()) {
|
|
|
|
|
$oCategory->setPid(null);
|
|
|
|
|
$oCategory->setUrlFull($oCategory->getUrl());
|
|
|
|
|
$this->Blog_UpdateCategory($oCategory);
|
|
|
|
|
}
|
|
|
|
|
$this->Blog_RebuildCategoryUrlFull($oCategory);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->Message_AddError($oCategory->_getValidateError(),$this->Lang_Get('error'));
|
|
|
|
|
}
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Перестроение дерева комментариев, актуально при $config['module']['comment']['use_nested'] = true;
|
|
|
|
|
*
|
|
|
|
|
*/
|
2010-09-19 13:09:31 +03:00
|
|
|
|
protected function EventRestoreComment() {
|
2012-06-10 10:37:22 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
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();
|
2012-04-10 09:31:15 +03:00
|
|
|
|
|
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
|
|
|
|
}
|
2012-04-10 09:31:15 +03:00
|
|
|
|
/**
|
2012-03-10 07:45:19 +02:00
|
|
|
|
* Пересчет счетчика избранных
|
2011-10-09 20:23:38 +03:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventRecalculateFavourite() {
|
2012-06-10 10:37:22 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
2011-10-09 20:23:38 +03:00
|
|
|
|
set_time_limit(0);
|
|
|
|
|
$this->Comment_RecalculateFavourite();
|
|
|
|
|
$this->Topic_RecalculateFavourite();
|
|
|
|
|
$this->Cache_Clean();
|
2012-04-10 09:31:15 +03:00
|
|
|
|
|
2011-10-09 20:23:38 +03:00
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('admin_favourites_recalculated'),$this->Lang_Get('attention'));
|
|
|
|
|
$this->SetTemplateAction('index');
|
|
|
|
|
}
|
2012-03-10 07:45:19 +02:00
|
|
|
|
/**
|
|
|
|
|
* Пересчет счетчика голосований
|
|
|
|
|
*/
|
|
|
|
|
protected function EventRecalculateVote() {
|
2012-06-10 10:37:22 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
2012-03-10 07:45:19 +02:00
|
|
|
|
set_time_limit(0);
|
|
|
|
|
$this->Topic_RecalculateVote();
|
|
|
|
|
$this->Cache_Clean();
|
|
|
|
|
|
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('admin_votes_recalculated'),$this->Lang_Get('attention'));
|
|
|
|
|
$this->SetTemplateAction('index');
|
|
|
|
|
}
|
2012-03-10 09:02:55 +02:00
|
|
|
|
/**
|
|
|
|
|
* Пересчет количества топиков в блогах
|
|
|
|
|
*/
|
|
|
|
|
protected function EventRecalculateTopic() {
|
2012-06-10 10:37:22 +03:00
|
|
|
|
$this->Security_ValidateSendForm();
|
2012-03-10 09:02:55 +02:00
|
|
|
|
set_time_limit(0);
|
|
|
|
|
$this->Blog_RecalculateCountTopic();
|
|
|
|
|
$this->Cache_Clean();
|
|
|
|
|
|
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('admin_topics_recalculated'),$this->Lang_Get('attention'));
|
|
|
|
|
$this->SetTemplateAction('index');
|
|
|
|
|
}
|
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);
|
|
|
|
|
$this->Viewer_AddHtmlTitle($this->Lang_Get('plugins_administartion_title'));
|
|
|
|
|
/**
|
|
|
|
|
* Устанавливаем шаблон вывода
|
|
|
|
|
*/
|
|
|
|
|
$this->SetTemplateAction('plugins');
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Управление полями пользователя
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
protected function EventUserFields()
|
|
|
|
|
{
|
2012-12-12 08:06:38 +02:00
|
|
|
|
switch(getRequestStr('action')) {
|
2011-08-28 21:49:01 +03:00
|
|
|
|
/**
|
2012-04-10 09:31:15 +03:00
|
|
|
|
* Создание нового поля
|
|
|
|
|
*/
|
2011-08-28 21:49:01 +03:00
|
|
|
|
case 'add':
|
|
|
|
|
/**
|
|
|
|
|
* Обрабатываем как ajax запрос (json)
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
|
|
|
|
if (!$this->checkUserField()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$oField = Engine::GetEntity('User_Field');
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$oField->setName(getRequestStr('name'));
|
|
|
|
|
$oField->setTitle(getRequestStr('title'));
|
|
|
|
|
$oField->setPattern(getRequestStr('pattern'));
|
|
|
|
|
if (in_array(getRequestStr('type'),$this->User_GetUserFieldTypes())) {
|
|
|
|
|
$oField->setType(getRequestStr('type'));
|
2012-04-19 21:04:25 +03:00
|
|
|
|
} else {
|
|
|
|
|
$oField->setType('');
|
2012-03-15 11:05:27 +02:00
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
|
|
|
|
|
$iId = $this->User_addUserField($oField);
|
|
|
|
|
if(!$iId) {
|
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Прогружаем переменные в ajax ответ
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_AssignAjax('id', $iId);
|
|
|
|
|
$this->Viewer_AssignAjax('lang_delete', $this->Lang_Get('user_field_delete'));
|
|
|
|
|
$this->Viewer_AssignAjax('lang_edit', $this->Lang_Get('user_field_update'));
|
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('user_field_added'),$this->Lang_Get('attention'));
|
|
|
|
|
break;
|
|
|
|
|
/**
|
|
|
|
|
* Удаление поля
|
|
|
|
|
*/
|
|
|
|
|
case 'delete':
|
|
|
|
|
/**
|
|
|
|
|
* Обрабатываем как ajax запрос (json)
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (!getRequestStr('id')) {
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$this->User_deleteUserField(getRequestStr('id'));
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Message_AddNotice($this->Lang_Get('user_field_deleted'),$this->Lang_Get('attention'));
|
|
|
|
|
break;
|
|
|
|
|
/**
|
|
|
|
|
* Изменение поля
|
|
|
|
|
*/
|
|
|
|
|
case 'update':
|
|
|
|
|
/**
|
|
|
|
|
* Обрабатываем как ajax запрос (json)
|
|
|
|
|
*/
|
|
|
|
|
$this->Viewer_SetResponseAjax('json');
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (!getRequestStr('id')) {
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (!$this->User_userFieldExistsById(getRequestStr('id'))) {
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!$this->checkUserField()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$oField = Engine::GetEntity('User_Field');
|
2012-12-12 08:06:38 +02:00
|
|
|
|
$oField->setId(getRequestStr('id'));
|
|
|
|
|
$oField->setName(getRequestStr('name'));
|
|
|
|
|
$oField->setTitle(getRequestStr('title'));
|
|
|
|
|
$oField->setPattern(getRequestStr('pattern'));
|
|
|
|
|
if (in_array(getRequestStr('type'),$this->User_GetUserFieldTypes())) {
|
|
|
|
|
$oField->setType(getRequestStr('type'));
|
2012-03-15 11:05:27 +02:00
|
|
|
|
} else {
|
|
|
|
|
$oField->setType('');
|
|
|
|
|
}
|
2011-08-28 21:49:01 +03:00
|
|
|
|
|
2013-02-08 17:02:15 +02:00
|
|
|
|
if (!$this->User_updateUserField($oField)) {
|
2011-08-28 21:49:01 +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;
|
|
|
|
|
/**
|
|
|
|
|
* Показываем страницу со списком полей
|
|
|
|
|
*/
|
|
|
|
|
default:
|
|
|
|
|
/**
|
2011-07-24 14:48:08 +03:00
|
|
|
|
* Загружаем в шаблон JS текстовки
|
|
|
|
|
*/
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Lang_AddLangJs(array('user_field_delete_confirm'));
|
|
|
|
|
/**
|
|
|
|
|
* Получаем список всех полей
|
|
|
|
|
*/
|
2012-03-15 11:05:27 +02:00
|
|
|
|
$this->Viewer_Assign('aUserFields',$this->User_getUserFields());
|
|
|
|
|
$this->Viewer_Assign('aUserFieldTypes',$this->User_GetUserFieldTypes());
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->SetTemplateAction('user_fields');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
2012-04-29 17:58:36 +03:00
|
|
|
|
* Проверка поля пользователя на корректность из реквеста
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*
|
2012-04-29 17:58:36 +03:00
|
|
|
|
* @return bool
|
2011-08-28 21:49:01 +03:00
|
|
|
|
*/
|
|
|
|
|
public function checkUserField()
|
|
|
|
|
{
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (!getRequestStr('title')) {
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_field_error_add_no_title'),$this->Lang_Get('error'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if (!getRequestStr('name')) {
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_field_error_add_no_name'),$this->Lang_Get('error'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Не допускаем дубликатов по имени
|
|
|
|
|
*/
|
2012-12-12 08:06:38 +02:00
|
|
|
|
if ($this->User_userFieldExistsByName(getRequestStr('name'), getRequestStr('id'))) {
|
2011-08-28 21:49:01 +03:00
|
|
|
|
$this->Message_AddError($this->Lang_Get('user_field_error_name_exists'),$this->Lang_Get('error'));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-01-08 22:01:40 +02:00
|
|
|
|
/**
|
|
|
|
|
* Активация\деактивация плагина
|
|
|
|
|
*
|
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'))) {
|
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/');
|
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|