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';
447 if ($features ==
'evaluation') {
449 $feature2 =
'evaluation';
455 $parameters = array(
'features'=>$features,
'originalfeatures'=>$originalfeatures,
'objectid'=>$objectid,
'dbt_select'=>$dbt_select,
'idtype'=>$dbt_select,
'isdraft'=>$isdraft);
456 if (!empty($hookmanager)) {
457 $reshook = $hookmanager->executeHooks(
'restrictedArea', $parameters);
459 if (isset($hookmanager->resArray[
'result'])) {
460 if ($hookmanager->resArray[
'result'] == 0) {
474 $featuresarray = array($features);
475 if (preg_match(
'/&/', $features)) {
476 $featuresarray = explode(
"&", $features);
477 } elseif (preg_match(
'/\|/', $features)) {
478 $featuresarray = explode(
"|", $features);
482 if (!empty($feature2)) {
483 $feature2 = explode(
"|", $feature2);
491 foreach ($featuresarray as $feature) {
492 $featureforlistofmodule = $feature;
493 if ($featureforlistofmodule ==
'produit') {
494 $featureforlistofmodule =
'product';
496 if ($featureforlistofmodule ==
'supplier_proposal') {
497 $featureforlistofmodule =
'supplierproposal';
499 if (!empty($user->socid) &&
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL') && !in_array($featureforlistofmodule, $listofmodules)) {
505 if ($feature ==
'societe' && (empty($feature2) || !in_array(
'contact', $feature2))) {
506 if (!$user->hasRight(
'societe',
'lire') && !$user->hasRight(
'fournisseur',
'lire')) {
510 } elseif (($feature ==
'societe' && (!empty($feature2) && in_array(
'contact', $feature2))) || $feature ==
'contact') {
511 if (!$user->hasRight(
'societe',
'contact',
'lire')) {
515 } elseif ($feature ==
'produit|service') {
516 if (!$user->hasRight(
'produit',
'lire') && !$user->hasRight(
'service',
'lire')) {
520 } elseif ($feature ==
'prelevement') {
521 if (!$user->hasRight(
'prelevement',
'bons',
'lire')) {
525 } elseif ($feature ==
'cheque') {
526 if (!$user->hasRight(
'banque',
'cheque')) {
530 } elseif ($feature ==
'projet') {
531 if (!$user->hasRight(
'projet',
'lire') && !$user->hasRight(
'projet',
'all',
'lire')) {
535 } elseif ($feature ==
'payment') {
536 if (!$user->hasRight(
'facture',
'lire')) {
540 } elseif ($feature ==
'payment_supplier') {
541 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
545 } elseif ($feature ==
'payment_sc') {
546 if (!$user->hasRight(
'tax',
'charges',
'lire')) {
550 } elseif (!empty($feature2)) {
552 foreach ($feature2 as $subfeature) {
553 if ($subfeature ==
'user' && $user->id == $objectid) {
556 if ($subfeature ==
'fiscalyear' && $user->hasRight(
'accounting',
'fiscalyear',
'write')) {
561 if (!empty($subfeature) && !$user->hasRight($feature, $subfeature,
'lire') && !$user->hasRight($feature, $subfeature,
'read')) {
563 } elseif (empty($subfeature) && !$user->hasRight($feature,
'lire') && !$user->hasRight($feature,
'read')) {
574 } elseif (!empty($feature) && ($feature !=
'user' && $feature !=
'usergroup')) {
575 if (!$user->hasRight($feature,
'lire')
576 && !$user->hasRight($feature,
'read')
577 && !$user->hasRight($feature,
'run')) {
585 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
601 $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));
602 $wemustcheckpermissionfordeletedraft = ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete');
604 if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) {
605 foreach ($featuresarray as $feature) {
606 if ($feature ==
'contact') {
607 if (!$user->hasRight(
'societe',
'contact',
'creer')) {
611 } elseif ($feature ==
'produit|service') {
612 if (!$user->hasRight(
'produit',
'creer') && !$user->hasRight(
'service',
'creer')) {
616 } elseif ($feature ==
'prelevement') {
617 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
621 } elseif ($feature ==
'commande_fournisseur') {
622 if (!$user->hasRight(
'fournisseur',
'commande',
'creer') || !$user->hasRight(
'supplier_order',
'creer')) {
626 } elseif ($feature ==
'banque') {
627 if (!$user->hasRight(
'banque',
'modifier')) {
631 } elseif ($feature ==
'cheque') {
632 if (!$user->hasRight(
'banque',
'cheque')) {
636 } elseif ($feature ==
'import') {
637 if (!$user->hasRight(
'import',
'run')) {
641 } elseif ($feature ==
'ecm') {
642 if (!$user->hasRight(
'ecm',
'upload')) {
646 } elseif ($feature ==
'modulebuilder') {
647 if (!$user->hasRight(
'modulebuilder',
'run')) {
651 } elseif (!empty($feature2)) {
652 foreach ($feature2 as $subfeature) {
653 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'creer')) {
656 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'password')) {
659 if ($subfeature ==
'user' && $user->id != $objectid && $user->hasRight(
'user',
'user',
'password')) {
663 if (!$user->hasRight($feature, $subfeature,
'creer')
664 && !$user->hasRight($feature, $subfeature,
'write')
665 && !$user->hasRight($feature, $subfeature,
'create')) {
674 } elseif (!empty($feature)) {
676 if (!$user->hasRight($feature,
'creer')
677 && !$user->hasRight($feature,
'write')
678 && !$user->hasRight($feature,
'create')) {
686 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
690 if ($wemustcheckpermissionforcreate && !$createok) {
702 if (
GETPOST(
'action',
'aZ09') ==
'confirm_create_user' &&
GETPOST(
"confirm",
'aZ09') ==
'yes') {
703 if (!$user->hasRight(
'user',
'user',
'creer')) {
707 if (!$createuserok) {
720 if ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete') {
721 foreach ($featuresarray as $feature) {
722 if ($feature ==
'bookmark') {
723 if (!$user->hasRight(
'bookmark',
'supprimer')) {
724 if ($user->id != $object->fk_user || !$user->hasRight(
'bookmark',
'creer')) {
728 } elseif ($feature ==
'contact') {
729 if (!$user->hasRight(
'societe',
'contact',
'supprimer')) {
732 } elseif ($feature ==
'produit|service') {
733 if (!$user->hasRight(
'produit',
'supprimer') && !$user->hasRight(
'service',
'supprimer')) {
736 } elseif ($feature ==
'commande_fournisseur') {
737 if (!$user->hasRight(
'fournisseur',
'commande',
'supprimer')) {
740 } elseif ($feature ==
'payment_supplier') {
741 if (!$user->hasRight(
'fournisseur',
'facture',
'creer')) {
744 } elseif ($feature ==
'payment') {
745 if (!$user->hasRight(
'facture',
'paiement')) {
748 } elseif ($feature ==
'payment_sc') {
749 if (!$user->hasRight(
'tax',
'charges',
'creer')) {
752 } elseif ($feature ==
'banque') {
753 if (!$user->hasRight(
'banque',
'modifier')) {
756 } elseif ($feature ==
'cheque') {
757 if (!$user->hasRight(
'banque',
'cheque')) {
760 } elseif ($feature ==
'ecm') {
761 if (!$user->hasRight(
'ecm',
'upload')) {
764 } elseif ($feature ==
'ftp') {
765 if (!$user->hasRight(
'ftp',
'write')) {
768 } elseif ($feature ==
'salaries') {
769 if (!$user->hasRight(
'salaries',
'delete')) {
772 } elseif ($feature ==
'adherent') {
773 if (!$user->hasRight(
'adherent',
'supprimer')) {
776 } elseif ($feature ==
'paymentbybanktransfer') {
777 if (!$user->hasRight(
'paymentbybanktransfer',
'create')) {
780 } elseif ($feature ==
'prelevement') {
781 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
784 } elseif (!empty($feature2)) {
785 foreach ($feature2 as $subfeature) {
786 if (!$user->hasRight($feature, $subfeature,
'supprimer') && !$user->hasRight($feature, $subfeature,
'delete')) {
793 } elseif (!empty($feature)) {
795 if (!$user->hasRight($feature,
'supprimer')
796 && !$user->hasRight($feature,
'delete')
797 && !$user->hasRight($feature,
'run')) {
804 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
808 if (!$deleteok && !($isdraft && $createok)) {
820 if (!empty($objectid) && $objectid > 0) {
821 $ok =
checkUserAccessToObject($user, $featuresarray, $object, $tableandshare, $feature2, $dbt_keyfield, $dbt_select, $parentfortableentity);
822 $params = array(
'objectid' => $objectid,
'features' => join(
',', $featuresarray),
'features2' => $feature2);
853function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tableandshare =
'', $feature2 =
'', $dbt_keyfield =
'', $dbt_select =
'rowid', $parenttableforentity =
'')
857 if (is_object($object)) {
858 $objectid = $object->id;
862 $objectid = preg_replace(
'/[^0-9\.\,]/',
'', $objectid);
869 $params = explode(
'&', $tableandshare);
870 $dbtablename = (!empty($params[0]) ? $params[0] :
'');
871 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
873 foreach ($featuresarray as $feature) {
879 if ($feature ==
'societe' && !empty($feature2) && is_array($feature2) && in_array(
'contact', $feature2)) {
880 $feature =
'contact';
883 if ($feature ==
'member') {
884 $feature =
'adherent';
886 if ($feature ==
'project') {
889 if ($feature ==
'projet' && !empty($feature2) && is_array($feature2) && !empty(array_intersect(array(
'project_task',
'projet_task'), $feature2))) {
890 $feature =
'project_task';
892 if ($feature ==
'task' || $feature ==
'projet_task') {
893 $feature =
'project_task';
895 if ($feature ==
'eventorganization') {
897 $dbtablename =
'actioncomm';
899 if ($feature ==
'payment_sc' && empty($parenttableforentity)) {
901 $parenttableforentity =
'';
902 $dbtablename =
"chargesociales";
903 $feature =
"chargesociales";
904 $objectid = $object->fk_charge;
907 $checkonentitydone = 0;
910 $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');
911 $checksoc = array(
'societe');
912 $checkparentsoc = array(
'agenda',
'contact',
'contrat');
913 $checkproject = array(
'projet',
'project');
914 $checktask = array(
'projet_task',
'project_task');
915 $checkhierarchy = array(
'expensereport',
'holiday',
'hrm');
916 $checkuser = array(
'bookmark');
917 $nocheck = array(
'barcode',
'stock');
922 if (empty($dbtablename)) {
923 $dbtablename = $feature;
924 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
928 if ($dbt_select !=
'rowid' && $dbt_select !=
'id') {
929 $objectid =
"'".$objectid.
"'";
932 if (in_array($feature, $check) && $objectid > 0) {
933 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
934 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
935 if (($feature ==
'user' || $feature ==
'usergroup') && isModEnabled(
'multicompany')) {
937 if ($conf->entity == 1 && $user->admin && !$user->entity) {
938 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
939 $sql .=
" AND dbt.entity IS NOT NULL";
941 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
942 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
943 $sql .=
" AND ((ug.fk_user = dbt.rowid";
944 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
945 $sql .=
" OR dbt.entity = 0)";
948 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
949 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
953 if ($parenttableforentity && preg_match(
'/(.*)@(.*)/', $parenttableforentity, $reg)) {
954 $sql .=
", ".MAIN_DB_PREFIX.$reg[2].
" as dbtp";
955 $sql .=
" WHERE dbt.".$reg[1].
" = dbtp.rowid AND dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
956 $sql .=
" AND dbtp.entity IN (".getEntity($sharedelement, 1).
")";
958 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
959 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
962 $checkonentitydone = 1;
964 if (in_array($feature, $checksoc) && $objectid > 0) {
966 if ($user->socid > 0) {
967 if ($user->socid != $objectid) {
970 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
972 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
973 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
974 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s)";
975 $sql .=
" WHERE sc.fk_soc IN (".$db->sanitize($objectid, 1).
")";
976 $sql .=
" AND sc.fk_user = ".((int) $user->id);
977 $sql .=
" AND sc.fk_soc = s.rowid";
978 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
979 } elseif (isModEnabled(
'multicompany')) {
981 $sql =
"SELECT COUNT(s.rowid) as nb";
982 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
983 $sql .=
" WHERE s.rowid IN (".$db->sanitize($objectid, 1).
")";
984 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
987 $checkonentitydone = 1;
989 if (in_array($feature, $checkparentsoc) && $objectid > 0) {
991 if ($user->socid > 0) {
992 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
993 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
994 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
995 $sql .=
" AND dbt.fk_soc = ".((int) $user->socid);
996 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
998 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
999 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1000 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1001 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1002 $sql .=
" AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)";
1003 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1004 } elseif (isModEnabled(
'multicompany')) {
1006 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1007 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1008 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1009 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1012 $checkonentitydone = 1;
1014 if (in_array($feature, $checkproject) && $objectid > 0) {
1015 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1016 $projectid = $objectid;
1018 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1019 $projectstatic =
new Project($db);
1020 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1022 $tmparray = explode(
',', $tmps);
1023 if (!in_array($projectid, $tmparray)) {
1027 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1028 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1029 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1030 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1032 $checkonentitydone = 1;
1034 if (in_array($feature, $checktask) && $objectid > 0) {
1035 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1036 $task =
new Task($db);
1037 $task->fetch($objectid);
1038 $projectid = $task->fk_project;
1040 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1041 $projectstatic =
new Project($db);
1042 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1044 $tmparray = explode(
',', $tmps);
1045 if (!in_array($projectid, $tmparray)) {
1049 $sharedelement =
'project';
1050 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1051 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1052 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1053 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1056 $checkonentitydone = 1;
1060 if (!$checkonentitydone && !in_array($feature, $nocheck) && $objectid > 0) {
1062 if ($user->socid > 0) {
1063 if (empty($dbt_keyfield)) {
1064 dol_print_error(
'',
'Param dbt_keyfield is required but not defined');
1066 $sql =
"SELECT COUNT(dbt.".$dbt_keyfield.
") as nb";
1067 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1068 $sql .=
" WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).
")";
1069 $sql .=
" AND dbt.".$dbt_keyfield.
" = ".((int) $user->socid);
1070 } elseif (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
1072 if ($feature !=
'ticket') {
1073 if (empty($dbt_keyfield)) {
1074 dol_print_error(
'',
'Param dbt_keyfield is required but not defined');
1076 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
1077 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1078 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1079 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1080 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1081 $sql .=
" AND sc.fk_soc = dbt.".$dbt_keyfield;
1082 $sql .=
" AND sc.fk_user = ".((int) $user->id);
1085 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1086 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1087 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield.
" AND sc.fk_user = ".((int) $user->id);
1088 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1089 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1090 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR sc.fk_user IS NULL)";
1092 } elseif (isModEnabled(
'multicompany')) {
1094 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1095 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1096 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1097 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1102 if ($feature ===
'agenda' && $objectid > 0) {
1104 if ($objectid > 0 && !$user->hasRight(
'agenda',
'allactions',
'read')) {
1105 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1107 $action->fetch($objectid);
1108 if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
1116 if (in_array($feature, $checkhierarchy) && is_object($object) && $objectid > 0) {
1117 $childids = $user->getAllChildIds(1);
1119 if ($feature ==
'holiday') {
1120 $useridtocheck = $object->fk_user;
1121 if (!$user->hasRight(
'holiday',
'readall') && !in_array($useridtocheck, $childids) && !in_array($object->fk_validator, $childids)) {
1125 if ($feature ==
'expensereport') {
1126 $useridtocheck = $object->fk_user_author;
1127 if (!$user->hasRight(
'expensereport',
'readall')) {
1128 if (!in_array($useridtocheck, $childids)) {
1133 if ($feature ==
'hrm' && in_array(
'evaluation', $feature2)) {
1134 $useridtocheck = $object->fk_user;
1136 if ($user->hasRight(
'hrm',
'evaluation',
'readall')) {
1140 if (!$user->hasRight(
'hrm',
'evaluation',
'read')) {
1145 return in_array($useridtocheck, $childids);
1151 if (in_array($feature, $checkuser) && is_object($object) && $objectid > 0) {
1152 $useridtocheck = $object->fk_user;
1153 if (!empty($useridtocheck) && $useridtocheck > 0 && $useridtocheck != $user->id && empty($user->admin)) {
1159 $resql = $db->query($sql);
1161 $obj = $db->fetch_object($resql);
1162 if (!$obj || $obj->nb < count(explode(
',', $objectid))) {
1166 dol_syslog(
"Bad forged sql in checkUserAccessToObject", LOG_WARNING);
1214function accessforbidden($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
1216 global $conf, $db, $user, $langs, $hookmanager;
1217 global $action, $object;
1219 if (!is_object($langs)) {
1220 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
1222 $langs->setDefaultLang();
1225 $langs->loadLangs(array(
"main",
"errors"));
1228 if (function_exists(
"llxHeader")) {
1230 } elseif (function_exists(
"llxHeaderVierge")) {
1233 print
'<div style="padding: 20px">';
1235 print
'<div class="error">';
1236 if (empty($message)) {
1237 print $langs->trans(
"ErrorForbidden");
1239 print $langs->trans($message);
1243 if (empty($showonlymessage)) {
1244 if (empty($hookmanager)) {
1245 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1248 $hookmanager->initHooks(array(
'main'));
1251 $parameters = array(
'message'=>$message,
'params'=>$params);
1252 $reshook = $hookmanager->executeHooks(
'getAccessForbiddenMessage', $parameters, $object, $action);
1253 print $hookmanager->resPrint;
1254 if (empty($reshook)) {
1255 $langs->loadLangs(array(
"errors"));
1257 print $langs->trans(
"CurrentLogin").
': <span class="error">'.$user->login.
'</span><br>';
1258 print $langs->trans(
"ErrorForbidden2", $langs->transnoentitiesnoconv(
"Home"), $langs->transnoentitiesnoconv(
"Users"));
1259 print $langs->trans(
"ErrorForbidden4");
1261 print $langs->trans(
"ErrorForbidden3");
1265 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.