dolibarr  17.0.4
ecm.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2022 Frédéric France <frederic.france@netlogic.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  * or see https://www.gnu.org/
18  */
19 
33 function ecm_prepare_dasboard_head($object)
34 {
35  global $langs, $conf, $user, $form;
36 
37  $h = 0;
38  $head = array();
39 
40  $showmediasection = 0;
41  if (isModEnabled('mailing') || isModEnabled('website')) {
42  $showmediasection = 1;
43  }
44 
45  $helptext = $langs->trans("ECMAreaDesc").'<br>';
46  $helptext .= $langs->trans("ECMAreaDesc2a").'<br>';
47  $helptext .= $langs->trans("ECMAreaDesc2b");
48  if ($showmediasection) {
49  $helptext .= '<br>'.$langs->trans("ECMAreaDesc3");
50  }
51 
52  $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php';
53  $head[$h][1] = $langs->trans("ECMSectionsManual").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3);
54  $head[$h][2] = 'index';
55  $h++;
56 
57  if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
58  $head[$h][0] = DOL_URL_ROOT.'/ecm/index_auto.php';
59  $head[$h][1] = $langs->trans("ECMSectionsAuto").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3);
60  $head[$h][2] = 'index_auto';
61  $h++;
62  }
63 
64  if ($showmediasection && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
65  $head[$h][0] = DOL_URL_ROOT.'/ecm/index_medias.php?file_manager=1';
66  $head[$h][1] = $langs->trans("ECMSectionsMedias").$form->textwithpicto('', $helptext, 1, 'info', '', 0, 3);
67  $head[$h][2] = 'index_medias';
68  $h++;
69  }
70 
71  // Show more tabs from modules
72  // Entries must be declared in modules descriptor with line
73  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
74  // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
75  complete_head_from_modules($conf, $langs, $object, $head, $h, 'ecm');
76 
77  complete_head_from_modules($conf, $langs, $object, $head, $h, 'ecm', 'remove');
78 
79  return $head;
80 }
81 
82 
91 function ecm_prepare_head($object, $module = 'ecm', $section = '')
92 {
93  global $langs, $conf, $user;
94  $h = 0;
95  $head = array();
96 
97  if ($module == 'ecm') {
98  $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$object->id;
99  $head[$h][1] = $langs->trans("Directory");
100  $head[$h][2] = 'card';
101  $h++;
102  } else {
103  $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$section.'&module='.$module;
104  $head[$h][1] = $langs->trans("Directory");
105  $head[$h][2] = 'card';
106  $h++;
107  }
108 
109  return $head;
110 }
111 
118 function ecm_file_prepare_head($object)
119 {
120  global $langs, $conf, $user;
121  $h = 0;
122  $head = array();
123 
124  $head[$h][0] = DOL_URL_ROOT.'/ecm/file_card.php?section='.$object->section_id.'&urlfile='.urlencode($object->label);
125  $head[$h][1] = $langs->trans("File");
126  $head[$h][2] = 'card';
127  $h++;
128 
129  // Notes
130  $head[$h][0] = DOL_URL_ROOT.'/ecm/file_note.php?section='.$object->section_id.'&urlfile='.urlencode($object->label);
131  $head[$h][1] = $langs->trans("Notes");
132  $nbNote = 0;
133  if (!empty($object->note_private)) {
134  $nbNote++;
135  }
136  if (!empty($object->note_public)) {
137  $nbNote++;
138  }
139  if ($nbNote > 0) {
140  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
141  }
142  $head[$h][2] = 'note';
143  $h++;
144 
145  return $head;
146 }
147 
154 function ecm_prepare_head_fm($object)
155 {
156  global $langs, $conf;
157  $h = 0;
158  $head = array();
159 
160  $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php?action=file_manager';
161  $head[$h][1] = $langs->trans('ECMFileManager');
162  $head[$h][2] = 'file_manager';
163  $h++;
164 
165  $head[$h][0] = DOL_URL_ROOT.'/ecm/search.php';
166  $head[$h][1] = $langs->trans('Search');
167  $head[$h][2] = 'search_form';
168  $h++;
169 
170  return $head;
171 }
172 
179 {
180  global $langs, $conf, $db;
181 
182  $extrafields = new ExtraFields($db);
183  $extrafields->fetch_name_optionals_label('ecm_files');
184  $extrafields->fetch_name_optionals_label('ecm_directories');
185 
186  $langs->load("ecm");
187 
188  $h = 0;
189  $head = array();
190 
191  $head[$h][0] = DOL_URL_ROOT."/admin/ecm.php";
192  $head[$h][1] = $langs->trans("Setup");
193  $head[$h][2] = 'ecm';
194  $h++;
195 
196  $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_files_extrafields.php';
197  $head[$h][1] = $langs->trans("ExtraFieldsEcmFiles");
198  $nbExtrafields = $extrafields->attributes['ecm_files']['count'];
199  if ($nbExtrafields > 0) {
200  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
201  }
202  $head[$h][2] = 'attributes_ecm_files';
203  $h++;
204 
205  $head[$h][0] = DOL_URL_ROOT.'/admin/ecm_directories_extrafields.php';
206  $head[$h][1] = $langs->trans("ExtraFieldsEcmDirectories");
207  $nbExtrafields = $extrafields->attributes['ecm_directories']['count'];
208  if ($nbExtrafields > 0) {
209  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
210  }
211  $head[$h][2] = 'attributes_ecm_directories';
212  $h++;
213 
214  complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin');
215 
216  complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin', 'remove');
217 
218  return $head;
219 }
Class to manage standard extra fields.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
ecm_prepare_dasboard_head($object)
Prepare array with list of different ecm main dashboard.
Definition: ecm.lib.php:33
ecm_file_prepare_head($object)
Prepare array with list of tabs.
Definition: ecm.lib.php:118
ecm_prepare_head_fm($object)
Prepare array with list of tabs.
Definition: ecm.lib.php:154
ecm_prepare_head($object, $module='ecm', $section='')
Prepare array with list of tabs.
Definition: ecm.lib.php:91
ecm_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: ecm.lib.php:178
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
isModEnabled($module)
Is Dolibarr module enabled.