dolibarr 21.0.0-beta
ajaxtooltip.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26if (!defined('NOTOKENRENEWAL')) {
27 define('NOTOKENRENEWAL', 1); // Disables token renewal
28}
29if (!defined('NOREQUIREMENU')) {
30 define('NOREQUIREMENU', '1');
31}
32if (!defined('NOREQUIREHTML')) {
33 define('NOREQUIREHTML', '1');
34}
35if (!defined('NOREQUIREAJAX')) {
36 define('NOREQUIREAJAX', '1');
37}
38if (!defined('NOHEADERNOFOOTER')) {
39 define('NOHEADERNOFOOTER', '1');
40}
41
42include '../../main.inc.php';
43include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
44
53$id = GETPOST('id', 'aZ09');
54$objecttype = GETPOST('objecttype', 'aZ09arobase'); // 'module' or 'myobject@mymodule', 'mymodule_myobject'
55
56$params = array('fromajaxtooltip' => 1);
57if (GETPOSTISSET('infologin')) {
58 $params['infologin'] = GETPOSTINT('infologin');
59}
60if (GETPOSTISSET('option')) {
61 $params['option'] = GETPOST('option', 'restricthtml');
62}
63$element_ref = '';
64if (is_numeric($id)) {
65 $id = (int) $id;
66} else {
67 $element_ref = $id;
68 $id = 0;
69}
70// Load object according to $element
71$object = fetchObjectByElement($id, $objecttype, $element_ref);
72if (empty($object->element)) {
73 httponly_accessforbidden('Failed to get object with fetchObjectByElement(id='.$id.', objecttype='.$objecttype.')');
74}
75
76$module = $object->module;
77$element = $object->element;
78
79$usesublevelpermission = ($module != $element ? $element : '');
80if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
81 $usesublevelpermission = '';
82}
83
84//print $object->id.' - '.$object->module.' - '.$object->element.' - '.$object->table_element.' - '.$usesublevelpermission."\n";
85
86// Security check
87restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission);
88
89
90/*
91 * View
92 */
93
95
96$html = '';
97
98if (is_object($object)) {
99 '@phan-var-force CommonObject $object';
100 if ($object->id > 0 || !empty($object->ref)) {
102 $html = $object->getTooltipContent($params);
103 } elseif ($id > 0) {
104 $html = $langs->trans('Deleted');
105 }
106 unset($object);
107}
108
109print $html;
110
111$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.