|
|
@ -29,11 +29,10 @@ class PostnDAO extends SQL { |
|
|
|
|
|
|
|
hash = :hash |
|
|
|
|
|
|
|
where session = :session |
|
|
|
and jid = :jid |
|
|
|
where origin = :origin |
|
|
|
and node = :node |
|
|
|
and nodeid = :nodeid'; |
|
|
|
|
|
|
|
|
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
@ -59,23 +58,20 @@ class PostnDAO extends SQL { |
|
|
|
'tags' => $post->tags, |
|
|
|
|
|
|
|
'hash' => $post->hash, |
|
|
|
|
|
|
|
'session' => $post->session, |
|
|
|
'jid' => $post->jid, |
|
|
|
|
|
|
|
'origin' => $post->origin, |
|
|
|
'node' => $post->node, |
|
|
|
'nodeid' => $post->nodeid |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
$this->run('Postn'); |
|
|
|
|
|
|
|
|
|
|
|
if(!$this->_effective) { |
|
|
|
$this->_sql =' |
|
|
|
insert into postn |
|
|
|
( |
|
|
|
session, |
|
|
|
|
|
|
|
jid, |
|
|
|
origin, |
|
|
|
node, |
|
|
|
nodeid, |
|
|
|
|
|
|
@ -101,10 +97,8 @@ class PostnDAO extends SQL { |
|
|
|
tags, |
|
|
|
|
|
|
|
hash) |
|
|
|
values( |
|
|
|
:session, |
|
|
|
|
|
|
|
:jid, |
|
|
|
values( |
|
|
|
:origin, |
|
|
|
:node, |
|
|
|
:nodeid, |
|
|
|
|
|
|
@ -158,8 +152,7 @@ class PostnDAO extends SQL { |
|
|
|
|
|
|
|
'hash' => $post->hash, |
|
|
|
|
|
|
|
'session' => $post->session, |
|
|
|
'jid' => $post->jid, |
|
|
|
'origin' => $post->origin, |
|
|
|
'node' => $post->node, |
|
|
|
'nodeid' => $post->nodeid |
|
|
|
) |
|
|
@ -206,8 +199,8 @@ class PostnDAO extends SQL { |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
left outer join privacy on postn.nodeid = privacy.pkey |
|
|
|
where postn.session = :session |
|
|
|
and postn.jid = :jid |
|
|
|
where ((postn.origin, node) in (select server, node from subscription where jid = :aid)) |
|
|
|
and postn.origin = :origin |
|
|
|
and postn.node = :node |
|
|
|
order by postn.published desc'; |
|
|
|
|
|
|
@ -217,8 +210,8 @@ class PostnDAO extends SQL { |
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $this->_user, |
|
|
|
'jid' => $from, |
|
|
|
'aid' => $this->_user, // TODO: Little hack to bypass the check, need to fix it in Modl
|
|
|
|
'origin' => $from, |
|
|
|
'node' => $node |
|
|
|
) |
|
|
|
); |
|
|
@ -232,7 +225,7 @@ class PostnDAO extends SQL { |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
left outer join privacy on postn.nodeid = privacy.pkey |
|
|
|
where postn.session = :session |
|
|
|
and postn.jid = :jid |
|
|
|
and postn.origin = :origin |
|
|
|
and postn.node like \'urn:xmpp:microblog:0\' |
|
|
|
and postn.picture = 1 |
|
|
|
order by postn.published desc'; |
|
|
@ -253,14 +246,11 @@ class PostnDAO extends SQL { |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
left outer join privacy on postn.nodeid = privacy.pkey |
|
|
|
where postn.session = :session |
|
|
|
and postn.nodeid = :nodeid |
|
|
|
order by postn.published desc'; |
|
|
|
where postn.nodeid = :nodeid'; |
|
|
|
|
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $this->_user, |
|
|
|
'nodeid' => $id |
|
|
|
) |
|
|
|
); |
|
|
@ -273,10 +263,13 @@ class PostnDAO extends SQL { |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
left outer join privacy on postn.nodeid = privacy.pkey |
|
|
|
where postn.session = :session |
|
|
|
where ((postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\') |
|
|
|
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\') |
|
|
|
or ((postn.origin, node) in (select server, node from subscription where jid = :origin))) |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
order by postn.published desc'; |
|
|
|
order by postn.published desc |
|
|
|
'; |
|
|
|
|
|
|
|
if($limitr) |
|
|
|
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf; |
|
|
@ -287,7 +280,7 @@ class PostnDAO extends SQL { |
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $jid |
|
|
|
'origin' => $jid |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
@ -296,14 +289,15 @@ class PostnDAO extends SQL { |
|
|
|
|
|
|
|
function getFeed($limitf = false, $limitr = false) { |
|
|
|
$this->_sql = ' |
|
|
|
select *, postn.aid as jid, privacy.value as privacy from postn |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
left outer join privacy on postn.nodeid = privacy.pkey |
|
|
|
where postn.session = :session |
|
|
|
and postn.node like \'urn:xmpp:microblog:0\' |
|
|
|
and (postn.jid in (select rosterlink.jid from rosterlink where rosterlink.session = :session) |
|
|
|
or postn.jid = :session) |
|
|
|
order by postn.published desc'; |
|
|
|
where ((postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\') |
|
|
|
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\')) |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
order by postn.published desc |
|
|
|
'; |
|
|
|
|
|
|
|
if($limitr) |
|
|
|
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf; |
|
|
@ -311,7 +305,7 @@ class PostnDAO extends SQL { |
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $this->_user |
|
|
|
'origin' => $this->_user |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
@ -320,18 +314,12 @@ class PostnDAO extends SQL { |
|
|
|
|
|
|
|
function getNews($limitf = false, $limitr = false) { |
|
|
|
$this->_sql = ' |
|
|
|
select *, postn.aid as jid, privacy.value as privacy from postn |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
left outer join privacy on postn.nodeid = privacy.pkey |
|
|
|
left outer join subscription on |
|
|
|
postn.session = subscription.jid and |
|
|
|
postn.jid = subscription.server and |
|
|
|
postn.node = subscription.node |
|
|
|
where postn.session = :session |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
and subscription is not null |
|
|
|
order by postn.published desc'; |
|
|
|
where ((postn.origin, node) in (select server, node from subscription where jid = :origin)) |
|
|
|
order by postn.published desc |
|
|
|
'; |
|
|
|
|
|
|
|
if($limitr) |
|
|
|
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf; |
|
|
@ -339,7 +327,7 @@ class PostnDAO extends SQL { |
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $this->_user |
|
|
|
'origin' => $this->_user |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
@ -347,13 +335,12 @@ class PostnDAO extends SQL { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getPublic($jid, $node) { |
|
|
|
function getPublic($origin, $node) { |
|
|
|
$this->_sql = ' |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
left outer join privacy on postn.nodeid = privacy.pkey |
|
|
|
where postn.jid = :jid |
|
|
|
and postn.session = :jid |
|
|
|
where postn.origin = :origin |
|
|
|
and postn.node = :node |
|
|
|
and privacy.value = 1 |
|
|
|
order by postn.published desc'; |
|
|
@ -361,14 +348,15 @@ class PostnDAO extends SQL { |
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'jid' => $jid, |
|
|
|
'origin' => $origin, |
|
|
|
'node' => $node |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
return $this->run('ContactPostn'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: fixme
|
|
|
|
function getComments($posts) { |
|
|
|
$commentsid = ''; |
|
|
|
if(is_array($posts)) { |
|
|
@ -416,7 +404,8 @@ class PostnDAO extends SQL { |
|
|
|
|
|
|
|
return $this->run('Postn'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: fixme
|
|
|
|
function getStatistics() { |
|
|
|
$this->_sql = ' |
|
|
|
select count(*) as count, extract(month from published) as month, extract(year from published) as year |
|
|
@ -435,29 +424,20 @@ class PostnDAO extends SQL { |
|
|
|
} |
|
|
|
|
|
|
|
function getCountSince($date) { |
|
|
|
/*$this->_sql = ' |
|
|
|
select count(*) from postn |
|
|
|
left outer join subscription on |
|
|
|
postn.session = subscription.jid and |
|
|
|
postn.jid = subscription.server and |
|
|
|
postn.node = subscription.node |
|
|
|
where postn.session = :session |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
and subscription is not null |
|
|
|
and published > :published';*/ |
|
|
|
$this->_sql = ' |
|
|
|
select count(*) from postn |
|
|
|
where postn.session = :session |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
and published > :published |
|
|
|
where ((postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\') |
|
|
|
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\') |
|
|
|
or ((postn.origin, node) in (select server, node from subscription where jid = :origin))) |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
and published > :published |
|
|
|
'; |
|
|
|
|
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $this->_user, |
|
|
|
'origin' => $this->_user, |
|
|
|
'published' => $date |
|
|
|
) |
|
|
|
); |
|
|
@ -470,23 +450,11 @@ class PostnDAO extends SQL { |
|
|
|
} |
|
|
|
|
|
|
|
function getLastDate() { |
|
|
|
/* |
|
|
|
$this->_sql = ' |
|
|
|
select published from postn |
|
|
|
left outer join subscription on |
|
|
|
postn.session = subscription.jid and |
|
|
|
postn.jid = subscription.server and |
|
|
|
postn.node = subscription.node |
|
|
|
where postn.session = :session |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
and subscription is not null |
|
|
|
order by postn.published desc |
|
|
|
limit 1 offset 0';*/ |
|
|
|
|
|
|
|
$this->_sql = ' |
|
|
|
select published from postn |
|
|
|
where postn.session = :session |
|
|
|
where ((postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\') |
|
|
|
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\') |
|
|
|
or ((postn.origin, node) in (select server, node from subscription where jid = :origin))) |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and postn.node not like \'urn:xmpp:inbox\' |
|
|
|
order by postn.published desc |
|
|
@ -495,7 +463,7 @@ class PostnDAO extends SQL { |
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $this->_user |
|
|
|
'origin' => $this->_user |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
@ -507,14 +475,12 @@ class PostnDAO extends SQL { |
|
|
|
function exist($id) { |
|
|
|
$this->_sql = ' |
|
|
|
select count(*) from postn |
|
|
|
where postn.session = :session |
|
|
|
and postn.nodeid = :nodeid |
|
|
|
where postn.nodeid = :nodeid |
|
|
|
'; |
|
|
|
|
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'session' => $this->_user, |
|
|
|
'nodeid' => $id |
|
|
|
) |
|
|
|
); |
|
|
|