dolibarr 19.0.3
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-2023 Frédéric France <frederic.france@netlogic.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25if (!defined('NOTOKENRENEWAL')) {
26 define('NOTOKENRENEWAL', 1); // Disables token renewal
27}
28if (!defined('NOREQUIREMENU')) {
29 define('NOREQUIREMENU', '1');
30}
31if (!defined('NOREQUIREHTML')) {
32 define('NOREQUIREHTML', '1');
33}
34if (!defined('NOREQUIREAJAX')) {
35 define('NOREQUIREAJAX', '1');
36}
37include '../../main.inc.php';
38include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
39
40
41$id = GETPOST('id', 'aZ09');
42$objecttype = GETPOST('objecttype', 'aZ09arobase'); // 'module' or 'myobject@mymodule', 'mymodule_myobject'
43
44$params = array('fromajaxtooltip' => 1);
45if (GETPOSTISSET('infologin')) {
46 $params['infologin'] = GETPOST('infologin', 'int');
47}
48if (GETPOSTISSET('option')) {
49 $params['option'] = GETPOST('option', 'restricthtml');
50}
51
52// Load object according to $element
53$object = fetchObjectByElement($id, $objecttype);
54if (empty($object->element)) {
55 httponly_accessforbidden('Failed to get object with fetchObjectByElement(id='.$id.', objecttype='.$objecttype.')');
56}
57
58$module = $object->module;
59$element = $object->element;
60
61$usesublevelpermission = ($module != $element ? $element : '');
62if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
63 $usesublevelpermission = '';
64}
65
66//print $object->id.' - '.$object->module.' - '.$object->element.' - '.$object->table_element.' - '.$usesublevelpermission."\n";
67
68// Security check
69restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission);
70
71
72/*
73 * View
74 */
75
77
78$html = '';
79
80if (is_object($object)) {
81 if ($object->id > 0 || !empty($object->ref)) {
83 $html = $object->getTooltipContent($params);
84 } elseif ($res == 0) {
85 $html = $langs->trans('Deleted');
86 }
87 unset($object);
88}
89
90print $html;
91
92$db->close();
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='')
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.
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.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.