Skip to content

Commit

Permalink
Enable audit by configuration nextcloud#163
Browse files Browse the repository at this point in the history
- audit of following actions:
- user X created circle Z;
- user X removed circle Z;
- user X change name of circle Z for circle W;
- user X was added to circle U by user Z;
- user X shared file/folder with circle Y;
- user X, that created circle, unshared file/folder with circle Y
- member X accepted invitation to circle Y by user Z;
- member X left circle Y;
- user X change role of member Y in circle Z for W.
- user X was invited to circle U by user Z
- adjust circles to emit signals of sharing to activity
  • Loading branch information
Flávio Gomes da Silva Lisboa committed Oct 16, 2018
1 parent 8a2fdbb commit 48b51e5
Show file tree
Hide file tree
Showing 31 changed files with 945 additions and 143 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ Anyone can find the circle and request an invitation; but only members will see
- A **Secret Circle** is an hidden group that can only be seen by its members or by people knowing the exact name of the circle.
Non-members won't be able to find your secret circle using the search bar.

## Settings

Circles settings is available in Nextcloud interface in **Settings / Additional Settings**.

### Async Testing

This option allows to initiate an async test in Circles.

### Allow linking of groups

This option allows that groups be linked to circles.

### Allow federated circles

This option allows that circles from different Nextclouds can be linked together.

### Enable audit

This options allows that actions of circles, members and sharing can be audit with records into log. Following actions are audited:

* User X created circle Z;
* User X removed circle Z;
* User X change name of circle Z for circle W;
* User X was added to circle U by user Z;
* User X shared file/folder with circle Y;
* User X, that created circle, unshared file/folder with circle Y
* Member X accepted invitation to circle Y by user Z;
* Member X left circle Y;
* User X change role of member Y in circle Z for W.
* User X was invited to circle U by user Z

***
# API (PHP & Javascript)
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Users won't be able to find this Circle using Nextcloud search engine.
<repository>https://github.com/nextcloud/circles.git</repository>
<screenshot>https://raw.githubusercontent.com/nextcloud/circles/master/screenshots/0.12.0.png</screenshot>
<dependencies>
<nextcloud min-version="14" max-version="15"/>
<nextcloud min-version="13" max-version="15"/>
</dependencies>

<repair-steps>
Expand Down
32 changes: 16 additions & 16 deletions css/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
padding: 20px;
}

#circle-navigation .navigation-element, #circle-navigation .navigation-element option {
#app-navigation .navigation-element, #app-navigation .navigation-element option {
padding: 3px 12px;
}

#circle-navigation input#circles_search, #circle-navigation select#circles_filters {
#app-navigation input#circles_search, #app-navigation select#circles_filters {
margin: 10px;
width: 225px;
width: 285px;
}

#circle-navigation select#circles_filters {
#app-navigation select#circles_filters {
margin-top: 0;
font-style: italic;
color: #777777;
}

#circle-navigation input, #circle-navigation select, #circle-navigation option {
#app-navigation input, #app-navigation select, #app-navigation option {
width: 100%;
box-sizing: border-box;
background: #ffffffaa !important;
Expand All @@ -29,7 +29,7 @@
overflow-x: hidden;
}

#circle-navigation .header {
#app-navigation .header {
padding: 0 12px;
line-height: 44px;
min-height: 44px;
Expand All @@ -39,7 +39,7 @@
#circles_new_type_definition div {
margin-top: 20px;
position: absolute;
width: 190px;
width: 255px;
color: #474747b0;
word-wrap: break-word;
}
Expand All @@ -51,7 +51,7 @@ SELECT.select_none {
#circles_list, #circles_list .lightenbg {
position: absolute;
width: 100%;
top: 350px;
top: 300px;
}

#circles_list div {
Expand All @@ -75,28 +75,28 @@ SELECT.select_none {
font-weight: bold !important;
}

