Skip to content

Commit

Permalink
Update translation files
Browse files Browse the repository at this point in the history
Updated by "Squash Git commits" hook in Weblate.

Translation: Matomo/CommunityPlugin GroupPermissions
Translate-URL: https://hosted.weblate.org/projects/matomo/communityplugin-grouppermissions/

[ci skip]
  • Loading branch information
weblate committed Jan 6, 2024
1 parent 07df960 commit 44ea2ed
Show file tree
Hide file tree
Showing 14 changed files with 770 additions and 101 deletions.
6 changes: 5 additions & 1 deletion Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
namespace Piwik\Plugins\GroupPermissions;

use Exception;
use Piwik\API\Request;
use Piwik\Common;
use Piwik\Piwik;
Expand Down Expand Up @@ -150,6 +149,11 @@ private function tabGroups(&$view)
else {
$view->groupUsers = array();
}

$allUsers = Request::processRequest('UsersManager.getUsersLogin', ['filter_limit' => '-1']);
// Create a named array using the user login as the key as well as the value
$allUsers = array_combine($allUsers, $allUsers);
$view->users = $allUsers;

$view->selectedIdGroup = $idGroup;
$view->selectedGroupName = isset($groups[$idGroup]) ? $groups[$idGroup] : '';
Expand Down
11 changes: 11 additions & 0 deletions GroupPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function registerEvents()
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'SitesManager.deleteSite.end' => 'deleteSite',
'UsersManager.deleteUser' => 'deleteUser',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
);
}

Expand All @@ -59,6 +60,16 @@ public function getStylesheetFiles(&$stylesheetFiles)
$stylesheetFiles[] = "plugins/GroupPermissions/stylesheets/choices.less";
}

public function getClientSideTranslationKeys(&$translations)
{
$translations[] = 'GroupPermissions_AddUserToGroup';
$translations[] = 'GroupPermissions_AddUserToGroupButton';
$translations[] = 'GroupPermissions_ManageGroupMembers';
$translations[] = 'GroupPermissions_RemoveFromGroup';
$translations[] = 'GroupPermissions_RemoveFromGroupConfirm';
$translations[] = 'GroupPermissions_SelectNewUser';
}

/**
* Delete group preferences associated with a particular site
*/
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Copy it into the plugins folder.
GPL v3 or later

## Changelog
- 5.0.0
- Compatibility with Matomo 5

- 4.0.5
- Fix js crash

Expand Down
80 changes: 40 additions & 40 deletions javascripts/groupPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
*/

