source: extensions/LCAS/trunk/admin/LCAS_admin.php @ 8143

Last change on this file since 8143 was 8143, checked in by Whiler, 13 years ago

Parameters labels weren't good... (opposite from what we are expecting) - fixed
Second tab only show users who are duplicated with the chosen options

File size: 10.6 KB
Line 
1<?php
2
3global $user, $lang, $conf, $errors;
4
5if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
6// +-----------------------------------------------------------------------+
7// | Check Access and exit when user status is not ok                      |
8// +-----------------------------------------------------------------------+
9check_status(ACCESS_ADMINISTRATOR);
10
11if (!defined('LCAS_PATH')) define('LCAS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
12
13//ini_set('error_reporting', E_ALL);
14//ini_set('display_errors', true);
15
16include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
17include_once (PHPWG_ROOT_PATH.'/include/constants.php');
18$my_base_url = get_admin_plugin_menu_link(__FILE__);
19
20load_language('plugin.lang', LCAS_PATH);
21load_language('help/plugin.lang', LCAS_PATH);
22
23$page['global'] = array();
24$error = array();
25$pattern = '/;/';
26$replacement = '.';
27
28$LCAS_Password_Test_Score = 0;
29$LCAS_Exclusionlist_Error = false;
30
31// +-----------------------------------------------------------------------+
32// |                            Tabssheet                                  |
33// +-----------------------------------------------------------------------+
34if (!isset($_GET['tab']))
35        $page['tab'] = 'global';
36else
37  $page['tab'] = $_GET['tab'];
38
39$tabsheet = new tabsheet();
40$tabsheet->add('global',
41               l10n('Tab_Global'),
42               $my_base_url.'&amp;tab=global');
43  $tabsheet->add('userlist',
44                 l10n('Tab_UserList'),
45                 $my_base_url.'&amp;tab=userlist');
46$tabsheet->select($page['tab']);
47$tabsheet->assign();
48
49
50// +-----------------------------------------------------------------------+
51// |                      Getting plugin version                           |
52// +-----------------------------------------------------------------------+
53$plugin =  LCAS_PluginInfos(LCAS_PATH);
54$version = $plugin['version'];
55
56
57// +----------------------------------------------------------+
58// |            FCK Editor for email text fields              |
59// +----------------------------------------------------------+
60
61/* Available only for ConfirmMail return page customization */
62$toolbar = 'Basic';
63$width = '750px';
64$height = '300px';
65$areas = array();
66array_push( $areas,'LCAS_ConfirmMail_Custom_Txt1','LCAS_ConfirmMail_Custom_Txt2');
67
68if (function_exists('set_fckeditor_instance'))
69{
70  $fcke_config = unserialize($conf['FCKEditor']);
71  foreach($areas as $area)
72  {
73    if (!isset($fcke_config[$area]))
74    {
75      $fcke_config[$area] = false;
76    }
77  }
78  $conf['FCKEditor'] = serialize($fcke_config);
79
80  set_fckeditor_instance($areas, $toolbar, $width, $height);
81}
82
83
84// +-----------------------------------------------------------------------+
85// |                            Tabssheet select                           |
86// +-----------------------------------------------------------------------+
87
88switch ($page['tab'])
89{
90// *************************************************************************
91// +-----------------------------------------------------------------------+
92// |                           Global Config                               |
93// +-----------------------------------------------------------------------+
94// *************************************************************************
95  case 'global':
96
97        if (isset($_POST['submit']) and !is_adviser() and isset($_POST['LCAS_Mail_Info']) and isset($_POST['LCAS_Confirm_Mail']) )
98  {
99
100/* General configuration settings */
101
102/* Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them */
103                $newconf_LCAS= array(
104      $_POST['LCAS_Mail_Info'],
105      $_POST['LCAS_Confirm_Mail']);
106
107    $conf['LoginCaseAccentsSensitivity'] = serialize($newconf_LCAS);
108
109                $query = '
110                UPDATE '.CONFIG_TABLE.'
111                SET value="'.addslashes($conf['LoginCaseAccentsSensitivity']).'"
112                WHERE param="LoginCaseAccentsSensitivity"
113                LIMIT 1
114                ;';
115               
116                pwg_query($query);
117
118                array_push($page['infos'], l10n('LCAS_save_config'));
119  }
120
121
122  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
123
124
125/* Save last opened paragraph in configuration tab */
126  $nb_para=(isset($_POST["nb_para"])) ? $_POST["nb_para"]:"";
127  $nb_para2=(isset($_POST["nb_para2"])) ? $_POST["nb_para2"]:"";
128
129  $template->assign(
130    array(
131    'nb_para'                        => $nb_para,
132    'nb_para2'                       => $nb_para2,
133    'LCAS_VERSION'                    => $version,
134    'LCAS_PATH'                       => LCAS_PATH,
135                'LCAS_MAIL_INFO_TRUE'             => $conf_LCAS[0]=='true' ?  'checked="checked"' : '' ,
136                'LCAS_MAIL_INFO_FALSE'            => $conf_LCAS[0]=='false' ?  'checked="checked"' : '' ,
137                'LCAS_CONFIRM_MAIL_TRUE'          => $conf_LCAS[1]=='true' ?  'checked="checked"' : '' ,
138                'LCAS_CONFIRM_MAIL_FALSE'         => $conf_LCAS[1]=='false' ?  'checked="checked"' : '' ,
139    )
140  );
141
142
143// +-----------------------------------------------------------------------+
144// |                             errors display                            |
145// +-----------------------------------------------------------------------+
146  if (isset ($errors) and count($errors) != 0)
147  {
148          $template->assign('errors',array());
149          foreach ($errors as $error)
150          {
151                  array_push($page['errors'], $error);
152                }
153        } 
154
155// +-----------------------------------------------------------------------+
156// |                           templates display                           |
157// +-----------------------------------------------------------------------+
158  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/global.tpl');
159  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
160
161  break;
162
163
164// *************************************************************************
165// +-----------------------------------------------------------------------+
166// |                           Users list page                             |
167// +-----------------------------------------------------------------------+
168// *************************************************************************
169  case 'userlist':
170 
171  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
172 
173  if ((isset($conf_LCAS[0]) and $conf_LCAS[0]=='true') || (isset($conf_LCAS[1]) and $conf_LCAS[1]=='true'))
174  {
175// +-----------------------------------------------------------------------+
176// |                           initialization                              |
177// +-----------------------------------------------------------------------+
178
179                if (!defined('PHPWG_ROOT_PATH'))
180    {
181        die('Hacking attempt!');
182    }
183         
184    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
185
186// +-----------------------------------------------------------------------+
187// | Check Access and exit when user status is not ok                      |
188// +-----------------------------------------------------------------------+
189                check_status(ACCESS_ADMINISTRATOR);
190
191
192// +-----------------------------------------------------------------------+
193// |                               user list                               |
194// +-----------------------------------------------------------------------+
195
196                if ($conf_LCAS[0]=='true' && $conf_LCAS[1]=='true')
197                        $lcas_rule = 2;
198                else if ($conf_LCAS[0]=='true')
199                        $lcas_rule = 1;
200                else if ($conf_LCAS[1]=='true')
201                        $lcas_rule = 3;
202                else
203                        $lcas_rule = 0;
204               
205                $page['all_users'] = LCAS_get_user_list($lcas_rule);
206
207// +-----------------------------------------------------------------------+
208// |                           Template Init                               |
209// +-----------------------------------------------------------------------+
210                /*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
211
212    if (isset($_GET['start']) and is_numeric($_GET['start']))
213    {
214      $start = $_GET['start'];
215    }
216    else
217    {
218      $start = 0;
219    }*/
220
221// +-----------------------------------------------------------------------+
222// |                            navigation bar                             |
223// +-----------------------------------------------------------------------+
224
225/*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
226
227$navbar = create_navigation_bar(
228  $url,
229  count($page['filtered_users']),
230  $start,
231  $conf['users_page']
232  );
233
234$template->assign('navbar', $navbar);*/
235
236// +-----------------------------------------------------------------------+
237// |                               user list                               |
238// +-----------------------------------------------------------------------+
239
240    $visible_user_list = array();
241    foreach ($page['all_users'] as $num => $local_user)
242    {
243// simulate LIMIT $start, $conf['users_page']
244                        /*if ($num < $start)
245      {
246        continue;
247      }
248      if ($num >= $start + $conf['users_page'])
249      {
250        break;
251      }*/
252
253      $visible_user_list[] = $local_user;
254                }
255
256                foreach ($visible_user_list as $local_user)
257    {
258      $lcas_SendEmail  = l10n('Send_Email'); 
259      $lcas_UpdateUser = l10n('Update_User'); 
260      $display = 'green';
261                        $display = '';
262
263                $template->append(
264                'users',
265        array(
266                'ID'          => $local_user['id'],
267                'USERNAME'    => stripslashes($local_user['username'].' | '.$local_user['transformed']),
268                                        'EMAIL'       => get_email_address_as_display_text($local_user['email']),
269          'LASTVISIT'   => $lcas_UpdateUser,
270          'DAYS'        => $lcas_SendEmail,
271          'DISPLAY'     => $display,
272                                )
273                        );
274                }
275    /* Plugin version inserted */
276    $template->assign(
277      array(
278        'LCAS_VERSION'  => $version,
279        'LCAS_PATH'     => LCAS_PATH,
280      )
281    );   
282// +-----------------------------------------------------------------------+
283// |                             errors display                            |
284// +-----------------------------------------------------------------------+
285                if ( isset ($errors) and count($errors) != 0)
286                {
287                $template->assign('errors',array());
288                        foreach ($errors as $error)
289                {
290                                array_push($page['errors'], $error);
291                }
292                } 
293
294// +-----------------------------------------------------------------------+
295// |                           templates display                           |
296// +-----------------------------------------------------------------------+
297                $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/userlist.tpl');
298    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
299  }
300  else
301  {
302                array_push($page['errors'], l10n('Err_Userlist_Settings'));
303  }
304  break;
305
306}
307?>
Note: See TracBrowser for help on using the repository browser.