Go to the documentation of this file.
26 if (! defined(
'DISABLE_JS_GRAHP')) define(
'DISABLE_JS_GRAPH', 1);
28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/htmlecm.form.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
34 $langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts",
"categories"));
37 $socid =
GETPOST(
'socid',
'int');
38 $action =
GETPOST(
'action',
'alpha');
39 $cancel =
GETPOST(
'cancel',
'aZ09');
40 $backtopage =
GETPOST(
'backtopage',
'alpha');
41 $confirm =
GETPOST(
'confirm',
'alpha');
43 $module =
GETPOST(
'module',
'alpha');
44 $website =
GETPOST(
'website',
'alpha');
45 $pageid =
GETPOST(
'pageid',
'int');
51 if ($user->socid > 0) {
53 $socid = $user->socid;
56 $section = $urlsection =
GETPOST(
'section',
'alpha');
57 if (empty($urlsection)) {
61 if ($module ==
'ecm') {
62 $upload_dir = $conf->ecm->dir_output.
'/'.$urlsection;
65 $upload_dir = $conf->medias->multidir_output[$conf->entity];
68 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
69 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
70 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
72 if (empty($page) || $page == -1) {
75 $offset = $limit * $page;
76 $pageprev = $page - 1;
77 $pagenext = $page + 1;
86 if (!empty($section)) {
87 $result = $ecmdir->fetch($section);
97 if ($module ==
'ecm') {
98 $permtoadd = $user->rights->ecm->setup;
99 $permtoupload = $user->rights->ecm->upload;
101 if ($module ==
'medias') {
102 $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
103 $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write);
117 if ($action ==
'add' && $permtoadd) {
119 if (!empty($backtopage)) {
120 header(
"Location: ".$backtopage);
123 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager'.($module ?
'&module='.$module :
''));
128 $ref = (string)
GETPOST(
"ref",
'alpha');
130 $desc = (string)
GETPOST(
"desc",
'alpha');
131 $catParent =
GETPOST(
"catParent",
'alpha');
132 if ($catParent ==
'-1') {
139 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
145 if ($module ==
'ecm') {
147 $ecmdir->label = $label;
148 $ecmdir->description = $desc;
149 $ecmdir->fk_parent = (int) $catParent;
151 $id = $ecmdir->create($user);
154 $langs->load(
"errors");
160 if ($module ==
'medias') {
161 $dirfornewdir = $conf->medias->multidir_output[$conf->entity];
163 if (empty($dirfornewdir)) {
169 $fullpathofdir = $dirfornewdir.
'/'.($catParent ? $catParent.
'/' :
'').$label;
170 $result =
dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
172 $langs->load(
"errors");
173 setEventMessages($langs->trans(
'ErrorFailToCreateDir', $label),
null,
'errors');
176 setEventMessages($langs->trans(
"ECMSectionWasCreated", $label),
null,
'mesgs');
183 if (!empty($backtopage)) {
184 header(
"Location: ".$backtopage);
187 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager');
191 } elseif ($action ==
'confirm_deletesection' && $confirm ==
'yes' && $permtoadd) {
193 $result = $ecmdir->delete($user);
194 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
204 llxHeader(
'', $langs->trans(
"ECMNewSection"));
209 if ($action ==
'create') {
213 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
214 print
'<input type="hidden" name="token" value="'.newToken().
'">';
215 print
'<input type="hidden" name="action" value="add">';
216 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
217 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).
'">';
219 print
'<input type="hidden" name="website" value="'.dol_escape_htmltag($website).
'">';
222 print
'<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).
'">';
225 $title = $langs->trans(
"ECMNewSection");
230 print
'<table class="border centpercent">';
233 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td><input name="label" class="minwidth100" maxlength="32" value="'.$ecmdir->label.
'" autofocus></td></tr>'.
"\n";
235 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
236 print $formecm->selectAllSections((
GETPOST(
"catParent",
'alpha') ?
GETPOST(
"catParent",
'alpha') : $ecmdir->fk_parent),
'catParent', $module);
237 print
'</td></tr>'.
"\n";
240 if ($module ==
'ecm') {
241 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
242 print
'<textarea name="desc" rows="4" class="quatrevingtpercent">';
243 print $ecmdir->description;
245 print
'</td></tr>'.
"\n";
252 print
'<div class="center">';
253 print
'<input type="submit" class="button" name="create" value="'.$langs->trans(
"Create").
'">';
254 print
' ';
255 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
261 if (empty($action) || $action ==
'delete_section') {
278 if ($action ==
'delete_section') {
279 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection');
284 print
'<div class="tabsAction">';
285 if ($user->rights->ecm->setup) {
286 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete_section&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a>';
288 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
'Delete').
'</a>';
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Class to manage ECM directories.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.