diff --git a/app/models/cache/CacheDAO.php b/app/models/cache/CacheDAO.php index 99fef0907..5af1a1c3b 100644 --- a/app/models/cache/CacheDAO.php +++ b/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, diff --git a/app/models/contact/Contact.php b/app/models/contact/Contact.php index 5bb157cd7..70fdd9489 100644 --- a/app/models/contact/Contact.php +++ b/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); diff --git a/app/models/contact/ContactDAO.php b/app/models/contact/ContactDAO.php index 228ddb751..e188bac29 100644 --- a/app/models/contact/ContactDAO.php +++ b/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 ( diff --git a/app/models/item/Item.php b/app/models/item/Item.php index 712570e4c..91ef3c52d 100644 --- a/app/models/item/Item.php +++ b/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; diff --git a/app/models/message/MessageDAO.php b/app/models/message/MessageDAO.php index 82dadb2f1..9184a2ea7 100644 --- a/app/models/message/MessageDAO.php +++ b/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 diff --git a/app/models/postn/Postn.php b/app/models/postn/Postn.php index 874499f5b..1b2fbd866 100644 --- a/app/models/postn/Postn.php +++ b/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); diff --git a/app/models/presence/PresenceDAO.php b/app/models/presence/PresenceDAO.php index e915e5295..b2321fee9 100644 --- a/app/models/presence/PresenceDAO.php +++ b/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 diff --git a/app/models/sessionx/Sessionx.php b/app/models/sessionx/Sessionx.php index 64a22a49c..a7d623a70 100644 --- a/app/models/sessionx/Sessionx.php +++ b/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" : diff --git a/app/models/sessionx/SessionxDAO.php b/app/models/sessionx/SessionxDAO.php index b4e244b88..ab2a21d62 100644 --- a/app/models/sessionx/SessionxDAO.php +++ b/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'; diff --git a/app/models/subscription/SubscriptionDAO.php b/app/models/subscription/SubscriptionDAO.php index 82fa5b5a6..5a466bb9d 100644 --- a/app/models/subscription/SubscriptionDAO.php +++ b/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 diff --git a/app/widgets/Chat/Chat.php b/app/widgets/Chat/Chat.php index f76bee4cd..0bcd38f82 100644 --- a/app/widgets/Chat/Chat.php +++ b/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))); diff --git a/app/widgets/Post/_post_card.tpl b/app/widgets/Post/_post_card.tpl index b2de901be..92a824a78 100644 --- a/app/widgets/Post/_post_card.tpl +++ b/app/widgets/Post/_post_card.tpl @@ -12,7 +12,7 @@ {else} - + {/if} diff --git a/composer.lock b/composer.lock index ed1cb522e..464bd2fe5 100644 --- a/composer.lock +++ b/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", diff --git a/src/Movim/Cache.php b/src/Movim/Cache.php index d34152b77..0f42fdf3b 100644 --- a/src/Movim/Cache.php +++ b/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; diff --git a/system/Sessionx.php b/system/Sessionx.php index 60f6d930d..bf4692f40 100644 --- a/system/Sessionx.php +++ b/system/Sessionx.php @@ -1,5 +1,7 @@ _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();