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 --- 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 ++--- 16 files changed, 98 insertions(+), 132 deletions(-) (limited to 'mod') 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 not 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; -- cgit v1.2.3