X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Facl_selectors.php;h=d1b791136f6aec05c84d7d0d3a51b6be7e4cb209;hb=5a0260a10fa375d34ceabd32363003f91aca18a4;hp=fbe5d1e6929910fef54479bedcad7638327996ae;hpb=95a358a4a5c5ffd59aead4706448f7d979a59765;p=friendica.git diff --git a/include/acl_selectors.php b/include/acl_selectors.php index fbe5d1e692..d1b791136f 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -1,16 +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\" "; @@ -55,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; @@ -156,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\" "; @@ -207,7 +208,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : ""); - if ($privmail AND $preselected) { + if ($privmail && $preselected) { $sql_extra .= " AND `id` IN (".implode(",", $preselected).")"; $hidepreselected = ' style="display: none;"'; } else { @@ -236,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\" "; @@ -259,7 +260,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o .= "\r\n"; - if ($privmail AND $preselected) { + if ($privmail && $preselected) { $o .= implode(", ", $receiverlist); } @@ -283,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']); @@ -330,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; @@ -339,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; @@ -376,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") ), )); @@ -386,6 +387,9 @@ function populate_acl($user = null, $show_jotnets = false) { } function construct_acl_data(App $a, $user) { + // This function is now deactivated. It seems as if the generated data isn't used anywhere. + /// @todo Remove this function and all function calls before releasing Friendica 3.5.3 + return; // Get group and contact information for html ACL selector $acl_data = acl_lookup($a, 'html'); @@ -468,28 +472,37 @@ function acl_lookup(App $a, $out_type = 'json') { $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 `notify` != '' $sql_extra2" , 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 `network` IN ('%s','%s','%s') $sql_extra2" , + AND `success_update` >= `failure_update` + 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 @@ -539,13 +552,16 @@ function acl_lookup(App $a, $out_type = 'json') { "forum" => '0' ); } + if ((count($groups) > 0) && ($search == "")) { + $groups[] = array("separator" => true); + } } if ($type == '') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact` + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, (`prv` OR `forum`) AS `frm` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' - AND NOT (`network` IN ('%s', '%s')) + AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s', '%s')) $sql_extra2 ORDER BY `name` ASC ", intval(local_user()), @@ -554,27 +570,35 @@ function acl_lookup(App $a, $out_type = 'json') { } elseif ($type == 'c') { $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 NOT (`network` IN ('%s')) + AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s')) $sql_extra2 ORDER BY `name` ASC ", 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 `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') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact` - WHERE `uid` = %d AND `pending` = 0 + WHERE `uid` = %d AND `pending` = 0 AND `success_update` >= `failure_update` $sql_extra2 ORDER BY `name` ASC ", intval(local_user()) @@ -607,9 +631,10 @@ function acl_lookup(App $a, $out_type = 'json') { } - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { + $forums = array(); foreach ($r as $g) { - $contacts[] = array( + $entry = array( 'type' => 'c', 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), 'name' => htmlentities($g['name']), @@ -620,6 +645,17 @@ function acl_lookup(App $a, $out_type = 'json') { 'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']), 'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0), ); + if ($entry['forum']) { + $forums[] = $entry; + } else { + $contacts[] = $entry; + } + } + if (count($forums) > 0) { + if ($search == "") { + $forums[] = array("separator" => true); + } + $contacts = array_merge($forums, $contacts); } } @@ -649,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( @@ -718,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']; @@ -738,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; }