dolibarr 21.0.0-alpha
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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 3 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 <https://www.gnu.org/licenses/>.
18 */
19
29include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30
31
32
37{
43 public function __construct($db)
44 {
45 $this->db = $db;
46 $this->numero = 66000;
47 // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
48 // It is used to group modules in module setup page
49 $this->family = "interface";
50 $this->module_position = '31';
51 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52 $this->name = preg_replace('/^mod/i', '', get_class($this));
53 // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
54 $this->description = "Enable OAuth2 authentication";
55 // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
56 $this->version = 'dolibarr';
57 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58 // Name of image file used for this module.
59 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
60 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
61 $this->picto = 'technic';
62
63 // Data directories to create when module is enabled.
64 $this->dirs = array();
65
66 // Config pages
67 $this->config_page_url = array("oauth.php");
68
69 // Dependencies
70 $this->hidden = false; // A condition to hide module
71 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
72 $this->requiredby = array(); // List of module ids to disable if this one is disabled
73 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
74 $this->phpmin = array(7, 0); // Minimum version of PHP required by module // Minimum version of PHP required by module
75 $this->need_dolibarr_version = array(3, 7, -2); // Minimum version of Dolibarr required by module
76 $this->conflictwith = array();
77 $this->langfiles = array("oauth");
78
79 // Constants
80 $this->const = array();
81
82 // Boxes
83 $this->boxes = array();
84
85 // Permissions
86 $this->rights = array();
87 $this->rights_class = 'oauth';
88
89 $r = 0;
90 // $this->rights[$r][0] Id permission (unique tous modules confondus)
91 // $this->rights[$r][1] Libelle par default si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
92 // $this->rights[$r][2] Non utilise
93 // $this->rights[$r][3] 1=Permis par default, 0=Non permis par default
94 // $this->rights[$r][4] Niveau 1 pour nommer permission dans code
95 // $this->rights[$r][5] Niveau 2 pour nommer permission dans code
96
97 /*$r++;
98 $this->rights[$r][0] = 66000;
99 $this->rights[$r][1] = 'OauthAccess';
100 $this->rights[$r][2] = 'r';
101 $this->rights[$r][3] = 0;
102 $this->rights[$r][4] = 'read';*/
103
104 // Main menu entries
105 $this->menu = array(); // List of menus to add
106 $r = 0;
107
108 // This is to declare the Top Menu entry:
109 //$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Put 0 if this is a top menu
110 // 'type'=>'left', // This is a Top menu entry
111 // 'titre'=>'MenuOauth',
112 // 'mainmenu'=>'oauth',
113 // 'url'=>'/oauth/index.php',
114 // 'langs'=>'oauth', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
115 // 'position'=>300,
116 // 'enabled'=>'$conf->oauth->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',
117 // 'perms'=>'$user->rights->oauth->read', // Use 'perms'=>'1' if you want your menu with no permission rules
118 // 'target'=>'',
119 // 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
120
121 //$r++;
122 }
123
124
133 public function init($options = '')
134 {
135 global $conf;
136
137 // Clean before activation
138 $this->remove($options);
139
140 $sql = array();
141
142 return $this->_init($sql, $options);
143 }
144}
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:142