X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Facl_selectors.php;h=d1b791136f6aec05c84d7d0d3a51b6be7e4cb209;hb=5a0260a10fa375d34ceabd32363003f91aca18a4;hp=ca463d9433f5868004ea543ad4d669ca3df5f07c;hpb=f3f42ae3a2f34f77ec2f025c9a424710cf66f91d;p=friendica.git diff --git a/include/acl_selectors.php b/include/acl_selectors.php index ca463d9433..d1b791136f 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -1,18 +1,18 @@ module . '_pre_' . $selname, $arr); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { foreach ($r as $rr) { if ((is_array($preselected)) && in_array($rr['id'], $preselected)) { $selected = " selected=\"selected\" "; @@ -57,10 +57,9 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { return $o; } -/// @TODO after an optional parameter, no mandadory parameter can follow /// @TODO find proper type-hints -function contact_selector($selname, $selclass, $preselected = false, $options) { - +function contact_selector($selname, $selclass, $options, $preselected = false) +{ $a = get_app(); $mutual = false; @@ -158,7 +157,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { call_hooks($a->module . '_pre_' . $selname, $arr); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { foreach ($r as $rr) { if ((is_array($preselected)) && in_array($rr['id'], $preselected)) { $selected = " selected=\"selected\" "; @@ -238,7 +237,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $receiverlist = array(); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { foreach ($r as $rr) { if ((is_array($preselected)) && in_array($rr['id'], $preselected)) { $selected = " selected=\"selected\" "; @@ -285,7 +284,7 @@ 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)) { + if (DBM::is_result($r)) { $ret = array(); foreach ($r as $rr) { $ret[] = intval($rr['id']); @@ -332,7 +331,7 @@ function populate_acl($user = null, $show_jotnets = false) { $jotnets = ''; if ($show_jotnets) { - $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + $mail_disabled = ((function_exists('imap_open') && (! Config::get('system','imap_disabled'))) ? 0 : 1); $mail_enabled = false; $pubmail_enabled = false; @@ -341,7 +340,7 @@ function populate_acl($user = null, $show_jotnets = false) { $r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval(local_user()) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $mail_enabled = true; if (intval($r[0]['pubmail'])) { $pubmail_enabled = true; @@ -378,7 +377,7 @@ function populate_acl($user = null, $show_jotnets = false) { '$aclModalTitle' => t('Permissions'), '$aclModalDismiss' => t('Close'), '$features' => array( - 'aclautomention' => (feature_enabled($user['uid'], "aclautomention") ? "true" : "false") + 'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "false") ), )); @@ -478,25 +477,32 @@ function acl_lookup(App $a, $out_type = 'json') { intval(local_user()) ); $contact_count = (int)$r[0]['c']; - } - elseif ($type == 'm') { - + } elseif ($type == 'f') { + // autocomplete for editor mentions of forums + $r = q("SELECT COUNT(*) AS c FROM `contact` + WHERE `uid` = %d AND NOT `self` + AND NOT `blocked` AND NOT `pending` AND NOT `archive` + AND (`forum` OR `prv`) + AND `success_update` >= `failure_update` + AND `notify` != '' $sql_extra2" , + intval(local_user()) + ); + $contact_count = (int)$r[0]['c']; + } elseif ($type == 'm') { // autocomplete for Private Messages $r = q("SELECT COUNT(*) AS c FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `success_update` >= `failure_update` - AND `network` IN ('%s','%s','%s') $sql_extra2" , + AND `network` IN ('%s', '%s') $sql_extra2" , intval(local_user()), dbesc(NETWORK_DFRN), - dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA) ); $contact_count = (int)$r[0]['c']; - } - elseif ($type == 'a') { + } elseif ($type == 'a') { // autocomplete for Contacts @@ -546,7 +552,7 @@ function acl_lookup(App $a, $out_type = 'json') { "forum" => '0' ); } - if (count($groups) > 0) { + if ((count($groups) > 0) && ($search == "")) { $groups[] = array("separator" => true); } } @@ -557,7 +563,7 @@ function acl_lookup(App $a, $out_type = 'json') { WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s', '%s')) $sql_extra2 - ORDER BY `frm` DESC, `name` ASC ", + ORDER BY `name` ASC ", intval(local_user()), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_STATUSNET) ); @@ -570,16 +576,24 @@ function acl_lookup(App $a, $out_type = 'json') { intval(local_user()), dbesc(NETWORK_STATUSNET) ); - } - elseif ($type == 'm') { + } elseif ($type == 'f') { + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact` + WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' + AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s')) + AND (`forum` OR `prv`) + $sql_extra2 + ORDER BY `name` ASC ", + intval(local_user()), + dbesc(NETWORK_STATUSNET) + ); + } elseif ($type == 'm') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` - AND `success_update` >= `failure_update` AND `network` IN ('%s','%s','%s') + AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s') $sql_extra2 ORDER BY `name` ASC ", intval(local_user()), dbesc(NETWORK_DFRN), - dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA) ); } elseif ($type == 'a') { @@ -617,7 +631,7 @@ function acl_lookup(App $a, $out_type = 'json') { } - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $forums = array(); foreach ($r as $g) { $entry = array( @@ -638,7 +652,9 @@ function acl_lookup(App $a, $out_type = 'json') { } } if (count($forums) > 0) { - $forums[] = array("separator" => true); + if ($search == "") { + $forums[] = array("separator" => true); + } $contacts = array_merge($forums, $contacts); } } @@ -669,9 +685,9 @@ function acl_lookup(App $a, $out_type = 'json') { dbesc($search), implode("', '", $known_contacts) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { foreach ($r as $row) { - $contact = get_contact_details_by_url($row['author-link']); + $contact = Contact::getDetailsByURL($row['author-link']); if (count($contact) > 0) { $unknown_contacts[] = array( @@ -738,12 +754,12 @@ function navbar_complete(App $a) { // logger('navbar_complete'); - if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + if ((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) { return; } // check if searching in the local global contact table is enabled - $localsearch = get_config('system','poco_local_search'); + $localsearch = Config::get('system','poco_local_search'); $search = $prefix.notags(trim($_REQUEST['search'])); $mode = $_REQUEST['smode']; @@ -758,7 +774,7 @@ function navbar_complete(App $a) { } if ($localsearch) { - $x = DirSearch::global_search_by_name($search, $mode); + $x = GContact::searchByName($search, $mode); return $x; }