dolibarr 20.0.5
note.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
30
31// Get parameters
32$id = GETPOSTINT('id');
33$action = GETPOST('action', 'aZ09');
34$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
35
36if (!isset($id) || empty($id)) {
38}
39
40// Load translation files required by page
41$langs->loadLangs(array('companies', 'members', 'bills', 'users'));
42
43$object = new User($db);
44$object->fetch($id, '', '', 1);
45$object->getrights();
46
47// If user is not user read and no permission to read other users, we stop
48if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
50}
51
52// Permissions
53// Writing notes on own record needs the "self" write right, writing on another user's record needs the "user" write right.
54// Without this distinction a user holding only "self" write could edit the notes of any user, including admins.
55$permissionnote = ((($object->id == $user->id) && $user->hasRight("user", "self", "write")) || (($object->id != $user->id) && $user->hasRight("user", "user", "write"))); // Used by the include of actions_setnotes.inc.php
56
57// Security check
58$socid = 0;
59if ($user->socid > 0) {
60 $socid = $user->socid;
61}
62$feature2 = (($socid && $user->hasRight("user", "self", "write")) ? '' : 'user');
63
64$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
65
66// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
67$hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
68
69
70/*
71 * Actions
72 */
73$parameters = array('id'=>$socid);
74$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
75if ($reshook < 0) {
76 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
77}
78if (empty($reshook)) {
79 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
80}
81
82
83/*
84 * View
85 */
86
87llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-user page-card_note');
88
89$form = new Form($db);
90
91if ($id) {
92 $head = user_prepare_head($object);
93
94 $title = $langs->trans("User");
95 print dol_get_fiche_head($head, 'note', $title, -1, 'user');
96
97 $linkback = '';
98
99 if ($user->hasRight("user", "user", "read") || $user->admin) {
100 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
101 }
102
103 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid" rel="noopener">';
104 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
105 $morehtmlref .= '</a>';
106
107 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
108 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
109
110 dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref);
111
112 print '<div class="underbanner clearboth"></div>';
113
114 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
115 print '<input type="hidden" name="token" value="'.newToken().'">';
116
117 print '<div class="fichecenter">';
118 print '<table class="border centpercent tableforfield">';
119
120 // Login
121 print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
122 if (!empty($object->ldap_sid) && $object->statut == 0) {
123 print '<td class="error">';
124 print $langs->trans("LoginAccountDisableInDolibarr");
125 print '</td>';
126 } else {
127 print '<td>';
128 $addadmin = '';
129 if (property_exists($object, 'admin')) {
130 if (isModEnabled('multicompany') && !empty($object->admin) && empty($object->entity)) {
131 $addadmin .= img_picto($langs->trans("SuperAdministratorDesc"), "redstar", 'class="paddingleft"');
132 } elseif (!empty($object->admin)) {
133 $addadmin .= img_picto($langs->trans("AdministratorDesc"), "star", 'class="paddingleft"');
134 }
135 }
136 print showValueWithClipboardCPButton($object->login).$addadmin;
137 print '</td>';
138 }
139 print '</tr>';
140
141 print "</table>";
142
143 print '</div>';
144
145
146 //print '<br>';
147
148 //print '<div class="underbanner clearboth"></div>';
149 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
150
151 print dol_get_fiche_end();
152} else {
153 $langs->load("errors");
154 print $langs->trans("ErrorRecordNotFound");
155}
156
157// End of page
158llxFooter();
159$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
user_prepare_head(User $object)
Prepare array with list of tabs.