dolibarr 24.0.0-beta
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-2026 Frédéric 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 * or see https://www.gnu.org/
19 */
20
34{
35 global $langs, $conf, $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] = dolBuildUrl(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 (!getDolGlobalString('ECM_AUTO_TREE_HIDEN')) {
58 $head[$h][0] = dolBuildUrl(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) {
65 $head[$h][0] = dolBuildUrl(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, null, $head, $h, 'ecm');
76
77 complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm', 'remove');
78
79 return $head;
80}
81
82
91function 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] = dolBuildUrl(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] = dolBuildUrl(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
119{
120 global $langs;
121 $h = 0;
122 $head = array();
123
124 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/ecm/file_card.php', ['section' => $object->section_id, 'urlfile' => $object->label]);
125 $head[$h][1] = $langs->trans("File");
126 $head[$h][2] = 'card';
127 $h++;
128
129 // Notes
130 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/ecm/file_note.php', ['section' => $object->section_id, 'urlfile' => $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
155{
156 global $langs, $conf;
157 $h = 0;
158 $head = array();
159
160 $head[$h][0] = dolBuildUrl(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] = dolBuildUrl(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, $extrafields;
181
182 $extrafields->fetch_name_optionals_label('ecm_files');
183 $extrafields->fetch_name_optionals_label('ecm_directories');
184
185 $langs->load("ecm");
186
187 $h = 0;
188 $head = array();
189
190 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT."/admin/ecm.php");
191 $head[$h][1] = $langs->trans("Setup");
192 $head[$h][2] = 'ecm';
193 $h++;
194
195 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/ecm_files_extrafields.php');
196 $head[$h][1] = $langs->trans("ExtraFieldsEcmFiles");
197 $nbExtrafields = $extrafields->attributes['ecm_files']['count'];
198 if ($nbExtrafields > 0) {
199 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
200 }
201 $head[$h][2] = 'attributes_ecm_files';
202 $h++;
203
204 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/ecm_directories_extrafields.php');
205 $head[$h][1] = $langs->trans("ExtraFieldsEcmDirectories");
206 $nbExtrafields = $extrafields->attributes['ecm_directories']['count'];
207 if ($nbExtrafields > 0) {
208 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
209 }
210 $head[$h][2] = 'attributes_ecm_directories';
211 $h++;
212
213 complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin');
214
215 complete_head_from_modules($conf, $langs, null, $head, $h, 'ecm_admin', 'remove');
216
217 return $head;
218}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
ecm_prepare_dasboard_head()
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 information.
Definition ecm.lib.php:178
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.