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