Browse Source

- Merge with edhelas

pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
b84e5e54cc
  1. 24
      app/models/postn/Postn.php
  2. 140
      app/models/postn/PostnDAO.php
  3. 25
      app/widgets/Blog/Blog.php
  4. 15
      app/widgets/Menu/Menu.php
  5. 6
      app/widgets/Menu/_menu_list.tpl
  6. 14
      app/widgets/Menu/menu.js
  7. 1
      app/widgets/Roster/roster.tpl
  8. 2
      mud.php
  9. 5
      themes/material/css/list.css

24
app/models/postn/Postn.php

@ -3,9 +3,7 @@
namespace Modl;
class Postn extends Model {
public $session;
public $jid; // Where the post is comming from (jid or server)
public $origin; // Where the post is comming from (jid or server)
public $node; // microblog or pubsub
public $nodeid; // the ID if the item
@ -34,15 +32,13 @@ class Postn extends Model {
public $privacy;
public $hash;
public function __construct() {
$this->hash = md5(openssl_random_pseudo_bytes(5));
$this->_struct = '
{
"session" :
{"type":"string", "size":64, "mandatory":true, "key":true },
"jid" :
"origin" :
{"type":"string", "size":64, "mandatory":true, "key":true },
"node" :
{"type":"string", "size":96, "mandatory":true, "key":true },
@ -89,15 +85,12 @@ class Postn extends Model {
}
public function set($item, $from, $delay = false, $node = false) {
$user = new \User();
$this->session = $user->getLogin();
if($item->item)
$entry = $item->item;
else
$entry = $item;
$this->jid = $from;
$this->origin = $from;
if($node)
$this->node = $node;
@ -186,7 +179,7 @@ class Postn extends Model {
$content .= '<br />'.$contentimg;
if(!isset($this->commentplace))
$this->commentplace = $this->jid;
$this->commentplace = $this->origin;
$this->content = trim($content);
$this->contentcleaned = prepareString(html_entity_decode($this->content));
@ -214,7 +207,8 @@ class Postn extends Model {
$enc = $enc['@attributes'];
array_push($l, $enc);
if($this->typeIsPicture($enc['type'])) {
if(array_key_exists('type', $enc)
&& $this->typeIsPicture($enc['type'])) {
$this->picture = true;
}
@ -270,7 +264,9 @@ class Postn extends Model {
}
public function isMine() {
if($this->jid == $this->session)
$user = new \User();
if($this->origin == $user->getLogin())
return true;
else
return false;

140
app/models/postn/PostnDAO.php

@ -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
)
);

25
app/widgets/Blog/Blog.php

@ -17,46 +17,21 @@ class Blog extends WidgetCommon {
$node = 'urn:xmpp:microblog:0';
} else {
return;
//$node = $_GET['n'];
}
/*$this->view->assign('from', $from);
if(isset($node))
$this->view->assign('node', $node);*/
$pd = new \modl\PostnDAO();
//if(isset($from) && isset($node))
$messages = $pd->getPublic($from, $node);
if($messages[0] != null) {
// Title and logo
// For a Pubsub feed
/*if(isset($from) && isset($node) && $node != 'urn:xmpp:microblog:0') {
$pd = new \modl\NodeDAO();
$n = $pd->getNode($from, $node);
if(isset($n->title))
$this->view->assign('title', $n->title);
elseif(isset($n->nodeid))
$this->view->assign('title', $n->nodeid);
// For a simple contact
} else {
$this->view->assign('title', $this->__('blog.title',$messages[0]->getContact()->getTrueName()));
$this->view->assign('logo', $messages[0]->getContact()->getPhoto('l'));
}*/
$cd = new \modl\ContactDAO();
$c = $cd->get($from);
$this->view->assign('contact', $c);
//$this->view->assign('date', date('c'));
//$this->view->assign('name', $messages[0]->getContact()->getTrueName());
//$this->view->assign('feed', Route::urlize('feed',array($from, $node)));
} else {
$this->view->assign('title', $this->__('page.feed'));
}
$this->view->assign('posts', $messages);
//$this->view->assign('posts', $this->preparePosts($messages, true));
}
}

15
app/widgets/Menu/Menu.php

@ -103,14 +103,11 @@ class Menu extends WidgetCommon
}
function prepareList($type = 'all', $server = null, $node = null, $page = 0) {
//movim_log(__METHOD__);
$view = $this->tpl();
$pd = new \Modl\PostnDAO;
$count = $pd->getCountSince(Cache::c('since'));
// getting newer, not older
//movim_log($page);
//movim_log($page == "");
if($page == 0 || $page == ""){
$count = 0;
Cache::c('since', date(DATE_ISO8601, strtotime($pd->getLastDate())));
@ -122,30 +119,18 @@ class Menu extends WidgetCommon
case 'all' :
$view->assign('history', $this->call('ajaxGetAll', $next));
$items = $pd->getAllPosts(false, $page * $this->_paging + $count, $this->_paging);
/*movim_log(__LINE__);
movim_log(" ALL ");
movim_log($page * $this->_paging + $count);*/
break;
case 'news' :
$view->assign('history', $this->call('ajaxGetNews', $next));
$items = $pd->getNews($page * $this->_paging + $count, $this->_paging);
/*movim_log(__LINE__);
movim_log(" NEWS ");
movim_log($page * $this->_paging + $count);*/
break;
case 'feed' :
$view->assign('history', $this->call('ajaxGetFeed', $next));
$items = $pd->getFeed($page * $this->_paging + $count, $this->_paging);
/*movim_log(__LINE__);
movim_log(" FEED ");
movim_log($page * $this->_paging + $count);*/
break;
case 'node' :
$view->assign('history', $this->call('ajaxGetNode', '"'.$server.'"', '"'.$node.'"', $next));
$items = $pd->getNode($server, $node, $page * $this->_paging + $count, $this->_paging);
/*movim_log(__LINE__);
movim_log(" NODE ");
movim_log($page * $this->_paging + $count);*/
break;
}

6
app/widgets/Menu/_menu_list.tpl

@ -12,7 +12,7 @@
title="{$c->__('menu.contact_post')}"
{/if}
>
{if="current(explode('.', $value->jid)) == 'nsfw'"}
{if="current(explode('.', $value->origin)) == 'nsfw'"}
<span class="icon bubble color red">
<i class="md md-warning"></i>
</span>
@ -40,10 +40,12 @@
{/if}
</li>
{/loop}
<li onclick="{$history} this.parentNode.removeChild(this);">
{if="count($items) == 15"}
<li id="history" onclick="{$history} this.parentNode.removeChild(this);">
<span class="icon"><i class="md md-history"></i></span>
{$c->__('post.older')}
</li>
{/if}
{if="$page == 0"}
</ul>

14
app/widgets/Menu/menu.js

@ -3,13 +3,15 @@ var Menu = {
var items = document.querySelectorAll('#menu_widget ul li');
var i = 0;
while(i < items.length -1)
while(i < items.length)
{
items[i].onclick = function(e) {
MovimTpl.showPanel();
Post_ajaxGetPost(this.dataset.id);
Menu.reset(items);
movim_add_class(this, 'active');
if(items[i].id != 'history') {
items[i].onclick = function(e) {
MovimTpl.showPanel();
Post_ajaxGetPost(this.dataset.id);
Menu.reset(items);
movim_add_class(this, 'active');
}
}
i++;
}

1
app/widgets/Roster/roster.tpl

@ -17,6 +17,7 @@
ng-class="{groupshown: rosterCtrl.groupIsShown(group.agroup)}" >
<li class="subheader" ng-click="rosterCtrl.showHideGroup(group.agroup)">
{{::group.agroup}}
<span class="info">{{group.agroupitems.length}}</span>
</li>
<li
ng-repeat="myjid in group.agroupitems"

2
mud.php

@ -40,8 +40,8 @@ Here some requests you can do with me :", 'green')."
if($infos == null) {
echo colorize("Nothing to do\n", 'green');
} else {
echo colorize("The database need to be updated\n", 'green');
foreach($infos as $i) {
echo colorize("The database need to be updated\n", 'green');
echo colorize($i."\n", 'blue');
}
}

5
themes/material/css/list.css

@ -211,9 +211,14 @@ ul.tabs {
text-align: center;
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
overflow: hidden;
white-space: nowrap;
height: 6rem;
}
ul.tabs:hover {
overflow-x: auto;
}
ul.tabs li {
display: inline-block;
white-space: nowrap;

Loading…
Cancel
Save