dolibarr 21.0.0-alpha
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
45
46$id = GETPOST('id', 'aZ09');
47$objecttype = GETPOST('objecttype', 'aZ09arobase'); // 'module' or 'myobject@mymodule', 'mymodule_myobject'
48
49$params = array('fromajaxtooltip' => 1);
50if (GETPOSTISSET('infologin')) {
51 $params['infologin'] = GETPOSTINT('infologin');
52}
53if (GETPOSTISSET('option')) {
54 $params['option'] = GETPOST('option', 'restricthtml');
55}
56$element_ref = '';
57if (is_numeric($id)) {
58 $id = (int) $id;
59} else {
60 $element_ref = $id;
61 $id = 0;
62}
63// Load object according to $element
64$object = fetchObjectByElement($id, $objecttype, $element_ref);
65if (empty($object->element)) {
66 httponly_accessforbidden('Failed to get object with fetchObjectByElement(id='.$id.', objecttype='.$objecttype.')');
67}
68
69$module = $object->module;
70$element = $object->element;
71
72$usesublevelpermission = ($module != $element ? $element : '');
73if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
74 $usesublevelpermission = '';
75}
76
77//print $object->id.' - '.$object->module.' - '.$object->element.' - '.$object->table_element.' - '.$usesublevelpermission."\n";
78
79// Security check
80restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission);
81
82
83/*
84 * View
85 */
86
88
89$html = '';
90
91if (is_object($object)) {
92 '@phan-var-force CommonObject $object';
93 if ($object->id > 0 || !empty($object->ref)) {
95 $html = $object->getTooltipContent($params);
96 } elseif ($id > 0) {
97 $html = $langs->trans('Deleted');
98 }
99 unset($object);
100}
101
102print $html;
103
104$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.