dolibarr  13.0.2
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 require '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
27 
28 // Load translation files required by page
29 $langs->loadLangs(array('users', 'admin'));
30 
31 $action = (string) GETPOST('action', 'aZ09');
32 $id = (int) GETPOST('id', 'int');
33 
34 // Security check
35 $socid = 0;
36 if ($user->socid > 0) $socid = $user->socid;
37 $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
38 
39 $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
40 
41 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
42 $hookmanager->initHooks(array('usercard', 'globalcard'));
43 
44 /*
45  * Actions
46  */
47 
48 $parameters = array('id'=>$socid);
49 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
50 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
51 
52 if (empty($reshook)) {
53  if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
54  $edituser = new User($db);
55  $edituser->fetch($id);
56 
57  $edituser->clicktodial_url = (string) GETPOST("url", "alpha");
58  $edituser->clicktodial_login = (string) GETPOST("login", "alpha");
59  $edituser->clicktodial_password = (string) GETPOST("password", "alpha");
60  $edituser->clicktodial_poste = (string) GETPOST("poste", "alpha");
61 
62  $result = $edituser->update_clicktodial();
63  if ($result < 0) {
64  setEventMessages($edituser->error, $edituser->errors, 'errors');
65  }
66  }
67 }
68 
69 
70 /*
71  * View
72  */
73 
74 $form = new Form($db);
75 
76 llxHeader("", "ClickToDial");
77 
78 
79 if ($id > 0)
80 {
81  $object = new User($db);
82  $object->fetch($id, '', '', 1);
83  $object->getrights();
84  $object->fetch_clicktodial();
85 
86 
87  $head = user_prepare_head($object);
88 
89  $title = $langs->trans("User");
90 
91 
92  print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
93  print '<input type="hidden" name="token" value="'.newToken().'">';
94  print '<input type="hidden" name="action" value="update">';
95 
96  print dol_get_fiche_head($head, 'clicktodial', $title, -1, 'user');
97 
98  $linkback = '';
99 
100  if ($user->rights->user->user->lire || $user->admin) {
101  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
102  }
103 
104  dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
105 
106  print '<div class="fichecenter">';
107  print '<div class="underbanner clearboth"></div>';
108 
109  // Edit mode
110  if ($action == 'edit')
111  {
112  print '<table class="border centpercent">';
113 
114  if ($user->admin)
115  {
116  print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
117  print '<td class="valeur">';
118  print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
119  if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url))
120  {
121  $langs->load("errors");
122  print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>';
123  } else {
124  print ' &nbsp; &nbsp; '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL, $langs->trans("ClickToDialUrlDesc"));
125  }
126  print '</td>';
127  print '</tr>';
128  }
129 
130  print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
131  print '<td class="valeur">';
132  print '<input name="poste" value="'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'"></td>';
133  print "</tr>\n";
134 
135  print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
136  print '<td class="valeur">';
137  print '<input name="login" value="'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'"></td>';
138  print '</tr>';
139 
140  print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
141  print '<td class="valeur">';
142  print '<input type="password" name="password" value="'.(!empty($object->clicktodial_password) ? $object->clicktodial_password : '').'"></td>';
143  print "</tr>\n";
144 
145  print '</table>';
146  } else // View mode
147  {
148  print '<table class="border centpercent tableforfield">';
149 
150  if (!empty($user->admin))
151  {
152  print '<tr><td class="titlefield">ClickToDial URL</td>';
153  print '<td class="valeur">';
154  $url = $conf->global->CLICKTODIAL_URL;
155  if (!empty($object->clicktodial_url)) $url = $object->clicktodial_url;
156  if (empty($url))
157  {
158  $langs->load("errors");
159  print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>';
160  } else {
161  print $form->textwithpicto((empty($object->clicktodial_url) ? '<span class="opacitymedium">'.$langs->trans("DefaultLink").':</span> ' : '').$url, $langs->trans("ClickToDialUrlDesc"));
162  }
163  print '</td>';
164  print '</tr>';
165  }
166 
167  print '<tr><td class="titlefield">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
168  print '<td class="valeur">'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'</td>';
169  print "</tr>";
170 
171  print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
172  print '<td class="valeur">'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'</td>';
173  print '</tr>';
174 
175  print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
176  print '<td class="valeur">'.preg_replace('/./', '*', (!empty($object->clicktodial_password) ? $object->clicktodial_password : '')).'</a></td>';
177  print "</tr>\n";
178 
179  print "</table>\n";
180  }
181 
182  print dol_get_fiche_end();
183 
184  if ($action == 'edit')
185  {
186  print '<br>';
187  print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
188  print '&nbsp;&nbsp;&nbsp;&nbsp&nbsp;';
189  print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
190  print '</div>';
191  }
192 
193  print '</div>';
194  print '</form>';
195 
196  /*
197  * Barre d'actions
198  */
199  print '<div class="tabsAction">';
200 
201  if (!empty($user->admin) && $action <> 'edit')
202  {
203  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
204  }
205 
206  print "</div>\n";
207 }
208 
209 // End of page
210 llxFooter();
211 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
user_prepare_head($object)
Prepare array with list of tabs.
Class to manage Dolibarr users.
Definition: user.class.php:44
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.