diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index e6ed20acb3d..acdf2e71a32 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -694,6 +694,7 @@ class Categorie extends CommonObject * @param CommonObject $obj Object to link to category * @param string $type Type of category ('product', ...). Use '' to take $obj->element. * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked + * @see del_type() */ public function add_type($obj, $type = '') { @@ -785,8 +786,8 @@ class Categorie extends CommonObject * * @param CommonObject $obj Object * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') - * * @return int 1 if OK, -1 if KO + * @see add_type() */ public function del_type($obj, $type) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ac5e293628a..d771c75ba48 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3987,7 +3987,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'salary', 'shipment', 'state', 'supplier_invoice', 'supplier_invoicea', 'supplier_invoicer', 'supplier_invoiced', 'technic', 'ticket', 'error', 'warning', - 'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'resource', 'recurring','rss', + 'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'replacement', 'resource', 'recurring','rss', 'shapes', 'square', 'stop-circle', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'uncheck', 'user-cog', 'user-injured', 'user-md', 'vat', 'website', 'workstation', 'webhook', 'world', 'private', @@ -4033,7 +4033,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right', 'recent' => 'question', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', - 'refresh'=>'redo', 'region'=>'map-marked', 'resource'=>'laptop-house', 'recurring'=>'history', + 'refresh'=>'redo', 'region'=>'map-marked', 'replacement'=>'exchange-alt', 'resource'=>'laptop-house', 'recurring'=>'history', 'service'=>'concierge-bell', 'state'=>'map-marked-alt', 'security'=>'key', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier'=>'building', 'technic'=>'cogs', diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index af816e362e4..ae3d31b6f12 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -42,6 +42,7 @@ MemberHasNoCategory=This member is not in any tags/categories ContactHasNoCategory=This contact is not in any tags/categories ProjectHasNoCategory=This project is not in any tags/categories ClassifyInCategory=Add to tag/category +RemoveCategory=Remove category NotCategorized=Without tag/category CategoryExistsAtSameLevel=This category already exists with this ref ContentsVisibleByAllShort=Contents visible by all diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index dd27366d314..eebf96a6040 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -518,7 +518,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( $sensitiveget = false; if ((GETPOSTISSET('massaction') || GETPOST('action', 'aZ09')) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') >= 3) { // All GET actions and mass actions are processed as sensitive. - if (GETPOSTISSET('massaction') || !in_array(GETPOST('action', 'aZ09'), array('create', 'createsite', 'edit', 'editvalidator', 'file_manager', 'presend', 'presend_addmessage', 'specimen'))) { // We exclude the case action='create' and action='file_manager' that are legitimate + if (GETPOSTISSET('massaction') || !in_array(GETPOST('action', 'aZ09'), array('create', 'createsite', 'edit', 'editvalidator', 'file_manager', 'presend', 'presend_addmessage', 'preview', 'specimen'))) { // We exclude the case action='create' and action='file_manager' that are legitimate $sensitiveget = true; } } elseif (getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') >= 2) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2809c1ff6e4..919da989e63 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -80,6 +80,7 @@ $type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); $section_dir = GETPOST('section_dir', 'alpha'); $file_manager = GETPOST('file_manager', 'alpha'); $replacesite = GETPOST('replacesite', 'alpha'); +$mode = GETPOST('mode', 'alpha'); if (GETPOST('deletesite', 'alpha')) { $action = 'deletesite'; @@ -130,7 +131,7 @@ if (empty($action) && $file_manager) { $action = 'file_manager'; } if (empty($action) && $replacesite) { - $action = 'replacesite'; + $mode = 'replacesite'; } if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x')) { $pageid = 0; @@ -334,7 +335,7 @@ if (empty($sortfield)) { $searchkey = GETPOST('searchstring', 'restricthtml'); -if ($action == 'replacesiteconfirm') { +if ($mode == 'replacesite') { $containertype = GETPOST('optioncontainertype', 'aZ09') != '-1' ? GETPOST('optioncontainertype', 'aZ09') : ''; $langcode = GETPOST('optionlanguage', 'aZ09'); $otherfilters = array(); @@ -397,6 +398,7 @@ if ($cancel && $action == 'renamefile') { // Cancel if ($cancel) { $action = 'preview'; + $mode = ''; if ($backtopage) { header("Location: ".$backtopage); exit; @@ -446,7 +448,7 @@ if ($action == 'unsetshowsubcontainers') { } if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha') && !$searchkey) { - $action = 'replacesite'; + $mode = 'replacesite'; $massaction = ''; } @@ -457,7 +459,7 @@ if ($massaction == 'setcategory' && GETPOST('confirmmassaction', 'alpha') && $us $db->begin(); - $categoryid = GETPOST('setcategory', 'restricthtml'); + $categoryid = GETPOST('setcategory', 'int'); if ($categoryid > 0) { $tmpwebsitepage = new WebsitePage($db); $category = new Categorie($db); @@ -488,6 +490,44 @@ if ($massaction == 'setcategory' && GETPOST('confirmmassaction', 'alpha') && $us // Now we reload list $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1); } +// Set category +if ($massaction == 'delcategory' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) { + $error = 0; + $nbupdate = 0; + + $db->begin(); + + $categoryid = GETPOST('setcategory', 'int'); + if ($categoryid > 0) { + $tmpwebsitepage = new WebsitePage($db); + $category = new Categorie($db); + $category->fetch($categoryid); + + foreach ($toselect as $tmpid) { + $tmpwebsitepage->id = $tmpid; + $result = $category->del_type($tmpwebsitepage, 'website_page'); + if ($result < 0 && $result != -3) { + $error++; + setEventMessages($category->error, $category->errors, 'errors'); + break; + } else { + $nbupdate++; + } + } + } + + if ($error) { + $db->rollback(); + } else { + if ($nbupdate) { + setEventMessages($langs->trans("RecordsModified", $nbupdate), null, 'mesgs'); + } + + $db->commit(); + } + // Now we reload list + $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1); +} // Replacement of string into pages if ($massaction == 'replace' && GETPOST('confirmmassaction', 'alpha') && $usercanedit) { @@ -1316,7 +1356,7 @@ if (!GETPOSTISSET('pageid')) { } if ($action == 'delete') { - $action = 'replacesiteconfirm'; + $mode = 'replacesite'; $containertype = GETPOST('optioncontainertype', 'aZ09') != '-1' ? GETPOST('optioncontainertype', 'aZ09') : ''; $langcode = GETPOST('optionlanguage', 'aZ09'); @@ -2642,11 +2682,8 @@ if ($action == 'importsite') { if ($action == 'file_manager') { print ''; } -if ($action == 'replacesite') { - print ''; -} -if ($action == 'replacesiteconfirm') { - print ''; +if ($mode) { + print ''; } print '