dolibarr 19.0.4
modOauth.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2014-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
28include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29
30
31
36{
42 public function __construct($db)
43 {
44 $this->db = $db;
45 $this->numero = 66000;
46 // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
47 // It is used to group modules in module setup page
48 $this->family = "interface";
49 $this->module_position = '31';
50 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51 $this->name = preg_replace('/^mod/i', '', get_class($this));
52 // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
53 $this->description = "Enable OAuth2 authentication";
54 // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
55 $this->version = 'dolibarr';
56 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
57 // Name of image file used for this module.
58 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
59 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
60 $this->picto = 'technic';
61
62 // Data directories to create when module is enabled.
63 $this->dirs = array();
64
65 // Config pages
66 $this->config_page_url = array("oauth.php");
67
68 // Dependencies
69 $this->hidden = false; // A condition to hide module
70 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
71 $this->requiredby = array(); // List of module ids to disable if this one is disabled
72 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
73 $this->phpmin = array(7, 0); // Minimum version of PHP required by module // Minimum version of PHP required by module
74 $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module
75 $this->conflictwith = array();
76 $this->langfiles = array("oauth");
77
78 // Constants
79 $this->const = array();
80
81 // Boxes
82 $this->boxes = array();
83
84 // Permissions
85 $this->rights = array();
86 $this->rights_class = 'oauth';
87
88 $r = 0;
89 // $this->rights[$r][0] Id permission (unique tous modules confondus)
90 // $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
91 // $this->rights[$r][2] Non utilise
92 // $this->rights[$r][3] 1=Permis par defaut, 0=Non permis par defaut
93 // $this->rights[$r][4] Niveau 1 pour nommer permission dans code
94 // $this->rights[$r][5] Niveau 2 pour nommer permission dans code
95
96 /*$r++;
97 $this->rights[$r][0] = 66000;
98 $this->rights[$r][1] = 'OauthAccess';
99 $this->rights[$r][2] = 'r';
100 $this->rights[$r][3] = 0;
101 $this->rights[$r][4] = 'read';*/
102
103 // Main menu entries
104 $this->menu = array(); // List of menus to add
105 $r = 0;
106
107 // This is to declare the Top Menu entry:
108 //$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu
109 // 'type'=>'left', // This is a Top menu entry
110 // 'titre'=>'MenuOauth',
111 // 'mainmenu'=>'oauth',
112 // 'url'=>'/oauth/index.php',
113 // 'langs'=>'oauth', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
114 // 'position'=>300,
115 // 'enabled'=>'$conf->oauth->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',
116 // 'perms'=>'$user->rights->oauth->read', // Use 'perms'=>'1' if you want your menu with no permission rules
117 // 'target'=>'',
118 // 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
119
120 //$r++;
121 }
122
123
132 public function init($options = '')
133 {
134 global $conf;
135
136 // Clean before activation
137 $this->remove($options);
138
139 $sql = array();
140
141 return $this->_init($sql, $options);
142 }
143}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
Class to describe and activate module OAuth.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124