dolibarr 24.0.0-beta
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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
29
38// Load translation files required by page
39$langs->loadLangs(array('users', 'admin'));
40
41$action = (string) GETPOST('action', 'aZ09');
42$cancel = GETPOST('cancel');
43
44$id = GETPOSTINT('id');
45
46// Security check
47$socid = 0;
48if ($user->socid > 0) {
49 $socid = $user->socid;
50}
51$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
52
53// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
54$hookmanager->initHooks(array('usercard', 'globalcard'));
55
56$object = new User($db);
57
58$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
59
60// Define value to know what current user can do on properties of edited user
61$canedituser = 0;
62if ($id > 0) {
63 // $user is the current logged user, $id is the user we want to edit
64 $canedituser = (($user->id == $id) && $user->hasRight("user", "self", "write")) || (($user->id != $id) && $user->hasRight("user", "user", "write"));
65}
66
67
68
69/*
70 * Actions
71 */
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}
78
79if (empty($reshook)) {
80 if ($action == 'update' && !$cancel && $canedituser) {
81 $edituser = new User($db);
82 $edituser->fetch($id);
83
84 $edituser->clicktodial_url = (string) GETPOST("url", "alpha");
85 $edituser->clicktodial_login = (string) GETPOST("login", "alpha");
86 $edituser->clicktodial_password = (string) GETPOST("password", "alpha");
87 $edituser->clicktodial_poste = (string) GETPOST("poste", "alpha");
88
89 $result = $edituser->update_clicktodial();
90 if ($result < 0) {
91 setEventMessages($edituser->error, $edituser->errors, 'errors');
92 }
93 }
94}
95
96
97/*
98 * View
99 */
100
101$form = new Form($db);
102
103if ($id > 0) {
104 $object = new User($db);
105 $object->fetch($id, '', '', 1);
106 $object->loadRights();
107 $object->fetch_clicktodial();
108
109 $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
110 $title = $person_name." - ".$langs->trans('ClickToDial');
111 $help_url = '';
112 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-clicktodial');
113
114 $head = user_prepare_head($object);
115
116 $title = $langs->trans("User");
117
118
119 print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
120 print '<input type="hidden" name="token" value="'.newToken().'">';
121 print '<input type="hidden" name="action" value="update">';
122
123 print dol_get_fiche_head($head, 'clicktodial', $title, -1, 'user');
124
125 $linkback = '';
126
127 if ($user->hasRight('user', 'user', 'lire') || $user->admin) {
128 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
129 }
130
131 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid valignmiddle" rel="noopener">';
132 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard', 'class="valignmiddle marginleftonly paddingrightonly"');
133 $morehtmlref .= '</a>';
134
135 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
136 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'refid valignmiddle nohover');
137
138 dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref);
139
140 print '<div class="fichecenter">';
141 print '<div class="underbanner clearboth"></div>';
142
143 // Edit mode
144 if ($action == 'edit') {
145 print '<table class="border centpercent">';
146
147 if ($user->admin) {
148 print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
149 print '<td class="valeur">';
150 print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
151 if (!getDolGlobalString('CLICKTODIAL_URL') && empty($object->clicktodial_url)) {
152 $langs->load("errors");
153 print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
154 } else {
155 print '<br>'.$form->textwithpicto('<span class="opacitymedium">'.$langs->trans("KeepEmptyToUseDefault").'</span>:<br>' . getDolGlobalString('CLICKTODIAL_URL'), $langs->trans("ClickToDialUrlDesc"));
156 }
157 print '</td>';
158 print '</tr>';
159 }
160
161 print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
162 print '<td class="valeur">';
163 print '<input name="poste" value="'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'"></td>';
164 print "</tr>\n";
165
166 print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
167 print '<td class="valeur">';
168 print '<input name="login" value="'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'"></td>';
169 print '</tr>';
170
171 print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
172 print '<td class="valeur">';
173 print '<input type="password" name="password" value="'.dol_escape_htmltag(empty($object->clicktodial_password) ? '' : $object->clicktodial_password).'"></td>';
174 print "</tr>\n";
175
176 print '</table>';
177 } else { // View mode
178 print '<table class="border centpercent tableforfield">';
179
180 if (!empty($user->admin)) {
181 print '<tr><td class="">ClickToDial URL</td>';
182 print '<td class="valeur">';
183 if (getDolGlobalString('CLICKTODIAL_URL')) {
184 $url = getDolGlobalString('CLICKTODIAL_URL');
185 }
186 if (!empty($object->clicktodial_url)) {
187 $url = $object->clicktodial_url;
188 }
189 if (empty($url)) {
190 $langs->load("errors");
191 print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
192 } else {
193 print $form->textwithpicto((empty($object->clicktodial_url) ? '<span class="opacitymedium">'.$langs->trans("DefaultLink").':</span> ' : '').$url, $langs->trans("ClickToDialUrlDesc"));
194 }
195 print '</td>';
196 print '</tr>';
197 }
198
199 print '<tr><td class="">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
200 print '<td class="valeur">'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'</td>';
201 print "</tr>";
202
203 print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
204 print '<td class="valeur">'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'</td>';
205 print '</tr>';
206
207 print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
208 print '<td class="valeur">'.preg_replace('/./', '*', (!empty($object->clicktodial_password) ? $object->clicktodial_password : '')).'</a></td>';
209 print "</tr>\n";
210
211 print "</table>\n";
212 }
213
214 print dol_get_fiche_end();
215
216 if ($action == 'edit') {
217 print '<br>';
218 print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
219 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
220 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
221 print '</div>';
222 }
223
224 print '</div>';
225 print '</form>';
226
227 /*
228 * Action bar
229 */
230 print '<div class="tabsAction">';
231
232 if (!empty($user->admin) && $action != 'edit') {
233 print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
234 }
235
236 print "</div>\n";
237}
238
239// End of page
240llxFooter();
241$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.