dolibarr  13.0.2
objectonoff.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <https://www.gnu.org/licenses/>.
15  */
16 
23 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
24 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
25 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
26 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
27 if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
28 if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
29 
30 require '../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
32 
33 $action = GETPOST('action', 'aZ09');
34 $id = GETPOST('id', 'int');
35 $value = GETPOST('value', 'int');
36 $field = GETPOST('field', 'alpha');
37 $element = GETPOST('element', 'alpha');
38 
39 $object = new GenericObject($db);
40 
41 // Security check
42 if (!empty($user->socid)) {
43  $socid = $user->socid;
44 }
45 
46 /*if (empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
47  accessforbidden('Calling this file is allowed only when MAIN_DIRECT_STATUS_UPDATE is set');
48 }*/
49 
50 
51 /*
52  * View
53  */
54 
55 top_httphead();
56 
57 print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
58 
59 if (in_array($field, array('status'))) {
60  $result = restrictedArea($user, $element, $id);
61 } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products
62  $result = restrictedArea($user, 'produit|service', $id, 'product&product', '', '', 'rowid');
63 } else {
64  accessforbidden("Bad value for combination of parameters element/field.", 0, 0, 1);
65  exit;
66 }
67 
68 // Registering new values
69 if (($action == 'set') && !empty($id)) {
70  $triggerkey = strtoupper($element).'_UPDATE';
71  // Special case
72  if ($triggerkey == 'SOCIETE_UPDATE') {
73  $triggerkey = 'COMPANY_UPDATE';
74  }
75 
76  $tablename = $element;
77  if ($tablename == 'websitepage') $tablename = 'website_page';
78 
79  $format = 'int';
80 
81  $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey);
82 }
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(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1214
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
Class of a generic business object.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...