#circle-navigation {
#app-navigation {
width: 300px;
border-right: 1px solid #ddd;
}

#circle-navigation.circles {
#app-navigation.circles {
overflow-y: auto;
width: 350px;
overflow-x: hidden;
z-index: 1002;
}

#circle-navigation.circles, #circle-navigation.circles .circle, #circle-navigation.circles .selected {
#app-navigation.circles, #app-navigation.circles .circle, #app-navigation.circles .selected {
-webkit-transition: background-color 0.3s ease-in;
transition: background-color 0.3s ease-in;
}

#circle-navigation.selected {
#app-navigation.selected {
background: #ededed !important;
}

#circle-navigation.circles .selected {
#app-navigation.circles .selected {
background: #e5e5e5;
}

Expand Down Expand Up @@ -216,8 +216,8 @@ div.circle .owner, div.circle .type, div.circle .resume {

#emptycontent {
position: absolute;
z-index: 1001;
left: 0px;
z-index: -99;
left: 200px;
}

#circle-actions {
Expand Down Expand Up @@ -354,4 +354,4 @@ DIV.result_bot {
padding: 5px;
height: 10px;
font-style: italic;
}
}
15 changes: 13 additions & 2 deletions js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ var elements = {
// test_async_wait: null,
members_limit: null,
allow_linked_groups: null,
allow_federated_circles: null
allow_federated_circles: null,
disable_notification_for_seen_users: null
};


