mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update ParentalControls, map updated saved permissions/roles
This commit is contained in:
parent
2dcfc81495
commit
9d365d07f9
2 changed files with 45 additions and 2 deletions
|
@ -59,9 +59,13 @@ class ParentalControlsController extends Controller
|
||||||
{
|
{
|
||||||
$this->authPreflight($request);
|
$this->authPreflight($request);
|
||||||
$uid = $request->user()->id;
|
$uid = $request->user()->id;
|
||||||
|
$ff = $this->requestFormFields($request);
|
||||||
$pc = ParentalControls::whereParentId($uid)->findOrFail($id);
|
$pc = ParentalControls::whereParentId($uid)->findOrFail($id);
|
||||||
$pc->permissions = $this->requestFormFields($request);
|
$pc->permissions = $ff;
|
||||||
$pc->save();
|
$pc->save();
|
||||||
|
|
||||||
|
$roles = UserRoleService::mapActions($pc->child_id, $ff);
|
||||||
|
UserRoles::whereUserId($pc->child_id)->update(['roles' => $roles]);
|
||||||
return redirect($pc->manageUrl() . '?permissions');
|
return redirect($pc->manageUrl() . '?permissions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ class UserRoleService
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($map as $key => $value) {
|
foreach ($map as $key => $value) {
|
||||||
if(!isset($data[$value], $data[substr($value, 1)])) {
|
if(!isset($data[$value]) && !isset($data[substr($value, 1)])) {
|
||||||
$map[$key] = false;
|
$map[$key] = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -188,4 +188,43 @@ class UserRoleService
|
||||||
|
|
||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function mapActions($id, $data = [])
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
$map = [
|
||||||
|
'account-force-private' => 'private',
|
||||||
|
'account-ignore-follow-requests' => 'private',
|
||||||
|
|
||||||
|
'can-view-public-feed' => 'discovery_feeds',
|
||||||
|
'can-view-network-feed' => 'discovery_feeds',
|
||||||
|
'can-view-discover' => 'discovery_feeds',
|
||||||
|
'can-view-hashtag-feed' => 'discovery_feeds',
|
||||||
|
|
||||||
|
'can-post' => 'post',
|
||||||
|
'can-comment' => 'comment',
|
||||||
|
'can-like' => 'like',
|
||||||
|
'can-share' => 'share',
|
||||||
|
|
||||||
|
'can-follow' => 'follow',
|
||||||
|
'can-make-public' => '!private',
|
||||||
|
|
||||||
|
'can-direct-message' => 'dms',
|
||||||
|
'can-use-stories' => 'story',
|
||||||
|
'can-view-sensitive' => '!hide_cw',
|
||||||
|
'can-bookmark' => 'bookmark',
|
||||||
|
'can-collections' => 'collection',
|
||||||
|
'can-federation' => 'federation',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($map as $key => $value) {
|
||||||
|
if(!isset($data[$value]) && !isset($data[substr($value, 1)])) {
|
||||||
|
$res[$key] = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$res[$key] = str_starts_with($value, '!') ? !$data[substr($value, 1)] : $data[$value];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue