mirror of
https://github.com/avecms/AVE.cms.git
synced 2025-01-22 07:20:07 +00:00
Fixes
This commit is contained in:
parent
818ea81983
commit
470ea6bb4c
2
admin/lang/ru/sysblocks.txt
Executable file → Normal file
2
admin/lang/ru/sysblocks.txt
Executable file → Normal file
@ -76,4 +76,4 @@ SYSBLOCK_ER_SYN = "Неверный алиас!<br> Алиас не долже
|
||||
SYSBLOCK_ER_EXISTS = "Неверный алиас!<br> Данный алиас уже привязан к другоому системному блоку"
|
||||
|
||||
// v 3.25
|
||||
SYSBLOCK_EVAL = "Выполнять PHP перед выозвращением результата"
|
||||
SYSBLOCK_EVAL = "Выполнять PHP перед возвращением результата"
|
@ -20,109 +20,74 @@
|
||||
global $AVE_DB, $AVE_Template;
|
||||
|
||||
require(BASE_DIR . '/class/class.sysblocks.php');
|
||||
$AVE_SysBlock = new AVE_SysBlock;
|
||||
|
||||
new Sysblocks;
|
||||
|
||||
$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/sysblocks.txt', 'sysblocks');
|
||||
|
||||
switch ($_REQUEST['action'])
|
||||
{
|
||||
// Список системных блоков
|
||||
case '':
|
||||
if (check_permission_acp('sysblocks_view'))
|
||||
{
|
||||
$AVE_SysBlock->sys_blockList();
|
||||
Sysblocks::startPage();
|
||||
}
|
||||
break;
|
||||
|
||||
// Список групп системных блоков
|
||||
case 'groups':
|
||||
if (check_permission_acp('sysblocks_view'))
|
||||
{
|
||||
Sysblocks::listGroups();
|
||||
}
|
||||
break;
|
||||
|
||||
// Создать новый системный блок
|
||||
case 'new':
|
||||
if (check_permission_acp('sysblocks_edit'))
|
||||
{
|
||||
$AVE_SysBlock->sys_blockNew();
|
||||
Sysblocks::newBlock();
|
||||
}
|
||||
break;
|
||||
|
||||
// Редактировать системный блок
|
||||
case 'edit':
|
||||
if (check_permission_acp('sysblocks_edit'))
|
||||
{
|
||||
$AVE_SysBlock->sys_blockEdit(isset($_REQUEST['id']) ? $_REQUEST['id'] : null);
|
||||
Sysblocks::editBlock();
|
||||
}
|
||||
break;
|
||||
|
||||
// Сохранить системный блок
|
||||
case 'save':
|
||||
if (check_permission_acp('sysblocks_edit'))
|
||||
{
|
||||
$AVE_SysBlock->sys_blockSave(isset($_REQUEST['id']) ? $_REQUEST['id'] : null);
|
||||
Sysblocks::saveBlock();
|
||||
}
|
||||
break;
|
||||
|
||||
// Удалить системный блок
|
||||
case 'del':
|
||||
if (check_permission_acp('sysblocks_edit'))
|
||||
{
|
||||
$AVE_SysBlock->sys_blockDelete($_REQUEST['id']);
|
||||
Sysblocks::delBlock();
|
||||
}
|
||||
break;
|
||||
|
||||
// Проверка алиаса
|
||||
case 'alias':
|
||||
if (check_permission_acp('sysblocks_edit'))
|
||||
{
|
||||
echo $AVE_SysBlock->sys_blockValidate($_REQUEST['alias'], (int)$_REQUEST['id']);
|
||||
echo Sysblocks::aliasValidate($_REQUEST['alias'], (int)$_REQUEST['id']);
|
||||
}
|
||||
exit;
|
||||
|
||||
// Копирование системного блока
|
||||
case 'multi':
|
||||
if (check_permission_acp('sysblocks_edit'))
|
||||
{
|
||||
$_REQUEST['sub'] = (!isset($_REQUEST['sub'])) ? '' : $_REQUEST['sub'];
|
||||
$errors = array();
|
||||
switch ($_REQUEST['sub'])
|
||||
{
|
||||
case 'save':
|
||||
$ok = true;
|
||||
$row = $AVE_DB->Query("
|
||||
SELECT sysblock_name
|
||||
FROM " . PREFIX . "_sysblocks
|
||||
WHERE sysblock_name = '" . $_REQUEST['sysblock_name'] . "'
|
||||
")->FetchRow();
|
||||
|
||||
if (@$row->sysblock_name != '')
|
||||
{
|
||||
array_push($errors, $AVE_Template->get_config_vars('SYSBLOCK_EXIST'));
|
||||
$AVE_Template->assign('errors', $errors);
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
if ($_REQUEST['sysblock_name'] == '')
|
||||
{
|
||||
array_push($errors, $AVE_Template->get_config_vars('SYSBLOCK_COPY_TIP'));
|
||||
$AVE_Template->assign('errors', $errors);
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
$row = $AVE_DB->Query("
|
||||
SELECT sysblock_text
|
||||
FROM " . PREFIX . "_sysblocks
|
||||
WHERE id = '" . (int)$_REQUEST['id'] . "'
|
||||
")->FetchRow();
|
||||
|
||||
$AVE_DB->Query("
|
||||
INSERT
|
||||
INTO " . PREFIX . "_sysblocks
|
||||
SET
|
||||
Id = '',
|
||||
sysblock_name = '" . $_REQUEST['sysblock_name'] . "',
|
||||
sysblock_text = '" . addslashes($row->sysblock_text) . "',
|
||||
sysblock_author_id = '" . $_SESSION['user_id'] . "',
|
||||
sysblock_created = '" . time() . "'
|
||||
");
|
||||
|
||||
reportLog($_SESSION['user_name'] . ' - создал копию системного блока (' . (int)$_REQUEST['id'] . ')', 2, 2);
|
||||
|
||||
header('Location:index.php?do=sysblocks'.'&cp=' . SESSION);
|
||||
}
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/multi.tpl'));
|
||||
break;
|
||||
}
|
||||
//
|
||||
}
|
||||
}
|
||||
?>
|
@ -142,7 +142,7 @@ function changeRub(select) {ldelim}
|
||||
<div class="pr12">
|
||||
<input type="text" name="request_alias" value="{if $smarty.request.Id != ''}{$row->request_alias}{else}{$smarty.request.request_alias}{/if}" id="request_alias" value="" class="mousetrap" data-accept="{#REQUEST_ACCEPT#}" data-error-syn="{#REQUEST_ER_SYN#}" data-error-exists="{#REQUEST_ER_EXISTS#}" placeholder="{#REQUEST_ALIAS#}" maxlength="20" style="width: 200px;" autocomplete="off" />
|
||||
<input type="text" id="request_alias_tag" value="[tag:request:{if $smarty.request.Id != ''}{if $row->request_alias != ''}{$row->request_alias}{else}{$smarty.request.Id}{/if}{else}{$smarty.request.request_alias}{/if}]" readonly size="40" class="mousetrap" style="width: 200px;" />
|
||||
<a style="text-align: center; padding: 5px 3px 4px 3px;" class="whiteBtn copyBtn" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#sysblock_alias_tag">
|
||||
<a style="text-align: center; padding: 5px 3px 4px 3px;" class="whiteBtn copyBtn" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#request_alias_tag">
|
||||
<img style="margin-top: -3px; position: relative; top: 4px; padding: 0 3px;" class="clippy" src="{$ABS_PATH}admin/templates/images/clippy.svg" width="13">
|
||||
</a>
|
||||
</div>
|
||||
|
2
admin/templates/sysblocks/form.tpl
Executable file → Normal file
2
admin/templates/sysblocks/form.tpl
Executable file → Normal file
@ -249,7 +249,7 @@
|
||||
{if $smarty.request.action != 'new'}
|
||||
<script language="javascript">
|
||||
var sett_options = {ldelim}
|
||||
url: 'index.php?do=sysblocks&action=save&cp={$sess}&ajax=1',
|
||||
url: 'index.php?do=sysblocks&action=save&cp={$sess}',
|
||||
dataType: 'json',
|
||||
beforeSubmit: Request,
|
||||
success: Response
|
||||
|
0
admin/templates/sysblocks/form_visual.tpl
Executable file → Normal file
0
admin/templates/sysblocks/form_visual.tpl
Executable file → Normal file
30
admin/templates/sysblocks/list.tpl
Executable file → Normal file
30
admin/templates/sysblocks/list.tpl
Executable file → Normal file
@ -42,7 +42,7 @@
|
||||
<h5>{#SYSBLOCK_EDIT#}</h5>
|
||||
</div>
|
||||
|
||||
<div class="widget" style="margin-top: 0px;">
|
||||
<div class="widget" style="margin-top: 0;">
|
||||
<div class="body">
|
||||
{#SYSBLOCK_EDIT_TIP#}
|
||||
</div>
|
||||
@ -57,6 +57,28 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="widgets">
|
||||
<table class="first tableButtons" cellpadding="0" cellspacing="0" width="100%" id="sysblocksButtons">
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
<tr>
|
||||
<td>
|
||||
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=basket_history&cp={$sess}">1</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=basket_coupon&cp={$sess}">2</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=basket_settings&cp={$sess}">3</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button basicBtn topBtn" href="index.php?do=modules&action=modedit&mod=basket&moduleaction=templates&cp={$sess}">4</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="widget first">
|
||||
<ul class="tabs">
|
||||
@ -81,7 +103,7 @@
|
||||
<col width="20">
|
||||
<col width="20">
|
||||
|
||||
{if $sys_blocks}
|
||||
{if $sysblocks}
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{#SYSBLOCK_ID#}</td>
|
||||
@ -97,7 +119,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{foreach from=$sys_blocks item=sysblock}
|
||||
{foreach from=$sysblocks item=sysblock}
|
||||
<tr id="tr{$sysblock->id}">
|
||||
<td align="center">{$sysblock->id}</td>
|
||||
<td align="center">{if $sysblock->sysblock_external}<a class="icon_sprite ico_globus topDir" title="{#SYSBLOCK_EXTERNAL_GO#}" href="http://{$smarty.server.HTTP_HOST}/?sysblock={if $sysblock->sysblock_alias}{$sysblock->sysblock_alias}{else}{$sysblock->id}{/if}" target="_blank"></a>{else}<span class="icon_sprite ico_globus_no"></span>{/if}</td>
|
||||
@ -120,7 +142,7 @@
|
||||
<td align="center">{$sysblock->sysblock_author_id|escape}</td>
|
||||
|
||||
<td align="center">
|
||||
<span class="date_text dgrey">{$sysblock->sysblock_created|date_format:$TIME_FORMAT|translate_date}</span>
|
||||
<span class="date_text dgrey">{$sysblock->sysblock_created|date_format:$TIME_FORMAT|pretty_date}</span>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
0
admin/templates/sysblocks/multi.tpl
Executable file → Normal file
0
admin/templates/sysblocks/multi.tpl
Executable file → Normal file
0
admin/templates/sysblocks/nav.tpl
Executable file → Normal file
0
admin/templates/sysblocks/nav.tpl
Executable file → Normal file
@ -327,39 +327,39 @@
|
||||
$sql_where_field = '';
|
||||
$field_link = '';
|
||||
|
||||
if ($_REQUEST['field_id'] && (int)$_REQUEST['field_id'] > 0)
|
||||
if (isset($_REQUEST['field_id']) && (int)$_REQUEST['field_id'] > 0)
|
||||
{
|
||||
$sql_join_field = "
|
||||
LEFT JOIN
|
||||
" . PREFIX . "_document_fields AS df1
|
||||
ON
|
||||
doc.Id = df1.document_id
|
||||
LEFT JOIN
|
||||
" . PREFIX . "_document_fields_text AS df2
|
||||
ON
|
||||
df1.document_id = df2.document_id
|
||||
";
|
||||
LEFT JOIN
|
||||
" . PREFIX . "_document_fields AS df1
|
||||
ON
|
||||
doc.Id = df1.document_id
|
||||
LEFT JOIN
|
||||
" . PREFIX . "_document_fields_text AS df2
|
||||
ON
|
||||
df1.document_id = df2.document_id
|
||||
";
|
||||
|
||||
if ($_REQUEST['field_request'] == 'eq')
|
||||
if ($_REQUEST['field_request'] == 'eq' && $_REQUEST['field_search'] != '')
|
||||
{
|
||||
$sql_where_field = "
|
||||
AND
|
||||
(df1.rubric_field_id = '" . (int)$_REQUEST['field_id'] . "'
|
||||
AND
|
||||
(UPPER(df1.field_value) = '" . mb_strtoupper($_REQUEST['field_search']) . "'
|
||||
OR
|
||||
df1.field_number_value = '" . mb_strtoupper($_REQUEST['field_search']) . "'))
|
||||
";
|
||||
}
|
||||
else if ($_REQUEST['field_request'] == 'like')
|
||||
{
|
||||
$sql_where_field = "
|
||||
AND
|
||||
(df1.rubric_field_id = '" . (int)$_REQUEST['field_id'] . "'
|
||||
AND
|
||||
(UPPER(df1.field_value) LIKE '%" . mb_strtoupper($_REQUEST['field_search']) . "%'
|
||||
(df1.rubric_field_id = '" . (int)$_REQUEST['field_id'] . "'
|
||||
AND
|
||||
(UPPER(df1.field_value) = '" . mb_strtoupper($_REQUEST['field_search']) . "'
|
||||
OR
|
||||
df1.field_number_value LIKE '%" . mb_strtoupper($_REQUEST['field_search']) . "%'))
|
||||
df1.field_number_value = '" . mb_strtoupper($_REQUEST['field_search']) . "'))
|
||||
";
|
||||
}
|
||||
else if ($_REQUEST['field_request'] == 'like' && $_REQUEST['field_search'] != '')
|
||||
{
|
||||
$sql_where_field = "
|
||||
AND
|
||||
(df1.rubric_field_id = '" . (int)$_REQUEST['field_id'] . "'
|
||||
AND
|
||||
(UPPER(df1.field_value) LIKE '%" . mb_strtoupper($_REQUEST['field_search']) . "%'
|
||||
OR
|
||||
df1.field_number_value LIKE '%" . mb_strtoupper($_REQUEST['field_search']) . "%'))
|
||||
";
|
||||
}
|
||||
|
||||
@ -376,24 +376,22 @@
|
||||
$nav_rub = '&rubric_id=' . (int)$_REQUEST['rubric_id'];
|
||||
|
||||
$sql = $AVE_DB->Query("
|
||||
SELECT
|
||||
Id,
|
||||
rubric_field_type,
|
||||
rubric_field_title
|
||||
FROM
|
||||
" . PREFIX . "_rubric_fields
|
||||
WHERE
|
||||
rubric_id = '" . $_REQUEST['rubric_id'] ."'
|
||||
ORDER BY
|
||||
rubric_field_title ASC
|
||||
");
|
||||
SELECT
|
||||
Id,
|
||||
rubric_field_type,
|
||||
rubric_field_title
|
||||
FROM
|
||||
" . PREFIX . "_rubric_fields
|
||||
WHERE
|
||||
rubric_id = '" . $_REQUEST['rubric_id'] ."'
|
||||
ORDER BY
|
||||
rubric_field_title ASC
|
||||
");
|
||||
|
||||
$fields = array();
|
||||
|
||||
while($row = $sql->FetchRow())
|
||||
{
|
||||
array_push($fields, $row);
|
||||
}
|
||||
|
||||
$AVE_Template->assign('fields', $fields);
|
||||
}
|
||||
|
470
class/class.sysblocks.php
Executable file → Normal file
470
class/class.sysblocks.php
Executable file → Normal file
@ -10,12 +10,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class AVE_SysBlock
|
||||
class Sysblocks
|
||||
{
|
||||
/**
|
||||
* Проверка алиаса тега на валидность и уникальность
|
||||
*/
|
||||
function sys_blockValidate ($alias = '', $id = 0)
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| aliasValidate
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Проверка алиаса на валидность и уникальность
|
||||
|
|
||||
*/
|
||||
public static function aliasValidate ($alias = '', $id = 0)
|
||||
{
|
||||
global $AVE_DB;
|
||||
|
||||
@ -23,152 +28,225 @@
|
||||
if (empty ($alias) || preg_match('/^[A-Za-z0-9-_]{1,20}$/i', $alias) !== 1 || is_numeric($alias))
|
||||
return 'syn';
|
||||
|
||||
//-- Уникальность
|
||||
return !(bool)$AVE_DB->Query("
|
||||
SELECT 1
|
||||
$sql = "
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
" . PREFIX . "_sysblocks
|
||||
WHERE
|
||||
sysblock_alias = '" . $alias . "'
|
||||
AND
|
||||
AND
|
||||
id != '" . $id . "'
|
||||
")->GetCell();
|
||||
";
|
||||
|
||||
//-- Уникальность
|
||||
return !(bool)$AVE_DB->Query($sql)->GetCell();
|
||||
}
|
||||
|
||||
/**
|
||||
* Вывод списка системных блоков
|
||||
*/
|
||||
function sys_blockList ()
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| startPage
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Гланая страница
|
||||
|
|
||||
*/
|
||||
public static function startPage()
|
||||
{
|
||||
global $AVE_DB, $AVE_Template;
|
||||
|
||||
$sys_blocks = array();
|
||||
//-- Группы
|
||||
$groups = [];
|
||||
|
||||
$sql = $AVE_DB->Query("
|
||||
$sql = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
" . PREFIX . "_sysblocks_groups
|
||||
ORDER BY
|
||||
position ASC
|
||||
";
|
||||
|
||||
$query = $AVE_DB->Query($sql);
|
||||
|
||||
while ($row = $query->FetchAssocArray())
|
||||
{
|
||||
$row['count'] = 0;
|
||||
$groups[$row['id']] = $row;
|
||||
}
|
||||
|
||||
//-- Блоки
|
||||
$sysblocks = [];
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
a.*,
|
||||
a.sysblock_group_id
|
||||
FROM
|
||||
" . PREFIX . "_sysblocks AS a
|
||||
LEFT JOIN
|
||||
" . PREFIX . "_sysblocks_groups AS b
|
||||
ON a.sysblock_group_id = b.id
|
||||
ORDER BY
|
||||
b.position ASC, a.id ASC
|
||||
";
|
||||
|
||||
$query = $AVE_DB->Query($sql);
|
||||
|
||||
while ($row = $query->FetchAssocArray())
|
||||
{
|
||||
$row['author'] = get_username_by_id($row['sysblock_author_id']);
|
||||
$sysblocks[$row['sysblock_group_id']][] = $row;
|
||||
}
|
||||
|
||||
foreach ($sysblocks AS $_k => $_v)
|
||||
{
|
||||
if ($_k == 0)
|
||||
{
|
||||
$groups[$_k]['position'] = 0;
|
||||
$groups[$_k]['title'] = 'Без группы';
|
||||
$groups[$_k]['description'] = 'Описание отсутсвует';
|
||||
}
|
||||
|
||||
$groups[$_k]['count'] = count($sysblocks[$_k]);
|
||||
}
|
||||
|
||||
//Debug::_echo($sysblocks, true);
|
||||
//Debug::_echo($groups, true);
|
||||
$AVE_Template->assign('groups', $groups);
|
||||
$AVE_Template->assign('sysblocks', $sysblocks);
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/start.tpl'));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| listBlocks
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Список системных блоков
|
||||
|
|
||||
*/
|
||||
public static function listBlocks()
|
||||
{
|
||||
global $AVE_DB, $AVE_Template;
|
||||
|
||||
$sysblocks = [];
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
" . PREFIX . "_sysblocks
|
||||
ORDER BY
|
||||
id
|
||||
");
|
||||
";
|
||||
|
||||
$query = $AVE_DB->Query($sql);
|
||||
|
||||
// Формируем массив из полученных данных
|
||||
while ($row = $sql->FetchRow())
|
||||
while ($row = $query->FetchRow())
|
||||
{
|
||||
$row->sysblock_author_id = get_username_by_id($row->sysblock_author_id);
|
||||
array_push($sys_blocks, $row);
|
||||
}
|
||||
|
||||
$AVE_Template->assign('sid', 0);
|
||||
$AVE_Template->assign('sys_blocks', $sys_blocks);
|
||||
$AVE_Template->assign('sysblocks', $sysblocks);
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/list.tpl'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Сохранение системного блока
|
||||
*
|
||||
* @param int $sysblock_id идентификатор системного блока
|
||||
*/
|
||||
function sys_blockSave ($sysblock_id = null)
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| listGroups
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Список групп системных блоков
|
||||
|
|
||||
*/
|
||||
public static function listGroups()
|
||||
{
|
||||
global $AVE_DB, $AVE_Template;
|
||||
|
||||
if (is_numeric($sysblock_id))
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
$_REQUEST['sysblock_external'] = (isset($_REQUEST['sysblock_external'])) ? $_REQUEST['sysblock_external'] : 0;
|
||||
$_REQUEST['sysblock_eval'] = (isset($_REQUEST['sysblock_eval'])) ? $_REQUEST['sysblock_eval'] : 0;
|
||||
$_REQUEST['sysblock_ajax'] = (isset($_REQUEST['sysblock_ajax'])) ? $_REQUEST['sysblock_ajax'] : 0;
|
||||
$_REQUEST['sysblock_visual'] = (isset($_REQUEST['sysblock_visual'])) ? $_REQUEST['sysblock_visual'] : 0;
|
||||
$_REQUEST['sysblock_alias'] = isset($_REQUEST['sysblock_alias']) ? $_REQUEST['sysblock_alias'] : '';
|
||||
$sql = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
" . PREFIX . "_sysblocks_groups
|
||||
ORDER BY
|
||||
id
|
||||
";
|
||||
|
||||
$sql = $AVE_DB->Query("
|
||||
UPDATE
|
||||
" . PREFIX . "_sysblocks
|
||||
SET
|
||||
sysblock_name = '" . $_REQUEST['sysblock_name'] . "',
|
||||
sysblock_description = '" . addslashes($_REQUEST['sysblock_description']) . "',
|
||||
sysblock_alias = '" . $_REQUEST['sysblock_alias'] . "',
|
||||
sysblock_text = '" . $_REQUEST['sysblock_text'] . "',
|
||||
sysblock_eval = '" . (int)$_REQUEST['sysblock_eval'] . "',
|
||||
sysblock_external = '" . (int)$_REQUEST['sysblock_external'] . "',
|
||||
sysblock_ajax = '" . (int)$_REQUEST['sysblock_ajax'] . "',
|
||||
sysblock_visual = '" . (int)$_REQUEST['sysblock_visual'] . "'
|
||||
WHERE
|
||||
id = '" . $sysblock_id . "'
|
||||
");
|
||||
$query = $AVE_DB->Query($sql);
|
||||
|
||||
if ($sql->_result === false)
|
||||
{
|
||||
$message = $AVE_Template->get_config_vars('SYSBLOCK_SAVED_ERR');
|
||||
$header = $AVE_Template->get_config_vars('SYSBLOCK_ERROR');
|
||||
$theme = 'error';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $AVE_Template->get_config_vars('SYSBLOCK_SAVED');
|
||||
$header = $AVE_Template->get_config_vars('SYSBLOCK_SUCCESS');
|
||||
$theme = 'accept';
|
||||
// Формируем массив из полученных данных
|
||||
while ($row = $query->FetchAssocArray())
|
||||
array_push($groups, $row);
|
||||
|
||||
//-- Стираем кеш сисблока
|
||||
$this->clearCache($sysblock_id, $_REQUEST['sysblock_alias']);
|
||||
|
||||
//-- Сохраняем системное сообщение в журнал
|
||||
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLUPDATE') . " (" . stripslashes($_REQUEST['sysblock_name']) . ") (id: $sysblock_id)");
|
||||
}
|
||||
|
||||
if (isAjax())
|
||||
{
|
||||
echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
|
||||
}
|
||||
else
|
||||
{
|
||||
$AVE_Template->assign('message', $message);
|
||||
header('Location:index.php?do=sysblocks&cp=' . SESSION);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$AVE_DB->Query("
|
||||
INSERT INTO
|
||||
" . PREFIX . "_sysblocks
|
||||
SET
|
||||
sysblock_name = '" . $_REQUEST['sysblock_name'] . "',
|
||||
sysblock_description = '" . addslashes($_REQUEST['sysblock_description']) . "',
|
||||
sysblock_alias = '" . $_REQUEST['sysblock_alias'] . "',
|
||||
sysblock_text = '" . $_REQUEST['sysblock_text'] . "',
|
||||
sysblock_author_id = '" . (int)$_SESSION['user_id'] . "',
|
||||
sysblock_eval = '" . (int)$_REQUEST['sysblock_eval'] . "',
|
||||
sysblock_external = '" . (int)$_REQUEST['sysblock_external'] . "',
|
||||
sysblock_ajax = '" . (int)$_REQUEST['sysblock_ajax'] . "',
|
||||
sysblock_visual = '" . (int)$_REQUEST['sysblock_visual'] . "',
|
||||
sysblock_created = '" . time() . "'
|
||||
");
|
||||
|
||||
$sysblock_id = $AVE_DB->InsertId();
|
||||
|
||||
//-- Сохраняем системное сообщение в журнал
|
||||
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLNEW') . " (" . stripslashes($_REQUEST['sysblock_name']) . ") (id: $sysblock_id)");
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['next_edit']))
|
||||
header('Location:index.php?do=sysblocks&cp=' . SESSION);
|
||||
else
|
||||
header('Location:index.php?do=sysblocks&action=edit&&id=' . $sysblock_id . '&cp=' . SESSION);
|
||||
$AVE_Template->assign('sid', 0);
|
||||
$AVE_Template->assign('groups', $groups);
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/groups.tpl'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Редактирование системного блока
|
||||
*
|
||||
* @param int $sysblock_id идентификатор системного блока
|
||||
*/
|
||||
function sys_blockEdit ($sysblock_id)
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| newBlock
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Создание системного блока
|
||||
|
|
||||
*/
|
||||
public static function newBlock ()
|
||||
{
|
||||
global $AVE_Template;
|
||||
|
||||
$row['sysblock_name'] = '';
|
||||
$row['sysblock_alias'] = '';
|
||||
$row['sysblock_text'] = '';
|
||||
$row['sysblock_visual'] = (isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] != 0) ? $_REQUEST['sysblock_visual'] : '';
|
||||
|
||||
$AVE_Template->assign('sid', 0);
|
||||
|
||||
if ((isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] == 1) || $row['sysblock_visual'] == 1)
|
||||
{
|
||||
$oCKeditor = new CKeditor();
|
||||
$oCKeditor->returnOutput = true;
|
||||
$oCKeditor->config['customConfig'] = 'sysblock.js';
|
||||
$oCKeditor->config['toolbar'] = 'Big';
|
||||
$oCKeditor->config['height'] = 400;
|
||||
$config = array();
|
||||
$row['sysblock_text'] = $oCKeditor->editor('sysblock_text', $row['sysblock_text'], $config);
|
||||
|
||||
$AVE_Template->assign($row);
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form_visual.tpl'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$AVE_Template->assign($row);
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form.tpl'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| editBlock
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Редактирование системного блока
|
||||
|
|
||||
*/
|
||||
public static function editBlock ()
|
||||
{
|
||||
global $AVE_DB, $AVE_Template;
|
||||
|
||||
$sysblock_id = (int)$_REQUEST['id'];
|
||||
|
||||
$row = $AVE_DB->Query("
|
||||
SELECT
|
||||
*
|
||||
@ -200,53 +278,127 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Создание системного блока
|
||||
*/
|
||||
function sys_blockNew ()
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| editBlock
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Сохранение системного блока
|
||||
|
|
||||
*/
|
||||
public static function saveBlock()
|
||||
{
|
||||
global $AVE_DB, $AVE_Template;
|
||||
|
||||
$row['sysblock_name'] = '';
|
||||
$row['sysblock_alias'] = '';
|
||||
$row['sysblock_text'] = '';
|
||||
$row['sysblock_eval'] = '1';
|
||||
$row['sysblock_visual'] = (isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] != 0) ? $_REQUEST['sysblock_visual'] : '';
|
||||
|
||||
$AVE_Template->assign('sid', 0);
|
||||
|
||||
if ((isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] == 1) || $row['sysblock_visual'] == 1)
|
||||
{
|
||||
$oCKeditor = new CKeditor();
|
||||
$oCKeditor->returnOutput = true;
|
||||
$oCKeditor->config['customConfig'] = 'sysblock.js';
|
||||
$oCKeditor->config['toolbar'] = 'Big';
|
||||
$oCKeditor->config['height'] = 400;
|
||||
$config = array();
|
||||
$row['sysblock_text'] = $oCKeditor->editor('sysblock_text', $row['sysblock_text'], $config);
|
||||
|
||||
$AVE_Template->assign($row);
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form_visual.tpl'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$AVE_Template->assign($row);
|
||||
$AVE_Template->assign('content', $AVE_Template->fetch('sysblocks/form.tpl'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаление системного блока
|
||||
*
|
||||
* @param int $sysblock_id идентификатор системного блока
|
||||
*/
|
||||
function sys_blockDelete ($sysblock_id)
|
||||
{
|
||||
global $AVE_DB, $AVE_Template;
|
||||
$sysblock_id = $_REQUEST['id']
|
||||
? (int)$_REQUEST['id']
|
||||
: null;
|
||||
|
||||
if (is_numeric($sysblock_id))
|
||||
{
|
||||
$row = $AVE_DB->Query("
|
||||
|
||||
$_REQUEST['sysblock_external'] = (isset($_REQUEST['sysblock_external'])) ? $_REQUEST['sysblock_external'] : 0;
|
||||
$_REQUEST['sysblock_ajax'] = (isset($_REQUEST['sysblock_ajax'])) ? $_REQUEST['sysblock_ajax'] : 0;
|
||||
$_REQUEST['sysblock_eval'] = (isset($_REQUEST['sysblock_eval'])) ? $_REQUEST['sysblock_eval'] : 0;
|
||||
$_REQUEST['sysblock_visual'] = (isset($_REQUEST['sysblock_visual'])) ? $_REQUEST['sysblock_visual'] : 0;
|
||||
$_REQUEST['sysblock_alias'] = isset($_REQUEST['sysblock_alias']) ? $_REQUEST['sysblock_alias'] : '';
|
||||
|
||||
$sql = $AVE_DB->Query("
|
||||
UPDATE
|
||||
" . PREFIX . "_sysblocks
|
||||
SET
|
||||
sysblock_name = '" . $_REQUEST['sysblock_name'] . "',
|
||||
sysblock_description = '" . addslashes($_REQUEST['sysblock_description']) . "',
|
||||
sysblock_alias = '" . $_REQUEST['sysblock_alias'] . "',
|
||||
sysblock_text = '" . $_REQUEST['sysblock_text'] . "',
|
||||
sysblock_eval = '" . (int)$_REQUEST['sysblock_eval'] . "',
|
||||
sysblock_external = '" . (int)$_REQUEST['sysblock_external'] . "',
|
||||
sysblock_ajax = '" . (int)$_REQUEST['sysblock_ajax'] . "',
|
||||
sysblock_visual = '" . (int)$_REQUEST['sysblock_visual'] . "'
|
||||
WHERE
|
||||
id = '" . $sysblock_id . "'
|
||||
");
|
||||
|
||||
if ($sql->_result === false)
|
||||
{
|
||||
$message = $AVE_Template->get_config_vars('SYSBLOCK_SAVED_ERR');
|
||||
$header = $AVE_Template->get_config_vars('SYSBLOCK_ERROR');
|
||||
$theme = 'error';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $AVE_Template->get_config_vars('SYSBLOCK_SAVED');
|
||||
$header = $AVE_Template->get_config_vars('SYSBLOCK_SUCCESS');
|
||||
$theme = 'accept';
|
||||
|
||||
//-- Стираем кеш сисблока
|
||||
self::clearCache($sysblock_id, $_REQUEST['sysblock_alias']);
|
||||
|
||||
//-- Сохраняем системное сообщение в журнал
|
||||
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLUPDATE') . " (" . stripslashes($_REQUEST['sysblock_name']) . ") (id: $sysblock_id)");
|
||||
}
|
||||
|
||||
if (isAjax())
|
||||
{
|
||||
echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
|
||||
}
|
||||
else
|
||||
{
|
||||
$AVE_Template->assign('message', $message);
|
||||
header('Location:index.php?do=sysblocks&cp=' . SESSION);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$AVE_DB->Query("
|
||||
INSERT INTO
|
||||
" . PREFIX . "_sysblocks
|
||||
SET
|
||||
sysblock_name = '" . $_REQUEST['sysblock_name'] . "',
|
||||
sysblock_description = '" . addslashes($_REQUEST['sysblock_description']) . "',
|
||||
sysblock_alias = '" . $_REQUEST['sysblock_alias'] . "',
|
||||
sysblock_text = '" . $_REQUEST['sysblock_text'] . "',
|
||||
sysblock_author_id = '" . (int)$_SESSION['user_id'] . "',
|
||||
sysblock_eval = '" . (int)$_REQUEST['sysblock_eval'] . "',
|
||||
sysblock_external = '" . (int)$_REQUEST['sysblock_external'] . "',
|
||||
sysblock_ajax = '" . (int)$_REQUEST['sysblock_ajax'] . "',
|
||||
sysblock_visual = '" . (int)$_REQUEST['sysblock_visual'] . "',
|
||||
sysblock_created = '" . time() . "'
|
||||
");
|
||||
|
||||
$sysblock_id = $AVE_DB->InsertId();
|
||||
|
||||
//-- Сохраняем системное сообщение в журнал
|
||||
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLNEW') . " (" . stripslashes($_REQUEST['sysblock_name']) . ") (id: $sysblock_id)");
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['next_edit']))
|
||||
header('Location:index.php?do=sysblocks&cp=' . SESSION);
|
||||
else
|
||||
header('Location:index.php?do=sysblocks&action=edit&&id=' . $sysblock_id . '&cp=' . SESSION);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| delBlock
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Удаление системного блока
|
||||
|
|
||||
*/
|
||||
public static function delBlock ()
|
||||
{
|
||||
global $AVE_DB, $AVE_Template;
|
||||
|
||||
$sysblock_id = $_REQUEST['id'];
|
||||
|
||||
if (is_numeric($sysblock_id))
|
||||
{
|
||||
$sysblock = $AVE_DB->Query("
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
@ -263,17 +415,25 @@
|
||||
");
|
||||
|
||||
//-- Стираем кеш сисблока
|
||||
$this->clearCache($sysblock_id, $row->sysblock_alias);
|
||||
self::clearCache($sysblock_id, $sysblock->sysblock_alias);
|
||||
|
||||
//-- Сохраняем системное сообщение в журнал
|
||||
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLDEL') . " (" . stripslashes($row->sysblock_name) . ") (id: $sysblock_id)");
|
||||
reportLog($AVE_Template->get_config_vars('SYSBLOCK_SQLDEL') . " (" . stripslashes($sysblock->sysblock_name) . ") (id: $sysblock_id)");
|
||||
}
|
||||
|
||||
header('Location:index.php?do=sysblocks&cp=' . SESSION);
|
||||
}
|
||||
|
||||
|
||||
function clearCache ($id, $alias = null)
|
||||
/*
|
||||
|--------------------------------------------------------------------------------------
|
||||
| editBlock
|
||||
|--------------------------------------------------------------------------------------
|
||||
|
|
||||
| Очистка кеша системного блока
|
||||
|
|
||||
*/
|
||||
public static function clearCache ($id, $alias = null)
|
||||
{
|
||||
$from_id = BASE_DIR . '/tmp/cache/sql/sysblocks/' . $id;
|
||||
rrmdir($from_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user