From be0459a98b9c047e4cf89b835fd35a32da51ca31 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 14 Jun 2015 21:08:00 -0700 Subject: convert the abook fields --- include/Contact.php | 59 ++++++++++++++++++++++++++++++------------ include/ConversationObject.php | 2 +- include/acl_selectors.php | 3 +-- include/api.php | 14 +++++----- include/conversation.php | 2 +- include/diaspora.php | 4 +-- include/follow.php | 14 +++++----- include/group.php | 6 ++--- include/identity.php | 9 +++---- include/items.php | 28 +++++++++----------- include/notifier.php | 3 +-- include/onepoll.php | 6 +---- include/permissions.php | 26 +++++++++---------- include/poller.php | 20 +++++--------- include/socgraph.php | 19 +++++++------- include/text.php | 15 +++++------ include/widgets.php | 10 +++---- include/zot.php | 50 ++++++++++++++++------------------- mod/acl.php | 15 +++++------ mod/channel.php | 10 +++---- mod/connections.php | 53 ++++++++++++++++--------------------- mod/connedit.php | 51 +++++++++++++++++------------------- mod/contactgroup.php | 5 ++-- mod/group.php | 16 +++++------- mod/import.php | 4 +-- mod/item.php | 4 +-- mod/manage.php | 6 ++--- mod/network.php | 17 +++++------- mod/photos.php | 3 ++- mod/ping.php | 12 +++------ mod/public.php | 10 +++---- mod/settings.php | 5 ++-- mod/viewconnections.php | 14 +++++----- mod/zfinger.php | 5 ++-- 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 .= "