diff --git a/README.md b/README.md index 2240618..faeb197 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,4 @@ DO NOT USE **Changelog** -Current Movim version : 20150731. +Current Movim version : 20150810. diff --git a/scripts/install b/scripts/install index 3e6bc31..eca57e5 100644 --- a/scripts/install +++ b/scripts/install @@ -49,10 +49,9 @@ sudo su -c "cd $final_path && php composer.phar install" -s /bin/sh www-data # Movim configuration sudo cp $final_path/config/db.example.inc.php $final_path/config/db.inc.php -sudo sed -i "s/yhuser/$db_user/g" $final_path/config/db.inc.php -sudo sed -i "s/yhpwd/$db_pwd/g" $final_path/config/db.inc.php -sudo sed -i "s/yhdb/$db_user/g" $final_path/config/db.inc.php -sudo sed -i "s@PATHTOCHANGE@$path@g" $final_path/app/assets/js/movim_websocket.js +sudo sed -i "s@username@$db_user@g" $final_path/config/db.inc.php +sudo sed -i "s@password@$db_pwd@g" $final_path/config/db.inc.php +sudo sed -i "s@/ws/@$path/ws/" $final_path/app/assets/js/movim_websocket.js sudo su -c "cd $final_path && php mud.php db set" -s /bin/sh www-data sudo su -c "cd $final_path && php mud.php config locale:$language" sudo su -c "cd $final_path && php mud.php config loglevel:1" diff --git a/sources/.bzrignore b/sources/.bzrignore new file mode 100755 index 0000000..2ce4fb1 --- /dev/null +++ b/sources/.bzrignore @@ -0,0 +1,14 @@ +*~ +*#* +cache.tmp +log/* +locales/files.list +*.pdf +*.swp + +./cache +./config/* +./lib/Modl +./lib/Moxl +./users/* +./log diff --git a/sources/.dir-locals.el b/sources/.dir-locals.el new file mode 100755 index 0000000..b6f02a6 --- /dev/null +++ b/sources/.dir-locals.el @@ -0,0 +1,4 @@ +((nil . ((indent-tabs-mode . nil) + (tab-width . 4) + (fill-column . 80))) + (c-mode . ((c-file-style . "stroustrup")))) diff --git a/sources/.gitignore b/sources/.gitignore new file mode 100644 index 0000000..35caf9b --- /dev/null +++ b/sources/.gitignore @@ -0,0 +1,8 @@ +/vendor +/log +/users +/cache +*~ +/config/db.inc.php +/composer.lock +/composer.phar diff --git a/sources/.htaccess b/sources/.htaccess new file mode 100755 index 0000000..740d33a --- /dev/null +++ b/sources/.htaccess @@ -0,0 +1,22 @@ +Options -Indexes +AddType application/x-web-app-manifest+json .webapp + + # Tell PHP that the mod_rewrite module is ENABLED. + SetEnv HTTP_MOD_REWRITE 1 + + # If you have troubles or use VirtualDocumentRoot + # uncomment this and set it to the path where your Movim installation is + # i.e.: + # Movim url: http://example.com + # RewriteBase / + # Movim url: http://some.example.com/movim + # RewriteBase /movim/ + + RewriteBase /0.9/ + RewriteEngine On + + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule (.*) index.php?query=$1 [L] + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + diff --git a/sources/app/assets/js/movim_tpl.js b/sources/app/assets/js/movim_tpl.js index 7965b78..8566332 100755 --- a/sources/app/assets/js/movim_tpl.js +++ b/sources/app/assets/js/movim_tpl.js @@ -1,6 +1,6 @@ /** * Movim Javascript Template functions - * + * * These are the default callback functions that users may (or may not) use. * * Note that all of them take only one parameter. Don't be fooled by this, the @@ -86,6 +86,13 @@ var MovimTpl = { return false; } }, + isPanelScrolled : function() { + var selector = document.querySelector('main section > div:first-child:nth-last-child(2) ~ div div'); + + if(selector != null) { + return (selector.scrollHeight - selector.scrollTop === selector.clientHeight); + } + }, scrollPanel : function() { var selector = document.querySelector('main section > div:first-child:nth-last-child(2) ~ div div'); @@ -116,9 +123,12 @@ var MovimTpl = { return; } - //if(!document.querySelector(element).contains(e.target)) + //if(!document.querySelector(element).contains(e.target)) movim_remove_class(element, classname); }, + toggleActionButton : function() { + movim_toggle_class('.button.action', 'active'); + }, hideContextMenu : function() { movim_remove_class('ul.context_menu', 'shown'); }, diff --git a/sources/app/assets/js/movim_websocket.js b/sources/app/assets/js/movim_websocket.js index 74c7824..8c29b18 100755 --- a/sources/app/assets/js/movim_websocket.js +++ b/sources/app/assets/js/movim_websocket.js @@ -41,9 +41,9 @@ var MovimWebsocket = { init : function() { if(SECURE_WEBSOCKET) { - var uri = 'wss://' + BASE_HOST + 'PATHTOCHANGE/ws/'; + var uri = 'wss://' + BASE_HOST + '/ws/'; } else { - var uri = 'ws://' + BASE_HOST + 'PATHTOCHANGE/ws/'; + var uri = 'ws://' + BASE_HOST + '/ws/'; } this.connection = new WebSocket(uri); diff --git a/sources/app/helpers/StringHelper.php b/sources/app/helpers/StringHelper.php index bd3fb5d..3bd3ff3 100755 --- a/sources/app/helpers/StringHelper.php +++ b/sources/app/helpers/StringHelper.php @@ -309,7 +309,7 @@ function stringToColor($string) { } /** - * Return the first letter of a string + * Return the first two letters of a string * @param string * @return string */ diff --git a/sources/app/models/config/Config.php b/sources/app/models/config/Config.php index 1c283d6..7d72bdb 100755 --- a/sources/app/models/config/Config.php +++ b/sources/app/models/config/Config.php @@ -2,8 +2,7 @@ namespace Modl; -class Config extends Model { - public $environment; +class Config extends Model { public $description; public $theme; public $locale; @@ -17,43 +16,40 @@ class Config extends Model { public $password; public $rewrite; public $sizelimit; - + public function __construct() { $this->_struct = ' { - "environment" : - {"type":"string", "size":64, "mandatory":true }, - "description" : + "description" : {"type":"text" }, - "theme" : + "theme" : {"type":"string", "size":32, "mandatory":true }, - "locale" : + "locale" : {"type":"string", "size":8, "mandatory":true }, - "maxusers" : + "maxusers" : {"type":"int", "size":16 }, - "loglevel" : + "loglevel" : {"type":"string", "size":16, "mandatory":true }, - "timezone" : + "timezone" : {"type":"string", "size":16, "mandatory":true }, - "xmppwhitelist" : + "xmppwhitelist" : {"type":"text" }, - "info" : + "info" : {"type":"text" }, - "unregister" : + "unregister" : {"type":"int", "size":1 }, - "username" : + "username" : {"type":"string", "size":32, "mandatory":true }, - "password" : + "password" : {"type":"string", "size":64, "mandatory":true }, - "rewrite" : + "rewrite" : {"type":"int", "size":1 }, - "sizelimit" : + "sizelimit" : {"type":"int", "size":16 } }'; - + parent::__construct(); - $this->environment = 'development'; $this->description = __('global.description'); $this->theme = 'material'; $this->locale = 'en'; diff --git a/sources/app/models/config/ConfigDAO.php b/sources/app/models/config/ConfigDAO.php index 2056503..e6b1d61 100755 --- a/sources/app/models/config/ConfigDAO.php +++ b/sources/app/models/config/ConfigDAO.php @@ -6,8 +6,7 @@ class ConfigDAO extends SQL { function set(Config $c) { $this->_sql = ' update config - set environment = :environment, - description = :description, + set description = :description, theme = :theme, locale = :locale, maxusers = :maxusers, @@ -20,11 +19,10 @@ class ConfigDAO extends SQL { password = :password, rewrite = :rewrite, sizelimit = :sizelimit'; - + $this->prepare( - 'Config', - array( - 'environment' => $c->environment, + 'Config', + array( 'description' => $c->description, 'theme' => $c->theme, 'locale' => $c->locale, @@ -40,25 +38,24 @@ class ConfigDAO extends SQL { 'sizelimit' => $c->sizelimit ) ); - + $this->run('Config'); - + if(!$this->_effective) { $this->_sql = ' truncate table config;'; $this->prepare( - 'Config', + 'Config', array( ) ); - + $this->run('Config'); - + $this->_sql = ' insert into config ( - environment, description, theme, locale, @@ -75,7 +72,6 @@ class ConfigDAO extends SQL { ) values ( - :environment, :description, :theme, :locale, @@ -91,11 +87,10 @@ class ConfigDAO extends SQL { :sizelimit ) '; - + $this->prepare( - 'Config', + 'Config', array( - 'environment' => $c->environment, 'description' => $c->description, 'theme' => $c->theme, 'locale' => $c->locale, @@ -111,7 +106,7 @@ class ConfigDAO extends SQL { 'sizelimit' => $c->sizelimit ) ); - + $this->run('Config'); } } @@ -121,7 +116,7 @@ class ConfigDAO extends SQL { select * from config'; $this->prepare('Config', array()); - + $conf = $this->run('Config', 'item'); if(!isset($conf)) diff --git a/sources/app/models/postn/Postn.php b/sources/app/models/postn/Postn.php index 3e88e0f..7a948cc 100755 --- a/sources/app/models/postn/Postn.php +++ b/sources/app/models/postn/Postn.php @@ -84,6 +84,24 @@ class Postn extends Model { parent::__construct(); } + private function getContent($contents) { + $content = ''; + foreach($contents as $c) { + switch($c->attributes()->type) { + case 'html': + case 'xhtml': + return (string)$c->asXML(); + break; + case 'text': + default : + $content = (string)$c; + break; + } + } + + return $content; + } + public function set($item, $from, $delay = false, $node = false) { if($item->item) $entry = $item->item; @@ -125,16 +143,7 @@ class Postn extends Model { $summary = ''; if($entry->entry && $entry->entry->content) { - if((string)$entry->entry->content->attributes()->type == 'text') - $content = (string)$entry->entry->content; - elseif( - (string)$entry->entry->content->attributes()->type == ('html' || 'xhtml') - //&& $entry->entry->content->html - //&& $entry->entry->content->html->body - ) { - $content = (string)$entry->entry->content/*->html->body*/->asXML(); - } else - $content = (string)$entry->entry->content; + $content = $this->getContent($entry->entry->content); } elseif($summary == '') $content = __(''); else diff --git a/sources/app/widgets/AdminMain/AdminMain.php b/sources/app/widgets/AdminMain/AdminMain.php index aa72959..9ec3d7f 100755 --- a/sources/app/widgets/AdminMain/AdminMain.php +++ b/sources/app/widgets/AdminMain/AdminMain.php @@ -14,7 +14,7 @@ * * See COPYING for licensing information. */ - + class AdminMain extends WidgetBase { function load() { @@ -46,7 +46,7 @@ class AdminMain extends WidgetBase } $cd->set($config); - + //set timezone if(isset($form['timezone'])) { date_default_timezone_set($form['timezone']); @@ -71,7 +71,7 @@ class AdminMain extends WidgetBase { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); - + $this->view->assign('conf', $cd->get()); $this->view->assign('logs', array( @@ -79,11 +79,6 @@ class AdminMain extends WidgetBase 1 => $this->__('log.syslog'), 2 => $this->__('log.syslog_files')) ); - $this->view->assign('envs', - array( - 'development' => 'Development', - 'production' => 'Production') - ); $this->view->assign('bosh_info4', $this->__('bosh.info4', '', '')); @@ -99,7 +94,7 @@ class AdminMain extends WidgetBase if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) { $this->view->assign('server_rewrite', true); } - + $this->view->assign('timezones', getTimezoneList()); $this->view->assign('langs', loadLangArray()); } diff --git a/sources/app/widgets/AdminMain/adminmain.tpl b/sources/app/widgets/AdminMain/adminmain.tpl index ed2c23c..79de4cd 100755 --- a/sources/app/widgets/AdminMain/adminmain.tpl +++ b/sources/app/widgets/AdminMain/adminmain.tpl @@ -7,7 +7,7 @@
'; - {loop="$envs"} - - {/loop} - -
- - + {if="!$c->version()"}
  • @@ -121,11 +112,10 @@ {if="!$_SERVER['HTTP_MOD_REWRITE']"}
  • - + {$c->__('compatibility.rewrite')}
  • {/if} - diff --git a/sources/app/widgets/Api/Api.php b/sources/app/widgets/Api/Api.php index dbf47aa..1a36ad3 100755 --- a/sources/app/widgets/Api/Api.php +++ b/sources/app/widgets/Api/Api.php @@ -14,7 +14,7 @@ * * See COPYING for licensing information. */ - + class Api extends WidgetBase { function load() { @@ -30,7 +30,7 @@ class Api extends WidgetBase { '', '', '')); - + $json = requestURL(MOVIM_API.'status', 1, array('uri' => BASE_URI)); $json = json_decode($json); @@ -55,10 +55,15 @@ class Api extends WidgetBase { function ajaxRegister() { $rewrite = false; - if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) { + + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + + if($config->rewrite/*isset($_SERVER['HTTP_MOD_REWRITE']) + && $_SERVER['HTTP_MOD_REWRITE']*/) { $rewrite = true; - } - + } + $json = requestURL( MOVIM_API.'register', 1, @@ -78,7 +83,7 @@ class Api extends WidgetBase { { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); - + $config->unregister = !$config->unregister; $cd->set($config); diff --git a/sources/app/widgets/Chat/Chat.php b/sources/app/widgets/Chat/Chat.php index 8ade9af..85ee764 100644 --- a/sources/app/widgets/Chat/Chat.php +++ b/sources/app/widgets/Chat/Chat.php @@ -75,7 +75,7 @@ class Chat extends WidgetBase Notification::append('chat|'.$from, $contact->getTrueName(), $message->body, $avatar, 4); } - RPC::call('movim_fill', $from.'_state', ''); + RPC::call('movim_fill', $from.'_state', $contact->jid); // If the message is from me } /*else { $from = $message->jidto; @@ -90,7 +90,6 @@ class Chat extends WidgetBase if(!preg_match('#^\?OTR#', $message->body)) { RPC::call('Chat.appendMessage', $this->prepareMessage($message)); } - RPC::call('MovimTpl.scrollPanel'); } function onComposing($array) @@ -154,7 +153,7 @@ class Chat extends WidgetBase $html = $view->draw('_chat_state', true); RPC::call('movim_fill', $jid.'_state', $html); - RPC::call('MovimTpl.scrollPanel'); + //RPC::call('MovimTpl.scrollPanel'); } /** diff --git a/sources/app/widgets/Chat/_chat.tpl b/sources/app/widgets/Chat/_chat.tpl index 1b17234..20a2bd5 100644 --- a/sources/app/widgets/Chat/_chat.tpl +++ b/sources/app/widgets/Chat/_chat.tpl @@ -2,7 +2,6 @@
    -
    -