extraparams.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  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. /**
  18. * \file /htdocs/core/ajax/extraparams.php
  19. * \brief File to make Ajax action on setting extra parameters of elements.
  20. * Called bu bloc_showhide.tpl.php, itself called when MAIN_DISABLE_CONTACTS_TAB or MAIN_DISABLE_NOTES_TAB are set
  21. */
  22. if (!defined('NOTOKENRENEWAL')) {
  23. define('NOTOKENRENEWAL', '1'); // Disables token renewal
  24. }
  25. if (!defined('NOREQUIREMENU')) {
  26. define('NOREQUIREMENU', '1');
  27. }
  28. if (!defined('NOREQUIREHTML')) {
  29. define('NOREQUIREHTML', '1');
  30. }
  31. if (!defined('NOREQUIREAJAX')) {
  32. define('NOREQUIREAJAX', '1');
  33. }
  34. if (!defined('NOREQUIRESOC')) {
  35. define('NOREQUIRESOC', '1');
  36. }
  37. include '../../main.inc.php';
  38. $id = GETPOST('id', 'int');
  39. $element = GETPOST('element', 'aZ09arobase');
  40. $htmlelement = GETPOST('htmlelement', 'alpha');
  41. $type = GETPOST('type', 'alpha');
  42. // Load object according to $id and $element
  43. $object = fetchObjectByElement($id, $element);
  44. $module = $object->module;
  45. $element = $object->element;
  46. $usesublevelpermission = ($module != $element ? $element : '');
  47. if ($usesublevelpermission && !$user->hasRight($module, $element)) { // There is no permission on object defined, we will check permission on module directly
  48. $usesublevelpermission = '';
  49. }
  50. //print $object->id.' - '.$object->module.' - '.$object->element.' - '.$object->table_element.' - '.$usesublevelpermission."\n";
  51. // Security check
  52. $result = restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission, 'fk_soc', 'rowid', 0, 1); // Call with mode return
  53. if (!$result) {
  54. httponly_accessforbidden('Not allowed by restrictArea');
  55. }
  56. /*
  57. * View
  58. */
  59. top_httphead();
  60. print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  61. if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) {
  62. $value = GETPOST('value', 'alpha');
  63. $params = array();
  64. dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG);
  65. if (is_object($object)) {
  66. $params[$htmlelement] = array($type => $value);
  67. $object->extraparams = array_merge($object->extraparams, $params);
  68. $result = $object->setExtraParameters();
  69. }
  70. }