dolibarr 19.0.4
modOpenSurvey.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2014 Marcos GarcĂ­a <marcosgdf@gmail.com>
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
26include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
27
28
33{
39 public function __construct($db)
40 {
41 global $langs, $conf;
42
43 $this->db = $db;
44
45 // Id for module (must be unique).
46 // Use here a free id (See in Home -> System information -> Dolibarr for list of used module id).
47 $this->numero = 55000;
48 // Key text used to identify module (for permission, menus, etc...)
49 $this->rights_class = 'opensurvey';
50
51 // Family can be 'crm','financial','hr','projects','product','technic','other'
52 // It is used to group modules in module setup page
53 $this->family = "portal";
54 $this->module_position = '40';
55 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56 $this->name = preg_replace('/^mod/i', '', get_class($this));
57 // Module description used if translation string 'ModuleXXXDesc' not found (XXX is value MyModule)
58 $this->description = "Module to make online surveys (like Doodle, Studs, Rdvz, ...)";
59 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
60 $this->version = 'dolibarr';
61 // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
62 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
63 // Name of image file used for this module.
64 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
65 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
66 $this->picto = 'poll';
67
68 // Data directories to create when module is enabled
69 $this->dirs = array();
70 //$this->dirs[0] = DOL_DATA_ROOT.'/mymodule;
71 //$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp;
72
73 // Dependencies
74 $this->hidden = false; // A condition to hide module
75 $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
76 $this->requiredby = array(); // List of module ids to disable if this one is disabled
77 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
78 $this->phpmin = array(7, 0); // Minimum version of PHP required by module
79 $this->need_dolibarr_version = array(3, 4, 0); // Minimum version of Dolibarr required by module
80
81 // Constants
82 $this->const = array(); // List of parameters
83
84 // Dictionaries
85 $this->dictionaries = array();
86
87 // Boxes
88 $this->boxes = array(); // List of boxes
89 $r = 0;
90
91 // Add here list of php file(s) stored in includes/boxes that contains class to show a box.
92 // Example:
93 //$this->boxes[$r][1] = "myboxa.php";
94 //$r++;
95 //$this->boxes[$r][1] = "myboxb.php";
96 //$r++;
97
98 // Permissions
99 $this->rights = array(); // Permission array used by this module
100 $r = 0;
101
102 // Add here list of permission defined by an id, a label, a boolean and two constant strings.
103 // Example:
104 $this->rights[$r][0] = 55001; // Permission id (must not be already used)
105 $this->rights[$r][1] = 'Read surveys'; // Permission label
106 $this->rights[$r][2] = 'r'; // Permission by default for new user (0/1)
107 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
108 $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
109 $r++;
110
111 // Add here list of permission defined by an id, a label, a boolean and two constant strings.
112 // Example:
113 $this->rights[$r][0] = 55002; // Permission id (must not be already used)
114 $this->rights[$r][1] = 'Create/modify surveys'; // Permission label
115 $this->rights[$r][2] = 'w'; // Permission by default for new user (0/1)
116 $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
117 $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
118 $r++;
119
120
121 // Menus
122 //-------
123 $r = 0;
124 $this->menu[$r] = array(
125 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
126 'type'=>'left',
127 'titre'=>'Survey',
128 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
129 'mainmenu'=>'tools',
130 'leftmenu'=>'opensurvey',
131 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey',
132 'langs'=>'opensurvey',
133 'position'=>200,
134 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.
135 'perms'=>'$user->rights->opensurvey->read',
136 'target'=>'',
137 'user'=>0,
138 );
139 $r++;
140
141 $this->menu[$r] = array(
142 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
143 'type'=>'left',
144 'titre'=>'NewSurvey',
145 'mainmenu'=>'tools',
146 'leftmenu'=>'opensurvey_new',
147 'url'=>'/opensurvey/wizard/index.php',
148 'langs'=>'opensurvey',
149 'position'=>210,
150 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.
151 'perms'=>'$user->rights->opensurvey->write',
152 'target'=>'',
153 'user'=>0,
154 );
155 $r++;
156
157 $this->menu[$r] = array(
158 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
159 'type'=>'left',
160 'titre'=>'List',
161 'mainmenu'=>'tools',
162 'leftmenu'=>'opensurvey_list',
163 'url'=>'/opensurvey/list.php',
164 'langs'=>'opensurvey',
165 'position'=>220,
166 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.
167 'perms'=>'$user->rights->opensurvey->read',
168 'target'=>'',
169 'user'=>0,
170 );
171 $r++;
172 }
173
182 public function init($options = '')
183 {
184 global $conf, $langs;
185
186 $result = $this->_load_tables('/install/mysql/', 'opensurvey');
187 if ($result < 0) {
188 return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
189 }
190
191 // Permissions
192 $this->remove($options);
193
194 $sql = array();
195
196 return $this->_init($sql, $options);
197 }
198}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Description and activation class for module opensurvey.
init($options='')
Function called when module is enabled.
__construct($db)
Constructor.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:124