aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php1
-rw-r--r--include/api.php39
-rw-r--r--include/expire.php5
-rwxr-xr-xinclude/items.php46
-rw-r--r--include/poller.php6
-rw-r--r--install/schema_mysql.sql8
-rw-r--r--mod/bookmarks.php6
-rw-r--r--mod/channel.php12
-rw-r--r--mod/display.php11
-rw-r--r--mod/item.php8
-rwxr-xr-xmod/like.php4
-rw-r--r--mod/manage.php4
-rw-r--r--mod/network.php14
-rw-r--r--mod/photos.php5
-rw-r--r--mod/ping.php9
-rw-r--r--mod/public.php8
-rw-r--r--mod/search.php12
-rw-r--r--mod/viewsrc.php3
-rw-r--r--mod/webpages.php4
19 files changed, 123 insertions, 82 deletions
diff --git a/boot.php b/boot.php
index 863ad5520..a42c82609 100755
--- a/boot.php
+++ b/boot.php
@@ -539,6 +539,7 @@ define ( 'ITEM_TYPE_POST', 0 );
define ( 'ITEM_TYPE_BLOCK', 1 );
define ( 'ITEM_TYPE_PDL', 2 );
define ( 'ITEM_TYPE_WEBPAGE', 3 );
+define ( 'ITEM_TYPE_BUG', 4 );
define ( 'DBTYPE_MYSQL', 0 );
define ( 'DBTYPE_POSTGRES', 1 );
diff --git a/include/api.php b/include/api.php
index e4c4b5240..a75aa2c32 100644
--- a/include/api.php
+++ b/include/api.php
@@ -344,10 +344,12 @@ require_once('include/items.php');
intval(api_user())
);
+ $item_normal = item_normal();
+
// count public wall messages
$r = q("SELECT COUNT(`id`) as `count` FROM `item`
WHERE `uid` = %d
- AND item_wall = 1 and item_restrict = 0
+ AND item_wall = 1 $item_normal
AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
intval($usr[0]['channel_id'])
);
@@ -373,7 +375,7 @@ require_once('include/items.php');
$countfollowers = $r[0]['count'];
}
- $r = q("SELECT count(`id`) as `count` FROM item where item_starred = 1 and uid = %d and item_restrict = 0",
+ $r = q("SELECT count(`id`) as `count` FROM item where item_starred = 1 and uid = %d " . item_normal(),
intval($uinfo[0]['channel_id'])
);
$starred = $r[0]['count'];
@@ -856,8 +858,10 @@ require_once('include/items.php');
function api_get_status($xchan_hash) {
require_once('include/security.php');
+ $item_normal = item_normal();
+
$lastwall = q("SELECT * from item where
- item_private = 0 and item_restrict = 0
+ item_private = 0 $item_normal
and author_xchan = '%s'
and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = ''
and verb = '%s'
@@ -919,9 +923,10 @@ require_once('include/items.php');
// get last public message
require_once('include/security.php');
+ $item_normal = item_normal();
$lastwall = q("SELECT * from item where
- item_private = 0 and item_restrict = 0
+ item_private = 0 $item_normal
and author_xchan = '%s'
and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = ''
and verb = '%s'
@@ -992,9 +997,10 @@ require_once('include/items.php');
$user_info = api_get_user($a);
require_once('include/security.php');
+ $item_normal = item_normal();
$lastwall = q("SELECT * from item where 1
- and item_private != 0 and item_restrict = 0
+ and item_private != 0 $item_normal
and author_xchan = '%s'
and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = ''
and verb = '%s'
@@ -1095,7 +1101,9 @@ require_once('include/items.php');
$sql_extra .= " and item_private = 0 ";
}
- $r = q("SELECT * from item WHERE uid = %d and item_restrict = 0
+ $item_normal = item_normal();
+
+ $r = q("SELECT * from item WHERE uid = %d $item_normal
$sql_extra
AND id > %d
ORDER BY received DESC LIMIT %d ,%d ",
@@ -1161,11 +1169,12 @@ require_once('include/items.php');
if ($max_id > 0)
$sql_extra = 'AND `item`.`id` <= '.intval($max_id);
require_once('include/security.php');
+ $item_normal = item_normal();
- $r = q("select * from item where item_restrict = 0
- and allow_cid = '' and allow_gid = ''
+ $r = q("select * from item where allow_cid = '' and allow_gid = ''
and deny_cid = '' and deny_gid = ''
and item_private = 0
+ $item_normal
and uid = " . $sys['channel_id'] . "
$sql_extra
AND id > %d group by mid
@@ -1221,7 +1230,8 @@ require_once('include/items.php');
else
$sql_extra .= " AND `item`.`id` = %d";
- $r = q("select * from item where item_restrict = 0 $sql_extra",
+ $item_normal = item_normal();
+ $r = q("select * from item where true $item_normal $sql_extra",
intval($id)
);
xchan_query($r,true);
@@ -1261,7 +1271,9 @@ require_once('include/items.php');
$observer = get_app()->get_observer();
- $r = q("SELECT * from item where item_restrict = 0 and id = %d limit 1",
+ $item_normal = item_normal();
+
+ $r = q("SELECT * from item where and id = %d $item_normal limit 1",
intval($id)
);
@@ -1624,12 +1636,13 @@ require_once('include/items.php');
$sql_extra .= " and item_private = 0 ";
}
- $r = q("SELECT * from item WHERE uid = %d and item_restrict = 0
- and ( item_flags & %d ) > 0 $sql_extra
+ $item_normal = item_normal();
+
+ $r = q("SELECT * from item WHERE uid = %d $item_normal
+ and item_starred = 1 $sql_extra
AND id > %d
ORDER BY received DESC LIMIT %d ,%d ",
intval($user_info['uid']),
- intval(ITEM_STARRED),
intval($since_id),
intval($start),
intval($count)
diff --git a/include/expire.php b/include/expire.php
index 8ba9f746b..1af13163d 100644
--- a/include/expire.php
+++ b/include/expire.php
@@ -12,7 +12,7 @@ function expire_run($argv, $argc){
// perform final cleanup on previously delete items
- $r = q("select id from item where item_deleted = 1 and not (item_restrict & %d)>0 and changed < %s - INTERVAL %s",
+ $r = q("select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s",
intval(ITEM_PENDING_REMOVE),
db_utcnow(), db_quoteinterval('10 DAY')
);
@@ -25,8 +25,7 @@ function expire_run($argv, $argc){
// physically remove anything that has been deleted for more than two months
/** @FIXME - this is a wretchedly inefficient query */
- $r = q("delete from item where ( item_restrict & %d ) > 0 and changed < %s - INTERVAL %s",
- intval(ITEM_PENDING_REMOVE),
+ $r = q("delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('36 DAY')
);
diff --git a/include/items.php b/include/items.php
index 2b00b52f8..c7dbbbda8 100755
--- a/include/items.php
+++ b/include/items.php
@@ -192,6 +192,13 @@ function comments_are_now_closed($item) {
return false;
}
+function item_normal() {
+ return " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0
+ and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
+ and item.item_blocked = 0 ";
+}
+
+
/**
* @brief
@@ -1396,7 +1403,7 @@ function encode_item_flags($item) {
$ret[] = 'nsfw';
if(intval($item['item_consensus']))
$ret[] = 'consensus';
- if($item['item_private'])
+ if(intval($item['item_private']))
$ret[] = 'private';
return $ret;
@@ -2117,7 +2124,7 @@ function item_store($arr, $allow_exec = false) {
$d1 = new DateTime('now +10 minutes', new DateTimeZone('UTC'));
$d2 = new DateTime($arr['created'] . '+00:00');
if($d2 > $d1)
- $arr['item_restrict'] = $arr['item_restrict'] | ITEM_DELAYED_PUBLISH;
+ $arr['item_delayed'] = 1;
$arr['llink'] = z_root() . '/display/' . $arr['mid'];
@@ -2334,10 +2341,9 @@ function item_store($arr, $allow_exec = false) {
// update the commented timestamp on the parent
- $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and not ( item_restrict & %d )>0 ",
+ $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and item_delayed = 0 ",
dbesc($arr['parent_mid']),
- intval($arr['uid']),
- intval(ITEM_DELAYED_PUBLISH)
+ intval($arr['uid'])
);
q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d",
@@ -2352,7 +2358,7 @@ function item_store($arr, $allow_exec = false) {
// so that we have an item in the DB that's marked deleted and won't store a fresh post
// that isn't aware that we were already told to delete it.
- if(! ($arr['item_restrict'] & ITEM_DELETED)) {
+ if(! intval($arr['item_deleted'])) {
send_status_notifications($current_post,$arr);
tag_deliver($arr['uid'],$current_post);
}
@@ -2766,7 +2772,7 @@ function tag_deliver($uid, $item_id) {
if($obj['id'] !== $u[0]['channel_hash'])
$poke_notify = false;
}
- if($item['item_restrict'] & ITEM_DELETED)
+ if(intval($item['item_deleted']))
$poke_notify = false;
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
@@ -3913,13 +3919,15 @@ function item_expire($uid,$days) {
if(! intval($expire_limit))
$expire_limit = 5000;
+ $item_normal = item_normal();
+
$r = q("SELECT * FROM `item`
WHERE `uid` = %d
AND `created` < %s - INTERVAL %s
AND `id` = `parent`
$sql_extra
AND item_retained = 0
- AND (item_restrict = 0 ) LIMIT $expire_limit ",
+ $item_normal LIMIT $expire_limit ",
intval($uid),
db_utcnow(), db_quoteinterval(intval($days).' DAY')
);
@@ -4108,9 +4116,8 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
switch($stage) {
case DROPITEM_PHASE2:
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '',
+ $r = q("UPDATE item SET item_pending_remove = 1, body = '', title = '',
changed = '%s', edited = '%s' WHERE id = %d",
- intval(ITEM_PENDING_REMOVE),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
@@ -4194,9 +4201,10 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
function first_post_date($uid,$wall = false) {
$wall_sql = (($wall) ? " and item_wall = 1 " : "" );
+ $item_normal = item_normal();
$r = q("select id, created from item
- where item_restrict = %d and uid = %d and id = parent $wall_sql
+ where uid = %d and id = parent $item_normal $wall_sql
order by created asc limit 1",
intval(ITEM_VISIBLE),
intval($uid)
@@ -4397,10 +4405,12 @@ function zot_feed($uid,$observer_hash,$arr) {
return array();
}
+ $item_normal = item_normal();
+
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) . ") AND item_restrict = 0
+ and uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ") $item_normal
AND item_wall = 1
and item_private = 0 $sql_extra GROUP BY parent ORDER BY created ASC $limit",
intval($uid)
@@ -4408,7 +4418,7 @@ function zot_feed($uid,$observer_hash,$arr) {
}
else {
$r = q("SELECT parent, created, postopts from item
- WHERE uid = %d AND item_restrict = 0
+ WHERE uid = %d $item_normal
AND item_wall = 1
$sql_extra GROUP BY parent ORDER BY created ASC $limit",
intval($uid)
@@ -4424,10 +4434,10 @@ function zot_feed($uid,$observer_hash,$arr) {
$parents_str = ids_to_querystr($r,'parent');
$sys_query = ((is_sys_channel($uid)) ? $sql_extra : '');
+ $item_normal = item_normal();
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`
- WHERE `item`.`item_restrict` = 0
- AND `item`.`parent` IN ( %s ) $sys_query ",
+ WHERE `item`.`parent` IN ( %s ) $item_normal $sys_query ",
dbesc($parents_str)
);
}
@@ -4465,6 +4475,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
$def_acl = '';
$item_uids = ' true ';
+ $item_normal = item_normal();
+
if ($arr['uid']) $uid= $arr['uid'];
@@ -4511,7 +4523,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
return $result;
}
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent $item_normal ) ";
$x = group_rec_byhash($uid,$r[0]['hash']);
$result['headline'] = sprintf( t('Collection: %s'),$x['name']);
@@ -4523,7 +4535,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
intval(local_channel())
);
if ($r) {
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) ";
$result['headline'] = sprintf( t('Connection: %s'),$r[0]['xchan_name']);
} else {
$result['message'] = t('Connection not found.');
diff --git a/include/poller.php b/include/poller.php
index a175d59b5..09c642f6a 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -90,15 +90,13 @@ function poller_run($argv, $argc){
// (time travel posts). Restrict to items that have come of age in the last
// couple of days to limit the query to something reasonable.
- $r = q("select id from item where ( item_restrict & %d ) > 0 and created <= %s and created > '%s' ",
- intval(ITEM_DELAYED_PUBLISH),
+ $r = q("select id from item where item_delayed = 1 and created <= %s and created > '%s' ",
db_utcnow(),
dbesc(datetime_convert('UTC','UTC','now - 2 days'))
);
if($r) {
foreach($r as $rr) {
- $x = q("update item set item_restrict = ( item_restrict & ~%d ) where id = %d",
- intval(ITEM_DELAYED_PUBLISH),
+ $x = q("update item set item_delayed = 0 where id = %d",
intval($rr['id'])
);
if($x) {
diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql
index c1344e6df..36a0d3f04 100644
--- a/install/schema_mysql.sql
+++ b/install/schema_mysql.sql
@@ -588,6 +588,10 @@ CREATE TABLE IF NOT EXISTS `item` (
`item_deleted` tinyint(1) NOT NULL DEFAULT '0',
`item_type` int(11) NOT NULL DEFAULT '0',
`item_hidden` tinyint(1) NOT NULL DEFAULT '0',
+ `item_unpublished` tinyint(1) NOT NULL DEFAULT '0',
+ `item_delayed` tinyint(1) NOT NULL DEFAULT '0',
+ `item_pending_remove` tinyint(1) NOT NULL DEFAULT '0',
+ `item_blocked` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `parent` (`parent`),
@@ -636,6 +640,10 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `item_type` (`item_type`),
KEY `item_hidden` (`item_hidden`),
KEY `item_consensus` (`item_consensus`),
+ KEY `item_unpublished` (`item_unpublished`),
+ KEY `item_delayed` (`item_delayed`),
+ KEY `item_pending_remove` (`item_pending_remove`),
+ KEY `item_blocked` (`item_blocked`),
FULLTEXT KEY `title` (`title`),
FULLTEXT KEY `body` (`body`),
FULLTEXT KEY `allow_cid` (`allow_cid`),
diff --git a/mod/bookmarks.php b/mod/bookmarks.php
index a5b9c473f..c3d25253f 100644
--- a/mod/bookmarks.php
+++ b/mod/bookmarks.php
@@ -9,7 +9,9 @@ function bookmarks_init(&$a) {
$u = $a->get_channel();
- $i = q("select * from item where id = %d and uid = %d limit 1",
+ $item_normal = item_normal();
+
+ $i = q("select * from item where id = %d and uid = %d $item_normal limit 1",
intval($item_id),
intval(local_channel())
);
@@ -23,7 +25,7 @@ function bookmarks_init(&$a) {
$terms = get_terms_oftype($item['term'],TERM_BOOKMARK);
- if($terms && (! $item['item_restrict'])) {
+ if($terms) {
require_once('include/bookmarks.php');
$s = q("select * from xchan where xchan_hash = '%s' limit 1",
diff --git a/mod/channel.php b/mod/channel.php
index 65af36b59..c0f1f419f 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -145,7 +145,7 @@ function channel_content(&$a, $update = 0, $load = false) {
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
*/
-
+ $item_normal = item_normal();
$sql_extra = item_permissions_sql($a->profile['profile_uid']);
if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode') && (! $mid))
@@ -165,7 +165,7 @@ function channel_content(&$a, $update = 0, $load = false) {
if(($update) && (! $load)) {
if ($mid) {
- $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0
+ $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal
AND item_wall = 1 AND item_unseen = 1 $sql_extra limit 1",
dbesc($mid . '%'),
intval($a->profile['profile_uid'])
@@ -173,7 +173,7 @@ function channel_content(&$a, $update = 0, $load = false) {
} else {
$r = q("SELECT distinct parent AS `item_id`, created from item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
- WHERE uid = %d AND item_restrict = 0
+ 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)
$sql_extra
@@ -207,7 +207,7 @@ 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
+ $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal
AND item_wall = 1 $sql_extra limit 1",
dbesc($mid),
intval($a->profile['profile_uid'])
@@ -219,7 +219,7 @@ function channel_content(&$a, $update = 0, $load = false) {
} else {
$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
+ 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)
$sql_extra $sql_extra2
@@ -240,7 +240,7 @@ function channel_content(&$a, $update = 0, $load = false) {
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`
FROM `item`
- WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0
+ WHERE `item`.`uid` = %d $item_normal
AND `item`.`parent` IN ( %s )
$sql_extra ",
intval($a->profile['profile_uid']),
diff --git a/mod/display.php b/mod/display.php
index 33fb83e70..2f61e688a 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -157,6 +157,7 @@ function display_content(&$a, $update = 0, $load = false) {
}
$observer_hash = get_observer_hash();
+ $item_normal = item_normal();
$sql_extra = public_permissions_sql($observer_hash);
@@ -175,9 +176,9 @@ function display_content(&$a, $update = 0, $load = false) {
if(local_channel()) {
$r = q("SELECT * from item
- WHERE item_restrict = 0
- and uid = %d
+ WHERE uid = %d
and mid = '%s'
+ $item_normal
limit 1",
intval(local_channel()),
dbesc($target_item['parent_mid'])
@@ -198,13 +199,13 @@ function display_content(&$a, $update = 0, $load = false) {
$r = q("SELECT * from item
- WHERE item_restrict = 0
- and mid = '%s'
+ WHERE mid = '%s'
AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
AND `item`.`deny_gid` = '' AND item_private = 0 )
and owner_xchan in ( " . stream_perms_xchans(($observer_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
OR uid = %d )
$sql_extra )
+ $item_normal
limit 1",
dbesc($target_item['parent_mid']),
intval($sysid)
@@ -224,7 +225,7 @@ function display_content(&$a, $update = 0, $load = false) {
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`
FROM `item`
- WHERE item_restrict = 0 and parent in ( %s ) ",
+ WHERE parent in ( %s ) $item_normal ",
dbesc($parents_str)
);
diff --git a/mod/item.php b/mod/item.php
index d631bd1f2..90f681854 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -676,7 +676,7 @@ function item_post(&$a) {
if($moderated)
- $item_restrict = $item_restrict | ITEM_MODERATED;
+ $item_blocked = ITEM_MODERATED;
if(! strlen($verb))
@@ -940,7 +940,7 @@ function item_content(&$a) {
if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) {
require_once('include/items.php');
- $i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_restrict from item where id = %d limit 1",
+ $i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_type from item where id = %d limit 1",
intval(argv(2))
);
@@ -966,7 +966,7 @@ function item_content(&$a) {
// if this is a different page type or it's just a local delete
// but not by the item author or owner, do a simple deletion
- if($i[0]['item_restrict'] || ($local_delete && (! $can_delete))) {
+ if(intval($i[0]['item_type']) || ($local_delete && (! $can_delete))) {
drop_item($i[0]['id']);
}
else {
@@ -1092,7 +1092,7 @@ function item_check_service_class($channel_id,$iswebpage) {
);
}
else {
- $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and item_wall = 1 and uid = %d ",
+ $r = q("select count(id) as total from item where parent = id and item_wall = 1 and uid = %d " . item_normal(),
intval($channel_id)
);
}
diff --git a/mod/like.php b/mod/like.php
index 57939885a..ffd302efa 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -304,7 +304,9 @@ function like_content(&$a) {
$multi_undo = 1;
}
- $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) AND item_restrict = 0
+ $item_normal = item_normal();
+
+ $r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) $item_normal
AND author_xchan = '%s' AND ( parent = %d OR thr_parent = '%s') and uid = %d ",
dbesc($observer['xchan_hash']),
intval($item_id),
diff --git a/mod/manage.php b/mod/manage.php
index bb6c010f6..bc538e564 100644
--- a/mod/manage.php
+++ b/mod/manage.php
@@ -56,8 +56,8 @@ function manage_content(&$a) {
$channels[$x]['default_links'] = '1';
- $c = q("SELECT id, item_restrict, item_wall FROM item
- WHERE item_restrict = 0 and item_unseen = 1 and uid = %d",
+ $c = q("SELECT id, item_wall FROM item
+ WHERE item_unseen = 1 and uid = %d " . item_normal(),
intval($channels[$x]['channel_id'])
);
diff --git a/mod/network.php b/mod/network.php
index 6431883d5..f4c8390dc 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -40,7 +40,7 @@ function network_content(&$a, $update = 0, $load = false) {
call_hooks('network_content_init', $arr);
$channel = $a->get_channel();
-
+ $item_normal = item_normal();
$datequery = $datequery2 = '';
@@ -198,7 +198,7 @@ function network_content(&$a, $update = 0, $load = false) {
info( t('Collection is empty'));
}
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) ";
$x = group_rec_byhash(local_channel(), $group_hash);
@@ -221,7 +221,7 @@ function network_content(&$a, $update = 0, $load = false) {
intval(local_channel())
);
if($r) {
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) ";
$title = replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => t('Connection: ') . $r[0]['xchan_name']
));
@@ -404,7 +404,7 @@ 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 AND item_restrict = 0
+ WHERE true $uids $item_normal
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
$simple_update
$sql_extra $sql_nets
@@ -433,7 +433,7 @@ function network_content(&$a, $update = 0, $load = false) {
$r = q("SELECT distinct item.id AS item_id, $ordering FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent = item.id
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets
@@ -446,7 +446,7 @@ function network_content(&$a, $update = 0, $load = false) {
// this is an update
$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 AND item.item_restrict = 0 $simple_update
+ 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)
@@ -463,7 +463,7 @@ function network_content(&$a, $update = 0, $load = false) {
$parents_str = ids_to_querystr($r,'item_id');
$items = q("SELECT item.*, item.id AS item_id FROM item
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent IN ( %s )
$sql_extra ",
dbesc($parents_str)
diff --git a/mod/photos.php b/mod/photos.php
index 3338e22ab..52fbe5e4c 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -135,14 +135,13 @@ function photos_post(&$a) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
- $r = q("select id, item_restrict from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d",
+ $r = q("select id from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d " . item_normal(),
intval($page_owner_uid)
);
if($r) {
foreach($r as $i) {
drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */);
- if(! $item_restrict)
- proc_run('php','include/notifier.php','drop',$i['id']);
+ proc_run('php','include/notifier.php','drop',$i['id']);
}
}
diff --git a/mod/ping.php b/mod/ping.php
index d43694358..f2ec93f32 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -43,6 +43,8 @@ function ping_init(&$a) {
$vnotify = false;
+ $item_normal = item_normal();
+
if(local_channel()) {
$vnotify = get_pconfig(local_channel(),'system','vnotify');
$evdays = intval(get_pconfig(local_channel(),'system','evdays'));
@@ -272,7 +274,7 @@ function ping_init(&$a) {
$result = array();
$r = q("SELECT * FROM item
- WHERE item_restrict = 0 and item_unseen = 1 and uid = %d
+ WHERE item_unseen = 1 and uid = %d $item_normal
and author_xchan != '%s' ORDER BY created DESC limit 300",
intval(local_channel()),
dbesc($ob_hash)
@@ -376,8 +378,9 @@ function ping_init(&$a) {
$t1 = dba_timer();
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
- $r = q("SELECT id, item_restrict, item_flags FROM item
- WHERE (item_restrict = 0) and item_unseen = 1 and uid = %d
+ $r = q("SELECT id, item_flags FROM item
+ WHERE item_unseen = 1 and uid = %d
+ $item_normal
and author_xchan != '%s'",
intval(local_channel()),
dbesc($ob_hash)
diff --git a/mod/public.php b/mod/public.php
index 1f23a1999..3868f6d6c 100644
--- a/mod/public.php
+++ b/mod/public.php
@@ -10,6 +10,8 @@ function public_content(&$a, $update = 0, $load = false) {
if(get_config('system','disable_discover_tab'))
return;
+ $item_normal = item_normal();
+
if(! $update) {
$maxheight = get_config('system','home_divmore_height');
@@ -95,7 +97,7 @@ function public_content(&$a, $update = 0, $load = false) {
$r = q("SELECT distinct item.id AS item_id, $ordering FROM item
left join abook on item.author_xchan = abook.abook_xchan
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent = item.id
and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)
$sql_extra3 $sql_extra $sql_nets
@@ -109,7 +111,7 @@ function public_content(&$a, $update = 0, $load = false) {
$r = q("SELECT distinct item.id AS item_id, $ordering FROM item
left join abook on item.author_xchan = abook.abook_xchan
- WHERE true $uids AND item.item_restrict = 0
+ 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",
@@ -126,7 +128,7 @@ function public_content(&$a, $update = 0, $load = false) {
$parents_str = ids_to_querystr($r,'item_id');
$items = q("SELECT item.*, item.id AS item_id FROM item
- WHERE true $uids AND item.item_restrict = 0
+ WHERE true $uids $item_normal
AND item.parent IN ( %s )
$sql_extra ",
dbesc($parents_str)
diff --git a/mod/search.php b/mod/search.php
index 426642141..0363a225f 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -125,6 +125,7 @@ function search_content(&$a,$update = 0, $load = false) {
}
+ $item_normal = item_normal();
$pub_sql = public_permissions_sql($observer_hash);
require_once('include/identity.php');
@@ -143,7 +144,7 @@ function search_content(&$a,$update = 0, $load = false) {
if($load) {
$r = null;
-
+
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$prefix = 'distinct on (created, mid)';
$suffix = 'ORDER BY created DESC, mid';
@@ -153,23 +154,22 @@ function search_content(&$a,$update = 0, $load = false) {
}
if(local_channel()) {
$r = q("SELECT $prefix mid, item.id as item_id, item.* from item
- WHERE item_restrict = 0 AND ( item_flags & %d ) = 0
- AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
+ WHERE ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
OR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' )
+ $item_normal
$sql_extra
$suffix $pager_sql ",
- intval(ITEM_OBSCURED),
intval(local_channel()),
dbesc($sys['xchan_hash'])
);
}
if($r === null) {
$r = q("SELECT $prefix mid, item.id as item_id, item.* from item
- WHERE item_restrict = 0 AND ( item_flags & %d ) = 0
- AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
+ WHERE (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
AND `item`.`deny_gid` = '' AND item_private = 0 )
and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
$pub_sql ) OR owner_xchan = '%s')
+ $item_normal
$sql_extra
$suffix $pager_sql",
intval(ITEM_OBSCURED),
diff --git a/mod/viewsrc.php b/mod/viewsrc.php
index 931175a44..cffb01b6e 100644
--- a/mod/viewsrc.php
+++ b/mod/viewsrc.php
@@ -20,9 +20,10 @@ function viewsrc_content(&$a) {
notice( t('Item not found.') . EOL);
}
+ $item_normal = item_normal();
if(local_channel() && $item_id) {
- $r = q("select id, item_flags, item_obscured, body from item where item_restrict = 0 and uid in (%d , %d) and id = %d limit 1",
+ $r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d $item_normal limit 1",
intval(local_channel()),
intval($sys['channel_id']),
intval($item_id)
diff --git a/mod/webpages.php b/mod/webpages.php
index 1795b52a0..8e12b5910 100644
--- a/mod/webpages.php
+++ b/mod/webpages.php
@@ -133,9 +133,9 @@ function webpages_content(&$a) {
$sql_extra = item_permissions_sql($owner);
$r = q("select * from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'WEBPAGE' and item_restrict = %d $sql_extra order by item.created desc",
+ where item_id.uid = %d and service = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc",
intval($owner),
- intval(ITEM_WEBPAGE)
+ intval(ITEM_TYPE_WEBPAGE)
);
$pages = null;