X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FACL.php;h=b604218774e3304cc0dc3ea0d4e8baba0e8b3ebf;hb=38e5733b6ee10f5a6dd7f017b6b6e7acfde80565;hp=cfe46e77061f9adff0ebe8fcd784c6e1235929ce;hpb=ae2959c7805ae458b125f33e34f650c1520b4ccf;p=friendica.git diff --git a/src/Core/ACL.php b/src/Core/ACL.php index cfe46e7706..b604218774 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -19,119 +19,6 @@ use Friendica\Model\Group; */ class ACL { - /** - * Returns a select input tag with all the contact of the local user - * - * @param string $selname Name attribute of the select input tag - * @param string $selclass Class attribute of the select input tag - * @param array $options Available options: - * - size: length of the select box - * - mutual_friends: Only used for the hook - * - single: Only used for the hook - * - exclude: Only used for the hook - * @param array $preselected Contact ID that should be already selected - * @return string - * @throws \Exception - */ - public static function getSuggestContactSelectHTML($selname, $selclass, array $options = [], array $preselected = []) - { - $a = DI::app(); - - $networks = null; - - $size = ($options['size'] ?? 0) ?: 4; - $mutual = !empty($options['mutual_friends']); - $single = !empty($options['single']) && empty($options['multiple']); - $exclude = $options['exclude'] ?? false; - - switch (($options['networks'] ?? '') ?: Protocol::PHANTOM) { - case 'DFRN_ONLY': - $networks = [Protocol::DFRN]; - break; - - case 'PRIVATE': - $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; - break; - - case 'TWO_WAY': - if (!empty($a->user['prvnets'])) { - $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; - } else { - $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS]; - } - break; - - default: /// @TODO Maybe log this call? - break; - } - - $x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks]; - - Hook::callAll('contact_select_options', $x); - - $o = ''; - - $sql_extra = ''; - - if (!empty($x['mutual'])) { - $sql_extra .= sprintf(" AND `rel` = %d ", intval(Contact::FRIEND)); - } - - if (!empty($x['exclude'])) { - $sql_extra .= sprintf(" AND `id` != %d ", intval($x['exclude'])); - } - - if (!empty($x['networks'])) { - /// @TODO rewrite to foreach() - array_walk($x['networks'], function (&$value) { - $value = "'" . DBA::escape($value) . "'"; - }); - $str_nets = implode(',', $x['networks']); - $sql_extra .= " AND `network` IN ( $str_nets ) "; - } - - $tabindex = (!empty($options['tabindex']) ? 'tabindex="' . $options["tabindex"] . '"' : ''); - - if (!empty($x['single'])) { - $o .= "\r\n"; - } - - $stmt = DBA::p("SELECT `id`, `name`, `url`, `network` FROM `contact` - WHERE `uid` = ? AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND NOT `deleted` AND `notify` != '' - $sql_extra - ORDER BY `name` ASC ", intval(local_user()) - ); - - $contacts = DBA::toArray($stmt); - - $arr = ['contact' => $contacts, 'entry' => $o]; - - // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - Hook::callAll(DI::module()->getName() . '_pre_' . $selname, $arr); - - if (DBA::isResult($contacts)) { - foreach ($contacts as $contact) { - if (in_array($contact['id'], $preselected)) { - $selected = ' selected="selected" '; - } else { - $selected = ''; - } - - $trimmed = mb_substr($contact['name'], 0, 20); - - $o .= "\r\n"; - } - } - - $o .= '' . PHP_EOL; - - Hook::callAll(DI::module()->getName() . '_post_' . $selname, $o); - - return $o; - } - /** * Returns a select input tag with all the contact of the local user *