dolibarr  7.0.0-beta
actions_setnotes.inc.php
Go to the documentation of this file.
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 
25 // $action must be defined
26 // $permissionnote must be defined to permission to edit object
27 // $object must be defined (object is loaded in this file with fetch)
28 // $id must be defined (object is loaded in this file with fetch)
29 
30 // Set public note
31 if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel','alpha'))
32 {
33  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');
34  if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
35  $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public');
36  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
37 }
38 // Set public note
39 else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha'))
40 {
41  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');
42  if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
43  $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES),'_private');
44  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
45 }
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_html_entity_decode($a, $b, $c='UTF-8')
Replace html_entity_decode functions to manage errors.