update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit d885a4baa9
5833 changed files with 418860 additions and 226988 deletions

View file

@ -0,0 +1,176 @@
/*!
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
$(document).ready(function () {
function hideLoading()
{
$('#giveUserAccessToViewReports').prop('disabled', false);
$('#ajaxLoadingGiveViewAccess').hide();
}
function showLoading()
{
$('#giveUserAccessToViewReports').prop('disabled', true);
$('#ajaxLoadingGiveViewAccess').show();
}
function showErrorNotification(errorMessage)
{
var placeAt = '#ajaxErrorGiveViewAccess';
$(placeAt).show();
var UI = require('piwik/UI');
var notification = new UI.Notification();
notification.show(errorMessage, {
placeat: placeAt,
context: 'error',
id: 'ajaxHelper',
type: null
});
notification.scrollToNotification();
hideLoading();
}
function createNewAjaxHelper()
{
var ajaxHandler = new ajaxHelper();
ajaxHandler.setCompleteCallback(function (xhr, status) {
if (xhr &&
xhr.responseJSON &&
xhr.responseJSON.message &&
xhr.responseJSON.result &&
xhr.responseJSON.result == 'error') {
hideLoading();
}
if (status && String(status).toLowerCase() !== 'sucess') {
hideLoading();
}
});
ajaxHandler.addParams({
module: 'API',
format: 'json'
}, 'GET');
ajaxHandler.setErrorElement('#ajaxErrorGiveViewAccess');
return ajaxHandler;
}
function sendViewAccess(userLogin)
{
sendUpdateUserAccess(userLogin, 'view', function () { window.location.reload(); });
setTimeout(hideLoading, 250);
// we hide loading after a bit since we cannot influence the ajax request in case of any error
}
function setViewAccessForUserToAllWebsitesIfUserConfirms(userLogin)
{
// ask confirmation
$('#confirm').find('#login').text(userLogin);
function onValidate() {
sendViewAccess(userLogin);
}
piwikHelper.modalConfirm('#confirm', {yes: onValidate, no: hideLoading})
}
function setViewAccessForUserIfNotAlreadyHasAccess(userLogin, idSites)
{
var ajaxHandler = createNewAjaxHelper();
ajaxHandler.addParams({
method: 'UsersManager.getUsersAccessFromSite',
userLogin: userLogin,
idSite: idSites
}, 'GET');
ajaxHandler.setCallback(function (users) {
var userLogins = [];
if (users && users[0]) {
userLogins = $.map(users[0], function (val, key) {
return (''+ key).toLowerCase();
});
}
if (-1 !== userLogins.indexOf(userLogin.toLowerCase())) {
showErrorNotification(_pk_translate('UsersManager_ExceptionUserHasViewAccessAlready'));
} else {
sendViewAccess(userLogin);
}
});
ajaxHandler.send();
}
function ifUserExists(usernameOrEmail, callback)
{
var ajaxHandler = createNewAjaxHelper();
ajaxHandler.addParams({
method: 'UsersManager.userExists',
userLogin: usernameOrEmail,
}, 'GET');
ajaxHandler.setCallback(callback);
ajaxHandler.send();
}
function getUsernameFromEmail(usernameOrEmail, callback)
{
var ajaxHandler = createNewAjaxHelper();
ajaxHandler.addParams({
method: 'UsersManager.getUserLoginFromUserEmail',
userEmail: usernameOrEmail,
}, 'GET');
ajaxHandler.setCallback(callback);
ajaxHandler.send();
}
function giveViewAccessToUser(userLogin)
{
var idSites = getIdSites();
if (idSites === 'all') {
setViewAccessForUserToAllWebsitesIfUserConfirms(userLogin);
} else {
setViewAccessForUserIfNotAlreadyHasAccess(userLogin, idSites);
}
}
$('#showGiveViewAccessForm').click(function () {
$('#giveViewAccessForm').toggle()
});
$('#giveViewAccessForm #user_invite').keypress(function (e) {
var key = e.keyCode || e.which;
if (key == 13) {
$('#giveViewAccessForm #giveUserAccessToViewReports').click();
}
});
$('#giveViewAccessForm #giveUserAccessToViewReports').click(function () {
showLoading();
var usernameOrEmail = $('#user_invite').val();
if (!usernameOrEmail) {
showErrorNotification(_pk_translate('UsersManager_ExceptionNoValueForUsernameOrEmail'));
return;
}
ifUserExists(usernameOrEmail, function (isUserName) {
if (isUserName && isUserName.value) {
giveViewAccessToUser(usernameOrEmail);
} else {
getUsernameFromEmail(usernameOrEmail, function (login) {
if (login && login.value) {
giveViewAccessToUser(login.value);
} else {
hideLoading();
}
});
}
});
});
});

View file

@ -1,5 +1,5 @@
/*!
* Piwik - Web Analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -229,7 +229,11 @@ $(document).ready(function () {
$(this)
.toggle()
.parent()
.prepend($('<input type="submit" class="submit updateuser" value="' + _pk_translate('General_Save') + '" />')
.prepend($('<a class="canceluser">' + _pk_translate('General_OrCancel', ['', '']) + '</a>')
.click(function () {
piwikHelper.redirect();
})
).prepend($('<input type="submit" class="submit updateuser" value="' + _pk_translate('General_Save') + '" />')
.click(function () {
var onValidate = function () {
sendUpdateUserAJAX($('tr#' + idRow));
@ -240,7 +244,7 @@ $(document).ready(function () {
onValidate();
}
})
);
);
});
$('.editable').keypress(submitOnEnter);
@ -259,7 +263,7 @@ $(document).ready(function () {
}
);
$('.addrow').click(function () {
$('.admin .user .add-user').click(function () {
piwikHelper.hideAjaxError();
$(this).toggle();
@ -268,10 +272,10 @@ $(document).ready(function () {
newRowId = 'row' + newRowId;
$($.parseHTML(' <tr id="' + newRowId + '">\
<td><input id="useradd_login" value="login?" size="10" /></td>\
<td><input id="useradd_password" value="password" size="10" /></td>\
<td><input id="useradd_email" value="email@domain.com" size="15" /></td>\
<td><input id="useradd_alias" value="alias" size="15" /></td>\
<td><input id="useradd_login" placeholder="username" size="10" /></td>\
<td><input id="useradd_password" placeholder="password" size="10" /></td>\
<td><input id="useradd_email" placeholder="email@domain.com" size="15" /></td>\
<td><input id="useradd_alias" placeholder="alias" size="15" /></td>\
<td>-</td>\
<td>-</td>\
<td><input type="submit" class="submit adduser" value="' + _pk_translate('General_Save') + '" /></td>\
@ -284,12 +288,11 @@ $(document).ready(function () {
$('.cancel').click(function () {
piwikHelper.hideAjaxError();
$(this).parents('tr').remove();
$('.addrow').toggle();
$('.add-user').toggle();
});
});
$('#access .updateAccess')
.click(bindUpdateAccess);
$('#access .updateAccess').click(bindUpdateAccess);
$('#superUserAccess .accessGranted, #superUserAccess .updateAccess').click(bindUpdateSuperUserAccess);
@ -299,4 +302,12 @@ $(document).ready(function () {
piwik.broadcast.propagateNewPage('segment=&idSite=' + site.id, false);
}
});
// Show the token_auth
$('.token_auth').click(function () {
var token = $(this).data('token');
if ($(this).text() != token) {
$(this).text(token);
}
});
});

View file

@ -1,5 +1,5 @@
/*!
* Piwik - Web Analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -38,6 +38,7 @@ function sendUserSettingsAJAX() {
postParams.defaultReport = defaultReport;
postParams.defaultDate = defaultDate;
postParams.language = $('#userSettingsTable #language').val();
postParams.timeformat = $('#userSettingsTable #timeformat').val();
var ajaxHandler = new ajaxHelper();
ajaxHandler.addParams({