Skip to content

Commit dfb78da

Browse files
committed
Support for edit system groups
1 parent 417d8d3 commit dfb78da

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

modules/users/admin/groups.php

+20-6
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,9 @@
280280
if (defined('NV_IS_SPADMIN')) {
281281
$post = array();
282282
$post['id'] = $nv_Request->get_int('id', 'get');
283+
283284
if ($nv_Request->isset_request('edit', 'get')) {
284-
if (empty($post['id']) or ! isset($groupsList[$post['id']]) or $post['id'] < 10 or $groupsList[$post['id']]['idsite'] != $global_config['idsite']) {
285+
if (empty($post['id']) or ! isset($groupsList[$post['id']]) or $groupsList[$post['id']]['idsite'] != $global_config['idsite']) {
285286
Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op);
286287
die();
287288
}
@@ -305,7 +306,6 @@
305306
die($lang_module['title_empty']);
306307
}
307308

308-
309309
// Kiểm tra trùng tên nhóm
310310
$stmt = $db->prepare('SELECT group_id FROM ' . NV_GROUPS_GLOBALTABLE . ' WHERE title LIKE :title AND group_id!= ' . intval($post['id']) . ' AND (idsite=' . $global_config['idsite'] . ' or (idsite=0 AND siteus=1))');
311311
$stmt->bindParam(':title', $post['title'], PDO::PARAM_STR);
@@ -339,7 +339,7 @@
339339
$post['siteus'] = 0;
340340
}
341341

342-
if (isset($post['id']) and $post['id'] > 3) {
342+
if (isset($post['id']) and $post['id'] > 9) {
343343
$stmt = $db->prepare("UPDATE " . NV_GROUPS_GLOBALTABLE . " SET
344344
title= :title,
345345
description= :description,
@@ -382,9 +382,11 @@
382382
$post['content'] = nv_editor_br2nl($post['content']);
383383
$post['exp_time'] = ! empty($post['exp_time']) ? date('d/m/Y', $post['exp_time']) : '';
384384
$post['siteus'] = $post['siteus'] ? ' checked="checked"' : '';
385+
$post['id'] = $post['group_id'];
385386
} else {
386387
$post['title'] = $post['description'] = $post['content'] = $post['exp_time'] = '';
387388
$post['group_type'] = 0;
389+
$post['id'] = 0;
388390
}
389391

390392
$post['content'] = htmlspecialchars(nv_editor_br2nl($post['content']));
@@ -415,7 +417,11 @@
415417
$xtpl->assign('CONTENT', $_cont);
416418
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
417419
$xtpl->assign('NV_LANG_INTERFACE', NV_LANG_INTERFACE);
418-
420+
421+
if ($post['id'] > 9 or $post['id'] == 0) {
422+
$xtpl->parse('add.basic_infomation');
423+
}
424+
419425
$xtpl->parse('add');
420426
$contents = $xtpl->text('add');
421427
} else {
@@ -428,7 +434,7 @@
428434
die();
429435
}
430436

431-
// Danh sach nhom
437+
// Danh sach nhom (AJAX)
432438
if ($nv_Request->isset_request('list', 'get')) {
433439
$weight_op = 1;
434440
foreach ($groupsList as $group_id => $values) {
@@ -450,13 +456,19 @@
450456
'link_userlist' => $link_userlist
451457
);
452458

453-
if (defined('NV_IS_SPADMIN') and $group_id > 9 and $values['idsite'] == $global_config['idsite']) {
459+
if (defined('NV_IS_SPADMIN') and $values['idsite'] == $global_config['idsite']) {
454460
$_bg = (empty($global_config['idsite'])) ? $weight_op : 1;
461+
455462
for ($i = $_bg; $i <= $groupcount; $i++) {
456463
$opt = array( 'value' => $i, 'selected' => $i == $values['weight'] ? ' selected="selected"' : '' );
457464
$xtpl->assign('NEWWEIGHT', $opt);
458465
$xtpl->parse('list.loop.option');
459466
}
467+
468+
if ($group_id > 9) {
469+
$xtpl->parse('list.loop.action.delete');
470+
}
471+
460472
$xtpl->parse('list.loop.action');
461473
} else {
462474
++$weight_op;
@@ -472,9 +484,11 @@
472484
$xtpl->assign('LOOP', $loop);
473485
$xtpl->parse('list.loop');
474486
}
487+
475488
if (defined('NV_IS_SPADMIN')) {
476489
$xtpl->parse('list.action_js');
477490
}
491+
478492
$xtpl->parse('list');
479493
$xtpl->out('list');
480494
exit();

themes/admin_default/modules/users/groups.tpl

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<div id="pageContent">
99
<form id="addCat" method="post" action="{ACTION_URL}">
1010
<h3 class="myh3">{PTITLE}</h3>
11+
<!-- BEGIN: basic_infomation -->
1112
<div class="table-responsive">
1213
<table class="table table-striped table-bordered table-hover">
1314
<colgroup>
@@ -50,6 +51,7 @@
5051
<div>
5152
{CONTENT}
5253
</div>
54+
<!-- END: basic_infomation -->
5355
<input type="hidden" name="save" value="1" />
5456
<p class="text-center"><input name="submit" type="submit" value="{LANG.save}" class="btn btn-primary w100" style="margin-top: 10px" /></p>
5557
</form>
@@ -125,7 +127,7 @@
125127
<td>
126128
<!-- BEGIN: action -->
127129
<em class="fa fa-edit fa-lg">&nbsp;</em> <a href="{MODULE_URL}={OP}&edit&id={GROUP_ID}">{GLANG.edit}</a> &nbsp;
128-
<em class="fa fa-trash-o fa-lg">&nbsp;</em> <a class="del" href="{GROUP_ID}">{GLANG.delete}</a>
130+
<!-- BEGIN: delete --><em class="fa fa-trash-o fa-lg">&nbsp;</em> <a class="del" href="{GROUP_ID}">{GLANG.delete}</a><!-- END: delete -->
129131
<!-- END: action -->
130132
</td>
131133
</tr>

0 commit comments

Comments
 (0)