dolibarr 18.0.8
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
42$id = GETPOST('id', 'aZ09');
43$objecttype = GETPOST('objecttype', 'aZ09arobase'); // 'module' or 'myobject@mymodule', 'mymodule_myobject'
44
45$params = array('fromajaxtooltip' => 1);
46if (GETPOSTISSET('infologin')) {
47 $params['infologin'] = GETPOST('infologin', 'int');
48}
49if (GETPOSTISSET('option')) {
50 $params['option'] = GETPOST('option', 'restricthtml');
51}
52
53// Load object according to $element
54$object = fetchObjectByElement($id, $objecttype);
55if (empty($object->element)) {
56 httponly_accessforbidden('Failed to get object with fetchObjectByElement(id='.$id.', objecttype='.$objecttype.')');
57}
58
59$module = $object->module;
60$element = $object->element;
61
62$usesublevelpermission = ($module != $element ? $element : '');
63$exclude = array('projet_task', 'project_task'); // for user rights compatibility
64if ($usesublevelpermission) {
65 if (!in_array($usesublevelpermission, $exclude)) {
66 if (!isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
67 $usesublevelpermission = '';
68 }
69 } elseif (!isset($user->rights->$module)) {
70 $usesublevelpermission = '';
71 }
72}
73
74//print $object->id.' - '.$object->module.' - '.$object->element.' - '.$object->table_element.' - '.$usesublevelpermission."\n";
75
76// Security check
77restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission);
78
79
80/*
81 * View
82 */
83
85
86$html = '';
87
88if (is_object($object)) {
89 if ($object->id > 0 || !empty($object->ref)) {
91 $html = $object->getTooltipContent($params);
92 } elseif ($res == 0) {
93 $html = $langs->trans('Deleted');
94 }
95 unset($object);
96}
97
98print $html;
99
100$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.