Skip to content

Commit

Permalink
[WIP] Multiple fixes and add Group Backend support
Browse files Browse the repository at this point in the history
NOTE: This big commit will be split in multiple commits and pull
requests soon!
Signed-off-by: Tortue Torche <tortuetorche@users.noreply.github.com>
  • Loading branch information
tortuetorche committed Apr 1, 2020
1 parent c5e1ad2 commit e4ee7a9
Show file tree
Hide file tree
Showing 26 changed files with 1,035 additions and 92 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,38 @@ Non-members won't be able to find your secret circle using the search bar.

In non-SSL environments (like on development setups) it is necessary to set two config flags for Circles:

`./occ config:app:set circles --value 1 allow_non_ssl_links`
`./occ config:app:set circles --value 1 allow_non_ssl_links`

`./occ config:app:set circles --value 1 local_is_non_ssl`

## Allow mirroring circles as groups

See: https://github.com/nextcloud/circles/issues/363

```bash
apk add --no-cache --virtual .maintenance-deps sudo

sudo -u www-data php occ maintenance:mode --on

sudo -u www-data php occ config:app:set circles --value 1 group_backend # Mirroring circles as groups
sudo -u www-data php occ config:app:set circles --value 0 allow_listed_circles # Hide circles in shared list, useful with the 'group_backend' option

# sudo -u www-data php occ config:app:set circles --value "🌀 " group_backend_name_prefix # Add custom group name prefix
# sudo -u www-data php occ config:app:set circles --value " " group_backend_name_suffix # Remove default group name suffix

sudo -u www-data php occ config:app:set circles --value 12 allow_circles # Only show 'public' and 'closed' circles
sudo -u www-data php occ config:app:set circles --value 1 skip_invitation_to_closed_circles

sudo -u www-data php occ config:app:set circles --value 0 allow_files_filtered_by_circles # Disable files list filtering by circles in the 'files' application
sudo -u www-data php occ config:app:set circles --value 0 allow_adding_any_group_members # Adding group members only for groups where the current user is a member or global administrators

sudo -u www-data php occ maintenance:mode --off

apk del .maintenance-deps


```

# Credits

App Icon by [Madebyoliver](http://www.flaticon.com/authors/madebyoliver) under Creative Commons BY 3.0
5 changes: 1 addition & 4 deletions appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@


$app = \OC::$server->query(Application::class);
$app->registerNavigation();
$app->registerFilesNavigation();
$app->registerFilesPlugin();

$app->register();
8 changes: 4 additions & 4 deletions css/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
}

#circles_new_type_definition div {
margin-top: 20px;
margin-top: 10px;
position: absolute;
width: 190px;
width: 250px;
color: #474747b0;
word-wrap: break-word;
}
Expand Down Expand Up @@ -209,7 +209,8 @@ div.circle .owner, div.circle .type, div.circle .resume {
}

.members_search, .groups_search {
padding: 10px;
padding: 12px;
padding-top: 5px;
border-top: solid 1px #00000022;
-webkit-transition: background-color 0.2s ease-in;
transition: background-color 0.2s ease-in;
Expand Down Expand Up @@ -363,7 +364,6 @@ DIV.result_top {

DIV.result_bot {
font-size: 12px;
padding: 5px;
height: 10px;
font-style: italic;
}
1 change: 0 additions & 1 deletion js/files/circles.files.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,3 @@

OCA.Circles.FileList = FileList;
})();

23 changes: 19 additions & 4 deletions lib/Activity/ProviderParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
use OCA\Circles\Model\FederatedLink;
use OCA\Circles\Model\Member;
use OCA\Circles\Service\MiscService;
use OCA\Circles\Service\ConfigService;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\IL10N;
use OCP\IURLGenerator;

