<?php
-
/**
* @file include/acl_selectors.php
*/
-
use Friendica\App;
+use Friendica\Content\Feature;
+use Friendica\Content\Widget;
use Friendica\Core\Config;
use Friendica\Database\DBM;
-use Friendica\Model\GlobalContact;
-use Friendica\Object\Contact;
+use Friendica\Model\Contact;
+use Friendica\Model\GContact;
-require_once "include/contact_selectors.php";
-require_once "include/contact_widgets.php";
-require_once "include/features.php";
require_once "mod/proxy.php";
-
/**
* @package acl_selectors
*/
'$aclModalTitle' => t('Permissions'),
'$aclModalDismiss' => t('Close'),
'$features' => array(
- 'aclautomention' => (feature_enabled($user['uid'], "aclautomention") ? "true" : "false")
+ 'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "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');
-
- $user_defaults = get_acl_permissions($user);
-
- if ($acl_data['groups']) {
- foreach ($acl_data['groups'] as $key => $group) {
- // Add a "selected" flag to groups that are posted to by default
- if ($user_defaults['allow_gid'] &&
- in_array($group['id'], $user_defaults['allow_gid']) && !in_array($group['id'], $user_defaults['deny_gid']) ) {
- $acl_data['groups'][$key]['selected'] = 1;
- } else {
- $acl_data['groups'][$key]['selected'] = 0;
- }
- }
- }
- if ($acl_data['contacts']) {
- foreach ($acl_data['contacts'] as $key => $contact) {
- // Add a "selected" flag to groups that are posted to by default
- if ($user_defaults['allow_cid'] &&
- in_array($contact['id'], $user_defaults['allow_cid']) && !in_array($contact['id'], $user_defaults['deny_cid']) ) {
- $acl_data['contacts'][$key]['selected'] = 1;
- } else {
- $acl_data['contacts'][$key]['selected'] = 0;
- }
- }
- }
-
- return $acl_data;
-
-}
-
-function acl_lookup(App $a, $out_type = 'json') {
-
+function acl_lookup(App $a, $out_type = 'json')
+{
if (!local_user()) {
return '';
}
- $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0);
- $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
- $search = (x($_REQUEST,'search') ? $_REQUEST['search'] : "");
- $type = (x($_REQUEST,'type') ? $_REQUEST['type'] : "");
- $mode = (x($_REQUEST,'smode') ? $_REQUEST['smode'] : "");
- $conv_id = (x($_REQUEST,'conversation') ? $_REQUEST['conversation'] : null);
+ $start = defaults($_REQUEST, 'start' , 0);
+ $count = defaults($_REQUEST, 'count' , 100);
+ $search = defaults($_REQUEST, 'search' , '');
+ $type = defaults($_REQUEST, 'type' , '');
+ $conv_id = defaults($_REQUEST, 'conversation', null);
// For use with jquery.textcomplete for private mail completion
-
- if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
+ if (x($_REQUEST, 'query')) {
if (! $type) {
$type = 'm';
}
logger("Searching for ".$search." - type ".$type, LOGGER_DEBUG);
- if ($search != "") {
+ if ($search != '') {
$sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'";
$sql_extra2 = "AND (`attag` LIKE '%%".dbesc($search)."%%' OR `name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')";
} else {
$group_count = 0;
}
- $sql_extra2 .= " ".unavailable_networks();
+ $sql_extra2 .= " ".Widget::unavailableNetworks();
if ($type == '' || $type == 'c') {
// autocomplete for editor mentions
$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') {
-
// autocomplete for Contacts
-
$r = q("SELECT COUNT(*) AS c FROM `contact`
WHERE `uid` = %d AND NOT `self`
AND NOT `pending` $sql_extra2" ,
intval(local_user())
);
$contact_count = (int)$r[0]['c'];
-
} else {
$contact_count = 0;
}
-
- $tot = $group_count+$contact_count;
+ $tot = $group_count + $contact_count;
$groups = array();
$contacts = array();
if ($type == '' || $type == 'g') {
-
/// @todo We should cache this query.
// This can be done when we can delete cache entries via wildcard
$r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
FROM `group`
- INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id` AND `group_member`.`uid` = `group`.`uid`
+ INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id`
WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
$sql_extra
GROUP BY `group`.`name`, `group`.`id`
);
foreach ($r as $g) {
-// logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']);
$groups[] = array(
"type" => "g",
"photo" => "images/twopeople.png",
}
if ($type == '') {
-
$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 `success_update` >= `failure_update` AND NOT (`network` IN ('%s', '%s'))
} 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') {
$r = array();
}
-
if (DBM::is_result($r)) {
$forums = array();
foreach ($r as $g) {
}
if ($localsearch) {
- $x = GlobalContact::searchByName($search, $mode);
+ $x = GContact::searchByName($search, $mode);
return $x;
}
if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
- $x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
+ $x = z_fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search));
if ($x['success']) {
- $t = 0;
$j = json_decode($x['body'],true);
- if ($j && $j['results']) {
+ if ($j && isset($j['results'])) {
return $j['results'];
}
}