dolibarr 21.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 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
34require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
35
44// Load translation files required by the page
45$langs->loadLangs(array('ecm'));
46
47$id = GETPOSTINT('id');
48$ref = GETPOST('ref', 'alpha');
49$socid = GETPOSTINT('socid');
50$action = GETPOST('action', 'aZ09');
51
52// Get parameters
53$socid = GETPOSTINT("socid");
54// Security check
55if ($user->socid > 0) {
56 $action = '';
57 $socid = $user->socid;
58}
59
60$backtopage = GETPOST('backtopage', 'alpha');
61
62$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
63$sortfield = GETPOST('sortfield', 'aZ09comma');
64$sortorder = GETPOST('sortorder', 'aZ09comma');
65$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
66if (empty($page) || $page == -1) {
67 $page = 0;
68} // If $page is not defined, or '' or -1
69$offset = $limit * $page;
70$pageprev = $page - 1;
71$pagenext = $page + 1;
72if (!$sortorder) {
73 $sortorder = "ASC";
74}
75if (!$sortfield) {
76 $sortfield = "label";
77}
78
79$section = GETPOST("section", 'alpha');
80if (!$section) {
81 dol_print_error(null, 'Error, section parameter missing');
82 exit;
83}
84$urlfile = (string) dol_sanitizePathName(GETPOST("urlfile"));
85if (!$urlfile) {
86 dol_print_error(null, "ErrorParamNotDefined");
87 exit;
88}
89
90// Load ecm object
91$ecmdir = new EcmDirectory($db);
92$result = $ecmdir->fetch(GETPOST("section", 'alpha'));
93if (!($result > 0)) {
94 dol_print_error($db, $ecmdir->error);
95 exit;
96}
97$relativepath = $ecmdir->getRelativePath();
98$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
99
100$fullpath = $conf->ecm->dir_output.'/'.$relativepath.$urlfile;
101
102$relativetodocument = 'ecm/'.$relativepath; // $relativepath is relative to ECM dir, we need relative to document
103$filepath = $relativepath.$urlfile;
104$filepathtodocument = $relativetodocument.$urlfile;
105
106// Try to load object from index
107$object = new EcmFiles($db);
108$extrafields = new ExtraFields($db);
109// fetch optionals attributes and labels
110$extrafields->fetch_name_optionals_label($object->table_element);
111
112$result = $object->fetch(0, '', $filepathtodocument);
113if ($result < 0) {
114 dol_print_error($db, $object->error, $object->errors);
115 exit;
116}
117
118$permissionnote = $user->hasRight('ecm', 'setup'); // Used by the include of actions_setnotes.inc.php
119
120$permissiontoread = $user->hasRight('ecm', 'read');
121
122if (!$permissiontoread) {
124}
125
126
127/*
128 * Actions
129 */
130
131include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
132
133
134/*
135 * View
136 */
137
138llxHeader('', $langs->trans('EcmFiles'), '', '', 0, 0, '', '', '', 'mod-ecm page-file_note');
139
140$form = new Form($db);
141
142$object->section_id = $ecmdir->id;
143$object->label = $urlfile;
144$head = ecm_file_prepare_head($object);
145
146print dol_get_fiche_head($head, 'note', $langs->trans("File"), -1, 'generic');
147
148$s = '';
149$tmpecmdir = new EcmDirectory($db); // Need to create a new one
150$tmpecmdir->fetch($ecmdir->id);
151$result = 1;
152$i = 0;
153while ($tmpecmdir && $result > 0) {
154 $tmpecmdir->ref = $tmpecmdir->label;
155 $s = $tmpecmdir->getNomUrl(1).$s;
156 if ($tmpecmdir->fk_parent) {
157 $s = ' -> '.$s;
158 $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
159 } else {
160 $tmpecmdir = 0;
161 }
162 $i++;
163}
164
165$urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfile);
166
167$s = img_picto('', 'object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s.' -> ';
168if ($action == 'edit') {
169 $s .= '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.'">';
170} else {
171 $s .= $urlfiletoshow;
172}
173
174$linkback = '';
175if ($backtopage) {
176 $linkback = '<a href="'.$backtopage.'">'.$langs->trans("BackToTree").'</a>';
177}
178
179$object->ref = ''; // Force to hide ref
180dol_banner_tab($object, '', $linkback, 0, '', '', $s);
181
182
183
184print '<div class="fichecenter">';
185print '<div class="underbanner clearboth"></div>';
186
187
188$cssclass = "titlefield";
189$moreparam = '&amp;section='.$section.'&amp;urlfile='.$urlfile;
190include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
191
192print '</div>';
193
194print dol_get_fiche_end();
195
196
197// End of page
198llxFooter();
199$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
Class to manage ECM directories.
Class to manage ECM files.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
ecm_file_prepare_head($object)
Prepare array with list of tabs.
Definition ecm.lib.php:118
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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...
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.