Clean code for validate permissions. "validate" is a status to say, "now

it exists, it is no more a draft", so by default we don't need this
permissions (it is same than create). We keep "validate" permissions as
an "advanced" permission only.
This commit is contained in:
Laurent Destailleur 2015-01-25 21:32:40 +01:00
parent e94d11ecf9
commit b61c475aa8
21 changed files with 132 additions and 74 deletions

View File

@ -103,7 +103,8 @@ if ($resql)
} }
} }
$user->rights->propale->valider=1; $user->rights->propal->creer=1;
$user->rights->propal->propal_advance->validate=1;
if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))

View File

@ -100,6 +100,7 @@ $hookmanager->initHooks(array('propalcard','globalcard'));
$permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php
/* /*
* Actions * Actions
*/ */
@ -172,7 +173,10 @@ if (empty($reshook))
} }
// Validation // Validation
else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) else if ($action == 'confirm_validate' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
)
{ {
$result = $object->valid($user); $result = $object->valid($user);
if ($result >= 0) if ($result >= 0)
@ -2082,19 +2086,21 @@ if ($action == 'create')
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook // modified by hook
if (empty($reshook)) { if (empty($reshook))
if ($action != 'statut' && $action != 'editline') { {
if ($action != 'statut' && $action != 'editline')
{
// Validate // Validate
if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider) { if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
) {
if (count($object->lines) > 0) if (count($object->lines) > 0)
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
// else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>'; // else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>';
} }
// Create event // Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page.
// "workflow" action so should appears somewhere
// else on
// page.
{ {
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>'; print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>';
} }

View File

@ -1334,7 +1334,8 @@ class Propal extends CommonObject
$error=0; $error=0;
$now=dol_now(); $now=dol_now();
if ($user->rights->propale->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
{ {
$this->db->begin(); $this->db->begin();
@ -1443,7 +1444,7 @@ class Propal extends CommonObject
return -1; return -1;
} }
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
@ -1472,7 +1473,7 @@ class Propal extends CommonObject
*/ */
function set_echeance($user, $date_fin_validite) function set_echeance($user, $date_fin_validite)
{ {
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null'); $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null');
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
@ -1498,7 +1499,7 @@ class Propal extends CommonObject
*/ */
function set_date_livraison($user, $date_livraison) function set_date_livraison($user, $date_livraison)
{ {
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null'); $sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null');
@ -1527,7 +1528,7 @@ class Propal extends CommonObject
*/ */
function set_availability($user, $id) function set_availability($user, $id)
{ {
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET fk_availability = '".$id."'"; $sql.= " SET fk_availability = '".$id."'";
@ -1556,7 +1557,7 @@ class Propal extends CommonObject
*/ */
function set_demand_reason($user, $id) function set_demand_reason($user, $id)
{ {
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET fk_input_reason = '".$id."'"; $sql.= " SET fk_input_reason = '".$id."'";
@ -1585,7 +1586,7 @@ class Propal extends CommonObject
*/ */
function set_ref_client($user, $ref_client) function set_ref_client($user, $ref_client)
{ {
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client); dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client);
@ -1620,7 +1621,7 @@ class Propal extends CommonObject
{ {
$remise=trim($remise)?trim($remise):0; $remise=trim($remise)?trim($remise):0;
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
$remise = price2num($remise); $remise = price2num($remise);
@ -1653,7 +1654,7 @@ class Propal extends CommonObject
{ {
$remise=trim($remise)?trim($remise):0; $remise=trim($remise)?trim($remise):0;
if ($user->rights->propale->creer) if (! empty($user->rights->propal->creer))
{ {
$remise = price2num($remise); $remise = price2num($remise);

View File

@ -883,7 +883,11 @@ if (empty($reshook))
exit(); exit();
} }
else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->commande->valider) { else if ($action == 'confirm_validate' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
)
{
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0; $qualified_for_stock_change=0;
@ -987,7 +991,11 @@ if (empty($reshook))
} }
} }
else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->commande->valider) { else if ($action == 'confirm_cancel' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
)
{
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0; $qualified_for_stock_change=0;
@ -2121,7 +2129,11 @@ if ($action == 'create' && $user->rights->commande->creer) {
// modified by hook // modified by hook
if (empty($reshook)) { if (empty($reshook)) {
// Valid // Valid
if ($object->statut == 0 && $object->total_ttc >= 0 && $numlines > 0 && $user->rights->commande->valider) { if ($object->statut == 0 && $object->total_ttc >= 0 && $numlines > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
)
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
} }
// Edit // Edit

View File

@ -205,7 +205,8 @@ class Commande extends CommonOrder
return 0; return 0;
} }
if (! $user->rights->commande->valider) if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
{ {
$this->error='Permission denied'; $this->error='Permission denied';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
@ -361,7 +362,8 @@ class Commande extends CommonOrder
return 0; return 0;
} }
if (! $user->rights->commande->valider) if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
{ {
$this->error='Permission denied'; $this->error='Permission denied';
return -1; return -1;
@ -494,7 +496,8 @@ class Commande extends CommonOrder
$error=0; $error=0;
if ($user->rights->commande->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
{ {
$this->db->begin(); $this->db->begin();

View File

@ -363,7 +363,10 @@ if (empty($reshook))
} }
// Classify to validated // Classify to validated
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) else if ($action == 'confirm_valid' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)))
)
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
@ -436,7 +439,10 @@ if (empty($reshook))
} }
// Go back to draft status (unvalidate) // Go back to draft status (unvalidate)
else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) else if ($action == 'confirm_modif' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
)
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
@ -3480,7 +3486,9 @@ if ($action == 'create')
if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) {
if (! $objectidnext && $object->is_last_in_cycle()) { if (! $objectidnext && $object->is_last_in_cycle()) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->invoice_advance->unvalidate)))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
} else { } else {
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("NotEnoughPermissions") . '">' . $langs->trans('Modify') . '</span></div>'; print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("NotEnoughPermissions") . '">' . $langs->trans('Modify') . '</span></div>';
@ -3510,7 +3518,9 @@ if ($action == 'create')
// Validate // Validate
if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($object->statut == 0 && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
if ($user->rights->facture->valider) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=valid">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=valid">' . $langs->trans('Validate') . '</a></div>';
} }
} }

View File

@ -1681,7 +1681,8 @@ class Facture extends CommonInvoice
return 0; return 0;
} }
if (! $user->rights->facture->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)))
{ {
$this->error='Permission denied'; $this->error='Permission denied';
dol_syslog(get_class($this)."::validate ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::validate ".$this->error, LOG_ERR);

View File

@ -128,7 +128,8 @@ class modCommande extends DolibarrModules
$this->rights[$r][1] = 'Valider les commandes clients'; $this->rights[$r][1] = 'Valider les commandes clients';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'valider'; $this->rights[$r][4] = 'order_advance';
$this->rights[$r][5] = 'validate';
$r++; $r++;
$this->rights[$r][0] = 86; $this->rights[$r][0] = 86;

View File

@ -151,7 +151,8 @@ class modExpedition extends DolibarrModules
$this->rights[$r][1] = 'Valider les expeditions'; $this->rights[$r][1] = 'Valider les expeditions';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'valider'; $this->rights[$r][4] = 'shipping_advance';
$this->rights[$r][5] = 'validate';
$r++; $r++;
$this->rights[$r][0] = 105; // id de la permission $this->rights[$r][0] = 105; // id de la permission
@ -197,8 +198,8 @@ class modExpedition extends DolibarrModules
$this->rights[$r][1] = 'Valider les bons de livraison'; $this->rights[$r][1] = 'Valider les bons de livraison';
$this->rights[$r][2] = 'd'; $this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'livraison'; $this->rights[$r][4] = 'livraison_advance';
$this->rights[$r][5] = 'valider'; $this->rights[$r][5] = 'validate';
$r++; $r++;
$this->rights[$r][0] = 1109; $this->rights[$r][0] = 1109;

View File

@ -137,7 +137,8 @@ class modFacture extends DolibarrModules
$this->rights[$r][1] = 'Valider les factures'; $this->rights[$r][1] = 'Valider les factures';
$this->rights[$r][2] = 'a'; $this->rights[$r][2] = 'a';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'valider'; $this->rights[$r][4] = 'invoice_advance';
$this->rights[$r][5] = 'validate';
$r++; $r++;
$this->rights[$r][0] = 15; $this->rights[$r][0] = 15;

View File

@ -150,8 +150,8 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][1] = 'Valider une commande fournisseur'; $this->rights[$r][1] = 'Valider une commande fournisseur';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'commande'; $this->rights[$r][4] = 'supplier_order_advance';
$this->rights[$r][5] = 'valider'; $this->rights[$r][5] = 'validate';
$r++; $r++;
$this->rights[$r][0] = 1185; $this->rights[$r][0] = 1185;
@ -206,8 +206,8 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][1] = 'Valider une facture fournisseur'; $this->rights[$r][1] = 'Valider une facture fournisseur';
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'facture'; $this->rights[$r][4] = 'supplier_invoice_advance';
$this->rights[$r][5] = 'valider'; $this->rights[$r][5] = 'validate';
$r++; $r++;
$this->rights[$r][0] = 1234; $this->rights[$r][0] = 1234;

