X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Facl_selectors.php;h=e69ac36f683c20a329d6f8676053a9a06a8a1684;hb=9e3bae5caa6725737c2a1221a6c499e06ea0077c;hp=02ab95bb1efaff48d3d080afe604aaf9553cdffd;hpb=35a18f68255f0b37b0109de4e6479cbf4312fc6e;p=friendica.git diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 02ab95bb1e..e69ac36f68 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -2,15 +2,19 @@ /** * @file include/acl_selectors.php */ + use Friendica\App; use Friendica\Content\Feature; +use Friendica\Content\Widget; +use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\L10n; +use Friendica\Core\Protocol; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\GContact; +use Friendica\Util\Network; -require_once "include/contact_selectors.php"; -require_once "include/contact_widgets.php"; require_once "mod/proxy.php"; /** @@ -29,11 +33,11 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { ); - $arr = array('group' => $r, 'entry' => $o); + $arr = ['group' => $r, 'entry' => $o]; // e.g. 'network_pre_group_deny', 'profile_pre_group_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + Addon::callHooks($a->module . '_pre_' . $selname, $arr); if (DBM::is_result($r)) { foreach ($r as $rr) { @@ -51,7 +55,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { } $o .= "\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + Addon::callHooks($a->module . '_post_' . $selname, $o); return $o; @@ -88,20 +92,20 @@ function contact_selector($selname, $selclass, $options, $preselected = false) if (x($options, 'networks')) { switch ($options['networks']) { case 'DFRN_ONLY': - $networks = array(NETWORK_DFRN); + $networks = [NETWORK_DFRN]; break; case 'PRIVATE': if (is_array($a->user) && $a->user['prvnets']) { - $networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA); + $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA]; } else { - $networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA); + $networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA]; } break; case 'TWO_WAY': if (is_array($a->user) && $a->user['prvnets']) { - $networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA); + $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA]; } else { - $networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS); + $networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS]; } break; default: /// @TODO Maybe log this call? @@ -110,9 +114,9 @@ function contact_selector($selname, $selclass, $options, $preselected = false) } } - $x = array('options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks); + $x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks]; - call_hooks('contact_select_options', $x); + Addon::callHooks('contact_select_options', $x); $o = ''; @@ -151,11 +155,11 @@ function contact_selector($selname, $selclass, $options, $preselected = false) ); - $arr = array('contact' => $r, 'entry' => $o); + $arr = ['contact' => $r, 'entry' => $o]; // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + Addon::callHooks($a->module . '_pre_' . $selname, $arr); if (DBM::is_result($r)) { foreach ($r as $rr) { @@ -174,7 +178,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false) $o .= "\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + Addon::callHooks($a->module . '_post_' . $selname, $o); return $o; } @@ -182,9 +186,6 @@ function contact_selector($selname, $selclass, $options, $preselected = false) function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) { - - require_once "include/bbcode.php"; - $a = get_app(); $o = ''; @@ -229,13 +230,13 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p ); - $arr = array('contact' => $r, 'entry' => $o); + $arr = ['contact' => $r, 'entry' => $o]; // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + Addon::callHooks($a->module . '_pre_' . $selname, $arr); - $receiverlist = array(); + $receiverlist = []; if (DBM::is_result($r)) { foreach ($r as $rr) { @@ -246,7 +247,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p } if ($privmail) { - $trimmed = GetProfileUsername($rr['url'], $rr['name'], false); + $trimmed = Protocol::formatMention($rr['url'], $rr['name']); } else { $trimmed = mb_substr($rr['name'],0,20); } @@ -264,14 +265,14 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o .= implode(", ", $receiverlist); } - call_hooks($a->module . '_post_' . $selname, $o); + Addon::callHooks($a->module . '_post_' . $selname, $o); return $o; } function fixacl(&$item) { - $item = intval(str_replace(array('<', '>'), array('', ''), $item)); + $item = intval(str_replace(['<', '>'], ['', ''], $item)); } function prune_deadguys($arr) { @@ -285,14 +286,14 @@ function prune_deadguys($arr) { $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); if (DBM::is_result($r)) { - $ret = array(); + $ret = []; foreach ($r as $rr) { $ret[] = intval($rr['id']); } return $ret; } - return array(); + return []; } @@ -301,13 +302,13 @@ function get_acl_permissions($user = null) { if (is_array($user)) { $allow_cid = ((strlen($user['allow_cid'])) - ? explode('><', $user['allow_cid']) : array() ); + ? explode('><', $user['allow_cid']) : [] ); $allow_gid = ((strlen($user['allow_gid'])) - ? explode('><', $user['allow_gid']) : array() ); + ? explode('><', $user['allow_gid']) : [] ); $deny_cid = ((strlen($user['deny_cid'])) - ? explode('><', $user['deny_cid']) : array() ); + ? explode('><', $user['deny_cid']) : [] ); $deny_gid = ((strlen($user['deny_gid'])) - ? explode('><', $user['deny_gid']) : array() ); + ? explode('><', $user['deny_gid']) : [] ); array_walk($allow_cid,'fixacl'); array_walk($allow_gid,'fixacl'); array_walk($deny_cid,'fixacl'); @@ -316,12 +317,12 @@ function get_acl_permissions($user = null) { $allow_cid = prune_deadguys($allow_cid); - return array( + return [ 'allow_cid' => $allow_cid, 'allow_gid' => $allow_gid, 'deny_cid' => $deny_cid, 'deny_gid' => $deny_gid, - ); + ]; } @@ -351,35 +352,34 @@ function populate_acl($user = null, $show_jotnets = false) { if (!$user['hidewall']) { if ($mail_enabled) { $selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); - $jotnets .= '