2005-01-14 14:08:01 +00:00
|
|
|
<?php
|
2012-07-10 11:20:53 +00:00
|
|
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2018-10-27 12:43:12 +00:00
|
|
|
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
2005-01-14 14:08:01 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-01-14 14:08:01 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 19:55:30 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2005-01-14 14:08:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2005-01-28 20:35:01 +00:00
|
|
|
/**
|
2009-01-09 21:22:58 +00:00
|
|
|
* \file htdocs/user/clicktodial.php
|
|
|
|
|
* \brief Page for Click to dial datas
|
|
|
|
|
*/
|
2005-01-14 14:08:01 +00:00
|
|
|
|
2012-08-22 21:24:21 +00:00
|
|
|
require '../main.inc.php';
|
2012-08-22 21:11:24 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
2005-01-14 14:08:01 +00:00
|
|
|
|
2018-05-26 14:24:54 +00:00
|
|
|
// Load translation files required by page
|
|
|
|
|
$langs->loadLangs(array('users', 'admin'));
|
2005-01-14 14:08:01 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
$action = GETPOST('action', 'alpha');
|
|
|
|
|
$id = GETPOST('id', 'int');
|
2012-01-04 22:17:12 +00:00
|
|
|
|
2009-08-17 17:32:38 +00:00
|
|
|
// Security check
|
2020-04-10 08:59:32 +00:00
|
|
|
$socid = 0;
|
2019-10-31 19:46:31 +00:00
|
|
|
if ($user->socid > 0) $socid = $user->socid;
|
2020-04-10 08:59:32 +00:00
|
|
|
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
|
2019-01-16 18:25:19 +00:00
|
|
|
|
2015-05-13 07:32:54 +00:00
|
|
|
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
2012-06-15 22:07:24 +00:00
|
|
|
|
2017-06-10 10:56:28 +00:00
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
2020-04-10 08:59:32 +00:00
|
|
|
$hookmanager->initHooks(array('usercard', 'globalcard'));
|
2006-04-01 12:03:31 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2009-08-05 17:19:55 +00:00
|
|
|
|
2020-04-10 08:59:32 +00:00
|
|
|
$parameters = array('id'=>$socid);
|
|
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
2015-09-16 07:37:49 +00:00
|
|
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
|
|
|
|
|
|
|
if (empty($reshook)) {
|
2019-01-27 10:55:16 +00:00
|
|
|
if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
|
2015-09-16 07:37:49 +00:00
|
|
|
$edituser = new User($db);
|
|
|
|
|
$edituser->fetch($id);
|
|
|
|
|
|
|
|
|
|
$edituser->clicktodial_url = GETPOST("url");
|
|
|
|
|
$edituser->clicktodial_login = GETPOST("login");
|
|
|
|
|
$edituser->clicktodial_password = GETPOST("password");
|
|
|
|
|
$edituser->clicktodial_poste = GETPOST("poste");
|
|
|
|
|
|
|
|
|
|
$result = $edituser->update_clicktodial();
|
2018-05-26 14:35:29 +00:00
|
|
|
if ($result < 0)
|
2015-12-21 13:43:21 +00:00
|
|
|
{
|
|
|
|
|
setEventMessages($edituser->error, $edituser->errors, 'errors');
|
2015-09-16 07:37:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-01-14 14:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-08-05 17:19:55 +00:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
2006-04-01 12:03:31 +00:00
|
|
|
|
2009-08-17 17:32:38 +00:00
|
|
|
$form = new Form($db);
|
|
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
llxHeader("", "ClickToDial");
|
2005-01-14 14:08:01 +00:00
|
|
|
|
|
|
|
|
|
2012-10-09 07:34:12 +00:00
|
|
|
if ($id > 0)
|
2005-01-14 14:08:01 +00:00
|
|
|
{
|
2015-10-11 14:25:31 +00:00
|
|
|
$object = new User($db);
|
2017-05-06 10:43:45 +00:00
|
|
|
$object->fetch($id, '', '', 1);
|
|
|
|
|
$object->getrights();
|
2015-10-11 14:25:31 +00:00
|
|
|
$object->fetch_clicktodial();
|
2005-08-11 18:48:08 +00:00
|
|
|
|
|
|
|
|
|
2015-10-11 14:25:31 +00:00
|
|
|
$head = user_prepare_head($object);
|
2005-08-11 18:48:08 +00:00
|
|
|
|
2009-08-05 17:19:55 +00:00
|
|
|
$title = $langs->trans("User");
|
2016-03-14 15:01:27 +00:00
|
|
|
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2016-03-14 15:01:27 +00:00
|
|
|
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
|
2019-12-01 09:20:11 +00:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2016-03-14 15:01:27 +00:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2017-04-14 11:00:39 +00:00
|
|
|
dol_fiche_head($head, 'clicktodial', $title, -1, 'user');
|
2005-08-11 18:48:08 +00:00
|
|
|
|
2017-04-09 12:09:33 +00:00
|
|
|
$linkback = '';
|
|
|
|
|
|
|
|
|
|
if ($user->rights->user->user->lire || $user->admin) {
|
2018-10-09 12:20:53 +00:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
2017-04-09 12:09:33 +00:00
|
|
|
}
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2017-04-14 11:00:39 +00:00
|
|
|
print '<div class="fichecenter">';
|
2015-10-11 14:25:31 +00:00
|
|
|
print '<div class="underbanner clearboth"></div>';
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2015-10-11 14:25:31 +00:00
|
|
|
// Edit mode
|
2012-01-04 22:17:12 +00:00
|
|
|
if ($action == 'edit')
|
2005-01-14 14:08:01 +00:00
|
|
|
{
|
2019-10-27 09:38:52 +00:00
|
|
|
print '<table class="border centpercent">';
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2008-01-26 13:18:47 +00:00
|
|
|
if ($user->admin)
|
|
|
|
|
{
|
2020-04-12 15:28:10 +00:00
|
|
|
print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
|
2019-02-03 21:41:57 +00:00
|
|
|
print '<td class="valeur">';
|
2019-11-13 18:35:39 +00:00
|
|
|
print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
|
2019-02-03 21:41:57 +00:00
|
|
|
if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url))
|
2011-03-05 18:20:19 +00:00
|
|
|
{
|
|
|
|
|
$langs->load("errors");
|
2019-08-01 10:23:02 +00:00
|
|
|
print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>';
|
2011-03-05 18:20:19 +00:00
|
|
|
}
|
2013-03-31 14:44:24 +00:00
|
|
|
else
|
2019-02-03 13:29:45 +00:00
|
|
|
{
|
2019-02-03 21:41:57 +00:00
|
|
|
print ' '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL, $langs->trans("ClickToDialUrlDesc"));
|
2019-02-03 13:29:45 +00:00
|
|
|
}
|
2013-03-31 14:44:24 +00:00
|
|
|
print '</td>';
|
2019-02-03 13:29:45 +00:00
|
|
|
print '</tr>';
|
2008-01-26 13:18:47 +00:00
|
|
|
}
|
2009-08-05 17:19:55 +00:00
|
|
|
|
2020-04-12 15:28:10 +00:00
|
|
|
print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
|
2015-04-29 21:39:34 +00:00
|
|
|
print '<td class="valeur">';
|
2019-11-13 18:35:39 +00:00
|
|
|
print '<input name="poste" value="'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'"></td>';
|
2015-04-29 21:39:34 +00:00
|
|
|
print "</tr>\n";
|
|
|
|
|
|
2015-10-11 14:25:31 +00:00
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
|
2008-01-26 13:18:47 +00:00
|
|
|
print '<td class="valeur">';
|
2019-11-13 18:35:39 +00:00
|
|
|
print '<input name="login" value="'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'"></td>';
|
2019-02-03 13:29:45 +00:00
|
|
|
print '</tr>';
|
2009-08-05 17:19:55 +00:00
|
|
|
|
2015-10-11 14:25:31 +00:00
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
|
2008-01-26 13:18:47 +00:00
|
|
|
print '<td class="valeur">';
|
2019-11-13 18:35:39 +00:00
|
|
|
print '<input type="password" name="password" value="'.(!empty($object->clicktodial_password) ? $object->clicktodial_password : '').'"></td>';
|
2005-08-11 18:48:08 +00:00
|
|
|
print "</tr>\n";
|
|
|
|
|
|
2013-03-31 14:44:24 +00:00
|
|
|
print '</table>';
|
2005-01-14 14:08:01 +00:00
|
|
|
}
|
2013-03-31 14:44:24 +00:00
|
|
|
else // View mode
|
2005-01-14 14:08:01 +00:00
|
|
|
{
|
2019-10-06 13:34:22 +00:00
|
|
|
print '<table class="border centpercent tableforfield">';
|
2005-08-11 18:48:08 +00:00
|
|
|
|
2019-11-13 18:35:39 +00:00
|
|
|
if (!empty($user->admin))
|
2008-01-26 13:18:47 +00:00
|
|
|
{
|
2020-04-12 15:28:10 +00:00
|
|
|
print '<tr><td class="titlefield">ClickToDial URL</td>';
|
2009-01-09 21:22:58 +00:00
|
|
|
print '<td class="valeur">';
|
2019-11-13 18:35:39 +00:00
|
|
|
$url = $conf->global->CLICKTODIAL_URL;
|
|
|
|
|
if (!empty($object->clicktodial_url)) $url = $object->clicktodial_url;
|
2013-03-31 14:44:24 +00:00
|
|
|
if (empty($url))
|
2011-03-05 18:20:19 +00:00
|
|
|
{
|
|
|
|
|
$langs->load("errors");
|
2019-08-01 10:23:02 +00:00
|
|
|
print '<font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</font>';
|
2011-03-05 18:20:19 +00:00
|
|
|
}
|
2013-03-31 14:44:24 +00:00
|
|
|
else
|
|
|
|
|
{
|
2020-07-23 22:06:18 +00:00
|
|
|
print $form->textwithpicto((empty($object->clicktodial_url) ? '<span class="opacitymedium">'.$langs->trans("DefaultLink").':</span> ' : '').$url, $langs->trans("ClickToDialUrlDesc"));
|
2013-03-31 14:44:24 +00:00
|
|
|
}
|
2009-01-09 21:22:58 +00:00
|
|
|
print '</td>';
|
2008-01-26 13:18:47 +00:00
|
|
|
print '</tr>';
|
|
|
|
|
}
|
2015-04-29 21:39:34 +00:00
|
|
|
|
2020-04-12 15:28:10 +00:00
|
|
|
print '<tr><td class="titlefield">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
|
2019-11-13 18:35:39 +00:00
|
|
|
print '<td class="valeur">'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'</td>';
|
2015-04-29 21:39:34 +00:00
|
|
|
print "</tr>";
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2015-10-11 14:25:31 +00:00
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
|
2019-11-13 18:35:39 +00:00
|
|
|
print '<td class="valeur">'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'</td>';
|
2008-01-26 13:18:47 +00:00
|
|
|
print '</tr>';
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2015-10-11 14:25:31 +00:00
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
|
2019-11-13 18:35:39 +00:00
|
|
|
print '<td class="valeur">'.preg_replace('/./', '*', (!empty($object->clicktodial_password) ? $object->clicktodial_password : '')).'</a></td>';
|
2005-08-11 18:48:08 +00:00
|
|
|
print "</tr>\n";
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2015-04-29 21:39:34 +00:00
|
|
|
print "</table>\n";
|
2005-01-14 14:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-11 14:25:31 +00:00
|
|
|
dol_fiche_end();
|
2005-08-11 18:48:08 +00:00
|
|
|
|
2016-03-14 15:01:27 +00:00
|
|
|
if ($action == 'edit')
|
|
|
|
|
{
|
2020-04-12 15:28:10 +00:00
|
|
|
print '<br>';
|
2019-02-16 09:29:15 +00:00
|
|
|
print '<div class="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
2016-03-14 15:01:27 +00:00
|
|
|
print '   ';
|
|
|
|
|
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
|
|
|
|
print '</div>';
|
2018-05-26 14:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
2017-04-14 11:00:39 +00:00
|
|
|
print '</div>';
|
2016-03-14 15:01:27 +00:00
|
|
|
print '</form>';
|
2018-05-26 14:35:29 +00:00
|
|
|
|
2005-08-11 18:48:08 +00:00
|
|
|
/*
|
|
|
|
|
* Barre d'actions
|
|
|
|
|
*/
|
|
|
|
|
print '<div class="tabsAction">';
|
|
|
|
|
|
2019-11-13 18:35:39 +00:00
|
|
|
if (!empty($user->admin) && $action <> 'edit')
|
2005-01-14 14:08:01 +00:00
|
|
|
{
|
2015-10-11 14:25:31 +00:00
|
|
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
2005-01-14 14:08:01 +00:00
|
|
|
}
|
2005-08-11 18:48:08 +00:00
|
|
|
|
|
|
|
|
print "</div>\n";
|
2005-01-14 14:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-04 13:58:05 +00:00
|
|
|
// End of page
|
2012-01-04 22:17:12 +00:00
|
|
|
llxFooter();
|
2005-01-14 14:08:01 +00:00
|
|
|
$db->close();
|