dolibarr 18.0.6
selectobject.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
23if (!defined('NOTOKENRENEWAL')) {
24 define('NOTOKENRENEWAL', 1); // Disables token renewal
25}
26if (!defined('NOREQUIREMENU')) {
27 define('NOREQUIREMENU', '1');
28}
29if (!defined('NOREQUIREHTML')) {
30 define('NOREQUIREHTML', '1');
31}
32if (!defined('NOREQUIREAJAX')) {
33 define('NOREQUIREAJAX', '1');
34}
35if (!defined('NOREQUIRESOC')) {
36 define('NOREQUIRESOC', '1');
37}
38
39// Load Dolibarr environment
40require '../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
42
43$objectdesc = GETPOST('objectdesc', 'alpha');
44$htmlname = GETPOST('htmlname', 'aZ09');
45$outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
46$id = GETPOST('id', 'int');
47$filter = GETPOST('filter', 'alphanohtml'); // Universal Syntax filter
48
49if (empty($htmlname)) {
50 httponly_accessforbidden('Bad value for param htmlname');
51}
52
53$InfoFieldList = explode(":", $objectdesc);
54$classname = $InfoFieldList[0];
55$classpath = $InfoFieldList[1];
56if (!empty($classpath)) {
57 dol_include_once($classpath);
58 if ($classname && class_exists($classname)) {
59 $objecttmp = new $classname($db);
60 }
61}
62if (!is_object($objecttmp)) {
63 httponly_accessforbidden('Bad value for param objectdesc');
64}
65
66/*
67// Load object according to $id and $element
68$object = fetchObjectByElement($id, $element);
69
70$module = $object->module;
71$element = $object->element;
72$usesublevelpermission = ($module != $element ? $element : '');
73if ($usesublevelpermission && !isset($user->rights->$module->$element)) { // There is no permission on object defined, we will check permission on module directly
74 $usesublevelpermission = '';
75}
76*/
77
78// When used from jQuery, the search term is added as GET param "term".
79$searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : ''));
80
81// Add a security test to avoid to get content of all tables
82if (!empty($objecttmp->module)) {
83 restrictedArea($user, $objecttmp->module, $id, $objecttmp->table_element, $objecttmp->element);
84} else {
85 restrictedArea($user, $objecttmp->element, $id);
86}
87
88
89/*
90 * View
91 */
92
93//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
94//print_r($_GET);
95
96//$langs->load("companies");
97
98$form = new Form($db);
99
100top_httphead($outjson ? 'application/json' : 'text/html');
101
102$arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1, 0, '', $filter);
103
104$db->close();
105
106if ($outjson) {
107 print json_encode($arrayresult);
108}
Class to manage generation of HTML components Only common components must be here.
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.
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.