28if (! defined(
'DISABLE_JS_GRAHP')) {
29 define(
'DISABLE_JS_GRAPH', 1);
33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/ecm/class/htmlecm.form.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
47$langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts",
"categories"));
51$action =
GETPOST(
'action',
'alpha');
53$backtopage =
GETPOST(
'backtopage',
'alpha');
54$confirm =
GETPOST(
'confirm',
'alpha');
56$module =
GETPOST(
'module',
'alpha');
57$website =
GETPOST(
'website',
'alpha');
64if ($user->socid > 0) {
66 $socid = $user->socid;
69$section = $urlsection =
GETPOST(
'section',
'alpha');
70if (empty($urlsection)) {
74if ($module ==
'ecm') {
75 $upload_dir =
$conf->ecm->dir_output.
'/'.$urlsection;
77 $upload_dir =
$conf->medias->multidir_output[
$conf->entity];
81$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
82$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
84if (empty($page) || $page == -1) {
87$offset = $limit * $page;
98if (!empty($section)) {
99 $result = $ecmdir->fetch((
int) $section);
100 if (!($result > 0)) {
108$permissiontodelete = 0;
109$permissiontoupload = 0;
110if ($module ==
'ecm') {
111 $permissiontoadd = $user->hasRight(
'ecm',
'setup');
112 $permissiontodelete = $user->hasRight(
'ecm',
'setup');
113 $permissiontoupload = $user->hasRight(
'ecm',
'upload');
115if ($module ==
'medias') {
116 $permissiontoadd = ($user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
117 $permissiontodelete = ($user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
118 $permissiontoupload = ($user->hasRight(
'mailing',
'creer') || $user->hasRight(
'website',
'write'));
121if (!$permissiontoadd) {
132if ($action ==
'add' && $permissiontoadd) {
134 if (!empty($backtopage)) {
135 header(
"Location: ".$backtopage);
138 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager'.($module ?
'&module='.$module :
''));
143 $ref = (string)
GETPOST(
"ref",
'alpha');
145 $desc = (string)
GETPOST(
"desc",
'alpha');
146 $catParent =
GETPOST(
"catParent",
'alpha');
147 if ($catParent ==
'-1') {
154 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
160 if ($module ==
'ecm') {
162 $ecmdir->label = $label;
163 $ecmdir->description = $desc;
164 $ecmdir->fk_parent = (int) $catParent;
166 $id = $ecmdir->create($user);
169 $langs->load(
"errors");
175 if ($module ==
'medias') {
176 $dirfornewdir =
$conf->medias->multidir_output[
$conf->entity];
178 if (empty($dirfornewdir)) {
184 $fullpathofdir = $dirfornewdir.
'/'.($catParent ? $catParent.
'/' :
'').$label;
185 $result =
dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
187 $langs->load(
"errors");
188 setEventMessages($langs->trans(
'ErrorFailToCreateDir', $label),
null,
'errors');
191 setEventMessages($langs->trans(
"ECMSectionWasCreated", $label),
null,
'mesgs');
198 if (!empty($backtopage)) {
199 header(
"Location: ".$backtopage);
202 header(
"Location: ".DOL_URL_ROOT.
'/ecm/index.php?action=file_manager');
206} elseif ($action ==
'confirm_deletesection' && $confirm ==
'yes' && $permissiontodelete) {
208 $result = $ecmdir->delete($user);
209 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
219llxHeader(
'', $langs->trans(
"ECMNewSection"),
'',
'', 0, 0,
'',
'',
'',
'mod-ecm page-dir_add_card');
221$form =
new Form($db);
224if ($action ==
'create') {
228 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
229 print
'<input type="hidden" name="token" value="'.newToken().
'">';
230 print
'<input type="hidden" name="action" value="add">';
231 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
232 print
'<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).
'">';
234 print
'<input type="hidden" name="website" value="'.dol_escape_htmltag($website).
'">';
237 print
'<input type="hidden" name="pageid" value="'.dol_escape_htmltag((
string) $pageid).
'">';
240 $title = $langs->trans(
"ECMNewSection");
245 print
'<table class="border centpercent">';
248 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
249 print
'<input name="label" class="minwidth100" maxlength="32" value="'.GETPOST(
"label",
'alpha').
'" autofocus></td></tr>'.
"\n";
251 print
'<tr><td>'.$langs->trans(
"AddIn").
'</td><td>';
252 print $formecm->selectAllSections((
GETPOST(
"catParent",
'alpha') ?
GETPOST(
"catParent",
'alpha') : $ecmdir->fk_parent),
'catParent', $module);
253 print
'</td></tr>'.
"\n";
256 if ($module ==
'ecm') {
257 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
258 print
'<textarea name="desc" rows="4" class="quatrevingtpercent">';
259 print $ecmdir->description;
261 print
'</td></tr>'.
"\n";
268 print
'<div class="center">';
269 print
'<input type="submit" class="button" name="create" value="'.$langs->trans(
"Create").
'">';
270 print
' ';
271 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
277if (empty($action) || $action ==
'delete_section') {
294 if ($action ==
'delete_section') {
295 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection');
300 print
'<div class="tabsAction">';
303 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $user->hasRight(
'ecm',
'setup'));
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage ECM directories.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.