Expand All @@ -46,6 +47,7 @@ $(document).ready(function () {
elements.members_limit = $('#members_limit');
elements.allow_linked_groups = $('#allow_linked_groups');
elements.allow_federated_circles = $('#allow_federated_circles');
elements.disable_notification_for_seen_users = $('#disable_notification_for_seen_users');

// elements.test_async_wait.hide().on('click', function () {
// self.refreshResult();
Expand Down Expand Up @@ -81,6 +83,11 @@ $(document).ready(function () {
elements.allow_federated_circles.on('change', function () {
saveChange();
});

elements.disable_notification_for_seen_users.on('change', function () {
saveChange();
});


saveChange = function () {
$.ajax({
Expand All @@ -91,12 +98,15 @@ $(document).ready(function () {
allow_linked_groups: (elements.allow_linked_groups.is(
':checked')) ? '1' : '0',
allow_federated_circles: (elements.allow_federated_circles.is(
':checked')) ? '1' : '0'
':checked')) ? '1' : '0',
disable_notification_for_seen_users: (elements.disable_notification_for_seen_users.is(
':checked')) ? '1' : '0'
}
}).done(function (res) {
elements.members_limit.val(res.membersLimit);
elements.allow_linked_groups.prop('checked', (res.allowLinkedGroups === '1'));
elements.allow_federated_circles.prop('checked', (res.allowFederatedCircles === '1'));
elements.disable_notification_for_seen_users.prop('checked', (res.disableNotificationForSeenUsers === '1'));
});
};

Expand Down Expand Up @@ -180,6 +190,7 @@ $(document).ready(function () {
elements.members_limit.val(res.membersLimit);
elements.allow_linked_groups.prop('checked', (res.allowLinkedGroups === '1'));
elements.allow_federated_circles.prop('checked', (res.allowFederatedCircles === '1'));
elements.disable_notification_for_seen_users.prop('checked', (res.disableNotificationForSeenUsers === '1'));
});
//
// var timerTestAsync = setInterval(function () {
Expand Down
6 changes: 5 additions & 1 deletion js/circles.app.elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ var elements = {
settingsDesc: null,
settingsLimit: null,
settingsEntryLimit: null,
settingsNotification: null,
settingsLink: null,
settingsLinkAuto: null,
settingsLinkFiles: null,
settingsEntryLink: null,
settingsEntryLinkAuto: null,
settingsEntryLinkFiles: null,
settingsEntryNotification: null,
settingsSave: null,

addMember: null,
Expand All @@ -98,7 +100,7 @@ var elements = {
elements.newType = $('#circles_new_type');
elements.newSubmit = $('#circles_new_submit');
elements.newName = $('#circles_new_name');
elements.navigation = $('#circle-navigation.circles');
elements.navigation = $('#app-navigation.circles');
elements.circlesList = $('#circles_list');
elements.circlesSearch = $('#circles_search');
elements.circlesFilters = $('#circles_filters');
Expand Down Expand Up @@ -139,9 +141,11 @@ var elements = {
elements.settingsLink = $('#settings-link');
elements.settingsLinkAuto = $('#settings-link-auto');
elements.settingsLinkFiles = $('#settings-link-files');
elements.settingsNotification = $('#settings-notification')
elements.settingsEntryLink = $('#settings-entry-link');
elements.settingsEntryLinkAuto = $('#settings-entry-link-auto');
elements.settingsEntryLinkFiles = $('#settings-entry-link-files');
elements.settingsEntryNotification = $('#settings-entry-notification');
elements.settingsSave = $('#settings-submit');

elements.addMember = $('#addmember');
Expand Down
1 change: 1 addition & 0 deletions js/circles.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var curr = {
allowed_linked_groups: 0,
allowed_federated_circles: 0,
allowed_circles: 0,
disabled_notification_for_seen_users: 0,

defineCircle: function (data) {
curr.circle = data.circle_id;
Expand Down
4 changes: 4 additions & 0 deletions js/circles.app.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ var settings = {
(curr.circleSettings['allow_links_auto'] === 'true'));
elements.settingsLinkFiles.prop('checked',
(curr.circleSettings['allow_links_files'] === 'true'));
elements.settingsNotification.prop('checked',
(curr.circleSettings['disable_notification_for_seen_users'] === 'true'));

elements.settingsLink.on('change', function () {
settings.interactUISettings();
Expand All @@ -86,6 +88,8 @@ var settings = {
(elements.settingsLink.is(":checked")));
settings.enableSetting(elements.settingsEntryLinkFiles, elements.settingsLinkFiles,
(elements.settingsLink.is(":checked")));
settings.enableSetting(elements.settingsEntryNotification, elements.settingsNotification,
(elements.settingsNotification.is(":checked")));
},

enableSetting: function (entry, input, enable) {
Expand Down
2 changes: 1 addition & 1 deletion js/circles.v1.members.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var members = {


searchUsers: function (search, callback) {

$('#addmember').val(t('Searching for users like...') + search);
var result = {status: -1};
$.ajax({
method: 'GET',
Expand Down
10 changes: 9 additions & 1 deletion l10n/pt_BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ OC.L10N.register(
"Members limit:" : "Limite de membros:",
"Default limit to the number of members in a circle." : "Limite de membros em um círculo.",
"Allow linking of groups:" : "Permitir links dos grupos:",
"Allow federated circles:" : "Permitir círculos federados:"
"Allow federated circles:" : "Permitir círculos federados:",
"You shared {file} with circle {circle}" : "Você compartilhou {file} com o círculo {circle}",
"{author} shared {file} with the circle {circle}" : "{author} compartilhou {file} com o círculo {circle}",
"You unshared {file} with the circle {circle}" : "Você descompartilhou {file} com o círculo {circle}",
"{author} unshared {file} with the circle {circle}" : "{author} descompartilhou {file} com o círculo {circle}",
"Searching for users like..." : "Buscando por usuários como...",
"Disable notification for seen users." : "Desabilita notificação para usuários vistos.",
"You changed circle {circle}" : "Você alterou {circle}",
"{author} changed circle {circle}" : "{author} alterou o círculo {circle}"
},
"nplurals=2; plural=(n > 1);");
10 changes: 9 additions & 1 deletion l10n/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@
"Members limit:" : "Limite de membros:",
"Default limit to the number of members in a circle." : "Limite de membros em um círculo.",
"Allow linking of groups:" : "Permitir links dos grupos:",
"Allow federated circles:" : "Permitir círculos federados:"
"Allow federated circles:" : "Permitir círculos federados:",
"You shared {file} with circle {circle}" : "Você compartilhou {file} com o círculo {circle}",
"{author} shared {file} with the circle {circle}" : "{author} compartilhou {file} com o círculo {circle}",
"You unshared {file} with the circle {circle}" : "Você descompartilhou {file} com o círculo {circle}",
"{author} unshared {file} with the circle {circle}" : "{author} descompartilhou {file} com o círculo {circle}",
"Searching for users like..." : "Buscando por usuários como...",
"Disable notification for seen users." : "Desabilita notificação para usuários vistos.",
"You changed circle {circle}" : "Você alterou o círculo {circle}",
"{author} changed circle {circle}" : "{author} alterou o círculo {circle}"
},"pluralForm" :"nplurals=2; plural=(n > 1);"
}
31 changes: 27 additions & 4 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class Provider implements IProvider {

/** @var ProviderSubjectLink */
private $parserLink;

/** @var ProviderSubjectShared */
private $parserShared;

/** @var MiscService */
protected $miscService;
Expand All @@ -66,7 +69,7 @@ class Provider implements IProvider {
public function __construct(
IManager $activityManager, MiscService $miscService, ProviderSubjectCircle $parserCircle,
ProviderSubjectMember $parserMember, ProviderSubjectGroup $parserGroup,
ProviderSubjectLink $parserLink
ProviderSubjectLink $parserLink, ProviderSubjectShared $parserShared
) {
$this->activityManager = $activityManager;
$this->miscService = $miscService;
Expand All @@ -75,6 +78,7 @@ public function __construct(
$this->parserMember = $parserMember;
$this->parserGroup = $parserGroup;
$this->parserLink = $parserLink;
$this->parserShared = $parserShared;
}


Expand All @@ -92,9 +96,11 @@ public function parse($lang, IEvent $event, IEvent $previousEvent = null) {
$this->setIcon($event, $circle);
$this->parseAsMember($event, $circle, $params);
$this->parseAsModerator($event, $circle, $params);

} catch (FakeException $e) {
/** clean exit */
} catch (InvalidArgumentException $e) {
/** sharing is a special case because app is files **/
$this->parseShared($event, $params);
}

return $event;
Expand All @@ -110,7 +116,7 @@ private function initActivityParser(IEvent $event, $params) {
throw new InvalidArgumentException();
}

if (!key_exists('circle', $params)) {
if ($event->getApp() === Application::APP_NAME && !key_exists('circle', $params)) {
throw new InvalidArgumentException();
}
}
Expand Down Expand Up @@ -161,6 +167,7 @@ private function parseAsModerator(IEvent &$event, Circle $circle, $params) {
return;
}

$this->parserCircle->parseSubjectCircleChange($event, $circle, $params);
$this->parseMemberAsModerator($event, $circle, $params);
$this->parseGroupAsModerator($event, $circle, $params);
$this->parseLinkAsModerator($event, $circle, $params);
Expand Down Expand Up @@ -252,5 +259,21 @@ private function parseLinkAsModerator(IEvent &$event, Circle $circle, $params) {
$this->parserLink->parseLinkRemove($event, $circle, $remote);
}


/**
* @param IEvent $event
* @param array $params
*
* @throws FakeException
*/
private function parseShared(IEvent &$event, $params) {
if ($event->getSubject() === 'shared_circle_self') {
$this->parserShared->parseSubjectSharedWithCircle($event, $params);
return;
}
if ($event->getSubject() === 'unshared_circle_self') {
$this->parserShared->parseSubjectUnsharedWithCircle($event, $params);
return;
}
throw new InvalidArgumentException();
}
}
Loading

0 comments on commit 48b51e5

Please sign in to comment.