Files
dolibarr/htdocs/ecm/dir_add_card.php
MDW 7b54824d49 Fix #28071 - New branch to fix bad merge (#28083)
* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop

* Qual: Introduce getDataToShowPhoto to prepare generic code

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Fix missing trans

* Fix langs

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Remove useless files in web templates

* Clean code

* Fix duplicate translation key

* Fix duplicate translation key

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Fix duplicate key

* Fix $object

* Debug v19

* WIP SMSing

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* WIP EMAILINGS_SUPPORT_ALSO_SMS

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* WIP SMSing

* Debug the "validate" feature

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Clean code

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop

* Enhance rector to fix empty($user->rights->modulex->perm1)

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop

* Fix template to use v19 dev rules

* Fix use v19 dev rules

* Fix phpunit

* Debug v19

* Clean code

* Use rector to convert user->rights into user->hasRight

* Clean code

* Use rector to convert user->rights into user->hasRight

* Use rector to convert user->rights into user->hasRight

* Clean code

* Fix phpcs

* add editorconfig for sql files (#27999)

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>

* add model_pdf field in llx_ticket-ticket.sql (#27996)

* add model_pdf field in llx_ticket-ticket.sql

* Update 19.0.0-20.0.0.sql

* Update 19.0.0-20.0.0.sql

* Improve wording in README (#27994)

* fix phpstan (#27989)

* fix phpstan

* Update UserRightsToFunction.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>

* Qual: Fix spelling/working in datapolicy translations (#28006)

# Qual: Fix spelling/wording in datapolicy translations

Fixed some spelling and wording in datapolicy translations.

* qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986)

htdocs/ticket/class/ticketstats.class.php	98	Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth()

* Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop

* Fix user with readonly perm on email template must be able to read.

* Fix doc

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Better message

* Add missing fields in merge of thirdparty

* Debug v19 selection of ticket printer per terminal

* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

* Use constant

* NEW: Adding a recipient on emails sent, change status to sent partialy.

* fix travis (#28052)

* fix travis

* Update partnership.class.php

* fix php doc (#28047)

* fix undefined array key (#28048)

* Add region and departament for Cuba (#28046)

* Update llx_10_c_regions.sql

Add Cuba Regions (id_country=77)

* Update llx_20_c_departements.sql

Add Provinces Cuba (id country=77)

* Find the typo (#28050)

* Find the typo

* clean code

* add last_main_doc field to product (#28045)

* add las_main_doc field to product

* add field fetch

* NEW Add Categorie filter for ActionComm (#28041)

* New Add Categorie filter for ActionComm

New Add Categorie filter for ActionComm

* Fix space errors

Fix space errors

* Fix space errors 2

Fix space errors 2

* Update cunits.class.php (#28056)

FIX: error SQL when creating a Cunit

* Update codespell-lines-ignore.txt to avoid PR merge conflict

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com>
Co-authored-by: thibdrev <thibault.drevet@gmail.com>
Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com>
Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com>
Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com>
Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 15:58:49 +01:00

302 lines
8.8 KiB
PHP

<?php
/* Copyright (C) 2008-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/ecm/dir_add_card.php
* \ingroup ecm
* \brief Main page for ECM section area
*/
if (! defined('DISABLE_JS_GRAHP')) {
define('DISABLE_JS_GRAPH', 1);
}
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
// Load translation files required by the page
$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts", "categories"));
// Get parameters
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int');
if (empty($module)) {
$module = 'ecm';
}
// Security check
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
$section = $urlsection = GETPOST('section', 'alpha');
if (empty($urlsection)) {
$urlsection = 'misc';
}
if ($module == 'ecm') {
$upload_dir = $conf->ecm->dir_output.'/'.$urlsection;
} else { // For example $module == 'medias'
$upload_dir = $conf->medias->multidir_output[$conf->entity];
}
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "label";
}
$ecmdir = new EcmDirectory($db);
if (!empty($section)) {
$result = $ecmdir->fetch($section);
if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
}
// Permissions
$permissiontoadd = 0;
$permissiontodelete = 0;
$permissiontoupload = 0;
if ($module == 'ecm') {
$permissiontoadd = $user->hasRight('ecm', 'setup');
$permissiontodelete = $user->hasRight('ecm', 'setup');
$permissiontoupload = $user->hasRight('ecm', 'upload');
}
if ($module == 'medias') {
$permissiontoadd = ($user->rights->mailing->creer || $user->rights->website->write);
$permissiontodelete = ($user->rights->mailing->creer || $user->rights->website->write);
$permissiontoupload = ($user->rights->mailing->creer || $user->rights->website->write);
}
if (!$permissiontoadd) {
accessforbidden();
}
/*
* Actions
*/
// Action ajout d'un produit ou service
if ($action == 'add' && $permissiontoadd) {
if ($cancel) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
} else {
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module ? '&module='.$module : ''));
exit;
}
}
$ref = (string) GETPOST("ref", 'alpha');
$label = dol_sanitizeFileName(GETPOST("label", 'alpha'));
$desc = (string) GETPOST("desc", 'alpha');
$catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager)
if ($catParent == '-1') {
$catParent = 0;
}
$error = 0;
if (empty($label)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create';
$error++;
}
if (!$error) {
if ($module == 'ecm') {
$ecmdir->ref = $ref;
$ecmdir->label = $label;
$ecmdir->description = $desc;
$ecmdir->fk_parent = (int) $catParent;
$id = $ecmdir->create($user);
if ($id <= 0) {
$error++;
$langs->load("errors");
setEventMessages($ecmdir->error, $ecmdir->errors, 'errors');
$action = 'create';
}
} else { // For example $module == 'medias'
$dirfornewdir = '';
if ($module == 'medias') {
$dirfornewdir = $conf->medias->multidir_output[$conf->entity];
}
if (empty($dirfornewdir)) {
$error++;
dol_print_error(null, 'Bad value for module. Not supported.');
}
if (!$error) {
$fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label;
$result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
if ($result < 0) {
$langs->load("errors");
setEventMessages($langs->trans('ErrorFailToCreateDir', $label), null, 'errors');
$error++;
} else {
setEventMessages($langs->trans("ECMSectionWasCreated", $label), null, 'mesgs');
}
}
}
}
if (!$error) {
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
} else {
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager');
exit;
}
}
} elseif ($action == 'confirm_deletesection' && $confirm == 'yes' && $permissiontodelete) {
// Deleting file
$result = $ecmdir->delete($user);
setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
}
/*
* View
*/
llxHeader('', $langs->trans("ECMNewSection"));
$form = new Form($db);
$formecm = new FormEcm($db);
if ($action == 'create') {
//***********************
// Create
//***********************
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
if ($website) {
print '<input type="hidden" name="website" value="'.dol_escape_htmltag($website).'">';
}
if ($pageid) {
print '<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).'">';
}
$title = $langs->trans("ECMNewSection");
print load_fiche_titre($title);
print dol_get_fiche_head();
print '<table class="border centpercent">';
// Label
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td>';
print '<input name="label" class="minwidth100" maxlength="32" value="'.GETPOST("label", 'alpha').'" autofocus></td></tr>'."\n";
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formecm->selectAllSections((GETPOST("catParent", 'alpha') ? GETPOST("catParent", 'alpha') : $ecmdir->fk_parent), 'catParent', $module);
print '</td></tr>'."\n";
// Description
if ($module == 'ecm') {
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
print '<textarea name="desc" rows="4" class="quatrevingtpercent">';
print $ecmdir->description;
print '</textarea>';
print '</td></tr>'."\n";
}
print '</table>';
print dol_get_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" name="create" value="'.$langs->trans("Create").'">';
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
}
if (empty($action) || $action == 'delete_section') {
//***********************
// List
//***********************
print load_fiche_titre($langs->trans("ECMSectionOfDocuments"));
print '<br>';
/*
$ecmdir->ref=$ecmdir->label;
print $langs->trans("ECMSection").': ';
print img_picto('','object_dir').' ';
print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php">'.$langs->trans("ECMRoot").'</a>';
//print ' -> <b>'.$ecmdir->getNomUrl(1).'</b><br>';
print "<br><br>";
*/
// Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection');
}
// Actions buttons
print '<div class="tabsAction">';
// Delete
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', $user->hasRight('ecm', 'setup'));
print '</div>';
}
// End of page
llxFooter();
$db->close();