aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php59
-rw-r--r--include/ConversationObject.php2
-rw-r--r--include/acl_selectors.php3
-rw-r--r--include/api.php14
-rw-r--r--include/conversation.php2
-rwxr-xr-xinclude/diaspora.php4
-rw-r--r--include/follow.php14
-rw-r--r--include/group.php6
-rw-r--r--include/identity.php9
-rwxr-xr-xinclude/items.php28
-rw-r--r--include/notifier.php3
-rw-r--r--include/onepoll.php6
-rw-r--r--include/permissions.php26
-rw-r--r--include/poller.php20
-rw-r--r--include/socgraph.php19
-rw-r--r--include/text.php15
-rw-r--r--include/widgets.php10
-rw-r--r--include/zot.php50
18 files changed, 143 insertions, 147 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 7e7649b94..7f02f04e4 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -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;
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index 9598bf543..7e0d67c10 100644
--- a/include/ConversationObject.php
+++ b/include/ConversationObject.php
@@ -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));
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index ae740b281..cb2266473 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -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())
);
diff --git a/include/api.php b/include/api.php
index a75aa2c32..effaa4484 100644
--- a/include/api.php
+++ b/include/api.php
@@ -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())
);
diff --git a/include/conversation.php b/include/conversation.php
index fe48ed2f5..332f9487c 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -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'];
diff --git a/include/diaspora.php b/include/diaspora.php
index 71425a6f8..fc3c6c2ce 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -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)
);
diff --git a/include/follow.php b/include/follow.php
index 4710f728c..9430feac6 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -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()),
diff --git a/include/group.php b/include/group.php
index a5e25fb76..81e9b98f2 100644
--- a/include/group.php
+++ b/include/group.php
@@ -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;
diff --git a/include/identity.php b/include/identity.php
index 8081755b1..0555cf21d 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -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'];
diff --git a/include/items.php b/include/items.php
index 23561ef46..ca7ceae42 100755
--- a/include/items.php
+++ b/include/items.php
@@ -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 "
);
}
diff --git a/include/notifier.php b/include/notifier.php
index ffdd80403..7dcf1b5a2 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -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)
);
diff --git a/include/onepoll.php b/include/onepoll.php
index 66b000934..fedeb1e95 100644
--- a/include/onepoll.php
+++ b/include/onepoll.php
@@ -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)
);
diff --git a/include/permissions.php b/include/permissions.php
index f63c6da18..59c6694d6 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -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;
}
diff --git a/include/poller.php b/include/poller.php
index 09c642f6a..f44298a9f 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -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))
diff --git a/include/socgraph.php b/include/socgraph.php
index 45ab9a366..e44a8ea9a 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -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)
);
diff --git a/include/text.php b/include/text.php
index e1923aed6..90ad57f62 100644
--- a/include/text.php
+++ b/include/text.php
@@ -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');
}
}
diff --git a/include/widgets.php b/include/widgets.php
index 86f65cdee..2b5a2076f 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -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'];
diff --git a/include/zot.php b/include/zot.php
index 5f93ba75b..afa60c92c 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -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 ++;
}