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

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

Initial version

File size: 10.5 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                $page['all_users'] = LCAS_get_user_list();
197
198// +-----------------------------------------------------------------------+
199// |                           Template Init                               |
200// +-----------------------------------------------------------------------+
201                /*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
202
203    if (isset($_GET['start']) and is_numeric($_GET['start']))
204    {
205      $start = $_GET['start'];
206    }
207    else
208    {
209      $start = 0;
210    }*/
211
212// +-----------------------------------------------------------------------+
213// |                            navigation bar                             |
214// +-----------------------------------------------------------------------+
215
216/*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
217
218$navbar = create_navigation_bar(
219  $url,
220  count($page['filtered_users']),
221  $start,
222  $conf['users_page']
223  );
224
225$template->assign('navbar', $navbar);*/
226
227// +-----------------------------------------------------------------------+
228// |                               user list                               |
229// +-----------------------------------------------------------------------+
230
231    $visible_user_list = array();
232    foreach ($page['all_users'] as $num => $local_user)
233    {
234// simulate LIMIT $start, $conf['users_page']
235                        /*if ($num < $start)
236      {
237        continue;
238      }
239      if ($num >= $start + $conf['users_page'])
240      {
241        break;
242      }*/
243
244      $visible_user_list[] = $local_user;
245                }
246
247                foreach ($visible_user_list as $local_user)
248    {
249      $lcas_SendEmail  = l10n('Send_Email'); 
250      $lcas_UpdateUser = l10n('Update_User'); 
251      $display = 'green';
252                        $display = '';
253
254                $template->append(
255                'users',
256        array(
257                'ID'          => $local_user['id'],
258                'USERNAME'    => stripslashes($local_user['username'].' | '.LCAS_change_case($local_user['username'], 1).' | '.LCAS_change_case($local_user['username'], 2).' | '.LCAS_change_case($local_user['username'], 3)),
259                                        'EMAIL'       => get_email_address_as_display_text($local_user['email']),
260          'LASTVISIT'   => $lcas_UpdateUser,
261          'DAYS'        => $lcas_SendEmail,
262          'DISPLAY'     => $display,
263                                )
264                        );
265                }
266    /* Plugin version inserted */
267    $template->assign(
268      array(
269        'LCAS_VERSION'  => $version,
270        'LCAS_PATH'     => LCAS_PATH,
271      )
272    );   
273// +-----------------------------------------------------------------------+
274// |                             errors display                            |
275// +-----------------------------------------------------------------------+
276                if ( isset ($errors) and count($errors) != 0)
277                {
278                $template->assign('errors',array());
279                        foreach ($errors as $error)
280                {
281                                array_push($page['errors'], $error);
282                }
283                } 
284
285// +-----------------------------------------------------------------------+
286// |                           templates display                           |
287// +-----------------------------------------------------------------------+
288                $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/userlist.tpl');
289    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
290  }
291  else
292  {
293                array_push($page['errors'], l10n('Err_Userlist_Settings'));
294  }
295  break;
296
297}
298?>
Note: See TracBrowser for help on using the repository browser.