dolibarr 24.0.0-beta
file_note.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
7 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
43require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
44
45// Load translation files required by the page
46$langs->loadLangs(array('ecm'));
47
48$id = GETPOSTINT('id');
49$ref = GETPOST('ref', 'alpha');
50$socid = GETPOSTINT('socid');
51$action = GETPOST('action', 'aZ09');
52
53// Get parameters
54$socid = GETPOSTINT("socid");
55// Security check
56if ($user->socid > 0) {
57 $action = '';
58 $socid = $user->socid;
59}
60
61$backtopage = GETPOST('backtopage', 'alpha');
62
63$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
64$sortfield = GETPOST('sortfield', 'aZ09comma');
65$sortorder = GETPOST('sortorder', 'aZ09comma');
66$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
67if (empty($page) || $page == -1) {
68 $page = 0;
69} // If $page is not defined, or '' or -1
70$offset = $limit * $page;
71$pageprev = $page - 1;
72$pagenext = $page + 1;
73if (!$sortorder) {
74 $sortorder = "ASC";
75}
76if (!$sortfield) {
77 $sortfield = "label";
78}
79
80$section = GETPOST("section", 'alpha');
81if (!$section) {
82 dol_print_error(null, 'Error, section parameter missing');
83 exit;
84}
85$urlfile = (string) dol_sanitizePathName(GETPOST("urlfile"));
86if (!$urlfile) {
87 dol_print_error(null, "ErrorParamNotDefined");
88 exit;
89}
90
91// Load ecm object
92$ecmdir = new EcmDirectory($db);
93$result = $ecmdir->fetch(GETPOSTINT("section"));
94if (!($result > 0)) {
95 dol_print_error($db, $ecmdir->error);
96 exit;
97}
98$relativepath = $ecmdir->getRelativePath();
99$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
100
101$fullpath = $conf->ecm->dir_output.'/'.$relativepath.$urlfile;
102
103$relativetodocument = 'ecm/'.$relativepath; // $relativepath is relative to ECM dir, we need relative to document
104$filepath = $relativepath.$urlfile;
105$filepathtodocument = $relativetodocument.$urlfile;
106
107// Try to load object from index
108$object = new EcmFiles($db);
109
110// fetch optionals attributes and labels
111$extrafields->fetch_name_optionals_label($object->table_element);
112
113$result = $object->fetch(0, '', $filepathtodocument);
114if ($result < 0) {
115 dol_print_error($db, $object->error, $object->errors);
116 exit;
117}
118
119$permissionnote = $user->hasRight('ecm', 'setup'); // Used by the include of actions_setnotes.inc.php
120
121$permissiontoread = $user->hasRight('ecm', 'read');
122
123if (!$permissiontoread) {
125}
126
127
128/*
129 * Actions
130 */
131
132include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
133
134
135/*
136 * View
137 */
138
139llxHeader('', $langs->trans('EcmFiles'), '', '', 0, 0, '', '', '', 'mod-ecm page-file_note');
140
141$form = new Form($db);
142
143$object->section_id = $ecmdir->id;
144$object->label = $urlfile;
145$head = ecm_file_prepare_head($object);
146
147print dol_get_fiche_head($head, 'note', $langs->trans("File"), -1, 'generic');
148
149$s = '';
150$tmpecmdir = new EcmDirectory($db); // Need to create a new one
151$tmpecmdir->fetch($ecmdir->id);
152$result = 1;
153$i = 0;
154while ($tmpecmdir && $result > 0) {
155 $tmpecmdir->ref = $tmpecmdir->label;
156 $s = $tmpecmdir->getNomUrl(1).$s;
157 if ($tmpecmdir->fk_parent) {
158 $s = ' -> '.$s;
159 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
160 } else {
161 $tmpecmdir = 0;
162 }
163 $i++;
164}
165
166$urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfile);
167
168$s = img_picto('', 'object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s.' -> ';
169if ($action == 'edit') {
170 $s .= '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.'">';
171} else {
172 $s .= $urlfiletoshow;
173}
174
175$linkback = '';
176if ($backtopage) {
177 $linkback = '<a href="'.$backtopage.'">'.$langs->trans("BackToTree").'</a>';
178}
179
180$object->ref = ''; // Force to hide ref
181dol_banner_tab($object, '', $linkback, 0, '', '', $s);
182
183
184
185print '<div class="fichecenter">';
186print '<div class="underbanner clearboth"></div>';
187
188
189$cssclass = "titlefield";
190$moreparam = '&amp;section='.$section.'&amp;urlfile='.$urlfile;
191include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
192
193print '</div>';
194
195print dol_get_fiche_end();
196
197
198// End of page
199llxFooter();
200$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage ECM directories.
Class to manage ECM files.
Class to manage generation of HTML components Only common components must be here.
ecm_file_prepare_head($object)
Prepare array with list of tabs.
Definition ecm.lib.php:118
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.