dolibarr 21.0.0-alpha
clicktodial.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2012 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
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
28
29// Load translation files required by page
30$langs->loadLangs(array('users', 'admin'));
31
32$action = (string) GETPOST('action', 'aZ09');
33$cancel = GETPOST('cancel', 'aZ09');
34
35$id = GETPOSTINT('id');
36
37// Security check
38$socid = 0;
39if ($user->socid > 0) {
40 $socid = $user->socid;
41}
42$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
43
44// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
45$hookmanager->initHooks(array('usercard', 'globalcard'));
46
47$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
48
49// Define value to know what current user can do on properties of edited user
50$canedituser = 0;
51if ($id > 0) {
52 // $user is the current logged user, $id is the user we want to edit
53 $canedituser = (($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write"));
54}
55
56
57/*
58 * Actions
59 */
60
61$parameters = array('id'=>$socid);
62$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
63if ($reshook < 0) {
64 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
65}
66
67if (empty($reshook)) {
68 if ($action == 'update' && !$cancel && $canedituser) {
69 $edituser = new User($db);
70 $edituser->fetch($id);
71
72 $edituser->clicktodial_url = (string) GETPOST("url", "alpha");
73 $edituser->clicktodial_login = (string) GETPOST("login", "alpha");
74 $edituser->clicktodial_password = (string) GETPOST("password", "alpha");
75 $edituser->clicktodial_poste = (string) GETPOST("poste", "alpha");
76
77 $result = $edituser->update_clicktodial();
78 if ($result < 0) {
79 setEventMessages($edituser->error, $edituser->errors, 'errors');
80 }
81 }
82}
83
84
85/*
86 * View
87 */
88
89$form = new Form($db);
90
91if ($id > 0) {
92 $object = new User($db);
93 $object->fetch($id, '', '', 1);
94 $object->loadRights();
95 $object->fetch_clicktodial();
96
97 $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
98 $title = $person_name." - ".$langs->trans('ClickToDial');
99 $help_url = '';
100 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-clicktodial');
101
102 $head = user_prepare_head($object);
103
104 $title = $langs->trans("User");
105
106
107 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
108 print '<input type="hidden" name="token" value="'.newToken().'">';
109 print '<input type="hidden" name="action" value="update">';
110
111 print dol_get_fiche_head($head, 'clicktodial', $title, -1, 'user');
112
113 $linkback = '';
114
115 if ($user->hasRight('user', 'user', 'lire') || $user->admin) {
116 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
117 }
118
119 $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">';
120 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
121 $morehtmlref .= '</a>';
122
123 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
124 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
125
126 dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref);
127
128 print '<div class="fichecenter">';
129 print '<div class="underbanner clearboth"></div>';
130
131 // Edit mode
132 if ($action == 'edit') {
133 print '<table class="border centpercent">';
134
135 if ($user->admin) {
136 print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
137 print '<td class="valeur">';
138 print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
139 if (!getDolGlobalString('CLICKTODIAL_URL') && empty($object->clicktodial_url)) {
140 $langs->load("errors");
141 print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
142 } else {
143 print '<br>'.$form->textwithpicto('<span class="opacitymedium">'.$langs->trans("KeepEmptyToUseDefault").'</span>:<br>' . getDolGlobalString('CLICKTODIAL_URL'), $langs->trans("ClickToDialUrlDesc"));
144 }
145 print '</td>';
146 print '</tr>';
147 }
148
149 print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
150 print '<td class="valeur">';
151 print '<input name="poste" value="'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'"></td>';
152 print "</tr>\n";
153
154 print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
155 print '<td class="valeur">';
156 print '<input name="login" value="'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'"></td>';
157 print '</tr>';
158
159 print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
160 print '<td class="valeur">';
161 print '<input type="password" name="password" value="'.dol_escape_htmltag(empty($object->clicktodial_password) ? '' : $object->clicktodial_password).'"></td>';
162 print "</tr>\n";
163
164 print '</table>';
165 } else { // View mode
166 print '<table class="border centpercent tableforfield">';
167
168 if (!empty($user->admin)) {
169 print '<tr><td class="">ClickToDial URL</td>';
170 print '<td class="valeur">';
171 if (getDolGlobalString('CLICKTODIAL_URL')) {
172 $url = getDolGlobalString('CLICKTODIAL_URL');
173 }
174 if (!empty($object->clicktodial_url)) {
175 $url = $object->clicktodial_url;
176 }
177 if (empty($url)) {
178 $langs->load("errors");
179 print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
180 } else {
181 print $form->textwithpicto((empty($object->clicktodial_url) ? '<span class="opacitymedium">'.$langs->trans("DefaultLink").':</span> ' : '').$url, $langs->trans("ClickToDialUrlDesc"));
182 }
183 print '</td>';
184 print '</tr>';
185 }
186
187 print '<tr><td class="">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
188 print '<td class="valeur">'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'</td>';
189 print "</tr>";
190
191 print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
192 print '<td class="valeur">'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'</td>';
193 print '</tr>';
194
195 print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
196 print '<td class="valeur">'.preg_replace('/./', '*', (!empty($object->clicktodial_password) ? $object->clicktodial_password : '')).'</a></td>';
197 print "</tr>\n";
198
199 print "</table>\n";
200 }
201
202 print dol_get_fiche_end();
203
204 if ($action == 'edit') {
205 print '<br>';
206 print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
207 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
208 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
209 print '</div>';
210 }
211
212 print '</div>';
213 print '</form>';
214
215 /*
216 * Action bar
217 */
218 print '<div class="tabsAction">';
219
220 if (!empty($user->admin) && $action != 'edit') {
221 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
222 }
223
224 print "</div>\n";
225}
226
227// End of page
228llxFooter();
229$db->close();
$id
Definition account.php:39
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
user_prepare_head(User $object)
Prepare array with list of tabs.