Browse Source

Fix #318

pull/325/head
Jaussoin Timothée 9 years ago
parent
commit
f8deae9336
  1. 9
      app/models/cache/CacheDAO.php
  2. 2
      app/models/contact/Contact.php
  3. 78
      app/models/contact/ContactDAO.php
  4. 4
      app/models/item/Item.php
  5. 22
      app/models/message/MessageDAO.php
  6. 4
      app/models/postn/Postn.php
  7. 35
      app/models/presence/PresenceDAO.php
  8. 6
      app/models/sessionx/Sessionx.php
  9. 58
      app/models/sessionx/SessionxDAO.php
  10. 29
      app/models/subscription/SubscriptionDAO.php
  11. 2
      app/widgets/Chat/Chat.php
  12. 2
      app/widgets/Post/_post_card.tpl
  13. 8
      composer.lock
  14. 2
      src/Movim/Cache.php
  15. 4
      system/Sessionx.php

9
app/models/cache/CacheDAO.php

@ -2,8 +2,10 @@
namespace modl;
class CacheDAO extends SQL {
function get($key) {
class CacheDAO extends SQL
{
function get($key)
{
$this->_sql = '
select * from cache
where
@ -21,7 +23,8 @@ class CacheDAO extends SQL {
return $this->run('Cache', 'item');
}
function set(Cache $cache) {
function set(Cache $cache)
{
$this->_sql = '
update cache
set data = :data,

2
app/models/contact/Contact.php

@ -172,7 +172,7 @@ class Contact extends Model
&& $validate_date->validate($vcard->vCard->BDAY))
$this->__set('date', (string)$vcard->vCard->BDAY);
$this->__set('date', date(DATE_ISO8601, strtotime($this->date)));
$this->__set('date', date(SQL::SQL_DATE, strtotime($this->date)));
$this->__set('name', (string)$vcard->vCard->NICKNAME);
$this->__set('fn', (string)$vcard->vCard->FN);

78
app/models/contact/ContactDAO.php

@ -2,12 +2,15 @@
namespace modl;
class ContactDAO extends SQL {
function __construct() {
class ContactDAO extends SQL
{
function __construct()
{
parent::__construct();
}
function get($jid = null, $empty = false) {
function get($jid = null, $empty = false)
{
$this->_sql = '
select *, privacy.value as privacy from contact
left outer join privacy
@ -18,9 +21,9 @@ class ContactDAO extends SQL {
$this->prepare(
'Contact',
array(
[
'jid' => $jid
)
]
);
$contact = $this->run('Contact', 'item');
@ -35,9 +38,10 @@ class ContactDAO extends SQL {
return $contact;
}
function set(Contact $contact) {
function set(Contact $contact)
{
if(!isset($contact->created)) {
$contact->created = date(DATE_ISO8601);
$contact->created = date(SQL::SQL_DATE);
}
$this->_sql = '
@ -94,7 +98,7 @@ class ContactDAO extends SQL {
$this->prepare(
'Contact',
array(
[
'fn' => $contact->fn,
'name' => $contact->name,
'date' => $contact->date,
@ -150,10 +154,10 @@ class ContactDAO extends SQL {
'avatarhash' => $contact->avatarhash,
'created' => $contact->created,
'updated' => date(DATE_ISO8601),
'updated' => date(SQL::SQL_DATE),
'jid' => $contact->jid
)
]
);
$this->run('Contact');
@ -273,7 +277,7 @@ class ContactDAO extends SQL {
$this->prepare(
'Contact',
array(
[
'fn' => $contact->fn,
'name' => $contact->name,
'date' => $contact->date,
@ -328,18 +332,19 @@ class ContactDAO extends SQL {
'avatarhash' => $contact->avatarhash,
'created' => date(DATE_ISO8601),
'updated' => date(DATE_ISO8601),
'created' => date(SQL::SQL_DATE),
'updated' => date(SQL::SQL_DATE),
'jid' => $contact->jid
)
]
);
$this->run('Contact');
}
}
function getAll() {
function getAll()
{
$this->_sql =
'select *, privacy.value as privacy from contact
left outer join privacy
@ -349,7 +354,8 @@ class ContactDAO extends SQL {
return $this->run('Contact');
}
function searchJid($search) {
function searchJid($search)
{
$this->_sql =
'select *, privacy.value as privacy from contact
left outer join privacy
@ -367,7 +373,8 @@ class ContactDAO extends SQL {
return $this->run('Contact');
}
function getAllPublic($limitf = false, $limitr = false) {
function getAllPublic($limitf = false, $limitr = false)
{
$this->_sql =
'select contact.*, presence.*, privacy.value as privacy from contact
left outer join privacy
@ -398,7 +405,8 @@ class ContactDAO extends SQL {
return $this->run('RosterContact');
}
function countAllPublic() {
function countAllPublic()
{
$this->_sql =
'select count(*) from contact
left outer join privacy
@ -459,7 +467,8 @@ class ContactDAO extends SQL {
}
// Get the roster without the presences
function getRosterSimple() {
function getRosterSimple()
{
$this->_sql = '
select
rosterlink.jid,
@ -524,17 +533,18 @@ class ContactDAO extends SQL {
$this->prepare(
'RosterLink',
array(
[
'session' => $this->_user,
'jid' => '%'.$key.'%',
'rostername' => '%'.$key.'%'
)
]
);
return $this->run('RosterContact');
}
function getRosterFrom() {
function getRosterFrom()
{
$this->_sql = '
select * from rosterlink
left outer join contact
@ -544,16 +554,17 @@ class ContactDAO extends SQL {
$this->prepare(
'RosterLink',
array(
[
'session' => $this->_user,
'rostersubscription' => 'from'
)
]
);
return $this->run('RosterContact');
}
function getRosterItem($jid, $item = false) {
function getRosterItem($jid, $item = false)
{
$this->_sql = '
select
rosterlink.jid,
@ -595,7 +606,8 @@ class ContactDAO extends SQL {
return $this->run('RosterContact', 'item');
}
function getPresence($jid, $resource) {
function getPresence($jid, $resource)
{
$this->_sql = '
select * from contact
right outer join presence on contact.jid = presence.mucjid
@ -606,17 +618,18 @@ class ContactDAO extends SQL {
$this->prepare(
'Presence',
array(
[
'session' => $this->_user,
'jid' => $jid,
'resource' => $resource
)
]
);
return $this->run('PresenceContact', 'item');
}
function getPresences($jid) {
function getPresences($jid)
{
$this->_sql = '
select * from contact
right outer join presence on contact.jid = presence.mucjid
@ -626,16 +639,17 @@ class ContactDAO extends SQL {
$this->prepare(
'Presence',
array(
[
'session' => $this->_user,
'jid' => $jid
)
]
);
return $this->run('PresenceContact');
}
function getTop($limit = 6, $filter = false) {
function getTop($limit = 6, $filter = false)
{
$filter = ($filter != false) ? implode('\',\'', $filter) : '';
$this->_sql = '
select *, jidfrom from (

4
app/models/item/Item.php

@ -54,7 +54,7 @@ class Item extends Model
if($this->jid == null)
$this->jid = $this->node;
$this->name = (string)$item->attributes()->name;
$this->updated = date('Y-m-d H:i:s');
$this->updated = date(SQL::SQL_DATE);
}
public function setMetadata($metadata, $from, $node)
@ -74,7 +74,7 @@ class Item extends Model
$this->creator = (string)$i->value;
break;
case 'pubsub#creation_date':
$this->created = (string)$i->value;
$this->created = date(SQL::SQL_DATE, strtotime((string)$i->value));
break;
case 'pubsub#description':
$this->description = (string)$i->value;

22
app/models/message/MessageDAO.php

@ -2,8 +2,10 @@
namespace modl;
class MessageDAO extends SQL {
function set(Message $message) {
class MessageDAO extends SQL
{
function set(Message $message)
{
$this->_sql = '
update message
set id = :thread,
@ -222,17 +224,18 @@ class MessageDAO extends SQL {
$this->prepare(
'Message',
array(
[
'jidfrom' => $jid,
'jidto' => $jid,
'session' => $this->_user
)
]
);
return $this->run('Message');
}
function getHistory($jid, $date, $limit = 30) {
function getHistory($jid, $date, $limit = 30)
{
$this->_sql = '
select * from message
where session = :session
@ -245,18 +248,19 @@ class MessageDAO extends SQL {
$this->prepare(
'Message',
array(
[
'session' => $this->_user,
'jidfrom' => $jid,
'jidto' => $jid,
'published' => $date
)
'published' => date(SQL::SQL_DATE, strtotime($date))
]
);
return $this->run('Message');
}
function getRoomSubject($room) {
function getRoomSubject($room)
{
$this->_sql = '
select * from message
where jidfrom = :jidfrom

4
app/models/postn/Postn.php

@ -213,14 +213,14 @@ class Postn extends Model
if($entry->entry->updated)
$this->__set('updated', (string)$entry->entry->updated);
else
$this->__set('updated', gmdate(DATE_ISO8601));
$this->__set('updated', gmdate(SQL::SQL_DATE));
if($entry->entry->published)
$this->__set('published', (string)$entry->entry->published);
elseif($entry->entry->updated)
$this->__set('published', (string)$entry->entry->updated);
else
$this->__set('published', gmdate(DATE_ISO8601));
$this->__set('published', gmdate(SQL::SQL_DATE));
if($delay)
$this->__set('delay', $delay);

35
app/models/presence/PresenceDAO.php

@ -2,12 +2,15 @@
namespace Modl;
class PresenceDAO extends SQL {
function __construct() {
class PresenceDAO extends SQL
{
function __construct()
{
parent::__construct();
}
function set(Presence $presence) {
function set(Presence $presence)
{
$id = sha1(
$presence->session.
$presence->jid.
@ -33,7 +36,7 @@ class PresenceDAO extends SQL {
$this->prepare(
'Presence',
array(
[
'value' => $presence->value,
'priority' => $presence->priority,
'status' => $presence->status,
@ -47,8 +50,8 @@ class PresenceDAO extends SQL {
'mucaffiliation' => $presence->mucaffiliation,
'mucrole' => $presence->mucrole,
'id' => $id,
'updated' => gmdate(DATE_ISO8601)
)
'updated' => gmdate(SQL::SQL_DATE)
]
);
$this->run('Presence');
@ -96,7 +99,7 @@ class PresenceDAO extends SQL {
$this->prepare(
'Presence',
array(
[
'id' => $id,
'session' => $presence->session,
'jid' => $presence->jid,
@ -113,9 +116,9 @@ class PresenceDAO extends SQL {
'mucjid' => $presence->mucjid,
'mucaffiliation' => $presence->mucaffiliation,
'mucrole' => $presence->mucrole,
'created' => gmdate(DATE_ISO8601),
'updated' => gmdate(DATE_ISO8601)
)
'created' => gmdate(SQL::SQL_DATE),
'updated' => gmdate(SQL::SQL_DATE)
]
);
$this->run('Presence');
@ -175,7 +178,8 @@ class PresenceDAO extends SQL {
return $this->run('Presence', 'item');
}
function getMyPresenceRoom($jid) {
function getMyPresenceRoom($jid)
{
$this->_sql = '
select * from presence
where
@ -194,7 +198,8 @@ class PresenceDAO extends SQL {
return $this->run('Presence', 'item');
}
function getJid($jid) {
function getJid($jid)
{
$this->_sql = '
select * from presence
where
@ -213,7 +218,8 @@ class PresenceDAO extends SQL {
return $this->run('Presence');
}
function clearPresence() {
function clearPresence()
{
$this->_sql = '
delete from presence
where
@ -243,7 +249,8 @@ class PresenceDAO extends SQL {
return $this->run('Presence');
}
function clearMuc($muc) {
function clearMuc($muc)
{
$this->_sql = '
delete from presence
where

6
app/models/sessionx/Sessionx.php

@ -2,7 +2,8 @@
namespace modl;
class Sessionx extends Model {
class Sessionx extends Model
{
public $session;
public $username;
public $hash;
@ -13,7 +14,8 @@ class Sessionx extends Model {
public $start;
public $timestamp;
public function __construct() {
public function __construct()
{
$this->_struct = '
{
"session" :

58
app/models/sessionx/SessionxDAO.php

@ -2,8 +2,10 @@
namespace modl;
class SessionxDAO extends SQL {
function init(Sessionx $s) {
class SessionxDAO extends SQL
{
function init(Sessionx $s)
{
$this->_sql = '
update sessionx
set username = :username,
@ -19,7 +21,7 @@ class SessionxDAO extends SQL {
$this->prepare(
'Sessionx',
array(
[
'session' => $s->session,
'username' => $s->username,
'jid' => $s->username.'@'.$s->host,
@ -30,7 +32,7 @@ class SessionxDAO extends SQL {
'active' => $s->active,
'start' => $s->start,
'timestamp' => $s->timestamp
)
]
);
$this->run('Sessionx');
@ -62,7 +64,7 @@ class SessionxDAO extends SQL {
$this->prepare(
'Sessionx',
array(
[
'session' => $s->session,
'username' => $s->username,
'jid' => $s->username.'@'.$s->host,
@ -73,14 +75,15 @@ class SessionxDAO extends SQL {
'active' => $s->active,
'start' => $s->start,
'timestamp' => $s->timestamp
)
]
);
$this->run('Sessionx');
}
}
function update($session, $key, $value) {
function update($session, $key, $value)
{
$this->_sql = '
update sessionx
set
@ -91,17 +94,18 @@ class SessionxDAO extends SQL {
$this->prepare(
'Sessionx',
array(
[
'session' => $session,
$key => $value,
'timestamp' => date(DATE_ISO8601)
)
'timestamp' => date(SQL::SQL_DATE)
]
);
$this->run('Sessionx');
}
function get($session) {
function get($session)
{
$this->_sql = '
select * from sessionx
where
@ -109,15 +113,16 @@ class SessionxDAO extends SQL {
$this->prepare(
'Sessionx',
array(
[
'session' => $session
)
]
);
return $this->run('Sessionx', 'item');
}
function getHash($hash) {
function getHash($hash)
{
$this->_sql = '
select * from sessionx
where
@ -125,15 +130,16 @@ class SessionxDAO extends SQL {
$this->prepare(
'Sessionx',
array(
[
'hash' => $hash
)
]
);
return $this->run('Sessionx', 'item');
}
function delete($session) {
function delete($session)
{
$this->_sql = '
delete from sessionx
where
@ -141,15 +147,16 @@ class SessionxDAO extends SQL {
$this->prepare(
'Sessionx',
array(
[
'session' => $session
)
]
);
return $this->run('Sessionx');
}
function deleteEmpty() {
function deleteEmpty()
{
$this->_sql = '
delete from sessionx
where active = 0
@ -157,26 +164,27 @@ class SessionxDAO extends SQL {
$this->prepare(
'Sessionx',
['timestamp' => date(DATE_ISO8601, time()-60)]
['timestamp' => date(SQL::SQL_DATE, time()-60)]
);
return $this->run('Sessionx');
}
function clear() {
function clear()
{
$this->_sql = '
truncate table sessionx';
$this->prepare(
'Sessionx',
array(
)
[]
);
$this->run('Sessionx');
}
function getAll() {
function getAll()
{
$this->_sql = '
select * from sessionx order by start desc';

29
app/models/subscription/SubscriptionDAO.php

@ -2,8 +2,10 @@
namespace modl;
class SubscriptionDAO extends SQL {
function set(Subscription $s) {
class SubscriptionDAO extends SQL
{
function set(Subscription $s)
{
$this->_sql = '
update subscription
set subscription = :subscription,
@ -18,7 +20,7 @@ class SubscriptionDAO extends SQL {
'Subscription',
[
'subscription' => $s->subscription,
'timestamp' => date(DATE_ISO8601),
'timestamp' => date(SQL::SQL_DATE),
'jid' => $s->jid,
'server'=> $s->server,
'node' => $s->node,
@ -37,22 +39,23 @@ class SubscriptionDAO extends SQL {
$this->prepare(
'Subscription',
array(
[
'subscription' => $s->subscription,
'timestamp' => date(DATE_ISO8601),
'timestamp' => date(SQL::SQL_DATE),
'jid' => $s->jid,
'server'=> $s->server,
'node' => $s->node,
'tags' => $s->tags,
'subid' => $s->subid
)
]
);
$this->run('Subscription');
}
}
function get($server, $node) {
function get($server, $node)
{
$this->_sql = '
select * from subscription
where jid = :jid
@ -71,7 +74,8 @@ class SubscriptionDAO extends SQL {
return $this->run('Subscription');
}
function getSubscribed() {
function getSubscribed()
{
$this->_sql = '
select
subscription.jid,
@ -111,7 +115,8 @@ class SubscriptionDAO extends SQL {
return $this->run('Subscription');
}
function delete() {
function delete()
{
$this->_sql = '
delete from subscription
where jid = :jid';
@ -126,7 +131,8 @@ class SubscriptionDAO extends SQL {
return $this->run('Subscription');
}
function deleteNode($server, $node) {
function deleteNode($server, $node)
{
$this->_sql = '
delete from subscription
where jid = :jid
@ -145,7 +151,8 @@ class SubscriptionDAO extends SQL {
return $this->run('Subscription');
}
function deleteNodeSubid($server, $node, $subid) {
function deleteNodeSubid($server, $node, $subid)
{
$this->_sql = '
delete from subscription
where jid = :jid

2
app/widgets/Chat/Chat.php

@ -403,7 +403,7 @@ class Chat extends \Movim\Widget\Base
{
if(!$this->validateJid($jid)) return;
$md = new \Modl\MessageDAO;
$messages = $md->getHistory(echapJid($jid), date(DATE_ISO8601, strtotime($date)), $this->_pagination);
$messages = $md->getHistory(echapJid($jid), $date, $this->_pagination);
if(count($messages) > 0) {
Notification::append(false, $this->__('message.history', count($messages)));

2
app/widgets/Post/_post_card.tpl

@ -12,7 +12,7 @@
<img src="{$url}"/>
</span>
{else}
<span class="primary icon thumb color {$post->getContact()->jid|stringToColor}">
<span class="primary icon bubble color {$post->getContact()->jid|stringToColor}">
<i class="zmdi zmdi-account"></i>
</span>
{/if}

8
composer.lock

@ -601,12 +601,12 @@
"source": {
"type": "git",
"url": "https://github.com/movim/modl.git",
"reference": "4f6a80928d9a272e903cb58fd3395fc55e414c2d"
"reference": "442fabc5900520dc872bed8b0839decd88afae29"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/movim/modl/zipball/4f6a80928d9a272e903cb58fd3395fc55e414c2d",
"reference": "4f6a80928d9a272e903cb58fd3395fc55e414c2d",
"url": "https://api.github.com/repos/movim/modl/zipball/442fabc5900520dc872bed8b0839decd88afae29",
"reference": "442fabc5900520dc872bed8b0839decd88afae29",
"shasum": ""
},
"require": {
@ -637,7 +637,7 @@
"database",
"sql"
],
"time": "2016-11-26 21:26:45"
"time": "2016-12-10 16:15:57"
},
{
"name": "movim/moxl",

2
src/Movim/Cache.php

@ -73,7 +73,7 @@ class Cache
private function writeCache($key, $object)
{
$data = str_replace("'", "\\'", base64_encode(gzcompress(serialize($object))));
$time = date(DATE_ISO8601, time());
$time = date(\Modl\SQL::SQL_DATE);
$cd = new \Modl\CacheDAO;
$c = new \Modl\Cache;

4
system/Sessionx.php

@ -1,5 +1,7 @@
<?php
use Modl\SQL;
class Sessionx
{
protected static $_sessionid = null;
@ -73,7 +75,7 @@ class Sessionx
$this->_user = $user;
$this->_password = $pass;
$this->_resource = 'moxl'.\generateKey(6);
$this->_start = date(DATE_ISO8601);
$this->_start = date(SQL::SQL_DATE);
$sd = new \Modl\SessionxDAO;
$s = $this->inject();

Loading…
Cancel
Save