364function restrictedArea(
User $user, $features, $object = 0, $tableandshare =
'', $feature2 =
'', $dbt_keyfield =
'fk_soc', $dbt_select =
'rowid', $isdraft = 0, $mode = 0)
370 if (is_object($object)) {
371 $objectid = $object->id;
375 if ($objectid ==
"-1") {
379 $objectid = preg_replace(
'/[^0-9\.\,]/',
'', $objectid);
388 $parentfortableentity =
'';
391 $originalfeatures = $features;
392 if ($features ==
'agenda') {
393 $tableandshare =
'actioncomm&societe';
394 $feature2 =
'myactions|allactions';
397 if ($features ==
'bank') {
398 $features =
'banque';
400 if ($features ==
'facturerec') {
401 $features =
'facture';
403 if ($features ==
'supplier_invoicerec') {
404 $features =
'fournisseur';
405 $feature2 =
'facture';
407 if ($features ==
'mo') {
410 if ($features ==
'member') {
411 $features =
'adherent';
413 if ($features ==
'subscription') {
414 $features =
'adherent';
415 $feature2 =
'cotisation';
417 if ($features ==
'website' && is_object($object) && $object->element ==
'websitepage') {
418 $parentfortableentity =
'fk_website@website';
420 if ($features ==
'project') {
421 $features =
'projet';
423 if ($features ==
'product') {
424 $features =
'produit';
426 if ($features ==
'productbatch') {
427 $features =
'produit';
429 if ($features ==
'tax') {
430 $feature2 =
'charges';
432 if ($features ==
'workstation') {
433 $feature2 =
'workstation';
435 if ($features ==
'fournisseur') {
436 $features =
'fournisseur';
437 if (is_object($object) && $object->element ==
'invoice_supplier') {
438 $feature2 =
'facture';
439 } elseif (is_object($object) && $object->element ==
'order_supplier') {
440 $feature2 =
'commande';
443 if ($features ==
'payment_sc') {
444 $tableandshare =
'paiementcharge';
445 $parentfortableentity =
'fk_charge@chargesociales';
451 $parameters = array(
'features'=>$features,
'originalfeatures'=>$originalfeatures,
'objectid'=>$objectid,
'dbt_select'=>$dbt_select,
'idtype'=>$dbt_select,
'isdraft'=>$isdraft);
452 if (!empty($hookmanager)) {
453 $reshook = $hookmanager->executeHooks(
'restrictedArea', $parameters);
455 if (isset($hookmanager->resArray[
'result'])) {
456 if ($hookmanager->resArray[
'result'] == 0) {
470 $featuresarray = array($features);
471 if (preg_match(
'/&/', $features)) {
472 $featuresarray = explode(
"&", $features);
473 } elseif (preg_match(
'/\|/', $features)) {
474 $featuresarray = explode(
"|", $features);
478 if (!empty($feature2)) {
479 $feature2 = explode(
"|", $feature2);
487 foreach ($featuresarray as $feature) {
488 $featureforlistofmodule = $feature;
489 if ($featureforlistofmodule ==
'produit') {
490 $featureforlistofmodule =
'product';
492 if ($featureforlistofmodule ==
'supplier_proposal') {
493 $featureforlistofmodule =
'supplierproposal';
495 if (!empty($user->socid) &&
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL') && !in_array($featureforlistofmodule, $listofmodules)) {
501 if ($feature ==
'societe' && (empty($feature2) || !in_array(
'contact', $feature2))) {
502 if (!$user->hasRight(
'societe',
'lire') && !$user->hasRight(
'fournisseur',
'lire')) {
506 } elseif (($feature ==
'societe' && (!empty($feature2) && in_array(
'contact', $feature2))) || $feature ==
'contact') {
507 if (!$user->hasRight(
'societe',
'contact',
'lire')) {
511 } elseif ($feature ==
'produit|service') {
512 if (!$user->hasRight(
'produit',
'lire') && !$user->hasRight(
'service',
'lire')) {
516 } elseif ($feature ==
'prelevement') {
517 if (!$user->hasRight(
'prelevement',
'bons',
'lire')) {
521 } elseif ($feature ==
'cheque') {
522 if (!$user->hasRight(
'banque',
'cheque')) {
526 } elseif ($feature ==
'projet') {
527 if (!$user->hasRight(
'projet',
'lire') && !$user->hasRight(
'projet',
'all',
'lire')) {
531 } elseif ($feature ==
'payment') {
532 if (!$user->hasRight(
'facture',
'lire')) {
536 } elseif ($feature ==
'payment_supplier') {
537 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
541 } elseif ($feature ==
'payment_sc') {
542 if (!$user->hasRight(
'tax',
'charges',
'lire')) {
546 } elseif (!empty($feature2)) {
548 foreach ($feature2 as $subfeature) {
549 if ($subfeature ==
'user' && $user->id == $objectid) {
552 if ($subfeature ==
'fiscalyear' && $user->hasRight(
'accounting',
'fiscalyear',
'write')) {
557 if (!empty($subfeature) && !$user->hasRight($feature, $subfeature,
'lire') && !$user->hasRight($feature, $subfeature,
'read')) {
559 } elseif (empty($subfeature) && !$user->hasRight($feature,
'lire') && !$user->hasRight($feature,
'read')) {
570 } elseif (!empty($feature) && ($feature !=
'user' && $feature !=
'usergroup')) {
571 if (!$user->hasRight($feature,
'lire')
572 && !$user->hasRight($feature,
'read')
573 && !$user->hasRight($feature,
'run')) {
581 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
597 $wemustcheckpermissionforcreate = (
GETPOST(
'sendit',
'alpha') ||
GETPOST(
'linkit',
'alpha') || in_array(
GETPOST(
'action',
'aZ09'), array(
'create',
'update',
'set',
'upload',
'add_element_resource',
'confirm_deletebank',
'confirm_delete_linked_resource')) ||
GETPOST(
'roworder',
'alpha', 2));
598 $wemustcheckpermissionfordeletedraft = ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete');
600 if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) {
601 foreach ($featuresarray as $feature) {
602 if ($feature ==
'contact') {
603 if (!$user->hasRight(
'societe',
'contact',
'creer')) {
607 } elseif ($feature ==
'produit|service') {
608 if (!$user->hasRight(
'produit',
'creer') && !$user->hasRight(
'service',
'creer')) {
612 } elseif ($feature ==
'prelevement') {
613 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
617 } elseif ($feature ==
'commande_fournisseur') {
618 if (!$user->hasRight(
'fournisseur',
'commande',
'creer') || !$user->hasRight(
'supplier_order',
'creer')) {
622 } elseif ($feature ==
'banque') {
623 if (!$user->hasRight(
'banque',
'modifier')) {
627 } elseif ($feature ==
'cheque') {
628 if (!$user->hasRight(
'banque',
'cheque')) {
632 } elseif ($feature ==
'import') {
633 if (!$user->hasRight(
'import',
'run')) {
637 } elseif ($feature ==
'ecm') {
638 if (!$user->hasRight(
'ecm',
'upload')) {
642 } elseif ($feature ==
'modulebuilder') {
643 if (!$user->hasRight(
'modulebuilder',
'run')) {
647 } elseif (!empty($feature2)) {
648 foreach ($feature2 as $subfeature) {
649 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'creer')) {
652 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'password')) {
655 if ($subfeature ==
'user' && $user->id != $objectid && $user->hasRight(
'user',
'user',
'password')) {
659 if (!$user->hasRight($feature, $subfeature,
'creer')
660 && !$user->hasRight($feature, $subfeature,
'write')
661 && !$user->hasRight($feature, $subfeature,
'create')) {
670 } elseif (!empty($feature)) {
672 if (!$user->hasRight($feature,
'creer')
673 && !$user->hasRight($feature,
'write')
674 && !$user->hasRight($feature,
'create')) {
682 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
686 if ($wemustcheckpermissionforcreate && !$createok) {
698 if (
GETPOST(
'action',
'aZ09') ==
'confirm_create_user' &&
GETPOST(
"confirm",
'aZ09') ==
'yes') {
699 if (!$user->hasRight(
'user',
'user',
'creer')) {
703 if (!$createuserok) {
716 if ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete') {
717 foreach ($featuresarray as $feature) {
718 if ($feature ==
'bookmark') {
719 if (!$user->hasRight(
'bookmark',
'supprimer')) {
720 if ($user->id != $object->fk_user || !$user->hasRight(
'bookmark',
'creer')) {
724 } elseif ($feature ==
'contact') {
725 if (!$user->hasRight(
'societe',
'contact',
'supprimer')) {
728 } elseif ($feature ==
'produit|service') {
729 if (!$user->hasRight(
'produit',
'supprimer') && !$user->hasRight(
'service',
'supprimer')) {
732 } elseif ($feature ==
'commande_fournisseur') {
733 if (!$user->hasRight(
'fournisseur',
'commande',
'supprimer')) {
736 } elseif ($feature ==
'payment_supplier') {
737 if (!$user->hasRight(
'fournisseur',
'facture',
'creer')) {
740 } elseif ($feature ==
'payment') {
741 if (!$user->hasRight(
'facture',
'paiement')) {
744 } elseif ($feature ==
'payment_sc') {
745 if (!$user->hasRight(
'tax',
'charges',
'creer')) {
748 } elseif ($feature ==
'banque') {
749 if (!$user->hasRight(
'banque',
'modifier')) {
752 } elseif ($feature ==
'cheque') {
753 if (!$user->hasRight(
'banque',
'cheque')) {
756 } elseif ($feature ==
'ecm') {
757 if (!$user->hasRight(
'ecm',
'upload')) {
760 } elseif ($feature ==
'ftp') {
761 if (!$user->hasRight(
'ftp',
'write')) {
764 } elseif ($feature ==
'salaries') {
765 if (!$user->hasRight(
'salaries',
'delete')) {
768 } elseif ($feature ==
'adherent') {
769 if (!$user->hasRight(
'adherent',
'supprimer')) {
772 } elseif ($feature ==
'paymentbybanktransfer') {
773 if (!$user->hasRight(
'paymentbybanktransfer',
'create')) {
776 } elseif ($feature ==
'prelevement') {
777 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
780 } elseif (!empty($feature2)) {
781 foreach ($feature2 as $subfeature) {
782 if (!$user->hasRight($feature, $subfeature,
'supprimer') && !$user->hasRight($feature, $subfeature,
'delete')) {
789 } elseif (!empty($feature)) {
791 if (!$user->hasRight($feature,
'supprimer')
792 && !$user->hasRight($feature,
'delete')
793 && !$user->hasRight($feature,
'run')) {
800 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
804 if (!$deleteok && !($isdraft && $createok)) {
816 if (!empty($objectid) && $objectid > 0) {
817 $ok =
checkUserAccessToObject($user, $featuresarray, $object, $tableandshare, $feature2, $dbt_keyfield, $dbt_select, $parentfortableentity);
818 $params = array(
'objectid' => $objectid,
'features' => join(
',', $featuresarray),
'features2' => $feature2);
849function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tableandshare =
'', $feature2 =
'', $dbt_keyfield =
'', $dbt_select =
'rowid', $parenttableforentity =
'')
853 if (is_object($object)) {
854 $objectid = $object->id;
858 $objectid = preg_replace(
'/[^0-9\.\,]/',
'', $objectid);
865 $params = explode(
'&', $tableandshare);
866 $dbtablename = (!empty($params[0]) ? $params[0] :
'');
867 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
869 foreach ($featuresarray as $feature) {
875 if ($feature ==
'societe' && !empty($feature2) && is_array($feature2) && in_array(
'contact', $feature2)) {
876 $feature =
'contact';
879 if ($feature ==
'member') {
880 $feature =
'adherent';
882 if ($feature ==
'project') {
885 if ($feature ==
'task') {
886 $feature =
'projet_task';
888 if ($feature ==
'eventorganization') {
890 $dbtablename =
'actioncomm';
892 if ($feature ==
'payment_sc' && empty($parenttableforentity)) {
894 $parenttableforentity =
'';
895 $dbtablename =
"chargesociales";
896 $feature =
"chargesociales";
897 $objectid = $object->fk_charge;
900 $checkonentitydone = 0;
903 $check = array(
'adherent',
'banque',
'bom',
'don',
'mrp',
'user',
'usergroup',
'payment',
'payment_supplier',
'payment_sc',
'product',
'produit',
'service',
'produit|service',
'categorie',
'resource',
'expensereport',
'holiday',
'salaries',
'website',
'recruitment',
'chargesociales',
'knowledgemanagement');
904 $checksoc = array(
'societe');
905 $checkparentsoc = array(
'agenda',
'contact',
'contrat');
906 $checkproject = array(
'projet',
'project');
907 $checktask = array(
'projet_task');
908 $checkhierarchy = array(
'expensereport',
'holiday');
909 $checkuser = array(
'bookmark');
910 $nocheck = array(
'barcode',
'stock');
915 if (empty($dbtablename)) {
916 $dbtablename = $feature;
917 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
921 if ($dbt_select !=
'rowid' && $dbt_select !=
'id') {
922 $objectid =
"'".$objectid.
"'";
925 if (in_array($feature, $check) && $objectid > 0) {
926 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
927 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
928 if (($feature ==
'user' || $feature ==
'usergroup') && isModEnabled(
'multicompany')) {
930 if ($conf->entity == 1 && $user->admin && !$user->entity) {
931 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
932 $sql .=
" AND dbt.entity IS NOT NULL";
934 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
935 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
936 $sql .=
" AND ((ug.fk_user = dbt.rowid";
937 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
938 $sql .=
" OR dbt.entity = 0)";
941 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
942 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
946 if ($parenttableforentity && preg_match(
'/(.*)@(.*)/', $parenttableforentity, $reg)) {
947 $sql .=
", ".MAIN_DB_PREFIX.$reg[2].
" as dbtp";
948 $sql .=
" WHERE dbt.".$reg[1].
" = dbtp.rowid AND dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
949 $sql .=
" AND dbtp.entity IN (".getEntity($sharedelement, 1).
")";
951 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
952 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
955 $checkonentitydone = 1;
957 if (in_array($feature, $checksoc) && $objectid > 0) {
959 if ($user->socid > 0) {
960 if ($user->socid != $objectid) {
963 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
965 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
966 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
967 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s)";
968 $sql .=
" WHERE sc.fk_soc IN (".$db->sanitize($objectid, 1).
")";
969 $sql .=
" AND sc.fk_user = ".((int) $user->id);
970 $sql .=
" AND sc.fk_soc = s.rowid";
971 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
972 } elseif (isModEnabled(
'multicompany')) {
974 $sql =
"SELECT COUNT(s.rowid) as nb";
975 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
976 $sql .=
" WHERE s.rowid IN (".$db->sanitize($objectid, 1).
")";
977 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
980 $checkonentitydone = 1;
982 if (in_array($feature, $checkparentsoc) && $objectid > 0) {
984 if ($user->socid > 0) {
985 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
986 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
987 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
988 $sql .=
" AND dbt.fk_soc = ".((int) $user->socid);
989 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
991 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
992 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
993 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
994 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
995 $sql .=
" AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)";
996 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
997 } elseif (isModEnabled(
'multicompany')) {
999 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1000 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1001 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1002 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1005 $checkonentitydone = 1;
1007 if (in_array($feature, $checkproject) && $objectid > 0) {
1008 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1009 $projectid = $objectid;
1011 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1012 $projectstatic =
new Project($db);
1013 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1015 $tmparray = explode(
',', $tmps);
1016 if (!in_array($projectid, $tmparray)) {
1020 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1021 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1022 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1023 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1025 $checkonentitydone = 1;
1027 if (in_array($feature, $checktask) && $objectid > 0) {
1028 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1029 $task =
new Task($db);
1030 $task->fetch($objectid);
1031 $projectid = $task->fk_project;
1033 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1034 $projectstatic =
new Project($db);
1035 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1037 $tmparray = explode(
',', $tmps);
1038 if (!in_array($projectid, $tmparray)) {
1042 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1043 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1044 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1045 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1048 $checkonentitydone = 1;
1052 if (!$checkonentitydone && !in_array($feature, $nocheck) && $objectid > 0) {
1054 if ($user->socid > 0) {
1055 if (empty($dbt_keyfield)) {
1056 dol_print_error(
'',
'Param dbt_keyfield is required but not defined');
1058 $sql =
"SELECT COUNT(dbt.".$dbt_keyfield.
") as nb";
1059 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1060 $sql .=
" WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).
")";
1061 $sql .=
" AND dbt.".$dbt_keyfield.
" = ".((int) $user->socid);
1062 } elseif (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
1064 if ($feature !=
'ticket') {
1065 if (empty($dbt_keyfield)) {
1066 dol_print_error(
'',
'Param dbt_keyfield is required but not defined');
1068 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
1069 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1070 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1071 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1072 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1073 $sql .=
" AND sc.fk_soc = dbt.".$dbt_keyfield;
1074 $sql .=
" AND sc.fk_user = ".((int) $user->id);
1077 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1078 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1079 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield.
" AND sc.fk_user = ".((int) $user->id);
1080 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1081 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1082 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR sc.fk_user IS NULL)";
1084 } elseif (isModEnabled(
'multicompany')) {
1086 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1087 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1088 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1089 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1094 if ($feature ===
'agenda' && $objectid > 0) {
1096 if ($objectid > 0 && !$user->hasRight(
'agenda',
'allactions',
'read')) {
1097 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1099 $action->fetch($objectid);
1100 if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
1108 if (in_array($feature, $checkhierarchy) && is_object($object) && $objectid > 0) {
1109 $childids = $user->getAllChildIds(1);
1111 if ($feature ==
'holiday') {
1112 $useridtocheck = $object->fk_user;
1113 if (!$user->hasRight(
'holiday',
'readall') && !in_array($useridtocheck, $childids) && !in_array($object->fk_validator, $childids)) {
1117 if ($feature ==
'expensereport') {
1118 $useridtocheck = $object->fk_user_author;
1119 if (!$user->hasRight(
'expensereport',
'readall')) {
1120 if (!in_array($useridtocheck, $childids)) {
1129 if (in_array($feature, $checkuser) && is_object($object) && $objectid > 0) {
1130 $useridtocheck = $object->fk_user;
1131 if (!empty($useridtocheck) && $useridtocheck > 0 && $useridtocheck != $user->id && empty($user->admin)) {
1137 $resql = $db->query($sql);
1139 $obj = $db->fetch_object($resql);
1140 if (!$obj || $obj->nb < count(explode(
',', $objectid))) {
1144 dol_syslog(
"Bad forged sql in checkUserAccessToObject", LOG_WARNING);
1192function accessforbidden($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
1194 global $conf, $db, $user, $langs, $hookmanager;
1195 global $action, $object;
1197 if (!is_object($langs)) {
1198 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
1200 $langs->setDefaultLang();
1203 $langs->loadLangs(array(
"main",
"errors"));
1206 if (function_exists(
"llxHeader")) {
1208 } elseif (function_exists(
"llxHeaderVierge")) {
1211 print
'<div style="padding: 20px">';
1213 print
'<div class="error">';
1214 if (empty($message)) {
1215 print $langs->trans(
"ErrorForbidden");
1217 print $langs->trans($message);
1221 if (empty($showonlymessage)) {
1222 if (empty($hookmanager)) {
1223 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1226 $hookmanager->initHooks(array(
'main'));
1229 $parameters = array(
'message'=>$message,
'params'=>$params);
1230 $reshook = $hookmanager->executeHooks(
'getAccessForbiddenMessage', $parameters, $object, $action);
1231 print $hookmanager->resPrint;
1232 if (empty($reshook)) {
1233 $langs->loadLangs(array(
"errors"));
1235 print $langs->trans(
"CurrentLogin").
': <span class="error">'.$user->login.
'</span><br>';
1236 print $langs->trans(
"ErrorForbidden2", $langs->transnoentitiesnoconv(
"Home"), $langs->transnoentitiesnoconv(
"Users"));
1237 print $langs->trans(
"ErrorForbidden4");
1239 print $langs->trans(
"ErrorForbidden3");
1243 if ($printfooter && function_exists(
"llxFooter")) {
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.