From 7ccbb68335d5311b049a8873afc34245c1e67737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaussoin=20Timoth=C3=A9e?= Date: Mon, 22 Sep 2014 13:30:26 +0200 Subject: [PATCH] - Move the NsToXEP array - Add a new request to CapsDAO - Hide the submit form if the server doesn't support post publication --- app/models/caps/CapsDAO.php | 15 +++++++++++ app/widgets/Caps/Caps.php | 48 +-------------------------------- app/widgets/Feed/Feed.php | 25 +++++++++++------ system/Utils.php | 53 +++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 55 deletions(-) diff --git a/app/models/caps/CapsDAO.php b/app/models/caps/CapsDAO.php index 75ace5ded..37c6e9c5f 100644 --- a/app/models/caps/CapsDAO.php +++ b/app/models/caps/CapsDAO.php @@ -34,6 +34,21 @@ class CapsDAO extends SQL { return $this->run('Caps'); } + function getServers() { + $this->_sql = ' + select * from caps + where category = :category'; + + $this->prepare( + 'Caps', + array( + 'category' => 'server' + ) + ); + + return $this->run('Caps'); + } + function getAll() { $this->_sql = ' select * from caps'; diff --git a/app/widgets/Caps/Caps.php b/app/widgets/Caps/Caps.php index cc9ab541b..fcacb72ea 100644 --- a/app/widgets/Caps/Caps.php +++ b/app/widgets/Caps/Caps.php @@ -41,53 +41,7 @@ class Caps extends WidgetBase ksort($this->_table); - $this->_nslist = array( - '0012' => array('name' => 'Last Activity', 'category' => 'chat', 'ns' => 'jabber:iq:last'), - '0050' => array('name' => 'Ad-Hoc Commands', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/commands'), - '0080' => array('name' => 'User Location', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/geoloc'), - '0071' => array('name' => 'XHTML-IM', 'category' => 'chat', 'ns' => 'http://jabber.org/protocol/xhtml-im'), - '0084' => array('name' => 'User Avatar', 'category' => 'profile', 'ns' => 'urn:xmpp:avatar:data'), - '0085' => array('name' => 'Chat State Notifications', 'category' => 'chat', 'ns' => 'http://jabber.org/protocol/chatstates'), - '0092' => array('name' => 'Software Version', 'category' => 'client', 'ns' => 'jabber:iq:version'), - '0108' => array('name' => 'User Activity', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/activity'), - '0115' => array('name' => 'Entity Capabilities', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/caps'), - '0118' => array('name' => 'User Tune', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/tune'), - '0124' => array('name' => 'Bidirectional-streams Over Synchronous HTTP (BOSH)', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/httpbind'), - '0152' => array('name' => 'Reachability Addresses', 'category' => 'client', 'ns' => 'urn:xmpp:reach:0'), - '0166' => array('name' => 'Jingle', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:1'), - '0167' => array('name' => 'Jingle RTP Sessions', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:apps:rtp:1'), - '0176' => array('name' => 'Jingle ICE-UDP Transport Method', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:transports:ice-udp:1'), - '0177' => array('name' => 'Jingle Raw UDP Transport Method', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:transports:raw-udp:1'), - '0184' => array('name' => 'Message Delivery Receipts', 'category' => 'chat', 'ns' => 'urn:xmpp:receipts'), - '0186' => array('name' => 'Invisible Command', 'category' => 'chat', 'ns' => 'urn:xmpp:invisible:0'), - '0199' => array('name' => 'XMPP Ping', 'category' => 'client', 'ns' => 'urn:xmpp:ping'), - '0202' => array('name' => 'Entity Time', 'category' => 'client', 'ns' => 'urn:xmpp:time'), - '0224' => array('name' => 'Attention', 'category' => 'chat', 'ns' => 'urn:xmpp:attention:0'), - '0231' => array('name' => 'Bits of Binary', 'category' => 'chat', 'ns' => 'urn:xmpp:bob'), - '0234' => array('name' => 'Jingle File Transfer', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:apps:file-transfer:4'), - '0249' => array('name' => 'Direct MUC Invitations', 'category' => 'chat', 'ns' => 'jabber:x:conference'), - '0277' => array('name' => 'Microblogging over XMPP', 'category' => 'social', 'ns' => 'urn:xmpp:microblog:0'), - '0292' => array('name' => 'vCard4 Over XMPP', 'category' => 'profile', 'ns' => 'urn:xmpp:vcard4'), - '0301' => array('name' => 'In-Band Real Time Text', 'category' => 'chat', 'ns' => 'urn:xmpp:rtt:0'), - '0308' => array('name' => 'Last Message Correction', 'category' => 'chat', 'ns' => 'urn:xmpp:message-correct:0'), - '0313' => array('name' => 'Message Archive Management', 'category' => 'chat', 'ns' => 'urn:xmpp:mam:0'), - '0320' => array('name' => 'Use of DTLS-SRTP in Jingle Sessions', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:apps:dtls:0'), - '0323' => array('name' => 'Internet of Things - Sensor Data', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:sensordata'), - '0324' => array('name' => 'Internet of Things - Provisioning', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:provisioning'), - '0325' => array('name' => 'Internet of Things - Control', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:control'), - '0326' => array('name' => 'Internet of Things - Concentrators', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:concentrators'), - '0327' => array('name' => 'Rayo', 'category' => 'rayo', 'ns' => 'urn:xmpp:rayo:0'), - '0330' => array('name' => 'Pubsub Subscription', 'category' => 'social', 'ns' => 'urn:xmpp:pubsub:subscription'), - '0332' => array('name' => 'HTTP over XMPP transport', 'category' => 'client', 'ns' => 'urn:xmpp:http'), - '0337' => array('name' => 'Event Logging over XMPP', 'category' => 'client', 'ns' => 'urn:xmpp:eventlog'), - '0338' => array('name' => 'Jingle Grouping Framework', 'category' => 'jingle', 'ns' => 'urn:ietf:rfc:5888'), - '0339' => array('name' => 'Source-Specific Media Attributes in Jingle', 'category' => 'jingle', 'ns' => 'urn:ietf:rfc:5576'), - '0340' => array('name' => 'COnferences with LIghtweight BRIdging (COLIBRI)', 'category' => 'jingle', 'ns' => 'http://jitsi.org/protocol/colibri'), - '0341' => array('name' => 'Rayo CPA', 'category' => 'rayo', 'ns' => 'urn:xmpp:rayo:cpa:0'), - '0342' => array('name' => 'Rayo Fax', 'category' => 'rayo', 'ns' => 'urn:xmpp:rayo:fax:1'), - '0347' => array('name' => 'Internet of Things - Discovery', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:discovery'), - '0348' => array('name' => 'Signing Forms', 'category' => 'client', 'ns' => 'urn:xmpp:xdata:signature:oauth1'), - ); + $this->_nslist = getXepNamespace(); } function isImplemented($client, $key) { diff --git a/app/widgets/Feed/Feed.php b/app/widgets/Feed/Feed.php index c9f576be8..524f9bc47 100644 --- a/app/widgets/Feed/Feed.php +++ b/app/widgets/Feed/Feed.php @@ -70,14 +70,23 @@ class Feed extends WidgetCommon { } function prepareHead() { - $html = ' - - '.$this->prepareSubmitForm($this->user->getLogin(), 'urn:xmpp:microblog:0').' -
'; + $session = \Sessionx::start(); + + $cd = new Modl\CapsDAO; + $caps = $cd->get($session->host); + + if(isset($caps) && in_array('http://jabber.org/protocol/pubsub#config-node', unserialize($caps->features))) { + $html = ' + + '.$this->prepareSubmitForm($this->user->getLogin(), 'urn:xmpp:microblog:0').' +
'; + } else { + $html = ''; + } return $html; } diff --git a/system/Utils.php b/system/Utils.php index 6ebb46e05..f5a2c19c2 100644 --- a/system/Utils.php +++ b/system/Utils.php @@ -45,6 +45,59 @@ function getClientTypes() { ); } +/** + * Return a XEP to namespace association + */ +function getXepNamespace() { + return array( + '0012' => array('name' => 'Last Activity', 'category' => 'chat', 'ns' => 'jabber:iq:last'), + '0050' => array('name' => 'Ad-Hoc Commands', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/commands'), + '0080' => array('name' => 'User Location', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/geoloc'), + '0071' => array('name' => 'XHTML-IM', 'category' => 'chat', 'ns' => 'http://jabber.org/protocol/xhtml-im'), + '0084' => array('name' => 'User Avatar', 'category' => 'profile', 'ns' => 'urn:xmpp:avatar:data'), + '0085' => array('name' => 'Chat State Notifications', 'category' => 'chat', 'ns' => 'http://jabber.org/protocol/chatstates'), + '0092' => array('name' => 'Software Version', 'category' => 'client', 'ns' => 'jabber:iq:version'), + '0108' => array('name' => 'User Activity', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/activity'), + '0115' => array('name' => 'Entity Capabilities', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/caps'), + '0118' => array('name' => 'User Tune', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/tune'), + '0124' => array('name' => 'Bidirectional-streams Over Synchronous HTTP (BOSH)', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/httpbind'), + '0152' => array('name' => 'Reachability Addresses', 'category' => 'client', 'ns' => 'urn:xmpp:reach:0'), + '0166' => array('name' => 'Jingle', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:1'), + '0167' => array('name' => 'Jingle RTP Sessions', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:apps:rtp:1'), + '0176' => array('name' => 'Jingle ICE-UDP Transport Method', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:transports:ice-udp:1'), + '0177' => array('name' => 'Jingle Raw UDP Transport Method', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:transports:raw-udp:1'), + '0184' => array('name' => 'Message Delivery Receipts', 'category' => 'chat', 'ns' => 'urn:xmpp:receipts'), + '0186' => array('name' => 'Invisible Command', 'category' => 'chat', 'ns' => 'urn:xmpp:invisible:0'), + '0199' => array('name' => 'XMPP Ping', 'category' => 'client', 'ns' => 'urn:xmpp:ping'), + '0202' => array('name' => 'Entity Time', 'category' => 'client', 'ns' => 'urn:xmpp:time'), + '0224' => array('name' => 'Attention', 'category' => 'chat', 'ns' => 'urn:xmpp:attention:0'), + '0231' => array('name' => 'Bits of Binary', 'category' => 'chat', 'ns' => 'urn:xmpp:bob'), + '0234' => array('name' => 'Jingle File Transfer', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:apps:file-transfer:4'), + '0249' => array('name' => 'Direct MUC Invitations', 'category' => 'chat', 'ns' => 'jabber:x:conference'), + '0277' => array('name' => 'Microblogging over XMPP', 'category' => 'social', 'ns' => 'urn:xmpp:microblog:0'), + '0292' => array('name' => 'vCard4 Over XMPP', 'category' => 'profile', 'ns' => 'urn:xmpp:vcard4'), + '0301' => array('name' => 'In-Band Real Time Text', 'category' => 'chat', 'ns' => 'urn:xmpp:rtt:0'), + '0308' => array('name' => 'Last Message Correction', 'category' => 'chat', 'ns' => 'urn:xmpp:message-correct:0'), + '0313' => array('name' => 'Message Archive Management', 'category' => 'chat', 'ns' => 'urn:xmpp:mam:0'), + '0320' => array('name' => 'Use of DTLS-SRTP in Jingle Sessions', 'category' => 'jingle', 'ns' => 'urn:xmpp:jingle:apps:dtls:0'), + '0323' => array('name' => 'Internet of Things - Sensor Data', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:sensordata'), + '0324' => array('name' => 'Internet of Things - Provisioning', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:provisioning'), + '0325' => array('name' => 'Internet of Things - Control', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:control'), + '0326' => array('name' => 'Internet of Things - Concentrators', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:concentrators'), + '0327' => array('name' => 'Rayo', 'category' => 'rayo', 'ns' => 'urn:xmpp:rayo:0'), + '0330' => array('name' => 'Pubsub Subscription', 'category' => 'social', 'ns' => 'urn:xmpp:pubsub:subscription'), + '0332' => array('name' => 'HTTP over XMPP transport', 'category' => 'client', 'ns' => 'urn:xmpp:http'), + '0337' => array('name' => 'Event Logging over XMPP', 'category' => 'client', 'ns' => 'urn:xmpp:eventlog'), + '0338' => array('name' => 'Jingle Grouping Framework', 'category' => 'jingle', 'ns' => 'urn:ietf:rfc:5888'), + '0339' => array('name' => 'Source-Specific Media Attributes in Jingle', 'category' => 'jingle', 'ns' => 'urn:ietf:rfc:5576'), + '0340' => array('name' => 'COnferences with LIghtweight BRIdging (COLIBRI)', 'category' => 'jingle', 'ns' => 'http://jitsi.org/protocol/colibri'), + '0341' => array('name' => 'Rayo CPA', 'category' => 'rayo', 'ns' => 'urn:xmpp:rayo:cpa:0'), + '0342' => array('name' => 'Rayo Fax', 'category' => 'rayo', 'ns' => 'urn:xmpp:rayo:fax:1'), + '0347' => array('name' => 'Internet of Things - Discovery', 'category' => 'iot', 'ns' => 'urn:xmpp:iot:discovery'), + '0348' => array('name' => 'Signing Forms', 'category' => 'client', 'ns' => 'urn:xmpp:xdata:signature:oauth1'), + ); +} + /** * Return a list of all the country */