View File

@ -130,7 +130,8 @@ class modPropale extends DolibarrModules
$this->rights[$r][1] = 'Valider les propositions commerciales'; // libelle de la permission $this->rights[$r][1] = 'Valider les propositions commerciales'; // libelle de la permission
$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'valider'; $this->rights[$r][4] = 'propal_advance';
$this->rights[$r][5] = 'validate';
$r++; $r++;
$this->rights[$r][0] = 25; // id de la permission $this->rights[$r][0] = 25; // id de la permission

View File

@ -256,7 +256,10 @@ if (empty($reshook))
} }
} }
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->valider) else if ($action == 'confirm_valid' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate)))
)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -304,7 +307,7 @@ if (empty($reshook))
} }
} }
else if ($action == 'reopen' && $user->rights->expedition->valider) else if ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate)))
{ {
$result = $object->setStatut(0); $result = $object->setStatut(0);
if ($result < 0) if ($result < 0)
@ -1354,7 +1357,8 @@ else if ($id || $ref)
if ($object->statut == 0 && $num_prod > 0) if ($object->statut == 0 && $num_prod > 0)
{ {
if ($user->rights->expedition->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate)))
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
} }
@ -1365,7 +1369,7 @@ else if ($id || $ref)
} }
// TODO add alternative status // TODO add alternative status
/* if ($object->statut == 1 && $user->rights->expedition->valider) /* if ($object->statut == 1 && $user->rights->expedition->creer)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
}*/ }*/

