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