actions_setnotes.inc.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /* Copyright (C) 2014 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 <http://www.gnu.org/licenses/>.
  16. * or see http://www.gnu.org/
  17. */
  18. /**
  19. * \file htdocs/core/actions_setnotes.inc.php
  20. * \brief Code for actions on setting notes of object page
  21. */
  22. // $action must be defined
  23. // $permissionnote must be defined to permission to edit object
  24. // $object must be defined (object is loaded in this file with fetch)
  25. // $id must be defined (object is loaded in this file with fetch)
  26. // Set public note
  27. if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel'))
  28. {
  29. if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
  30. if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
  31. $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public');
  32. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  33. }
  34. // Set public note
  35. else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel'))
  36. {
  37. if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
  38. if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
  39. $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private');
  40. if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
  41. }