aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--mod/acl.php15
-rw-r--r--mod/channel.php10
-rw-r--r--mod/connections.php53
-rw-r--r--mod/connedit.php51
-rw-r--r--mod/contactgroup.php5
-rw-r--r--mod/group.php16
-rw-r--r--mod/import.php4
-rw-r--r--mod/item.php4
-rw-r--r--mod/manage.php6
-rw-r--r--mod/network.php17
-rw-r--r--mod/photos.php3
-rw-r--r--mod/ping.php12
-rw-r--r--mod/public.php10
-rw-r--r--mod/settings.php5
-rw-r--r--mod/viewconnections.php14
-rw-r--r--mod/zfinger.php5
34 files changed, 241 insertions, 279 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 ++;
}
diff --git a/mod/acl.php b/mod/acl.php
index ba2159dbc..6383d774c 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -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" => '',
);
diff --git a/mod/channel.php b/mod/channel.php
index c0f1f419f..9a98ade60 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -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'])
);
}
}
diff --git a/mod/connections.php b/mod/connections.php
index c732cf272..481ccfb99 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -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']),
diff --git a/mod/connedit.php b/mod/connedit.php
index 91fa2f324..88304d2ed 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -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'),
diff --git a/mod/contactgroup.php b/mod/contactgroup.php
index 6138f9e19..61ca37054 100644
--- a/mod/contactgroup.php
+++ b/mod/contactgroup.php
@@ -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'];
diff --git a/mod/group.php b/mod/group.php
index f3984f9c8..ce9633669 100644
--- a/mod/group.php
+++ b/mod/group.php
@@ -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);
}
diff --git a/mod/import.php b/mod/import.php
index 030b714bc..d3864c077 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -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 ++;
}
}
diff --git a/mod/item.php b/mod/item.php
index 888d1643b..db0218136 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -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'];
diff --git a/mod/manage.php b/mod/manage.php
index bc538e564..c6b653ab6 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -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)
diff --git a/mod/network.php b/mod/network.php
index f4c8390dc..d5e305687 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -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();
}
diff --git a/mod/photos.php b/mod/photos.php
index 1a4a50c05..1fbee70e8 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -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);
}
diff --git a/mod/ping.php b/mod/ping.php
index f2ec93f32..9af234514 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -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();
diff --git a/mod/public.php b/mod/public.php
index 6a4e6a334..fe3f3aa21 100644
--- a/mod/public.php
+++ b/mod/public.php
@@ -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();
}
diff --git a/mod/settings.php b/mod/settings.php
index 5bae3778a..9284033e6 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -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));
diff --git a/mod/viewconnections.php b/mod/viewconnections.php
index c1da07292..d9a9aecc1 100644
--- a/mod/viewconnections.php
+++ b/mod/viewconnections.php
@@ -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),
diff --git a/mod/zfinger.php b/mod/zfinger.php
index 37243922c..39c9ae9aa 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -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;