diff --git a/CHANGELOG b/CHANGELOG index d5b2f62..4ac5b68 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ **Changelog** +1.7.1 2016-? +- Update to movim 0.9 git2016-03-29 + 1.7 2016-03-17 - Update to movim 0.9 git2016-03-17 - sources/upgrade : dont delete composer.lock diff --git a/README.md b/README.md index 7d3436e..71e6d27 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-03-17 +Provided Movim version : 0.9 git2016-03-29 Please read CHANGELOG. diff --git a/sources/CHANGELOG.md b/sources/CHANGELOG.md index 5070b11..21cd034 100644 --- a/sources/CHANGELOG.md +++ b/sources/CHANGELOG.md @@ -13,7 +13,12 @@ v0.9.1 (trunk) * Clean properly the tags in the database * Allow tags with special characters * Various UI and navigation fixed + * Use UUID as identifiers for the messages and posts + * Delete properly the comments when deleting a post * Update the dependencies + * Create an internal API to save some memory and improve session handling + * Improve image handling in posts + * Improve overall performances v0.9 --------------------------- diff --git a/sources/app/assets/js/movim_tpl.js b/sources/app/assets/js/movim_tpl.js index ef5f46f..2d6ddd6 100644 --- a/sources/app/assets/js/movim_tpl.js +++ b/sources/app/assets/js/movim_tpl.js @@ -109,7 +109,7 @@ var MovimTpl = { var selector = document.querySelector('main section > div:first-child:nth-last-child(2) ~ div div'); if(selector != null) { - return (selector.scrollHeight - Math.floor(selector.scrollTop) === selector.clientHeight); + return (selector.scrollHeight - Math.floor(selector.scrollTop) <= selector.clientHeight + 3); } }, scrollPanel : function() { diff --git a/sources/app/controllers/AboutController.php b/sources/app/controllers/AboutController.php index 59e1e99..e80d928 100644 --- a/sources/app/controllers/AboutController.php +++ b/sources/app/controllers/AboutController.php @@ -1,6 +1,7 @@ session_only = false; } diff --git a/sources/app/controllers/AccountController.php b/sources/app/controllers/AccountController.php index 541ae3a..409a8f8 100644 --- a/sources/app/controllers/AccountController.php +++ b/sources/app/controllers/AccountController.php @@ -1,6 +1,7 @@ session_only = false; } diff --git a/sources/app/controllers/AccountnextController.php b/sources/app/controllers/AccountnextController.php index 3689084..f4c7174 100644 --- a/sources/app/controllers/AccountnextController.php +++ b/sources/app/controllers/AccountnextController.php @@ -1,6 +1,7 @@ session_only = false; } diff --git a/sources/app/controllers/AdminController.php b/sources/app/controllers/AdminController.php index 84cd9ce..3dd1bf5 100644 --- a/sources/app/controllers/AdminController.php +++ b/sources/app/controllers/AdminController.php @@ -1,6 +1,7 @@ session_only = false; } diff --git a/sources/app/controllers/AdminloginController.php b/sources/app/controllers/AdminloginController.php index 68bd601..4008bbf 100644 --- a/sources/app/controllers/AdminloginController.php +++ b/sources/app/controllers/AdminloginController.php @@ -1,6 +1,7 @@ page->setTitle(__('title.administration', APP_TITLE)); - + $cd = new \Modl\ConfigDAO(); $config = $cd->get(); - - if($config->username == $_POST['username'] + + if($config->username == $_POST['username'] && $config->password == sha1($_POST['password'])) { $_SESSION['admin'] = true; $this->name = 'admin'; diff --git a/sources/app/controllers/BlogController.php b/sources/app/controllers/BlogController.php index f009826..1edccbb 100644 --- a/sources/app/controllers/BlogController.php +++ b/sources/app/controllers/BlogController.php @@ -1,6 +1,8 @@ session_only = false; $this->public = true; diff --git a/sources/app/controllers/ChatController.php b/sources/app/controllers/ChatController.php index 0c5f706..98aade3 100644 --- a/sources/app/controllers/ChatController.php +++ b/sources/app/controllers/ChatController.php @@ -1,6 +1,8 @@ session_only = true; } diff --git a/sources/app/controllers/ConfController.php b/sources/app/controllers/ConfController.php index 19ddcd7..83cb251 100644 --- a/sources/app/controllers/ConfController.php +++ b/sources/app/controllers/ConfController.php @@ -1,6 +1,8 @@ session_only = true; } diff --git a/sources/app/controllers/ContactController.php b/sources/app/controllers/ContactController.php index af3f003..ad82ee2 100644 --- a/sources/app/controllers/ContactController.php +++ b/sources/app/controllers/ContactController.php @@ -1,6 +1,8 @@ session_only = true; } diff --git a/sources/app/controllers/DisconnectController.php b/sources/app/controllers/DisconnectController.php index 0443e9a..6671364 100644 --- a/sources/app/controllers/DisconnectController.php +++ b/sources/app/controllers/DisconnectController.php @@ -1,13 +1,21 @@ session_only = false; } function dispatch() { - $user = new User(); - $user->desauth(); + $session = \Sessionx::start(); + requestURL('http://localhost:1560/disconnect/', 2, ['sid' => $session->sessionid]); + + $pd = new modl\PresenceDAO(); + $pd->clearPresence(); + + Session::dispose(); + $this->redirect('login'); } } diff --git a/sources/app/controllers/FeedController.php b/sources/app/controllers/FeedController.php index c51a730..3d7db60 100644 --- a/sources/app/controllers/FeedController.php +++ b/sources/app/controllers/FeedController.php @@ -1,6 +1,8 @@ session_only = false; $this->raw = true; diff --git a/sources/app/controllers/GroupController.php b/sources/app/controllers/GroupController.php index 5fa4ec2..1ece763 100644 --- a/sources/app/controllers/GroupController.php +++ b/sources/app/controllers/GroupController.php @@ -1,6 +1,8 @@ session_only = false; } diff --git a/sources/app/controllers/HelpController.php b/sources/app/controllers/HelpController.php index 676d24e..03290cc 100644 --- a/sources/app/controllers/HelpController.php +++ b/sources/app/controllers/HelpController.php @@ -1,6 +1,8 @@ session_only = true; } diff --git a/sources/app/controllers/InfosController.php b/sources/app/controllers/InfosController.php index 8e3bfd8..90b68de 100644 --- a/sources/app/controllers/InfosController.php +++ b/sources/app/controllers/InfosController.php @@ -1,6 +1,8 @@ session_only = false; diff --git a/sources/app/controllers/LoginController.php b/sources/app/controllers/LoginController.php index e8ec1d8..fbef9d4 100644 --- a/sources/app/controllers/LoginController.php +++ b/sources/app/controllers/LoginController.php @@ -1,12 +1,13 @@ session_only = false; } function dispatch() { - $this->page->setTitle(__('title.login', APP_TITLE)); + $this->page->setTitle(__('page.login')); $user = new User(); if($user->isLogged()) { diff --git a/sources/app/controllers/NewsController.php b/sources/app/controllers/NewsController.php index 5fbc2ac..2516d35 100644 --- a/sources/app/controllers/NewsController.php +++ b/sources/app/controllers/NewsController.php @@ -1,6 +1,8 @@ session_only = true; } diff --git a/sources/app/controllers/NodeController.php b/sources/app/controllers/NodeController.php index d931e90..2d197c3 100644 --- a/sources/app/controllers/NodeController.php +++ b/sources/app/controllers/NodeController.php @@ -1,6 +1,8 @@ session_only = false; $this->public = true; diff --git a/sources/app/controllers/NotfoundController.php b/sources/app/controllers/NotfoundController.php index fb10f9e..47d29f4 100644 --- a/sources/app/controllers/NotfoundController.php +++ b/sources/app/controllers/NotfoundController.php @@ -1,6 +1,8 @@ session_only = false; } diff --git a/sources/app/controllers/RoomController.php b/sources/app/controllers/RoomController.php index 9726e40..f7ba3fd 100644 --- a/sources/app/controllers/RoomController.php +++ b/sources/app/controllers/RoomController.php @@ -1,6 +1,8 @@ session_only = true; } diff --git a/sources/app/controllers/TagController.php b/sources/app/controllers/TagController.php index 4707b4b..9f866ab 100644 --- a/sources/app/controllers/TagController.php +++ b/sources/app/controllers/TagController.php @@ -1,6 +1,8 @@ session_only = false; } diff --git a/sources/app/controllers/VisioController.php b/sources/app/controllers/VisioController.php index 48ed20b..49f5dab 100644 --- a/sources/app/controllers/VisioController.php +++ b/sources/app/controllers/VisioController.php @@ -1,6 +1,8 @@ session_only = true; $this->raw = true; diff --git a/sources/app/helpers/StringHelper.php b/sources/app/helpers/StringHelper.php index 5e039a4..df59468 100644 --- a/sources/app/helpers/StringHelper.php +++ b/sources/app/helpers/StringHelper.php @@ -21,7 +21,7 @@ class MovimEmoji $this->_emoji = new Emoji(new EmojiIndex(), $this->getPath()); } - public function replace($string, $large = false) + public function replace($string) { $this->_emoji->setAssetUrlFormat($this->getPath()); $string = $this->_emoji->replaceEmojiWithImages($string); @@ -30,7 +30,7 @@ class MovimEmoji return $string; } - private function getPath($large = false) + private function getPath() { return BASE_URI . 'themes/' . $this->_theme . '/img/emojis/svg/%s.svg'; } @@ -99,48 +99,7 @@ function prepareString($string, $large = false, $preview = false) { $string = addUrls($string, $preview); // We add some smileys... - $emoji = MovimEmoji::getInstance(); - $string = $emoji->replace($string, $large); - - return trim($string); -} - - -/** - * Fix self-closing tags - */ -function fixSelfClosing($string) { - return preg_replace_callback('/<([^\s<]+)\/>/', - function($match) { - return '<'.$match[1].'>'; - } - , $string); -} - -/** - * @desc Escape the unescaped ampersand - */ -function escapeAmpersands($string) { - return preg_replace( - '/&[^; ]{0,6}.?/e', - "((substr('\\0',-1) == ';') ? '\\0' : '&'.substr('\\0',1))", - $string); -} - -/** - * Remove the content, body and html tags - */ -function cleanHTMLTags($string) { - return str_replace( - array( - '', - '', - '', - '', - '', - ''), - '', - $string); + return trim((string)requestURL('http://localhost:1560/emojis/', 2, ['string' => $string])); } /** @@ -319,35 +278,7 @@ function stripTags($string) */ function purifyHTML($string) { - $config = \HTMLPurifier_Config::createDefault(); - $config->set('HTML.Doctype', 'XHTML 1.1'); - $config->set('Cache.SerializerPath', '/tmp'); - $config->set('HTML.DefinitionID', 'html5-definitions'); - $config->set('HTML.DefinitionRev', 1); - if ($def = $config->maybeGetRawHTMLDefinition()) { - $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array( - 'src' => 'URI', - 'type' => 'Text', - 'width' => 'Length', - 'height' => 'Length', - 'poster' => 'URI', - 'preload' => 'Enum#auto,metadata,none', - 'controls' => 'Bool', - )); - $def->addElement('audio', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array( - 'src' => 'URI', - 'preload' => 'Enum#auto,metadata,none', - 'muted' => 'Bool', - 'controls' => 'Bool', - )); - $def->addElement('source', 'Block', 'Flow', 'Common', array( - 'src' => 'URI', - 'type' => 'Text', - )); - } - - $purifier = new \HTMLPurifier($config); - return $purifier->purify($string); + return (string)requestURL('http://localhost:1560/purify/', 2, ['html' => urlencode($string)]); } /** diff --git a/sources/app/helpers/UtilsHelper.php b/sources/app/helpers/UtilsHelper.php new file mode 100644 index 0000000..76a687b --- /dev/null +++ b/sources/app/helpers/UtilsHelper.php @@ -0,0 +1,649 @@ + + * + * @version 1.0 + * @date 20 February 2011 + * + * Copyright (C)2011 Etenil + * + * All rights reserved. + */ + +use Monolog\Logger; +use Monolog\Handler\SyslogHandler; +use Monolog\Handler\StreamHandler; + +class Utils { + public static function log($message, $priority = '') + { + if(LOG_LEVEL != null && LOG_LEVEL > 0) { + $log = new Logger('movim'); + + $handler = new SyslogHandler('movim'); + + if(LOG_LEVEL > 1) + $log->pushHandler(new StreamHandler(LOG_PATH.'/movim.log', Logger::DEBUG)); + + $log->pushHandler($handler, Logger::DEBUG); + + $errlines = explode("\n",$message); + foreach ($errlines as $txt) { $log->addDebug($txt); } + } + } +} + +/** + * Return the list of gender + */ +function getGender() { + return array('N' => __('gender.nil'), + 'M' => __('gender.male'), + 'F' => __('gender.female'), + 'O' => __('gender.other') + ); +} + +/** + * Return the list of client types + */ +function getClientTypes() { + return array( + 'bot' => __('client.bot'), + 'pc' => __('client.desktop'), + 'phone' => __('client.phone'), + 'handheld' => __('client.phone'), + 'web' => __('client.web'), + 'registered' => __('client.registered') + ); +} + +/** + * Return a XEP to namespace association + */ +function getXepNamespace() { + return array( + '0004' => array('name' => 'Data Forms', 'category' => 'client', 'ns' => 'jabber:x:data'), + '0012' => array('name' => 'Last Activity', 'category' => 'chat', 'ns' => 'jabber:iq:last'), + '0030' => array('name' => 'Service Discovery', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/disco#info'), + '0045' => array('name' => 'Multi-User Chat', 'category' => 'chat', 'ns' => 'http://jabber.org/protocol/muc'), + '0050' => array('name' => 'Ad-Hoc Commands', 'category' => 'client', 'ns' => 'http://jabber.org/protocol/commands'), + '0054' => array('name' => 'vcard-temp', 'category' => 'client', 'ns' => 'vcard-temp'), + '0071' => array('name' => 'XHTML-IM', 'category' => 'chat', 'ns' => 'http://jabber.org/protocol/xhtml-im'), + '0080' => array('name' => 'User Location', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/geoloc'), + '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'), + '0107' => array('name' => 'User Mood', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/mood'), + '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'), + '0172' => array('name' => 'User Nickname', 'category' => 'profile', 'ns' => 'http://jabber.org/protocol/nick'), + '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'), + '0280' => array('name' => 'Message Carbons', 'category' => 'chat', 'ns' => 'urn:xmpp:carbons:2'), + '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 + */ +function getCountries() { + return array( + 'AF' => 'Afghanistan', + 'AX' => 'Aland Islands', + 'AL' => 'Albania', + 'DZ' => 'Algeria', + 'AS' => 'American Samoa', + 'AD' => 'Andorra', + 'AO' => 'Angola', + 'AI' => 'Anguilla', + 'AQ' => 'Antarctica', + 'AG' => 'Antigua and Barbuda', + 'AR' => 'Argentina', + 'AM' => 'Armenia', + 'AW' => 'Aruba', + 'AU' => 'Australia', + 'AT' => 'Austria', + 'AZ' => 'Azerbaijan', + 'BS' => 'Bahamas The', + 'BH' => 'Bahrain', + 'BD' => 'Bangladesh', + 'BB' => 'Barbados', + 'BY' => 'Belarus', + 'BE' => 'Belgium', + 'BZ' => 'Belize', + 'BJ' => 'Benin', + 'BM' => 'Bermuda', + 'BT' => 'Bhutan', + 'BO' => 'Bolivia', + 'BA' => 'Bosnia and Herzegovina', + 'BW' => 'Botswana', + 'BV' => 'Bouvet Island (Bouvetoya)', + 'BR' => 'Brazil', + 'IO' => 'British Indian Ocean Territory (Chagos Archipelago)', + 'VG' => 'British Virgin Islands', + 'BN' => 'Brunei Darussalam', + 'BG' => 'Bulgaria', + 'BF' => 'Burkina Faso', + 'BI' => 'Burundi', + 'KH' => 'Cambodia', + 'CM' => 'Cameroon', + 'CA' => 'Canada', + 'CV' => 'Cape Verde', + 'KY' => 'Cayman Islands', + 'CF' => 'Central African Republic', + 'TD' => 'Chad', + 'CL' => 'Chile', + 'CN' => 'China', + 'CX' => 'Christmas Island', + 'CC' => 'Cocos (Keeling) Islands', + 'CO' => 'Colombia', + 'KM' => 'Comoros The', + 'CD' => 'Congo', + 'CG' => 'Congo The', + 'CK' => 'Cook Islands', + 'CR' => 'Costa Rica', + 'CI' => 'Cote d\'Ivoire', + 'HR' => 'Croatia', + 'CU' => 'Cuba', + 'CY' => 'Cyprus', + 'CZ' => 'Czech Republic', + 'DK' => 'Denmark', + 'DJ' => 'Djibouti', + 'DM' => 'Dominica', + 'DO' => 'Dominican Republic', + 'EC' => 'Ecuador', + 'EG' => 'Egypt', + 'SV' => 'El Salvador', + 'GQ' => 'Equatorial Guinea', + 'ER' => 'Eritrea', + 'EE' => 'Estonia', + 'ET' => 'Ethiopia', + 'FO' => 'Faroe Islands', + 'FK' => 'Falkland Islands (Malvinas)', + 'FJ' => 'Fiji The Fiji Islands', + 'FI' => 'Finland', + 'FR' => 'France, French Republic', + 'GF' => 'French Guiana', + 'PF' => 'French Polynesia', + 'TF' => 'French Southern Territories', + 'GA' => 'Gabon', + 'GM' => 'Gambia The', + 'GE' => 'Georgia', + 'DE' => 'Germany', + 'GH' => 'Ghana', + 'GI' => 'Gibraltar', + 'GR' => 'Greece', + 'GL' => 'Greenland', + 'GD' => 'Grenada', + 'GP' => 'Guadeloupe', + 'GU' => 'Guam', + 'GT' => 'Guatemala', + 'GG' => 'Guernsey', + 'GN' => 'Guinea', + 'GW' => 'Guinea-Bissau', + 'GY' => 'Guyana', + 'HT' => 'Haiti', + 'HM' => 'Heard Island and McDonald Islands', + 'VA' => 'Holy See (Vatican City State)', + 'HN' => 'Honduras', + 'HK' => 'Hong Kong', + 'HU' => 'Hungary', + 'IS' => 'Iceland', + 'IN' => 'India', + 'ID' => 'Indonesia', + 'IR' => 'Iran', + 'IQ' => 'Iraq', + 'IE' => 'Ireland', + 'IM' => 'Isle of Man', + 'IL' => 'Israel', + 'IT' => 'Italy', + 'JM' => 'Jamaica', + 'JP' => 'Japan', + 'JE' => 'Jersey', + 'JO' => 'Jordan', + 'KZ' => 'Kazakhstan', + 'KE' => 'Kenya', + 'KI' => 'Kiribati', + 'KP' => 'Korea', + 'KR' => 'Korea', + 'KW' => 'Kuwait', + 'KG' => 'Kyrgyz Republic', + 'LA' => 'Lao', + 'LV' => 'Latvia', + 'LB' => 'Lebanon', + 'LS' => 'Lesotho', + 'LR' => 'Liberia', + 'LY' => 'Libyan Arab Jamahiriya', + 'LI' => 'Liechtenstein', + 'LT' => 'Lithuania', + 'LU' => 'Luxembourg', + 'MO' => 'Macao', + 'MK' => 'Macedonia', + 'MG' => 'Madagascar', + 'MW' => 'Malawi', + 'MY' => 'Malaysia', + 'MV' => 'Maldives', + 'ML' => 'Mali', + 'MT' => 'Malta', + 'MH' => 'Marshall Islands', + 'MQ' => 'Martinique', + 'MR' => 'Mauritania', + 'MU' => 'Mauritius', + 'YT' => 'Mayotte', + 'MX' => 'Mexico', + 'FM' => 'Micronesia', + 'MD' => 'Moldova', + 'MC' => 'Monaco', + 'MN' => 'Mongolia', + 'ME' => 'Montenegro', + 'MS' => 'Montserrat', + 'MA' => 'Morocco', + 'MZ' => 'Mozambique', + 'MM' => 'Myanmar', + 'NA' => 'Namibia', + 'NR' => 'Nauru', + 'NP' => 'Nepal', + 'AN' => 'Netherlands Antilles', + 'NL' => 'Netherlands The', + 'NC' => 'New Caledonia', + 'NZ' => 'New Zealand', + 'NI' => 'Nicaragua', + 'NE' => 'Niger', + 'NG' => 'Nigeria', + 'NU' => 'Niue', + 'NF' => 'Norfolk Island', + 'MP' => 'Northern Mariana Islands', + 'NO' => 'Norway', + 'OM' => 'Oman', + 'PK' => 'Pakistan', + 'PW' => 'Palau', + 'PS' => 'Palestinian Territory', + 'PA' => 'Panama', + 'PG' => 'Papua New Guinea', + 'PY' => 'Paraguay', + 'PE' => 'Peru', + 'PH' => 'Philippines', + 'PN' => 'Pitcairn Islands', + 'PL' => 'Poland', + 'PT' => 'Portugal, Portuguese Republic', + 'PR' => 'Puerto Rico', + 'QA' => 'Qatar', + 'RE' => 'Reunion', + 'RO' => 'Romania', + 'RU' => 'Russian Federation', + 'RW' => 'Rwanda', + 'BL' => 'Saint Barthelemy', + 'SH' => 'Saint Helena', + 'KN' => 'Saint Kitts and Nevis', + 'LC' => 'Saint Lucia', + 'MF' => 'Saint Martin', + 'PM' => 'Saint Pierre and Miquelon', + 'VC' => 'Saint Vincent and The Grenadines', + 'WS' => 'Samoa', + 'SM' => 'San Marino', + 'ST' => 'Sao Tome and Principe', + 'SA' => 'Saudi Arabia', + 'SN' => 'Senegal', + 'RS' => 'Serbia', + 'SC' => 'Seychelles', + 'SL' => 'Sierra Leone', + 'SG' => 'Singapore', + 'SK' => 'Slovakia (Slovak Republic)', + 'SI' => 'Slovenia', + 'SB' => 'Solomon Islands', + 'SO' => 'Somalia, Somali Republic', + 'ZA' => 'South Africa', + 'GS' => 'South Georgia and The South Sandwich Islands', + 'ES' => 'Spain', + 'LK' => 'Sri Lanka', + 'SD' => 'Sudan', + 'SR' => 'Suriname', + 'SJ' => 'Svalbard & Jan Mayen Islands', + 'SZ' => 'Swaziland', + 'SE' => 'Sweden', + 'CH' => 'Switzerland, Swiss Confederation', + 'SY' => 'Syrian Arab Republic', + 'TW' => 'Taiwan', + 'TJ' => 'Tajikistan', + 'TZ' => 'Tanzania', + 'TH' => 'Thailand', + 'TL' => 'Timor-Leste', + 'TG' => 'Togo', + 'TK' => 'Tokelau', + 'TO' => 'Tonga', + 'TT' => 'Trinidad and Tobago', + 'TN' => 'Tunisia', + 'TR' => 'Turkey', + 'TM' => 'Turkmenistan', + 'TC' => 'Turks and Caicos Islands', + 'TV' => 'Tuvalu', + 'UG' => 'Uganda', + 'UA' => 'Ukraine', + 'AE' => 'United Arab Emirates', + 'GB' => 'United Kingdom', + 'US' => 'United States of America', + 'UM' => 'United States Minor Outlying Islands', + 'VI' => 'United States Virgin Islands', + 'UY' => 'Uruguay, Eastern Republic of', + 'UZ' => 'Uzbekistan', + 'VU' => 'Vanuatu', + 'VE' => 'Venezuela', + 'VN' => 'Vietnam', + 'WF' => 'Wallis and Futuna', + 'EH' => 'Western Sahara', + 'YE' => 'Yemen', + 'ZM' => 'Zambia', + 'ZW' => 'Zimbabwe' + ); +} + +/** + * Return the list of marital status + */ +function getMarital() { + return array( + 'none' => __('marital.nil'), + 'single' => __('marital.single'), + 'relationship' => __('marital.relationship'), + 'married' => __('marital.married'), + 'divorced' => __('marital.divorced'), + 'widowed' => __('marital.widowed'), + 'cohabiting' => __('marital.cohabiting'), + 'union' => __('marital.union') + ); +} + +function getPresences() { + return array( + 1 => __('presence.online'), + 2 => __('presence.away'), + 3 => __('presence.dnd'), + 4 => __('presence.xa'), + 5 => __('presence.offline'), + 6 => __('presence.error') + ); + +} + +function getPresencesTxt() { + return array( + 1 => 'online', + 2 => 'away', + 3 => 'dnd', + 4 => 'xa', + 5 => 'offline', + 6 => 'server_error' + ); +} + +function getMood() { + return array( + 'afraid' => __('mood.afraid'), // Impressed with fear or apprehension; in fear; apprehensive. + 'amazed' => __('mood.amazed'), // Astonished; confounded with fear, surprise or wonder. + 'amorous' => __('mood.amorous'), // Inclined to love; having a propensity to love, or to sexual enjoyment; loving, fond, affectionate, passionate, lustful, sexual, etc. + 'angry' => __('mood.angry'), // Displaying or feeling anger, i.e., a strong feeling of displeasure, hostility or antagonism towards someone or something, usually combined with an urge to harm. + 'annoyed' => __('mood.annoyed'), // To be disturbed or irritated, especially by continued or repeated acts. + 'anxious' => __('mood.anxious'), // Full of anxiety or disquietude; greatly concerned or solicitous, esp. respecting something future or unknown; being in painful suspense. + 'aroused' => __('mood.aroused'), // To be stimulated in one's feelings, especially to be sexually stimulated. + 'ashamed' => __('mood.ashamed'), // Feeling shame or guilt. + 'bored' => __('mood.bored'), // Suffering from boredom; uninterested, without attention. + 'brave' => __('mood.brave'), // Strong in the face of fear; courageous. + 'calm' => __('mood.calm'), // Peaceful, quiet. + 'cautious' => __('mood.cautious'), // Taking care or caution; tentative. + 'cold' => __('mood.cold'), // Feeling the sensation of coldness, especially to the point of discomfort. + 'confident' => __('mood.confident'), // Feeling very sure of or positive about something, especially about one's own capabilities. + 'confused' => __('mood.confused'), // Chaotic, jumbled or muddled. + 'contemplative' => __('mood.contemplative'), // Feeling introspective or thoughtful. + 'contented' => __('mood.contented'), // Pleased at the satisfaction of a want or desire; satisfied. + 'cranky' => __('mood.cranky'), // Grouchy, irritable; easily upset. + 'crazy' => __('mood.crazy'), // Feeling out of control; feeling overly excited or enthusiastic. + 'creative' => __('mood.creative'), // Feeling original, expressive, or imaginative. + 'curious' => __('mood.curious'), // Inquisitive; tending to ask questions, investigate, or explore. + 'dejected' => __('mood.dejected'), // Feeling sad and dispirited. + 'depressed' => __('mood.depressed'), // Severely despondent and unhappy. + 'disappointed' => __('mood.disappointed'), // Defeated of expectation or hope; let down. + 'disgusted' => __('mood.disgusted'), // Filled with disgust; irritated and out of patience. + 'dismayed' => __('mood.dismayed'), // Feeling a sudden or complete loss of courage in the face of trouble or danger. + 'distracted' => __('mood.distracted'), // Having one's attention diverted; preoccupied. + 'embarrassed' => __('mood.embarrassed'), // Having a feeling of shameful discomfort. + 'envious' => __('mood.envious'), // Feeling pain by the excellence or good fortune of another. + 'excited' => __('mood.excited'), // Having great enthusiasm. + 'flirtatious' => __('mood.flirtatious'), // In the mood for flirting. + 'frustrated' => __('mood.frustrated'), // Suffering from frustration; dissatisfied, agitated, or discontented because one is unable to perform an action or fulfill a desire. + 'grateful' => __('mood.grateful'), // Feeling appreciation or thanks. + 'grieving' => __('mood.grieving'), // Feeling very sad about something, especially something lost; mournful; sorrowful. + 'grumpy' => __('mood.grumpy'), // Unhappy and irritable. + 'guilty' => __('mood.guilty'), // Feeling responsible for wrongdoing; feeling blameworthy. + 'happy' => __('mood.happy'), // Experiencing the effect of favourable fortune; having the feeling arising from the consciousness of well-being or of enjoyment; enjoying good of any kind, as peace, tranquillity, comfort; contented; joyous. + 'hopeful' => __('mood.hopeful'), // Having a positive feeling, belief, or expectation that something wished for can or will happen. + 'hot' => __('mood.hot'), // Feeling the sensation of heat, especially to the point of discomfort. + 'humbled' => __('mood.humbled'), // Having or showing a modest or low estimate of one's own importance; feeling lowered in dignity or importance. + 'humiliated' => __('mood.humiliated'), // Feeling deprived of dignity or self-respect. + 'hungry' => __('mood.hungry'), // Having a physical need for food. + 'hurt' => __('mood.hurt'), // Wounded, injured, or pained, whether physically or emotionally. + 'impressed' => __('mood.impressed'), // Favourably affected by something or someone. + 'in_awe' => __('mood.in_awe'), // Feeling amazement at something or someone; or feeling a combination of fear and reverence. + 'in_love' => __('mood.in_love'), // Feeling strong affection, care, liking, or attraction.. + 'indignant' => __('mood.indignant'), // Showing anger or indignation, especially at something unjust or wrong. + 'interested' => __('mood.interested'), // Showing great attention to something or someone; having or showing interest. + 'intoxicated' => __('mood.intoxicated'), // Under the influence of alcohol; drunk. + 'invincible' => __('mood.invincible'), // Feeling as if one cannot be defeated, overcome or denied. + 'jealous' => __('mood.jealous'), // Fearful of being replaced in position or affection. + 'lonely' => __('mood.lonely'), // Feeling isolated, empty, or abandoned. + 'lost' => __('mood.lost'), // Unable to find one's way, either physically or emotionally. + 'lucky' => __('mood.lucky'), // Feeling as if one will be favored by luck. + 'mean' => __('mood.mean'), // Causing or intending to cause intentional harm; bearing ill will towards another; cruel; malicious. + 'moody' => __('mood.moody'), // Given to sudden or frequent changes of mind or feeling; temperamental. + 'nervous' => __('mood.nervous'), // Easily agitated or alarmed; apprehensive or anxious. + 'neutral' => __('mood.neutral'), // Not having a strong mood or emotional state. + 'offended' => __('mood.offended'), // Feeling emotionally hurt, displeased, or insulted. + 'outraged' => __('mood.outraged'), // Feeling resentful anger caused by an extremely violent or vicious attack, or by an offensive, immoral, or indecent act. + 'playful' => __('mood.playful'), // Interested in play; fun, recreational, unserious, lighthearted; joking, silly. + 'proud' => __('mood.proud'), // Feeling a sense of one's own worth or accomplishment. + 'relaxed' => __('mood.relaxed'), // Having an easy-going mood; not stressed; calm. + 'relieved' => __('mood.relieved'), // Feeling uplifted because of the removal of stress or discomfort. + 'remorseful' => __('mood.remorseful'), // Feeling regret or sadness for doing something wrong. + 'restless' => __('mood.restless'), // Without rest; unable to be still or quiet; uneasy; continually moving. + 'sad' => __('mood.sad'), // Feeling sorrow; sorrowful, mournful. + 'sarcastic' => __('mood.sarcastic'), // Mocking and ironical. + 'satisfied' => __('mood.satisfied'), // Pleased at the fulfillment of a need or desire. + 'serious' => __('mood.serious'), // Without humor or expression of happiness; grave in manner or disposition; earnest; thoughtful; solemn. + 'shocked' => __('mood.shocked'), // Surprised, startled, confused, or taken aback. + 'shy' => __('mood.shy'), // Feeling easily frightened or scared; timid; reserved or coy. + 'sick' => __('mood.sick'), // Feeling in poor health; ill. + 'sleepy' => __('mood.sleepy'), // Feeling the need for sleep. + 'spontaneous' => __('mood.spontaneous'), // Acting without planning; natural; impulsive. + 'stressed' => __('mood.stressed'), // Suffering emotional pressure. + 'strong' => __('mood.strong'), // Capable of producing great physical force; or, emotionally forceful, able, determined, unyielding. + 'surprised' => __('mood.surprised'), // Experiencing a feeling caused by something unexpected. + 'thankful' => __('mood.thankful'), // Showing appreciation or gratitude. + 'thirsty' => __('mood.thirsty'), // Feeling the need to drink. + 'tired' => __('mood.tired'), // In need of rest or sleep. + 'undefined' => __('mood.undefined'), // [Feeling any emotion not defined here.] + 'weak' => __('mood.weak'), // Lacking in force or ability, either physical or emotional. + 'worried' => __('mood.worried') // Thinking about unpleasant things that have happened or that might happen; feeling afraid and unhappy. + ); +} + +/* + * Generate a standard UUID + */ +function generateUUID($string = false) { + if($string != false) + $data = $string; + else + $data = openssl_random_pseudo_bytes(16); + + $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010 + $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 + + return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); +} + +function movim_log($logs) { + $log = new Logger('movim'); + $log->pushHandler(new SyslogHandler('movim')); + + $log->pushHandler(new StreamHandler(LOG_PATH.'/logger.log', Logger::DEBUG)); + if(is_array($logs)) + $log->addInfo('', $logs); + else + $log->addInfo($logs); +} + +/* + * @desc Generate a simple random key + * @params The size of the key + */ +function generateKey($size) { + // Generating the session cookie's hash. + $hash_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $hash = ""; + + for($i = 0; $i < $size; $i++) { + $r = mt_rand(0, strlen($hash_chars) - 1); + $hash.= $hash_chars[$r]; + } + return $hash; +} + +/* + * @desc Get the range aroung a position with a radius + */ +function geoRadius($latitude, $longitude, $radius) { + $lat_range = $range/69.172; + $lon_range = abs($range/(cos($latitude) * 69.172)); + $min_lat = number_format($latitude - $lat_range, "4", ".", ""); + $max_lat = number_format($latitude + $lat_range, "4", ".", ""); + $min_lon = number_format($longitude - $lon_range, "4", ".", ""); + $max_lon = number_format($longitude + $lon_range, "4", ".", ""); + + return array($min_lat, $max_lat, $min_lon, $max_lon); +} + +/* + * @desc Request a simple url + */ +function requestURL($url, $timeout = 10, $post = false) { + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0'); + + if(is_array($post)) { + $params = ''; + + foreach($post as $key => $value) { + $params .= $key . '=' . $value .'&'; + } + curl_setopt ($ch, CURLOPT_POST, 1); + curl_setopt ($ch, CURLOPT_POSTFIELDS, $params); + } + + $rs = array(); + + $content = curl_exec($ch); + + $rs['content'] = $content; + $rs['errno'] = curl_errno($ch); + $rs['errmsg'] = curl_error($ch); + $rs['header'] = curl_getinfo($ch); + + if($rs['errno'] == 0) { + return $rs['content']; + } else { + return false; + } +} + +/* + * @desc Get the URI of a smiley + */ +function getSmileyPath($id) +{ + return BASE_URI.'/themes/material/img/emojis/svg/'.$id.'.svg'; +} + +/* + * @desc Translate something + */ +function __() { + $args = func_get_args(); + $l = Movim\i18n\Locale::start(); + + $string = array_shift($args); + return $l->translate($string, $args); +} + +function createEmailPic($jid, $email) { + $cachefile = DOCUMENT_ROOT.'/cache/'.$jid.'_email.png'; + + if(file_exists(DOCUMENT_ROOT.'/cache/'.$jid.'_email.png')) + unlink(DOCUMENT_ROOT.'/cache/'.$jid.'_email.png'); + + $draw = new ImagickDraw(); + try { + $draw->setFontSize(13); + $draw->setGravity(Imagick::GRAVITY_CENTER); + + $canvas = new Imagick(); + + $metrics = $canvas->queryFontMetrics($draw, $email); + + $canvas->newImage($metrics['textWidth'], $metrics['textHeight'], "transparent", "png"); + $canvas->annotateImage($draw, 0, 0, 0, $email); + + $canvas->setImageFormat('PNG'); + $canvas->writeImage($cachefile); + + $canvas->clear(); + } catch (ImagickException $e) { + error_log($e->getMessage()); + } +} + diff --git a/sources/app/models/cache/Cache.php b/sources/app/models/cache/Cache.php index e98fb48..4c7ee2f 100644 --- a/sources/app/models/cache/Cache.php +++ b/sources/app/models/cache/Cache.php @@ -7,20 +7,20 @@ class Cache extends Model{ public $name; public $data; public $timestamp; - + public function __construct() { $this->_struct = ' { - "session" : + "session" : {"type":"string", "size":64, "key":true }, - "name" : + "name" : {"type":"string", "size":32, "key":true }, - "data" : + "data" : {"type":"text", "mandatory":true }, - "timestamp" : + "timestamp" : {"type":"date", "mandatory":true } }'; - + parent::__construct(); } } diff --git a/sources/app/models/cache/CacheDAO.php b/sources/app/models/cache/CacheDAO.php index a1ca5ff..9639e98 100644 --- a/sources/app/models/cache/CacheDAO.php +++ b/sources/app/models/cache/CacheDAO.php @@ -3,24 +3,24 @@ namespace modl; class CacheDAO extends SQL { - function get($session, $key) { + function get($key) { $this->_sql = ' select * from cache - where + where session = :session and name = :name'; - + $this->prepare( - 'Cache', + 'Cache', array( - 'session' => $session, + 'session' => $this->_user, 'name' => $key ) ); - + return $this->run('Cache', 'item'); } - + function set(Cache $cache) { $this->_sql = ' update cache @@ -28,35 +28,35 @@ class CacheDAO extends SQL { timestamp = :timestamp where session = :session and name = :name'; - + $this->prepare( - 'Cache', + 'Cache', array( - 'session' => $cache->session, + 'session' => $this->_user, 'data' => $cache->data, 'timestamp' => $cache->timestamp, 'name' => $cache->name ) ); - + $this->run('Cache'); - + if(!$this->_effective) { $this->_sql = ' insert into cache (session, name, data, timestamp) values (:session, :name, :data, :timestamp)'; - + $this->prepare( - 'Cache', + 'Cache', array( - 'session' => $cache->session, + 'session' => $this->_user, 'name' => $cache->name, 'data' => $cache->data, 'timestamp' => $cache->timestamp ) ); - + return $this->run('Cache'); } } diff --git a/sources/app/models/item/Item.php b/sources/app/models/item/Item.php index 938fc87..fe331ad 100644 --- a/sources/app/models/item/Item.php +++ b/sources/app/models/item/Item.php @@ -14,6 +14,7 @@ class Item extends Model { public $subscription; public $num; public $sub; + public $logo; public function __construct() { $this->_struct = ' @@ -31,7 +32,9 @@ class Item extends Model { "created" : {"type":"date"}, "description" : - {"type":"text" }, + {"type":"text"}, + "logo" : + {"type":"bool"}, "updated" : {"type":"date", "mandatory":true} }'; @@ -76,6 +79,28 @@ class Item extends Model { $this->updated = date('Y-m-d H:i:s'); } + public function setPicture() + { + $pd = new \Modl\PostnDAO; + $item = $pd->getGroupPicture($this->server, $this->node); + + if($item) { + $item->getAttachements(); + + $p = new \Picture; + $p->fromURL($item->getPicture()); + if($p->set($this->server.$this->node)) { + $this->logo = true; + } + } + } + + public function getLogo() + { + $p = new \Picture; + return $p->get($this->server.$this->node, 120); + } + public function getName() { if($this->name != null) return $this->name; diff --git a/sources/app/models/item/ItemDAO.php b/sources/app/models/item/ItemDAO.php index 5d1e2cd..68fe759 100644 --- a/sources/app/models/item/ItemDAO.php +++ b/sources/app/models/item/ItemDAO.php @@ -11,7 +11,8 @@ class ItemDAO extends SQL { creator = :creator, created = :created, updated = :updated, - description = :description + description = :description, + logo = :logo where server = :server and jid = :jid and node = :node'; @@ -26,7 +27,8 @@ class ItemDAO extends SQL { 'jid' => $item->jid, 'node' => $item->node, 'creator' => $item->creator, - 'description' => $item->description + 'description' => $item->description, + 'logo' => $item->logo ) ); @@ -43,7 +45,8 @@ class ItemDAO extends SQL { name, created, updated, - description + description, + logo ) values( :server, @@ -53,7 +56,8 @@ class ItemDAO extends SQL { :name, :created, :updated, - :description + :description, + :logo )'; $this->prepare( @@ -66,7 +70,8 @@ class ItemDAO extends SQL { 'server' => $item->server, 'jid' => $item->jid, 'node' => $item->node, - 'description' => $item->description + 'description' => $item->description, + 'logo' => $item->logo ) ); diff --git a/sources/app/models/message/Message.php b/sources/app/models/message/Message.php index 81e92c9..e127c79 100644 --- a/sources/app/models/message/Message.php +++ b/sources/app/models/message/Message.php @@ -41,7 +41,7 @@ class Message extends Model { "jidfrom" : {"type":"string", "size":96, "mandatory":true }, "resource" : - {"type":"string", "size":128, "mandatory":true }, + {"type":"string", "size":128 }, "type" : {"type":"string", "size":16, "mandatory":true }, "subject" : @@ -96,27 +96,16 @@ class Message extends Model { if($stanza->subject) $this->__set('subject', (string)$stanza->subject); - $images = (bool)($this->type == 'chat'); - - \movim_log((string)$stanza->html->body); - if($stanza->html) { - $xhtml = new \SimpleXMLElement(''.escapeAmpersands((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); + $xml = \simplexml_load_string((string)$stanza->html->body); + if($xml) { + $results = $xml->xpath('//img/@src'); + if(is_array($results) && !empty($results)) { + $this->sticker = getCid((string)$results[0]); + } } } - /*if($stanza->html) { - $this->html = \cleanHTMLTags($stanza->html->body->asXML()); - $this->html = \fixSelfClosing($this->html); - $this->html = \prepareString($this->html, false, $images); - } else {*/ - // $this->html = \prepareString($this->body, false, $images); - //} - if($stanza->replace) { $this->newid = $this->id; $this->id = (string)$stanza->replace->attributes()->id; diff --git a/sources/app/models/postn/Postn.php b/sources/app/models/postn/Postn.php index 7b25cc0..11978e6 100644 --- a/sources/app/models/postn/Postn.php +++ b/sources/app/models/postn/Postn.php @@ -117,6 +117,28 @@ class Postn extends Model { return $content; } + private function getTitle($titles) { + $title = ''; + foreach($titles as $t) { + switch($t->attributes()->type) { + case 'html': + case 'xhtml': + $title = strip_tags((string)$t->children()->asXML()); + break; + case 'text': + if(trim($t) != '') { + $title = trim($t); + } + break; + default : + $title = (string)$t; + break; + } + } + + return $title; + } + public function set($item, $from, $delay = false, $node = false) { if($item->item) $entry = $item->item; @@ -150,7 +172,7 @@ class Postn extends Model { if($entry->entry->source && $entry->entry->source->author->uri) $this->__set('aid', substr((string)$entry->entry->source->author->uri, 5)); - $this->__set('title', (string)$entry->entry->title); + $this->__set('title', $this->getTitle($entry->entry->title)); // Content if($entry->entry->summary && (string)$entry->entry->summary != '') @@ -182,8 +204,6 @@ class Postn extends Model { if($delay) $this->__set('delay', $delay); - $contentimg = $this->setAttachements($entry->entry->link); - // Tags parsing if($entry->entry->category) { $td = new \Modl\TagDAO; @@ -205,15 +225,25 @@ class Postn extends Model { } } - if($contentimg != '') - $content .= '
'.$contentimg; - if(!isset($this->commentplace)) $this->__set('commentplace', $this->origin); $this->__set('content', trim($content)); $this->contentcleaned = purifyHTML(html_entity_decode($this->content)); + $extra = false; + // We try to extract a picture + $xml = \simplexml_load_string('
'.$this->contentcleaned.'
'); + if($xml) { + $results = $xml->xpath('//img/@src'); + if(is_array($results) && !empty($results)) { + $extra = (string)$results[0]; + $this->picture = true; + } + } + + $this->setAttachements($entry->entry->link, $extra); + if($entry->entry->geoloc) { if($entry->entry->geoloc->lat != 0) $this->__set('lat', (string)$entry->entry->geoloc->lat); @@ -223,16 +253,14 @@ class Postn extends Model { } private function typeIsPicture($type) { - return in_array($type, array('image/jpeg', 'image/png', 'image/jpg', 'image/gif')); + return in_array($type, array('picture', 'image/jpeg', 'image/png', 'image/jpg', 'image/gif')); } private function typeIsLink($type) { return $type == 'text/html'; } - private function setAttachements($links) { - $contentimg = ''; - + private function setAttachements($links, $extra = false) { $l = array(); foreach($links as $attachment) { @@ -252,10 +280,12 @@ class Postn extends Model { } } + if($extra) { + array_push($l, array('href' => $extra, 'type' => 'picture')); + } + if(!empty($l)) $this->links = serialize($l); - - return $contentimg; } public function getAttachements() diff --git a/sources/app/models/postn/PostnDAO.php b/sources/app/models/postn/PostnDAO.php index acb2069..603a14c 100644 --- a/sources/app/models/postn/PostnDAO.php +++ b/sources/app/models/postn/PostnDAO.php @@ -287,6 +287,27 @@ class PostnDAO extends SQL { return $this->run('ContactPostn'); } + function getGroupPicture($origin, $node) + { + $this->_sql = ' + select * from postn + where postn.origin = :origin + and postn.node = :node + and postn.picture = 1 + order by postn.published desc + limit 1'; + + $this->prepare( + 'Postn', + array( + 'origin' => $origin, + 'node' => $node + ) + ); + + return $this->run('Postn', 'item'); + } + function getItem($id) { $this->_sql = ' select *, postn.aid, privacy.value as privacy from postn @@ -383,7 +404,8 @@ class PostnDAO extends SQL { } - function getMe($limitf = false, $limitr = false) { + function getMe($limitf = false, $limitr = false) + { $this->_sql = ' select *, postn.aid, privacy.value as privacy from postn left outer join contact on postn.aid = contact.jid @@ -404,7 +426,9 @@ class PostnDAO extends SQL { return $this->run('ContactPostn'); } - function getPublic($origin, $node, $limitf = false, $limitr = false) { + + function getPublic($origin, $node, $limitf = false, $limitr = false) + { $this->_sql = ' select *, postn.aid, privacy.value as privacy from postn left outer join contact on postn.aid = contact.jid diff --git a/sources/app/models/presence/PresenceDAO.php b/sources/app/models/presence/PresenceDAO.php index 27e896b..934dcca 100644 --- a/sources/app/models/presence/PresenceDAO.php +++ b/sources/app/models/presence/PresenceDAO.php @@ -6,7 +6,7 @@ class PresenceDAO extends SQL { function __construct() { parent::__construct(); } - + function set(Presence $presence) { $id = sha1( $presence->session. @@ -29,10 +29,10 @@ class PresenceDAO extends SQL { mucaffiliation = :mucaffiliation, mucrole = :mucrole where id = :id'; - + $this->prepare( - 'Presence', - array( + 'Presence', + array( 'value' => $presence->value, 'priority' => $presence->priority, 'status' => $presence->status, @@ -48,9 +48,9 @@ class PresenceDAO extends SQL { 'id' => $id ) ); - + $this->run('Presence'); - + if(!$this->_effective) { $this->_sql = ' insert into presence @@ -87,9 +87,9 @@ class PresenceDAO extends SQL { :mucjid, :mucaffiliation, :mucrole)'; - + $this->prepare( - 'Presence', + 'Presence', array( 'id' => $id, 'session' => $presence->session, @@ -109,7 +109,7 @@ class PresenceDAO extends SQL { 'mucrole' => $presence->mucrole ) ); - + $this->run('Presence'); } } @@ -125,14 +125,14 @@ class PresenceDAO extends SQL { $this->_sql = ' delete from presence where id = :id'; - + $this->prepare( - 'Presence', + 'Presence', array( 'id' => $id ) ); - + return $this->run('Presence'); } @@ -140,100 +140,100 @@ class PresenceDAO extends SQL { $this->_sql = ' select * from presence; '; - + $this->prepare('Presence'); return $this->run('Presence'); } - function getPresence($jid, $resource) { + function getPresence($jid, $resource) { $this->_sql = ' select * from presence - where + where session = :session and jid = :jid and resource = :resource'; - + $this->prepare( - 'Presence', + 'Presence', array( 'session' => $this->_user, 'jid' => $jid, 'resource' => $resource ) ); - + return $this->run('Presence', 'item'); } - - function getMyPresenceRoom($jid) { + + function getMyPresenceRoom($jid) { $this->_sql = ' select * from presence - where + where session = :session and jid = :jid and mucjid = :session'; - + $this->prepare( - 'Presence', + 'Presence', array( 'session' => $this->_user, 'jid' => $jid, ) ); - + return $this->run('Presence', 'item'); } - function getJid($jid) { + function getJid($jid) { $this->_sql = ' select * from presence - where + where session = :session and jid = :jid order by mucaffiliation desc'; - + $this->prepare( - 'Presence', + 'Presence', array( 'session' => $this->_user, 'jid' => $jid ) ); - + return $this->run('Presence'); } - - function clearPresence($session) { + + function clearPresence() { $this->_sql = ' delete from presence - where + where session = :session'; - + $this->prepare( - 'Presence', + 'Presence', array( - 'session' => $session + 'session' => $this->_user ) ); - + return $this->run('Presence'); } - + function clearMuc($muc) { $this->_sql = ' delete from presence - where + where session = :session and jid = :jid'; - + $this->prepare( - 'Presence', + 'Presence', array( 'session' => $this->_user, 'jid' => $muc ) ); - + return $this->run('Presence'); } } diff --git a/sources/app/models/subscription/Subscription.php b/sources/app/models/subscription/Subscription.php index b69009c..a33e194 100644 --- a/sources/app/models/subscription/Subscription.php +++ b/sources/app/models/subscription/Subscription.php @@ -14,6 +14,7 @@ class Subscription extends Model { public $timestamp; public $name; public $servicename; + public $logo; public function __construct() { $this->_struct = ' @@ -39,6 +40,12 @@ class Subscription extends Model { parent::__construct(); } + public function getLogo() + { + $p = new \Picture; + return $p->get($this->server.$this->node, 120); + } + function set($jid, $server, $node, $s) { $this->__set('jid', $jid); $this->__set('server', $server); diff --git a/sources/app/models/subscription/SubscriptionDAO.php b/sources/app/models/subscription/SubscriptionDAO.php index 3706385..de2eaec 100644 --- a/sources/app/models/subscription/SubscriptionDAO.php +++ b/sources/app/models/subscription/SubscriptionDAO.php @@ -80,6 +80,7 @@ class SubscriptionDAO extends SQL { subscription, item.name, item.description, + item.logo, caps.name as servicename from subscription left outer join item @@ -95,7 +96,8 @@ class SubscriptionDAO extends SQL { subscription, caps.name, item.name, - item.description + item.description, + item.logo order by subscription.server'; diff --git a/sources/app/views/conf.tpl b/sources/app/views/conf.tpl index 20e40ca..f80852d 100644 --- a/sources/app/views/conf.tpl +++ b/sources/app/views/conf.tpl @@ -4,17 +4,23 @@
- widget('Header'); ?>
+
+
    +
  • + + +

    +
  • +
+
widget('Tabs');?> widget('Vcard4');?> widget('Avatar');?> widget('Config');?> widget('Account');?> widget('AdHoc');?> - widget('ConfigData');?> - widget('PubsubSubscriptionConfig');?>
diff --git a/sources/app/views/help.tpl b/sources/app/views/help.tpl index f6f61b7..e17e4b7 100644 --- a/sources/app/views/help.tpl +++ b/sources/app/views/help.tpl @@ -4,9 +4,17 @@
- widget('Header'); ?>
+
+
    +
  • + + +

    +
  • +
+
widget('Tabs');?> widget('Help');?> widget('About');?> diff --git a/sources/app/views/room.tpl b/sources/app/views/room.tpl index a04c7e8..23151f5 100644 --- a/sources/app/views/room.tpl +++ b/sources/app/views/room.tpl @@ -1,7 +1,6 @@ widget('Presence'); ?> widget('LoginAnonymous'); ?>
- widget('Header');?>
widget('Rooms'); ?> diff --git a/sources/app/widgets/About/About.php b/sources/app/widgets/About/About.php index fe1b1f0..1928560 100644 --- a/sources/app/widgets/About/About.php +++ b/sources/app/widgets/About/About.php @@ -13,7 +13,7 @@ * See COPYING for licensing information. */ -class About extends WidgetBase +class About extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/Account/Account.php b/sources/app/widgets/Account/Account.php index d217d75..c74925b 100644 --- a/sources/app/widgets/Account/Account.php +++ b/sources/app/widgets/Account/Account.php @@ -6,7 +6,7 @@ use Moxl\Xec\Action\Register\Get; use Moxl\Xec\Action\Register\Set; use Respect\Validation\Validator; -class Account extends WidgetBase +class Account extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/AccountNext/AccountNext.php b/sources/app/widgets/AccountNext/AccountNext.php index ec4a29c..5570b4f 100644 --- a/sources/app/widgets/AccountNext/AccountNext.php +++ b/sources/app/widgets/AccountNext/AccountNext.php @@ -3,7 +3,7 @@ use Moxl\Xec\Action\Disco\Request; use Moxl\Xec\Action\Register\Set; -class AccountNext extends WidgetBase { +class AccountNext extends \Movim\Widget\Base { function load() { $this->addjs('accountnext.js'); diff --git a/sources/app/widgets/Ack/Ack.php b/sources/app/widgets/Ack/Ack.php index 6605040..477f9e4 100644 --- a/sources/app/widgets/Ack/Ack.php +++ b/sources/app/widgets/Ack/Ack.php @@ -21,7 +21,7 @@ use Moxl\Xec\Action\Ack\Send; use Moxl\Xec\Action\Disco\Request; use Moxl\Stanza\Disco; -class Ack extends WidgetBase { +class Ack extends \Movim\Widget\Base { function load() { $this->registerEvent('ack', 'onAckRequest'); diff --git a/sources/app/widgets/AdHoc/AdHoc.php b/sources/app/widgets/AdHoc/AdHoc.php index b9916c7..2b6819f 100644 --- a/sources/app/widgets/AdHoc/AdHoc.php +++ b/sources/app/widgets/AdHoc/AdHoc.php @@ -4,7 +4,7 @@ use Moxl\Xec\Action\AdHoc\Get; use Moxl\Xec\Action\AdHoc\Command; use Moxl\Xec\Action\AdHoc\Submit; -class AdHoc extends WidgetBase +class AdHoc extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/AdminDB/AdminDB.php b/sources/app/widgets/AdminDB/AdminDB.php index 8d668a6..db97da9 100644 --- a/sources/app/widgets/AdminDB/AdminDB.php +++ b/sources/app/widgets/AdminDB/AdminDB.php @@ -15,7 +15,7 @@ * See COPYING for licensing information. */ -class AdminDB extends WidgetBase +class AdminDB extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/AdminLogin/AdminLogin.php b/sources/app/widgets/AdminLogin/AdminLogin.php index 7866287..95f32c3 100644 --- a/sources/app/widgets/AdminLogin/AdminLogin.php +++ b/sources/app/widgets/AdminLogin/AdminLogin.php @@ -15,7 +15,7 @@ * See COPYING for licensing information. */ -class AdminLogin extends WidgetBase { +class AdminLogin extends \Movim\Widget\Base { function load() { } diff --git a/sources/app/widgets/AdminMain/AdminMain.php b/sources/app/widgets/AdminMain/AdminMain.php index fe28e29..bbbee64 100644 --- a/sources/app/widgets/AdminMain/AdminMain.php +++ b/sources/app/widgets/AdminMain/AdminMain.php @@ -15,7 +15,7 @@ * See COPYING for licensing information. */ -class AdminMain extends WidgetBase +class AdminMain extends \Movim\Widget\Base { function load() { $this->addjs('admin.js'); diff --git a/sources/app/widgets/AdminTest/AdminTest.php b/sources/app/widgets/AdminTest/AdminTest.php index 8f8cdda..8035528 100644 --- a/sources/app/widgets/AdminTest/AdminTest.php +++ b/sources/app/widgets/AdminTest/AdminTest.php @@ -15,7 +15,7 @@ * See COPYING for licensing information. */ -class AdminTest extends WidgetBase +class AdminTest extends \Movim\Widget\Base { function load() { $this->addjs('admintest.js'); diff --git a/sources/app/widgets/Api/Api.php b/sources/app/widgets/Api/Api.php index 9ae95c8..6238bd0 100644 --- a/sources/app/widgets/Api/Api.php +++ b/sources/app/widgets/Api/Api.php @@ -15,7 +15,7 @@ * See COPYING for licensing information. */ -class Api extends WidgetBase { +class Api extends \Movim\Widget\Base { function load() { } @@ -27,8 +27,6 @@ class Api extends WidgetBase { $this->__( 'api.info', '', - '', - '', '')); $json = requestURL(MOVIM_API.'status', 1, array('uri' => BASE_URI)); diff --git a/sources/app/widgets/Api/locales.ini b/sources/app/widgets/Api/locales.ini index e05c6ce..3b2b7f8 100644 --- a/sources/app/widgets/Api/locales.ini +++ b/sources/app/widgets/Api/locales.ini @@ -1,6 +1,6 @@ [api] title = API -info = Here you can register your pod on the official %sMovim API%s and be listed on %sthe pods page%s. +info = Here you can register your pod on the official %sMovim API%s register = Your pod is not registered on the API registered = Your pod is registered on the API wait = Your pod is not yet validated diff --git a/sources/app/widgets/Avatar/Avatar.php b/sources/app/widgets/Avatar/Avatar.php index e8c02e5..a030230 100644 --- a/sources/app/widgets/Avatar/Avatar.php +++ b/sources/app/widgets/Avatar/Avatar.php @@ -19,7 +19,7 @@ use Moxl\Xec\Action\Avatar\Get; use Moxl\Xec\Action\Avatar\Set; use forxer\Gravatar\Gravatar; -class Avatar extends WidgetBase +class Avatar extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/Blog/Blog.php b/sources/app/widgets/Blog/Blog.php index 654e3f8..0aafb0d 100644 --- a/sources/app/widgets/Blog/Blog.php +++ b/sources/app/widgets/Blog/Blog.php @@ -4,7 +4,7 @@ use Respect\Validation\Validator; include_once WIDGETS_PATH.'Post/Post.php'; -class Blog extends WidgetBase { +class Blog extends \Movim\Widget\Base { public $_paging = 10; private $_from; diff --git a/sources/app/widgets/Bookmark/Bookmark.php b/sources/app/widgets/Bookmark/Bookmark.php index 5745254..9cbb69b 100644 --- a/sources/app/widgets/Bookmark/Bookmark.php +++ b/sources/app/widgets/Bookmark/Bookmark.php @@ -22,7 +22,7 @@ use Moxl\Xec\Action\Bookmark\Get; use Moxl\Xec\Action\Bookmark\Set; use Moxl\Xec\Action\Presence\Muc; -class Bookmark extends WidgetBase +class Bookmark extends \Movim\Widget\Base { private $_list_server; diff --git a/sources/app/widgets/Caps/Caps.php b/sources/app/widgets/Caps/Caps.php index a711a09..b8951a3 100644 --- a/sources/app/widgets/Caps/Caps.php +++ b/sources/app/widgets/Caps/Caps.php @@ -15,7 +15,7 @@ * See COPYING for licensing information. */ -class Caps extends WidgetBase +class Caps extends \Movim\Widget\Base { private $_table = array(); private $_nslist; diff --git a/sources/app/widgets/Chat/Chat.php b/sources/app/widgets/Chat/Chat.php index 050d2b2..969716b 100644 --- a/sources/app/widgets/Chat/Chat.php +++ b/sources/app/widgets/Chat/Chat.php @@ -14,7 +14,7 @@ use Respect\Validation\Validator; use Ramsey\Uuid\Uuid; -class Chat extends WidgetBase +class Chat extends \Movim\Widget\Base { private $_pagination = 30; @@ -562,6 +562,9 @@ class Chat extends WidgetBase function prepareMessage(&$message) { + $message->jidto = echapJS($message->jidto); + $message->jidfrom = echapJS($message->jidfrom); + if(isset($message->html)) { $message->body = $message->html; } else { diff --git a/sources/app/widgets/Chats/Chats.php b/sources/app/widgets/Chats/Chats.php index 46bbb36..fa6cb02 100644 --- a/sources/app/widgets/Chats/Chats.php +++ b/sources/app/widgets/Chats/Chats.php @@ -6,7 +6,7 @@ use Moxl\Xec\Action\Bookmark\Set; use Respect\Validation\Validator; -class Chats extends WidgetBase +class Chats extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/Config/Config.php b/sources/app/widgets/Config/Config.php index 61c7c2c..f6a97b7 100644 --- a/sources/app/widgets/Config/Config.php +++ b/sources/app/widgets/Config/Config.php @@ -21,7 +21,7 @@ use Moxl\Xec\Action\Storage\Set; use Respect\Validation\Validator; -class Config extends WidgetBase +class Config extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/Contact/Contact.php b/sources/app/widgets/Contact/Contact.php index fe0380b..d980da6 100644 --- a/sources/app/widgets/Contact/Contact.php +++ b/sources/app/widgets/Contact/Contact.php @@ -5,7 +5,7 @@ use Moxl\Xec\Action\Vcard4\Get; use Respect\Validation\Validator; use Moxl\Xec\Action\Pubsub\GetItems; -class Contact extends WidgetBase +class Contact extends \Movim\Widget\Base { private $_paging = 10; diff --git a/sources/app/widgets/Dialog/Dialog.php b/sources/app/widgets/Dialog/Dialog.php index 61e8875..6af9613 100644 --- a/sources/app/widgets/Dialog/Dialog.php +++ b/sources/app/widgets/Dialog/Dialog.php @@ -1,6 +1,6 @@ content); Notification::append(false, $this->__('group.empty')); - $this->ajaxDelete($server, $node, true); - $this->ajaxGetAffiliations($server, $node); - // Display an error message - RPC::call('Group.clearLoad'); + if($node != 'urn:xmpp:microblog:0') { + $this->ajaxDelete($server, $node, true); + $this->ajaxGetAffiliations($server, $node); + // Display an error message + RPC::call('Group.clearLoad'); + } } function onAffiliations($packet) @@ -389,8 +391,13 @@ class Group extends WidgetBase private function prepareHeader($server, $node) { - $pd = new \Modl\ItemDAO; - $item = $pd->getItem($server, $node); + $id = new \Modl\ItemDAO; + $item = $id->getItem($server, $node); + + if($item && !$item->logo) { + $item->setPicture(); + $id->set($item); + } $pd = new \Modl\SubscriptionDAO; $subscription = $pd->get($server, $node); @@ -406,7 +413,7 @@ class Group extends WidgetBase private function prepareGroup($server, $node, $page = 0) { - $pd = new \Modl\PostnDAO(); + $pd = new \Modl\PostnDAO; $posts = $pd->getNodeUnfiltered($server, $node, $page*$this->_paging, $this->_paging); $view = $this->tpl(); diff --git a/sources/app/widgets/Groups/Groups.php b/sources/app/widgets/Groups/Groups.php index 6e3dde2..04283f9 100644 --- a/sources/app/widgets/Groups/Groups.php +++ b/sources/app/widgets/Groups/Groups.php @@ -6,7 +6,7 @@ use Respect\Validation\Validator; use Moxl\Xec\Action\Pubsub\Create; use Moxl\Xec\Action\Pubsub\TestCreate; -class Groups extends WidgetBase +class Groups extends \Movim\Widget\Base { private $_list_server; @@ -175,18 +175,6 @@ class Groups extends WidgetBase return $html; } - private function cleanServers($servers) { - $i = 0; - foreach($servers as $c) { - if(filter_var($c->server, FILTER_VALIDATE_EMAIL)) { - unset($servers[$i]); - } elseif(count(explode('.', $c->server))<3) { - unset($servers[$i]); - } - $i++; - } - return $servers; - } /** * @brief Validate the server * diff --git a/sources/app/widgets/Groups/_groups_server.tpl b/sources/app/widgets/Groups/_groups_server.tpl index 44927be..e859935 100644 --- a/sources/app/widgets/Groups/_groups_server.tpl +++ b/sources/app/widgets/Groups/_groups_server.tpl @@ -18,7 +18,14 @@ {/if} - {$value->node|firstLetterCapitalize} + + {if="$value->logo"} + + + + {else} + {$value->node|firstLetterCapitalize} + {/if}

{if="$value->name"} {$value->name} diff --git a/sources/app/widgets/Groups/_groups_subscriptions.tpl b/sources/app/widgets/Groups/_groups_subscriptions.tpl index ce26855..cef1d02 100644 --- a/sources/app/widgets/Groups/_groups_subscriptions.tpl +++ b/sources/app/widgets/Groups/_groups_subscriptions.tpl @@ -21,7 +21,13 @@ data-node="{$value->node}" title="{$value->server} - {$value->node}" > - {$value->node|firstLetterCapitalize} + {if="$value->logo"} + + + + {else} + {$value->node|firstLetterCapitalize} + {/if}

{if="$value->name"} {$value->name} diff --git a/sources/app/widgets/Header/Header.php b/sources/app/widgets/Header/Header.php index 47c999b..c0cda92 100644 --- a/sources/app/widgets/Header/Header.php +++ b/sources/app/widgets/Header/Header.php @@ -1,6 +1,6 @@ clearPresence($this->user->getLogin()); + $pd->clearPresence(); $session = \Sessionx::start(); $session->load(); diff --git a/sources/app/widgets/LoginAnonymous/LoginAnonymous.php b/sources/app/widgets/LoginAnonymous/LoginAnonymous.php index 19fcf83..c5f043f 100644 --- a/sources/app/widgets/LoginAnonymous/LoginAnonymous.php +++ b/sources/app/widgets/LoginAnonymous/LoginAnonymous.php @@ -2,7 +2,7 @@ use Respect\Validation\Validator; -class LoginAnonymous extends WidgetBase +class LoginAnonymous extends \Movim\Widget\Base { function load() { diff --git a/sources/app/widgets/Menu/Menu.php b/sources/app/widgets/Menu/Menu.php index 4f0c978..2ef3fd5 100644 --- a/sources/app/widgets/Menu/Menu.php +++ b/sources/app/widgets/Menu/Menu.php @@ -2,7 +2,7 @@ use Moxl\Xec\Action\Pubsub\GetItems; -class Menu extends WidgetBase +class Menu extends \Movim\Widget\Base { private $_paging = 15; diff --git a/sources/app/widgets/Menu/menu.js b/sources/app/widgets/Menu/menu.js index cd43948..74dc529 100644 --- a/sources/app/widgets/Menu/menu.js +++ b/sources/app/widgets/Menu/menu.js @@ -1,6 +1,6 @@ var Menu = { refresh: function() { - var items = document.querySelectorAll('#menu_widget ul li, #post_widget ul.card li'); + var items = document.querySelectorAll('ul#menu_wrapper li, #post_widget ul.card li'); var i = 0; while(i < items.length) diff --git a/sources/app/widgets/Navigation/Navigation.php b/sources/app/widgets/Navigation/Navigation.php index 206cf48..965a79e 100644 --- a/sources/app/widgets/Navigation/Navigation.php +++ b/sources/app/widgets/Navigation/Navigation.php @@ -1,6 +1,6 @@ {$c->__('page.chats')}

- -
    + diff --git a/sources/app/widgets/NotFound/NotFound.php b/sources/app/widgets/NotFound/NotFound.php index bfe5b51..b270c1a 100644 --- a/sources/app/widgets/NotFound/NotFound.php +++ b/sources/app/widgets/NotFound/NotFound.php @@ -1,6 +1,6 @@ setNode($node) ->setId($id) ->request(); + + $p = new Delete; + $p->setTo($to) + ->setNode('urn:xmpp:microblog:0:comments/'.$id) + ->request(); } function ajaxGetComments($jid, $id) @@ -214,9 +220,6 @@ class Post extends WidgetBase if(!$validate->validate($id)) return; - $pd = new \Modl\PrivacyDAO(); - $p = $pd->get($id); - $pd = new \Modl\PostnDAO; $po = $pd->getItem($id); diff --git a/sources/app/widgets/Post/_post.tpl b/sources/app/widgets/Post/_post.tpl index 8816470..e52a2bc 100644 --- a/sources/app/widgets/Post/_post.tpl +++ b/sources/app/widgets/Post/_post.tpl @@ -133,9 +133,11 @@ {if="$post->isShort() && isset($attachements.pictures)"} {loop="$attachements.pictures"} + {if="$value.type != 'picture'"} + {/if} {/loop} {elseif="$post->getYoutube()"}
    @@ -199,6 +201,7 @@ {if="!$post->isShort() && isset($attachements.pictures)"}
      {loop="$attachements.pictures"} + {if="$value.type != 'picture'"}
    • @@ -207,6 +210,7 @@
    • + {/if} {/loop}
    {/if} diff --git a/sources/app/widgets/Post/_post_empty.tpl b/sources/app/widgets/Post/_post_empty.tpl index dc1a391..0b983f7 100644 --- a/sources/app/widgets/Post/_post_empty.tpl +++ b/sources/app/widgets/Post/_post_empty.tpl @@ -27,64 +27,7 @@
{/if} -
  • diff --git a/sources/app/widgets/Post/locales.ini b/sources/app/widgets/Post/locales.ini index 59dc740..3df8908 100644 --- a/sources/app/widgets/Post/locales.ini +++ b/sources/app/widgets/Post/locales.ini @@ -23,3 +23,15 @@ discover = Discover more articles on the Groups page comments_disabled = Comments disabled comment_published = Comment published + +[hello] +blog_title = Visit your public blog +blog_text = See your public posts and share them with all your contacts +contact_post = Contact post +share_title = Universal share button +share_text = Bookmark or drag and drop the following button in your toolbar and use it on all the pages you want to share on Movim +share_button = Share on Movim +enter_title = Oh! Hello! +enter_paragraph = It seems that you're new there! Welcome on Movim! +menu_title = Check the Menu +menu_paragraph = All the main Movim features are accessible there. Don't hesitate to navigate through the pages to discover more! diff --git a/sources/app/widgets/Presence/Presence.php b/sources/app/widgets/Presence/Presence.php index eec13d4..b15e285 100644 --- a/sources/app/widgets/Presence/Presence.php +++ b/sources/app/widgets/Presence/Presence.php @@ -27,7 +27,7 @@ use Moxl\Xec\Action\Pubsub\GetItems; use Moxl\Stanza\Stream; use Moxl\Xec\Action\Storage\Get; -class Presence extends WidgetBase +class Presence extends \Movim\Widget\Base { function load() @@ -35,6 +35,19 @@ class Presence extends WidgetBase $this->addcss('presence.css'); $this->addjs('presence.js'); $this->registerEvent('mypresence', 'onMyPresence'); + $this->registerEvent('session_up', 'onSessionUp'); + $this->registerEvent('session_down', 'onSessionDown'); + } + + function onSessionUp() + { + $this->ajaxSet(); + } + + function onSessionDown() + { + $p = new Away; + $p->request(); } function onMyPresence($packet) @@ -46,11 +59,6 @@ class Presence extends WidgetBase RPC::call('movim_remove_class', '#presence_widget', 'unfolded'); } - function onPostDisconnect($data) - { - RPC::call('movim_reload', Route::urlize('disconnect')); - } - function ajaxSet($form = false) { if($form == false) { @@ -103,9 +111,7 @@ class Presence extends WidgetBase function ajaxLogout() { $pd = new \Modl\PresenceDAO(); - - $session = \Sessionx::start(); - $pd->clearPresence($session->username.'@'.$session->host); + $pd->clearPresence(); $session = \Sessionx::start(); $p = new Unavailable; @@ -226,7 +232,6 @@ class Presence extends WidgetBase $presencetpl->assign('txt', $txt); $presencetpl->assign('txts', $txts); - $presencetpl->assign('calllogout', $this->call('ajaxLogout')); $html = $presencetpl->draw('_presence_list', true); return $html; diff --git a/sources/app/widgets/Presence/_presence.tpl b/sources/app/widgets/Presence/_presence.tpl index 76cafbd..fd6215f 100644 --- a/sources/app/widgets/Presence/_presence.tpl +++ b/sources/app/widgets/Presence/_presence.tpl @@ -10,10 +10,10 @@ {/if} - -

    {$me->getTrueName()}

    + + + + +

    {$me->getTrueName()}

    {$presence->status}

  • diff --git a/sources/app/widgets/Presence/_presence_list.tpl b/sources/app/widgets/Presence/_presence_list.tpl index 7f7bda5..f9e8010 100644 --- a/sources/app/widgets/Presence/_presence_list.tpl +++ b/sources/app/widgets/Presence/_presence_list.tpl @@ -56,24 +56,6 @@
-
    -
  • -

    {$c->__('status.disconnect')}

    -
  • -
  • - -

    {$c->__('status.disconnect')}

    -
  • -
-
diff --git a/sources/app/widgets/Presence/presence.css b/sources/app/widgets/Presence/presence.css index fa20eb3..73f08fb 100644 --- a/sources/app/widgets/Presence/presence.css +++ b/sources/app/widgets/Presence/presence.css @@ -1,159 +1,11 @@ form[name=presence] ul { margin: 0 -2rem; } -/* -form[name=presence] li { - padding-left: 7rem; + +#presence_widget { + min-width: 20rem; } -form[name=presence] li span.icon { - left: 1rem; -}*/ -/*#presence_widget { - max-width: 15rem; - position: fixed; - top: 0; - right: 0; - z-index: 4; - padding: 0.3em; - box-sizing: border-box; +#presence_widget li { + padding: 2.5rem 0; } - -#presence_widget img.avatar { - width: 2em; - float: left; - border-radius: 3em; - position: relative; - margin-right: 1em; -} - -#presence_widget span.bubble { - left: 1.4em; - top: 1.4em; - width: 0.9em; - height: 0.9em; - box-shadow: 0 0 2px rgba(0, 0, 0, 1); - border-radius: 2em; - display: inline-block; - position: absolute; -} - -#presence_widget .online span.bubble { background-color: #6FCC43; } -#presence_widget .away span.bubble { background-color: #FFE433; } -#presence_widget .dnd span.bubble { background-color: #D92727; } -#presence_widget .xa span.bubble { background-color: #442178; } - -#presence_widget #tab { - color: white; - height: 2.5em; - padding: 0.2em; - width: 14.4rem; - box-sizing: border-box; - float: right; - position: relative; -} - -#presence_widget #tab:hover { - cursor: pointer; - border-radius: 0.05em; - background-color: rgba(255, 255, 255, 0.2); -} - -#presence_widget span.arrow { - float: right; - padding-right: 0.5em; - line-height: 2em; -} - -#presence_widget span.name, -#presence_widget span.status { - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - width: calc(100% - 6em); - display: inline-block; -} - -#presence_widget span.status { - font-weight: normal; - font-size: 0.8em; - color: #DDD; - display: block; -} - -#presence_widget #list { - width: 14.4rem; - background-color: white; - display: none; - z-index: 6; -} - -#presence_widget #list .tab { - padding: 0.2em; -} - -#presence_widget #list .tab span.name { - line-height: 2em; -} - -#presence_widget #list .tab:hover { - cursor: pointer; - border-radius: 0.1em; -} - -#presence_widget.unfolded #tab { - display: none; -} - -#presence_widget.unfolded #list { - display: block; - border-radius: 0.1em; - box-shadow: 0 0 0.3em rgba(0, 0, 0, 0.4); -} - -#presence_widget textarea.status { - margin: 0.5em 0; - padding: 0.5em; - box-sizing: border-box; - border: 0; - width: 100%; - border-bottom: 1px solid #D4D4D4; - height: 2.7em; - resize: none; -} - -@media screen and (max-width: 1024px) { - #presence_widget #tab { - width: auto; - } -} - -#presence_widget #list a { - position: relative; - clear: both; - display: block; - font-weight: normal; - line-height: 2.8em; - padding: 0 1em; -} - -#presence_widget #list a:hover { - cursor: pointer; - background-color: rgba(0, 0, 0, 0.05); -} - -#presence_widget #list a i { - float: right; - line-height: 2.8em; - margin: 0; -} - -#presence_widget #list span.bubble { - box-shadow: none; - box-shadow: 0 0 2px rgba(0, 0, 0, 0.1); - display: inline-block; - float: right; - margin-top: 1em; - position: initial; -} -*/ diff --git a/sources/app/widgets/Presence/presence.js b/sources/app/widgets/Presence/presence.js index af92c58..9bb23da 100644 --- a/sources/app/widgets/Presence/presence.js +++ b/sources/app/widgets/Presence/presence.js @@ -1,20 +1,3 @@ -function postStart() { - if(localStorage.postStart == 1) { - // We disable the notifications for a couple of seconds - Notification.inhibit(10); - - Presence_ajaxSet(); - //Presence_ajaxConfigGet(); - Presence_ajaxServerCapsGet(); - Presence_ajaxBookmarksGet(); - Presence_ajaxUserRefresh(); - Presence_ajaxFeedRefresh(); - Presence_ajaxServerDisco(); - //Menu_ajaxRefresh(); - localStorage.postStart = 0; - } -} - var Presence = { refresh : function() { var textarea = document.querySelector('form[name=presence] textarea'); @@ -37,11 +20,28 @@ var Presence = { } i++; } + }, + + postStart : function() { + if(localStorage.postStart == 1) { + // We disable the notifications for a couple of seconds + Notification.inhibit(10); + + Presence_ajaxSet(); + //Presence_ajaxConfigGet(); + Presence_ajaxServerCapsGet(); + Presence_ajaxBookmarksGet(); + Presence_ajaxUserRefresh(); + Presence_ajaxFeedRefresh(); + Presence_ajaxServerDisco(); + //Menu_ajaxRefresh(); + localStorage.postStart = 0; + } } } MovimWebsocket.attach(function() { Presence.refresh(); - postStart(); + Presence.postStart(); }); diff --git a/sources/app/widgets/Publish/Publish.php b/sources/app/widgets/Publish/Publish.php index 0823545..c527bd7 100644 --- a/sources/app/widgets/Publish/Publish.php +++ b/sources/app/widgets/Publish/Publish.php @@ -24,7 +24,7 @@ use Moxl\Xec\Action\Microblog\CommentCreateNode; use \Michelf\Markdown; use Respect\Validation\Validator; -class Publish extends WidgetBase +class Publish extends \Movim\Widget\Base { function load() { @@ -211,7 +211,6 @@ class Publish extends WidgetBase $p->setLink($form->embed->value); if(in_array($embed->type, array('photo', 'rich'))) { - $key = key($embed->images); $p->setImage($embed->images[0]['value'], $embed->title, $embed->images[0]['mime']); } @@ -285,10 +284,8 @@ class Publish extends WidgetBase $validate_server = Validator::stringType()->noWhitespace()->length(6, 40); $validate_node = Validator::stringType()->length(3, 100); - if(!$validate_server->validate($server) - || !$validate_node->validate($node) - ) return false; - else return true; + return ($validate_server->validate($server) + && $validate_node->validate($node)); } function display() diff --git a/sources/app/widgets/Publish/_publish_create.tpl b/sources/app/widgets/Publish/_publish_create.tpl index ad81df0..ba7d7fb 100644 --- a/sources/app/widgets/Publish/_publish_create.tpl +++ b/sources/app/widgets/Publish/_publish_create.tpl @@ -55,7 +55,7 @@ name="embed" placeholder="http://myawesomewebsite.com/ or http://mynicepictureurl.com/" onpaste="var e=this; setTimeout(function(){Publish_ajaxEmbedTest(e.value);}, 4);" - {if="$attachement != false"}value="{$attachement.href}"{/if} + {if="isset($attachement) && $attachement != false"}value="{$attachement.href}"{/if} > diff --git a/sources/app/widgets/Publish/_publish_preview.tpl b/sources/app/widgets/Publish/_publish_preview.tpl index bce65a1..b957a47 100644 --- a/sources/app/widgets/Publish/_publish_preview.tpl +++ b/sources/app/widgets/Publish/_publish_preview.tpl @@ -11,6 +11,6 @@
- {$c->__('button.cancel')} + {$c->__('button.close')}
diff --git a/sources/app/widgets/Rooms/Rooms.php b/sources/app/widgets/Rooms/Rooms.php index 4692941..ebf651e 100644 --- a/sources/app/widgets/Rooms/Rooms.php +++ b/sources/app/widgets/Rooms/Rooms.php @@ -7,7 +7,7 @@ use Moxl\Xec\Action\Presence\Unavailable; use Respect\Validation\Validator; -class Rooms extends WidgetBase +class Rooms extends \Movim\Widget\Base { function load() { @@ -58,7 +58,6 @@ class Rooms extends WidgetBase { $view = $this->tpl(); - $cd = new \Modl\ContactDAO; $view->assign('username', $this->user->getUser()); Dialog::fill($view->draw('_rooms_add', true)); @@ -188,15 +187,17 @@ class Rooms extends WidgetBase $sd = new \modl\SubscriptionDAO(); $cd = new \modl\ConferenceDAO(); - foreach($sd->getSubscribed() as $s) { - array_push($arr, - array( - 'type' => 'subscription', - 'server' => $s->server, - 'title' => $s->title, - 'subid' => $s->subid, - 'tags' => unserialize($s->tags), - 'node' => $s->node)); + if($sd->getSubscribed()) { + foreach($sd->getSubscribed() as $s) { + array_push($arr, + array( + 'type' => 'subscription', + 'server' => $s->server, + 'title' => $s->title, + 'subid' => $s->subid, + 'tags' => unserialize($s->tags), + 'node' => $s->node)); + } } foreach($cd->getAll() as $c) { diff --git a/sources/app/widgets/Rooms/_rooms.tpl b/sources/app/widgets/Rooms/_rooms.tpl index 481e660..e41a090 100644 --- a/sources/app/widgets/Rooms/_rooms.tpl +++ b/sources/app/widgets/Rooms/_rooms.tpl @@ -36,7 +36,7 @@

{$c->__('room.anonymous_title')}

{$c->__('room.anonymous_login', $room)}

-