Fix: A lot of fix in permissions

This commit is contained in:
Laurent Destailleur 2010-07-15 20:48:40 +00:00
parent cea172ce0e
commit 321840ee67
9 changed files with 68 additions and 38 deletions

View File

@ -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;

View File

@ -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 '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$commande->id.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a>';
}
// Annuler commande
// Cancel order
if ($commande->statut == 1)
{
$nb_expedition = $commande->nb_expedition();

View File

@ -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 '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=modif">'.$langs->trans('Modify').'</a>';
if ($user->rights->facture->unvalidate)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=modif">'.$langs->trans('Modify').'</a>';
}
else
{
print '<span class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Modify').'</span>';
}
}
else
{

View File

@ -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

View File

@ -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 '<a class="butActionDelete" href="fiche.php?id='.$commande->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';

View File

@ -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")

View File

@ -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;

View File

@ -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;

View File

@ -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 '</td></tr>';
}