source: extensions/LCAS/trunk/main.inc.php @ 8141

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

Initial version

File size: 3.5 KB
Line 
1<?php
2/*
3Plugin Name: LCAS
4Version: 0.0.1
5Description: Allow to disable login/register name to be sensible to the case/accents
6Plugin URI: http://fr.piwigo.org/forum/viewtopic.php?pid=158563
7Author: Nicco, Eric, LucMorizur, Whiler
8Author URI: http://gallery-nicco.no-ip.org, http://www.infernoweb.net, http://blogs.wittwer.fr/whiler/
9*/
10
11/* History:  LCAS_PATH.'Changelog.txt.php' */
12
13/*
14 ***** TODO List *****
15See project bugtracker: http://piwigo.org/bugs/my_view_page.php
16*/
17
18if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
19if (!defined('LCAS_DIR')) define('LCAS_DIR' , basename(dirname(__FILE__)));
20if (!defined('LCAS_PATH')) define('LCAS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
21
22include_once (LCAS_PATH.'include/constants.php');
23include_once (LCAS_PATH.'include/functions.inc.php');
24
25load_language('plugin.lang', LCAS_PATH);
26
27
28/* Plugin admin */
29add_event_handler('get_admin_plugin_menu_links', 'LCAS_admin_menu');
30
31function LCAS_admin_menu($menu)
32{
33// +-----------------------------------------------------------------------+
34// |                      Getting plugin name                              |
35// +-----------------------------------------------------------------------+
36  $plugin =  LCAS_PluginInfos(LCAS_PATH);
37  $name = $plugin['name'];
38 
39  array_push($menu,
40    array(
41      'NAME' => $name,
42      'URL'  => get_admin_plugin_menu_link(LCAS_PATH.'/admin/LCAS_admin.php')
43    )
44  );
45
46  return $menu;
47}
48
49/* User creation */
50add_event_handler('register_user', 'LCAS_Adduser');
51
52function LCAS_Adduser($register_user)
53{
54  global $conf;
55
56  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
57
58}
59
60
61/* User deletion */
62add_event_handler('delete_user', 'LCAS_Deluser');
63
64function LCAS_Deluser($user_id)
65{
66
67}
68
69
70// Check users registration
71add_event_handler('register_user_check', 'LCAS_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
72
73function LCAS_RegistrationCheck($errors, $user)
74{
75  global $conf;
76
77}
78
79
80if (script_basename() == 'profile')
81{
82  add_event_handler('loc_begin_profile', 'LCAS_Profile_Init');
83
84  function LCAS_Profile_Init()
85  {
86
87  }
88}
89
90
91// RedirectToProfile - Thx to LucMorizur
92// redirects a visitor (except for admins, webmasters and generic statuses) to his
93// profile.php page
94//
95// no variable, no return
96add_event_handler('login_success', 'LCAS_RedirectToProfile');
97
98function LCAS_RedirectToProfile()
99{
100  global $conf, $user;
101 
102  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
103 
104  $query ='
105SELECT user_id, status
106FROM '.USER_INFOS_TABLE.'
107WHERE user_id = '.$user['id'].'
108;';
109  $data = pwg_db_fetch_assoc(pwg_query($query));
110 
111  if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic")
112  {
113    if ((isset($conf_LCAS[21]) and $conf_LCAS[21] == 'true'))
114    {
115      $user_idsOK = array();
116      if (!check_consult($user['id'], $user_idsOK))
117        redirect(PHPWG_ROOT_PATH.'profile.php');
118    }
119  }
120}
121
122
123add_event_handler('init', 'LCAS_InitPage');
124/* *** Important ! This is necessary to make email exclusion work in admin's users management panel *** */
125function LCAS_InitPage()
126{
127  load_language('plugin.lang', LCAS_PATH);
128  global $conf, $template, $page, $lang, $errors;
129
130  $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']);
131
132/* Admin user management */
133  if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list')
134  {
135    if (isset($_POST['submit_add']))
136    {
137
138    }
139  }
140}
141
142?>
Note: See TracBrowser for help on using the repository browser.