users_control_members.php
4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/**
* @author: Bunzia Alexander <nifus@mail.ru> <http://www.weblancer.net/users/nifus/>
* @copyright: Copyright (c) 2010, Bunzia Alexander
* @version: 1.0
* @license: http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @package: HiLo CMS
*/
class users_control_members{
private $error = false;
private $act = 'index';
private $JsHttpRequest = false;
public function __construct(){
global $MAIN_PAGE;
define('M_PATH',MAIN_SOURCE_PATH.'/modules/'.$MAIN_PAGE -> dirname() );
define('M_URL',MAIN_SOURCE_URL.'/modules/'.$MAIN_PAGE -> dirname() );
define('A_CHARSET', $MAIN_PAGE -> charset() );
include_once(M_PATH.'/inc/url.php');
include_once(MAIN_PATH.'/tmp/config/users.php');
include_once(MAIN_SOURCE_PATH.'/inc/class.html.php');
include(MAIN_SOURCE_PATH.'/ext/ajax/JsHttpRequest.php');
$this -> JsHttpRequest = new JsHttpRequest( A_CHARSET );
$this -> act = !empty($_REQUEST['act']) ? $_REQUEST['act'] : $this -> act;
$GLOBALS['_RESULT']['id_request'] = !empty($_REQUEST['id_request']) ? $_REQUEST['id_request'] : 0;
}
public function get(){
$func = $this -> act;
if ( !method_exists($this ,$func) ){
sys_error(ERROR_404);
}
return $this -> $func();
}
private function index(){
global $MAIN_PAGE;
$t = new PHPTAL( M_PATH.'/tmpl/control_members/main.html' );
$p = new usersQuery('u');
$p -> orderby_id('DESC');
$p -> set_page(1);
$p -> set_count_rows( $MAIN_PAGE -> config('users_pub_on_page') );
//$p -> set_debug(1);
$p -> get('
u.u_active AS row_class,
u.u_type AS user_type,
u.u_login AS url_user_comments,
u.*',true);
$t -> rows =$p -> rows() ;
$count = $p -> get_count_rows();
if ( !empty($count) ){
include_once(MAIN_SOURCE_PATH.'/inc/class.pagenav.php');
$pn = new page_nav( $count);
$pn -> set_limit( $MAIN_PAGE -> config('users_pub_on_page') );
$pn -> set_url_tmpl(URL_PAGE_NAV);
$t -> page_nav = $pn -> get(1);
}
// подгружаем библиотеки
upload_img::include_files();
return $t -> execute();
}
/* AJAX */
private function ajax_reload(){
global $MAIN_PAGE;
sys_block_disable();
$t = new PHPTAL( M_PATH.'/tmpl/control_members/inc/row.html' );
$t -> execute = true;
$p = new usersQuery('u');
if ( !empty($_REQUEST['orderby_key']) ){
$p -> $_REQUEST['orderby_key']( $_REQUEST['orderby_value']);
}else{
$p -> orderby_id('DESC');
}
if ( !empty($_REQUEST['filter_active']) ){
if ( $_REQUEST['filter_active']==5){
$_REQUEST['filter_active']=0;
}
$p -> where_active( $_REQUEST['filter_active'] );
}
if ( !empty($_REQUEST['filter_group']) ){
$p -> where_group( $_REQUEST['filter_group'] );
}
$p -> where_id( $_REQUEST['filter_id'] );
$p -> where_like_login( $_REQUEST['filter_login'] );
$p -> set_page($_REQUEST['page']);
$p -> set_count_rows( $MAIN_PAGE -> config('users_pub_on_page') );
//$p -> set_debug(1);
$p -> get('
u.u_active AS row_class,
u.u_login AS profile_url,
u.*',true);
$t -> rows = $p -> rows() ;
$count = $p -> get_count_rows();
if ( !empty($count) ){
include_once(MAIN_SOURCE_PATH.'/inc/class.pagenav.php');
$pn = new page_nav( $count);
$pn -> set_limit( $MAIN_PAGE -> config('users_pub_on_page') );
$pn -> set_url_tmpl(URL_PAGE_NAV);
$t -> page_nav = $pn -> get($_REQUEST['page']);
}
$GLOBALS['_RESULT']['content'] = $t -> execute();
exit();
}
private function ajax_delete(){
sys_block_disable();
$m = users::load_id($_REQUEST['id']);
if ( false===$m ){
die( A_EMPTY_ID );
}
$m -> delete();
exit();
}
/**
* форма редактирования пользователя
*
*/
private function ajax_edit(){
global $MAIN_PAGE;
sys_block_disable();
$b = new usersQuery('u');
//$b -> set_debug(1);
if ( !$b -> where_id($_GET['id']) )
{
$row = array('u_id'=>0,'groups_list'=> filedsGetUsers::groups_list(), 'upl_img'=> filedsGetUsers::upl_img(),);
}
else
{
$b -> get(
'u.*,
u.u_active as u_active_checked,
u.u_avatar as upl_img,
u.u_active AS `unconfirm`,
u.g_id as groups_list');
$row = $b -> row();
}
$t = new PHPTAL( false);
$t -> setSnippet('users','users_control_members_ajax_edit');
$t -> row = $row;
$GLOBALS['_RESULT']['content'] = $t -> execute();
$GLOBALS['_RESULT']['title'] = EDIT;
exit();
}
/**
* Сохраняем пользователя
*
*/
private function ajax_save(){
sys_block_disable();
$p = users::load_id($_REQUEST['id']);
if ( false===$p )
{
$p = users::create();
$create = true;
$p -> set('u_time_reg',MAIN_TIME);
}
//$p -> set_debug(1);
try
{
foreach( $_POST['form'] as $k=>$v )
{
$p -> set($k,$v);
}
$id = ( true===$create) ? $p -> insert() : $p -> update();
}
catch( Exception $e )
{
sys_error(ERROR_501,$e -> getMessage() );
}
$GLOBALS['_RESULT']['msg'] = MOD_SAVE;
exit();
}
}
?>