|
|
@ -3,46 +3,6 @@ |
|
|
|
namespace modl; |
|
|
|
|
|
|
|
class PostnDAO extends ModlSQL { |
|
|
|
/*function create() { |
|
|
|
$sql = ' |
|
|
|
drop table if exists Postn'; |
|
|
|
|
|
|
|
$this->_db->query($sql); |
|
|
|
|
|
|
|
$sql = ' |
|
|
|
create table if not exists Postn ( |
|
|
|
`id` binary(40) NOT NULL, |
|
|
|
`key` varchar(128) DEFAULT NULL, |
|
|
|
|
|
|
|
`from` varchar(128) DEFAULT NULL, |
|
|
|
`node` varchar(128) DEFAULT NULL, |
|
|
|
`nodeid` varchar(128) DEFAULT NULL, |
|
|
|
|
|
|
|
`aname` varchar(128) DEFAULT NULL, |
|
|
|
`aid` varchar(128) DEFAULT NULL, |
|
|
|
|
|
|
|
`title` varchar(128) DEFAULT NULL, |
|
|
|
`content` text, |
|
|
|
|
|
|
|
`commentplace`varchar(128) DEFAULT NULL, |
|
|
|
|
|
|
|
`published`datetime DEFAULT NULL, |
|
|
|
`updated` datetime DEFAULT NULL, |
|
|
|
`delay` datetime DEFAULT NULL, |
|
|
|
|
|
|
|
`lat` varchar(128) DEFAULT NULL, |
|
|
|
`lon` varchar(128) DEFAULT NULL, |
|
|
|
|
|
|
|
`links` text, |
|
|
|
`tags` text, |
|
|
|
|
|
|
|
`hash` varchar(128) DEFAULT NULL, |
|
|
|
PRIMARY KEY (id) |
|
|
|
) CHARACTER SET utf8 COLLATE utf8_bin;'; |
|
|
|
|
|
|
|
$this->_db->query($sql); |
|
|
|
}*/ |
|
|
|
|
|
|
|
function set(Postn $post) { |
|
|
|
$this->_sql = ' |
|
|
|
update postn |
|
|
@ -71,6 +31,95 @@ class PostnDAO extends ModlSQL { |
|
|
|
and node = :node |
|
|
|
and nodeid = :nodeid'; |
|
|
|
|
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'aname' => $post->aname, |
|
|
|
'aid' => $post->aid, |
|
|
|
|
|
|
|
'title' => $post->title, |
|
|
|
'content' => $post->content, |
|
|
|
|
|
|
|
'commentplace' => $post->commentplace, |
|
|
|
|
|
|
|
'published' => $post->published, |
|
|
|
'updated' => $post->updated, |
|
|
|
'delay' => $post->delay, |
|
|
|
|
|
|
|
'lat' => $post->lat, |
|
|
|
'lon' => $post->lon, |
|
|
|
|
|
|
|
'links' => $post->links, |
|
|
|
'tags' => $post->tags, |
|
|
|
|
|
|
|
'hash' => $post->hash, |
|
|
|
|
|
|
|
'session' => $post->session, |
|
|
|
'jid' => $post->jid, |
|
|
|
'node' => $post->node, |
|
|
|
'nodeid' => $post->nodeid |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
$this->run('Postn'); |
|
|
|
|
|
|
|
if(!$this->_effective) { |
|
|
|
$this->_sql =' |
|
|
|
insert into postn |
|
|
|
( |
|
|
|
session, |
|
|
|
|
|
|
|
jid, |
|
|
|
node, |
|
|
|
nodeid, |
|
|
|
|
|
|
|
aname, |
|
|
|
aid, |
|
|
|
|
|
|
|
title, |
|
|
|
content, |
|
|
|
|
|
|
|
commentplace, |
|
|
|
|
|
|
|
published, |
|
|
|
updated, |
|
|
|
delay, |
|
|
|
|
|
|
|
lat, |
|
|
|
lon, |
|
|
|
|
|
|
|
links, |
|
|
|
tags, |
|
|
|
|
|
|
|
hash) |
|
|
|
values( |
|
|
|
:session, |
|
|
|
|
|
|
|
:jid, |
|
|
|
:node, |
|
|
|
:nodeid, |
|
|
|
|
|
|
|
:aname, |
|
|
|
:aid, |
|
|
|
|
|
|
|
:title, |
|
|
|
:content, |
|
|
|
|
|
|
|
:commentplace, |
|
|
|
|
|
|
|
:published, |
|
|
|
:updated, |
|
|
|
:delay, |
|
|
|
|
|
|
|
:lat, |
|
|
|
:lon, |
|
|
|
|
|
|
|
:links, |
|
|
|
:tags, |
|
|
|
|
|
|
|
:hash |
|
|
|
)'; |
|
|
|
|
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
@ -102,215 +151,7 @@ class PostnDAO extends ModlSQL { |
|
|
|
); |
|
|
|
|
|
|
|
$this->run('Postn'); |
|
|
|
|
|
|
|
if(!$this->_effective) { |
|
|
|
$this->_sql =' |
|
|
|
insert into postn |
|
|
|
( |
|
|
|
session, |
|
|
|
|
|
|
|
jid, |
|
|
|
node, |
|
|
|
nodeid, |
|
|
|
|
|
|
|
aname, |
|
|
|
aid, |
|
|
|
|
|
|
|
title, |
|
|
|
content, |
|
|
|
|
|
|
|
commentplace, |
|
|
|
|
|
|
|
published, |
|
|
|
updated, |
|
|
|
delay, |
|
|
|
|
|
|
|
lat, |
|
|
|
lon, |
|
|
|
|
|
|
|
links, |
|
|
|
tags, |
|
|
|
|
|
|
|
hash) |
|
|
|
values( |
|
|
|
:session, |
|
|
|
|
|
|
|
:jid, |
|
|
|
:node, |
|
|
|
:nodeid, |
|
|
|
|
|
|
|
:aname, |
|
|
|
:aid, |
|
|
|
|
|
|
|
:title, |
|
|
|
:content, |
|
|
|
|
|
|
|
:commentplace, |
|
|
|
|
|
|
|
:published, |
|
|
|
:updated, |
|
|
|
:delay, |
|
|
|
|
|
|
|
:lat, |
|
|
|
:lon, |
|
|
|
|
|
|
|
:links, |
|
|
|
:tags, |
|
|
|
|
|
|
|
:hash |
|
|
|
)'; |
|
|
|
|
|
|
|
$this->prepare( |
|
|
|
'Postn', |
|
|
|
array( |
|
|
|
'aname' => $post->aname, |
|
|
|
'aid' => $post->aid, |
|
|
|
|
|
|
|
'title' => $post->title, |
|
|
|
'content' => $post->content, |
|
|
|
|
|
|
|
'commentplace' => $post->commentplace, |
|
|
|
|
|
|
|
'published' => $post->published, |
|
|
|
'updated' => $post->updated, |
|
|
|
'delay' => $post->delay, |
|
|
|
|
|
|
|
'lat' => $post->lat, |
|
|
|
'lon' => $post->lon, |
|
|
|
|
|
|
|
'links' => $post->links, |
|
|
|
'tags' => $post->tags, |
|
|
|
|
|
|
|
'hash' => $post->hash, |
|
|
|
|
|
|
|
'session' => $post->session, |
|
|
|
'jid' => $post->jid, |
|
|
|
'node' => $post->node, |
|
|
|
'nodeid' => $post->nodeid |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
$this->run('Postn'); |
|
|
|
} |
|
|
|
/* |
|
|
|
$request = $this->prepare(' |
|
|
|
update Postn |
|
|
|
set `aname` = ?, |
|
|
|
`aid` = ?, |
|
|
|
|
|
|
|
`title` = ?, |
|
|
|
`content` = ?, |
|
|
|
|
|
|
|
`commentplace` = ?, |
|
|
|
|
|
|
|
`published` = ?, |
|
|
|
`updated` = ?, |
|
|
|
`delay` = ?, |
|
|
|
|
|
|
|
`lat` = ?, |
|
|
|
`lon` = ?, |
|
|
|
|
|
|
|
`links` = ?, |
|
|
|
`tags` = ?, |
|
|
|
|
|
|
|
`hash` = ? |
|
|
|
|
|
|
|
where `id` = ?', $post); |
|
|
|
|
|
|
|
|
|
|
|
where `key` = ? |
|
|
|
and `from` = ? |
|
|
|
and `node` = ? |
|
|
|
and `nodeid` = ?', $post); |
|
|
|
$hash = sha1( |
|
|
|
$post->key. |
|
|
|
$post->from. |
|
|
|
$post->node. |
|
|
|
$post->nodeid |
|
|
|
); |
|
|
|
|
|
|
|
$request->bind_param( |
|
|
|
'ssssssssssssss', |
|
|
|
$post->aname, |
|
|
|
$post->aid, |
|
|
|
$post->title, |
|
|
|
$post->content, |
|
|
|
$post->commentplace, |
|
|
|
$post->published, |
|
|
|
$post->updated, |
|
|
|
$post->delay, |
|
|
|
$post->lat, |
|
|
|
$post->lon, |
|
|
|
$post->links, |
|
|
|
$post->tags, |
|
|
|
$post->hash, |
|
|
|
$hash |
|
|
|
); |
|
|
|
|
|
|
|
$result = $request->execute(); |
|
|
|
|
|
|
|
if($this->_db->affected_rows == 0) { |
|
|
|
$request = $this->prepare(' |
|
|
|
insert into Postn |
|
|
|
( |
|
|
|
`id`, |
|
|
|
`key`, |
|
|
|
|
|
|
|
`from`, |
|
|
|
`node`, |
|
|
|
`nodeid`, |
|
|
|
|
|
|
|
`aname`, |
|
|
|
`aid`, |
|
|
|
|
|
|
|
`title`, |
|
|
|
`content`, |
|
|
|
|
|
|
|
`commentplace`, |
|
|
|
|
|
|
|
`published`, |
|
|
|
`updated`, |
|
|
|
`delay`, |
|
|
|
|
|
|
|
`lat`, |
|
|
|
`lon`, |
|
|
|
|
|
|
|
`links`, |
|
|
|
`tags`, |
|
|
|
|
|
|
|
`hash`) |
|
|
|
values( |
|
|
|
?,?,?,?,?, |
|
|
|
?,?,?,?,?, |
|
|
|
?,?,?,?,?, |
|
|
|
?,?,? |
|
|
|
)', $post); |
|
|
|
|
|
|
|
$request->bind_param( |
|
|
|
'ssssssssssssssssss', |
|
|
|
$hash, |
|
|
|
$post->key, |
|
|
|
$post->from, |
|
|
|
$post->node, |
|
|
|
$post->nodeid, |
|
|
|
$post->aname, |
|
|
|
$post->aid, |
|
|
|
$post->title, |
|
|
|
$post->content, |
|
|
|
$post->commentplace, |
|
|
|
$post->published, |
|
|
|
$post->updated, |
|
|
|
$post->delay, |
|
|
|
$post->lat, |
|
|
|
$post->lon, |
|
|
|
$post->links, |
|
|
|
$post->tags, |
|
|
|
$post->hash |
|
|
|
); |
|
|
|
$request->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
$request->close();*/ |
|
|
|
} |
|
|
|
|
|
|
|
function delete($nodeid) { |
|
|
@ -326,30 +167,9 @@ class PostnDAO extends ModlSQL { |
|
|
|
); |
|
|
|
|
|
|
|
return $this->run('Message'); |
|
|
|
|
|
|
|
/*$from = $this->_db->real_escape_string($from); |
|
|
|
$nodeid = $this->_db->real_escape_string($nodeid); |
|
|
|
$sql = ' |
|
|
|
delete from Postn |
|
|
|
where nodeid=\''.$nodeid.'\''; |
|
|
|
return $this->_db->query($sql); */ |
|
|
|
} |
|
|
|
|
|
|
|
function getNode($from, $node, $limitf = false, $limitr = false) { |
|
|
|
/*$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.key |
|
|
|
where Postn.key = \''.$this->_user->getLogin().'\' |
|
|
|
and Postn.from = \''.$from.'\' |
|
|
|
and Postn.node = \''.$node.'\' |
|
|
|
order by Postn.published desc'; |
|
|
|
|
|
|
|
if($limitr) |
|
|
|
$sql = $sql.' limit '.$limitf.','.$limitr; |
|
|
|
|
|
|
|
return $this->mapper('ContactPostn', $this->_db->query($sql));*/ |
|
|
|
|
|
|
|
$this->_sql = ' |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
@ -375,23 +195,6 @@ class PostnDAO extends ModlSQL { |
|
|
|
} |
|
|
|
|
|
|
|
function getFeed($limitf = false, $limitr = false) { |
|
|
|
/* |
|
|
|
* $sql = ' |
|
|
|
select *, Postn.aid as jid, Privacy.value as privacy from Postn |
|
|
|
left outer join Contact on Postn.aid = Contact.jid |
|
|
|
left outer join Privacy on Postn.nodeid = Privacy.key |
|
|
|
where Postn.key = \''.$this->_user->getLogin().'\' |
|
|
|
and Postn.node like \'urn:xmpp:microblog:0\' |
|
|
|
and (Postn.from in (select RosterLink.jid from RosterLink where RosterLink.key = \''.$this->_user->getLogin().'\') |
|
|
|
or Postn.from = \''.$this->_user->getLogin().'\') |
|
|
|
order by Postn.published desc'; |
|
|
|
|
|
|
|
if($limitr) |
|
|
|
$sql = $sql.' limit '.$limitf.','.$limitr; |
|
|
|
|
|
|
|
return $this->mapper('ContactPostn', $this->_db->query($sql)); |
|
|
|
*/ |
|
|
|
|
|
|
|
$this->_sql = ' |
|
|
|
select *, postn.aid as jid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
@ -416,24 +219,6 @@ class PostnDAO extends ModlSQL { |
|
|
|
} |
|
|
|
|
|
|
|
function getNews($limitf = false, $limitr = false) { |
|
|
|
/*$sql = ' |
|
|
|
select *, Postn.aid as jid from Postn |
|
|
|
left outer join Contact on Postn.aid = Contact.jid |
|
|
|
left outer join Subscription on |
|
|
|
Postn.key = Subscription.jid and |
|
|
|
Postn.from = Subscription.server and |
|
|
|
Postn.node = Subscription.node |
|
|
|
where Postn.key = \''.$this->_user->getLogin().'\' |
|
|
|
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'; |
|
|
|
|
|
|
|
if($limitr) |
|
|
|
$sql = $sql.' limit '.$limitf.','.$limitr; |
|
|
|
|
|
|
|
return $this->mapper('ContactPostn', $this->_db->query($sql));*/ |
|
|
|
|
|
|
|
$this->_sql = ' |
|
|
|
select *, postn.aid as jid from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
@ -462,40 +247,6 @@ class PostnDAO extends ModlSQL { |
|
|
|
|
|
|
|
|
|
|
|
function getPublic($jid, $node) { |
|
|
|
/*if($node != false) |
|
|
|
$n = 'and Postn.node = \''.$node.'\' '; |
|
|
|
|
|
|
|
$sql = ' |
|
|
|
select *, Postn.aid as jid, Privacy.value as privacy from Postn |
|
|
|
left outer join Contact on Postn.aid = Contact.jid |
|
|
|
join Privacy on Postn.nodeid = Privacy.key |
|
|
|
where Postn.from = \''.$jid.'\' |
|
|
|
'.$n.' |
|
|
|
and Postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and Privacy.value = 1 |
|
|
|
group by nodeid |
|
|
|
order by Postn.published desc |
|
|
|
limit 0, 20'; |
|
|
|
|
|
|
|
return $this->mapper('ContactPostn', $this->_db->query($sql)); */ |
|
|
|
|
|
|
|
/*if($node != false) |
|
|
|
$n = 'and Postn.node = :node '; |
|
|
|
else |
|
|
|
$n = '';*/ |
|
|
|
|
|
|
|
/*$this->_sql = ' |
|
|
|
select *, postn.aid as jid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
|
join privacy on postn.nodeid = privacy.pkey |
|
|
|
where postn.jid = :jid |
|
|
|
and Postn.node = :node |
|
|
|
and postn.node not like \'urn:xmpp:microblog:0:comments/%\' |
|
|
|
and privacy.value = 1 |
|
|
|
group by nodeid |
|
|
|
order by postn.published desc';*/ |
|
|
|
//limit 0, 20';
|
|
|
|
|
|
|
|
$this->_sql = ' |
|
|
|
select *, postn.aid, privacy.value as privacy from postn |
|
|
|
left outer join contact on postn.aid = contact.jid |
|
|
@ -551,12 +302,6 @@ class PostnDAO extends ModlSQL { |
|
|
|
} |
|
|
|
|
|
|
|
function clearPost() { |
|
|
|
/*$sql = ' |
|
|
|
delete from Postn |
|
|
|
where Postn.key=\''.$this->_user->getLogin().'\''; |
|
|
|
|
|
|
|
return $this->_db->query($sql);*/ |
|
|
|
|
|
|
|
$this->_sql = ' |
|
|
|
delete from postn |
|
|
|
where session = :session'; |
|
|
|