429function restrictedArea(
User $user, $features,
$object = 0, $tableandshare =
'', $feature2 =
'', $dbt_keyfield =
'fk_soc', $dbt_select =
'rowid', $isdraft = 0, $mode = 0)
439 if ($objectid ==
"-1") {
443 $objectid = preg_replace(
'/[^0-9\.\,]/',
'', (
string) $objectid);
452 $parentfortableentity =
'';
456 $originalfeatures = $features;
457 if ($features ==
'agenda') {
458 $tableandshare =
'actioncomm&societe';
459 $feature2 =
'myactions|allactions';
462 if ($features ==
'bank') {
463 $features =
'banque';
465 if ($features ==
'facturerec') {
466 $features =
'facture';
468 if ($features ==
'supplier_invoicerec') {
469 $features =
'fournisseur';
470 $feature2 =
'facture';
472 if ($features ==
'mo') {
475 if ($features ==
'member') {
476 $features =
'adherent';
478 if ($features ==
'subscription') {
479 $features =
'adherent';
480 $feature2 =
'cotisation';
482 if ($features ==
'website' && is_object(
$object) &&
$object->element ==
'websitepage') {
483 $parentfortableentity =
'fk_website@website';
485 if ($features ==
'project') {
486 $features =
'projet';
488 if ($features ==
'product') {
489 $features =
'produit';
491 if ($features ==
'productbatch') {
492 $features =
'produit';
494 if ($features ==
'tax') {
495 $feature2 =
'charges';
497 if ($features ==
'workstation') {
498 $feature2 =
'workstation';
500 if ($features ==
'fournisseur') {
501 $features =
'fournisseur';
502 if (is_object(
$object) &&
$object->element ==
'invoice_supplier') {
503 $feature2 =
'facture';
504 } elseif (is_object(
$object) &&
$object->element ==
'order_supplier') {
505 $feature2 =
'commande';
508 if ($features ==
'payment_sc') {
509 $tableandshare =
'paiementcharge';
510 $parentfortableentity =
'fk_charge@chargesociales';
515 if (in_array($features, [
'commandedet',
'propaldet',
'facturedet',
'supplier_proposaldet',
'evaluationdet',
'skilldet',
'deliverydet',
'contratdet'])) {
516 $features = substr($features, 0, -3);
517 } elseif (in_array($features, [
'stocktransferline',
'inventoryline',
'bomline',
'expensereport_det',
'facture_fourn_det'])) {
518 $features = substr($features, 0, -4);
519 } elseif ($features ==
'commandefournisseurdispatch') {
520 $features =
'commandefournisseur';
521 } elseif ($features ==
'invoice_supplier_det_rec') {
522 $features =
'invoice_supplier_rec';
524 if ($features ==
'evaluation') {
526 $feature2 =
'evaluation';
540 $parameters = array(
'features' => $features,
'originalfeatures' => $originalfeatures,
'objectid' => $objectid,
'dbt_select' => $dbt_select,
'idtype' => $dbt_select,
'isdraft' => $isdraft);
541 if (!empty($hookmanager)) {
542 $reshook = $hookmanager->executeHooks(
'restrictedArea', $parameters);
544 if (isset($hookmanager->resArray[
'result'])) {
545 if ($hookmanager->resArray[
'result'] == 0) {
559 $featuresarray = array($features);
560 if (preg_match(
'/&/', $features)) {
561 $featuresarray = explode(
"&", $features);
562 } elseif (preg_match(
'/\|/', $features)) {
563 $featuresarray = explode(
"|", $features);
567 if (!empty($feature2)) {
568 $feature2 = explode(
"|", $feature2);
576 foreach ($featuresarray as $feature) {
577 $featureforlistofmodule = $feature;
578 if ($featureforlistofmodule ==
'produit') {
579 $featureforlistofmodule =
'product';
581 if ($featureforlistofmodule ==
'supplier_proposal') {
582 $featureforlistofmodule =
'supplierproposal';
584 if (!empty($user->socid) &&
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL') && !in_array($featureforlistofmodule, $listofmodules)) {
590 if ($feature ==
'societe' && (empty($feature2) || !in_array(
'contact', $feature2))) {
591 if (!$user->hasRight(
'societe',
'lire') && !$user->hasRight(
'fournisseur',
'lire')) {
595 } elseif (($feature ==
'societe' && (!empty($feature2) && in_array(
'contact', $feature2))) || $feature ==
'contact') {
596 if (!$user->hasRight(
'societe',
'contact',
'lire')) {
600 } elseif ($feature ==
'produit|service') {
601 if (!$user->hasRight(
'produit',
'lire') && !$user->hasRight(
'service',
'lire')) {
605 } elseif ($feature ==
'prelevement') {
606 if (!$user->hasRight(
'prelevement',
'bons',
'lire')) {
610 } elseif ($feature ==
'cheque') {
611 if (!$user->hasRight(
'banque',
'cheque')) {
615 } elseif ($feature ==
'projet') {
616 if (!$user->hasRight(
'projet',
'lire') && !$user->hasRight(
'projet',
'all',
'lire')) {
620 } elseif ($feature ==
'payment') {
621 if (!$user->hasRight(
'facture',
'lire')) {
625 } elseif ($feature ==
'payment_supplier') {
626 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
630 } elseif ($feature ==
'payment_sc') {
631 if (!$user->hasRight(
'tax',
'charges',
'lire')) {
635 } elseif (!empty($feature2)) {
637 foreach ($feature2 as $subfeature) {
638 if ($subfeature ==
'user' && $user->id == $objectid) {
641 if ($subfeature ==
'fiscalyear' && $user->hasRight(
'accounting',
'fiscalyear',
'write')) {
646 if (!empty($subfeature) && !$user->hasRight($feature, $subfeature,
'lire') && !$user->hasRight($feature, $subfeature,
'read')) {
648 } elseif (empty($subfeature) && !$user->hasRight($feature,
'lire') && !$user->hasRight($feature,
'read')) {
659 } elseif (!empty($feature) && ($feature !=
'user' && $feature !=
'usergroup')) {
660 if (!$user->hasRight($feature,
'lire')
661 && !$user->hasRight($feature,
'read')
662 && !$user->hasRight($feature,
'run')) {
670 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
686 $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));
687 $wemustcheckpermissionfordeletedraft = ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete');
689 if ($wemustcheckpermissionforcreate || $wemustcheckpermissionfordeletedraft) {
690 foreach ($featuresarray as $feature) {
691 if ($feature ==
'contact') {
692 if (!$user->hasRight(
'societe',
'contact',
'creer')) {
696 } elseif ($feature ==
'produit|service') {
697 if (!$user->hasRight(
'produit',
'creer') && !$user->hasRight(
'service',
'creer')) {
701 } elseif ($feature ==
'prelevement') {
702 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
706 } elseif ($feature ==
'commande_fournisseur') {
707 if (!$user->hasRight(
'fournisseur',
'commande',
'creer') || !$user->hasRight(
'supplier_order',
'creer')) {
711 } elseif ($feature ==
'banque') {
712 if (!$user->hasRight(
'banque',
'modifier')) {
716 } elseif ($feature ==
'cheque') {
717 if (!$user->hasRight(
'banque',
'cheque')) {
721 } elseif ($feature ==
'import') {
722 if (!$user->hasRight(
'import',
'run')) {
726 } elseif ($feature ==
'ecm') {
727 if (!$user->hasRight(
'ecm',
'upload')) {
731 } elseif ($feature ==
'modulebuilder') {
732 if (!$user->hasRight(
'modulebuilder',
'run')) {
736 } elseif (!empty($feature2)) {
737 foreach ($feature2 as $subfeature) {
738 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'creer')) {
741 if ($subfeature ==
'user' && $user->id == $objectid && $user->hasRight(
'user',
'self',
'password')) {
744 if ($subfeature ==
'user' && $user->id != $objectid && $user->hasRight(
'user',
'user',
'password')) {
748 if (!$user->hasRight($feature, $subfeature,
'creer')
749 && !$user->hasRight($feature, $subfeature,
'write')
750 && !$user->hasRight($feature, $subfeature,
'create')) {
759 } elseif (!empty($feature)) {
761 if (!$user->hasRight($feature,
'creer')
762 && !$user->hasRight($feature,
'write')
763 && !$user->hasRight($feature,
'create')) {
771 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
775 if ($wemustcheckpermissionforcreate && !$createok) {
787 if (
GETPOST(
'action',
'aZ09') ==
'confirm_create_user' &&
GETPOST(
"confirm",
'aZ09') ==
'yes') {
788 if (!$user->hasRight(
'user',
'user',
'creer')) {
792 if (!$createuserok) {
805 if ((
GETPOST(
"action",
"aZ09") ==
'confirm_delete' &&
GETPOST(
"confirm",
"aZ09") ==
'yes') ||
GETPOST(
"action",
"aZ09") ==
'delete') {
806 foreach ($featuresarray as $feature) {
807 if ($feature ==
'bookmark') {
808 if (!$user->hasRight(
'bookmark',
'supprimer')) {
809 if ($user->id !=
$object->fk_user || !$user->hasRight(
'bookmark',
'creer')) {
813 } elseif ($feature ==
'contact') {
814 if (!$user->hasRight(
'societe',
'contact',
'supprimer')) {
817 } elseif ($feature ==
'produit|service') {
818 if (!$user->hasRight(
'produit',
'supprimer') && !$user->hasRight(
'service',
'supprimer')) {
821 } elseif ($feature ==
'commande_fournisseur') {
822 if (!$user->hasRight(
'fournisseur',
'commande',
'supprimer')) {
825 } elseif ($feature ==
'payment_supplier') {
826 if (!$user->hasRight(
'fournisseur',
'facture',
'creer')) {
829 } elseif ($feature ==
'payment') {
830 if (!$user->hasRight(
'facture',
'paiement')) {
833 } elseif ($feature ==
'payment_sc') {
834 if (!$user->hasRight(
'tax',
'charges',
'creer')) {
837 } elseif ($feature ==
'banque') {
838 if (!$user->hasRight(
'banque',
'modifier')) {
841 } elseif ($feature ==
'cheque') {
842 if (!$user->hasRight(
'banque',
'cheque')) {
845 } elseif ($feature ==
'ecm') {
846 if (!$user->hasRight(
'ecm',
'upload')) {
849 } elseif ($feature ==
'ftp') {
850 if (!$user->hasRight(
'ftp',
'write')) {
853 } elseif ($feature ==
'salaries') {
854 if (!$user->hasRight(
'salaries',
'delete')) {
857 } elseif ($feature ==
'adherent') {
858 if (!$user->hasRight(
'adherent',
'supprimer')) {
861 } elseif ($feature ==
'paymentbybanktransfer') {
862 if (!$user->hasRight(
'paymentbybanktransfer',
'create')) {
865 } elseif ($feature ==
'prelevement') {
866 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
869 } elseif (!empty($feature2)) {
870 foreach ($feature2 as $subfeature) {
871 if (!$user->hasRight($feature, $subfeature,
'supprimer') && !$user->hasRight($feature, $subfeature,
'delete')) {
878 } elseif (!empty($feature)) {
880 if (!$user->hasRight($feature,
'supprimer')
881 && !$user->hasRight($feature,
'delete')
882 && !$user->hasRight($feature,
'run')) {
889 if (preg_match(
'/\|/', $features) && $nbko < count($featuresarray)) {
893 if (!$deleteok && !($isdraft && $createok)) {
905 if (!empty($objectid) && $objectid > 0) {
907 $params = array(
'objectid' => $objectid,
'features' => implode(
',', $featuresarray),
'features2' => $feature2);
938function checkUserAccessToObject($user, array $featuresarray,
$object = 0, $tableandshare =
'', $feature2 =
'', $dbt_keyfield =
'', $dbt_select =
'rowid', $parenttableforentity =
'')
947 $objectid = preg_replace(
'/[^0-9\.\,]/',
'', $objectid);
954 $params = explode(
'&', $tableandshare);
955 $dbtablename = (!empty($params[0]) ? $params[0] :
'');
956 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
958 foreach ($featuresarray as $feature) {
964 if ($feature ==
'societe' && !empty($feature2) && is_array($feature2) && in_array(
'contact', $feature2)) {
965 $feature =
'contact';
968 if ($feature ==
'member') {
969 $feature =
'adherent';
971 if ($feature ==
'project') {
974 if ($feature ==
'projet' && !empty($feature2) && is_array($feature2) && !empty(array_intersect(array(
'project_task',
'projet_task'), $feature2))) {
975 $feature =
'project_task';
977 if ($feature ==
'task' || $feature ==
'projet_task') {
978 $feature =
'project_task';
980 if ($feature ==
'eventorganization') {
982 $dbtablename =
'actioncomm';
984 if ($feature ==
'payment_sc' && empty($parenttableforentity)) {
986 $parenttableforentity =
'';
987 $dbtablename =
"chargesociales";
988 $feature =
"chargesociales";
989 $objectid =
$object->fk_charge;
992 $checkonentitydone = 0;
995 $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');
996 $checksoc = array(
'societe');
997 $checkparentsoc = array(
'agenda',
'contact',
'contrat');
998 $checkproject = array(
'projet',
'project');
999 $checktask = array(
'projet_task',
'project_task');
1000 $checkhierarchy = array(
'expensereport',
'holiday',
'hrm');
1001 $checkuser = array(
'bookmark');
1002 $nocheck = array(
'barcode');
1007 if (empty($dbtablename)) {
1008 $dbtablename = $feature;
1009 $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
1013 if ($dbt_select !=
'rowid' && $dbt_select !=
'id') {
1014 $objectid =
"'".$objectid.
"'";
1017 if (in_array($feature, $check) && $objectid > 0) {
1018 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1019 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1020 if (($feature ==
'user' || $feature ==
'usergroup') && isModEnabled(
'multicompany')) {
1022 if (
$conf->entity == 1 && $user->admin && !$user->entity) {
1023 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1024 $sql .=
" AND dbt.entity IS NOT NULL";
1026 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
1027 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1028 $sql .=
" AND ((ug.fk_user = dbt.rowid";
1029 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
1030 $sql .=
" OR dbt.entity = 0)";
1033 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1034 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1038 if ($parenttableforentity && preg_match(
'/(.*)@(.*)/', $parenttableforentity, $reg)) {
1039 $sql .=
", ".MAIN_DB_PREFIX.$reg[2].
" as dbtp";
1040 $sql .=
" WHERE dbt.".$reg[1].
" = dbtp.rowid AND dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1041 $sql .=
" AND dbtp.entity IN (".getEntity($sharedelement, 1).
")";
1043 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1044 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1047 $checkonentitydone = 1;
1049 if (in_array($feature, $checksoc) && $objectid > 0) {
1051 if ($user->socid > 0) {
1052 if ($user->socid != $objectid) {
1055 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
1057 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
1058 $sql .=
" FROM (".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1059 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s)";
1060 $sql .=
" WHERE sc.fk_soc IN (".$db->sanitize($objectid, 1).
")";
1061 $sql .=
" AND (sc.fk_user = ".((int) $user->id);
1063 $userschilds = $user->getAllChildIds();
1064 if (!empty($userschilds)) $sql .=
" OR sc.fk_user IN (".$db->sanitize(implode(
',', $userschilds)).
")";
1067 $sql .=
" AND sc.fk_soc = s.rowid";
1068 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
1069 } elseif (isModEnabled(
'multicompany')) {
1071 $sql =
"SELECT COUNT(s.rowid) as nb";
1072 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
1073 $sql .=
" WHERE s.rowid IN (".$db->sanitize($objectid, 1).
")";
1074 $sql .=
" AND s.entity IN (".getEntity($sharedelement, 1).
")";
1077 $checkonentitydone = 1;
1079 if (in_array($feature, $checkparentsoc) && $objectid > 0) {
1081 if ($user->socid > 0) {
1082 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1083 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1084 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1085 $sql .=
" AND dbt.fk_soc = ".((int) $user->socid);
1086 } elseif (isModEnabled(
"societe") && ($user->hasRight(
'societe',
'lire') && !$user->hasRight(
'societe',
'client',
'voir'))) {
1088 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1089 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1090 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1091 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1092 $sql .=
" AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)";
1093 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1094 } elseif (isModEnabled(
'multicompany')) {
1096 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1097 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1098 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1099 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1102 $checkonentitydone = 1;
1104 if (in_array($feature, $checkproject) && $objectid > 0) {
1105 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1106 $projectid = $objectid;
1108 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1109 $projectstatic =
new Project($db);
1110 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1112 $tmparray = explode(
',', $tmps);
1113 if (!in_array($projectid, $tmparray)) {
1117 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1118 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1119 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1120 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1122 $checkonentitydone = 1;
1124 if (in_array($feature, $checktask) && $objectid > 0) {
1125 if (isModEnabled(
'project') && !$user->hasRight(
'projet',
'all',
'lire')) {
1126 $task =
new Task($db);
1127 $task->fetch($objectid);
1128 $projectid = $task->fk_project;
1130 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1131 $projectstatic =
new Project($db);
1132 $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
1134 $tmparray = explode(
',', $tmps);
1135 if (!in_array($projectid, $tmparray)) {
1139 $sharedelement =
'project';
1140 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1141 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1142 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1143 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1146 $checkonentitydone = 1;
1150 if (!$checkonentitydone && !in_array($feature, $nocheck) && $objectid > 0) {
1152 if ($user->socid > 0) {
1153 if (empty($dbt_keyfield)) {
1154 dol_print_error(
null,
'Param dbt_keyfield is required but not defined');
1156 $sql =
"SELECT COUNT(dbt.".$dbt_keyfield.
") as nb";
1157 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1158 $sql .=
" WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).
")";
1159 $sql .=
" AND dbt.".$dbt_keyfield.
" = ".((int) $user->socid);
1160 } elseif (isModEnabled(
"societe") && !$user->hasRight(
'societe',
'client',
'voir')) {
1162 if ($feature !=
'ticket') {
1163 if (empty($dbt_keyfield)) {
1164 dol_print_error(
null,
'Param dbt_keyfield is required but not defined');
1166 $sql =
"SELECT COUNT(sc.fk_soc) as nb";
1167 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1168 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1169 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1170 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1171 $sql .=
" AND sc.fk_soc = dbt.".$dbt_keyfield;
1172 $sql .=
" AND (sc.fk_user = ".((int) $user->id);
1174 $userschilds = $user->getAllChildIds();
1175 if (!empty($userschilds)) $sql .=
" OR sc.fk_user IN (".$db->sanitize(implode(
',', $userschilds)).
")";
1180 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1181 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1182 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe_commerciaux as sc ON sc.fk_soc = dbt.".$dbt_keyfield.
" AND sc.fk_user = ".((int) $user->id);
1183 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1184 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1185 $sql .=
" AND (sc.fk_user = ".((int) $user->id).
" OR sc.fk_user IS NULL)";
1187 } elseif (isModEnabled(
'multicompany')) {
1189 $sql =
"SELECT COUNT(dbt.".$dbt_select.
") as nb";
1190 $sql .=
" FROM ".MAIN_DB_PREFIX.$dbtablename.
" as dbt";
1191 $sql .=
" WHERE dbt.".$dbt_select.
" IN (".$db->sanitize($objectid, 1).
")";
1192 $sql .=
" AND dbt.entity IN (".getEntity($sharedelement, 1).
")";
1197 if ($feature ===
'agenda' && $objectid > 0) {
1199 if ($objectid > 0 && !$user->hasRight(
'agenda',
'allactions',
'read')) {
1200 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
1202 $action->fetch($objectid);
1203 if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
1211 if (in_array($feature, $checkhierarchy) && is_object(
$object) && $objectid > 0) {
1212 $childids = $user->getAllChildIds(1);
1214 if ($feature ==
'holiday') {
1215 $useridtocheck =
$object->fk_user;
1216 if (!$user->hasRight(
'holiday',
'readall') && !in_array($useridtocheck, $childids) && !in_array(
$object->fk_validator, $childids)) {
1220 if ($feature ==
'expensereport') {
1221 $useridtocheck =
$object->fk_user_author;
1222 if (!$user->hasRight(
'expensereport',
'readall')) {
1223 if (!in_array($useridtocheck, $childids)) {
1228 if ($feature ==
'hrm' && in_array(
'evaluation', $feature2)) {
1229 $useridtocheck =
$object->fk_user;
1231 if ($user->hasRight(
'hrm',
'evaluation',
'readall')) {
1235 if (!$user->hasRight(
'hrm',
'evaluation',
'read')) {
1240 return in_array($useridtocheck, $childids);
1246 if (in_array($feature, $checkuser) && is_object(
$object) && $objectid > 0) {
1247 $useridtocheck =
$object->fk_user;
1248 if (!empty($useridtocheck) && $useridtocheck > 0 && $useridtocheck != $user->id && empty($user->admin)) {
1254 $resql = $db->query($sql);
1256 $obj = $db->fetch_object($resql);
1257 if (!$obj || $obj->nb < count(explode(
',', $objectid))) {
1261 dol_syslog(
"Bad forged sql in checkUserAccessToObject", LOG_WARNING);
1309function accessforbidden($message =
'', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params =
null)
1311 global
$conf, $db, $user, $langs, $hookmanager;
1314 if (!is_object($langs)) {
1315 include_once DOL_DOCUMENT_ROOT.
'/core/class/translate.class.php';
1317 $langs->setDefaultLang();
1320 $langs->loadLangs(array(
"main",
"errors"));
1322 if ($printheader && !defined(
'NOHEADERNOFOOTER')) {
1323 if (function_exists(
"llxHeader")) {
1325 } elseif (function_exists(
"llxHeaderVierge")) {
1328 print
'<div style="padding: 20px">';
1330 print
'<div class="error">';
1331 if (empty($message)) {
1332 print $langs->trans(
"ErrorForbidden");
1334 print $langs->trans($message);
1338 if (empty($showonlymessage)) {
1339 if (empty($hookmanager)) {
1340 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1343 $hookmanager->initHooks(array(
'main'));
1346 $parameters = array(
'message' => $message,
'params' => $params);
1347 $reshook = $hookmanager->executeHooks(
'getAccessForbiddenMessage', $parameters,
$object, $action);
1348 print $hookmanager->resPrint;
1349 if (empty($reshook)) {
1350 $langs->loadLangs(array(
"errors"));
1352 print $langs->trans(
"CurrentLogin").
': <span class="error">'.$user->login.
'</span><br>';
1353 print $langs->trans(
"ErrorForbidden2", $langs->transnoentitiesnoconv(
"Home"), $langs->transnoentitiesnoconv(
"Users"));
1354 print $langs->trans(
"ErrorForbidden4");
1356 print $langs->trans(
"ErrorForbidden3");
1360 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.