PageRenderTime 39ms CodeModel.GetById 3ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/core/modules/modUser.class.php

https://github.com/asterix14/dolibarr
PHP | 259 lines | 163 code | 38 blank | 58 comment | 1 complexity | 7d8ba816bfb695918f40fe9e1332aaad MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \defgroup user Module user management
  21. * \brief Module pour gerer les utilisateurs
  22. * \file htdocs/core/modules/modUser.class.php
  23. * \ingroup user
  24. * \brief Fichier de description et activation du module Utilisateur
  25. */
  26. include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
  27. /**
  28. * \class modUser
  29. * \brief Classe de description et activation du module User
  30. */
  31. class modUser extends DolibarrModules
  32. {
  33. /**
  34. * Constructor. Define names, constants, directories, boxes, permissions
  35. *
  36. * @param DoliDB $DB Database handler
  37. */
  38. function modUser($DB)
  39. {
  40. global $conf;
  41. $this->db = $DB ;
  42. $this->numero = 0;
  43. $this->family = "base"; // Family for module (or "base" if core module)
  44. // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
  45. $this->name = preg_replace('/^mod/i','',get_class($this));
  46. $this->description = "Gestion des utilisateurs (requis)";
  47. $this->always_enabled = 1; // Can't be disabled
  48. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
  49. $this->version = 'dolibarr';
  50. $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
  51. $this->special = 0;
  52. $this->picto='group';
  53. // Data directories to create when module is enabled
  54. $this->dirs = array("/users/temp");
  55. // Config pages
  56. $this->config_page_url = array("user.php");
  57. // Dependancies
  58. $this->depends = array();
  59. $this->requiredby = array();
  60. $this->langfiles = array("main","users","companies");
  61. // Constants
  62. $this->const = array();
  63. // Boxes
  64. $this->boxes = array();
  65. // Permissions
  66. $this->rights = array();
  67. $this->rights_class = 'user';
  68. $this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled)
  69. $r=0;
  70. $r++;
  71. $this->rights[$r][0] = 251;
  72. $this->rights[$r][1] = 'Consulter les autres utilisateurs';
  73. $this->rights[$r][2] = 'r';
  74. $this->rights[$r][3] = 0;
  75. $this->rights[$r][4] = 'user';
  76. $this->rights[$r][5] = 'lire';
  77. $r++;
  78. $this->rights[$r][0] = 252;
  79. $this->rights[$r][1] = 'Consulter les permissions des autres utilisateurs';
  80. $this->rights[$r][2] = 'r';
  81. $this->rights[$r][3] = 0;
  82. $this->rights[$r][4] = 'user_advance';
  83. $this->rights[$r][5] = 'readperms';
  84. $r++;
  85. $this->rights[$r][0] = 253;
  86. $this->rights[$r][1] = 'Creer/modifier utilisateurs internes et externes';
  87. $this->rights[$r][2] = 'w';
  88. $this->rights[$r][3] = 0;
  89. $this->rights[$r][4] = 'user';
  90. $this->rights[$r][5] = 'creer';
  91. $r++;
  92. $this->rights[$r][0] = 254;
  93. $this->rights[$r][1] = 'Creer/modifier utilisateurs externes seulement';
  94. $this->rights[$r][2] = 'w';
  95. $this->rights[$r][3] = 0;
  96. $this->rights[$r][4] = 'user_advance';
  97. $this->rights[$r][5] = 'write';
  98. $r++;
  99. $this->rights[$r][0] = 255;
  100. $this->rights[$r][1] = 'Modifier le mot de passe des autres utilisateurs';
  101. $this->rights[$r][2] = 'w';
  102. $this->rights[$r][3] = 0;
  103. $this->rights[$r][4] = 'user';
  104. $this->rights[$r][5] = 'password';
  105. $r++;
  106. $this->rights[$r][0] = 256;
  107. $this->rights[$r][1] = 'Supprimer ou desactiver les autres utilisateurs';
  108. $this->rights[$r][2] = 'd';
  109. $this->rights[$r][3] = 0;
  110. $this->rights[$r][4] = 'user';
  111. $this->rights[$r][5] = 'supprimer';
  112. $r++;
  113. $this->rights[$r][0] = 341;
  114. $this->rights[$r][1] = 'Consulter ses propres permissions';
  115. $this->rights[$r][2] = 'r';
  116. $this->rights[$r][3] = 1;
  117. $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  118. $this->rights[$r][5] = 'readperms';
  119. $r++;
  120. $this->rights[$r][0] = 342;
  121. $this->rights[$r][1] = 'Creer/modifier ses propres infos utilisateur';
  122. $this->rights[$r][2] = 'w';
  123. $this->rights[$r][3] = 1;
  124. $this->rights[$r][4] = 'self';
  125. $this->rights[$r][5] = 'creer';
  126. $r++;
  127. $this->rights[$r][0] = 343;
  128. $this->rights[$r][1] = 'Modifier son propre mot de passe';
  129. $this->rights[$r][2] = 'w';
  130. $this->rights[$r][3] = 1;
  131. $this->rights[$r][4] = 'self';
  132. $this->rights[$r][5] = 'password';
  133. $r++;
  134. $this->rights[$r][0] = 344;
  135. $this->rights[$r][1] = 'Modifier ses propres permissions';
  136. $this->rights[$r][2] = 'w';
  137. $this->rights[$r][3] = 1;
  138. $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  139. $this->rights[$r][5] = 'writeperms';
  140. $r++;
  141. $this->rights[$r][0] = 351;
  142. $this->rights[$r][1] = 'Consulter les groupes';
  143. $this->rights[$r][2] = 'r';
  144. $this->rights[$r][3] = 0;
  145. $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  146. $this->rights[$r][5] = 'read';
  147. $r++;
  148. $this->rights[$r][0] = 352;
  149. $this->rights[$r][1] = 'Consulter les permissions des groupes';
  150. $this->rights[$r][2] = 'r';
  151. $this->rights[$r][3] = 0;
  152. $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  153. $this->rights[$r][5] = 'readperms';
  154. $r++;
  155. $this->rights[$r][0] = 353;
  156. $this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';
  157. $this->rights[$r][2] = 'w';
  158. $this->rights[$r][3] = 0;
  159. $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  160. $this->rights[$r][5] = 'write';
  161. $r++;
  162. $this->rights[$r][0] = 354;
  163. $this->rights[$r][1] = 'Supprimer ou desactiver les groupes';
  164. $this->rights[$r][2] = 'd';
  165. $this->rights[$r][3] = 0;
  166. $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
  167. $this->rights[$r][5] = 'delete';
  168. $r++;
  169. $this->rights[$r][0] = 358;
  170. $this->rights[$r][1] = 'Exporter les utilisateurs';
  171. $this->rights[$r][2] = 'r';
  172. $this->rights[$r][3] = 0;
  173. $this->rights[$r][4] = 'user';
  174. $this->rights[$r][5] = 'export';
  175. // Exports
  176. //--------
  177. $r=0;
  178. $r++;
  179. $this->export_code[$r]=$this->rights_class.'_'.$r;
  180. $this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs';
  181. $this->export_permission[$r]=array(array("user","user","export"));
  182. $this->export_fields_array[$r]=array('u.rowid'=>"Id",'u.login'=>"Login",'u.name'=>"Lastname",'u.firstname'=>"Firstname",'u.office_phone'=>'Tel','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",'u.admin'=>"Admin",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion','u.fk_socpeople'=>"IdContact",'u.fk_societe'=>"IdCompany",'u.fk_member'=>"MemberId");
  183. $this->export_entities_array[$r]=array('u.rowid'=>"user",'u.login'=>"user",'u.name'=>"user",'u.firstname'=>"user",'u.office_phone'=>'user','u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user",'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_societe'=>"company",'u.fk_member'=>"member");
  184. if (empty($conf->adherent->enabled))
  185. {
  186. unset($this->export_fields_array[$r]['u.fk_member']);
  187. unset($this->export_entities_array[$r]['u.fk_member']);
  188. }
  189. $this->export_sql_start[$r]='SELECT DISTINCT ';
  190. $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
  191. $this->export_sql_end[$r] .=' WHERE u.entity IN (0,'.$conf->entity.')';
  192. }
  193. /**
  194. * Function called when module is enabled.
  195. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  196. * It also creates data directories.
  197. *
  198. * @return int 1 if OK, 0 if KO
  199. */
  200. function init()
  201. {
  202. global $conf;
  203. // Permissions
  204. $this->remove();
  205. $sql = array();
  206. return $this->_init($sql);
  207. }
  208. /**
  209. * Function called when module is disabled.
  210. * Remove from database constants, boxes and permissions from Dolibarr database.
  211. * Data directories are not deleted.
  212. *
  213. * @return int 1 if OK, 0 if KO
  214. */
  215. function remove()
  216. {
  217. $sql = array();
  218. return $this->_remove($sql);
  219. }
  220. }
  221. ?>