use user->hasRight

This commit is contained in:
Frédéric FRANCE 2023-02-14 23:00:15 +01:00
parent ae48571135
commit 03e8ee0e6d
10 changed files with 41 additions and 41 deletions

View File

@ -1232,7 +1232,7 @@ if ($object->id > 0) {
/*
* Latest interventions
*/
if (isModEnabled('ficheinter') && $user->rights->ficheinter->lire) {
if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire')) {
$sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate, f.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.rowid";
@ -1572,7 +1572,7 @@ if ($object->id > 0) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContract").'</a></div>';
}
if (isModEnabled('ficheinter') && $user->rights->ficheinter->creer && $object->status == 1) {
if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer') && $object->status == 1) {
$langs->load("fichinter");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a></div>';
}

View File

@ -170,7 +170,7 @@ if ($object->thirdparty->client) {
}
}
if (isModEnabled('ficheinter') && $user->rights->ficheinter->lire) {
if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire')) {
$elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
}

View File

@ -994,7 +994,7 @@ class doc_generic_project_odt extends ModelePDFProjects
'class' => 'Fichinter',
'table' => 'fichinter',
'disableamount' => 1,
'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
'test' => $conf->ficheinter->enabled && $user->hasRight('ficheinter', 'lire')
),
'shipping' => array(
'title' => "ListShippingAssociatedProject",

View File

@ -433,7 +433,7 @@ class pdf_beluga extends ModelePDFProjects
'table'=>'fichinter',
'datefieldname'=>'date_valid',
'disableamount'=>1,
'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
'test'=>$conf->ficheinter->enabled && $user->hasRight('ficheinter', 'lire'),
'lang'=>'interventions'),
'trip'=>array(
'name'=>"TripsAndExpenses",

View File

@ -238,18 +238,18 @@ if ($action == 'add') {
$id = 0;
header('Location: '.$_SERVER["PHP_SELF"]);
exit;
} elseif ($action == 'setfrequency' && $user->rights->ficheinter->creer) {
} elseif ($action == 'setfrequency' && $user->hasRight('ficheinter', 'creer')) {
// Set frequency and unit frequency
$object->fetch($id);
$object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha'));
} elseif ($action == 'setdate_when' && $user->rights->ficheinter->creer) {
} elseif ($action == 'setdate_when' && $user->hasRight('ficheinter', 'creer')) {
// Set next date of execution
$object->fetch($id);
$date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear'));
if (!empty($date)) {
$object->setNextDate($date);
}
} elseif ($action == 'setnb_gen_max' && $user->rights->ficheinter->creer) {
} elseif ($action == 'setnb_gen_max' && $user->hasRight('ficheinter', 'creer')) {
// Set max period
$object->fetch($id);
$object->setMaxPeriod(GETPOST('nb_gen_max', 'int'));
@ -611,7 +611,7 @@ if ($action == 'create') {
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Frequency');
print '</td>';
if ($action != 'editfrequency' && $user->rights->ficheinter->creer) {
if ($action != 'editfrequency' && $user->hasRight('ficheinter', 'creer')) {
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editfrequency&token='.newToken().'&id='.$id.'">';
print img_edit($langs->trans('Edit'), 1).'</a></td>';
}

View File

@ -104,7 +104,7 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$permissionnote = $user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->ficheinter->creer; // Used by the include of actions_dellink.inc.php
$permissiontodelete = (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer);
$permissiontodelete = (($object->statut == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer')) || $user->rights->ficheinter->supprimer);
/*
@ -146,7 +146,7 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->hasRight('ficheinter', 'creer')) {
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} else {
@ -167,7 +167,7 @@ if (empty($reshook)) {
}
}
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('ficheinter', 'creer')) {
$result = $object->setValid($user);
if ($result >= 0) {
@ -193,7 +193,7 @@ if (empty($reshook)) {
} else {
$mesg = $object->error;
}
} elseif ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
} elseif ($action == 'confirm_modify' && $confirm == 'yes' && $user->hasRight('ficheinter', 'creer')) {
$result = $object->setDraft($user);
if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@ -218,7 +218,7 @@ if (empty($reshook)) {
} else {
$mesg = $object->error;
}
} elseif ($action == 'add' && $user->rights->ficheinter->creer) {
} elseif ($action == 'add' && $user->hasRight('ficheinter', 'creer')) {
$selectedLines = GETPOST('toselect', 'array');
$object->socid = $socid;
$object->duration = (int) GETPOST('duration', 'int');
@ -437,7 +437,7 @@ if (empty($reshook)) {
$action = 'create';
$error++;
}
} elseif ($action == 'update' && $user->rights->ficheinter->creer) {
} elseif ($action == 'update' && $user->hasRight('ficheinter', 'creer')) {
$object->socid = $socid;
$object->fk_project = (int) GETPOST('projectid', 'int');
$object->fk_contrat = (int) GETPOST('contratid', 'int');
@ -450,7 +450,7 @@ if (empty($reshook)) {
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'classin' && $user->rights->ficheinter->creer) {
} elseif ($action == 'classin' && $user->hasRight('ficheinter', 'creer')) {
// Set into a project
$result = $object->setProject(GETPOST('projectid', 'int'));
if ($result < 0) {
@ -462,7 +462,7 @@ if (empty($reshook)) {
if ($result < 0) {
dol_print_error($db, $object->error);
}
} elseif ($action == 'setref_client' && $user->rights->ficheinter->creer) {
} elseif ($action == 'setref_client' && $user->hasRight('ficheinter', 'creer')) {
// Positionne ref client
$result = $object->setRefClient($user, GETPOST('ref_client', 'alpha'));
if ($result < 0) {
@ -476,12 +476,12 @@ if (empty($reshook)) {
header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1');
exit;
} elseif ($action == 'setdescription' && $user->rights->ficheinter->creer) {
} elseif ($action == 'setdescription' && $user->hasRight('ficheinter', 'creer')) {
$result = $object->set_description($user, GETPOST('description'));
if ($result < 0) {
dol_print_error($db, $object->error);
}
} elseif ($action == "addline" && $user->rights->ficheinter->creer) {
} elseif ($action == "addline" && $user->hasRight('ficheinter', 'creer')) {
// Add line
if (!GETPOST('np_desc', 'restricthtml') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description"));
@ -542,7 +542,7 @@ if (empty($reshook)) {
$db->rollback();
}
}
} elseif ($action == 'classifybilled' && $user->rights->ficheinter->creer) {
} elseif ($action == 'classifybilled' && $user->hasRight('ficheinter', 'creer')) {
// Classify Billed
$result = $object->setStatut(Fichinter::STATUS_BILLED);
if ($result > 0) {
@ -551,7 +551,7 @@ if (empty($reshook)) {
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'classifyunbilled' && $user->rights->ficheinter->creer) {
} elseif ($action == 'classifyunbilled' && $user->hasRight('ficheinter', 'creer')) {
// Classify unbilled
$result = $object->setStatut(Fichinter::STATUS_VALIDATED);
if ($result > 0) {
@ -560,7 +560,7 @@ if (empty($reshook)) {
} else {
$mesg = $object->error;
}
} elseif ($action == 'classifydone' && $user->rights->ficheinter->creer) {
} elseif ($action == 'classifydone' && $user->hasRight('ficheinter', 'creer')) {
// Classify Done
$result = $object->setStatut(Fichinter::STATUS_CLOSED);
if ($result > 0) {
@ -569,7 +569,7 @@ if (empty($reshook)) {
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'confirm_reopen' && $user->rights->ficheinter->creer) {
} elseif ($action == 'confirm_reopen' && $user->hasRight('ficheinter', 'creer')) {
// Reopen
$result = $object->setStatut(Fichinter::STATUS_VALIDATED);
if ($result > 0) {
@ -578,7 +578,7 @@ if (empty($reshook)) {
} else {
$mesg = $object->error;
}
} elseif ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save', 'alpha') == $langs->trans("Save")) {
} elseif ($action == 'updateline' && $user->hasRight('ficheinter', 'creer') && GETPOST('save', 'alpha') == $langs->trans("Save")) {
// Mise a jour d'une ligne d'intervention
$objectline = new FichinterLigne($db);
if ($objectline->fetch($lineid) <= 0) {
@ -630,7 +630,7 @@ if (empty($reshook)) {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
} elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer) {
} elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->hasRight('ficheinter', 'creer')) {
// Supprime une ligne d'intervention AVEC confirmation
$objectline = new FichinterLigne($db);
if ($objectline->fetch($lineid) <= 0) {
@ -660,7 +660,7 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
fichinter_create($db, $object, $object->model_pdf, $outputlangs);
}
} elseif ($action == 'up' && $user->rights->ficheinter->creer) {
} elseif ($action == 'up' && $user->hasRight('ficheinter', 'creer')) {
// Set position of lines
$object->line_up($lineid);
@ -683,7 +683,7 @@ if (empty($reshook)) {
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
exit;
} elseif ($action == 'down' && $user->rights->ficheinter->creer) {
} elseif ($action == 'down' && $user->hasRight('ficheinter', 'creer')) {
$object->line_down($lineid);
// Define output language
@ -743,7 +743,7 @@ if (empty($reshook)) {
}
}
if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer) {
if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->hasRight('ficheinter', 'creer')) {
if ($action == 'addcontact') {
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
@ -1392,7 +1392,7 @@ if ($action == 'create') {
print "</td>\n";
// Icon to edit and delete
if ($object->statut == 0 && $user->rights->ficheinter->creer) {
if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer')) {
print '<td class="center">';
print '<a class="editfielda marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&token='.newToken().'&line_id='.$objp->rowid.'#'.$objp->rowid.'">';
print img_edit();
@ -1422,7 +1422,7 @@ if ($action == 'create') {
}
// Line in update mode
if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id', 'int') == $objp->rowid) {
if ($object->statut == 0 && $action == 'editline' && $user->hasRight('ficheinter', 'creer') && GETPOST('line_id', 'int') == $objp->rowid) {
print '<tr class="oddeven nohover">';
// No.
@ -1487,7 +1487,7 @@ if ($action == 'create') {
$db->free($resql);
// Add new line
if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer') && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
if (!$num) {
print '<br>';
print '<table class="noborder centpercent">';
@ -1601,7 +1601,7 @@ if ($action == 'create') {
if ($action != 'editdescription' && ($action != 'presend')) {
// Validate
if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('ficheinter', 'creer')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a></div>';
} else {
print '<div class="inline-block divButActionRefused"><span class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</span></div>';
@ -1609,7 +1609,7 @@ if ($action == 'create') {
}
// Modify
if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate))) {
if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('ficheinter', 'creer')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate))) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">';
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
print $langs->trans("Modify");
@ -1640,7 +1640,7 @@ if ($action == 'create') {
}
// Create intervention model
if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) {
if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer') && (count($object->lines) > 0)) {
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id.'&action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans("ChangeIntoRepeatableIntervention").'</a>';
print '</div>';

View File

@ -56,7 +56,7 @@ if (!$result) {
* Adding a new contact
*/
if ($action == 'addcontact' && $user->rights->ficheinter->creer) {
if ($action == 'addcontact' && $user->hasRight('ficheinter', 'creer')) {
if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
@ -76,10 +76,10 @@ if ($action == 'addcontact' && $user->rights->ficheinter->creer) {
setEventMessages($mesg, null, 'errors');
}
} elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer) {
} elseif ($action == 'swapstatut' && $user->hasRight('ficheinter', 'creer')) {
// Toggle the status of a contact
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
} elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer) {
} elseif ($action == 'deletecontact' && $user->hasRight('ficheinter', 'creer')) {
// Deletes a contact
$result = $object->delete_contact(GETPOST('lineid', 'int'));

View File

@ -1554,7 +1554,7 @@ if ($action == 'create' && $user->rights->projet->creer) {
$langs->load("suppliers");
print dolGetButtonAction('', $langs->trans('AddSupplierInvoice'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}
if (isModEnabled('ficheinter') && $user->rights->ficheinter->creer) {
if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer')) {
$langs->load("interventions");
print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
}

View File

@ -1109,7 +1109,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
//'builddoc'=>$langs->trans("PDFMerge"),
);
}
if ( isModEnabled('ficheinter') && $user->rights->ficheinter->creer) {
if ( isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer')) {
$langs->load("interventions");
$arrayofmassactions['generateinter'] = $langs->trans("GenerateInter");
}
@ -1390,7 +1390,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<input type="hidden" name="action" value="addtimespent">';
} elseif ($massaction == 'generateinvoice' && $user->hasRight('facture', 'creer')) {
print '<input type="hidden" name="action" value="confirm_generateinvoice">';
} elseif ($massaction == 'generateinter' && $user->rights->ficheinter->creer) {
} elseif ($massaction == 'generateinter' && $user->hasRight('ficheinter', 'creer')) {
print '<input type="hidden" name="action" value="confirm_generateinter">';
} else {
print '<input type="hidden" name="action" value="list">';

View File

@ -1416,7 +1416,7 @@ if ($action == 'create' || $action == 'presend') {
if (!$object->fk_soc && $user->hasRight("ficheinter", "creer")) {
print dolGetButtonAction($langs->trans('UnableToCreateInterIfNoSocid'), $langs->trans('TicketAddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
if ($object->fk_soc > 0 && isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $user->rights->ficheinter->creer) {
if ($object->fk_soc > 0 && isset($object->status) && $object->status < Ticket::STATUS_CLOSED && $user->hasRight('ficheinter', 'creer')) {
print dolGetButtonAction('', $langs->trans('TicketAddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&token='.newToken().'&socid='. $object->fk_soc.'&origin=ticket_ticket&originid='. $object->id, '');
}