diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 8c4a5197b77..600d22b432a 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -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 '
'.$langs->trans("AddContract").'
'; } - if (isModEnabled('ficheinter') && $user->rights->ficheinter->creer && $object->status == 1) { + if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer') && $object->status == 1) { $langs->load("fichinter"); print '
'.$langs->trans("AddIntervention").'
'; } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 3e7a1554367..7d9a95bad56 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -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'); } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 6afa6d2efc6..c878ede3a16 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -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", diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 8d13e69bdfe..98bf61d4f20 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -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", diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index bfed76168d5..de6d5f97c24 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -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 ''; - if ($action != 'editfrequency' && $user->rights->ficheinter->creer) { + if ($action != 'editfrequency' && $user->hasRight('ficheinter', 'creer')) { print ''; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 253fcd004fd..f5aa06d48d5 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -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 "\n"; // Icon to edit and delete - if ($object->statut == 0 && $user->rights->ficheinter->creer) { + if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer')) { print ''; // 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 '
'; print '
'; print $langs->trans('Frequency'); print ''; print img_edit($langs->trans('Edit'), 1).''; print '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 '
'; @@ -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 '
'.$langs->trans("Validate").'
'; } else { print '
'.$langs->trans("Validate").'
'; @@ -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 '
'; 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 '
'; print ''.$langs->trans("ChangeIntoRepeatableIntervention").''; print '
'; diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index aa0fe5b482f..9884fb1e2cd 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -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')); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 55f2d51372c..66e58075e33 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -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&projectid='.$object->id.'&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&projectid='.$object->id.'&socid='.$object->socid, '', 1, array('isDropDown' => true)); } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 42e75cce65a..30f2a867af0 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -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 ''; } elseif ($massaction == 'generateinvoice' && $user->hasRight('facture', 'creer')) { print ''; - } elseif ($massaction == 'generateinter' && $user->rights->ficheinter->creer) { + } elseif ($massaction == 'generateinter' && $user->hasRight('ficheinter', 'creer')) { print ''; } else { print ''; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index fe63cfc8334..95d290d680a 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -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, ''); }