- * @copyright 2017
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-/** global: OC */
-/** global: OCA */
-/** global: Notyf */
-
-/** global: actions */
-/** global: nav */
-/** global: elements */
-/** global: curr */
-/** global: api */
-
-
-
-var resultMembers = {
-
-
- generateItemResult: function(search, value) {
-
- switch (value.type) {
- case define.typeUser:
- return resultMembers.generateItemUser(search, value);
- case define.typeGroup:
- return resultMembers.generateItemGroup(search, value);
- case define.typeContact:
- return resultMembers.generateItemContact(search, value);
- }
- },
-
-
- enhanceSearchResult: function(search, display) {
- display = nav.escapeHtml(display);
- if (search.length > 0) {
- display = display.replace(new RegExp('(' + search + ')', 'gi'), '$1');
- }
-
- return display;
- },
-
-
- generateItemUser: function(search, value) {
- var instance = value.instance;
- if (instance !== '') {
- return '' +
- resultMembers.enhanceSearchResult(search, value.data.display) + '
' +
- '' + t('circles', 'Global Scale User') + ' (' + instance + ')
';
- }
-
- return '' +
- resultMembers.enhanceSearchResult(search, value.data.display) + '
' +
- '' + t('circles', 'Local User') + '
';
- },
-
- generateItemGroup: function(search, value) {
- return '' +
- resultMembers.enhanceSearchResult(search, value.data.display) + '
' +
- '' + t('circles', 'Local Group') + '
';
- },
-
- generateItemContact: function(search, value) {
- var display = resultMembers.enhanceSearchResult(search, value.data.display);
- var email = resultMembers.enhanceSearchResult(search, value.data.email);
- var org = resultMembers.enhanceSearchResult(search, value.data.organization);
- if (email !== '') {
- email = ' - ' + email;
- }
-
- if (org !== '') {
- display += ' (' + org + ')';
- }
-
- return '' + display + '
' +
- '' + t('circles', 'Contact') + email + '
';
- },
-
-
- searchMembersResult: function(response) {
- if (response === null) {
- elements.membersSearchResult.children().remove();
- elements.membersSearchResult.fadeOut(0);
- return;
- }
-
- if (response.order < curr.searchOrderDisplayed) {
- return;
- }
-
- elements.membersSearchResult.children().remove();
- curr.searchOrderDisplayed = response.order;
-
- var currSearch = response.search;
- $.each(response.result, function(index, value) {
- elements.membersSearchResult.append('' +
- resultMembers.generateItemResult(currSearch, value) + '
'
- )
- ;
- });
-
- $('.members_search').on('click', function() {
- var ident = $(this).attr('data-ident');
- var type = $(this).attr('data-type');
- var instance = $(this).attr('data-instance');
- if (instance === undefined) {
- instance = '';
- }
- if (Number(type) === define.typeGroup) {
-
- OC.dialogs.confirm(
- t('circles',
- 'This operation will add/invite all members of the group to the circle'),
- t('circles', 'Please confirm'),
- function(e) {
- if (e === true) {
- api.addMember(curr.circle, ident, type, instance,
- resultMembers.addMemberResult);
- }
- });
-
- } else {
- api.addMember(curr.circle, ident, type, instance, resultMembers.addMemberResult);
- }
-
- elements.membersSearchResult.hide(100);
- });
-
- // elements.fillMembersSearch('users', response.ocs.data.exact.users,
- // response.ocs.data.users); elements.fillMembersSearch('groups',
- // response.ocs.data.exact.groups, response.ocs.data.groups); if
- // (elements.membersSearchResult.children().length === 0) {
- // elements.membersSearchResult.fadeOut(0); return; } $('.members_search').on('click',
- // function () { curr.searchUserSelected = $(this).attr('searchresult'); if
- // ($(this).attr('source') === 'groups') { OC.dialogs.confirm( t('circles', 'This
- // operation will add/invite all members of the group to the circle'), t('circles', 'Please
- // confirm'), function (e) { if (e === true) { api.addGroupMembers(curr.circle,
- // curr.searchUserSelected, resultMembers.addGroupMembersResult); } }); } else {
- // api.addMember(curr.circle, curr.searchUserSelected, resultMembers.addMemberResult); } });
- elements.membersSearchResult.fadeIn(300);
- },
-
-
- addMemberResult: function(result) {
- resultMembers.addMemberUserResult(result);
- resultMembers.addMemberGroupResult(result);
- resultMembers.addMemberMailResult(result);
- resultMembers.addMemberContactResult(result);
- },
-
-
- addMemberUserResult: function(result) {
- if (result.user_type !== define.typeUser) {
- return;
- }
-
- if (curr.circleDetails.type === define.typeClosed) {
- resultMembers.inviteMemberResult(result);
- return;
- }
-
- if (result.status === 1) {
- OCA.notification.onSuccess(t('circles', "A new member was added to the circle"));
-
- nav.displayMembers(result.members);
- return;
- }
-
- OCA.notification.onFail(
- t('circles', "Member could not be added to the circle") +
- ': ' + ((result.error) ? result.error : t('circles', 'no error message')));
- },
-
-
- addMemberMailResult: function(result) {
- if (result.user_type !== define.typeMail) {
- return;
- }
-
- if (result.status === 1) {
- OCA.notification.onSuccess(
- t('circles', "The email address '{email}' was added to the circle",
- {email: result.display}));
-
- nav.displayMembers(result.members);
- return;
- }
- OCA.notification.onFail(
- t('circles', "The email address '{email}' could not be added to the circle",
- {email: result.display}) +
- ': ' + ((result.error) ? result.error : t('circles', 'no error message')));
- },
-
- addMemberContactResult: function(result) {
- if (result.user_type !== define.typeContact) {
- return;
- }
-
- if (result.status === 1) {
- OCA.notification.onSuccess(t('circles', "A new contact was added to the circle"));
-
- nav.displayMembers(result.members);
- return;
- }
- OCA.notification.onFail(
- t('circles', "Contact could not be added to the circle") +
- ': ' + ((result.error) ? result.error : t('circles', 'no error message')));
- },
-
-
- inviteMemberResult: function(result) {
-
- if (result.status === 1) {
- OCA.notification.onSuccess(
- t('circles', "A new member was invited to the circle"));
-
- nav.displayMembers(result.members);
- return;
- }
- OCA.notification.onFail(
- t('circles', "Member could not be invited to the circle") +
- ': ' + ((result.error) ? result.error : t('circles', 'no error message')));
- },
-
-
- addMemberGroupResult: function(result) {
-
- if (result.user_type !== define.typeGroup) {
- return;
- }
-
- if (curr.circleDetails.type === define.typeClosed) {
- resultMembers.inviteMemberGroupResult(result);
- return;
- }
-
- if (result.status === 1) {
- OCA.notification.onSuccess(
- t('circles', "Members of the group '{name}' were added to the circle",
- {name: result.display}));
-
- nav.displayMembers(result.members);
- return;
- }
- OCA.notification.onFail(
- t('circles', "Members of the group '{name}' could not be added to the circle",
- {name: result.display}) +
- ': ' +
- ((result.error) ? result.error : t('circles', 'no error message')));
- },
-
-
- inviteMemberGroupResult: function(result) {
-
- if (result.status === 1) {
- OCA.notification.onSuccess(
- t('circles', "Members of the group '{name}' were invited to the circle",
- {name: result.display}));
-
- nav.displayMembers(result.members);
- return;
- }
- OCA.notification.onFail(
- t('circles', "Members of the group '{name}' could not be invited to the circle",
- {name: result.display}) +
- ': ' +
- ((result.error) ? result.error : t('circles', 'no error message')));
- },
-
-
- removeMemberResult: function(result) {
- if (result.status === 1) {
-
- elements.mainUIMembersTable.children("[member-id='" + result.user_id + "']").each(
- function() {
- if (Number($(this).attr('member-type')) === result.user_type) {
- $(this).hide(300);
- }
- });
- OCA.notification.onSuccess(t('circles', "Member was removed from the circle"));
- return;
- }
-
- OCA.notification.onFail(
- t('circles', "Member could not be removed from the circle") +
- ': ' + ((result.error) ? result.error : t('circles', 'no error message')));
- },
-
- levelMemberResult: function(result) {
- if (result.status === 1) {
- OCA.notification.onSuccess(
- t('circles', "Member updated"));
-
- nav.displayMembers(result.members);
- return;
- }
-
- nav.displayMembers('');
- OCA.notification.onFail(
- t('circles', "Member could not be updated") + ': ' +
- ((result.error) ? result.error : t('circles', 'no error message')));
- }
-
-};
diff --git a/js/circles.app.settings.js b/js/circles.app.settings.js
deleted file mode 100644
index 97a429a0..00000000
--- a/js/circles.app.settings.js
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Circles - Bring cloud-users closer together.
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange
- * @copyright 2017
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-/** global: OC */
-/** global: OCA */
-/** global: Notyf */
-
-/** global: curr */
-/** global: define */
-/** global: elements */
-/** global: nav */
-
-var settings = {
-
- displaySettings: function(display) {
- if (display) {
- settings.initUISettings();
- elements.circleDesc.hide(define.animationSpeed);
- elements.mainUIMembers.hide(define.animationSpeed);
- elements.settingsPanel.delay(define.animationSpeed).show(define.animationSpeed);
- } else {
- elements.settingsPanel.hide(define.animationSpeed);
- elements.mainUIMembers.delay(define.animationSpeed).show(define.animationSpeed);
- }
- },
-
- initUISettings: function() {
- elements.settingsName.val(curr.circleName);
- elements.settingsDesc.val(curr.circleDesc);
- elements.settingsLimit.val(curr.circleLimit);
-
-
-// single-password-enabled
- elements.settingsPassword.prop('checked',
- (curr.circleSettings['password_enforcement'] === 'true'));
- elements.settingsPassword.on('change', function() {
- settings.interactUISettings();
- });
-
- elements.settingsSinglePassword.val('');
- elements.settingsSinglePasswordEnabled.prop('checked',
- (curr.circleSettings['password_single_enabled'] === 'true'));
- elements.settingsSinglePasswordEnabled.on('change', function() {
- settings.interactUISettings();
- });
-
- if (OC.isUserAdmin()) {
- elements.settingsEntryLimit.show();
- } else {
- elements.settingsEntryLimit.hide();
- }
-
- elements.settingsLink.prop('checked', (curr.circleSettings['allow_links'] === 'true'));
- elements.settingsLinkAuto.prop('checked',
- (curr.circleSettings['allow_links_auto'] === 'true'));
- elements.settingsLinkFiles.prop('checked',
- (curr.circleSettings['allow_links_files'] === 'true'));
-
- elements.settingsLink.on('change', function() {
- settings.interactUISettings();
- });
-
- settings.interactUISettings();
- },
-
-
- interactUISettings: function() {
- if (elements.settingsPassword.is(":checked")) {
- settings.enableSetting(elements.settingsEntrySinglePassword, elements.settingsSinglePassword,
- true);
- settings.enableSetting(null, elements.settingsSinglePasswordEnabled, true);
- if (elements.settingsSinglePasswordEnabled.is(":checked")) {
- settings.enableSetting(null, elements.settingsSinglePassword, true);
- } else {
- settings.enableSetting(null, elements.settingsSinglePassword,
- false);
- }
- } else {
- settings.enableSetting(null, elements.settingsSinglePasswordEnabled, false);
- settings.enableSetting(elements.settingsEntrySinglePassword, elements.settingsSinglePassword,
- false);
- }
-
- if (curr.allowed_federated_circles !== '1' ||
- curr.circleDetails.type === define.typePersonal) {
- settings.enableSetting(elements.settingsEntryLink, elements.settingsLink, false);
- settings.enableSetting(elements.settingsEntryLinkAuto, elements.settingsLinkAuto,
- false);
- settings.enableSetting(elements.settingsEntryLinkFiles, elements.settingsLinkFiles,
- false);
- return;
- }
- settings.enableSetting(elements.settingsEntryLink, elements.settingsLink, true);
- settings.enableSetting(elements.settingsEntryLinkAuto, elements.settingsLinkAuto,
- (elements.settingsLink.is(":checked")));
- settings.enableSetting(elements.settingsEntryLinkFiles, elements.settingsLinkFiles,
- (elements.settingsLink.is(":checked")));
- },
-
- enableSetting: function(entry, input, enable) {
- if (entry !== null) {
- entry.stop().fadeTo(curr.animationSpeed, (enable) ? 1 : 0.3);
- }
- input.prop('disabled', !enable);
- },
-
- saveSettingsResult: function(result) {
- if (result.status < 1) {
- OCA.notification.onFail(
- t('circles', 'Issue while saving settings') + ': ' +
- ((result.error) ? result.error : t('circles', 'no error message')));
- return;
- }
-
- nav.circlesActionReturn();
- curr.defineCircle(result);
- nav.displayCircleDetails(result.details);
- nav.displayMembersInteraction(result.details);
- OCA.notification.onSuccess(t('circles', "Settings saved."));
- }
-};
-
-
-
diff --git a/js/circles.v1.circles.js b/js/circles.v1.circles.js
deleted file mode 100644
index 2dc64a97..00000000
--- a/js/circles.v1.circles.js
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Circles - Bring cloud-users closer together.
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange
- * @copyright 2017
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-/** global: OC */
-/** global: OCA */
-
-var circles = {
-
- createCircle: function (type, name, callback) {
- OCA.Circles.api.request({
- method: 'PUT',
- url: OC.generateUrl('/apps/circles/v1/circles'),
- data: {
- type: type,
- name: name
- }
- }, callback);
- },
-
-
- listCircles: function (type, name, level, callback) {
- OCA.Circles.api.request({
- method: 'GET',
- url: OC.generateUrl('/apps/circles/v1/circles'),
- data: {
- type: type,
- name: name,
- level: level
- }
- }, callback);
- },
-
-
- detailsCircle: function (circleId, callback) {
- OCA.Circles.api.request({
- method: 'GET',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId)
- }, callback);
- },
-
-
- joinCircle: function (circleId, callback) {
- OCA.Circles.api.request({
- method: 'GET',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/join'),
- data: {}
- }, callback);
- },
-
-
- settingsCircle: function (circleId, settings, callback) {
- OCA.Circles.api.request({
- method: 'POST',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/settings'),
- data: {settings: settings}
- }, callback);
- },
-
-
- leaveCircle: function (circleId, callback) {
- OCA.Circles.api.request({
- method: 'GET',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/leave'),
- data: {}
- }, callback);
- },
-
-
- destroyCircle: function (circleId, callback) {
- OCA.Circles.api.request({
- method: 'DELETE',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId),
- data: {}
- }, callback);
- }
-
-};
-
diff --git a/js/circles.v1.js b/js/circles.v1.js
deleted file mode 100644
index cc0eb48a..00000000
--- a/js/circles.v1.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Circles - Bring cloud-users closer together.
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange
- * @copyright 2017
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-/** global: OC */
-/** global: OCA */
-
-(function () {
-
-
- /**
- * @constructs Circles
- */
- var Circles = function () {
-
- $.extend(Circles.prototype, circles);
- $.extend(Circles.prototype, members);
- $.extend(Circles.prototype, links);
-
- this.initialize();
- };
-
- Circles.prototype = {
-
-
- initialize: function () {
-
- var self = this;
-
-
- this.shareToCircle = function (circleId, source, type, item, callback) {
- self.request({
- method: 'PUT',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/share'),
- data: {
- source: source,
- type: type,
- item: item
- }
- }, callback)
- };
-
- this.request = function (options, callback) {
- var result = {status: -1};
- $.ajax(options)
- .done(function (res) { self.onCallback(callback, res); })
- .fail(function () { self.onCallback(callback, result); });
- };
-
- this.onCallback = function (callback, result) {
- if (callback && (typeof callback === 'function')) {
- if (typeof result === 'object') {
- callback(result);
- } else {
- callback({status: -1});
- }
- }
- };
-
- }
-
- };
-
- OCA.Circles = Circles;
- OCA.Circles.api = new Circles();
-
-})();
-
-
diff --git a/js/circles.v1.links.js b/js/circles.v1.links.js
deleted file mode 100644
index 5d14288f..00000000
--- a/js/circles.v1.links.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Circles - Bring cloud-users closer together.
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange
- * @copyright 2017
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-
-/** global: OC */
-/** global: OCA */
-
-var links = {
-
- linkCircle: function (circleId, remote, callback) {
- OCA.Circles.api.request({
- method: 'POST',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/link'),
- data: {
- remote: remote
- }
- }, callback);
- },
-
-
- linkStatus: function (linkId, status, callback) {
- OCA.Circles.api.request({
- method: 'POST',
- url: OC.generateUrl('/apps/circles/v1/link/' + linkId + '/status'),
- data: {
- status: status
- }
- }, callback);
- },
-
-
- linkGroup: function (circleId, groupId, callback) {
- OCA.Circles.api.request({
- method: 'PUT',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/groups'),
- data: {
- name: groupId
- }
- }, callback);
- },
-
-
- unlinkGroup: function (circleId, groupId, callback) {
- OCA.Circles.api.request({
- method: 'DELETE',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/groups'),
- data: {
- group: groupId
- }
- }, callback);
- },
-
-
- levelGroup: function (circleId, group, level, callback) {
- OCA.Circles.api.request({
- method: 'POST',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/group/level'),
- data: {
- group: group,
- level: level
- }
- }, callback);
- }
-
-};
diff --git a/js/circles.v1.members.js b/js/circles.v1.members.js
deleted file mode 100644
index c6568582..00000000
--- a/js/circles.v1.members.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Circles - Bring cloud-users closer together.
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Maxence Lange
- * @copyright 2017
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- *
- */
-
-/** global: OC */
-/** global: OCA */
-/** global: curr */
-
-var members = {
-
- searchUsers: function(search, callback) {
- curr.searchOrder++;
- OCA.Circles.api.request({
- method: 'GET',
- url: OC.generateUrl('/apps/circles/v1/globalsearch'),
- data: {
- search: search,
- order: curr.searchOrder
- }
- }, callback);
- },
-
-
- addMember: function(circleId, ident, type, instance, callback) {
- OCA.Circles.api.request({
- method: 'PUT',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'),
- data: {
- ident: ident,
- type: type,
- instance: instance
- }
- }, callback);
- },
-
-
- removeMember: function(circleId, userId, userType, instance, callback) {
- OCA.Circles.api.request({
- method: 'DELETE',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/member'),
- data: {
- member: userId,
- type: Number(userType),
- instance: instance
- }
- }, callback);
- },
-
-
- levelMember: function(circleId, userId, userType, instance, level, callback) {
- OCA.Circles.api.request({
- method: 'POST',
- url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/level'),
- data: {
- member: userId,
- type: userType,
- instance: instance,
- level: level
- }
- }, callback);
- }
-
-
-};
-
diff --git a/js/vendor/notyf.js b/js/vendor/notyf.js
deleted file mode 100644
index 96f1d773..00000000
--- a/js/vendor/notyf.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(){function n(n,t){for(property in t)t.hasOwnProperty(property)&&(n[property]=t[property]);return n}function t(n,t){var e=document.createElement("div");e.className="notyf__toast";var o=document.createElement("div");o.className="notyf__wrapper";var i=document.createElement("div");i.className="notyf__icon";var a=document.createElement("i");a.className=t;var r=document.createElement("div");r.className="notyf__message",r.innerHTML=n,i.appendChild(a),o.appendChild(i),o.appendChild(r),e.appendChild(o);var c=this;return setTimeout(function(){e.className+=" notyf--disappear",e.addEventListener(c.animationEnd,function(n){n.target==e&&c.container.removeChild(e)});var n=c.notifications.indexOf(e);c.notifications.splice(n,1)},c.options.delay),e}function e(){var n,t=document.createElement("fake"),e={transition:"animationend",OTransition:"oAnimationEnd",MozTransition:"animationend",WebkitTransition:"webkitAnimationEnd"};for(n in e)if(void 0!==t.style[n])return e[n]}this.Notyf=function(){this.notifications=[];var t={delay:2e3,alertIcon:"notyf__icon--alert",confirmIcon:"notyf__icon--confirm"};arguments[0]&&"object"==typeof arguments[0]?this.options=n(t,arguments[0]):this.options=t;var o=document.createDocumentFragment(),i=document.createElement("div");i.className="notyf",o.appendChild(i),document.body.appendChild(o),this.container=i,this.animationEnd=e()},this.Notyf.prototype.alert=function(n){var e=t.call(this,n,this.options.alertIcon);e.className+=" notyf--alert",this.container.appendChild(e),this.notifications.push(e)},this.Notyf.prototype.confirm=function(n){var e=t.call(this,n,this.options.confirmIcon);e.className+=" notyf--confirm",this.container.appendChild(e),this.notifications.push(e)}}(),function(){"function"==typeof define&&define.amd?define("Notyf",function(){return Notyf}):"undefined"!=typeof module&&module.exports?module.exports=Notyf:window.Notyf=Notyf}();
\ No newline at end of file
diff --git a/lib/Command/MembersSearch.php b/lib/Command/MembersSearch.php
new file mode 100644
index 00000000..2c2c26c1
--- /dev/null
+++ b/lib/Command/MembersSearch.php
@@ -0,0 +1,132 @@
+
+ * @copyright 2021
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+
+namespace OCA\Circles\Command;
+
+
+use OC\Core\Command\Base;
+use OCA\Circles\Model\FederatedUser;
+use OCA\Circles\Model\Member;
+use OCA\Circles\Service\ConfigService;
+use OCA\Circles\Service\SearchService;
+use Symfony\Component\Console\Helper\Table;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\ConsoleOutput;
+use Symfony\Component\Console\Output\OutputInterface;
+
+
+/**
+ * Class MembersSearch
+ *
+ * @package OCA\Circles\Command
+ */
+class MembersSearch extends Base {
+
+
+ /** @var SearchService */
+ private $searchService;
+
+ /** @var ConfigService */
+ private $configService;
+
+
+ /**
+ * MembersSearch constructor.
+ *
+ * @param SearchService $searchService
+ * @param ConfigService $configService
+ */
+ public function __construct(SearchService $searchService, ConfigService $configService) {
+ parent::__construct();
+ $this->searchService = $searchService;
+ $this->configService = $configService;
+ }
+
+
+ protected function configure() {
+ parent::configure();
+ $this->setName('circles:members:search')
+ ->setDescription('Change the level of a member from a Circle')
+ ->addArgument('needle', InputArgument::REQUIRED, 'search')
+ ->addOption('json', '', InputOption::VALUE_NONE, 'return result as JSON')
+ ->addOption('initiator', '', InputOption::VALUE_REQUIRED, 'set an initiator to the request', '')
+ ->addOption('status-code', '', InputOption::VALUE_NONE, 'display status code on exception');
+ }
+
+
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ *
+ * @return int
+ */
+ protected function execute(InputInterface $input, OutputInterface $output): int {
+ $needle = $input->getArgument('needle');
+
+ $result = $this->searchService->search($needle);
+
+ if ($input->getOption('json')) {
+ $output->writeln(json_encode($result, JSON_PRETTY_PRINT));
+ }
+
+ $this->displaySearchResult($result);
+
+ return 0;
+ }
+
+
+ /**
+ * @param FederatedUser[] $result
+ */
+ private function displaySearchResult(array $result) {
+ $output = new ConsoleOutput();
+ $output = $output->section();
+ $table = new Table($output);
+ $table->setHeaders(['SingleId', 'UserId', 'UserType', 'Instance']);
+ $table->render();
+
+ $local = $this->configService->getFrontalInstance();
+ foreach ($result as $entry) {
+ $table->appendRow(
+ [
+ $entry->getSingleId(),
+ $entry->getUserId(),
+ Member::$DEF_TYPE[$entry->getUserType()],
+ ($entry->getInstance() === $local) ? '' : $entry->getInstance(),
+ ]
+ );
+ }
+ }
+
+}
+
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php
index 4d707c05..2775a8d4 100644
--- a/lib/Controller/LocalController.php
+++ b/lib/Controller/LocalController.php
@@ -44,6 +44,7 @@ use OCA\Circles\Service\CircleService;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\FederatedUserService;
use OCA\Circles\Service\MemberService;
+use OCA\Circles\Service\SearchService;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
@@ -75,6 +76,9 @@ class LocalController extends OcsController {
/** @var MemberService */
private $memberService;
+ /** @var SearchService */
+ private $searchService;
+
/** @var ConfigService */
protected $configService;
@@ -88,18 +92,20 @@ class LocalController extends OcsController {
* @param FederatedUserService $federatedUserService
* @param CircleService $circleService
* @param MemberService $memberService
+ * @param SearchService $searchService
* @param ConfigService $configService
*/
public function __construct(
string $appName, IRequest $request, IUserSession $userSession,
FederatedUserService $federatedUserService, CircleService $circleService,
- MemberService $memberService, ConfigService $configService
+ MemberService $memberService, SearchService $searchService, ConfigService $configService
) {
parent::__construct($appName, $request);
$this->userSession = $userSession;
$this->federatedUserService = $federatedUserService;
$this->circleService = $circleService;
$this->memberService = $memberService;
+ $this->searchService = $searchService;
$this->configService = $configService;
$this->setup('app', 'circles');
@@ -127,6 +133,25 @@ class LocalController extends OcsController {
}
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $needle
+ *
+ * @return DataResponse
+ * @throws OCSException
+ */
+ public function search(string $needle): DataResponse {
+ try {
+ $this->setCurrentFederatedUser();
+
+ return new DataResponse($this->searchService->search($needle));
+ } catch (Exception $e) {
+ throw new OcsException($e->getMessage(), $e->getCode());
+ }
+ }
+
+
/**
* @NoAdminRequired
*
diff --git a/lib/Db/MemberRequest.php b/lib/Db/MemberRequest.php
index b9d626cd..4dcb4ed3 100644
--- a/lib/Db/MemberRequest.php
+++ b/lib/Db/MemberRequest.php
@@ -273,5 +273,19 @@ class MemberRequest extends MemberRequestBuilder {
return $this->getItemFromRequest($qb);
}
+
+ /**
+ * @param string $needle
+ *
+ * @return FederatedUser[]
+ */
+ public function searchFederatedUsers(string $needle): array {
+ $qb = $this->getMemberSelectSql();
+ $qb->searchInDBField('user_id', '%' . $needle . '%');
+ $qb->groupBy('single_id');
+
+ return $this->getItemsFromRequest($qb, true);
+ }
+
}
diff --git a/lib/Db/MemberRequestBuilder.php b/lib/Db/MemberRequestBuilder.php
index 65a14623..ed28cb00 100644
--- a/lib/Db/MemberRequestBuilder.php
+++ b/lib/Db/MemberRequestBuilder.php
@@ -34,6 +34,7 @@ namespace OCA\Circles\Db;
use daita\MySmallPhpTools\Exceptions\RowNotFoundException;
use OCA\Circles\Exceptions\MemberNotFoundException;
+use OCA\Circles\Model\FederatedUser;
use OCA\Circles\Model\Member;
@@ -74,13 +75,14 @@ class MemberRequestBuilder extends CoreQueryBuilder {
protected function getMemberSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->select(
- 'm.circle_id', 'm.member_id', 'm.single_id', 'm.user_id', 'm.instance', 'm.user_type', 'm.level', 'm.status',
+ 'm.circle_id', 'm.member_id', 'm.single_id', 'm.user_id', 'm.instance', 'm.user_type', 'm.level',
+ 'm.status',
'm.note', 'm.contact_id', 'm.cached_name', 'm.cached_update', 'm.contact_meta',
'm.joined'
)
->from(self::TABLE_MEMBER, 'm')
->orderBy('m.joined')
- ->groupBy('m.member_id')
+ ->groupBy('m.member_id')
->setDefaultSelectAlias('m');
return $qb;
@@ -124,13 +126,19 @@ class MemberRequestBuilder extends CoreQueryBuilder {
/**
* @param CoreRequestBuilder $qb
+ * @param bool $asFederatedUser
*
- * @return Member[]
+ * @return Member|FederatedUser[]
*/
- public function getItemsFromRequest(CoreRequestBuilder $qb): array {
- /** @var Member[] $result */
+ public function getItemsFromRequest(CoreRequestBuilder $qb, bool $asFederatedUser = false): array {
+ $object = Member::class;
+ if ($asFederatedUser) {
+ $object = FederatedUser::class;
+ }
+
+ /** @var Member|FederatedUser[] $result */
return $qb->asItems(
- Member::class,
+ $object,
[
'local' => $this->configService->getFrontalInstance()
]
diff --git a/lib/ISearch.php b/lib/ISearch.php
index 5cdfa833..bf5165db 100644
--- a/lib/ISearch.php
+++ b/lib/ISearch.php
@@ -1,12 +1,16 @@
- * @copyright 2017
+ * @author Maxence Lange
+ * @copyright 2021
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -24,18 +28,26 @@
*
*/
+
namespace OCA\Circles;
-use OCA\Circles\Model\SearchResult;
+use OCA\Circles\Model\FederatedUser;
+
+/**
+ * Interface ISearch
+ *
+ * @package OCA\Circles
+ */
interface ISearch {
/**
- * @param string $search
+ * @param string $needle
*
- * @return SearchResult[]
+ * @return FederatedUser[]
*/
- public function search($search);
+ public function search(string $needle): array;
+
+}
-}
\ No newline at end of file
diff --git a/lib/Model/FederatedUser.php b/lib/Model/FederatedUser.php
index 24c43733..0be569ad 100644
--- a/lib/Model/FederatedUser.php
+++ b/lib/Model/FederatedUser.php
@@ -226,7 +226,7 @@ class FederatedUser extends ManagedModel implements IFederatedUser, IDeserializa
* @return INC21QueryRow
*/
public function importFromDatabase(array $data, string $prefix = ''): INC21QueryRow {
- $this->setSingleId($this->get($prefix . 'member_id', $data));
+ $this->setSingleId($this->get($prefix . 'single_id', $data));
$this->setUserId($this->get($prefix . 'user_id', $data));
$this->setUserType($this->getInt($prefix . 'user_type', $data));
$this->setInstance($this->get($prefix . 'instance', $data));
diff --git a/lib/Service/ExceptionService.php b/lib/Search/FederatedUsers.php
similarity index 65%
rename from lib/Service/ExceptionService.php
rename to lib/Search/FederatedUsers.php
index a397b30f..787aa02f 100644
--- a/lib/Service/ExceptionService.php
+++ b/lib/Search/FederatedUsers.php
@@ -29,39 +29,42 @@ declare(strict_types=1);
*/
-namespace OCA\Circles\Service;
+namespace OCA\Circles\Search;
-use OCP\IL10N;
+use OCA\Circles\Db\MemberRequest;
+use OCA\Circles\ISearch;
/**
- * Class ExceptionService
+ * Class FederatedUsers
*
- * @package OCA\Circles\Service
+ * @package OCA\Circles\Search
*/
-class ExceptionService {
+class FederatedUsers implements ISearch {
- /** @var IL10N */
- private $l10n;
+ /** @var MemberRequest */
+ private $memberRequest;
/**
- * ExceptionService constructor.
+ * LocalUsers constructor.
*
- * @param IL10N $l10n
+ * @param MemberRequest $memberRequest
*/
- public function __construct(IL10N $l10n) {
- $this->l10n = $l10n;
+ public function __construct(MemberRequest $memberRequest) {
+ $this->memberRequest = $memberRequest;
}
/**
- * @return IL10N
+ * @param string $needle
+ *
+ * @return array
*/
- public function getL10n(): IL10N {
- return $this->l10n;
+ public function search(string $needle): array {
+ return $this->memberRequest->searchFederatedUsers($needle);
}
}
diff --git a/lib/Service/SearchService.php b/lib/Service/SearchService.php
index 96112d59..5e726265 100644
--- a/lib/Service/SearchService.php
+++ b/lib/Service/SearchService.php
@@ -1,12 +1,16 @@
- * @copyright 2017
+ * @author Maxence Lange
+ * @copyright 2021
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
@@ -24,78 +28,54 @@
*
*/
+
namespace OCA\Circles\Service;
+use OC;
use OCA\Circles\ISearch;
-use OCP\IL10N;
-use OCP\IUserManager;
+use OCA\Circles\Model\FederatedUser;
+use OCA\Circles\Search\FederatedUsers;
+
+/**
+ * Class SearchService
+ *
+ * @package OCA\Circles\Service
+ */
class SearchService {
- /** @var IL10N */
- private $l10n;
- /** @var IUserManager */
- private $userManager;
+ static $SERVICES = [
+ FederatedUsers::class
+ ];
- /** @var ConfigService */
- private $configService;
-
- /** @var MiscService */
- private $miscService;
-
- /** @var string[] */
- private $searchList;
/**
* MembersService constructor.
*
- * @param IL10N $l10n
- * @param IUserManager $userManager
- * @param ConfigService $configService
- * @param MiscService $miscService
*/
- public function __construct(
- IL10N $l10n, IUserManager $userManager, ConfigService $configService,
- MiscService $miscService
- ) {
- $this->l10n = $l10n;
- $this->userManager = $userManager;
- $this->configService = $configService;
- $this->miscService = $miscService;
-
- $this->loadSearch();
+ public function __construct() {
}
/**
- * load list of search engine
+ * @param string $needle
+ *
+ * @return FederatedUser[]
*/
- public function loadSearch() {
- $this->searchList = [
- 'OCA\Circles\Search\LocalUsers',
- 'OCA\Circles\Search\GlobalScaleUsers',
- 'OCA\Circles\Search\LocalGroups',
- 'OCA\Circles\Search\Contacts'
- ];
- }
-
-
- public function searchGlobal($str) {
+ public function search(string $needle): array {
$result = [];
- foreach ($this->searchList as $container) {
- $searcher = \OC::$server->query((string)$container);
- if (!($searcher instanceof ISearch)) {
- $this->miscService->log('Search ' . $container . ' is not compatible exception');
- continue;
- }
+ foreach (self::$SERVICES as $service) {
+ /** @var ISearch $service */
+ $service = OC::$server->get($service);
- $result = array_merge($result, $searcher->search($str));
+ $result = array_merge($result, $service->search($needle));
}
return $result;
}
}
+