368function restrictedArea(
User $user, $features,
$object = 0, $tableandshare =
'', $feature2 =
'', $dbt_keyfield =
'fk_soc', $dbt_select =
'rowid', $isdraft = 0, $mode = 0)
378 if ($objectid ==
"-1") {
382 $objectid = preg_replace(
'/[^0-9\.\,]/',
'', (
string) $objectid);
391 $parentfortableentity =
'';
394 $originalfeatures = $features;
395 if ($features ==
'agenda') {
396 $tableandshare =
'actioncomm&societe';
397 $feature2 =
'myactions|allactions';
400 if ($features ==
'bank') {
401 $features =
'banque';
403 if ($features ==
'facturerec') {
404 $features =
'facture';
406 if ($features ==
'supplier_invoicerec') {
407 $features =
'fournisseur';
408 $feature2 =
'facture';
410 if ($features ==
'mo') {
413 if ($features ==
'member') {
414 $features =
'adherent';
416 if ($features ==
'subscription') {
417 $features =
'adherent';
418 $feature2 =
'cotisation';
420 if ($features ==
'website' && is_object(
$object) &&
$object->element ==
'websitepage') {
421 $parentfortableentity =
'fk_website@website';
423 if ($features ==
'project') {
424 $features =
'projet';
426 if ($features ==
'product') {
427 $features =
'produit';
429 if ($features ==
'productbatch') {
430 $features =
'produit';
432 if ($features ==
'tax') {
433 $feature2 =
'charges';
435 if ($features ==
'workstation') {
436 $feature2 =
'workstation';
438 if ($features ==
'fournisseur') {
439 $features =
'fournisseur';
440 if (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
441 $feature2 =
'facture';
442 } elseif (is_object(
$object) &&
$object->element ==
'order_supplier') {
443 $feature2 =
'commande';
446 if ($features ==
'payment_sc') {
447 $tableandshare =
'paiementcharge';
448 $parentfortableentity =
'fk_charge@chargesociales';
450 if ($features ==
'evaluation') {
452 $feature2 =
'evaluation';
458 $parameters = array(
'features' => $features,
'originalfeatures' => $originalfeatures,
'objectid' => $objectid,
'dbt_select' => $dbt_select,
'idtype' => $dbt_select,
'isdraft' => $isdraft);
459 if (!empty($hookmanager)) {
460 $reshook = $hookmanager->executeHooks(
'restrictedArea', $parameters);
462 if (isset($hookmanager->resArray[
'result'])) {
463 if ($hookmanager->resArray[
'result'] == 0) {
477 $featuresarray = array($features);
478 if (preg_match(
'/&/', $features)) {
479 $featuresarray = explode(
"&", $features);
480 } elseif (preg_match(
'/\|/', $features)) {
481 $featuresarray = explode(
"|", $features);
485 if (!empty($feature2)) {
486 $feature2 = explode(
"|", $feature2);
494 foreach ($featuresarray as $feature) {
495 $featureforlistofmodule = $feature;
496 if ($featureforlistofmodule ==
'produit') {
497 $featureforlistofmodule =
'product';
499 if ($featureforlistofmodule ==
'supplier_proposal') {
500 $featureforlistofmodule =
'supplierproposal';
502 if (!empty($user->socid) &&
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL') && !in_array($featureforlistofmodule, $listofmodules)) {
508 if ($feature ==
'societe' && (empty($feature2) || !in_array(
'contact', $feature2))) {
509 if (!$user->hasRight(
'societe',
'lire') && !$user->hasRight(
'fournisseur',
'lire')) {
513 } elseif (($feature ==
'societe' && (!empty($feature2) && in_array(
'contact', $feature2))) || $feature ==
'contact') {
514 if (!$user->hasRight(
'societe',
'contact',
'lire')) {
518 } elseif ($feature ==
'produit|service') {
519 if (!$user->hasRight(
'produit',
'lire') && !$user->hasRight(
'service',
'lire')) {
523 } elseif ($feature ==
'prelevement') {
524 if (!$user->hasRight(
'prelevement',
'bons',
'lire')) {
528 } elseif ($feature ==
'cheque') {
529 if (!$user->hasRight(
'banque',
'cheque')) {
533 } elseif ($feature ==
'projet') {
534 if (!$user->hasRight(
'projet',
'lire') && !$user->hasRight(
'projet',
'all',
'lire')) {
538 } elseif ($feature ==
'payment') {
539 if (!$user->hasRight(
'facture',
'lire')) {
543 } elseif ($feature ==
'payment_supplier') {
544 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
548 } elseif ($feature ==
'payment_sc') {
549 if (!$user->hasRight(
'tax',
'charges',
'lire')) {
553 } elseif (!empty($feature2)) {
555 foreach ($feature2 as $subfeature) {
556 if ($subfeature ==
'user' && $user->id == $objectid) {
559 if ($subfeature ==
'fiscalyear' && $user->hasRight(
'accounting',
'fiscalyear',
'write')) {
564 if (!empty($subfeature) && !$user->hasRight($feature, $subfeature,
'lire') && !$user->hasRight($feature, $subfeature,
'read')) {
566 } elseif (empty($subfeature) && !$user->hasRight($feature,
'lire') && !$user->hasRight($feature,
'read')) {
577 } elseif (!empty($feature) && ($feature !=
'user' && $feature !=
'usergroup')) {
578 if (!$user->hasRight($feature,
'lire')
579 && !$user->hasRight($feature,
'read')
580 && !$user->hasRight($feature,
'run')) {
588 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
604 $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));
605 $wemustcheckpermissionfordeletedraft = ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete');
607 if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) {
608 foreach ($featuresarray as $feature) {
609 if ($feature ==
'contact') {
610 if (!$user->hasRight(
'societe',
'contact',
'creer')) {
614 } elseif ($feature ==
'produit|service') {
615 if (!$user->hasRight(
'produit',
'creer') && !$user->hasRight(
'service',
'creer')) {
619 } elseif ($feature ==
'prelevement') {
620 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
624 } elseif ($feature ==
'commande_fournisseur') {
625 if (!$user->hasRight(
'fournisseur',
'commande',
'creer') || !$user->hasRight(
'supplier_order',
'creer')) {
629 } elseif ($feature ==
'banque') {
630 if (!$user->hasRight(
'banque',
'modifier')) {
634 } elseif ($feature ==
'cheque') {
635 if (!$user->hasRight(
'banque',
'cheque')) {
639 } elseif ($feature ==
'import') {
640 if (!$user->hasRight(
'import',
'run')) {
644 } elseif ($feature ==
'ecm') {
645 if (!$user->hasRight(
'ecm',
'upload')) {
649 } elseif ($feature ==
'modulebuilder') {
650 if (!$user->hasRight(
'modulebuilder',
'run')) {
654 } elseif (!empty($feature2)) {
655 foreach ($feature2 as $subfeature) {
656 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'creer')) {
659 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'password')) {
662 if ($subfeature ==
'user' && $user->id != $objectid && $user->hasRight(
'user',
'user',
'password')) {
666 if (!$user->hasRight($feature, $subfeature,
'creer')
667 && !$user->hasRight($feature, $subfeature,
'write')
668 && !$user->hasRight($feature, $subfeature,
'create')) {
677 } elseif (!empty($feature)) {
679 if (!$user->hasRight($feature,
'creer')
680 && !$user->hasRight($feature,
'write')
681 && !$user->hasRight($feature,
'create')) {
689 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
693 if ($wemustcheckpermissionforcreate && !$createok) {
705 if (
GETPOST(
'action',
'aZ09') ==
'confirm_create_user' &&
GETPOST(
"confirm",
'aZ09') ==
'yes') {
706 if (!$user->hasRight(
'user',
'user',
'creer')) {
710 if (!$createuserok) {
723 if ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete') {
724 foreach ($featuresarray as $feature) {
725 if ($feature ==
'bookmark') {
726 if (!$user->hasRight(
'bookmark',
'supprimer')) {
727 if ($user->id !=
$object->fk_user || !$user->hasRight(
'bookmark',
'creer')) {
731 } elseif ($feature ==
'contact') {
732 if (!$user->hasRight(
'societe',
'contact',
'supprimer')) {
735 } elseif ($feature ==
'produit|service') {
736 if (!$user->hasRight(
'produit',
'supprimer') && !$user->hasRight(
'service',
'supprimer')) {
739 } elseif ($feature ==
'commande_fournisseur') {
740 if (!$user->hasRight(
'fournisseur',
'commande',
'supprimer')) {
743 } elseif ($feature ==
'payment_supplier') {
744 if (!$user->hasRight(
'fournisseur',
'facture',
'creer')) {
747 } elseif ($feature ==
'payment') {
748 if (!$user->hasRight(
'facture',
'paiement')) {
751 } elseif ($feature ==
'payment_sc') {
752 if (!$user->hasRight(
'tax',
'charges',
'creer')) {
755 } elseif ($feature ==
'banque') {
756 if (!$user->hasRight(
'banque',
'modifier')) {
759 } elseif ($feature ==
'cheque') {
760 if (!$user->hasRight(
'banque',
'cheque')) {
763 } elseif ($feature ==
'ecm') {
764 if (!$user->hasRight(
'ecm',
'upload')) {
767 } elseif ($feature ==
'ftp') {
768 if (!$user->hasRight(
'ftp',
'write')) {
771 } elseif ($feature ==
'salaries') {
772 if (!$user->hasRight(
'salaries',
'delete')) {
775 } elseif ($feature ==
'adherent') {
776 if (!$user->hasRight(
'adherent',
'supprimer')) {
779 } elseif ($feature ==
'paymentbybanktransfer') {
780 if (!$user->hasRight(
'paymentbybanktransfer',
'create')) {
783 } elseif ($feature ==
'prelevement') {
784 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
787 } elseif (!empty($feature2)) {
788 foreach ($feature2 as $subfeature) {
789 if (!$user->hasRight($feature, $subfeature,
'supprimer') && !$user->hasRight($feature, $subfeature,
'delete')) {
796 } elseif (!empty($feature)) {
798 if (!$user->hasRight($feature,
'supprimer')
799 && !$user->hasRight($feature,
'delete')
800 && !$user->hasRight($feature,
'run')) {
807 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
811 if (!$deleteok && !($isdraft && $createok)) {
823 if (!empty($objectid) && $objectid > 0) {
825 $params = array(
'objectid' => $objectid,
'features' => implode(
',', $featuresarray),
'features2' => $feature2);
856function checkUserAccessToObject($user, array $featuresarray,
$object = 0, $tableandshare =
'', $feature2 =
'', $dbt_keyfield =
'', $dbt_select =
'rowid', $parenttableforentity =
'')
865 $objectid = preg_replace(
'/[^0-9\.\,]/',
'', $objectid);
872 $params = explode(
'&', $tableandshare);
873 $dbtablename = (!empty($params[0]) ? $params[0] :
'');
874 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
876 foreach ($featuresarray as $feature) {
882 if ($feature ==
'societe' && !empty($feature2) && is_array($feature2) && in_array(
'contact', $feature2)) {
883 $feature =
'contact';
886 if ($feature ==
'member') {
887 $feature =
'adherent';
889 if ($feature ==
'category') {
890 $feature =
'categorie';
892 if ($feature ==
'project') {
895 if ($feature ==
'projet' && !empty($feature2) && is_array($feature2) && !empty(array_intersect(array(
'project_task',
'projet_task'), $feature2))) {
896 $feature =
'project_task';
898 if ($feature ==
'task' || $feature ==
'projet_task') {
899 $feature =
'project_task';
901 if ($feature ==
'eventorganization') {
903 $dbtablename =
'actioncomm';
905 if ($feature ==
'payment_sc' && empty($parenttableforentity)) {
907 $parenttableforentity =
'';
908 $dbtablename =
"chargesociales";
909 $feature =
"chargesociales";
910 $objectid =
$object->fk_charge;
913 $checkonentitydone = 0;
916 $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',
'stock');
917 $checksoc = array(
'societe');
918 $checkparentsoc = array(
'agenda',
'contact',
'contrat');
919 $checkproject = array(
'projet',
'project');
920 $checktask = array(
'projet_task',
'project_task');
921 $checkhierarchy = array(
'expensereport',
'holiday',
'hrm');
922 $checkuser = array(
'bookmark');
923 $nocheck = array(
'barcode');
928 if (empty($dbtablename)) {
929 $dbtablename = $feature;
930 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
934 if ($dbt_select !=
'rowid' && $dbt_select !=
'id') {
935 $objectid =
"'".$objectid.
"'";
938 if (in_array($feature, $check) && $objectid > 0) {
939 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
940 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
941 if (($feature ==
'user' || $feature ==
'usergroup') && isModEnabled(
'multicompany')) {
943 if ($conf->entity == 1 && $user->admin && !$user->entity) {
944 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
945 $sql .=
" AND dbt.entity IS NOT NULL";
947 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
948 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
949 $sql .=
" AND ((ug.fk_user = dbt.rowid";
950 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
951 $sql .=
" OR dbt.entity = 0)";
954 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
955 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
959 if ($parenttableforentity && preg_match(
'/(.*)@(.*)/', $parenttableforentity, $reg)) {
960 $sql .=
", ".MAIN_DB_PREFIX.$reg[2].
" as dbtp";
961 $sql .=
" WHERE dbt.".$reg[1].
" = dbtp.rowid AND dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
962 $sql .=
" AND dbtp.entity IN (".getEntity($sharedelement, 1).
")";
964 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
965 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
968 $checkonentitydone = 1;
970 if (in_array($feature, $checksoc) && $objectid > 0) {
972 if ($user->socid > 0) {
973 if ($user->socid != $objectid) {
976 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
978 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
979 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
980 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s)";
981 $sql .=
" WHERE sc.fk_soc IN (".$db->sanitize($objectid, 1).
")";
982 $sql .=
" AND (sc.fk_user = ".((int) $user->id);
984 $userschilds = $user->getAllChildIds();
985 if (!empty($userschilds)) $sql .=
" OR sc.fk_user IN (".$db->sanitize(implode(
',', $userschilds)).
")";
988 $sql .=
" AND sc.fk_soc = s.rowid";
989 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
990 } elseif (isModEnabled(
'multicompany')) {
992 $sql =
"SELECT COUNT(s.rowid) as nb";
993 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
994 $sql .=
" WHERE s.rowid IN (".$db->sanitize($objectid, 1).
")";
995 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
998 $checkonentitydone = 1;
1000 if (in_array($feature, $checkparentsoc) && $objectid > 0) {
1002 if ($user->socid > 0) {
1003 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1004 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1005 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1006 $sql .=
" AND dbt.fk_soc = ".((int) $user->socid);
1007 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
1009 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1010 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1011 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1012 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1013 $sql .=
" AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)";
1014 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1015 } elseif (isModEnabled(
'multicompany')) {
1017 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1018 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1019 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1020 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1023 $checkonentitydone = 1;
1025 if (in_array($feature, $checkproject) && $objectid > 0) {
1026 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1027 $projectid = $objectid;
1029 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1030 $projectstatic =
new Project($db);
1031 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1033 $tmparray = explode(
',', $tmps);
1034 if (!in_array($projectid, $tmparray)) {
1038 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1039 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1040 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1041 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1043 $checkonentitydone = 1;
1045 if (in_array($feature, $checktask) && $objectid > 0) {
1046 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1047 $task =
new Task($db);
1048 $task->fetch($objectid);
1049 $projectid = $task->fk_project;
1051 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1052 $projectstatic =
new Project($db);
1053 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1055 $tmparray = explode(
',', $tmps);
1056 if (!in_array($projectid, $tmparray)) {
1060 $sharedelement =
'project';
1061 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1062 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1063 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1064 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1067 $checkonentitydone = 1;
1071 if (!$checkonentitydone && !in_array($feature, $nocheck) && $objectid > 0) {
1073 if ($user->socid > 0) {
1074 if (empty($dbt_keyfield)) {
1075 dol_print_error(
null,
'Param dbt_keyfield is required but not defined');
1077 $sql =
"SELECT COUNT(dbt.".$dbt_keyfield.
") as nb";
1078 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1079 $sql .=
" WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).
")";
1080 $sql .=
" AND dbt.".$dbt_keyfield.
" = ".((int) $user->socid);
1081 } elseif (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
1083 if ($feature !=
'ticket') {
1084 if (empty($dbt_keyfield)) {
1085 dol_print_error(
null,
'Param dbt_keyfield is required but not defined');
1087 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
1088 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1089 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1090 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1091 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1092 $sql .=
" AND sc.fk_soc = dbt.".$dbt_keyfield;
1093 $sql .=
" AND (sc.fk_user = ".((int) $user->id);
1095 $userschilds = $user->getAllChildIds();
1096 if (!empty($userschilds)) $sql .=
" OR sc.fk_user IN (".$db->sanitize(implode(
',', $userschilds)).
")";
1101 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1102 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1103 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield.
" AND sc.fk_user = ".((int) $user->id);
1104 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1105 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1106 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR sc.fk_user IS NULL)";
1108 } elseif (isModEnabled(
'multicompany')) {
1110 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1111 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1112 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1113 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1118 if ($feature ===
'agenda' && $objectid > 0) {
1120 if ($objectid > 0 && !$user->hasRight(
'agenda',
'allactions',
'read')) {
1121 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1123 $action->fetch($objectid);
1124 if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
1132 if (in_array($feature, $checkhierarchy) && is_object(
$object) && $objectid > 0) {
1133 $childids = $user->getAllChildIds(1);
1135 if ($feature ==
'holiday') {
1136 $useridtocheck =
$object->fk_user;
1137 if (!$user->hasRight(
'holiday',
'readall') && !in_array($useridtocheck, $childids) && !in_array(
$object->fk_validator, $childids)) {
1141 if ($feature ==
'expensereport') {
1142 $useridtocheck =
$object->fk_user_author;
1143 if (!$user->hasRight(
'expensereport',
'readall')) {
1144 if (!in_array($useridtocheck, $childids)) {
1149 if ($feature ==
'hrm' && in_array(
'evaluation', $feature2)) {
1150 $useridtocheck =
$object->fk_user;
1152 if ($user->hasRight(
'hrm',
'evaluation',
'readall')) {
1156 if (!$user->hasRight(
'hrm',
'evaluation',
'read')) {
1161 return in_array($useridtocheck, $childids);
1167 if (in_array($feature, $checkuser) && is_object(
$object) && $objectid > 0) {
1168 $useridtocheck =
$object->fk_user;
1169 if (!empty($useridtocheck) && $useridtocheck > 0 && $useridtocheck != $user->id && empty($user->admin)) {
1175 $resql = $db->query($sql);
1177 $obj = $db->fetch_object($resql);
1178 if (!$obj || $obj->nb < count(explode(
',', $objectid))) {
1182 dol_syslog(
"Bad forged sql in checkUserAccessToObject", LOG_WARNING);
1230function accessforbidden($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
1232 global $conf, $db, $user, $langs, $hookmanager;
1235 if (!is_object($langs)) {
1236 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
1238 $langs->setDefaultLang();
1241 $langs->loadLangs(array(
"main",
"errors"));
1243 if ($printheader && !defined(
'NOHEADERNOFOOTER')) {
1244 if (function_exists(
"llxHeader")) {
1246 } elseif (function_exists(
"llxHeaderVierge")) {
1249 print
'<div style="padding: 20px">';
1251 print
'<div class="error">';
1252 if (empty($message)) {
1253 print $langs->trans(
"ErrorForbidden");
1255 print $langs->trans($message);
1259 if (empty($showonlymessage)) {
1260 if (empty($hookmanager)) {
1261 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1264 $hookmanager->initHooks(array(
'main'));
1267 $parameters = array(
'message' => $message,
'params' => $params);
1268 $reshook = $hookmanager->executeHooks(
'getAccessForbiddenMessage', $parameters,
$object, $action);
1269 print $hookmanager->resPrint;
1270 if (empty($reshook)) {
1271 $langs->loadLangs(array(
"errors"));
1273 print $langs->trans(
"CurrentLogin").
': <span class="error">'.$user->login.
'</span><br>';
1274 print $langs->trans(
"ErrorForbidden2", $langs->transnoentitiesnoconv(
"Home"), $langs->transnoentitiesnoconv(
"Users"));
1275 print $langs->trans(
"ErrorForbidden4");
1277 print $langs->trans(
"ErrorForbidden3");
1281 if ($printfooter && !defined(
'NOHEADERNOFOOTER') && 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.