26if (! defined(
'DISABLE_JS_GRAHP')) define(
'DISABLE_JS_GRAPH', 1);
29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/ecm/class/htmlecm.form.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
35$langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts",
"categories"));
38$socid =
GETPOST(
'socid',
'int');
39$action =
GETPOST(
'action',
'alpha');
40$cancel =
GETPOST(
'cancel',
'aZ09');
41$backtopage =
GETPOST(
'backtopage',
'alpha');
42$confirm =
GETPOST(
'confirm',
'alpha');
44$module =
GETPOST(
'module',
'alpha');
45$website =
GETPOST(
'website',
'alpha');
46$pageid =
GETPOST(
'pageid',
'int');
52if ($user->socid > 0) {
54 $socid = $user->socid;
57$section = $urlsection =
GETPOST(
'section',
'alpha');
58if (empty($urlsection)) {
62if ($module ==
'ecm') {
63 $upload_dir = $conf->ecm->dir_output.
'/'.$urlsection;
66 $upload_dir = $conf->medias->multidir_output[$conf->entity];
69$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
70$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
71$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
72$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
73if (empty($page) || $page == -1) {
76$offset = $limit * $page;
87if (!empty($section)) {
88 $result = $ecmdir->fetch($section);
97$permissiontodelete = 0;
98$permissiontoupload = 0;
99if ($module ==
'ecm') {
100 $permissiontoadd = $user->rights->ecm->setup;
101 $permissiontodelete = $user->rights->ecm->setup;
102 $permissiontoupload = $user->rights->ecm->upload;
104if ($module ==
'medias') {
105 $permissiontoadd = ($user->rights->mailing->creer || $user->rights->website->write);
106 $permissiontodelete = ($user->rights->mailing->creer || $user->rights->website->write);
107 $permissiontoupload = ($user->rights->mailing->creer || $user->rights->website->write);
110if (!$permissiontoadd) {
121if ($action ==
'add' && $permissiontoadd) {
123 if (!empty($backtopage)) {
124 header(
"Location: ".$backtopage);
127 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager'.($module ?
'&module='.$module :
''));
132 $ref = (string)
GETPOST(
"ref",
'alpha');
134 $desc = (string)
GETPOST(
"desc",
'alpha');
135 $catParent =
GETPOST(
"catParent",
'alpha');
136 if ($catParent ==
'-1') {
143 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
149 if ($module ==
'ecm') {
151 $ecmdir->label = $label;
152 $ecmdir->description = $desc;
153 $ecmdir->fk_parent = (int) $catParent;
155 $id = $ecmdir->create($user);
158 $langs->load(
"errors");
164 if ($module ==
'medias') {
165 $dirfornewdir = $conf->medias->multidir_output[$conf->entity];
167 if (empty($dirfornewdir)) {
173 $fullpathofdir = $dirfornewdir.
'/'.($catParent ? $catParent.
'/' :
'').$label;
174 $result =
dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
176 $langs->load(
"errors");
177 setEventMessages($langs->trans(
'ErrorFailToCreateDir', $label),
null,
'errors');
180 setEventMessages($langs->trans(
"ECMSectionWasCreated", $label),
null,
'mesgs');
187 if (!empty($backtopage)) {
188 header(
"Location: ".$backtopage);
191 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager');
195} elseif ($action ==
'confirm_deletesection' && $confirm ==
'yes' && $permissiontodelete) {
197 $result = $ecmdir->delete($user);
198 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
208llxHeader(
'', $langs->trans(
"ECMNewSection"));
210$form =
new Form($db);
213if ($action ==
'create') {
217 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
218 print
'<input type="hidden" name="token" value="'.newToken().
'">';
219 print
'<input type="hidden" name="action" value="add">';
220 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
221 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).
'">';
223 print
'<input type="hidden" name="website" value="'.dol_escape_htmltag($website).
'">';
226 print
'<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).
'">';
229 $title = $langs->trans(
"ECMNewSection");
234 print
'<table class="border centpercent">';
237 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
238 print
'<input name="label" class="minwidth100" maxlength="32" value="'.GETPOST(
"label",
'alpha').
'" autofocus></td></tr>'.
"\n";
240 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
241 print $formecm->selectAllSections((
GETPOST(
"catParent",
'alpha') ?
GETPOST(
"catParent",
'alpha') : $ecmdir->fk_parent),
'catParent', $module);
242 print
'</td></tr>'.
"\n";
245 if ($module ==
'ecm') {
246 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
247 print
'<textarea name="desc" rows="4" class="quatrevingtpercent">';
248 print $ecmdir->description;
250 print
'</td></tr>'.
"\n";
257 print
'<div class="center">';
258 print
'<input type="submit" class="button" name="create" value="'.$langs->trans(
"Create").
'">';
259 print
' ';
260 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
266if (empty($action) || $action ==
'delete_section') {
283 if ($action ==
'delete_section') {
284 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection');
289 print
'<div class="tabsAction">';
292 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'', $user->rights->ecm->setup);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage ECM directories.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.