2005-01-14 15:08:01 +01:00
|
|
|
<?php
|
2012-07-10 13:20:53 +02:00
|
|
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2018-10-27 14:43:12 +02:00
|
|
|
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
2005-01-14 15:08:01 +01: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 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-01-14 15:08:01 +01: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 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2005-01-14 15:08:01 +01:00
|
|
|
*/
|
|
|
|
|
|
2005-01-28 21:35:01 +01:00
|
|
|
/**
|
2009-01-09 22:22:58 +01:00
|
|
|
* \file htdocs/user/clicktodial.php
|
|
|
|
|
* \brief Page for Click to dial datas
|
|
|
|
|
*/
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2018-05-26 16:24:54 +02:00
|
|
|
// Load translation files required by page
|
|
|
|
|
$langs->loadLangs(array('users', 'admin'));
|
2005-01-14 15:08:01 +01:00
|
|
|
|
2020-11-13 21:00:23 +01:00
|
|
|
$action = (string) GETPOST('action', 'aZ09');
|
|
|
|
|
$id = (int) GETPOST('id', 'int');
|
2012-01-04 23:17:12 +01:00
|
|
|
|
2009-08-17 19:32:38 +02:00
|
|
|
// Security check
|
2020-04-10 10:59:32 +02:00
|
|
|
$socid = 0;
|
2021-02-26 13:18:40 +01:00
|
|
|
if ($user->socid > 0) {
|
|
|
|
|
$socid = $user->socid;
|
|
|
|
|
}
|
2020-04-10 10:59:32 +02:00
|
|
|
$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
|
2019-01-16 19:25:19 +01:00
|
|
|
|
2015-05-13 09:32:54 +02:00
|
|
|
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
2012-06-16 00:07:24 +02:00
|
|
|
|
2017-06-10 12:56:28 +02:00
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
2020-04-10 10:59:32 +02:00
|
|
|
$hookmanager->initHooks(array('usercard', 'globalcard'));
|
2006-04-01 14:03:31 +02:00
|
|
|
|
2022-07-29 10:41:09 +02:00
|
|
|
|
2006-04-01 14:03:31 +02:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2009-08-05 19:19:55 +02:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$parameters = array('id'=>$socid);
|
|
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
2021-02-26 13:18:40 +01:00
|
|
|
if ($reshook < 0) {
|
|
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
|
|
}
|
2015-09-16 09:37:49 +02:00
|
|
|
|
|
|
|
|
if (empty($reshook)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
|
|
|
|
|
$edituser = new User($db);
|
|
|
|
|
$edituser->fetch($id);
|
|
|
|
|
|
2020-11-13 21:00:23 +01:00
|
|
|
$edituser->clicktodial_url = (string) GETPOST("url", "alpha");
|
|
|
|
|
$edituser->clicktodial_login = (string) GETPOST("login", "alpha");
|
|
|
|
|
$edituser->clicktodial_password = (string) GETPOST("password", "alpha");
|
|
|
|
|
$edituser->clicktodial_poste = (string) GETPOST("poste", "alpha");
|
2020-10-31 14:32:18 +01:00
|
|
|
|
|
|
|
|
$result = $edituser->update_clicktodial();
|
2020-11-13 21:00:23 +01:00
|
|
|
if ($result < 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
setEventMessages($edituser->error, $edituser->errors, 'errors');
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-01-14 15:08:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-08-05 19:19:55 +02:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
2006-04-01 14:03:31 +02:00
|
|
|
|
2009-08-17 19:32:38 +02:00
|
|
|
$form = new Form($db);
|
|
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
llxHeader("", "ClickToDial");
|
2005-01-14 15:08:01 +01:00
|
|
|
|
|
|
|
|
|
2021-02-26 13:18:40 +01:00
|
|
|
if ($id > 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$object = new User($db);
|
|
|
|
|
$object->fetch($id, '', '', 1);
|
|
|
|
|
$object->getrights();
|
|
|
|
|
$object->fetch_clicktodial();
|
2005-08-11 20:48:08 +02:00
|
|
|
|
|
|
|
|
|
2015-10-11 16:25:31 +02:00
|
|
|
$head = user_prepare_head($object);
|
2005-08-11 20:48:08 +02:00
|
|
|
|
2009-08-05 19:19:55 +02:00
|
|
|
$title = $langs->trans("User");
|
2016-03-14 16:01:27 +01:00
|
|
|
|
2018-05-26 16:35:29 +02:00
|
|
|
|
2016-03-14 16:01:27 +01:00
|
|
|
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
|
2019-12-01 10:20:11 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2016-03-14 16:01:27 +01:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2018-05-26 16:35:29 +02:00
|
|
|
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head($head, 'clicktodial', $title, -1, 'user');
|
2005-08-11 20:48:08 +02:00
|
|
|
|
2017-04-09 14:09:33 +02:00
|
|
|
$linkback = '';
|
|
|
|
|
|
|
|
|
|
if ($user->rights->user->user->lire || $user->admin) {
|
2018-10-09 14:20:53 +02:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
2017-04-09 14:09:33 +02:00
|
|
|
}
|
2018-05-26 16:35:29 +02:00
|
|
|
|
2022-07-29 10:41:09 +02:00
|
|
|
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'" class="refid">';
|
|
|
|
|
$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
|
|
|
|
|
$morehtmlref .= '</a>';
|
|
|
|
|
|
|
|
|
|
dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
|
2020-10-31 14:32:18 +01:00
|
|
|
|
|
|
|
|
print '<div class="fichecenter">';
|
|
|
|
|
print '<div class="underbanner clearboth"></div>';
|
|
|
|
|
|
|
|
|
|
// Edit mode
|
2021-02-26 13:18:40 +01:00
|
|
|
if ($action == 'edit') {
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<table class="border centpercent">';
|
|
|
|
|
|
2021-02-26 13:18:40 +01:00
|
|
|
if ($user->admin) {
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<tr><td class="titlefield fieldrequired">ClickToDial URL</td>';
|
|
|
|
|
print '<td class="valeur">';
|
|
|
|
|
print '<input name="url" value="'.(!empty($object->clicktodial_url) ? $object->clicktodial_url : '').'" size="92">';
|
2021-02-26 13:18:40 +01:00
|
|
|
if (empty($conf->global->CLICKTODIAL_URL) && empty($object->clicktodial_url)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$langs->load("errors");
|
2021-10-05 11:44:48 +02:00
|
|
|
print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
|
2020-10-31 14:32:18 +01:00
|
|
|
} else {
|
|
|
|
|
print ' '.$form->textwithpicto($langs->trans("KeepEmptyToUseDefault").': '.$conf->global->CLICKTODIAL_URL, $langs->trans("ClickToDialUrlDesc"));
|
|
|
|
|
}
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '<tr><td class="titlefield fieldrequired">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
|
|
|
|
|
print '<td class="valeur">';
|
|
|
|
|
print '<input name="poste" value="'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'"></td>';
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
|
|
|
|
|
print '<td class="valeur">';
|
|
|
|
|
print '<input name="login" value="'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'"></td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
|
|
|
|
|
print '<td class="valeur">';
|
2022-06-13 10:44:20 +02:00
|
|
|
print '<input type="password" name="password" value="'.dol_escape_htmltag(empty($object->clicktodial_password) ? '' : $object->clicktodial_password).'"></td>';
|
2020-10-31 14:32:18 +01:00
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
} else // View mode
|
|
|
|
|
{
|
|
|
|
|
print '<table class="border centpercent tableforfield">';
|
|
|
|
|
|
2021-02-26 13:18:40 +01:00
|
|
|
if (!empty($user->admin)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<tr><td class="titlefield">ClickToDial URL</td>';
|
|
|
|
|
print '<td class="valeur">';
|
2021-07-07 14:50:10 +02:00
|
|
|
if (!empty($conf->global->CLICKTODIAL_URL)) {
|
|
|
|
|
$url = $conf->global->CLICKTODIAL_URL;
|
|
|
|
|
}
|
2021-02-26 13:18:40 +01:00
|
|
|
if (!empty($object->clicktodial_url)) {
|
|
|
|
|
$url = $object->clicktodial_url;
|
|
|
|
|
}
|
|
|
|
|
if (empty($url)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$langs->load("errors");
|
2021-10-05 11:44:48 +02:00
|
|
|
print '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("ClickToDial")).'</span>';
|
2020-10-31 14:32:18 +01:00
|
|
|
} else {
|
|
|
|
|
print $form->textwithpicto((empty($object->clicktodial_url) ? '<span class="opacitymedium">'.$langs->trans("DefaultLink").':</span> ' : '').$url, $langs->trans("ClickToDialUrlDesc"));
|
|
|
|
|
}
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '<tr><td class="titlefield">ClickToDial '.$langs->trans("IdPhoneCaller").'</td>';
|
|
|
|
|
print '<td class="valeur">'.(!empty($object->clicktodial_poste) ? $object->clicktodial_poste : '').'</td>';
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
|
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Login").'</td>';
|
|
|
|
|
print '<td class="valeur">'.(!empty($object->clicktodial_login) ? $object->clicktodial_login : '').'</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
print '<tr><td>ClickToDial '.$langs->trans("Password").'</td>';
|
|
|
|
|
print '<td class="valeur">'.preg_replace('/./', '*', (!empty($object->clicktodial_password) ? $object->clicktodial_password : '')).'</a></td>';
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
print "</table>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
|
|
2021-02-26 13:18:40 +01:00
|
|
|
if ($action == 'edit') {
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<br>';
|
2020-11-19 20:23:38 +01:00
|
|
|
print '<div class="center"><input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
|
2021-02-07 19:12:26 +01:00
|
|
|
print ' ';
|
2020-11-23 15:12:52 +01:00
|
|
|
print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
|
|
|
|
/*
|
2021-03-16 04:22:55 +01:00
|
|
|
* Action bar
|
2021-02-26 13:18:40 +01:00
|
|
|
*/
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<div class="tabsAction">';
|
2005-08-11 20:48:08 +02:00
|
|
|
|
2021-02-26 13:18:40 +01:00
|
|
|
if (!empty($user->admin) && $action <> 'edit') {
|
2021-09-27 12:24:01 +02:00
|
|
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2005-08-11 20:48:08 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print "</div>\n";
|
2005-01-14 15:08:01 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-04 15:58:05 +02:00
|
|
|
// End of page
|
2012-01-04 23:17:12 +01:00
|
|
|
llxFooter();
|
2005-01-14 15:08:01 +01:00
|
|
|
$db->close();
|