Fix: add key generator in agenda xcal admin page

This commit is contained in:
Regis Houssin 2012-10-24 12:18:40 +02:00
parent 87d44c845d
commit 382f1a54c3
2 changed files with 53 additions and 34 deletions

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
*
* 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
@ -51,12 +52,12 @@ if ($actionsave)
if ($i >= 3)
{
$db->commit();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
setEventMessage($langs->trans("SetupSaved"));
}
else
{
$db->rollback();
$mesg = "<font class=\"error\">".$langs->trans("SaveFailed")."</font>";
setEventMessage($langs->trans("SaveFailed"), 'errors');
}
}
@ -95,7 +96,10 @@ print "</tr>";
print "<tr class=\"impair\">";
print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
print "<td><input required=\"required\" type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_XCAL_EXPORTKEY\" value=\"". (GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha')?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha'):$conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) . "\" size=\"40\"></td>";
print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="' . (GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha')?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha'):$conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) . '" size="40">';
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td>';
print "<td>&nbsp;</td>";
print "</tr>";
@ -147,9 +151,24 @@ $message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions5",$user->login,$user->login);
print info_admin($message);
dol_htmloutput_mesg($mesg);
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#MAIN_AGENDA_XCAL_EXPORTKEY").val(token);
});
});
});';
print '</script>';
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -71,7 +71,7 @@ if ($action == 'setvalue' && $user->admin)
if (! $error)
{
$db->commit();
$mesg='<div class="ok">'.$langs->trans("SetupSaved").'</div>';
setEventMessage($langs->trans("SetupSaved"));
}
else
{
@ -100,37 +100,13 @@ dol_fiche_head($head, 'paypalaccount', $langs->trans("ModuleSetup"));
print $langs->trans("PaypalDesc")."<br>\n";
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
$("#apidoc").hide();
$("#apidoca").click(function() {
$("#apidoca").hide();
$("#apidoc").show();
});
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#PAYPAL_SECURITY_TOKEN").val(token);
});
});
});';
print '</script>';
}
// Test if php curl exist
if (! function_exists('curl_version'))
{
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans("ErrorPhpCurlNotInstalled").'</div>';
setEventMessage($langs->trans("ErrorPhpCurlNotInstalled"), 'errors');
}
dol_htmloutput_mesg($mesg);
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
@ -235,7 +211,8 @@ $var=!$var;
print '<tr '.$bc[$var].'><td>';
print $langs->trans("SecurityToken").'</td><td>';
print '<input size="48" type="text" id="PAYPAL_SECURITY_TOKEN" name="PAYPAL_SECURITY_TOKEN" value="'.$conf->global->PAYPAL_SECURITY_TOKEN.'">';
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td></tr>';
$var=!$var;
@ -256,7 +233,8 @@ print '<br><br>';
// Help doc
print '<u>'.$langs->trans("InformationToFindParameters","Paypal").'</u>:<br>';
if ($conf->use_javascript_ajax) print '<a href="#" id="apidoca">'.$langs->trans("ClickHere").'...</a>';
if (! empty($conf->use_javascript_ajax))
print '<a href="#" id="apidoca">'.$langs->trans("ClickHere").'...</a>';
$realpaypalurl='www.paypal.com';
$sandboxpaypalurl='developer.paypal.com';
@ -374,7 +352,29 @@ if (! empty($conf->adherent->enabled))
print "<br>";
print info_admin($langs->trans("YouCanAddTagOnUrl"));
llxFooter();
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#apidoc").hide();
$("#apidoca").click(function() {
$("#apidoca").hide();
$("#apidoc").show();
});
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#PAYPAL_SECURITY_TOKEN").val(token);
});
});
});';
print '</script>';
}
llxFooter();
$db->close();
?>