dolibarr  17.0.4
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
26 require '../main.inc.php';
27 require_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;
37 if ($user->socid > 0) {
38  $socid = $user->socid;
39 }
40 $feature2 = (($socid && $user->rights->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
54 if ($reshook < 0) {
55  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
56 }
57 
58 if (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 
81 if ($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.'" class="refid">';
110  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
111  $morehtmlref .= '</a>';
112 
113  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
114 
115  print '<div class="fichecenter">';
116  print '<div class="underbanner clearboth"></div>';
117 
118  // Edit mode
119  if ($action == 'edit') {
120  print '<table class="border centpercent">';
121 
122  if ($user->admin) {
123  print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
124  print '<td class="valeur">';
125  print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
126  if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) {
127  $langs->load("errors");
128  print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
129  } else {
130  print '<br>'.$form->textwithpicto('<span class="opacitymedium">'.$langs->trans("KeepEmptyToUseDefault").'</span>:<br>'.$conf->global->CLICKTODIAL_URL, $langs->trans("ClickToDialUrlDesc"));
131  }
132  print '</td>';
133  print '</tr>';
134  }
135 
136  print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
137  print '<td class="valeur">';
138  print '<input name="poste" value="'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'"></td>';
139  print "</tr>\n";
140 
141  print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
142  print '<td class="valeur">';
143  print '<input name="login" value="'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'"></td>';
144  print '</tr>';
145 
146  print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
147  print '<td class="valeur">';
148  print '<input type="password" name="password" value="'.dol_escape_htmltag(empty($object->clicktodial_password) ? '' : $object->clicktodial_password).'"></td>';
149  print "</tr>\n";
150 
151  print '</table>';
152  } else // View mode
153  {
154  print '<table class="border centpercent tableforfield">';
155 
156  if (!empty($user->admin)) {
157  print '<tr><td class="">ClickToDial URL</td>';
158  print '<td class="valeur">';
159  if (!empty($conf->global->CLICKTODIAL_URL)) {
160  $url = $conf->global->CLICKTODIAL_URL;
161  }
162  if (!empty($object->clicktodial_url)) {
163  $url = $object->clicktodial_url;
164  }
165  if (empty($url)) {
166  $langs->load("errors");
167  print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
168  } else {
169  print $form->textwithpicto((empty($object->clicktodial_url) ? '<span class="opacitymedium">'.$langs->trans("DefaultLink").':</span> ' : '').$url, $langs->trans("ClickToDialUrlDesc"));
170  }
171  print '</td>';
172  print '</tr>';
173  }
174 
175  print '<tr><td class="">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
176  print '<td class="valeur">'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'</td>';
177  print "</tr>";
178 
179  print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
180  print '<td class="valeur">'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'</td>';
181  print '</tr>';
182 
183  print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
184  print '<td class="valeur">'.preg_replace('/./', '*', (!empty($object->clicktodial_password) ? $object->clicktodial_password : '')).'</a></td>';
185  print "</tr>\n";
186 
187  print "</table>\n";
188  }
189 
190  print dol_get_fiche_end();
191 
192  if ($action == 'edit') {
193  print '<br>';
194  print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
195  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
196  print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
197  print '</div>';
198  }
199 
200  print '</div>';
201  print '</form>';
202 
203  /*
204  * Action bar
205  */
206  print '<div class="tabsAction">';
207 
208  if (!empty($user->admin) && $action <> 'edit') {
209  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
210  }
211 
212  print "</div>\n";
213 }
214 
215 // End of page
216 llxFooter();
217 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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.
Definition: user.class.php:47
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.