-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
76 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/* Copyright (C) 2005 Matthieu Valleton <[email protected]> | ||
* Copyright (C) 2006-2020 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2006-2024 Laurent Destailleur <[email protected]> | ||
* Copyright (C) 2007 Patrick Raguin <[email protected]> | ||
* Copyright (C) 2005-2012 Regis Houssin <[email protected]> | ||
* Copyright (C) 2015 Raphaël Doursenaud <[email protected]> | ||
|
@@ -108,7 +108,7 @@ | |
$parameters = array('type' => $type, 'id' => $id, 'label' => $label); | ||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks | ||
// Remove element from category | ||
if ($id > 0 && $removeelem > 0 && $action == 'unlink') { | ||
if ($id > 0 && $removeelem > 0 && $action == 'unlink') { // Test on permission not required here. Done later according to type of object. | ||
if ($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { | ||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | ||
$tmpobject = new Product($db); | ||
|
@@ -174,9 +174,8 @@ | |
} | ||
} | ||
|
||
if ($elemid && $action == 'addintocategory' && | ||
( | ||
($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) || | ||
if ($elemid && $action == 'addintocategory') { // Test on permission not required here. Done just after depending on object type | ||
if (($type == Categorie::TYPE_PRODUCT && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) || | ||
($type == Categorie::TYPE_CUSTOMER && $user->hasRight('societe', 'creer')) || | ||
($type == Categorie::TYPE_SUPPLIER && $user->hasRight('societe', 'creer')) || | ||
($type == Categorie::TYPE_TICKET && $user->hasRight('ticket', 'write')) || | ||
|
@@ -185,57 +184,58 @@ | |
($type == Categorie::TYPE_CONTACT && $user->hasRight('societe', 'creer')) || | ||
($type == Categorie::TYPE_USER && $user->hasRight('user', 'user', 'creer')) || | ||
($type == Categorie::TYPE_ACCOUNT && $user->hasRight('banque', 'configurer')) | ||
)) { | ||
if ($type == Categorie::TYPE_PRODUCT) { | ||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | ||
$newobject = new Product($db); | ||
$elementtype = 'product'; | ||
} elseif ($type == Categorie::TYPE_CUSTOMER) { | ||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; | ||
$newobject = new Societe($db); | ||
$elementtype = 'customer'; | ||
} elseif ($type == Categorie::TYPE_SUPPLIER) { | ||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; | ||
$newobject = new Societe($db); | ||
$elementtype = 'supplier'; | ||
} elseif ($type == Categorie::TYPE_TICKET) { | ||
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; | ||
$newobject = new Ticket($db); | ||
$elementtype = 'ticket'; | ||
} elseif ($type == Categorie::TYPE_PROJECT) { | ||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; | ||
$newobject = new Project($db); | ||
$elementtype = 'project'; | ||
} elseif ($type == Categorie::TYPE_MEMBER) { | ||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; | ||
$newobject = new Adherent($db); | ||
$elementtype = 'member'; | ||
} elseif ($type == Categorie::TYPE_CONTACT) { | ||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; | ||
$newobject = new Contact($db); | ||
$elementtype = 'contact'; | ||
} elseif ($type == Categorie::TYPE_USER) { | ||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; | ||
$newobject = new User($db); | ||
$elementtype = 'user'; | ||
} elseif ($type == Categorie::TYPE_ACCOUNT) { | ||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; | ||
$newobject = new Account($db); | ||
$elementtype = 'bank_account'; | ||
} else { | ||
dol_print_error(null, "Not supported value of type = ".$type); | ||
} | ||
$result = $newobject->fetch($elemid); | ||
) { | ||
if ($type == Categorie::TYPE_PRODUCT) { | ||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | ||
$newobject = new Product($db); | ||
$elementtype = 'product'; | ||
} elseif ($type == Categorie::TYPE_CUSTOMER) { | ||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; | ||
$newobject = new Societe($db); | ||
$elementtype = 'customer'; | ||
} elseif ($type == Categorie::TYPE_SUPPLIER) { | ||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; | ||
$newobject = new Societe($db); | ||
$elementtype = 'supplier'; | ||
} elseif ($type == Categorie::TYPE_TICKET) { | ||
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; | ||
$newobject = new Ticket($db); | ||
$elementtype = 'ticket'; | ||
} elseif ($type == Categorie::TYPE_PROJECT) { | ||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; | ||
$newobject = new Project($db); | ||
$elementtype = 'project'; | ||
} elseif ($type == Categorie::TYPE_MEMBER) { | ||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; | ||
$newobject = new Adherent($db); | ||
$elementtype = 'member'; | ||
} elseif ($type == Categorie::TYPE_CONTACT) { | ||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; | ||
$newobject = new Contact($db); | ||
$elementtype = 'contact'; | ||
} elseif ($type == Categorie::TYPE_USER) { | ||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; | ||
$newobject = new User($db); | ||
$elementtype = 'user'; | ||
} elseif ($type == Categorie::TYPE_ACCOUNT) { | ||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; | ||
$newobject = new Account($db); | ||
$elementtype = 'bank_account'; | ||
} else { | ||
dol_print_error(null, "Not supported value of type = ".$type); | ||
} | ||
$result = $newobject->fetch($elemid); | ||
|
||
// Add into category | ||
$result = $object->add_type($newobject, $elementtype); | ||
if ($result >= 0) { | ||
setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs'); | ||
} else { | ||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { | ||
setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); | ||
// Add into category | ||
$result = $object->add_type($newobject, $elementtype); | ||
if ($result >= 0) { | ||
setEventMessages($langs->trans("WasAddedSuccessfully", $newobject->ref), null, 'mesgs'); | ||
} else { | ||
setEventMessages($object->error, $object->errors, 'errors'); | ||
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { | ||
setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); | ||
} else { | ||
setEventMessages($object->error, $object->errors, 'errors'); | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters