aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php132
1 files changed, 113 insertions, 19 deletions
diff --git a/include/items.php b/include/items.php
index 7a94336be..c35a442b2 100755
--- a/include/items.php
+++ b/include/items.php
@@ -239,6 +239,31 @@ function red_unescape_codeblock($m) {
}
+function red_zrlify_img_callback($matches) {
+ $m = @parse_url($matches[2]);
+ $zrl = false;
+ if($m['host']) {
+ $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
+ dbesc($m['host'])
+ );
+ if($r)
+ $zrl = true;
+ }
+
+ $t = strip_zids($matches[2]);
+ if($t !== $matches[2]) {
+ $zrl = true;
+ $matches[2] = $t;
+ }
+
+ if($zrl)
+ return '[zmg' . $matches[1] . ']' . $matches[2] . '[/zmg]';
+ return $matches[0];
+}
+
+
+
+
/**
* @function post_activity_item($arr)
*
@@ -918,6 +943,8 @@ function map_scope($scope) {
return 'network: red';
case PERMS_SITE:
return 'site: ' . get_app()->get_hostname();
+ case PERMS_PENDING:
+ return 'any connections';
case PERMS_CONTACTS:
default:
return 'contacts';
@@ -1976,8 +2003,6 @@ function item_store_update($arr,$allow_exec = false) {
$arr = $d['item'];
$allow_exec = $d['allow_exec'];
-
-
$ret = array('success' => false, 'item_id' => 0);
if(! intval($arr['uid'])) {
logger('item_store_update: no uid');
@@ -2011,6 +2036,10 @@ function item_store_update($arr,$allow_exec = false) {
if($orig[0]['item_flags'] & ITEM_VERIFIED)
$orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_VERIFIED;
+ if($orig[0]['item_flags'] & ITEM_OBSCURED)
+ $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_OBSCURED;
+
+
$arr['item_flags'] = intval($arr['item_flags']) | $orig[0]['item_flags'];
$arr['item_restrict'] = intval($arr['item_restrict']) | $orig[0]['item_restrict'];
@@ -2092,7 +2121,7 @@ function item_store_update($arr,$allow_exec = false) {
unset($arr['llink']);
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
- $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : $orig[0]['expires']);
+ $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : $orig[0]['expires']);
$arr['commented'] = $orig[0]['commented'];
$arr['received'] = datetime_convert();
$arr['changed'] = datetime_convert();
@@ -2105,11 +2134,13 @@ function item_store_update($arr,$allow_exec = false) {
$arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : $orig[0]['tgt_type']);
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : $orig[0]['target']);
$arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : $orig[0]['plink']);
- $arr['allow_cid'] = ((x($arr,'allow_cid')) ? trim($arr['allow_cid']) : $orig[0]['allow_cid']);
- $arr['allow_gid'] = ((x($arr,'allow_gid')) ? trim($arr['allow_gid']) : $orig[0]['allow_gid']);
- $arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : $orig[0]['deny_cid']);
- $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : $orig[0]['deny_gid']);
- $arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : $orig[0]['item_private']);
+
+ $arr['allow_cid'] = ((array_key_exists('allow_cid',$arr)) ? trim($arr['allow_cid']) : $orig[0]['allow_cid']);
+ $arr['allow_gid'] = ((array_key_exists('allow_gid',$arr)) ? trim($arr['allow_gid']) : $orig[0]['allow_gid']);
+ $arr['deny_cid'] = ((array_key_exists('deny_cid',$arr)) ? trim($arr['deny_cid']) : $orig[0]['deny_cid']);
+ $arr['deny_gid'] = ((array_key_exists('deny_gid',$arr)) ? trim($arr['deny_gid']) : $orig[0]['deny_gid']);
+ $arr['item_private'] = ((array_key_exists('item_private',$arr)) ? intval($arr['item_private']) : $orig[0]['item_private']);
+
$arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : $orig[0]['app']);
@@ -2309,6 +2340,34 @@ function tag_deliver($uid,$item_id) {
}
+ if (stristr($item['verb'],ACTIVITY_POKE)) {
+ $poke_notify = true;
+
+ if(($item['obj_type'] == "") || ($item['obj_type'] !== ACTIVITY_OBJ_PERSON) || (! $item['object']))
+ $poke_notify = false;
+
+ $obj = json_decode_plus($item['object']);
+ if($obj) {
+ if($obj['id'] !== $u[0]['channel_hash'])
+ $poke_notify = false;
+ }
+
+ $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
+ if($poke_notify) {
+ require_once('include/enotify.php');
+ notification(array(
+ 'to_xchan' => $u[0]['channel_hash'],
+ 'from_xchan' => $item['author_xchan'],
+ 'type' => NOTIFY_POKE,
+ 'item' => $item,
+ 'link' => $i[0]['llink'],
+ 'verb' => ACTIVITY_POKE,
+ 'activity' => $verb,
+ 'otype' => 'item'
+ ));
+ }
+ }
+
if($item['obj_type'] === ACTIVITY_OBJ_TAGTERM) {
// We received a community tag activity for a post.
@@ -2413,7 +2472,7 @@ function tag_deliver($uid,$item_id) {
if($terms) {
foreach($terms as $term) {
- if((strcasecmp($term['term'],$u[0]['channel_name']) == 0) && link_compare($term['url'],$link)) {
+ if(link_compare($term['url'],$link)) {
$mention = true;
break;
}
@@ -2449,11 +2508,11 @@ function tag_deliver($uid,$item_id) {
$tagged = false;
$plustagged = false;
- $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'],'/') . '\[\/zrl\]/';
+ $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'],'/') . '\[\/zrl\]/';
if(preg_match($pattern,$body,$matches))
$tagged = true;
- $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'] . '+','/') . '\[\/zrl\]/';
+ $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/';
if(preg_match($pattern,$body,$matches))
$plustagged = true;
@@ -2582,7 +2641,7 @@ function tgroup_check($uid,$item) {
if($terms) {
foreach($terms as $term) {
- if(($term['term'] == $u[0]['channel_name']) && link_compare($term['url'],$link)) {
+ if(link_compare($term['url'],$link)) {
$mention = true;
break;
}
@@ -2600,7 +2659,7 @@ function tgroup_check($uid,$item) {
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']);
- $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'] . '+','/') . '\[\/zrl\]/';
+ $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/';
if(! preg_match($pattern,$body,$matches)) {
logger('tgroup_check: mention was in a reshare - ignoring');
@@ -4028,7 +4087,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
if(! array_key_exists('nouveau',$arr)) {
- $sql_extra2 = " AND item.parent = item.id ";
+ $sql_extra2 = " AND item.parent = item.id ";
$sql_extra3 = '';
}
@@ -4069,12 +4128,12 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
$pager_sql = sprintf(" LIMIT %d, %d ",intval($arr['start']), intval($arr['records']));
if(array_key_exists('cmin',$arr) || array_key_exists('cmax',$arr)) {
- if(($arr['cmin'] != 0) || ($arr['cmax'] != 99)) {
+ if(($arr['cmin'] != 0) || ($arr['cmax'] != 99)) {
- // Not everybody who shows up in the network stream will be in your address book.
- // By default those that aren't are assumed to have closeness = 99; but this isn't
- // recorded anywhere. So if cmax is 99, we'll open the search up to anybody in
- // the stream with a NULL address book entry.
+ // Not everybody who shows up in the network stream will be in your address book.
+ // By default those that aren't are assumed to have closeness = 99; but this isn't
+ // recorded anywhere. So if cmax is 99, we'll open the search up to anybody in
+ // the stream with a NULL address book entry.
$sql_nets .= " AND ";
@@ -4245,3 +4304,38 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
}
+
+/**
+ * change access control for item with message_id $mid and channel_id $uid
+ */
+
+
+function item_add_cid($xchan_hash,$mid,$uid) {
+ $r = q("select id from item where mid = '%s' and uid = %d and allow_cid like '%s'",
+ dbesc($mid),
+ intval($uid),
+ dbesc('<' . $xchan_hash . '>')
+ );
+ if(! $r) {
+ $r = q("update item set allow_cid = concat(allow_cid,'%s') where mid = '%s' and uid = %d limit 1",
+ dbesc('<' . $xchan_hash . '>'),
+ dbesc($mid),
+ intval($uid)
+ );
+ }
+}
+
+function item_remove_cid($xchan_hash,$mid,$uid) {
+ $r = q("select allow_cid from item where mid = '%s' and uid = %d and allow_cid like '%s'",
+ dbesc($mid),
+ intval($uid),
+ dbesc('<' . $xchan_hash . '>')
+ );
+ if($r) {
+ $x = q("update item set allow_cid = '%s' where mid = '%s' and uid = %d limit 1",
+ dbesc(str_replace('<' . $xchan_hash . '>','',$r[0]['allow_cid'])),
+ dbesc($mid),
+ intval($uid)
+ );
+ }
+}