26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/htmlecm.form.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
32 $langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts",
"categories"));
35 $socid =
GETPOST(
'socid',
'int');
36 $action =
GETPOST(
'action',
'alpha');
37 $cancel =
GETPOST(
'cancel',
'aZ09');
38 $backtopage =
GETPOST(
'backtopage',
'alpha');
39 $confirm =
GETPOST(
'confirm',
'alpha');
41 $module =
GETPOST(
'module',
'alpha');
42 $website =
GETPOST(
'website',
'alpha');
43 $pageid =
GETPOST(
'pageid',
'int');
49 if ($user->socid > 0) {
51 $socid = $user->socid;
54 $section = $urlsection =
GETPOST(
'section',
'alpha');
55 if (empty($urlsection)) {
59 if ($module ==
'ecm') {
60 $upload_dir = $conf->ecm->dir_output.
'/'.$urlsection;
63 $upload_dir = $conf->medias->multidir_output[$conf->entity];
66 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
67 $sortfield =
GETPOST(
"sortfield",
'alpha');
68 $sortorder =
GETPOST(
"sortorder",
'alpha');
70 if (empty($page) || $page == -1) {
73 $offset = $limit * $page;
74 $pageprev = $page - 1;
75 $pagenext = $page + 1;
84 if (!empty($section)) {
85 $result = $ecmdir->fetch($section);
95 if ($module ==
'ecm') {
96 $permtoadd = $user->rights->ecm->setup;
97 $permtoupload = $user->rights->ecm->upload;
99 if ($module ==
'medias') {
100 $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
101 $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write);
115 if ($action ==
'add' && $permtoadd) {
117 if (!empty($backtopage)) {
118 header(
"Location: ".$backtopage);
121 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager'.($module ?
'&module='.$module :
''));
126 $ref = (string)
GETPOST(
"ref",
'alpha');
127 $label = (string)
GETPOST(
"label",
'alpha');
128 $desc = (string)
GETPOST(
"desc",
'alpha');
129 $catParent =
GETPOST(
"catParent",
'alpha');
130 if ($catParent ==
'-1') {
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")), null,
'errors');
143 if ($module ==
'ecm') {
145 $ecmdir->label = $label;
146 $ecmdir->description = $desc;
147 $ecmdir->fk_parent = (int) $catParent;
149 $id = $ecmdir->create($user);
152 $langs->load(
"errors");
159 if ($module ==
'medias') {
160 $dirfornewdir = $conf->medias->multidir_output[$conf->entity];
162 if (empty($dirfornewdir)) {
168 $fullpathofdir = $dirfornewdir.
'/'.($catParent ? $catParent.
'/' :
'').$label;
169 $result =
dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
171 setEventMessages($langs->trans(
'ErrorFailToCreateDir', $label), null,
'errors');
174 setEventMessages($langs->trans(
"ECMSectionWasCreated", $label), null,
'mesgs');
181 if (!empty($backtopage)) {
182 header(
"Location: ".$backtopage);
185 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager');
192 elseif ($action ==
'confirm_deletesection' && $confirm ==
'yes') {
193 $result = $ecmdir->delete($user);
194 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label), null,
'mesgs');
204 llxHeader(
'', $langs->trans(
"ECMNewSection"));
206 $form =
new Form($db);
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>';
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= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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 ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
Class to manage ECM directories.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)