class ProviderParser {


/** @var MiscService */
protected $miscService;

Expand All @@ -52,13 +52,28 @@ class ProviderParser {
/** @var IManager */
protected $activityManager;

/** @var ConfigService */
protected $configService;

/**
* @param IURLGenerator $url
* @param IManager $activityManager
* @param IL10N $l10n
* @param MiscService $miscService
* @param ConfigService $configService
*/
public function __construct(
IURLGenerator $url, IManager $activityManager, IL10N $l10n, MiscService $miscService
IURLGenerator $url,
IManager $activityManager,
IL10N $l10n,
MiscService $miscService,
ConfigService $configService
) {
$this->url = $url;
$this->activityManager = $activityManager;
$this->l10n = $l10n;
$this->miscService = $miscService;
$this->configService = $configService;
}


Expand Down Expand Up @@ -299,7 +314,7 @@ protected function generateViewerParameter(Circle $circle) {
*/
protected function generateExternalMemberParameter(Member $member) {
return [
'type' => 'member_' . $member->getType(),
'type' => $member->getTypeName(),
'id' => $member->getUserId(),
'name' => $member->getDisplayName() . ' (' . $member->getTypeString() . ')',
'_parsed' => $member->getDisplayName()
Expand Down Expand Up @@ -365,7 +380,7 @@ protected function generateUserParameter(Member $member) {
*/
protected function generateGroupParameter($group) {
return [
'type' => 'group',
'type' => 'user-group',
'id' => $group->getUserId(),
'name' => $group->getUserId(),
'_parsed' => $group->getUserId()
Expand Down
8 changes: 6 additions & 2 deletions lib/Activity/ProviderSubjectMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public function parseSubjectMemberJoin(IEvent $event, Circle $circle, Member $me
* @throws FakeException
*/
private function parseSubjectMemberJoinClosedCircle(IEvent $event, Circle $circle, Member $member) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED ||
$this->configService->isInvitationSkipped()
) {
return;
}

Expand Down Expand Up @@ -141,7 +143,9 @@ private function parseSubjectMemberAddNotLocalMember(IEvent $event, Circle $circ
* @throws FakeException
*/
private function parseSubjectMemberAddClosedCircle(IEvent $event, Circle $circle, Member $member) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED) {
if ($circle->getType() !== Circle::CIRCLES_CLOSED ||
$this->configService->isInvitationSkipped()
) {
return;
}

Expand Down
13 changes: 11 additions & 2 deletions lib/Api/Sharees.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\Member;
use OCA\Circles\Service\CirclesService;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\MiscService;
use OCP\Share;

Expand Down Expand Up @@ -61,12 +62,20 @@ protected static function getContainer() {
// public static function search($search, $limit, $offset) {
public static function search($search) {
$c = self::getContainer();

$type = Circle::CIRCLES_ALL;
$circlesAreVisible = $c->query(ConfigService::class)
->isListedCirclesAllowed();
if (!$circlesAreVisible) {
$type = $type - Circle::CIRCLES_CLOSED - Circle::CIRCLES_PUBLIC;
}

$userId = \OC::$server->getUserSession()
->getUser()
->getUID();

$data = $c->query(CirclesService::class)
->listCircles($userId, Circle::CIRCLES_ALL, $search, Member::LEVEL_MEMBER);
->listCircles($userId, $type, $search, Member::LEVEL_MEMBER);
$result = array(
'exact' => ['circles'],
'circles' => []
Expand Down Expand Up @@ -111,4 +120,4 @@ private static function addResultEntry(&$result, $entry, $exact = false) {

}

}
}
38 changes: 38 additions & 0 deletions lib/Api/v1/Circles.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OCA\Circles\Model\Member;
use OCA\Circles\Model\SharingFrame;
use OCA\Circles\Service\CirclesService;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\FederatedLinkService;
use OCA\Circles\Service\MembersService;
use OCA\Circles\Service\MiscService;
Expand Down Expand Up @@ -181,6 +182,43 @@ public static function leaveCircle($circleUniqueId) {
public static function listCircles($type, $name = '', $level = 0, $userId = '', $forceAll = false) {
$c = self::getContainer();

$configService = $c->query(ConfigService::class);
$circlesAreVisible = $configService->isListedCirclesAllowed();
$circlesAllowed = (int)$configService->getAppValue(ConfigService::CIRCLES_ALLOW_CIRCLES);

if (!$circlesAreVisible) {
switch (true) {
case ($type === Circle::CIRCLES_CLOSED):
case ($type === Circle::CIRCLES_PUBLIC):
case (Circle::CIRCLES_CLOSED + Circle::CIRCLES_PUBLIC === $circlesAllowed):
return [];
break;
case ($type === Circle::CIRCLES_ALL &&
$circlesAllowed === Circle::CIRCLES_ALL
):
$type = $type - Circle::CIRCLES_CLOSED - Circle::CIRCLES_PUBLIC;
break;
case ($type > Circle::CIRCLES_CLOSED &&
$type < Circle::CIRCLES_PUBLIC &&
$circlesAllowed === Circle::CIRCLES_ALL
):
$type = $type - Circle::CIRCLES_CLOSED;
break;
case ($type > Circle::CIRCLES_PUBLIC &&
$type < (Circle::CIRCLES_PUBLIC + Circle::CIRCLES_CLOSED) &&
$circlesAllowed === Circle::CIRCLES_ALL
):
$type = $type - Circle::CIRCLES_PUBLIC;
break;
case ($type > (Circle::CIRCLES_PUBLIC + Circle::CIRCLES_CLOSED) &&
$type < Circle::CIRCLES_ALL &&
$circlesAllowed === Circle::CIRCLES_ALL
):
$type = $type - Circle::CIRCLES_PUBLIC - Circle::CIRCLES_CLOSED;
break;
}
}

if ($userId === '') {
$userId = \OC::$server->getUserSession()
->getUser()
Expand Down
Loading

0 comments on commit e4ee7a9

Please sign in to comment.