- $o = '';
-
- // 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::FRIEND));
- $sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", Protocol::DFRN, Protocol::DIASPORA);
-
- $tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : '';
-
- $hidepreselected = '';
- if ($preselected) {
- $sql_extra .= " AND `id` IN (" . implode(",", $preselected) . ")";
- $hidepreselected = ' style="display: none;"';
- }
-
- $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\"$tabindex_attr$hidepreselected>\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);
-
- $receiverlist = [];
-
- if (DBA::isResult($contacts)) {
- foreach ($contacts as $contact) {
- if (in_array($contact['id'], $preselected)) {
- $selected = ' selected="selected"';
- } else {
- $selected = '';
- }
-
- $trimmed = Protocol::formatMention($contact['url'], $contact['name']);
-
- $receiverlist[] = $trimmed;
-
- $o .= "<option value=\"{$contact['id']}\"$selected title=\"{$contact['name']}|{$contact['url']}\" >$trimmed</option>\r\n";
- }
- }
-
- $o .= '</select>' . PHP_EOL;
-
- if ($preselected) {
- $o .= implode(', ', $receiverlist);
- }
-
- Hook::callAll(DI::module()->getName() . '_post_' . $selname, $o);