aboutsummaryrefslogtreecommitdiffstats
path: root/mod/acl.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/acl.php')
-rw-r--r--mod/acl.php132
1 files changed, 89 insertions, 43 deletions
diff --git a/mod/acl.php b/mod/acl.php
index 2f1866f85..fa399a9b5 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -39,7 +39,7 @@ function acl_init(&$a){
// count groups and contacts
if ($type=='' || $type=='g'){
- $r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
+ $r = q("SELECT COUNT(`id`) AS g FROM `groups` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
intval(local_user())
);
$group_count = (int)$r[0]['g'];
@@ -49,37 +49,52 @@ function acl_init(&$a){
if ($type=='' || $type=='c'){
$r = q("SELECT COUNT(abook_id) AS c FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d AND not ( abook_flags & %d ) $sql_extra2" ,
+ WHERE abook_channel = %d AND not ( abook_flags & %d ) and not (xchan_flags & %d ) $sql_extra2" ,
intval(local_user()),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVE)
+ intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED),
+ intval(XCHAN_FLAGS_DELETED)
);
$contact_count = (int)$r[0]['c'];
+
+ if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_user(),'system','taganyone'))) {
+ if(((! $r) || (! $r[0]['total'])) && $type == 'c') {
+ $r = q("SELECT COUNT(xchan_hash) AS c FROM xchan
+ WHERE not (xchan_flags & %d ) $sql_extra2" ,
+ intval(XCHAN_FLAGS_DELETED)
+ );
+ $contact_count = (int)$r[0]['c'];
+ }
+ }
+
}
elseif ($type == 'm') {
// autocomplete for Private Messages
- $r = q("SELECT COUNT(`id`) AS c FROM `contact`
- WHERE `uid` = %d AND `self` = 0
- AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
- AND `network` IN ('%s','%s','%s') $sql_extra2" ,
+
+ $r = q("SELECT count(xchan_hash) as c
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and ( (abook_their_perms = null) or (abook_their_perms & %d ))
+ and not ( xchan_flags & %d )
+ $sql_extra2 ",
intval(local_user()),
- dbesc(NETWORK_DFRN),
- dbesc(NETWORK_ZOT),
- dbesc(NETWORK_DIASPORA)
+ intval(PERMS_W_MAIL),
+ intval(XCHAN_FLAGS_DELETED)
);
- $contact_count = (int)$r[0]['c'];
+
+ if($r)
+ $contact_count = (int)$r[0]['c'];
}
elseif ($type == 'a') {
// autocomplete for Contacts
- $r = q("SELECT COUNT(`id`) AS c FROM `contact`
- WHERE `uid` = %d AND `self` = 0
- AND `pending` = 0 $sql_extra2" ,
- intval(local_user())
+ $r = q("SELECT COUNT(abook_id) AS c FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and not ( xchan_flags & %d ) $sql_extra2" ,
+ intval(local_user()),
+ intval(XCHAN_FLAGS_DELETED)
);
$contact_count = (int)$r[0]['c'];
@@ -94,14 +109,14 @@ function acl_init(&$a){
if ($type=='' || $type=='g'){
- $r = q("SELECT `group`.`id`, `group`.`hash`, `group`.`name`,
+ $r = q("SELECT `groups`.`id`, `groups`.`hash`, `groups`.`name`,
GROUP_CONCAT(DISTINCT `group_member`.`xchan` SEPARATOR ',') as uids
- FROM `group`,`group_member`
- WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d
- AND `group_member`.`gid`=`group`.`id`
+ FROM `groups`,`group_member`
+ WHERE `groups`.`deleted` = 0 AND `groups`.`uid` = %d
+ AND `group_member`.`gid`=`groups`.`id`
$sql_extra
- GROUP BY `group`.`id`
- ORDER BY `group`.`name`
+ GROUP BY `groups`.`id`
+ ORDER BY `groups`.`name`
LIMIT %d,%d",
intval(local_user()),
intval($start),
@@ -121,32 +136,47 @@ function acl_init(&$a){
);
}
}
-
+
if ($type=='' || $type=='c') {
- $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick
+ $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags
FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d AND not ( abook_flags & %d ) $sql_extra2 order by xchan_name asc" ,
+ WHERE abook_channel = %d AND not ( abook_flags & %d ) and not (xchan_flags & %d ) $sql_extra2 order by xchan_name asc" ,
intval(local_user()),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVE)
+ intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED),
+ intval(XCHAN_FLAGS_DELETED)
);
+ if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_user(),'system','taganyone'))) {
+ if((! $r) && $type == 'c') {
+ $r = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags
+ FROM xchan
+ WHERE not (xchan_flags & %d ) $sql_extra2 order by xchan_name asc" ,
+ intval(XCHAN_FLAGS_DELETED)
+ );
+ }
+ }
}
elseif($type == 'm') {
$r = q("SELECT xchan_hash as id, xchan_name as name, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and ( (abook_their_perms = null) or (abook_their_perms & %d ))
+ and not (xchan_flags & %d)
$sql_extra3
ORDER BY `xchan_name` ASC ",
intval(local_user()),
- intval(PERMS_W_MAIL)
+ intval(PERMS_W_MAIL),
+ intval(XCHAN_FLAGS_DELETED)
);
}
elseif($type == 'a') {
- $r = q("SELECT abook_id as id, xchan_name as name, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag FROM abook left join xchan on abook_xchan = xchan_hash
+ $r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d
+ and not (xchan_flags & %d)
$sql_extra3
ORDER BY xchan_name ASC ",
- intval(local_user())
+ intval(local_user()),
+ intval(XCHAN_FLAGS_DELETED)
+
);
}
elseif($type == 'x') {
@@ -195,14 +225,31 @@ function acl_init(&$a){
if(count($r)) {
foreach($r as $g){
+ if(($g['abook_their_perms'] & PERMS_W_TAGWALL) && $type == 'c') {
+ $contacts[] = array(
+ "type" => "c",
+ "photo" => "images/twopeople.png",
+ "name" => $g['name'] . '+',
+ "id" => $g['id'] . '+',
+ "xid" => $g['hash'],
+ "link" => $g['nick'],
+ "nick" => substr($g['nick'],0,strpos($g['nick'],'@')),
+ "self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''),
+ "taggable" => 'taggable',
+ "label" => t('network')
+ );
+ }
$contacts[] = array(
- "type" => "c",
- "photo" => $g['micro'],
- "name" => $g['name'],
- "id" => $g['id'],
- "xid" => $g['hash'],
- "link" => $g['nick'],
- "nick" => substr($g['nick'],0,strpos($g['nick'],'@'))
+ "type" => "c",
+ "photo" => $g['micro'],
+ "name" => $g['name'],
+ "id" => $g['id'],
+ "xid" => $g['hash'],
+ "link" => $g['nick'],
+ "nick" => substr($g['nick'],0,strpos($g['nick'],'@')),
+ "self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''),
+ "taggable" => '',
+ "label" => '',
);
}
}
@@ -226,6 +273,10 @@ function navbar_complete(&$a) {
// logger('navbar_complete');
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ return;
+ }
+
$dirmode = intval(get_config('system','directory_mode'));
$search = ((x($_REQUEST,'query')) ? htmlentities($_REQUEST['query'],ENT_COMPAT,'UTF-8',false) : '');
if(! $search || mb_strlen($search) < 2)
@@ -251,14 +302,9 @@ function navbar_complete(&$a) {
}
if(! $url) {
+ require_once("include/dir_fns.php");
$directory = find_upstream_directory($dirmode);
-
- if($directory) {
- $url = $directory['url'];
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch';
- }
+ $url = $directory['url'] . '/dirsearch';
}
if($url) {
@@ -275,4 +321,4 @@ function navbar_complete(&$a) {
}
}
return array();
-} \ No newline at end of file
+}