PageRenderTime 61ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/user/clicktodial.php

https://bitbucket.org/speedealing/speedealing
PHP | 207 lines | 123 code | 44 blank | 40 comment | 19 complexity | 48f76d1f0c855503120a7d45ff437499 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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@capnetworks.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. $langs->load("users");
  26. $langs->load("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', $feature2);
  38. /*
  39. * Actions
  40. */
  41. if ($action == 'update' && ! $_POST['cancel'])
  42. {
  43. $edituser = new User($db);
  44. $edituser->fetch($id);
  45. $edituser->clicktodial_login = $_POST["login"];
  46. $edituser->clicktodial_password = $_POST["password"];
  47. $edituser->clicktodial_poste = $_POST["poste"];
  48. $result=$edituser->update_clicktodial();
  49. }
  50. /*
  51. * View
  52. */
  53. $form = new Form($db);
  54. llxHeader("","ClickToDial");
  55. if ($id > 0)
  56. {
  57. $fuser = new User($db);
  58. $fuser->fetch($id);
  59. $fuser->fetch_clicktodial();
  60. /*
  61. * Affichage onglets
  62. */
  63. $head = user_prepare_head($fuser);
  64. $title = $langs->trans("User");
  65. dol_fiche_head($head, 'clicktodial', $title, 0, 'user');
  66. /*
  67. * Fiche en mode visu
  68. */
  69. print '<table class="border" width="100%">';
  70. // Ref
  71. print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
  72. print '<td colspan="2">';
  73. print $form->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin);
  74. print '</td>';
  75. print '</tr>';
  76. // Name
  77. print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
  78. print '<td colspan="2">'.$fuser->lastname.'</td>';
  79. print "</tr>\n";
  80. // Prenom
  81. print '<tr><td width="25%" valign="top">'.$langs->trans("Firstname").'</td>';
  82. print '<td colspan="2">'.$fuser->name.'</td>';
  83. print "</tr>\n";
  84. print "</table>\n";
  85. print "<br>\n";
  86. if ($action == 'edit')
  87. {
  88. print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'" method="post">';
  89. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  90. print '<input type="hidden" name="action" value="update">';
  91. print '<table class="border" width="100%">';
  92. if ($user->admin)
  93. {
  94. print '<tr><td width="25%" valign="top">ClickToDial URL</td>';
  95. print '<td class="valeur">';
  96. if (empty($conf->global->CLICKTODIAL_URL))
  97. {
  98. $langs->load("errors");
  99. print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>';
  100. }
  101. else print $form->textwithpicto($conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc"));
  102. print '</td>';
  103. print '</tr>';
  104. }
  105. print '<tr><td width="25%" valign="top">ClickToDial '.$langs->trans("Login").'</td>';
  106. print '<td class="valeur">';
  107. print '<input name="login" value="'.(! empty($fuser->clicktodial_login)?$fuser->clicktodial_login:'').'"></td>';
  108. print '</tr>';
  109. print '<tr><td width="25%" valign="top">ClickToDial '.$langs->trans("Password").'</td>';
  110. print '<td class="valeur">';
  111. print '<input name="password" value="'.(! empty($fuser->clicktodial_password)?$fuser->clicktodial_password:'').'"></td>';
  112. print "</tr>\n";
  113. print '<tr><td width="25%" valign="top">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
  114. print '<td class="valeur">';
  115. print '<input name="poste" value="'.(! empty($fuser->clicktodial_poste)?$fuser->clicktodial_poste:'').'"></td>';
  116. print "</tr>\n";
  117. print '<tr><td colspan="2" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">';
  118. print ' &nbsp; &nbsp; ';
  119. print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
  120. print '</td></tr>';
  121. print '</table></form>';
  122. }
  123. else
  124. {
  125. print '<table class="border" width="100%">';
  126. if (! empty($user->admin))
  127. {
  128. print "<tr>".'<td width="25%" valign="top">ClickToDial URL</td>';
  129. print '<td class="valeur">';
  130. if (empty($conf->global->CLICKTODIAL_URL))
  131. {
  132. $langs->load("errors");
  133. print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font>';
  134. }
  135. else print $form->textwithpicto($conf->global->CLICKTODIAL_URL,$langs->trans("ClickToDialUrlDesc"));
  136. print '</td>';
  137. print '</tr>';
  138. }
  139. print '<tr><td width="25%" valign="top">ClickToDial '.$langs->trans("Login").'</td>';
  140. print '<td class="valeur">'.(! empty($fuser->clicktodial_login)?$fuser->clicktodial_login:'').'</td>';
  141. print '</tr>';
  142. print '<tr><td width="25%" valign="top">ClickToDial '.$langs->trans("Password").'</td>';
  143. print '<td class="valeur">'.preg_replace('/./','*',(! empty($fuser->clicktodial_password)?$fuser->clicktodial_password:'')).'</a></td>';
  144. print "</tr>\n";
  145. print '<tr><td width="25%" valign="top">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
  146. print '<td class="valeur">'.(! empty($fuser->clicktodial_poste)?$fuser->clicktodial_poste:'').'</td>';
  147. print "</tr></table>\n";
  148. }
  149. print "</div>\n";
  150. /*
  151. * Barre d'actions
  152. */
  153. print '<div class="tabsAction">';
  154. if (! empty($user->admin) && $action <> 'edit')
  155. {
  156. print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>';
  157. }
  158. print "</div>\n";
  159. print "<br>\n";
  160. }
  161. llxFooter();
  162. $db->close();
  163. ?>