X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FACL.php;h=164333aae49366e8614cd8da2cb924c4a83818f9;hb=804cfa03200456116db0c96b7f2ae6e3b7bdbfd8;hp=415978bae079340410f576eb782ddbd5647ad84c;hpb=a6fb3568f989f72164b435baafc63a174397b542;p=friendica.git diff --git a/src/Core/ACL.php b/src/Core/ACL.php index 415978bae0..164333aae4 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -8,6 +8,7 @@ namespace Friendica\Core; use Friendica\BaseObject; use Friendica\Content\Feature; +use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\GContact; @@ -46,22 +47,21 @@ class ACL extends BaseObject switch (defaults($options, 'networks', Protocol::PHANTOM)) { case 'DFRN_ONLY': - $networks = [NETWORK_DFRN]; + $networks = [Protocol::DFRN]; break; + case 'PRIVATE': - if (!empty($a->user['prvnets'])) { - $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA]; - } else { - $networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA]; - } + $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; break; + case 'TWO_WAY': if (!empty($a->user['prvnets'])) { - $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA]; + $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; } else { - $networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS]; + $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS]; } break; + default: /// @TODO Maybe log this call? break; } @@ -75,7 +75,7 @@ class ACL extends BaseObject $sql_extra = ''; if (!empty($x['mutual'])) { - $sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND)); + $sql_extra .= sprintf(" AND `rel` = %d ", intval(Contact::FRIEND)); } if (!empty($x['exclude'])) { @@ -151,8 +151,8 @@ class ACL extends BaseObject // When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector // to one recipient. By default our selector allows multiple selects amongst all contacts. - $sql_extra = sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND)); - $sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", NETWORK_DFRN, NETWORK_DIASPORA); + $sql_extra = sprintf(" AND `rel` = %d ", intval(Contact::FRIEND)); + $sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", Protocol::DFRN, Protocol::DIASPORA); $tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : ''; @@ -251,19 +251,18 @@ class ACL extends BaseObject /** * Return the full jot ACL selector HTML * - * @param array $user + * @param array $user User array + * @param array $default_permissions Static defaults permission array: ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''] * @param bool $show_jotnets * @return string */ - public static function getFullSelectorHTML(array $user = null, $show_jotnets = false) + public static function getFullSelectorHTML(array $user, $show_jotnets = false, array $default_permissions = []) { - - if (empty($user['uid'])) { - return ''; + // Defaults user permissions + if (empty($default_permissions)) { + $default_permissions = self::getDefaultUserPermissions($user); } - $perms = self::getDefaultUserPermissions($user); - $jotnets = ''; if ($show_jotnets) { $imap_disabled = !function_exists('imap_open') || Config::get('system', 'imap_disabled'); @@ -279,7 +278,7 @@ class ACL extends BaseObject } } - if (empty($user['hidewall'])) { + if (empty($default_permissions['hidewall'])) { if ($mail_enabled) { $selected = $pubmail_enabled ? ' checked="checked"' : ''; $jotnets .= '