dolibarr 18.0.6
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$id = (int) GETPOST('id', 'int');
34
35// Security check
36$socid = 0;
37if ($user->socid > 0) {
38 $socid = $user->socid;
39}
40$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
41
42$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
43
44// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
45$hookmanager->initHooks(array('usercard', 'globalcard'));
46
47
48/*
49 * Actions
50 */
51
52$parameters = array('id'=>$socid);
53$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
54if ($reshook < 0) {
55 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
56}
57
58if (empty($reshook)) {
59 if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
60 $edituser = new User($db);
61 $edituser->fetch($id);
62
63 $edituser->clicktodial_url = (string) GETPOST("url", "alpha");
64 $edituser->clicktodial_login = (string) GETPOST("login", "alpha");
65 $edituser->clicktodial_password = (string) GETPOST("password", "alpha");
66 $edituser->clicktodial_poste = (string) GETPOST("poste", "alpha");
67
68 $result = $edituser->update_clicktodial();
69 if ($result < 0) {
70 setEventMessages($edituser->error, $edituser->errors, 'errors');
71 }
72 }
73}
74
75
76/*
77 * View
78 */
79$form = new Form($db);
80
81if ($id > 0) {
82 $object = new User($db);
83 $object->fetch($id, '', '', 1);
84 $object->getrights();
85 $object->fetch_clicktodial();
86
87 $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
88 $title = $person_name." - ".$langs->trans('ClickToDial');
89 $help_url = '';
90 llxHeader('', $title, $help_url);
91
92 $head = user_prepare_head($object);
93
94 $title = $langs->trans("User");
95
96
97 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
98 print '<input type="hidden" name="token" value="'.newToken().'">';
99 print '<input type="hidden" name="action" value="update">';
100
101 print dol_get_fiche_head($head, 'clicktodial', $title, -1, 'user');
102
103 $linkback = '';
104
105 if ($user->rights->user->user->lire || $user->admin) {
106 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
107 }
108
109 $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">';
110 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
111 $morehtmlref .= '</a>';
112
113 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
114 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
115
116 dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
117
118 print '<div class="fichecenter">';
119 print '<div class="underbanner clearboth"></div>';
120
121 // Edit mode
122 if ($action == 'edit') {
123 print '<table class="border centpercent">';
124
125 if ($user->admin) {
126 print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
127 print '<td class="valeur">';
128 print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
129 if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) {
130 $langs->load("errors");
131 print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
132 } else {
133 print '<br>'.$form->textwithpicto('<span class="opacitymedium">'.$langs->trans("KeepEmptyToUseDefault").'</span>:<br>'.$conf->global->CLICKTODIAL_URL, $langs->trans("ClickToDialUrlDesc"));
134 }
135 print '</td>';
136 print '</tr>';
137 }
138
139 print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
140 print '<td class="valeur">';
141 print '<input name="poste" value="'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'"></td>';
142 print "</tr>\n";
143
144 print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
145 print '<td class="valeur">';
146 print '<input name="login" value="'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'"></td>';
147 print '</tr>';
148
149 print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
150 print '<td class="valeur">';
151 print '<input type="password" name="password" value="'.dol_escape_htmltag(empty($object->clicktodial_password) ? '' : $object->clicktodial_password).'"></td>';
152 print "</tr>\n";
153
154 print '</table>';
155 } else // View mode
156 {
157 print '<table class="border centpercent tableforfield">';
158
159 if (!empty($user->admin)) {
160 print '<tr><td class="">ClickToDial URL</td>';
161 print '<td class="valeur">';
162 if (!empty($conf->global->CLICKTODIAL_URL)) {
163 $url = $conf->global->CLICKTODIAL_URL;
164 }
165 if (!empty($object->clicktodial_url)) {
166 $url = $object->clicktodial_url;
167 }
168 if (empty($url)) {
169 $langs->load("errors");
170 print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
171 } else {
172 print $form->textwithpicto((empty($object->clicktodial_url) ? '<span class="opacitymedium">'.$langs->trans("DefaultLink").':</span> ' : '').$url, $langs->trans("ClickToDialUrlDesc"));
173 }
174 print '</td>';
175 print '</tr>';
176 }
177
178 print '<tr><td class="">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
179 print '<td class="valeur">'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'</td>';
180 print "</tr>";
181
182 print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
183 print '<td class="valeur">'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'</td>';
184 print '</tr>';
185
186 print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
187 print '<td class="valeur">'.preg_replace('/./', '*', (!empty($object->clicktodial_password) ? $object->clicktodial_password : '')).'</a></td>';
188 print "</tr>\n";
189
190 print "</table>\n";
191 }
192
193 print dol_get_fiche_end();
194
195 if ($action == 'edit') {
196 print '<br>';
197 print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
198 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
199 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
200 print '</div>';
201 }
202
203 print '</div>';
204 print '</form>';
205
206 /*
207 * Action bar
208 */
209 print '<div class="tabsAction">';
210
211 if (!empty($user->admin) && $action <> 'edit') {
212 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
213 }
214
215 print "</div>\n";
216}
217
218// End of page
219llxFooter();
220$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
user_prepare_head(User $object)
Prepare array with list of tabs.