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';
50$field =
GETPOST(
'field',
'alpha');
51$element =
GETPOST(
'element',
'alpha');
52$table_element =
GETPOST(
'table_element',
'alpha');
53$fk_element =
GETPOST(
'fk_element',
'alpha');
57if (is_numeric($fk_element)) {
58 $id = (int) $fk_element;
60 $element_ref = $fk_element;
67$usesublevelpermission = ($module != $element ? $element :
'');
68if ($usesublevelpermission && !$user->hasRight($module, $element)) {
69 $usesublevelpermission =
'';
94if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) {
95 $ext_element =
GETPOST(
'ext_element',
'alpha');
96 $field = substr($field, 8);
97 $type =
GETPOST(
'type',
'alpha');
98 $loadmethod = (
GETPOST(
'loadmethod',
'alpha') ?
GETPOST(
'loadmethod',
'alpha') :
'getValueFrom');
100 if ($element !=
'order_supplier' && $element !=
'invoice_supplier' && preg_match(
'/^([^_]+)_([^_]+)/i', $element, $regs)) {
102 $subelement = $regs[2];
105 if ($element ==
'propal') {
106 $element =
'propale';
107 } elseif ($element ==
'fichinter') {
108 $element =
'ficheinter';
109 } elseif ($element ==
'product') {
110 $element =
'produit';
111 } elseif ($element ==
'member') {
112 $element =
'adherent';
113 } elseif ($element ==
'order_supplier') {
114 $element =
'fournisseur';
115 $subelement =
'commande';
116 } elseif ($element ==
'invoice_supplier') {
117 $element =
'fournisseur';
118 $subelement =
'facture';
121 if ($user->hasRight($element,
'lire') || $user->hasRight($element,
'read')
122 || (isset($subelement) && ($user->hasRight($element, $subelement,
'lire') || $user->hasRight($element, $subelement,
'read')))
123 || ($element ==
'payment' && $user->hasRight(
'facture',
'lire'))
124 || ($element ==
'payment_supplier' && $user->hasRight(
'fournisseur',
'facture',
'lire'))) {
125 if ($type ==
'select') {
126 $methodname =
'load_cache_'.$loadmethod;
127 $cachename =
'cache_'.GETPOST(
'loadmethod',
'alpha');
129 $form =
new Form($db);
130 if (method_exists($form, $methodname)) {
131 $ret = $form->$methodname();
133 echo json_encode($form->$cachename);
135 } elseif (!empty($ext_element)) {
136 $module = $subelement = $ext_element;
138 if (preg_match(
'/^([^_]+)_([^_]+)/i', $ext_element, $regs)) {
140 $subelement = $regs[2];
144 $classname =
'Actions'.ucfirst($subelement);
146 '@phan-var-force ActionsMulticompany|ActionsAdherentCardCommon|ActionsContactCardCommon|CommonHookActions|ActionsCardProduct|ActionsCardService|ActionsCardCommon $object';
147 $ret =
$object->$methodname($fk_element);
149 echo json_encode(
$object->$cachename);
154 $value =
$object->$loadmethod($table_element, $fk_element, $field);
158 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.