Merge pull request #8063 from MrPetovan/bug/8058-use-default-user-acl-events
Use default user permissions when creating new event
This commit is contained in:
commit
e56c8dcc3c
5 changed files with 18 additions and 51 deletions
|
@ -18,6 +18,7 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Event;
|
use Friendica\Model\Event;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
|
use Friendica\Model\User;
|
||||||
use Friendica\Module\Security\Login;
|
use Friendica\Module\Security\Login;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
@ -427,7 +428,7 @@ function events_content(App $a)
|
||||||
// Passed parameters overrides anything found in the DB
|
// Passed parameters overrides anything found in the DB
|
||||||
if (in_array($mode, ['edit', 'new', 'copy'])) {
|
if (in_array($mode, ['edit', 'new', 'copy'])) {
|
||||||
if (empty($orig_event)) {
|
if (empty($orig_event)) {
|
||||||
$orig_event = [];
|
$orig_event = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values
|
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values
|
||||||
|
|
|
@ -206,11 +206,6 @@ class ACL
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function fixACL(&$item)
|
|
||||||
{
|
|
||||||
$item = intval(str_replace(['<', '>'], ['', ''], $item));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the default permission of the provided user array
|
* Return the default permission of the provided user array
|
||||||
*
|
*
|
||||||
|
@ -220,32 +215,13 @@ class ACL
|
||||||
*/
|
*/
|
||||||
public static function getDefaultUserPermissions(array $user = null)
|
public static function getDefaultUserPermissions(array $user = null)
|
||||||
{
|
{
|
||||||
$matches = [];
|
$aclFormatter = DI::aclFormatter();
|
||||||
|
|
||||||
$acl_regex = '/<([0-9]+)>/i';
|
|
||||||
|
|
||||||
preg_match_all($acl_regex, $user['allow_cid'] ?? '', $matches);
|
|
||||||
$allow_cid = $matches[1];
|
|
||||||
preg_match_all($acl_regex, $user['allow_gid'] ?? '', $matches);
|
|
||||||
$allow_gid = $matches[1];
|
|
||||||
preg_match_all($acl_regex, $user['deny_cid'] ?? '', $matches);
|
|
||||||
$deny_cid = $matches[1];
|
|
||||||
preg_match_all($acl_regex, $user['deny_gid'] ?? '', $matches);
|
|
||||||
$deny_gid = $matches[1];
|
|
||||||
|
|
||||||
// Reformats the ACL data so that it is accepted by the JS frontend
|
|
||||||
array_walk($allow_cid, 'self::fixACL');
|
|
||||||
array_walk($allow_gid, 'self::fixACL');
|
|
||||||
array_walk($deny_cid, 'self::fixACL');
|
|
||||||
array_walk($deny_gid, 'self::fixACL');
|
|
||||||
|
|
||||||
Contact::pruneUnavailable($allow_cid);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'allow_cid' => $allow_cid,
|
'allow_cid' => Contact::pruneUnavailable($aclFormatter->expand($user['allow_cid'] ?? '')),
|
||||||
'allow_gid' => $allow_gid,
|
'allow_gid' => $aclFormatter->expand($user['allow_gid'] ?? ''),
|
||||||
'deny_cid' => $deny_cid,
|
'deny_cid' => $aclFormatter->expand($user['deny_cid'] ?? ''),
|
||||||
'deny_gid' => $deny_gid,
|
'deny_gid' => $aclFormatter->expand($user['deny_gid'] ?? ''),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2682,26 +2682,23 @@ class Contact
|
||||||
* Remove the unavailable contact ids from the provided list
|
* Remove the unavailable contact ids from the provided list
|
||||||
*
|
*
|
||||||
* @param array $contact_ids Contact id list
|
* @param array $contact_ids Contact id list
|
||||||
|
* @return array
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function pruneUnavailable(array &$contact_ids)
|
public static function pruneUnavailable(array $contact_ids)
|
||||||
{
|
{
|
||||||
if (empty($contact_ids)) {
|
if (empty($contact_ids)) {
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = DBA::escape(implode(',', $contact_ids));
|
$contacts = Contact::selectToArray(['id'], [
|
||||||
|
'id' => $contact_ids,
|
||||||
|
'blocked' => false,
|
||||||
|
'pending' => false,
|
||||||
|
'archive' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
$stmt = DBA::p("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
|
return array_column($contacts, 'id');
|
||||||
|
|
||||||
$return = [];
|
|
||||||
while($contact = DBA::fetch($stmt)) {
|
|
||||||
$return[] = $contact['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
DBA::close($stmt);
|
|
||||||
|
|
||||||
$contact_ids = $return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -384,7 +384,7 @@ class Group
|
||||||
DBA::close($stmt);
|
DBA::close($stmt);
|
||||||
|
|
||||||
if ($check_dead) {
|
if ($check_dead) {
|
||||||
Contact::pruneUnavailable($return);
|
$return = Contact::pruneUnavailable($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -5,22 +5,15 @@ namespace Friendica\Module\Item;
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Feature;
|
use Friendica\Content\Feature;
|
||||||
use Friendica\Core\ACL;
|
use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Config;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Model\FileTag;
|
|
||||||
use Friendica\Model\Group;
|
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Module\Security\Login;
|
use Friendica\Module\Security\Login;
|
||||||
use Friendica\Network\HTTPException\NotImplementedException;
|
use Friendica\Network\HTTPException\NotImplementedException;
|
||||||
use Friendica\Util\ACLFormatter;
|
|
||||||
use Friendica\Util\Crypto;
|
use Friendica\Util\Crypto;
|
||||||
|
|
||||||
class Compose extends BaseModule
|
class Compose extends BaseModule
|
||||||
|
|
Loading…
Reference in a new issue