aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php38
1 files changed, 29 insertions, 9 deletions
diff --git a/include/items.php b/include/items.php
index 9807831e3..28fd8502b 100755
--- a/include/items.php
+++ b/include/items.php
@@ -833,10 +833,13 @@ function title_is_body($title, $body) {
}
-function get_item_elements($x) {
+function get_item_elements($x,$allow_code = false) {
$arr = array();
- $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : '');
+ if($allow_code)
+ $arr['body'] = $x['body'];
+ else
+ $arr['body'] = (($x['body']) ? htmlspecialchars($x['body'],ENT_COMPAT,'UTF-8',false) : '');
$key = get_config('system','pubkey');
@@ -1309,7 +1312,7 @@ function encode_item($item,$mirror = false) {
$x['comment_scope'] = $c_scope;
if($item['term'])
- $x['tags'] = encode_item_terms($item['term']);
+ $x['tags'] = encode_item_terms($item['term'],$mirror);
if($item['diaspora_meta']) {
$z = json_decode($item['diaspora_meta'],true);
@@ -1401,11 +1404,16 @@ function encode_item_xchan($xchan) {
return $ret;
}
-function encode_item_terms($terms) {
+function encode_item_terms($terms,$mirror = false) {
$ret = array();
$allowed_export_terms = array( TERM_UNKNOWN, TERM_HASHTAG, TERM_MENTION, TERM_CATEGORY, TERM_BOOKMARK );
+ if($mirror) {
+ $allowed_export_terms[] = TERM_PCATEGORY;
+ $allowed_export_terms[] = TERM_FILE;
+ }
+
if($terms) {
foreach($terms as $term) {
if(in_array($term['type'],$allowed_export_terms))
@@ -3322,7 +3330,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
dbesc($title),
dbesc($body),
intval($item_wall),
- $intval($item_origin),
+ intval($item_origin),
intval($item_id)
);
@@ -4632,10 +4640,12 @@ function zot_feed($uid,$observer_hash,$arr) {
$items = array();
- /** @FIXME fix this part for PostgreSQL */
+ /** @FIXME re-unite these SQL statements. There is no need for them to be separate. The mySQL is convoluted with misuse of group by. As it stands, there is a slight difference where the postgres version doesn't remove the duplicate parents up to 100. In practice this doesn't matter. It could be made to match behavior by adding "distinct on (parent) " to the front of the selection list, at a not-worth-it performance penalty (page temp results to disk). duplicates are still ignored in the in() clause, you just get less than 100 parents if there are many children. */
if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
- return array();
+ $groupby = '';
+ } else {
+ $groupby = 'GROUP BY parent';
}
$item_normal = item_normal();
@@ -4645,7 +4655,7 @@ function zot_feed($uid,$observer_hash,$arr) {
WHERE uid != %d
$item_normal
AND item_wall = 1
- and item_private = 0 $sql_extra GROUP BY parent ORDER BY created ASC $limit",
+ and item_private = 0 $sql_extra $groupby ORDER BY created ASC $limit",
intval($uid)
);
}
@@ -4653,7 +4663,7 @@ function zot_feed($uid,$observer_hash,$arr) {
$r = q("SELECT parent, created, postopts from item
WHERE uid = %d $item_normal
AND item_wall = 1
- $sql_extra GROUP BY parent ORDER BY created ASC $limit",
+ $sql_extra $groupby ORDER BY created ASC $limit",
intval($uid)
);
}
@@ -4724,6 +4734,12 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
if($arr['wall'])
$sql_options .= " and item_wall = 1 ";
+
+ if($arr['item_id'])
+ $sql_options .= " and parent = " . intval($arr['item_id']) . " ";
+
+ if($arr['mid'])
+ $sql_options .= " and parent_mid = '" . dbesc($arr['mid']) . "' ";
$sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) ";
@@ -4850,11 +4866,15 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
require_once('include/security.php');
$sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash);
+
if($arr['pages'])
$item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " ";
else
$item_restrict = " AND item_type = 0 ";
+ if($arr['item_type'] === '*')
+ $item_restrict = '';
+
if ($arr['nouveau'] && ($client_mode & CLIENT_MODE_LOAD) && $channel) {
// "New Item View" - show all items unthreaded in reverse created date order