25if (!defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL',
'1');
28if (!defined(
'NOREQUIREMENU')) {
29 define(
'NOREQUIREMENU',
'1');
31if (!defined(
'NOREQUIREAJAX')) {
32 define(
'NOREQUIREAJAX',
'1');
34if (!defined(
'NOREQUIRESOC')) {
35 define(
'NOREQUIRESOC',
'1');
39require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
42$field =
GETPOST(
'field',
'alpha');
43$element =
GETPOST(
'element',
'alpha');
44$table_element =
GETPOST(
'table_element',
'alpha');
45$fk_element =
GETPOST(
'fk_element',
'alpha');
49if (is_numeric($fk_element)) {
50 $id = (int) $fk_element;
52 $element_ref = $fk_element;
59$usesublevelpermission = ($module != $element ? $element :
'');
60if ($usesublevelpermission && !$user->hasRight($module, $element)) {
61 $usesublevelpermission =
'';
86if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) {
87 $ext_element =
GETPOST(
'ext_element',
'alpha');
88 $field = substr($field, 8);
89 $type =
GETPOST(
'type',
'alpha');
90 $loadmethod = (
GETPOST(
'loadmethod',
'alpha') ?
GETPOST(
'loadmethod',
'alpha') :
'getValueFrom');
92 if ($element !=
'order_supplier' && $element !=
'invoice_supplier' && preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
94 $subelement = $regs[2];
97 if ($element ==
'propal') {
99 } elseif ($element ==
'fichinter') {
100 $element =
'ficheinter';
101 } elseif ($element ==
'product') {
102 $element =
'produit';
103 } elseif ($element ==
'member') {
104 $element =
'adherent';
105 } elseif ($element ==
'order_supplier') {
106 $element =
'fournisseur';
107 $subelement =
'commande';
108 } elseif ($element ==
'invoice_supplier') {
109 $element =
'fournisseur';
110 $subelement =
'facture';
113 if ($user->hasRight($element,
'lire') || $user->hasRight($element,
'read')
114 || (isset($subelement) && ($user->hasRight($element, $subelement,
'lire') || $user->hasRight($element, $subelement,
'read')))
115 || ($element ==
'payment' && $user->hasRight(
'facture',
'lire'))
116 || ($element ==
'payment_supplier' && $user->hasRight(
'fournisseur',
'facture',
'lire'))) {
117 if ($type ==
'select') {
118 $methodname =
'load_cache_'.$loadmethod;
119 $cachename =
'cache_'.GETPOST(
'loadmethod',
'alpha');
121 $form =
new Form($db);
122 if (method_exists($form, $methodname)) {
123 $ret = $form->$methodname();
125 echo json_encode($form->$cachename);
127 } elseif (!empty($ext_element)) {
128 $module = $subelement = $ext_element;
130 if (preg_match(
'/^([^_]+)_([^_]+)/i', $ext_element, $regs)) {
132 $subelement = $regs[2];
136 $classname =
'Actions'.ucfirst($subelement);
138 '@phan-var-force ActionsMulticompany|ActionsAdherentCardCommon|ActionsContactCardCommon|CommonHookActions|ActionsCardProduct|ActionsCardService|ActionsCardCommon $object';
139 $ret =
$object->$methodname($fk_element);
141 echo json_encode(
$object->$cachename);
146 $value =
$object->$loadmethod($table_element, $fk_element, $field);
150 echo $langs->transnoentities(
'NotEnoughPermissions');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class of a generic business object.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
fetchObjectByElement($element_id, $element_type, $element_ref='', $useCache=0, $maxCacheByType=10)
Fetch an object from its id and element_type Inclusion of classes is automatic.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.