From c06392fa2a3fc72d69e1324454e943701807601a Mon Sep 17 00:00:00 2001 From: src386 Date: Thu, 25 Feb 2016 11:28:01 +0100 Subject: [PATCH] update to movim upstream --- CHANGELOG | 2 +- README.md | 2 +- sources/app/helpers/StringHelper.php | 11 ++ sources/app/models/cache/Cache.php | 6 +- sources/app/models/caps/Caps.php | 6 +- sources/app/models/conference/Conference.php | 4 +- sources/app/models/contact/Contact.php | 30 ++--- sources/app/models/item/Item.php | 10 +- sources/app/models/message/Message.php | 36 +++-- sources/app/models/message/MessageDAO.php | 9 +- sources/app/models/postn/Postn.php | 14 +- sources/app/models/presence/Presence.php | 6 +- sources/app/models/rosterlink/RosterLink.php | 16 +-- .../app/models/rosterlink/RosterLinkDAO.php | 8 -- sources/app/models/sessionx/Sessionx.php | 42 +++--- .../app/models/subscription/Subscription.php | 6 +- sources/app/views/chat.tpl | 1 + sources/app/widgets/Chat/Chat.php | 36 ++++- sources/app/widgets/Chat/_chat_smiley.tpl | 5 + sources/app/widgets/Chat/chat.js | 48 +++++-- sources/app/widgets/Login/Login.php | 2 +- sources/app/widgets/Login/login.js | 2 +- sources/app/widgets/Stickers/Stickers.php | 127 ++++++++++++++++++ sources/app/widgets/Stickers/_stickers.tpl | 17 +++ sources/app/widgets/Stickers/stickers.tpl | 0 ...86e8d52ed54b2bc9260cf5141b072fd8659ba1.png | Bin 0 -> 14635 bytes ...f19f655883f59b4bc126ef82edece5237b849b.png | Bin 0 -> 25896 bytes ...22a5939c07ab34d54a8d6917f6824be7892895.png | Bin 0 -> 17530 bytes ...6498f6904e966e5bf15bd09574062a1e023497.png | Bin 0 -> 27867 bytes ...ba40ff2eb35921aee0cdeac4b7629c34f5309a.png | Bin 0 -> 19665 bytes ...94acbc0c9a3bb73c7ba6b349560e284824ab70.png | Bin 0 -> 9103 bytes sources/bootstrap.php | 2 +- sources/linker.php | 6 +- sources/system/Picture.php | 31 +++-- sources/themes/material/css/listn.css | 20 ++- 35 files changed, 367 insertions(+), 138 deletions(-) create mode 100644 sources/app/widgets/Stickers/Stickers.php create mode 100644 sources/app/widgets/Stickers/_stickers.tpl create mode 100644 sources/app/widgets/Stickers/stickers.tpl create mode 100644 sources/app/widgets/Stickers/stickers/0886e8d52ed54b2bc9260cf5141b072fd8659ba1.png create mode 100644 sources/app/widgets/Stickers/stickers/71f19f655883f59b4bc126ef82edece5237b849b.png create mode 100644 sources/app/widgets/Stickers/stickers/a322a5939c07ab34d54a8d6917f6824be7892895.png create mode 100644 sources/app/widgets/Stickers/stickers/a86498f6904e966e5bf15bd09574062a1e023497.png create mode 100644 sources/app/widgets/Stickers/stickers/f9ba40ff2eb35921aee0cdeac4b7629c34f5309a.png create mode 100644 sources/app/widgets/Stickers/stickers/fa94acbc0c9a3bb73c7ba6b349560e284824ab70.png diff --git a/CHANGELOG b/CHANGELOG index e0ffd60..17b56e7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ **Changelog** 1.7 2016-? -- Update to movim 0.9 git2016-02-19 +- Update to movim 0.9 git2016-02-25 1.6.1 2016-02-12 - Update to movim 0.9 git2016-01-27 diff --git a/README.md b/README.md index 8627c28..4277bf6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Movim is a decentralized social network, written in PHP and HTML5 and based on t It is recommended to use a "valid" certificate to use Movim, auto-signed is sometimes problematic. You might want to take a look a StartSSL or Let's Encrypt. -Provided Movim version : 0.9 git2016-02-19 +Provided Movim version : 0.9 git2016-02-25 Please read CHANGELOG. diff --git a/sources/app/helpers/StringHelper.php b/sources/app/helpers/StringHelper.php index 2d1f240..cf3ff4c 100644 --- a/sources/app/helpers/StringHelper.php +++ b/sources/app/helpers/StringHelper.php @@ -223,6 +223,17 @@ function cleanJid($jid) return reset($explode); } +/* + * Extract the CID + */ +function getCid($string) +{ + preg_match("/(\w+)\@/", $string, $matches); + if(is_array($matches)) { + return $matches[1]; + } +} + /* * Explode JID */ diff --git a/sources/app/models/cache/Cache.php b/sources/app/models/cache/Cache.php index 7beb453..e98fb48 100644 --- a/sources/app/models/cache/Cache.php +++ b/sources/app/models/cache/Cache.php @@ -12,13 +12,13 @@ class Cache extends Model{ $this->_struct = ' { "session" : - {"type":"string", "size":64, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "name" : - {"type":"string", "size":32, "mandatory":true, "key":true }, + {"type":"string", "size":32, "key":true }, "data" : {"type":"text", "mandatory":true }, "timestamp" : - {"type":"date" } + {"type":"date", "mandatory":true } }'; parent::__construct(); diff --git a/sources/app/models/caps/Caps.php b/sources/app/models/caps/Caps.php index 5036a8d..b3dd6d8 100644 --- a/sources/app/models/caps/Caps.php +++ b/sources/app/models/caps/Caps.php @@ -13,11 +13,11 @@ class Caps extends Model { $this->_struct = ' { "node" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":128, "key":true }, "category" : - {"type":"string", "size":128, "mandatory":true }, + {"type":"string", "size":16, "mandatory":true }, "type" : - {"type":"string", "size":128, "mandatory":true }, + {"type":"string", "size":16, "mandatory":true }, "name" : {"type":"string", "size":128, "mandatory":true }, "features" : diff --git a/sources/app/models/conference/Conference.php b/sources/app/models/conference/Conference.php index 77d2d59..67e1eb4 100644 --- a/sources/app/models/conference/Conference.php +++ b/sources/app/models/conference/Conference.php @@ -16,9 +16,9 @@ class Conference extends Model { $this->_struct = ' { "jid" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":128, "key":true }, "conference" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":128, "key":true }, "name" : {"type":"string", "size":128, "mandatory":true }, "nick" : diff --git a/sources/app/models/contact/Contact.php b/sources/app/models/contact/Contact.php index 2af619b..1dcf48d 100644 --- a/sources/app/models/contact/Contact.php +++ b/sources/app/models/contact/Contact.php @@ -75,11 +75,11 @@ class Contact extends Model { $this->_struct = ' { "jid" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "fn" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "name" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "date" : {"type":"date", "size":11 }, "url" : @@ -89,21 +89,21 @@ class Contact extends Model { "adrlocality" : {"type":"string", "size":128 }, "adrpostalcode" : - {"type":"string", "size":128 }, + {"type":"string", "size":12 }, "adrcountry" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "gender" : {"type":"string", "size":1 }, "marital" : - {"type":"string", "size":20 }, + {"type":"string", "size":16 }, "description" : {"type":"text"}, "mood" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "activity" : {"type":"string", "size":128 }, "nickname" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "tuneartist" : {"type":"string", "size":128 }, "tunelenght" : @@ -117,25 +117,25 @@ class Contact extends Model { "tunetrack" : {"type":"string", "size":128 }, "loclatitude" : - {"type":"string", "size":128 }, + {"type":"string", "size":32 }, "loclongitude" : - {"type":"string", "size":128 }, + {"type":"string", "size":32 }, "localtitude" : {"type":"int", "size":11 }, "loccountry" : {"type":"string", "size":128 }, "loccountrycode" : - {"type":"string", "size":128 }, + {"type":"string", "size":2 }, "locregion" : {"type":"string", "size":128 }, "locpostalcode" : - {"type":"string", "size":128 }, + {"type":"string", "size":32 }, "loclocality" : {"type":"string", "size":128 }, "locstreet" : {"type":"string", "size":128 }, "locbuilding" : - {"type":"string", "size":128 }, + {"type":"string", "size":32 }, "loctext" : {"type":"text" }, "locuri" : @@ -151,9 +151,9 @@ class Contact extends Model { "avatarhash" : {"type":"string", "size":128 }, "created" : - {"type":"date" }, + {"type":"date", "mandatory":true }, "updated" : - {"type":"date" } + {"type":"date", "mandatory":true } }'; parent::__construct(); diff --git a/sources/app/models/item/Item.php b/sources/app/models/item/Item.php index dd7a379..938fc87 100644 --- a/sources/app/models/item/Item.php +++ b/sources/app/models/item/Item.php @@ -19,13 +19,13 @@ class Item extends Model { $this->_struct = ' { "server" : - {"type":"string", "size":64, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "jid" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "node" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":96, "key":true }, "creator" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "name" : {"type":"string", "size":128 }, "created" : @@ -33,7 +33,7 @@ class Item extends Model { "description" : {"type":"text" }, "updated" : - {"type":"date"} + {"type":"date", "mandatory":true} }'; parent::__construct(); diff --git a/sources/app/models/message/Message.php b/sources/app/models/message/Message.php index 29cae40..451493f 100644 --- a/sources/app/models/message/Message.php +++ b/sources/app/models/message/Message.php @@ -26,22 +26,24 @@ class Message extends Model { public $publishedPrepared; // Only for chat purpose public $edited; + public $sticker; // The sticker code + public function __construct() { $this->_struct = ' { "session" : - {"type":"string", "size":128, "mandatory":true }, + {"type":"string", "size":96, "mandatory":true }, "id" : - {"type":"string", "size":36}, + {"type":"string", "size":64}, "jidto" : - {"type":"string", "size":128, "mandatory":true }, + {"type":"string", "size":96, "mandatory":true }, "jidfrom" : - {"type":"string", "size":128, "mandatory":true }, + {"type":"string", "size":96, "mandatory":true }, "resource" : - {"type":"string", "size":128 }, + {"type":"string", "size":128, "mandatory":true }, "type" : - {"type":"string", "size":20 }, + {"type":"string", "size":16, "mandatory":true }, "subject" : {"type":"text"}, "thread" : @@ -51,11 +53,13 @@ class Message extends Model { "html" : {"type":"text"}, "published" : - {"type":"date"}, + {"type":"date", "mandatory":true}, "delivered" : {"type":"date"}, "edited" : - {"type":"int", "size":1} + {"type":"int", "size":1}, + "sticker" : + {"type":"string", "size":128 } }'; parent::__construct(); @@ -86,11 +90,23 @@ class Message extends Model { $this->type = (string)$stanza->attributes()->type; } - $this->__set('body', (string)$stanza->body); - $this->__set('subject', (string)$stanza->subject); + if($stanza->body) + $this->__set('body', (string)$stanza->body); + + if($stanza->subject) + $this->__set('subject', (string)$stanza->subject); $images = (bool)($this->type == 'chat'); + if($stanza->html) { + $xhtml = new \SimpleXMLElement(''.(string)$stanza->html->body.''); + $xhtml->registerXPathNamespace('xhtml', 'http://www.w3.org/1999/xhtml'); + $img = $xhtml->xpath('//xhtml:img/@src')[0]; + if($img) { + $this->sticker = getCid((string)$img); + } + } + /*if($stanza->html) { $this->html = \cleanHTMLTags($stanza->html->body->asXML()); $this->html = \fixSelfClosing($this->html); diff --git a/sources/app/models/message/MessageDAO.php b/sources/app/models/message/MessageDAO.php index e76b75f..276cdd7 100644 --- a/sources/app/models/message/MessageDAO.php +++ b/sources/app/models/message/MessageDAO.php @@ -50,7 +50,8 @@ class MessageDAO extends SQL { body, html, published, - delivered) + delivered, + sticker) values( :id, :session, @@ -63,7 +64,8 @@ class MessageDAO extends SQL { :body, :html, :published, - :delivered + :delivered, + :sticker )'; $this->prepare( @@ -80,7 +82,8 @@ class MessageDAO extends SQL { 'body' => $message->body, 'html' => $message->html, 'published' => $message->published, - 'delivered' => $message->delivered + 'delivered' => $message->delivered, + 'sticker' => $message->sticker ) ); } diff --git a/sources/app/models/postn/Postn.php b/sources/app/models/postn/Postn.php index 733e3a2..681cc9a 100644 --- a/sources/app/models/postn/Postn.php +++ b/sources/app/models/postn/Postn.php @@ -43,15 +43,15 @@ class Postn extends Model { $this->_struct = ' { "origin" : - {"type":"string", "size":64, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "node" : - {"type":"string", "size":96, "mandatory":true, "key":true }, + {"type":"string", "size":96, "key":true }, "nodeid" : - {"type":"string", "size":96, "mandatory":true, "key":true }, + {"type":"string", "size":96, "key":true }, "aname" : {"type":"string", "size":128 }, "aid" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "aemail" : {"type":"string", "size":64 }, "title" : @@ -73,16 +73,16 @@ class Postn extends Model { {"type":"date" }, "lat" : - {"type":"string", "size":128 }, + {"type":"string", "size":32 }, "lon" : - {"type":"string", "size":128 }, + {"type":"string", "size":32 }, "links" : {"type":"text" }, "picture" : {"type":"int", "size":4 }, "hash" : - {"type":"string", "size":128 } + {"type":"string", "size":128, "mandatory":true } }'; parent::__construct(); diff --git a/sources/app/models/presence/Presence.php b/sources/app/models/presence/Presence.php index 0f64f7a..62cd57f 100644 --- a/sources/app/models/presence/Presence.php +++ b/sources/app/models/presence/Presence.php @@ -38,11 +38,11 @@ class Presence extends Model { $this->_struct = ' { "id" : - {"type":"string", "size":128, "mandatory":true }, + {"type":"string", "size":64, "mandatory":true }, "session" : - {"type":"string", "size":64, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "jid" : - {"type":"string", "size":64, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "resource" : {"type":"string", "size":64, "key":true }, "value" : diff --git a/sources/app/models/rosterlink/RosterLink.php b/sources/app/models/rosterlink/RosterLink.php index 61595da..3bbb7e7 100644 --- a/sources/app/models/rosterlink/RosterLink.php +++ b/sources/app/models/rosterlink/RosterLink.php @@ -10,8 +10,6 @@ class RosterLink extends Model { public $rosterask; public $rostersubscription; - protected $realname; - protected $groupname; public $chaton; @@ -22,19 +20,17 @@ class RosterLink extends Model { $this->_struct = ' { "session" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "jid" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":96, "key":true }, "rostername" : - {"type":"string", "size":128 }, + {"type":"string", "size":96 }, "rosterask" : - {"type":"string", "size":128 }, + {"type":"string", "size":16 }, "rostersubscription" : - {"type":"string", "size":128 }, - "realname" : - {"type":"string", "size":128 }, + {"type":"string", "size":4, "mandatory":true }, "groupname" : - {"type":"string", "size":128 }, + {"type":"string", "size":64 }, "chaton" : {"type":"int", "size":11 } }'; diff --git a/sources/app/models/rosterlink/RosterLinkDAO.php b/sources/app/models/rosterlink/RosterLinkDAO.php index ef2f6d4..be08c9e 100644 --- a/sources/app/models/rosterlink/RosterLinkDAO.php +++ b/sources/app/models/rosterlink/RosterLinkDAO.php @@ -12,7 +12,6 @@ class RosterLinkDAO extends SQL { rostername, rosterask, rostersubscription, - realname, groupname, chaton) values ( @@ -21,7 +20,6 @@ class RosterLinkDAO extends SQL { :rostername, :rosterask, :rostersubscription, - :realname, :groupname, :chaton )'; @@ -34,7 +32,6 @@ class RosterLinkDAO extends SQL { 'rostername' => $r->rostername, 'rosterask' => $r->rosterask, 'rostersubscription' => $r->rostersubscription, - 'realname' => $r->realname, 'groupname' => $r->groupname, 'chaton' => $r->chaton ) @@ -52,7 +49,6 @@ class RosterLinkDAO extends SQL { rostername, rosterask, rostersubscription, - realname, groupname, chaton) values @@ -69,7 +65,6 @@ class RosterLinkDAO extends SQL { :rostername_$i, :rosterask_$i, :rostersubscription_$i, - :realname_$i, :groupname_$i, :chaton_$i ),"; @@ -82,7 +77,6 @@ class RosterLinkDAO extends SQL { "rostername_$i" => $r->rostername, "rosterask_$i" => $r->rosterask, "rostersubscription_$i" => $r->rostersubscription, - "realname_$i" => $r->realname, "groupname_$i" => $r->groupname, "chaton_$i" => $r->chaton ) @@ -107,7 +101,6 @@ class RosterLinkDAO extends SQL { set rostername = :rostername, rosterask = :rosterask, rostersubscription = :rostersubscription, - realname = :realname, groupname = :groupname, chaton = :chaton where session = :session @@ -121,7 +114,6 @@ class RosterLinkDAO extends SQL { 'rostername' => $r->rostername, 'rosterask' => $r->rosterask, 'rostersubscription' => $r->rostersubscription, - 'realname' => $r->realname, 'groupname' => $r->groupname, 'chaton' => $r->chaton ) diff --git a/sources/app/models/sessionx/Sessionx.php b/sources/app/models/sessionx/Sessionx.php index cc49de6..2c8c931 100644 --- a/sources/app/models/sessionx/Sessionx.php +++ b/sources/app/models/sessionx/Sessionx.php @@ -19,44 +19,44 @@ class Sessionx extends Model { public $start; public $timestamp; public $mechanism; - + public function __construct() { $this->_struct = ' { - "session" : - {"type":"string", "size":128, "mandatory":true, "key":true }, - "username" : + "session" : + {"type":"string", "size":32, "key":true }, + "username" : {"type":"string", "size":64 }, - "password" : + "password" : {"type":"string", "size":64 }, - "hash" : - {"type":"string", "size":128 }, - "resource" : + "hash" : {"type":"string", "size":64 }, - "rid" : + "resource" : + {"type":"string", "size":16 }, + "rid" : {"type":"int", "size":8, "mandatory":true }, - "sid" : + "sid" : {"type":"string", "size":64 }, - "id" : + "id" : {"type":"int", "size":8, "mandatory":true }, - "port" : + "port" : {"type":"int", "size":5, "mandatory":true }, - "host" : + "host" : {"type":"string", "size":64, "mandatory":true }, - "domain" : + "domain" : {"type":"string", "size":64, "mandatory":true }, - "config" : + "config" : {"type":"text" }, - "active" : + "active" : {"type":"int", "size":4 }, - "start" : + "start" : {"type":"date" }, - "timestamp" : + "timestamp" : {"type":"date" }, - "mechanism" : - {"type":"string", "size":64 } + "mechanism" : + {"type":"string", "size":16 } }'; - + parent::__construct(); } } diff --git a/sources/app/models/subscription/Subscription.php b/sources/app/models/subscription/Subscription.php index 6dd273f..b69009c 100644 --- a/sources/app/models/subscription/Subscription.php +++ b/sources/app/models/subscription/Subscription.php @@ -19,11 +19,11 @@ class Subscription extends Model { $this->_struct = ' { "jid" : - {"type":"string", "size":64, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "server" : - {"type":"string", "size":64, "mandatory":true, "key":true }, + {"type":"string", "size":64, "key":true }, "node" : - {"type":"string", "size":128, "mandatory":true, "key":true }, + {"type":"string", "size":128, "key":true }, "subscription" : {"type":"string", "size":128, "mandatory":true }, "subid" : diff --git a/sources/app/views/chat.tpl b/sources/app/views/chat.tpl index 518ce1c..9fc978c 100644 --- a/sources/app/views/chat.tpl +++ b/sources/app/views/chat.tpl @@ -1,3 +1,4 @@ +widget('Stickers');?>