convert the abook fields

This commit is contained in:
redmatrix 2015-06-14 21:08:00 -07:00
parent f0b255b1a9
commit be0459a98b
34 changed files with 241 additions and 279 deletions

View File

@ -34,18 +34,16 @@ function rconnect_url($channel_id,$xchan) {
function abook_connections($channel_id, $sql_conditions = '') {
$r = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d
and not ( abook_flags & %d )>0 $sql_conditions",
intval($channel_id),
intval(ABOOK_FLAG_SELF)
and abook_self = 0 $sql_conditions",
intval($channel_id)
);
return(($r) ? $r : array());
}
function abook_self($channel_id) {
$r = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d
and ( abook_flags & %d )>0 limit 1",
intval($channel_id),
intval(ABOOK_FLAG_SELF)
and abook_self = 1 limit 1",
intval($channel_id)
);
return(($r) ? $r[0] : array());
}
@ -128,9 +126,40 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') {
function abook_toggle_flag($abook,$flag) {
$r = q("UPDATE abook set abook_flags = (abook_flags %s %d) where abook_id = %d and abook_channel = %d",
db_getfunc('^'),
intval($flag),
$field = '';
switch($flag) {
case ABOOK_FLAG_BLOCKED:
$field = 'abook_blocked';
break;
case ABOOK_FLAG_IGNORED:
$field = 'abook_ignored';
break;
case ABOOK_FLAG_HIDDEN:
$field = 'abook_hidden';
break;
case ABOOK_FLAG_ARCHIVED:
$field = 'abook_archived';
break;
case ABOOK_FLAG_PENDING:
$field = 'abook_pending';
break;
case ABOOK_FLAG_UNCONNECTED:
$field = 'abook_unconnected';
break;
case ABOOK_FLAG_SELF:
$field = 'abook_self';
break;
case ABOOK_FLAG_FEED:
$field = 'abook_feed';
break;
default:
break;
}
if(! $field)
return;
$r = q("UPDATE abook set $field = (1 - $field) where abook_id = %d and abook_channel = %d",
intval($abook['abook_id']),
intval($abook['abook_channel'])
);
@ -138,7 +167,7 @@ function abook_toggle_flag($abook,$flag) {
// if unsetting the archive bit, update the timestamps so we'll try to connect for an additional 30 days.
if(($flag === ABOOK_FLAG_ARCHIVED) && ($abook['abook_flags'] & ABOOK_FLAG_ARCHIVED)) {
if(($flag === ABOOK_FLAG_ARCHIVED) && (intval($abook['abook_archived']))) {
$r = q("update abook set abook_connected = '%s', abook_updated = '%s'
where abook_id = %d and abook_channel = %d",
dbesc(datetime_convert()),
@ -298,9 +327,8 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
q("DELETE FROM `spam` WHERE `uid` = %d", intval($channel_id));
q("delete from abook where abook_xchan = '%s' and (abook_flags & %d)>0",
dbesc($channel['channel_hash']),
dbesc(ABOOK_FLAG_SELF)
q("delete from abook where abook_xchan = '%s' and abook_self = 1 ",
dbesc($channel['channel_hash'])
);
$r = q("update channel set channel_deleted = '%s', channel_pageflags = (channel_pageflags | %d) where channel_id = %d",
@ -506,8 +534,7 @@ function contact_remove($channel_id, $abook_id) {
$archive = get_pconfig($channel_id, 'system','archive_removed_contacts');
if($archive) {
q("update abook set abook_flags = ( abook_flags | %d ) where abook_id = %d and abook_channel = %d",
intval(ABOOK_FLAG_ARCHIVED),
q("update abook set abook_archived = 1 where abook_id = %d and abook_channel = %d",
intval($abook_id),
intval($channel_id)
);
@ -524,7 +551,7 @@ function contact_remove($channel_id, $abook_id) {
$abook = $r[0];
if($abook['abook_flags'] & ABOOK_FLAG_SELF)
if(intval($abook['abook_self']))
return false;

View File

@ -170,7 +170,7 @@ class Conversation extends BaseObject {
$item->set_commentable(false);
}
elseif(($this->observer) && (! $item->is_commentable())) {
if((array_key_exists('owner',$item->data)) && ($item->data['owner']['abook_flags'] & ABOOK_FLAG_SELF))
if((array_key_exists('owner',$item->data)) && intval($item->data['owner']['abook_self']))
$item->set_commentable(perm_is_allowed($this->profile_owner,$this->observer['xchan_hash'],'post_comments'));
else
$item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data));

View File

@ -171,10 +171,9 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n";
$r = q("SELECT abook_id, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash
where abook_flags = 0 or not ( abook_flags & %d )>0 and abook_channel = %d
where abook_self = 0 and abook_channel = %d
$sql_extra
ORDER BY xchan_name ASC ",
intval(ABOOK_FLAG_SELF),
intval(local_channel())
);

View File

@ -318,7 +318,7 @@ require_once('include/items.php');
return False;
} else {
$user = local_channel();
$extra_query = " AND abook_channel = %d AND (abook_flags & " . ABOOK_FLAG_SELF . " )>0 ";
$extra_query = " AND abook_channel = %d AND abook_self = 1 ";
}
}
@ -336,7 +336,7 @@ require_once('include/items.php');
return False;
}
if($uinfo[0]['abook_flags'] & ABOOK_FLAG_SELF) {
if(intval($uinfo[0]['abook_self'])) {
$usr = q("select * from channel where channel_id = %d limit 1",
intval(api_user())
);
@ -368,7 +368,7 @@ require_once('include/items.php');
// count friends
if($usr) {
$r = q("SELECT COUNT(abook_id) as `count` FROM abook
WHERE abook_channel = %d AND abook_flags = 0 ",
WHERE abook_channel = %d AND abook_self = 0 ",
intval($usr[0]['channel_id'])
);
$countfriends = $r[0]['count'];
@ -381,7 +381,7 @@ require_once('include/items.php');
$starred = $r[0]['count'];
if(! ($uinfo[0]['abook_flags'] & ABOOK_FLAG_SELF)) {
if(! intval($uinfo[0]['abook_self'])) {
$countfriends = 0;
$countfollowers = 0;
$starred = 0;
@ -389,7 +389,7 @@ require_once('include/items.php');
$ret = Array(
'id' => intval($uinfo[0]['abook_id']),
'self' => (($uinfo[0]['abook_flags'] & ABOOK_FLAG_SELF) ? 1 : 0),
'self' => (intval($uinfo[0]['abook_self']) ? 1 : 0),
'uid' => intval($uinfo[0]['abook_channel']),
'guid' => $uinfo[0]['xchan_hash'],
'name' => (($uinfo[0]['xchan_name']) ? $uinfo[0]['xchan_name'] : substr($uinfo[0]['xchan_addr'],0,strpos($uinfo[0]['xchan_addr'],'@'))),
@ -1929,7 +1929,7 @@ require_once('include/items.php');
if($qtype == 'followers')
$sql_extra = sprintf(" AND ( abook_my_perms & %d )>0 and not ( abook_their_perms & %d )>0 ", intval(PERMS_W_STREAM), intval(PERMS_W_STREAM));
$r = q("SELECT abook_id FROM abook where abook_flags = 0 and abook_channel = %d $sql_extra",
$r = q("SELECT abook_id FROM abook where abook_self = 0 and abook_channel = %d $sql_extra",
intval(api_user())
);
@ -2045,7 +2045,7 @@ require_once('include/items.php');
if($qtype == 'followers')
$sql_extra = sprintf(" AND ( abook_my_perms & %d )>0 and not ( abook_their_perms & %d )>0 ", intval(PERMS_W_STREAM), intval(PERMS_W_STREAM));
$r = q("SELECT abook_id FROM abook where abook_flags = 0 and abook_channel = %d $sql_extra",
$r = q("SELECT abook_id FROM abook where abook_self = 0 and abook_channel = %d $sql_extra",
intval(api_user())
);

View File

@ -919,7 +919,7 @@ function item_photo_menu($item){
if($contact) {
$poke_link = $a->get_baseurl($ssl_state) . '/poke/?f=&c=' . $contact['abook_id'];
if (!($contact['abook_flags'] & ABOOK_FLAG_SELF))
if (! intval($contact['abook_self']))
$contact_url = $a->get_baseurl($ssl_state) . '/connedit/' . $contact['abook_id'];
$posts_link = $a->get_baseurl($ssl_state) . '/network/?cid=' . $contact['abook_id'];

View File

@ -783,7 +783,7 @@ function diaspora_request($importer,$xml) {
$closeness = 80;
$r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_my_perms, abook_their_perms, abook_closeness, abook_rating, abook_created, abook_updated, abook_connected, abook_dob, abook_flags) values ( %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d )",
$r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_my_perms, abook_their_perms, abook_closeness, abook_rating, abook_created, abook_updated, abook_connected, abook_dob, abook_pending) values ( %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d )",
intval($importer['channel_account_id']),
intval($importer['channel_id']),
dbesc($ret['xchan_hash']),
@ -795,7 +795,7 @@ function diaspora_request($importer,$xml) {
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(NULL_DATE),
intval(($default_perms) ? 0 : ABOOK_FLAG_PENDING)
intval(($default_perms) ? 0 : 1)
);

View File

@ -37,9 +37,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
// check service class limits
$r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d)>0 ",
intval($uid),
intval(ABOOK_FLAG_SELF)
$r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ",
intval($uid)
);
if($r)
$total_channels = $r[0]['total'];
@ -205,9 +204,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
return $result;
}
$r = q("select count(*) as total from abook where abook_account = %d and ( abook_flags & %d )>0",
intval($aid),
intval(ABOOK_FLAG_FEED)
$r = q("select count(*) as total from abook where abook_account = %d and abook_feed = 1 ",
intval($aid)
);
if($r)
$total_feeds = $r[0]['total'];
@ -239,13 +237,13 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
if($closeness === false)
$closeness = 80;
$r = q("insert into abook ( abook_account, abook_channel, abook_closeness, abook_xchan, abook_flags, abook_their_perms, abook_my_perms, abook_created, abook_updated )
$r = q("insert into abook ( abook_account, abook_channel, abook_closeness, abook_xchan, abook_feed, abook_their_perms, abook_my_perms, abook_created, abook_updated )
values( %d, %d, %d, '%s', %d, %d, %d, '%s', '%s' ) ",
intval($aid),
intval($uid),
intval($closeness),
dbesc($xchan_hash),
intval(($is_http) ? ABOOK_FLAG_FEED : 0),
intval(($is_http) ? 1 : 0),
intval(($is_http) ? $their_perms|PERMS_R_STREAM|PERMS_A_REPUBLISH : $their_perms),
intval($my_perms),
dbesc(datetime_convert()),

View File

@ -200,12 +200,10 @@ function group_get_members($gid) {
if(intval($gid)) {
$r = q("SELECT * FROM `group_member`
LEFT JOIN abook ON abook_xchan = `group_member`.`xchan` left join xchan on xchan_hash = abook_xchan
WHERE `gid` = %d AND abook_channel = %d and `group_member`.`uid` = %d and xchan_deleted = 0 and not ( abook_flags & %d )>0 and not ( abook_flags & %d )>0 ORDER BY xchan_name ASC ",
WHERE `gid` = %d AND abook_channel = %d and `group_member`.`uid` = %d and xchan_deleted = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ",
intval($gid),
intval(local_channel()),
intval(local_channel()),
intval(ABOOK_FLAG_BLOCKED),
intval(ABOOK_FLAG_PENDING)
intval(local_channel())
);
if(count($r))
$ret = $r;

View File

@ -363,7 +363,7 @@ function create_identity($arr) {
|PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT
|PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE;
$r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_flags, abook_my_perms )
$r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_closeness, abook_created, abook_updated, abook_self, abook_my_perms )
values ( %d, %d, '%s', %d, '%s', '%s', %d, %d ) ",
intval($ret['channel']['channel_account_id']),
intval($newuid),
@ -371,7 +371,7 @@ function create_identity($arr) {
intval(0),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval(ABOOK_FLAG_SELF),
intval(1),
intval($myperms)
);
@ -1555,9 +1555,8 @@ function notifications_on($channel_id,$value) {
function get_channel_default_perms($uid) {
$r = q("select abook_my_perms from abook where abook_channel = %d and (abook_flags & %d) > 0 limit 1",
intval($uid),
intval(ABOOK_FLAG_SELF)
$r = q("select abook_my_perms from abook where abook_channel = %d and abook_self = 1 limit 1",
intval($uid)
);
if($r)
return $r[0]['abook_my_perms'];

View File

@ -42,9 +42,8 @@ function collect_recipients($item, &$private_envelope) {
// as that would allow the denied person to see the post by logging out.
if((! $item['allow_cid']) && (! $item['allow_gid'])) {
$r = q("select * from abook where abook_channel = %d and not (abook_flags & %d)>0 ",
intval($item['uid']),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED)
$r = q("select * from abook where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ",
intval($item['uid'])
);
if($r) {
@ -82,9 +81,8 @@ function collect_recipients($item, &$private_envelope) {
//$sys = get_sys_channel();
if(array_key_exists('public_policy',$item) && $item['public_policy'] !== 'self') {
$r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d)>0 ",
intval($item['uid']),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED)
$r = q("select abook_xchan, xchan_network from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and abook_pending = 0 and abook_archived = 0 ",
intval($item['uid'])
);
if($r) {
@ -3281,7 +3279,7 @@ function check_item_source($uid, $item) {
if(! $r)
return false;
$x = q("select abook_their_perms, abook_flags from abook where abook_channel = %d and abook_xchan = '%s' limit 1",
$x = q("select abook_their_perms, abook_feed from abook where abook_channel = %d and abook_xchan = '%s' limit 1",
intval($uid),
dbesc($item['owner_xchan'])
);
@ -3292,7 +3290,7 @@ function check_item_source($uid, $item) {
if(! ($x[0]['abook_their_perms'] & PERMS_A_REPUBLISH))
return false;
if($item['item_private'] && (! ($x[0]['abook_flags'] & ABOOK_FLAG_FEED)))
if($item['item_private'] && (! intval($x[0]['abook_feed'])))
return false;
if($r[0]['src_channel_xchan'] === $item['owner_xchan'])
@ -4491,7 +4489,7 @@ function zot_feed($uid,$observer_hash,$arr) {
if(is_sys_channel($uid)) {
$r = q("SELECT parent, created, postopts from item
WHERE uid != %d
and uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ") $item_normal
$item_normal
AND item_wall = 1
and item_private = 0 $sql_extra GROUP BY parent ORDER BY created ASC $limit",
intval($uid)
@ -4611,7 +4609,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
elseif($arr['cid'] && $uid) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ")>0 limit 1",
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1",
intval($arr['cid']),
intval(local_channel())
);
@ -4735,10 +4733,9 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
left join abook on item.author_xchan = abook.abook_xchan
WHERE $item_uids $item_restrict
AND item.parent = item.id
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets
ORDER BY item.$ordering DESC $pager_sql ",
intval(ABOOK_FLAG_BLOCKED)
ORDER BY item.$ordering DESC $pager_sql "
);
}
@ -4747,9 +4744,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
$r = q("SELECT item.parent AS item_id FROM item
left join abook on item.author_xchan = abook.abook_xchan
WHERE $item_uids $item_restrict $simple_update
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets ",
intval(ABOOK_FLAG_BLOCKED)
and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets "
);
}

View File

@ -100,10 +100,9 @@ function notifier_run($argv, $argc){
// Get the recipient
$r = q("select abook.*, hubloc.* from abook
left join hubloc on hubloc_hash = abook_xchan
where abook_id = %d and not ( abook_flags & %d ) > 0
where abook_id = %d and abook_self = 0
and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0 limit 1",
intval($item_id),
intval(ABOOK_FLAG_SELF),
intval(HUBLOC_FLAGS_DELETED),
intval(HUBLOC_OFFLINE)
);

View File

@ -28,13 +28,9 @@ function onepoll_run($argv, $argc){
$contacts = q("SELECT abook.*, xchan.*, account.*
FROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan
where abook_id = %d
AND (( abook_flags & %d )>0 OR ( abook_flags = %d ))
AND NOT ( abook_flags & %d )>0
and abook_pending = 0 and abook_archived = 0 and abook_blocked = 0 and abook_ignored = 0
AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1",
intval($contact_id),
intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED|ABOOK_FLAG_FEED),
intval(0),
intval(ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_BLOCKED|ABOOK_FLAG_IGNORED),
intval(ACCOUNT_OK),
intval(ACCOUNT_UNVERIFIED)
);

View File

@ -113,11 +113,10 @@ function get_all_perms($uid, $observer_xchan, $internal_use = true) {
}
if(! $abook_checked) {
$x = q("select abook_my_perms, abook_flags, xchan_network from abook left join xchan on abook_xchan = xchan_hash
where abook_channel = %d and abook_xchan = '%s' and not ( abook_flags & %d )>0 limit 1",
$x = q("select abook_my_perms, abook_blocked, abook_ignored, abook_pending, xchan_network from abook left join xchan on abook_xchan = xchan_hash
where abook_channel = %d and abook_xchan = '%s' and abook_self = 0 limit 1",
intval($uid),
dbesc($observer_xchan),
intval(ABOOK_FLAG_SELF)
dbesc($observer_xchan)
);
if(! $x) {
// not in address book, see if they've got an xchan
@ -131,7 +130,7 @@ function get_all_perms($uid, $observer_xchan, $internal_use = true) {
// If they're blocked - they can't read or write
if(($x) && ($x[0]['abook_flags'] & ABOOK_FLAG_BLOCKED)) {
if(($x) && intval($x[0]['abook_blocked'])) {
$ret[$perm_name] = false;
continue;
}
@ -139,7 +138,7 @@ function get_all_perms($uid, $observer_xchan, $internal_use = true) {
// Check if this is a write permission and they are being ignored
// This flag is only visible internally.
if(($x) && ($internal_use) && (! $global_perms[$perm_name][2]) && ($x[0]['abook_flags'] & ABOOK_FLAG_IGNORED)) {
if(($x) && ($internal_use) && (! $global_perms[$perm_name][2]) && intval($x[0]['abook_ignored'])) {
$ret[$perm_name] = false;
continue;
}
@ -218,7 +217,7 @@ function get_all_perms($uid, $observer_xchan, $internal_use = true) {
continue;
}
if($x[0]['abook_flags'] & ABOOK_FLAG_PENDING) {
if(intval($x[0]['abook_pending'])) {
$ret[$perm_name] = false;
continue;
}
@ -300,19 +299,18 @@ function perm_is_allowed($uid, $observer_xchan, $permission) {
if($r[0][$channel_perm] & PERMS_AUTHED)
return true;
$x = q("select abook_my_perms, abook_flags, xchan_network from abook left join xchan on abook_xchan = xchan_hash
where abook_channel = %d and abook_xchan = '%s' and not ( abook_flags & %d )>0 limit 1",
$x = q("select abook_my_perms, abook_blocked, abook_ignored, abook_pending, xchan_network from abook left join xchan on abook_xchan = xchan_hash
where abook_channel = %d and abook_xchan = '%s' and abook_self = 0 limit 1",
intval($uid),
dbesc($observer_xchan),
intval(ABOOK_FLAG_SELF)
dbesc($observer_xchan)
);
// If they're blocked - they can't read or write
if(($x) && ($x[0]['abook_flags'] & ABOOK_FLAG_BLOCKED))
if(($x) && intval($x[0]['abook_blocked']))
return false;
if(($x) && (! $global_perms[$permission][2]) && ($x[0]['abook_flags'] & ABOOK_FLAG_IGNORED))
if(($x) && (! $global_perms[$permission][2]) && intval($x[0]['abook_ignored']))
return false;
if(! $x) {
@ -374,7 +372,7 @@ function perm_is_allowed($uid, $observer_xchan, $permission) {
return true;
}
if($x[0]['abook_flags'] & ABOOK_FLAG_PENDING) {
if(intval($x[0]['abook_pending'])) {
return false;
}

View File

@ -293,13 +293,11 @@ function poller_run($argv, $argc){
$randfunc = db_getfunc('RAND');
$contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_xchan, abook_channel, xchan_network
FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash LEFT JOIN account on abook_account = account_id
$contacts = q("SELECT * FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash
LEFT JOIN account on abook_account = account_id
where abook_self = 0
$sql_extra
AND (( abook_flags & %d ) > 0 OR ( abook_flags = %d ))
AND (( account_flags = %d ) OR ( account_flags = %d )) $abandon_sql ORDER BY $randfunc",
intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED|ABOOK_FLAG_FEED),
intval(0),
intval(ACCOUNT_OK),
intval(ACCOUNT_UNVERIFIED) // FIXME
@ -309,15 +307,12 @@ function poller_run($argv, $argc){
foreach($contacts as $contact) {
if($contact['abook_flags'] & ABOOK_FLAG_SELF)
continue;
$update = false;
$t = $contact['abook_updated'];
$c = $contact['abook_connected'];
if($contact['abook_flags'] & ABOOK_FLAG_FEED) {
if(intval($contact['abook_feed'])) {
$min = service_class_fetch($contact['abook_channel'],'minimum_feedcheck_minutes');
if(! $min)
$min = intval(get_config('system','minimum_feedcheck_minutes'));
@ -356,15 +351,14 @@ function poller_run($argv, $argc){
// He's dead, Jim
if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) {
$r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d",
intval(ABOOK_FLAG_ARCHIVED),
$r = q("update abook set abook_archived = 1 where abook_id = %d",
intval($contact['abook_id'])
);
$update = false;
continue;
}
if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) {
if(intval($contact['abook_archived'])) {
$update = false;
continue;
}
@ -385,7 +379,7 @@ function poller_run($argv, $argc){
}
if($contact['abook_flags'] & (ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_IGNORED))
if(intval($contact['abook_pending']) || intval($contact['abook_archived']) || intval($contact['abook_ignored']) || intval($contact['abook_blocked']))
continue;
if((! $update) && (! $force))

View File

@ -212,7 +212,7 @@ function poco_load($xchan = '', $url = null) {
function count_common_friends($uid,$xchan) {
$r = q("SELECT count(xlink_id) as total from xlink where xlink_xchan = '%s' and xlink_static = 0 and xlink_link in
(select abook_xchan from abook where abook_xchan != '%s' and abook_channel = %d and abook_flags = 0 )",
(select abook_xchan from abook where abook_xchan != '%s' and abook_channel = %d and abook_self = 0 )",
dbesc($xchan),
dbesc($xchan),
intval($uid)
@ -233,7 +233,7 @@ function common_friends($uid,$xchan,$start = 0,$limit=100000000,$shuffle = false
$sql_extra = " order by xchan_name asc ";
$r = q("SELECT * from xchan left join xlink on xlink_link = xchan_hash where xlink_xchan = '%s' and xlink_static = 0 and xlink_link in
(select abook_xchan from abook where abook_xchan != '%s' and abook_channel = %d and abook_flags = 0 ) $sql_extra limit %d offset %d",
(select abook_xchan from abook where abook_xchan != '%s' and abook_channel = %d and abook_self = 0 ) $sql_extra limit %d offset %d",
dbesc($xchan),
dbesc($xchan),
intval($uid),
@ -459,16 +459,16 @@ function poco($a,$extended = false) {
}
if($justme)
$sql_extra = " and ( abook_flags & " . ABOOK_FLAG_SELF . " )>0 ";
$sql_extra = " and abook_self = 1 ";
else
$sql_extra = " and abook_flags = 0 ";
$sql_extra = " and abook_self = 0 ";
if($cid)
$sql_extra = sprintf(" and abook_id = %d and ( abook_flags & " . ABOOK_FLAG_HIDDEN . " ) = 0 ",intval($cid));
$sql_extra = sprintf(" and abook_id = %d and abook_hidden = 0 ",intval($cid));
if($system_mode) {
$r = q("SELECT count(*) as `total` from abook where ( abook_flags & " . ABOOK_FLAG_SELF .
" )>0 and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') ");
$r = q("SELECT count(*) as `total` from abook where abook_self = 1
and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') ");
}
else {
$r = q("SELECT count(*) as `total` from abook where abook_channel = %d
@ -491,8 +491,9 @@ function poco($a,$extended = false) {
$itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
if($system_mode) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where ( abook_flags & " . ABOOK_FLAG_SELF .
" )>0 and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') limit %d offset %d ",
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_self = 1
and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1')
limit %d offset %d ",
intval($itemsPerPage),
intval($startIndex)
);

View File

@ -814,19 +814,19 @@ function contact_block() {
$is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false);
$sql_extra = '';
$abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF;
$abook_flags = " and abook_pending = 0 and abook_self = 0 ";
if(! $is_owner) {
$abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
$abook_flags .= " and abook_hidden = 0 ";
$sql_extra = " and xchan_hidden = 0 ";
}
if((! is_array($a->profile)) || ($a->profile['hide_friends']))
return $o;
$r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not ( abook_flags & %d )>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra",
intval($a->profile['uid']),
intval($abook_flags)
$r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
$abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra",
intval($a->profile['uid'])
);
if(count($r)) {
$total = intval($r[0]['total']);
@ -838,9 +838,8 @@ function contact_block() {
$randfunc = db_getfunc('RAND');
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND not ( abook_flags & %d)>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d",
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d $abook_flags and abook_archived = 0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d",
intval($a->profile['uid']),
intval($abook_flags|ABOOK_FLAG_ARCHIVED),
intval($shown)
);
@ -848,7 +847,7 @@ function contact_block() {
$contacts = sprintf( tt('%d Connection','%d Connections', $total),$total);
$micropro = Array();
foreach($r as $rr) {
$rr['archived'] = (($rr['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false);
$rr['archived'] = (intval($rr['abook_archived']) ? true : false);
$micropro[] = micropro($rr,true,'mpfriend');
}
}

View File

@ -155,9 +155,8 @@ function widget_follow($args) {
$a = get_app();
$uid =$a->channel['channel_id'];
$r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d)>0 ",
intval($uid),
intval(ABOOK_FLAG_SELF)
$r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ",
intval($uid)
);
if($r)
$total_channels = $r[0]['total'];
@ -473,9 +472,8 @@ function widget_settings_menu($arr) {
$role = get_pconfig(local_channel(),'system','permissions_role');
$abk = q("select abook_id from abook where abook_channel = %d and ( abook_flags & %d )>0 limit 1",
intval(local_channel()),
intval(ABOOK_FLAG_SELF)
$abk = q("select abook_id from abook where abook_channel = %d and abook_self = 1 limit 1",
intval(local_channel())
);
if($abk)
$abook_self_id = $abk[0]['abook_id'];

View File

@ -384,10 +384,9 @@ function zot_refresh($them, $channel = null, $force = false) {
}
}
$r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 limit 1",
$r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc($x['hash']),
intval($channel['channel_id']),
intval(ABOOK_FLAG_SELF)
intval($channel['channel_id'])
);
if(array_key_exists('profile',$j) && array_key_exists('next_birthday',$j['profile'])) {
@ -406,16 +405,15 @@ function zot_refresh($them, $channel = null, $force = false) {
if(substr($r[0]['abook_dob'],5) == substr($next_birthday,5))
$next_birthday = $r[0]['abook_dob'];
$current_abook_connected = (($r[0]['abook_flags'] & ABOOK_FLAG_UNCONNECTED) ? 0 : 1);
$current_abook_connected = (intval($r[0]['abook_unconnected']) ? 0 : 1);
$y = q("update abook set abook_their_perms = %d, abook_dob = '%s'
where abook_xchan = '%s' and abook_channel = %d
and not (abook_flags & %d) > 0 ",
and abook_self = 0 ",
intval($their_perms),
dbescdate($next_birthday),
dbesc($x['hash']),
intval($channel['channel_id']),
intval(ABOOK_FLAG_SELF)
intval($channel['channel_id'])
);
// if(($connected_set === 0 || $connected_set === 1) && ($connected_set !== $current_abook_unconnected)) {
@ -424,13 +422,11 @@ function zot_refresh($them, $channel = null, $force = false) {
// match your current connected state setting, toggle it.
/** @FIXME uncoverted to postgres */
/** @FIXME when this was enabled, all contacts became unconnected. Currently disabled intentionally */
// $y1 = q("update abook set abook_flags = (abook_flags ^ %d)
// $y1 = q("update abook set abook_unconnected = 1
// where abook_xchan = '%s' and abook_channel = %d
// and not (abook_flags & %d) limit 1",
// intval(ABOOK_FLAG_UNCONNECTED),
// and abook_self = 0 limit 1",
// dbesc($x['hash']),
// intval($channel['channel_id']),
// intval(ABOOK_FLAG_SELF)
// intval($channel['channel_id'])
// );
// }
@ -461,7 +457,7 @@ function zot_refresh($them, $channel = null, $force = false) {
if($closeness === false)
$closeness = 80;
$y = q("insert into abook ( abook_account, abook_channel, abook_closeness, abook_xchan, abook_their_perms, abook_my_perms, abook_created, abook_updated, abook_dob, abook_flags ) values ( %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', %d )",
$y = q("insert into abook ( abook_account, abook_channel, abook_closeness, abook_xchan, abook_their_perms, abook_my_perms, abook_created, abook_updated, abook_dob, abook_pending ) values ( %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', %d )",
intval($channel['channel_account_id']),
intval($channel['channel_id']),
intval($closeness),
@ -471,7 +467,7 @@ function zot_refresh($them, $channel = null, $force = false) {
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($next_birthday),
intval(($default_perms) ? 0 : ABOOK_FLAG_PENDING)
intval(($default_perms) ? 0 : 1)
);
if($y) {
@ -479,15 +475,14 @@ function zot_refresh($them, $channel = null, $force = false) {
$new_perms = get_all_perms($channel['channel_id'],$x['hash']);
if($new_perms != $previous_perms) {
// Send back a permissions update if permissions have changed
$z = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 limit 1",
$z = q("select * from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc($x['hash']),
intval($channel['channel_id']),
intval(ABOOK_FLAG_SELF)
intval($channel['channel_id'])
);
if($z)
proc_run('php','include/notifier.php','permission_update',$z[0]['abook_id']);
}
$new_connection = q("select abook_id, abook_flags from abook where abook_channel = %d and abook_xchan = '%s' order by abook_created desc limit 1",
$new_connection = q("select abook_id, abook_pending from abook where abook_channel = %d and abook_xchan = '%s' order by abook_created desc limit 1",
intval($channel['channel_id']),
dbesc($x['hash'])
);
@ -503,7 +498,7 @@ function zot_refresh($them, $channel = null, $force = false) {
if($new_connection && ($their_perms & PERMS_R_STREAM)) {
if(($channel['channel_w_stream'] & PERMS_PENDING)
|| (! ($new_connection[0]['abook_flags'] & ABOOK_FLAG_PENDING)) )
|| (! intval($new_connection[0]['abook_pending'])) )
proc_run('php','include/onepoll.php',$new_connection[0]['abook_id']);
}
}
@ -1333,7 +1328,7 @@ function public_recips($msg) {
where abook_xchan = '%s' and ( channel_pageflags & " . intval(PAGE_REMOVED) . " ) = 0
and (( " . $col . " & " . intval(PERMS_SPECIFIC) . " ) > 0 and ( abook_my_perms & " . intval($field) . " ) > 0 )
OR ( " . $col . " & " . intval(PERMS_PENDING) . " ) > 0
OR (( " . $col . " & " . intval(PERMS_CONTACTS) . " ) > 0 and ( abook_flags & " . intval(ABOOK_FLAG_PENDING) . " ) = 0 ) ",
OR (( " . $col . " & " . intval(PERMS_CONTACTS) . " ) > 0 and abook_pending = 0 )) ",
dbesc($msg['notify']['sender']['hash'])
);
@ -2863,14 +2858,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
$total_friends = 0;
$total_feeds = 0;
$r = q("select abook_id, abook_flags from abook where abook_channel = %d",
$r = q("select abook_id, abook_feed from abook where abook_channel = %d",
intval($channel['channel_id'])
);
if($r) {
// don't count yourself
$total_friends = ((count($r) > 0) ? count($r) - 1 : 0);
foreach($r as $rr)
if($rr['abook_flags'] & ABOOK_FLAG_FEED)
if(intval($rr['abook_feed']))
$total_feeds ++;
}
@ -2883,16 +2878,15 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
logger('process_channel_sync_delivery: removing abook entry for ' . $abook['abook_xchan']);
require_once('include/Contact.php');
$r = q("select abook_id, abook_flags from abook where abook_xchan = '%s' and abook_channel = %d and not ( abook_flags & %d )>0 limit 1",
$r = q("select abook_id, abook_feed from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc($abook['abook_xchan']),
intval($channel['channel_id']),
intval(ABOOK_FLAG_SELF)
intval($channel['channel_id'])
);
if($r) {
contact_remove($channel['channel_id'],$r[0]['abook_id']);
if($total_friends)
$total_friends --;
if($r[0]['abook_flags'] & ABOOK_FLAG_FEED)
if(intval($r[0]['abook_feed']))
$total_feeds --;
}
continue;
@ -2934,7 +2928,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
logger('process_channel_sync_delivery: total_channels service class limit exceeded');
continue;
}
if($max_feeds !== false && ($clean['abook_flags'] & ABOOK_FLAG_FEED) && $total_feeds > $max_feeds) {
if($max_feeds !== false && intval($clean['abook_feed']) && $total_feeds > $max_feeds) {
logger('process_channel_sync_delivery: total_feeds service class limit exceeded');
continue;
}
@ -2943,7 +2937,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
intval($channel['channel_id'])
);
$total_friends ++;
if($clean['abook_flags'] & ABOOK_FLAG_FEED)
if(intval($clean['abook_feed']))
$total_feeds ++;
}

View File

@ -90,13 +90,12 @@ function acl_init(&$a){
// Getting info from the abook is better for local users because it contains info about permissions
if(local_channel()) {
if($extra_channels_sql != '')
$extra_channels_sql = " OR (abook_channel IN ($extra_channels_sql)) and not (abook_flags & ". intval(ABOOK_FLAG_HIDDEN) . ') > 0';
$extra_channels_sql = " OR (abook_channel IN ($extra_channels_sql)) and abook_hidden = 0 ";
$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 $extra_channels_sql) AND not ( abook_flags & %d )>0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
intval(local_channel()),
intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED)
WHERE (abook_channel = %d $extra_channels_sql) AND abook_blocked = 0 and abook_pending = 0 and abook_archived = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
intval(local_channel())
);
}
@ -119,9 +118,7 @@ function acl_init(&$a){
$r2 = 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 IN ($extra_channels_sql) $known_hashes_sql AND not ( abook_flags & %d )>0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
intval(ABOOK_FLAG_BLOCKED|ABOOK_FLAG_PENDING|ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_HIDDEN)
);
WHERE abook_channel IN ($extra_channels_sql) $known_hashes_sql AND abook_blocked = 0 and abook_pending = 0 and abook_archived = 0 and abook_hidden = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc");
if($r2)
$r = array_merge($r,$r2);
@ -220,7 +217,7 @@ function acl_init(&$a){
"xid" => $g['hash'],
"link" => $g['nick'],
"nick" => substr($g['nick'],0,strpos($g['nick'],'@')),
"self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''),
"self" => (intval($g['abook_self']) ? 'abook-self' : ''),
"taggable" => 'taggable',
"label" => t('network')
);
@ -233,7 +230,7 @@ function acl_init(&$a){
"xid" => $g['hash'],
"link" => $g['nick'],
"nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : t('RSS')),
"self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''),
"self" => (intval($g['abook_self']) ? 'abook-self' : ''),
"taggable" => '',
"label" => '',
);

View File

@ -175,11 +175,10 @@ function channel_content(&$a, $update = 0, $load = false) {
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
WHERE uid = %d $item_normal
AND item_wall = 1 AND item_unseen = 1
AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
AND (abook.blocked = 0 or abook.abook_flags is null)
$sql_extra
ORDER BY created DESC",
intval($a->profile['profile_uid']),
intval(ABOOK_FLAG_BLOCKED)
intval($a->profile['profile_uid'])
);
$_SESSION['loadtime'] = datetime_convert();
}
@ -221,11 +220,10 @@ function channel_content(&$a, $update = 0, $load = false) {
left join abook on item.author_xchan = abook.abook_xchan
WHERE uid = %d $item_normal
AND item_wall = 1 and item_thread_top = 1
AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
AND (abook_blocked = 0 or abook.abook_flags is null)
$sql_extra $sql_extra2
ORDER BY created DESC $pager_sql ",
intval($a->profile['profile_uid']),
intval(ABOOK_FLAG_BLOCKED)
intval($a->profile['profile_uid'])
);
}
}

View File

@ -71,21 +71,18 @@ function connections_post(&$a) {
}
}
$abook_flags = $orig_record[0]['abook_flags'];
$new_friend = false;
if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) {
$abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING );
if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
$new_friend = true;
}
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d
where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
intval($abook_flags),
intval(1 - intval($new_friend)),
intval($contact_id),
intval(local_channel())
);
@ -96,7 +93,7 @@ function connections_post(&$a) {
notice( t('Failed to update connection record.') . EOL);
if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms
&& (! ($a->data['abook']['abook_flags'] & ABOOK_FLAG_SELF))) {
&& (! intval($a->data['abook']['abook_self']))) {
proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
}
@ -182,45 +179,43 @@ function connections_content(&$a) {
if(! $_REQUEST['aj'])
$_SESSION['return_url'] = $a->query_string;
$search_flags = 0;
$search_flags = '';
$head = '';
if(argc() == 2) {
switch(argv(1)) {
case 'blocked':
$search_flags = ABOOK_FLAG_BLOCKED;
$search_flags = " and abook_blocked = 1 ";
$head = t('Blocked');
$blocked = true;
break;
case 'ignored':
$search_flags = ABOOK_FLAG_IGNORED;
$search_flags = " and abook_ignored = 1 ";
$head = t('Ignored');
$ignored = true;
break;
case 'hidden':
$search_flags = ABOOK_FLAG_HIDDEN;
$search_flags = " and abook_hidden = 1 ";
$head = t('Hidden');
$hidden = true;
break;
case 'archived':
$search_flags = ABOOK_FLAG_ARCHIVED;
$search_flags = " and abook_archived = 1 ";
$head = t('Archived');
$archived = true;
break;
case 'pending':
$search_flags = ABOOK_FLAG_PENDING;
$search_flags = " and abook_pending = 1 ";
$head = t('New');
$pending = true;
nav_set_selected('intros');
break;
case 'ifpending':
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or xchan_deleted = 1 or xchan_orphan = 1)",
intval(local_channel()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED)
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0)",
intval(local_channel())
);
if($r && $r[0]['total']) {
$search_flags = ABOOK_FLAG_PENDING;
$search_flags = " and abook_pending = 1 ";
$head = t('New');
$pending = true;
nav_set_selected('intros');
@ -228,7 +223,7 @@ function connections_content(&$a) {
}
else {
$head = t('All');
$search_flags = 0;
$search_flags = '';
$all = true;
$a->argc = 1;
unset($a->argv[1]);
@ -236,7 +231,7 @@ function connections_content(&$a) {
nav_set_selected('intros');
break;
// case 'unconnected':
// $search_flags = ABOOK_FLAG_UNCONNECTED;
// $search_flags = " and abook_unconnected = 1 ";
// $head = t('Unconnected');
// $unconnected = true;
// break;
@ -244,19 +239,19 @@ function connections_content(&$a) {
case 'all':
$head = t('All');
default:
$search_flags = 0;
$search_flags = '';
$all = true;
break;
}
$sql_extra = (($search_flags) ? " and ( abook_flags & " . $search_flags . " )>0 " : "");
$sql_extra = $search_flags;
if(argv(1) === 'pending')
$sql_extra .= " and not ( abook_flags & " . ABOOK_FLAG_IGNORED . " )>0 ";
$sql_extra .= " and abook_ignored = 0 ";
}
else {
$sql_extra = " and not ( abook_flags & " . ABOOK_FLAG_BLOCKED . " )>0 ";
$sql_extra = " and abook_blocked = 0 ";
$unblocked = true;
}
@ -342,9 +337,8 @@ function connections_content(&$a) {
}
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
where abook_channel = %d and not (abook_flags & %d)>0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ",
intval(local_channel()),
intval(ABOOK_FLAG_SELF)
where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ",
intval(local_channel())
);
if($r) {
$a->set_pager_total($r[0]['total']);
@ -352,9 +346,8 @@ function connections_content(&$a) {
}
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
WHERE abook_channel = %d and not (abook_flags & %d)>0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d OFFSET %d ",
WHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ORDER BY xchan_name LIMIT %d OFFSET %d ",
intval(local_channel()),
intval(ABOOK_FLAG_SELF),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
@ -374,7 +367,7 @@ function connections_content(&$a) {
'thumb' => $rr['xchan_photo_m'],
'name' => $rr['xchan_name'],
'username' => $rr['xchan_name'],
'classes' => (($rr['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'archived' : ''),
'classes' => (intval($rr['abook_archived']) ? 'archived' : ''),
'link' => z_root() . '/connedit/' . $rr['abook_id'],
'edit' => t('Edit'),
'url' => chanlink_url($rr['xchan_url']),

View File

@ -79,7 +79,7 @@ function connedit_post(&$a) {
call_hooks('contact_edit_post', $_POST);
if($orig_record[0]['abook_flags'] & ABOOK_FLAG_SELF) {
if(intval($orig_record[0]['abook_self'])) {
$autoperms = intval($_POST['autoperms']);
$is_self = true;
}
@ -174,8 +174,7 @@ function connedit_post(&$a) {
}
}
if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) {
$abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING );
if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
$new_friend = true;
if(! $abook_my_perms) {
@ -190,12 +189,12 @@ function connedit_post(&$a) {
}
}
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d
where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
intval($abook_flags),
intval(1 - intval($new_friend)),
intval($contact_id),
intval(local_channel())
);
@ -216,7 +215,7 @@ function connedit_post(&$a) {
notice( t('Failed to update connection record.') . EOL);
if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms
&& (! ($a->poi['abook_flags'] & ABOOK_FLAG_SELF))) {
&& (! intval($a->poi['abook_self']))) {
proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
}
@ -236,8 +235,7 @@ function connedit_post(&$a) {
$pr = q("select * from profile where uid = %d and is_default = 1 and hide_friends = 0",
intval($channel['channel_id'])
);
if(($pr) && (! ($abook_flags & ABOOK_FLAG_HIDDEN))
&& (intval(get_pconfig($channel['channel_id'],'system','post_newfriend')))) {
if(($pr) && (! intval($orig_record[0]['abook_hidden'])) && (intval(get_pconfig($channel['channel_id'],'system','post_newfriend')))) {
$xarr = array();
$xarr['verb'] = ACTIVITY_FRIEND;
$xarr['item_wall'] = 1;
@ -367,10 +365,9 @@ function connedit_content(&$a) {
$cmd = argv(2);
$orig_record = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_id = %d AND abook_channel = %d AND NOT ( abook_flags & %d )>0 LIMIT 1",
WHERE abook_id = %d AND abook_channel = %d AND abook_self = 0 LIMIT 1",
intval($contact_id),
intval(local_channel()),
intval(ABOOK_FLAG_SELF)
intval(local_channel())
);
if(! count($orig_record)) {
@ -394,7 +391,7 @@ function connedit_content(&$a) {
if($cmd === 'block') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_BLOCKED)) {
info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_BLOCKED)
info((intval($orig_record[0]['abook_blocked'])
? t('Channel has been unblocked')
: t('Channel has been blocked')) . EOL );
connedit_clone($a);
@ -406,7 +403,7 @@ function connedit_content(&$a) {
if($cmd === 'ignore') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) {
info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_IGNORED)
info((intval($orig_record[0]['abook_ignored'])
? t('Channel has been unignored')
: t('Channel has been ignored')) . EOL );
connedit_clone($a);
@ -418,7 +415,7 @@ function connedit_content(&$a) {
if($cmd === 'archive') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) {
info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_ARCHIVED)
info((intval($orig_record[0]['abook_archived'])
? t('Channel has been unarchived')
: t('Channel has been archived')) . EOL );
connedit_clone($a);
@ -430,7 +427,7 @@ function connedit_content(&$a) {
if($cmd === 'hide') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_HIDDEN)) {
info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_HIDDEN)
info((intval($orig_record[0]['abook_hidden'])
? t('Channel has been unhidden')
: t('Channel has been hidden')) . EOL );
connedit_clone($a);
@ -444,9 +441,9 @@ function connedit_content(&$a) {
// Though maybe somebody will want this eventually (??)
if($cmd === 'approve') {
if($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING) {
if(intval($orig_record[0]['abook_pending'])) {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_PENDING)) {
info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING)
info((intval($orig_record[0]['abook_pending'])
? t('Channel has been approved')
: t('Channel has been unapproved')) . EOL );
connedit_clone($a);
@ -516,28 +513,28 @@ function connedit_content(&$a) {
$buttons = array(
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')),
'label' => (intval($contact['abook_blocked']) ? t('Unblock') : t('Block')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/block',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''),
'sel' => (intval($contact['abook_blocked']) ? 'active' : ''),
'title' => t('Block (or Unblock) all communications with this connection'),
),
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')),
'label' => (intval($contact['abook_ignored']) ? t('Unignore') : t('Ignore')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/ignore',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''),
'sel' => (intval($contact['abook_ignored']) ? 'active' : ''),
'title' => t('Ignore (or Unignore) all inbound communications from this connection'),
),
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')),
'label' => (intval($contact['abook_archived']) ? t('Unarchive') : t('Archive')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/archive',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''),
'sel' => (intval($contact['abook_archived']) ? 'active' : ''),
'title' => t('Archive (or Unarchive) this connection - mark channel dead but keep content'),
),
array(
'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')),
'label' => (intval($contact['abook_hidden']) ? t('Unhide') : t('Hide')),
'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/hide',
'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''),
'sel' => (intval($contact['abook_hidden']) ? 'active' : ''),
'title' => t('Hide or Unhide this connection from your other connections'),
),
@ -552,7 +549,7 @@ function connedit_content(&$a) {
$self = false;
if(! ($contact['abook_flags'] & ABOOK_FLAG_SELF)) {
if(! intval($contact['abook_self'])) {
$tab_tpl = get_markup_template('common_tabs.tpl');
$t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
}
@ -671,7 +668,7 @@ function connedit_content(&$a) {
'$tabs' => $t,
'$tab_str' => $tab_str,
'$perms_step1' => t('Default permissions for your channel type have (just) been applied. They have not yet been submitted. Please review the permissions on this page and make any desired changes at this time. This new connection may <em>not</em> be able to communicate with you until you submit this page, which will install and apply the selected permissions.'),
'$is_pending' => (($contact['abook_flags'] & ABOOK_FLAG_PENDING) ? 1 : ''),
'$is_pending' => (intval($contact['abook_pending']) ? 1 : ''),
'$unapproved' => $unapproved,
'$inherited' => t('inherited'),
'$approve' => t('Approve this connection'),

View File

@ -9,10 +9,9 @@ function contactgroup_content(&$a) {
}
if((argc() > 2) && (intval(argv(1))) && (argv(2))) {
$r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and not ( abook_flags & %d )>0 limit 1",
$r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1",
dbesc(base64url_decode(argv(2))),
intval(local_channel()),
intval(ABOOK_FLAG_SELF)
intval(local_channel())
);
if($r)
$change = $r[0]['abook_xchan'];

View File

@ -117,11 +117,9 @@ function group_content(&$a) {
check_form_security_token_ForbiddenOnErr('group_member_change', 't');
$r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and not (abook_flags & %d)>0 and not (abook_flags & %d)>0 limit 1",
$r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and abook_blocked = 0 and abook_pending = 0 limit 1",
dbesc(base64url_decode(argv(2))),
intval(local_channel()),
intval(ABOOK_FLAG_BLOCKED),
intval(ABOOK_FLAG_PENDING)
intval(local_channel())
);
if(count($r))
$change = base64url_decode(argv(2));
@ -202,7 +200,7 @@ function group_content(&$a) {
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
foreach($members as $member) {
if($member['xchan_url']) {
$member['archived'] = (($member['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false);
$member['archived'] = (intval($member['abook_archived']) ? true : false);
$member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
$groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
}
@ -210,17 +208,15 @@ function group_content(&$a) {
group_rmv_member(local_channel(),$group['name'],$member['xchan_hash']);
}
$r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND not (abook_flags & %d)>0 and xchan_deleted = 0 and not (abook_flags & %d)>0 order by xchan_name asc",
intval(local_channel()),
intval(ABOOK_FLAG_BLOCKED),
intval(ABOOK_FLAG_PENDING)
$r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc",
intval(local_channel())
);
if(count($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
foreach($r as $member) {
if(! in_array($member['xchan_hash'],$preselected)) {
$member['archived'] = (($member['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false);
$member['archived'] = (intval($member['abook_archived']) ? true : false);
$member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
$groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode);
}

View File

@ -324,7 +324,7 @@ function import_post(&$a) {
foreach($abooks as $abook) {
if($max_friends !== false && $friends > $max_friends)
continue;
if($max_feeds !== false && ($abook['abook_flags'] & ABOOK_FLAG_FEED) && $feeds > $max_feeds)
if($max_feeds !== false && intval($abook['abook_feed']) && ($feeds > $max_feeds))
continue;
unset($abook['abook_id']);
@ -338,7 +338,7 @@ function import_post(&$a) {
. "')" );
$friends ++;
if($abook['abook_flags'] & ABOOK_FLAG_FEED)
if(intval($abook['abook_feed']))
$feeds ++;
}
}

View File

@ -197,7 +197,7 @@ function item_post(&$a) {
if($parent) {
logger('mod_item: item_post parent=' . $parent);
$can_comment = false;
if((array_key_exists('owner',$parent_item)) && ($parent_item['owner']['abook_flags'] & ABOOK_FLAG_SELF))
if((array_key_exists('owner',$parent_item)) && intval($parent_item['owner']['abook_self']))
$can_comment = perm_is_allowed($profile_uid,$observer['xchan_hash'],'post_comments');
else
$can_comment = can_comment_on_post($observer['xchan_hash'],$parent_item);
@ -367,7 +367,7 @@ function item_post(&$a) {
$item_hidden = $orig_post['item_hidden'];
$item_unpublished = $orig_post['item_unpublished'];
$item_delayed = $orig_post['item_delayed'];
$item_pending_remove = $orig_post['item_pedning_remove'];
$item_pending_remove = $orig_post['item_pending_remove'];
$item_blocked = $orig_post['item_blocked'];

View File

@ -71,10 +71,8 @@ function manage_content(&$a) {
}
$intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or xchan_deleted = 1 or xchan_orphan = 1)",
intval($channels[$x]['channel_id']),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED)
$intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 0 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ",
intval($channels[$x]['channel_id'])
);
if($intr)

View File

@ -216,7 +216,7 @@ function network_content(&$a, $update = 0, $load = false) {
elseif($cid) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ") > 0 limit 1",
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1",
intval($cid),
intval(local_channel())
);
@ -405,11 +405,10 @@ function network_content(&$a, $update = 0, $load = false) {
$items = q("SELECT item.*, item.id AS item_id, received FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
WHERE true $uids $item_normal
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
and (abook.abook_blocked = 0 or abook.abook_flags is null)
$simple_update
$sql_extra $sql_nets
ORDER BY item.received DESC $pager_sql ",
intval(ABOOK_FLAG_BLOCKED)
ORDER BY item.received DESC $pager_sql "
);
require_once('include/items.php');
@ -435,10 +434,9 @@ function network_content(&$a, $update = 0, $load = false) {
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
WHERE true $uids $item_normal
AND item.parent = item.id
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets
ORDER BY $ordering DESC $pager_sql ",
intval(ABOOK_FLAG_BLOCKED)
ORDER BY $ordering DESC $pager_sql "
);
}
@ -447,9 +445,8 @@ function network_content(&$a, $update = 0, $load = false) {
$r = q("SELECT item.parent AS item_id FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
WHERE true $uids $item_normal $simple_update
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets ",
intval(ABOOK_FLAG_BLOCKED)
and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets "
);
$_SESSION['loadtime'] = datetime_convert();
}

View File

@ -390,8 +390,9 @@ function photos_post(&$a) {
*/
$_REQUEST['source'] = 'photos';
require_once('include/attach.php');
$r = photo_upload($a->channel,$a->get_observer(), $_REQUEST);
$r = attach_store($a->channel,get_observer_hash(), $_REQUEST);
if(! $r['success']) {
notice($r['message'] . EOL);
}

View File

@ -296,10 +296,8 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'intros')) {
$result = array();
$r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or xchan_deleted = 1 or xchan_orphan = 1) ORDER BY abook_created DESC LIMIT 50",
intval(local_channel()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED)
$r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ORDER BY abook_created DESC LIMIT 50",
intval(local_channel())
);
if($r) {
@ -407,10 +405,8 @@ function ping_init(&$a) {
$t2 = dba_timer();
if($vnotify & VNOTIFY_INTRO) {
$intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or xchan_deleted = 1 or xchan_orphan = 1)",
intval(local_channel()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED)
$intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0)",
intval(local_channel())
);
$t3 = dba_timer();

View File

@ -105,10 +105,9 @@ function public_content(&$a, $update = 0, $load = false) {
left join abook on item.author_xchan = abook.abook_xchan
WHERE true $uids $item_normal
AND item.parent = item.id
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets
ORDER BY $ordering DESC $pager_sql ",
intval(ABOOK_FLAG_BLOCKED)
ORDER BY $ordering DESC $pager_sql "
);
@ -119,9 +118,8 @@ function public_content(&$a, $update = 0, $load = false) {
left join abook on item.author_xchan = abook.abook_xchan
WHERE true $uids $item_normal
AND item.parent = item.id $simple_update
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets",
intval(ABOOK_FLAG_BLOCKED)
and (abook.abook_blocked = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets"
);
$_SESSION['loadtime'] = datetime_convert();
}

View File

@ -373,10 +373,9 @@ function settings_post(&$a) {
);
}
$r = q("update abook set abook_my_perms = %d where abook_channel = %d and (abook_flags & %d)>0",
$r = q("update abook set abook_my_perms = %d where abook_channel = %d and abook_self = 1",
intval(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0),
intval(local_channel()),
intval(ABOOK_FLAG_SELF)
intval(local_channel())
);
set_pconfig(local_channel(),'system','autoperms',(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0));

View File

@ -34,25 +34,23 @@ function viewconnections_content(&$a) {
$is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false);
$abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF;
$abook_flags = " and abook_pending = 0 and abook_self = 0 ";
$sql_extra = '';
if(! $is_owner) {
$abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
$abook_flags = " and abook_hidden = 0 ";
$sql_extra = " and xchan_hidden = 0 ";
}
$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d )>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ",
intval($a->profile['uid']),
intval($abook_flags)
$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ",
intval($a->profile['uid'])
);
if($r) {
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d )>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra order by xchan_name LIMIT %d OFFSET %d ",
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra order by xchan_name LIMIT %d OFFSET %d ",
intval($a->profile['uid']),
intval($abook_flags),
intval($a->pager['itemspage']),
intval($a->pager['start'])
);
@ -70,7 +68,7 @@ function viewconnections_content(&$a) {
if($url) {
$contacts[] = array(
'id' => $rr['abook_id'],
'archived' => (($rr['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false),
'archived' => (intval($rr['abook_archived']) ? true : false),
'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']),
'thumb' => $rr['xchan_photo_m'],
'name' => substr($rr['xchan_name'],0,20),

View File

@ -117,9 +117,8 @@ function zfinger_init(&$a) {
}
else {
// check if it has characteristics of a public forum based on custom permissions.
$t = q("select abook_my_perms from abook where abook_channel = %d and (abook_flags & %d)>0 limit 1",
intval($e['channel_id']),
intval(ABOOK_FLAG_SELF)
$t = q("select abook_my_perms from abook where abook_channel = %d and abook_self = 1 limit 1",
intval($e['channel_id'])
);
if($t && ($t[0]['abook_my_perms'] & PERMS_W_TAGWALL))
$public_forum = true;