diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index dd7cd655392..debeab8a681 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -497,9 +497,7 @@ if ($id > 0) { $formconfirm = $hookmanager->resPrint; } - /* - * View card - */ + print dol_get_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill', 0, '', '', 0, '', 1); // Print form confirm diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e35a62608b0..867c6b26d51 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -409,7 +409,7 @@ if (empty($reshook)) { $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if ($action == 'setstcomm') { + if ($action == 'setstcomm' && $permissiontoadd) { $object = new Contact($db); $result = $object->fetch(GETPOST('stcommcontactid')); $object->stcomm_id = dol_getIdFromCode($db, GETPOST('stcomm', 'alpha'), 'c_stcommcontact'); diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php index e636b499745..43e71fa6dd0 100644 --- a/htdocs/core/ajax/check_notifications.php +++ b/htdocs/core/ajax/check_notifications.php @@ -53,7 +53,7 @@ $listofreminderids = GETPOST('listofreminderids', 'aZ09'); * Actions */ -if ($action == 'stopreminder') { +if ($action == 'stopreminder') { // Test on permission not required here. Endpoint can be called dol_syslog("Clear notification for listofreminderids=".$listofreminderids); $listofreminderid = GETPOST('listofreminderids', 'intcomma'); diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index eff5c260b26..c4d57726ea5 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -59,23 +59,28 @@ if (empty($user->admin)) { /* - * View + * Actions */ -top_httphead(); - -//print ''."\n"; - // Registering the new value of constant if (!empty($action) && !empty($name)) { - if ($action == 'set') { + if ($action == 'set') { // Test on permission not required here. Already done into test on user->admin in header. dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity); - } elseif ($action == 'del') { + } elseif ($action == 'del') { // Test on permission not required here. Already done into test on user->admin in header. dolibarr_del_const($db, $name, $entity); if ($entity == 1) { // Sometimes the param was saved in both entity 0 and 1. When we work on master entity, we should clean also if entity is 0 dolibarr_del_const($db, $name, 0); } } } else { - http_response_code(403); + httponly_accessforbidden('Param action and name is required', 403); } + + +/* + * View + */ + +top_httphead(); + +//print ''."\n"; diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index bf5ca78cd16..b6726fe9e99 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -98,7 +98,11 @@ $hookmanager->initHooks(array('ecmmediascard', 'globalcard')); $result = restrictedArea($user, 'ecm', 0); +$permissiontoread = ($user->hasRight('ecm', 'read') || $user->hasRight('mailing', 'lire') || $user->hasRight('website', 'read')); $permissiontouploadfile = ($user->hasRight('ecm', 'setup') || $user->hasRight('mailing', 'creer') || $user->hasRight('website', 'write')); +$permissiontoadd = $permissiontouploadfile; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles + + $diroutput = $conf->medias->multidir_output[$conf->entity]; $relativepath = $section_dir; @@ -106,7 +110,7 @@ $upload_dir = preg_replace('/\/$/', '', $diroutput).'/'.preg_replace('/^\//', '' $websitekey = ''; -$permissiontoadd = $permissiontouploadfile; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles + /* * Actions @@ -124,7 +128,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; // This manage 's $backtopage = $savbacktopage; -if ($action == 'renamefile') { // Must be after include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; If action were renamefile, we set it to 'file_manager' +if ($action == 'renamefile') { // Test on permission not required here. Must be after include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; If action were renamefile, we set it to 'file_manager' $action = 'file_manager'; } @@ -148,7 +152,7 @@ if ($action == 'add' && $permissiontouploadfile) { } // Remove directory -if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes') { +if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes' && $permissiontoadd) { $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); @@ -158,7 +162,7 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm', 'alpha') == 'yes') // Refresh directory view // This refresh list of dirs, not list of files (for performance reason). List of files is refresh only if dir was not synchronized. // To refresh content of dir with cache, just open the dir in edit mode. -if ($action == 'refreshmanual') { +if ($action == 'refreshmanual' && $permissiontoread) { $ecmdirtmp = new EcmDirectory($db); // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate diff --git a/htdocs/expedition/ajax/searchfrombarcode.php b/htdocs/expedition/ajax/searchfrombarcode.php index f1f354a0438..543ec0c34a5 100644 --- a/htdocs/expedition/ajax/searchfrombarcode.php +++ b/htdocs/expedition/ajax/searchfrombarcode.php @@ -65,13 +65,21 @@ if (!$result) { httponly_accessforbidden('Not allowed by restrictArea (module='.$object->module.' table_element='.$object->table_element.')'); } + +/* + * Action + */ + +// None + + /* * View */ top_httphead('application/json'); -if ($action == "existbarcode" && !empty($barcode)) { +if ($action == "existbarcode" && !empty($barcode) && $user->hasRight('stock', 'lire')) { if (!empty($mode) && $mode == "lotserial") { $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode, ps.reel, pb.batch"; $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 1b3072f8402..d0b8b07db05 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -528,7 +528,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } // TODO add alternative status - //} elseif ($action == 'reopen' && (!empty($user->rights->expedition->creer) || !empty($user->rights->expedition->shipping_advance->validate))) + //} elseif ($action == 'reopen' && ($user->hasRight('expedition', 'creer') || $user->hasRight('expedition', 'shipping_advance', 'validate'))) //{ // $result = $object->setStatut(0); // if ($result < 0) @@ -544,15 +544,7 @@ if (empty($reshook)) { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif (($action == 'settracking_number' - || $action == 'settracking_url' - || $action == 'settrueWeight' - || $action == 'settrueWidth' - || $action == 'settrueHeight' - || $action == 'settrueDepth' - || $action == 'setshipping_method_id') - && $user->hasRight('expedition', 'creer') - ) { + } elseif (in_array($action, array('settracking_number', 'settracking_url', 'settrueWeight', 'settrueWidth', 'settrueHeight', 'settrueDepth', 'setshipping_method_id')) && $user->hasRight('expedition', 'creer')) { // Action update $error = 0; @@ -589,7 +581,7 @@ if (empty($reshook)) { } $action = ""; - } elseif ($action == 'classifybilled') { + } elseif ($action == 'classifybilled' && $permissiontoadd) { $object->fetch($id); $result = $object->setBilled(); if ($result >= 0) { @@ -597,7 +589,7 @@ if (empty($reshook)) { exit(); } setEventMessages($object->error, $object->errors, 'errors'); - } elseif ($action == 'classifyclosed') { + } elseif ($action == 'classifyclosed' && $permissiontoadd) { $object->fetch($id); $result = $object->setClosed(); if ($result >= 0) { @@ -605,7 +597,7 @@ if (empty($reshook)) { exit(); } setEventMessages($object->error, $object->errors, 'errors'); - } elseif ($action == 'deleteline' && !empty($line_id)) { + } elseif ($action == 'deleteline' && !empty($line_id) && $permissiontoadd) { // delete a line $object->fetch($id); $lines = $object->lines; @@ -640,7 +632,7 @@ if (empty($reshook)) { } else { setEventMessages($line->error, $line->errors, 'errors'); } - } elseif ($action == 'updateline' && $user->hasRight('expedition', 'creer') && GETPOST('save')) { + } elseif ($action == 'updateline' && $permissiontoadd && GETPOST('save')) { // Update a line // Clean parameters $qty = 0; @@ -876,7 +868,7 @@ if (empty($reshook)) { header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // To redisplay the form being edited exit(); } - } elseif ($action == 'updateline' && $user->hasRight('expedition', 'creer') && GETPOST('cancel', 'alpha') == $langs->trans("Cancel")) { + } elseif ($action == 'updateline' && $permissiontoadd && GETPOST('cancel', 'alpha') == $langs->trans("Cancel")) { header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // To redisplay the form being edited exit(); } diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 6229bdff4ad..4291ae72ba8 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -243,10 +243,10 @@ if ($action == 'unselectfield' && $user->hasRight('export', 'creer')) { if (($action == 'downfield' || $action == 'upfield') && $user->hasRight('export', 'creer')) { $pos = $array_selected[GETPOST("field")]; - if ($action == 'downfield') { + if ($action == 'downfield') { // Test on permission already done $newpos = $pos + 1; } - if ($action == 'upfield') { + if ($action == 'upfield') { // Test on permission already done $newpos = $pos - 1; } // Recherche code avec qui switcher diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8df3a82fe01..4759e1ed30f 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1063,7 +1063,7 @@ if (empty($reshook)) { } // Force mandatory order method - if ($action == 'commande') { // Not a real action so no permission test + if ($action == 'commande') { // Test on permission not required here $methodecommande = GETPOSTINT('methodecommande'); if ($cancel) { @@ -1546,8 +1546,8 @@ if (empty($reshook)) { } } - if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB') && $permissiontoadd) { - if ($action == 'addcontact') { + if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { + if ($action == 'addcontact' && $permissiontoadd) { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -1565,10 +1565,10 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } elseif ($action == 'swapstatut' && $object->id > 0) { + } elseif ($action == 'swapstatut' && $object->id > 0 && $permissiontoadd) { // bascule du statut d'un contact $result = $object->swapContactStatus(GETPOSTINT('ligne')); - } elseif ($action == 'deletecontact' && $object->id > 0) { + } elseif ($action == 'deletecontact' && $object->id > 0 && $permissiontoadd) { // Efface un contact $result = $object->delete_contact(GETPOSTINT("lineid")); diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index 7fefb8a3c44..aa7e5ede40e 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -872,7 +872,7 @@ if (empty($reshook)) { } /* - * View + * View */ $help_url = ''; @@ -889,9 +889,8 @@ $invoicerectmp = new FactureFournisseurRec($db); $now = dol_now(); $nowlasthour = dol_get_last_hour($now); -/* - * Create mode - */ +// Create mode + if ($action == 'create') { print load_fiche_titre($langs->trans("CreateRepeatableInvoice"), '', 'bill'); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b77d4e47e15..10a5536a845 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2050,7 +2050,7 @@ if (empty($reshook)) { /* - * View + * View */ $form = new Form($db); diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index e5a990b7756..ae60d77c152 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -68,12 +68,16 @@ if ($socid && $socid != $object->thirdparty->id) { accessforbidden(); } +$permissiontoadd = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "write")); +$permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "write"))) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "supplier_invoice_advance", "validate"))); +$permissiontodelete = ($user->hasRight("fournisseur", "facture", "supprimer") || $user->hasRight("supplier_invoice", "delete")); + /* * Actions */ -if ($action == 'setnote' && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) { +if ($action == 'setnote' && $permissiontoadd) { $db->begin(); $object->fetch($id); @@ -87,7 +91,7 @@ if ($action == 'setnote' && ($user->hasRight("fournisseur", "facture", "creer") } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight("fournisseur", "facture", "supprimer")) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) { $db->begin(); $object->fetch($id); @@ -102,10 +106,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight("fournis } } -if ($action == 'confirm_validate' && $confirm == 'yes' && - ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"))) - || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "supplier_invoice_advance", "validate"))) -) { +if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontovalidate) { $db->begin(); $object->fetch($id); @@ -119,7 +120,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && } } -if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { +if ($action == 'setnum_paiement' && GETPOST('num_paiement') && $permissiontoadd) { $object->fetch($id); $res = $object->update_num(GETPOST('num_paiement')); if ($res === 0) { @@ -129,7 +130,7 @@ if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { } } -if ($action == 'setdatep' && GETPOST('datepday')) { +if ($action == 'setdatep' && GETPOST('datepday') && $permissiontoadd) { $object->fetch($id); $datepaye = dol_mktime(GETPOSTINT('datephour'), GETPOSTINT('datepmin'), GETPOSTINT('datepsec'), GETPOSTINT('datepmonth'), GETPOSTINT('datepday'), GETPOSTINT('datepyear')); $res = $object->update_date($datepaye); @@ -142,8 +143,6 @@ if ($action == 'setdatep' && GETPOST('datepday')) { // Build document $upload_dir = $conf->fournisseur->payment->dir_output; -// TODO: get the appropriate permission -$permissiontoadd = true; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 8a2297f5f93..4abddc738c7 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -95,14 +95,14 @@ if (($id > 0) || $ref) { // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('holidaycard', 'globalcard')); -$cancreate = 0; -$cancreateall = 0; +$permissiontoadd = 0; +$permissiontoaddall = 0; if ($user->hasRight('holiday', 'write') && in_array($fuserid, $childids)) { - $cancreate = 1; + $permissiontoadd = 1; } if ($user->hasRight('holiday', 'writeall')) { - $cancreate = 1; - $cancreateall = 1; + $permissiontoadd = 1; + $permissiontoaddall = 1; } $candelete = 0; @@ -155,7 +155,7 @@ if (empty($reshook)) { } // Add leave request - if ($action == 'add' && $cancreate) { + if ($action == 'add' && $permissiontoadd) { $object = new Holiday($db); $db->begin(); @@ -180,7 +180,7 @@ if (empty($reshook)) { $description = trim(GETPOST('description', 'restricthtml')); // Check that leave is for a user inside the hierarchy or advanced permission for all is set - if (!$cancreateall) { + if (!$permissiontoaddall) { if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { if (!$user->hasRight('holiday', 'write')) { $error++; @@ -332,8 +332,8 @@ if (empty($reshook)) { } // If no right to modify a request - if (!$cancreateall) { - if ($cancreate) { + if (!$permissiontoaddall) { + if ($permissiontoadd) { if (!in_array($fuserid, $childids)) { setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors'); header('Location: '.$_SERVER["PHP_SELF"].'?action=create'); @@ -351,7 +351,7 @@ if (empty($reshook)) { // If under validation if ($object->status == Holiday::STATUS_DRAFT) { // If this is the requester or has read/write rights - if ($cancreate) { + if ($permissiontoadd) { $approverid = GETPOSTINT('valideur'); // TODO Check this approver user id has the permission for approval @@ -454,7 +454,7 @@ if (empty($reshook)) { $object->fetch($id); // If draft and owner of leave - if ($object->status == Holiday::STATUS_DRAFT && $cancreate) { + if ($object->status == Holiday::STATUS_DRAFT && $permissiontoadd) { $object->oldcopy = dol_clone($object, 2); $object->status = Holiday::STATUS_VALIDATED; @@ -595,7 +595,7 @@ if (empty($reshook)) { $object->fetch($id); // If status is waiting approval and approver is also user - if ($object->status == Holiday::STATUS_VALIDATED && ($user->id == $object->fk_validator || $cancreateall) && $user->hasRight('holiday', 'approve')) { + if ($object->status == Holiday::STATUS_VALIDATED && ($user->id == $object->fk_validator || $permissiontoaddall) && $user->hasRight('holiday', 'approve')) { $object->oldcopy = dol_clone($object, 2); $object->date_approval = dol_now(); @@ -702,7 +702,7 @@ if (empty($reshook)) { $object->fetch($id); // If status pending validation and validator = user - if ($object->status == Holiday::STATUS_VALIDATED && ($user->id == $object->fk_validator || $cancreateall) && $user->hasRight('holiday', 'approve')) { + if ($object->status == Holiday::STATUS_VALIDATED && ($user->id == $object->fk_validator || $permissiontoaddall) && $user->hasRight('holiday', 'approve')) { $object->date_refuse = dol_now(); $object->fk_user_refuse = $user->id; $object->statut = Holiday::STATUS_REFUSED; @@ -823,7 +823,7 @@ if (empty($reshook)) { // If status pending validation and validator = validator or user, or rights to do for others if (($object->status == Holiday::STATUS_VALIDATED || $object->status == Holiday::STATUS_APPROVED) && - (!empty($user->admin) || $user->id == $object->fk_validator || $cancreate || $cancreateall)) { + (!empty($user->admin) || $user->id == $object->fk_validator || $permissiontoadd || $permissiontoaddall)) { $db->begin(); $oldstatus = $object->status; @@ -1047,7 +1047,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print ''; print ''.$langs->trans("User").''; print '
'; - if ($cancreate && !$cancreateall) { + if ($permissiontoadd && !$permissiontoaddall) { print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500 inline-block'); //print ''; } else { @@ -1534,7 +1534,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { if (($action == 'edit' && $object->status == Holiday::STATUS_DRAFT) || ($action == 'editvalidator')) { if ($action == 'edit' && $object->status == Holiday::STATUS_DRAFT) { - if ($cancreate && $object->status == Holiday::STATUS_DRAFT) { + if ($permissiontoadd && $object->status == Holiday::STATUS_DRAFT) { print $form->buttonsSaveCancel(); } } @@ -1547,17 +1547,17 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print '
'; - if ($cancreate && $object->status == Holiday::STATUS_DRAFT) { + if ($permissiontoadd && $object->status == Holiday::STATUS_DRAFT) { print ''.$langs->trans("EditCP").''; } - if ($cancreate && $object->status == Holiday::STATUS_DRAFT) { // If draft + if ($permissiontoadd && $object->status == Holiday::STATUS_DRAFT) { // If draft print ''.$langs->trans("Validate").''; } if ($object->status == Holiday::STATUS_VALIDATED) { // If validated // Button Approve / Refuse - if (($user->id == $object->fk_validator || $cancreateall) && $user->hasRight('holiday', 'approve')) { + if (($user->id == $object->fk_validator || $permissiontoaddall) && $user->hasRight('holiday', 'approve')) { print ''.$langs->trans("Approve").''; print ''.$langs->trans("ActionRefuseCP").''; } else { @@ -1565,7 +1565,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print ''.$langs->trans("ActionRefuseCP").''; // Button Cancel (because we can't approve) - if ($cancreate || $cancreateall) { + if ($permissiontoadd || $permissiontoaddall) { if (($object->date_fin > dol_now()) || !empty($user->admin)) { print ''.$langs->trans("ActionCancelCP").''; } else { @@ -1575,7 +1575,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } } if ($object->status == Holiday::STATUS_APPROVED) { // If validated and approved - if ($user->id == $object->fk_validator || $user->id == $object->fk_user_approve || $cancreate || $cancreateall) { + if ($user->id == $object->fk_validator || $user->id == $object->fk_user_approve || $permissiontoadd || $permissiontoaddall) { if (($object->date_fin > dol_now()) || !empty($user->admin) || $user->id == $object->fk_user_approve) { print ''.$langs->trans("ActionCancelCP").''; } else { @@ -1590,7 +1590,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } } - if (($cancreate || $cancreateall) && $object->status == Holiday::STATUS_CANCELED) { + if (($permissiontoadd || $permissiontoaddall) && $object->status == Holiday::STATUS_CANCELED) { print ''.$langs->trans("SetToDraft").''; } if ($candelete && ($object->status == Holiday::STATUS_DRAFT || $object->status == Holiday::STATUS_CANCELED || $object->status == Holiday::STATUS_REFUSED)) { // If draft or canceled or refused diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 2e65d6eda72..512d865d334 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -99,14 +99,14 @@ if (($id > 0) || $ref) { // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('holidaycard', 'globalcard')); -$cancreate = 0; -$cancreateall = 0; +$permissiontoadd = 0; +$permissiontoaddall = 0; if ($user->hasRight('holiday', 'write') && in_array($fuserid, $childids)) { - $cancreate = 1; + $permissiontoadd = 1; } if ($user->hasRight('holiday', 'writeall')) { - $cancreate = 1; - $cancreateall = 1; + $permissiontoadd = 1; + $permissiontoaddall = 1; } $candelete = 0; @@ -159,7 +159,7 @@ if (empty($reshook)) { } // Add leave request - if ($action == 'add' && $cancreate) { + if ($action == 'add' && $permissiontoadd) { $users = GETPOST('users', 'array'); $groups = GETPOST('groups', 'array'); @@ -184,7 +184,7 @@ if (empty($reshook)) { $description = trim(GETPOST('description', 'restricthtml')); // Check that leave is for a user inside the hierarchy or advanced permission for all is set - if (!$cancreateall) { + if (!$permissiontoaddall) { if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { if (!$user->hasRight('holiday', 'write')) { $error++; @@ -332,7 +332,7 @@ if (empty($reshook)) { if ($AutoSendMail && !$error) { // send a mail to the user - $returnSendMail = sendMail($result, $cancreate, $now, $autoValidation); + $returnSendMail = sendMail($result, $permissiontoadd, $now, $autoValidation); if (!empty($returnSendMail->msg)) { setEventMessage($returnSendMail->msg, $returnSendMail->style); } @@ -664,13 +664,14 @@ llxFooter(); if (is_object($db)) { $db->close(); } + /** * send email to validator for current leave represented by (id) * - * @param int $id validator for current leave represented by (id) - * @param int $cancreate flag for user right - * @param int $now date - * @param int $autoValidation boolean flag on autovalidation + * @param int $id validator for current leave represented by (id) + * @param int $cancreate flag for user right + * @param int $now date + * @param int $autoValidation boolean flag on autovalidation * * @return stdClass * @throws Exception @@ -683,7 +684,7 @@ function sendMail($id, $cancreate, $now, $autoValidation) $objStd->error = 0; $objStd->style = ''; - global $db, $user, $conf, $langs; + global $db, $user, $langs; $object = new Holiday($db); diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 018ee9229f1..8ddddd946ff 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -55,6 +55,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'inclu $permissiontoread = $user->admin; $permissiontoadd = $user->admin; // Used by the include of actions_addupdatedelete.inc.php $permissiontodelete = $user->admin; + $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check - Protection if external user @@ -74,7 +75,7 @@ if (empty($permissiontoread)) { * Actions */ -if ($action == 'confirm_delete' && $confirm == "yes") { +if ($action == 'confirm_delete' && $confirm == "yes" && $permissiontodelete) { $result = $object->delete($user); if ($result >= 0) { header("Location: ../admin/admin_establishment.php"); @@ -82,7 +83,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { } else { setEventMessages($object->error, $object->errors, 'errors'); } -} elseif ($action == 'add') { +} elseif ($action == 'add' && $permissiontoadd) { if (!$cancel) { $error = 0; @@ -117,7 +118,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { header("Location: ../admin/admin_establishment.php"); exit; } -} elseif ($action == 'update') { +} elseif ($action == 'update' && $permissiontoadd) { // Update record $error = 0; @@ -153,6 +154,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") { } } + /* * View */ @@ -162,9 +164,7 @@ llxHeader(); $form = new Form($db); $formcompany = new FormCompany($db); -/* - * Action create - */ +// Action create if ($action == 'create') { print load_fiche_titre($langs->trans("NewEstablishment")); diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 5e9973a34bd..da44a96e8bb 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -608,9 +608,7 @@ if ($action != "create" && $action != "edit") { $arrayfields = dol_sort_array($arrayfields, 'position'); - /* - * View - */ + // View $form = new Form($db); diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 76fccc5a621..28cab2e155d 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -94,6 +94,13 @@ dolibarr_install_syslog("--- step2: entering step2.php page"); '@phan-var-force string $dolibarr_main_db_prefix'; // From configuraiotn file or install/inc.php +/* + * Actions + */ + +// None + + /* * View */ @@ -107,7 +114,7 @@ if (!is_writable($conffile)) { exit; } -if ($action == "set") { +if ($action == "set") { // Test on permission not required. Already managed by test in inc.php print '

Database '.$langs->trans("Database").'

'; print ''; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 26a203d9fcf..373ddd3d4cc 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -496,7 +496,7 @@ if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontac '---Replace with your own copyright and developer email---' => getLicenceHeader($user, $langs, $now) ); - if ($action == 'initapi') { + if ($action == 'initapi') { // Test on permission already done if (count($objects) >= 1) { addObjectsToApiFile($srcfile, $destfile, $objects, $modulename); } diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 82a50720428..e75db71c70a 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -115,7 +115,7 @@ if ($action == "existbarcode" && !empty($barcode) && $user->hasRight('stock', 'l $response = array('status'=>'error','errorcode'=>'ActionError','message'=>"Error on action"); } -if ($action == "addnewlineproduct") { +if ($action == "addnewlineproduct" && $user->hasRight('stock', 'creer')) { require_once DOL_DOCUMENT_ROOT."/product/inventory/class/inventory.class.php"; $inventoryline = new InventoryLine($db); if (!empty($fk_inventory)) { diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 58ca72c3a27..b65fc5d1459 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -658,6 +658,9 @@ class CodingPhpTest extends CommonClassTest && !preg_match('/done later/i', $val[0]) && !preg_match('/not required/i', $val[0])) { $ok = false; + + //var_dump($file['fullname'].' '.$filecontentaction);exit; + print "File ".$file['relativename']." - Line: ".$val[0]."\n"; break; }