clicktodial.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/user/clicktodial.php
  21. * \brief Page for Click to dial datas
  22. */
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
  25. // Load translation files required by page
  26. $langs->loadLangs(array('users', 'admin'));
  27. $action=GETPOST('action','alpha');
  28. $id=GETPOST('id','int');
  29. // Security check
  30. $socid=0;
  31. if ($user->societe_id > 0) $socid = $user->societe_id;
  32. $feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
  33. if ($user->id == $id) // A user can always read its own card
  34. {
  35. $feature2='';
  36. }
  37. $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
  38. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  39. $hookmanager->initHooks(array('usercard','globalcard'));
  40. /*
  41. * Actions
  42. */
  43. $parameters=array('id'=>$socid);
  44. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  45. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  46. if (empty($reshook)) {
  47. if ($action == 'update' && !GETPOST('cancel','alpha')) {
  48. $edituser = new User($db);
  49. $edituser->fetch($id);
  50. $edituser->clicktodial_url = GETPOST("url");
  51. $edituser->clicktodial_login = GETPOST("login");
  52. $edituser->clicktodial_password = GETPOST("password");
  53. $edituser->clicktodial_poste = GETPOST("poste");
  54. $result = $edituser->update_clicktodial();
  55. if ($result < 0)
  56. {
  57. setEventMessages($edituser->error, $edituser->errors, 'errors');
  58. }
  59. }
  60. }
  61. /*
  62. * View
  63. */
  64. $form = new Form($db);
  65. llxHeader("","ClickToDial");
  66. if ($id > 0)
  67. {
  68. $object = new User($db);
  69. $object->fetch($id, '', '', 1);
  70. $object->getrights();
  71. $object->fetch_clicktodial();
  72. $head = user_prepare_head($object);
  73. $title = $langs->trans("User");
  74. print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
  75. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  76. print '<input type="hidden" name="action" value="update">';
  77. dol_fiche_head($head, 'clicktodial', $title, -1, 'user');
  78. $linkback = '';
  79. if ($user->rights->user->user->lire || $user->admin) {
  80. $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  81. }
  82. dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
  83. print '<div class="fichecenter">';
  84. print '<div class="underbanner clearboth"></div>';
  85. // Edit mode
  86. if ($action == 'edit')
  87. {
  88. print '<table class="border" width="100%">';
  89. if ($user->admin)
  90. {
  91. print '<tr><td width="25%" valign="top">ClickToDial URL</td>';
  92. print '<td class="valeur">';
  93. print '<input name="url" value="'.(! empty($object->clicktodial_url)?$object->clicktodial_url:'').'" size="92">';
  94. if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url))
  95. {
  96. $langs->load("errors");
  97. print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>';
  98. }
  99. else
  100. {
  101. print ' &nbsp; &nbsp; '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc"));
  102. }
  103. print '</td>';
  104. print '</tr>';
  105. }
  106. print '<tr><td class="titlefield">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
  107. print '<td class="valeur">';
  108. print '<input name="poste" value="'.(! empty($object->clicktodial_poste)?$object->clicktodial_poste:'').'"></td>';
  109. print "</tr>\n";
  110. print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
  111. print '<td class="valeur">';
  112. print '<input name="login" value="'.(! empty($object->clicktodial_login)?$object->clicktodial_login:'').'"></td>';
  113. print '</tr>';
  114. print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
  115. print '<td class="valeur">';
  116. print '<input type="password" name="password" value="'.(! empty($object->clicktodial_password)?$object->clicktodial_password:'').'"></td>';
  117. print "</tr>\n";
  118. print '</table>';
  119. }
  120. else // View mode
  121. {
  122. print '<table class="border" width="100%">';
  123. if (! empty($user->admin))
  124. {
  125. print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
  126. print '<td class="valeur">';
  127. $url=$conf->global->CLICKTODIAL_URL;
  128. if (! empty($object->clicktodial_url)) $url=$object->clicktodial_url;
  129. if (empty($url))
  130. {
  131. $langs->load("errors");
  132. print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>';
  133. }
  134. else
  135. {
  136. print $form->textwithpicto((empty($object->clicktodial_url)?$langs->trans("DefaultLink").': ':'').$url,$langs->trans("ClickToDialUrlDesc"));
  137. }
  138. print '</td>';
  139. print '</tr>';
  140. }
  141. print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
  142. print '<td class="valeur">'.(! empty($object->clicktodial_poste)?$object->clicktodial_poste:'').'</td>';
  143. print "</tr>";
  144. print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
  145. print '<td class="valeur">'.(! empty($object->clicktodial_login)?$object->clicktodial_login:'').'</td>';
  146. print '</tr>';
  147. print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
  148. print '<td class="valeur">'.preg_replace('/./','*',(! empty($object->clicktodial_password)?$object->clicktodial_password:'')).'</a></td>';
  149. print "</tr>\n";
  150. print "</table>\n";
  151. }
  152. dol_fiche_end();
  153. if ($action == 'edit')
  154. {
  155. print '<div align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">';
  156. print '&nbsp;&nbsp;&nbsp;&nbsp&nbsp;';
  157. print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
  158. print '</div>';
  159. }
  160. print '</div>';
  161. print '</form>';
  162. /*
  163. * Barre d'actions
  164. */
  165. print '<div class="tabsAction">';
  166. if (! empty($user->admin) && $action <> 'edit')
  167. {
  168. print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
  169. }
  170. print "</div>\n";
  171. }
  172. // End of page
  173. llxFooter();
  174. $db->close();