View File

@ -530,7 +530,8 @@ class Expedition extends CommonObject
return 0; return 0;
} }
if (! $user->rights->expedition->valider) if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))))
{ {
$this->error='Permission denied'; $this->error='Permission denied';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);

View File

@ -334,7 +334,8 @@ class CommandeFournisseur extends CommonOrder
dol_syslog(get_class($this)."::valid"); dol_syslog(get_class($this)."::valid");
$result = 0; $result = 0;
if ($user->rights->fournisseur->commande->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate)))
{ {
$this->db->begin(); $this->db->begin();

View File

@ -506,7 +506,10 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r
} }
} }
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->commande->valider) else if ($action == 'confirm_valid' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate)))
)
{ {
$object->date_commande=dol_now(); $object->date_commande=dol_now();
$result = $object->valid($user); $result = $object->valid($user);
@ -2212,7 +2215,8 @@ elseif (! empty($object->id))
// Validate // Validate
if ($object->statut == 0 && $num > 0) if ($object->statut == 0 && $num > 0)
{ {
if ($user->rights->fournisseur->commande->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate)))
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"';
print '>'.$langs->trans('Validate').'</a>'; print '>'.$langs->trans('Validate').'</a>';

View File

@ -120,7 +120,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
// } // }
} }
elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) elseif ($action == 'confirm_valid' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
)
{ {
$idwarehouse=GETPOST('idwarehouse'); $idwarehouse=GETPOST('idwarehouse');
@ -2255,7 +2258,8 @@ else
{ {
if (count($object->lines)) if (count($object->lines))
{ {
if ($user->rights->fournisseur->facture->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid"';
print '>'.$langs->trans('Validate').'</a>'; print '>'.$langs->trans('Validate').'</a>';

View File

@ -83,7 +83,10 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse
} }
} }
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) if ($action == 'confirm_valide' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
)
{ {
$db->begin(); $db->begin();
@ -312,7 +315,8 @@ if ($result > 0)
{ {
if ($user->societe_id == 0 && $object->statut == 0 && $action == '') if ($user->societe_id == 0 && $object->statut == 0 && $action == '')
{ {
if ($user->rights->fournisseur->facture->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=valide">'.$langs->trans('Valid').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=valide">'.$langs->trans('Valid').'</a>';

View File

@ -119,7 +119,10 @@ if ($action == 'add')
} }
} }
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->expedition->livraison->valider) else if ($action == 'confirm_valid' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison_advance->validate)))
)
{ {
$result = $object->valid($user); $result = $object->valid($user);

View File

@ -341,7 +341,8 @@ class Livraison extends CommonObject
$error = 0; $error = 0;
if ($user->rights->expedition->livraison->valider) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->livraison_advance->validate)))
{ {
if (! empty($conf->global->LIVRAISON_ADDON_NUMBER)) if (! empty($conf->global->LIVRAISON_ADDON_NUMBER))
{ {

View File

@ -639,10 +639,8 @@ class User extends CommonObject
} }
// For backward compatibility // For backward compatibility
if (isset($this->rights->propale)) if (isset($this->rights->propale) && ! isset($this->rights->propal)) $this->rights->propal = $this->rights->propale;
{ if (isset($this->rights->propal) && ! isset($this->rights->propale)) $this->rights->propale = $this->rights->propal;
$this->rights->propal = $this->rights->propale;
}
if (! $moduletag) if (! $moduletag)
{ {