From 321840ee675a70678b2f0d436bdbcc2c2a91e073 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Jul 2010 20:48:40 +0000 Subject: [PATCH] Fix: A lot of fix in permissions --- htdocs/commande/class/commande.class.php | 1 + htdocs/commande/fiche.php | 4 +- htdocs/compta/facture.php | 16 +++++-- .../class/fournisseur.commande.class.php | 8 ++-- htdocs/fourn/commande/fiche.php | 7 +-- .../modules/DolibarrModules.class.php | 5 +- htdocs/includes/modules/modFacture.class.php | 7 +-- .../includes/modules/modFournisseur.class.php | 10 ++-- htdocs/install/upgrade2.php | 48 +++++++++++++------ 9 files changed, 68 insertions(+), 38 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4079430e51f..7f7c2994287 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -55,6 +55,7 @@ class Commande extends CommonObject var $contactid; var $fk_project; var $statut; // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted, 3=Closed (Envoyee/Recue facturee ou non) + var $facturee; // Facturee ou non var $brouillon; var $cond_reglement_id; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 8ebb025ce53..3eb1bc3db75 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -632,7 +632,7 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes' & } } -if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->creer) +if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes' && $user->rights->commande->cloturer) { $commande = new Commande($db); $commande->fetch($_GET['id']); // Load order and lines @@ -2167,7 +2167,7 @@ else print ''.$langs->trans("ToClone").''; } - // Annuler commande + // Cancel order if ($commande->statut == 1) { $nb_expedition = $commande->nb_expedition(); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 685f548f99c..4e6049253a4 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -329,8 +329,8 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $ } } -// Repasse la facture en mode brouillon -if ($_GET['action'] == 'modif' && $user->rights->facture->modifier) +// Repasse la facture en mode brouillon (unvalidate) +if ($_GET['action'] == 'modif' && $user->rights->facture->unvalidate) { $fac = new Facture($db); $fac->fetch($_GET['facid']); @@ -3150,12 +3150,18 @@ else // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees $ventilExportCompta = $fac->getVentilExportCompta(); - if ($user->rights->facture->modifier - && ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0)) + if ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0) { if (! $facidnext) { - print ''.$langs->trans('Modify').''; + if ($user->rights->facture->unvalidate) + { + print ''.$langs->trans('Modify').''; + } + else + { + print ''.$langs->trans('Modify').''; + } } else { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7f86c91ed6a..4add2c6507d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -49,10 +49,10 @@ class CommandeFournisseur extends Commande var $ref; var $brouillon; - var $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally - // -> 7=Canceled/Never received -> 3=Process - // -> 6=Canceled -> 2=Approved - // -> 9=Refused -> 1=Validated + var $statut; // 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially + // -> 7=Canceled/Never received -> (reopen) 3=Process runing + // -> 6=Canceled -> (reopen) 2=Approved + // -> 9=Refused -> (reopen) 1=Validated /** \brief Constructeur diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 47ec0a90b68..b83b3c984c4 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -355,11 +355,11 @@ if ($_REQUEST['action'] == 'confirm_commande' && $_REQUEST['confirm'] == 'yes' & } -if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->commande->creer) +if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->fournisseur->commande->supprimer) { $commande = new CommandeFournisseur($db); - $commande->id = $id; - $result=$commande->delete(); + $commande->fetch($id); + $result=$commande->delete($user); if ($result > 0) { Header("Location: ".DOL_URL_ROOT.'/fourn/commande/liste.php'); @@ -1308,6 +1308,7 @@ if ($id > 0 || ! empty($ref)) } } + // Delete if ($user->rights->fournisseur->commande->supprimer) { print ''.$langs->trans("Delete").''; diff --git a/htdocs/includes/modules/DolibarrModules.class.php b/htdocs/includes/modules/DolibarrModules.class.php index 189d9c89b4e..5b6510b240f 100644 --- a/htdocs/includes/modules/DolibarrModules.class.php +++ b/htdocs/includes/modules/DolibarrModules.class.php @@ -788,8 +788,8 @@ class DolibarrModules $name = $this->const[$key][0]; $type = $this->const[$key][1]; $val = $this->const[$key][2]; - $note = $this->const[$key][3]; - $visible = $this->const[$key][4]; + $note = isset($this->const[$key][3])?$this->const[$key][3]:''; + $visible = isset($this->const[$key][4])?$this->const[$key][4]:0; $entity = ! empty($this->const[$key][5])?0:$conf->entity; // Clean @@ -905,6 +905,7 @@ class DolibarrModules dol_syslog("DolibarrModules::insert_permissions sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql,1); + if (! $resql) { if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") diff --git a/htdocs/includes/modules/modFacture.class.php b/htdocs/includes/modules/modFacture.class.php index 77553c1ae32..3eeb31bee6d 100644 --- a/htdocs/includes/modules/modFacture.class.php +++ b/htdocs/includes/modules/modFacture.class.php @@ -119,17 +119,18 @@ class modFacture extends DolibarrModules $r++; $this->rights[$r][0] = 12; - $this->rights[$r][1] = 'Creer les factures'; + $this->rights[$r][1] = 'Creer/modifier les factures'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'creer'; + // There is a particular permission for unvalidate because this may be not forbidden by some laws $r++; $this->rights[$r][0] = 13; - $this->rights[$r][1] = 'Modifier les factures'; + $this->rights[$r][1] = 'Dévalider les factures'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'modifier'; + $this->rights[$r][4] = 'unvalidate'; $r++; $this->rights[$r][0] = 14; diff --git a/htdocs/includes/modules/modFournisseur.class.php b/htdocs/includes/modules/modFournisseur.class.php index ab57867adf1..e499f618517 100644 --- a/htdocs/includes/modules/modFournisseur.class.php +++ b/htdocs/includes/modules/modFournisseur.class.php @@ -141,7 +141,7 @@ class modFournisseur extends DolibarrModules $r++; $this->rights[$r][0] = 1185; - $this->rights[$r][1] = 'Approuver les commandes fournisseur'; + $this->rights[$r][1] = 'Approuver une commande fournisseur'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'commande'; @@ -149,7 +149,7 @@ class modFournisseur extends DolibarrModules $r++; $this->rights[$r][0] = 1186; - $this->rights[$r][1] = 'Commander/Annuler une commande fournisseur'; + $this->rights[$r][1] = 'Commander une commande fournisseur'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'commande'; @@ -157,7 +157,7 @@ class modFournisseur extends DolibarrModules $r++; $this->rights[$r][0] = 1187; - $this->rights[$r][1] = 'Receptionner les commandes fournisseur'; + $this->rights[$r][1] = 'Receptionner une commande fournisseur'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'commande'; @@ -165,11 +165,11 @@ class modFournisseur extends DolibarrModules $r++; $this->rights[$r][0] = 1188; - $this->rights[$r][1] = 'Cloturer les commandes fournisseur'; + $this->rights[$r][1] = 'Supprimer une commande fournisseur'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'commande'; - $this->rights[$r][5] = 'cloturer'; + $this->rights[$r][5] = 'supprimer'; $r++; $this->rights[$r][0] = 1231; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 29c40292f49..2e8b98995df 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -278,12 +278,12 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"])) migrate_shipping_delivery($db,$langs,$conf); migrate_shipping_delivery2($db,$langs,$conf); - - migrate_reload_modules($db,$langs,$conf); - - migrate_reload_menu($db,$langs,$conf); } + migrate_reload_modules($db,$langs,$conf); + + migrate_reload_menu($db,$langs,$conf); + // On commit dans tous les cas. // La procedure etant concue pour pouvoir passer plusieurs fois quelquesoit la situation. $db->commit(); @@ -1843,6 +1843,27 @@ function migrate_reload_modules($db,$langs,$conf) $mod=new modService($db); $mod->init(); } + if (! empty($conf->global->MAIN_MODULE_COMMANDE)) // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Commande"); + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/modCommande.class.php'); + $mod=new modCommande($db); + $mod->init(); + } + if (! empty($conf->global->MAIN_MODULE_FACTURE)) // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Facture"); + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/modFacture.class.php'); + $mod=new modFacture($db); + $mod->init(); + } + if (! empty($conf->global->MAIN_MODULE_FOURNISSEUR)) // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Fournisseur"); + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/modFournisseur.class.php'); + $mod=new modFournisseur($db); + $mod->init(); + } } /* @@ -2847,15 +2868,6 @@ function migrate_project_task_time($db,$langs,$conf) dol_print_error($db); } } - - if ($error == 0) - { - $db->commit(); - } - else - { - $db->rollback(); - } } else { @@ -2865,7 +2877,6 @@ function migrate_project_task_time($db,$langs,$conf) else { dol_print_error($db); - $db->rollback(); } } else @@ -2878,6 +2889,15 @@ function migrate_project_task_time($db,$langs,$conf) dol_print_error($db); } + if ($error == 0) + { + $db->commit(); + } + else + { + $db->rollback(); + } + print ''; }