aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Hq.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Hq.php')
-rw-r--r--Zotlabs/Module/Hq.php108
1 files changed, 51 insertions, 57 deletions
diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index 4c2067299..3b8e88488 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -1,6 +1,10 @@
<?php
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Widget\Messages;
+
+
require_once("include/bbcode.php");
require_once('include/security.php');
require_once('include/conversation.php');
@@ -14,67 +18,52 @@ class Hq extends \Zotlabs\Web\Controller {
if(! local_channel())
return;
- \App::$profile_uid = local_channel();
+ App::$profile_uid = local_channel();
}
- function post() {
+ function get($update = 0, $load = false) {
- if(!local_channel())
+ if(!local_channel()) {
return;
-
- if($_REQUEST['notify_id']) {
- q("update notify set seen = 1 where id = %d and uid = %d",
- intval($_REQUEST['notify_id']),
- intval(local_channel())
- );
}
- killme();
-
- }
+ if(argc() > 1 && argv(1) !== 'load') {
+ $item_hash = unpack_link_id(argv(1));
+ }
- function get($update = 0, $load = false) {
+ if(isset($_REQUEST['mid'])) {
+ $item_hash = unpack_link_id($_REQUEST['mid']);
+ }
- if(!local_channel())
+ if($item_hash === false) {
+ notice(t('Malformed message id.') . EOL);
return;
-
- if(argc() > 1 && argv(1) !== 'load') {
- $item_hash = argv(1);
}
-
- if($_REQUEST['mid'])
- $item_hash = $_REQUEST['mid'];
$item_normal = item_normal();
$item_normal_update = item_normal_update();
if(! $item_hash) {
- $r = q("SELECT mid FROM item
+ $r = q("SELECT mid FROM item
WHERE uid = %d $item_normal
- AND mid = parent_mid
+ AND mid = parent_mid
+ AND item_private IN (0, 1)
ORDER BY created DESC LIMIT 1",
intval(local_channel())
);
-
if($r[0]['mid']) {
- $item_hash = 'b64.' . base64url_encode($r[0]['mid']);
+ $item_hash = $r[0]['mid'];
}
}
if($item_hash) {
- if(strpos($item_hash,'b64.') === 0)
- $decoded = @base64url_decode(substr($item_hash,4));
-
- if($decoded)
- $item_hash = $decoded;
-
$target_item = null;
- $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid like '%s' limit 1",
- dbesc($item_hash . '%')
+ $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid = '%s' limit 1",
+ dbesc($item_hash)
);
-
+
if($r) {
$target_item = $r[0];
}
@@ -83,7 +72,7 @@ class Hq extends \Zotlabs\Web\Controller {
if($target_item['item_blocked'] == ITEM_MODERATED) {
goaway(z_root() . '/moderate/' . $target_item['id']);
}
-
+
$simple_update = '';
if($update && $_SESSION['loadtime'])
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
@@ -94,16 +83,16 @@ class Hq extends \Zotlabs\Web\Controller {
$sys_item = false;
}
-
+
if(! $update) {
- $channel = \App::get_channel();
+ $channel = App::get_channel();
$channel_acl = [
- 'allow_cid' => $channel['channel_allow_cid'],
- 'allow_gid' => $channel['channel_allow_gid'],
- 'deny_cid' => $channel['channel_deny_cid'],
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
'deny_gid' => $channel['channel_deny_gid']
- ];
+ ];
$x = [
'is_owner' => true,
@@ -125,13 +114,7 @@ class Hq extends \Zotlabs\Web\Controller {
'reset' => t('Reset form')
];
- $o = replace_macros(get_markup_template("hq.tpl"),
- [
- '$no_messages' => (($target_item) ? false : true),
- '$no_messages_label' => [ t('Welcome to Hubzilla!'), t('You have got no unseen posts...') ],
- '$editor' => status_editor($a,$x,false,'Hq')
- ]
- );
+ $o = status_editor($a, $x, true);
}
@@ -142,10 +125,9 @@ class Hq extends \Zotlabs\Web\Controller {
if($target_item) {
// if the target item is not a post (eg a like) we want to address its thread parent
//$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']);
- $mid = $target_item['mid'];
- // if we got a decoded hash we must encode it again before handing to javascript
- if($decoded)
- $mid = 'b64.' . base64url_encode($mid);
+
+ // if we got a decoded hash we must encode it again before handing to javascript
+ $mid = gen_link_id($target_item['mid']);
}
else {
$mid = '';
@@ -153,9 +135,9 @@ class Hq extends \Zotlabs\Web\Controller {
$o .= '<div id="live-hq"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . local_channel()
- . "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . ";</script>\r\n";
-
- \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
+ . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . ";</script>\r\n";
+
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
'$baseurl' => z_root(),
'$pgtype' => 'hq',
'$uid' => local_channel(),
@@ -241,14 +223,14 @@ class Hq extends \Zotlabs\Web\Controller {
else {
$r = [];
}
-
+
if($r) {
- $items = q("SELECT item.*, item.id AS item_id
+ $items = q("SELECT item.*, item.id AS item_id
FROM item
WHERE parent = '%s' $item_normal ",
dbesc($r[0]['item_id'])
);
-
+
xchan_query($items,true,(($sys_item) ? local_channel() : 0));
$items = fetch_post_tags($items,true);
$items = conv_sort($items,'created');
@@ -267,4 +249,16 @@ class Hq extends \Zotlabs\Web\Controller {
}
+ function post() {
+ if (!local_channel())
+ return;
+
+ $options['offset'] = $_REQUEST['offset'];
+ $options['type'] = $_REQUEST['type'];
+
+ $ret = Messages::get_messages_page($options);
+
+ json_return_and_die($ret);
+ }
+
}