$(document).ready(function () {

function getSelectedIdSite() {
return $('#groupPermissionsSiteSelect').attr('siteid');
}

function sendUpdateGroupPermissionAccess(name, access, successCallback) {
var parameters = {};
parameters.name = name;
parameters.access = access;
parameters.idSites = getSelectedIdSite();

var ajaxHandler = new ajaxHelper();
ajaxHandler.addParams({
module: 'API',
Expand All @@ -29,15 +29,15 @@ $(document).ready(function () {
ajaxHandler.setErrorElement('#ajaxErrorGroupPermissions');
ajaxHandler.send(true);
}

function callSendUpdateGroupPermissionAccess(self, successCallback) {
sendUpdateGroupPermissionAccess(
$(self).parent().parent().find('#group').html(), //if changed change also the modal
$(self).parent().attr('id'),
successCallback
);
}

function bindUpdateGroupPermissions() {
var self = this;
// callback called when the ajax request Update the group permissions is successful
Expand All @@ -53,7 +53,7 @@ $(document).ready(function () {
.attr('src', "plugins/UsersManager/images/ok.png")
.attr('class', "accessGranted")
;

var UI = require('piwik/UI');
var notification = new UI.Notification();
notification.show(_pk_translate('General_Done'), {
Expand All @@ -65,26 +65,26 @@ $(document).ready(function () {
id: 'groupPermissionsAccessUpdated'
});
}

var idSite = getSelectedIdSite();
if (idSite == 'all') {
var target = this;

//ask confirmation
var group = $(this).parent().parent().find('#group').text();
$('#confirmGroupPermissions').find('#group').text(group);

function onValidate() {
callSendUpdateGroupPermissionAccess(target, successCallback);
}

piwikHelper.modalConfirm('#confirmGroupPermissions', {yes: onValidate})
}
else {
callSendUpdateGroupPermissionAccess(this, successCallback);
}
}

function sendAddGroupMember(idGroup, login, successCallback) {
var parameters = {};
parameters.idGroup = idGroup;
Expand All @@ -102,7 +102,7 @@ $(document).ready(function () {
ajaxHandler.setErrorElement('#ajaxErrorManageGroupMember');
ajaxHandler.send(true);
}

function sendRemoveGroupMember(idGroup, login, successCallback) {
var parameters = {};
parameters.idGroup = idGroup;
Expand All @@ -120,7 +120,7 @@ $(document).ready(function () {
ajaxHandler.setErrorElement('#ajaxErrorManageGroupMember');
ajaxHandler.send(true);
}

function bindRemoveGroupMember() {
var idGroup = $('#groupPermissionsCurrentIdGroup').val();
var name = $('#groupPermissionsCurrentGroupName').val();
Expand All @@ -130,15 +130,15 @@ $(document).ready(function () {
function successCallback(response) {
line.remove();
}

$('#confirmRemoveUserFromGroup').find('#login').text(login);
$('#confirmRemoveUserFromGroup').find('#group').text(name);
$('#confirmRemoveUserFromGroup').find('#group').text(name);

piwikHelper.modalConfirm('#confirmRemoveUserFromGroup', {yes: function() {
sendRemoveGroupMember(idGroup, login, successCallback);
}});
}

function sendCreateGroup(groupName, successCallback) {
var parameters = {};
parameters.groupName = groupName;
Expand All @@ -155,15 +155,15 @@ $(document).ready(function () {
ajaxHandler.setErrorElement('#ajaxErrorCreateGroup');
ajaxHandler.send(true);
}

function bindCreateGroup() {
var groupName = $('#groupPermissionsGroupCreateGroup').val();

function successCallback(response) {
location.reload();
}
sendCreateGroup(groupName, successCallback);

sendCreateGroup(groupName, successCallback);
}


Expand All @@ -184,7 +184,7 @@ $(document).ready(function () {
ajaxHandler.setErrorElement('#ajaxErrorManageGroupRename');
ajaxHandler.send(true);
}

function bindRenameGroup() {
var idGroup = $('#groupPermissionsCurrentIdGroup').val();
var name = $('#groupPermissionsCurrentGroupName').val();
Expand All @@ -193,10 +193,10 @@ $(document).ready(function () {
function successCallback(response) {
location.reload();
}

$('#confirmRenameGroup').find('#confirmOldGroupName').text(name);
$('#confirmRenameGroup').find('#confirmNewGroupName').text(newName);
$('#confirmRenameGroup').find('#confirmNewGroupName').text(newName);

piwikHelper.modalConfirm('#confirmRenameGroup', {yes: function() {
sendRenameGroup(idGroup, newName, successCallback);
}});
Expand All @@ -218,24 +218,24 @@ $(document).ready(function () {
ajaxHandler.setErrorElement('#ajaxErrorManageGroupDelete');
ajaxHandler.send(true);
}

function bindDeleteGroup() {
var idGroup = $('#groupPermissionsCurrentIdGroup').val();
var name = $('#groupPermissionsCurrentGroupName').val();

function successCallback(response) {
location.reload();
}

$('#confirmDeleteGroup').find('#confirmDeleteGroupName').text(name);

piwikHelper.modalConfirm('#confirmDeleteGroup', {yes: function() {
sendDeleteGroup(idGroup, successCallback);
}});
}

function initializeUserSelect() {

var userSelect = new Choices('#groupPermissionsGroupAddUserSelect', {
allowHTML: false,
searchPlaceholderValue: 'Search for a user',
Expand Down Expand Up @@ -273,11 +273,11 @@ $(document).ready(function () {
tableBody.append('<tr><td class="login">'+login+'</td><td class="text-center">'
+'<button class="groupPermissionsRemoveUser btn btn-flat" data-login="'+login+'"><span class="icon-delete"></span></button>'
+'</td></tr>');

userSelect.setChoiceByValue('');
}
sendAddGroupMember(idGroup, login, successCallback);

sendAddGroupMember(idGroup, login, successCallback);
}

$('#groupPermissionsGroupAddUserButton').click(bindAddGroupMember);
Expand All @@ -293,19 +293,19 @@ $(document).ready(function () {
// when a group is selected, reload the page w/o showing the ajax loading element
$('#groupPermissionsGroupSelect').bind('change', function (e) {
piwik.broadcast.propagateNewPage('idGroup=' + encodeURIComponent($('#groupPermissionsGroupSelect').val()), false);
});
});

$('#groupPermissions .updateAccess').click(bindUpdateGroupPermissions);
$('#groupPermissionsGroup').on("click", ".groupPermissionsRemoveUser", bindRemoveGroupMember);

// $('#groupPermissionsGroup').on("click", ".groupPermissionsRemoveUser", bindRemoveGroupMember);

$('#groupPermissionsGroupRenameGroupButton').click(bindRenameGroup);

$('#groupPermissionsGroupDeleteGroupButton').click(bindDeleteGroup);

$('#groupPermissionsGroupCreateGroupButton').click(bindCreateGroup);

if ($('#groupPermissionsGroupAddUserSelect').length) {
initializeUserSelect();
// initializeUserSelect();
}
});
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"email": "[email protected]"
}],
"description": "Manage user permissions with groups.",
"version": "4.0.5",
"version": "5.0.0",
"theme": false,
"require": {
"matomo": ">=4.0.0-b1,<5.0.0-b1"
"matomo": ">=5.0.0-b1,<6.0.0-b1"
},
"keywords": [
"GroupPermissions",
Expand Down
11 changes: 6 additions & 5 deletions stylesheets/groupPermissions.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
font-weight: 700;
}

.groupPermissionsGroupAddUserWrapper .select-wrapper {
.groupPermissionsGroupAddUserWrapper {
.form-group, .row, .input-field {
margin: 0;
}

margin-bottom: 20px;

input.select-dropdown {
display: none;
.input-field {
padding-left: 0;
}
}
66 changes: 13 additions & 53 deletions templates/_groups.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,21 @@

<div class="card">
<div class="card-content">
<h2>{{ 'GroupPermissions_ManageGroup'|translate }}</h2>

<select name="idGroup" id="groupPermissionsGroupSelect">
{% for idgroup,name in groups %}
<option value="{{ idgroup }}" {% if selectedIdGroup==idgroup %}selected{% endif %}>{{ name }}</option>
{% endfor %}
</select>
<h2>{{ 'GroupPermissions_ManageGroup'|translate }}</h2>

<select name="idGroup" id="groupPermissionsGroupSelect">
{% for idgroup,name in groups %}
<option value="{{ idgroup }}" {% if selectedIdGroup==idgroup %}selected{% endif %}>{{ name }}</option>
{% endfor %}
</select>

<h3>{{ 'GroupPermissions_ManageGroupMembers'|translate }}</h3>

<div class="entityContainer" style="width:600px;margin-top:16px;">

<input type="hidden" id="groupPermissionsCurrentIdGroup" value="{{ selectedIdGroup }}" />
<input type="hidden" id="groupPermissionsCurrentGroupName" value="{{ selectedGroupName }}" />

<table class="entityTable dataTable" id="groupPermissionsGroup" style="display:inline-table;width:550px;">
<thead>
<tr>
<th>{{ 'General_Username'|translate }}</th>
<th>{{ 'GroupPermissions_RemoveFromGroup'|translate }}</th>
</tr>
</thead>

<tbody>
{% for login in groupUsers %}
<tr>
<td class='login'>{{ login }}</td>
<td class="text-center">
<button class="groupPermissionsRemoveUser btn btn-flat" title="{{ 'GroupPermissions_RemoveFromGroup'|translate }}" data-login="{{ login }}">
<span class="icon-delete"></span>
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div id="accessUpdated" style="vertical-align:top;"></div>
</div>

<div class="ui-confirm" id="confirmRemoveUserFromGroup">
<h2>{{ 'GroupPermissions_RemoveFromGroupConfirm'|translate("<span id='login'></span>", "<span id='group'></span>")|raw }}</h2>
<input role="yes" type="button" value="{{ 'General_Yes'|translate }}"/>
<input role="no" type="button" value="{{ 'General_No'|translate }}"/>
</div>

<div style="margin-top: 70px;">
<h3>{{ 'GroupPermissions_AddUserToGroup'|translate }}</h3>
<div class="groupPermissionsGroupAddUserWrapper">
<select id="groupPermissionsGroupAddUserSelect">
<option value="">Select a new member</option>
</select>
<input id="groupPermissionsGroupAddUserButton" type="button" value="{{ 'GroupPermissions_AddUserToGroupButton'|translate }}" style="padding: 8px;"/>
</div>
</div>
<div
vue-entry="GroupPermissions.ManageGroupMembers"
selected-id-group="{{ selectedIdGroup }}"
selected-group-name="{{ selectedGroupName }}"
users="{{ users|json_encode }}"
group-users="{{ groupUsers|json_encode }}"
></div>

<div style="padding: 10px 0 0 0;">
{% import 'ajaxMacros.twig' as ajax %}
Expand Down
Loading

0 comments on commit 44ea2ed

Please sign in to comment.