diff options
author | friendica <info@friendica.com> | 2015-01-22 17:41:16 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-01-22 17:41:16 -0800 |
commit | e46eba125888704b4381aa8418495e91eeb565c8 (patch) | |
tree | d91e1e52560ea27be806f416485d32b831d03ebc /mod | |
parent | 29436081a86650e7905a79eba4fdf7dc12f1c7c9 (diff) | |
download | volse-hubzilla-e46eba125888704b4381aa8418495e91eeb565c8.tar.gz volse-hubzilla-e46eba125888704b4381aa8418495e91eeb565c8.tar.bz2 volse-hubzilla-e46eba125888704b4381aa8418495e91eeb565c8.zip |
heavy lifting converting item flag bits
Diffstat (limited to 'mod')
-rw-r--r-- | mod/channel.php | 25 | ||||
-rw-r--r-- | mod/display.php | 5 | ||||
-rwxr-xr-x | mod/events.php | 2 | ||||
-rw-r--r-- | mod/home.php | 2 | ||||
-rw-r--r-- | mod/item.php | 2 | ||||
-rwxr-xr-x | mod/like.php | 6 | ||||
-rw-r--r-- | mod/manage.php | 7 | ||||
-rw-r--r-- | mod/network.php | 16 | ||||
-rw-r--r-- | mod/p.php | 5 | ||||
-rw-r--r-- | mod/photos.php | 6 | ||||
-rw-r--r-- | mod/ping.php | 22 | ||||
-rw-r--r-- | mod/starred.php | 8 | ||||
-rwxr-xr-x | mod/subthread.php | 3 |
13 files changed, 39 insertions, 70 deletions
diff --git a/mod/channel.php b/mod/channel.php index c8ac83baf..84b302cce 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -147,23 +147,19 @@ function channel_content(&$a, $update = 0, $load = false) { if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND (item_flags & %d) > 0 $sql_extra limit 1", + AND item_wall = 1 AND item_unseen = 1 $sql_extra limit 1", dbesc($mid), - intval($a->profile['profile_uid']), - intval(ITEM_WALL), - intval(ITEM_UNSEEN) + intval($a->profile['profile_uid']) ); } else { $r = q("SELECT distinct parent AS `item_id`, created from item left join abook on item.author_xchan = abook.abook_xchan WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND ( item_flags & %d ) > 0 + AND item_wall = 1 AND item_unseen = 1 AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", intval($a->profile['profile_uid']), - intval(ITEM_WALL), - intval(ITEM_UNSEEN), intval(ABOOK_FLAG_BLOCKED) ); } @@ -192,10 +188,9 @@ function channel_content(&$a, $update = 0, $load = false) { if($load || ($_COOKIE['jsAvailable'] != 1)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 - AND (item_flags & %d)>0 $sql_extra limit 1", + AND item_wall = 1 $sql_extra limit 1", dbesc($mid), - intval($a->profile['profile_uid']), - intval(ITEM_WALL) + intval($a->profile['profile_uid']) ); if (! $r) { notice( t('Permission denied.') . EOL); @@ -205,13 +200,11 @@ function channel_content(&$a, $update = 0, $load = false) { $r = q("SELECT distinct id AS item_id, created FROM item left join abook on item.author_xchan = abook.abook_xchan WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d)>0 and (item_flags & %d)>0 + AND item_wall = 1 and item_thread_top = 1 AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra $sql_extra2 ORDER BY created DESC $pager_sql ", intval($a->profile['profile_uid']), - intval(ITEM_WALL), - intval(ITEM_THREAD_TOP), intval(ABOOK_FLAG_BLOCKED) ); } @@ -317,11 +310,7 @@ function channel_content(&$a, $update = 0, $load = false) { } if($is_owner && $update_unseen) { - $r = q("UPDATE item SET item_flags = (item_flags & ~%d) - WHERE (item_flags & %d) > 0 AND (item_flags & %d) > 0 AND uid = %d $update_unseen", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), - intval(ITEM_WALL), + $r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 and item_wall = 1 AND uid = %d $update_unseen", intval(local_user()) ); } diff --git a/mod/display.php b/mod/display.php index f14aca6da..b9b660fdd 100644 --- a/mod/display.php +++ b/mod/display.php @@ -231,10 +231,7 @@ function display_content(&$a, $update = 0, $load = false) { } if($updateable) { - $x = q("UPDATE item SET item_flags = ( item_flags & ~%d ) - WHERE (item_flags & %d)>0 AND uid = %d and parent = %d ", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ", intval(local_user()), intval($r[0]['parent']) ); diff --git a/mod/events.php b/mod/events.php index 28a816ea4..14ff03468 100755 --- a/mod/events.php +++ b/mod/events.php @@ -392,7 +392,7 @@ function events_content(&$a) { $last_date = $d; // FIXME - $edit = (($rr['item_flags'] & ITEM_WALL) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null); + $edit = (intval($rr['item_wall']) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null); $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); if(! $title) { list($title, $_trash) = explode("<br",bbcode($rr['desc']),2); diff --git a/mod/home.php b/mod/home.php index 2e57a2ab9..648a8ff4f 100644 --- a/mod/home.php +++ b/mod/home.php @@ -170,7 +170,7 @@ function home_content(&$a, $update = 0, $load = false) { $page_mode = 'list'; - $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : ''); + $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; diff --git a/mod/item.php b/mod/item.php index 152c10b13..a6ab99ef5 100644 --- a/mod/item.php +++ b/mod/item.php @@ -809,7 +809,7 @@ function item_post(&$a) { // only send comment notification if this is a wall-to-wall comment, // otherwise it will happen during delivery - if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($parent_item['item_flags'] & ITEM_WALL)) { + if(($datarray['owner_xchan'] != $datarray['author_xchan']) && (intval($parent_item['item_wall']))) { notification(array( 'type' => NOTIFY_COMMENT, 'from_xchan' => $datarray['author_xchan'], diff --git a/mod/like.php b/mod/like.php index 4d4d4249e..968f9c81e 100755 --- a/mod/like.php +++ b/mod/like.php @@ -328,14 +328,14 @@ function like_content(&$a) { ), )); - if(! ($item['item_flags'] & ITEM_THREAD_TOP)) + if(! intval($item['item_thread_top'])) $post_type = 'comment'; $arr['item_origin'] = 1; $arr['item_notshown'] = 1; - if($item['item_flags'] & ITEM_WALL) - $item_flags |= ITEM_WALL; + if(intval($item['item_wall'])) + $arr['item_wall'] = 1; // if this was a linked photo and was hidden, unhide it. diff --git a/mod/manage.php b/mod/manage.php index 6797b4892..4297e8f08 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -56,16 +56,15 @@ function manage_content(&$a) { $channels[$x]['default_links'] = '1'; - $c = q("SELECT id, item_restrict, item_flags FROM item - WHERE (item_restrict = %d) and ( item_flags & %d )>0 and uid = %d", + $c = q("SELECT id, item_restrict, item_wall FROM item + WHERE (item_restrict = %d) and item_unseen = 1 and uid = %d", intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), intval($channels[$x]['channel_id']) ); if($c) { foreach ($c as $it) { - if($it['item_flags'] & ITEM_WALL) + if(intval($it['item_wall'])) $channels[$x]['home'] ++; else $channels[$x]['network'] ++; diff --git a/mod/network.php b/mod/network.php index 65332e3f6..5e583f657 100644 --- a/mod/network.php +++ b/mod/network.php @@ -154,12 +154,12 @@ function network_content(&$a, $update = 0, $load = false) { $sql_options = (($star) - ? " and (item_flags & " . intval(ITEM_STARRED) . ") > 0" + ? " and item_starred = 1 " : ''); $sql_nets = ''; - $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ")>0 $sql_options ) "; + $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE item_thread_top = 1 $sql_options ) "; if($group) { $contact_str = ''; @@ -291,9 +291,8 @@ function network_content(&$a, $update = 0, $load = false) { } if($conv) { - $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or ( item_flags & %d ) > 0)) ", - dbesc(protect_sprintf($channel['channel_hash'])), - intval(ITEM_MENTIONSME) + $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", + dbesc(protect_sprintf($channel['channel_hash'])) ); } @@ -346,7 +345,7 @@ function network_content(&$a, $update = 0, $load = false) { else $page_mode = 'client'; - $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : ''); + $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); // This fixes a very subtle bug so I'd better explain it. You wake up in the morning or return after a day // or three and look at your matrix page - after opening up your browser. The first page loads just as it @@ -465,10 +464,7 @@ function network_content(&$a, $update = 0, $load = false) { } if(($update_unseen) && (! $firehose)) - $r = q("UPDATE item SET item_flags = ( item_flags & ~%d) - WHERE (item_flags & %d) > 0 AND uid = %d $update_unseen ", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d $update_unseen ", intval(local_user()) ); @@ -11,9 +11,8 @@ function p_init(&$a) { $mid = str_replace('.xml','',argv(1)); - $r = q("select * from item where mid = '%s' and (item_flags & %d)>0 and item_private = 0 limit 1", - dbesc($mid), - intval(ITEM_WALL) + $r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1", + dbesc($mid) ); diff --git a/mod/photos.php b/mod/photos.php index b2eb2847f..216a562c7 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -877,11 +877,9 @@ function photos_content(&$a) { } if((local_user()) && (local_user() == $link_item['uid'])) { - q("UPDATE `item` SET item_flags = (item_flags & ~%d) WHERE parent = %d and uid = %d and (item_flags & %d)>0", - intval(ITEM_UNSEEN), + q("UPDATE `item` SET item_unseen = 0 WHERE parent = %d and uid = %d and item_unseen = 1", intval($link_item['parent']), - intval(local_user()), - intval(ITEM_UNSEEN) + intval(local_user()) ); } } diff --git a/mod/ping.php b/mod/ping.php index e5fc4d930..62e8197df 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -151,17 +151,12 @@ function ping_init(&$a) { if(x($_REQUEST, 'markRead') && local_user()) { switch($_REQUEST['markRead']) { case 'network': - $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and uid = %d", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where item_unseen = 1 and uid = %d", intval(local_user()) ); break; case 'home': - $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and (item_flags & %d) > 0 and uid = %d", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), - intval(ITEM_WALL), + $r = q("update item set item_unseen = 0 where item_unseen = 1 and item_wall = 1 and uid = %d", intval(local_user()) ); break; @@ -188,8 +183,7 @@ function ping_init(&$a) { } if(x($_REQUEST, 'markItemRead') && local_user()) { - $r = q("update item set item_flags = ( item_flags & ~%d ) where parent = %d and uid = %d", - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where parent = %d and uid = %d", intval($_REQUEST['markItemRead']), intval(local_user()) ); @@ -276,10 +270,9 @@ function ping_init(&$a) { $result = array(); $r = q("SELECT * FROM item - WHERE item_restrict = %d and ( item_flags & %d ) > 0 and uid = %d + WHERE item_restrict = %d and item_unseen = 1 and uid = %d and author_xchan != '%s' ORDER BY created DESC", intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), intval(local_user()), dbesc($ob_hash) ); @@ -287,7 +280,7 @@ function ping_init(&$a) { if($r) { xchan_query($r); foreach($r as $item) { - if((argv(1) === 'home') && (! ($item['item_flags'] & ITEM_WALL))) + if((argv(1) === 'home') && (! intval($item['item_wall']))) continue; $result[] = format_notification($item); } @@ -383,10 +376,9 @@ function ping_init(&$a) { if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { $r = q("SELECT id, item_restrict, item_flags FROM item - WHERE (item_restrict = %d) and ( item_flags & %d ) > 0 and uid = %d + WHERE (item_restrict = %d) and item_unseen = 1 and uid = %d and author_xchan != '%s'", intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), intval(local_user()), dbesc($ob_hash) ); @@ -396,7 +388,7 @@ function ping_init(&$a) { call_hooks('network_ping', $arr); foreach ($r as $it) { - if($it['item_flags'] & ITEM_WALL) + if(intval($it['item_wall'])) $result['home'] ++; else $result['network'] ++; diff --git a/mod/starred.php b/mod/starred.php index 05b45bea3..931b24a71 100644 --- a/mod/starred.php +++ b/mod/starred.php @@ -19,15 +19,15 @@ function starred_init(&$a) { if(! count($r)) killme(); - $item_flags = ( $r[0]['item_flags'] ^ ITEM_STARRED ); + $item_starred = (intval($r[0]['item_starred']) ? 0 : 1); - $r = q("UPDATE item SET item_flags = %d WHERE uid = %d and id = %d", - intval($item_flags), + $r = q("UPDATE item SET item_starred = %d WHERE uid = %d and id = %d", + intval($item_starred), intval(local_user()), intval($message_id) ); header('Content-type: application/json'); - echo json_encode(array('result' => (($item_flags & ITEM_STARRED) ? 1 : 0))); + echo json_encode(array('result' => $item_starred)); killme(); } diff --git a/mod/subthread.php b/mod/subthread.php index 92ada64ad..f4472cf05 100755 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -96,10 +96,9 @@ function subthread_content(&$a) { ), )); - if(! ($item['item_flags'] & ITEM_THREAD_TOP)) + if(! intval($item['item_thread_top'])) $post_type = 'comment'; - $bodyverb = t('%1$s is following %2$s\'s %3$s'); $arr = array(); |