dolibarr 18.0.6
clicktodial.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2021 Laurent Destailleur <eldy@users.sourceforge.org>
4 * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
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
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29
30// Load translation files required by the page
31$langs->load("admin");
32
33if (!$user->admin) {
35}
36
37$action = GETPOST('action', 'aZ09');
38
39if (!isModEnabled('clicktodial')) {
40 accessforbidden($langs->transnoentitiesnoconv("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name")));
41}
42
43
44/*
45 * Actions
46 */
47
48if ($action == 'setvalue' && $user->admin) {
49 $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
50 $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
51 $result3 = dolibarr_set_const($db, "CLICKTODIAL_KEY_FOR_CIDLOOKUP", GETPOST("CLICKTODIAL_KEY_FOR_CIDLOOKUP"), 'chaine', 0, '', $conf->entity);
52
53 if ($result1 >= 0 && $result2 >= 0 && $result3 >= 0) {
54 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
55 } else {
56 setEventMessages($langs->trans("Error"), null, 'errors');
57 }
58}
59
60
61/*
62 * View
63 */
64
65$form = new Form($db);
66
67$user->fetch_clicktodial();
68
69$wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
70llxHeader('', $langs->trans("ClickToDialSetup"), $wikihelp);
71
72$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
73print load_fiche_titre($langs->trans("ClickToDialSetup"), $linkback, 'title_setup');
74
75print '<span class="opacitymedium">'.$langs->trans("ClickToDialDesc")."</span><br>\n";
76
77print '<br>';
78print '<form method="post" action="clicktodial.php">';
79print '<input type="hidden" name="token" value="'.newToken().'">';
80print '<input type="hidden" name="action" value="setvalue">';
81
82print '<div class="div-table-responsive-no-min">';
83print '<table class="noborder centpercent">';
84print '<tr class="liste_titre">';
85print '<td class="minwidth200">'.$langs->trans("Name").'</td>';
86print '<td>'.$langs->trans("Value").'</td>';
87print "</tr>\n";
88
89
90print '<tr class="oddeven"><td>';
91print $langs->trans("ClickToDialUseTelLink").'</td><td>';
92print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'<br>';
93print '<br>';
94print '<span class="opacitymedium small">'.$langs->trans("ClickToDialUseTelLinkDesc").'</span>';
95print '</td></tr>';
96
97
98print '<tr class="oddeven"><td>';
99print $langs->trans("DefaultLink").'</td><td>';
100print '<input class="quatrevingtpercent" type="text" id="CLICKTODIAL_URL" name="CLICKTODIAL_URL"'.(getDolGlobalString('CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS') ? ' disabled="disabled"' : '').' value="'.getDolGlobalString('CLICKTODIAL_URL').'"><br>';
101print ajax_autoselect('CLICKTODIAL_URL');
102print '<br>';
103print $langs->trans("ClickToDialUrlDesc").'<br>';
104print '<br>';
105print '<span class="opacitymedium">';
106print $langs->trans("Examples").':<br>';
107print '* https://myphoneserver/phoneurl?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
108print '* sip:__PHONETO__@my.sip.server';
109print '</span>';
110
111//if (!empty($user->clicktodial_url))
112//{
113 print '<br>';
114 print info_admin($langs->trans("ValueOverwrittenByUserSetup"));
115//}
116
117print '</td></tr>';
118
119print '<tr class="oddeven">';
120print '<td>'.$langs->trans("SecurityKey").'</td>';
121print '<td>';
122
123global $dolibarr_main_url_root;
124
125// Define $urlwithroot
126$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
127$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
128//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
129
130// Url for CIDLookup
131//print '<div class="div-table-responsive-no-min">';
132//print $langs->trans("URLToLaunchCronJobs").':<br>';
133$url = $urlwithroot.'/public/clicktodial/cidlookup.php?securitykey='.getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP', 'ValueToDefine').'&phone=...';
134//print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
135//print '</div>';
136//print '<br>';
137
138
139print '<span class="opacitymedium">'.$langs->trans("CIDLookupURL").'</span>';
140print '<br>'.$url;
141print '<br>';
142print '<br>';
143print '<input type="text" class="flat minwidth300" id="CLICKTODIAL_KEY_FOR_CIDLOOKUP" name="CLICKTODIAL_KEY_FOR_CIDLOOKUP" value="'.(GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') ? GETPOST('CLICKTODIAL_KEY_FOR_CIDLOOKUP') : (!empty($conf->global->CLICKTODIAL_KEY_FOR_CIDLOOKUP) ? $conf->global->CLICKTODIAL_KEY_FOR_CIDLOOKUP : '')).'">';
144if (!empty($conf->use_javascript_ajax)) {
145 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
146}
147print '</td>';
148print '</tr>';
149
150print '</table>';
151print '</div>';
152
153print $form->buttonsSaveCancel("Modify", '');
154
155print '</form><br><br>';
156
157
158if (!empty($conf->global->CLICKTODIAL_URL)) {
159 $user->fetch_clicktodial();
160
161 $phonefortest = $mysoc->phone;
162 if (GETPOST('phonefortest')) {
163 $phonefortest = GETPOST('phonefortest');
164 }
165
166 print '<form action="'.$_SERVER["PHP_SELF"].'">';
167 print '<input type="hidden" name="token" value="'.newToken().'">';
168 print $langs->trans("LinkToTestClickToDial", $user->login).' : ';
169 print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
170 print '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
171 print '</form>';
172
173 $setupcomplete = 1;
174 if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) {
175 $setupcomplete = 0;
176 }
177 if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) {
178 $setupcomplete = 0;
179 }
180 if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) {
181 $setupcomplete = 0;
182 }
183
184 if ($setupcomplete) {
185 print $langs->trans("LinkToTest", $user->login).': &nbsp; '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL', '', 'mobile');
186 } else {
187 $langs->load("errors");
188 print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';
189 }
190}
191
192// Add button to autosuggest a key
193include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
194print dolJSToSetRandomPassword('CLICKTODIAL_KEY_FOR_CIDLOOKUP');
195
196
197// End of page
198llxFooter();
199$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ="&nbsp;", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Ouput javacript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.