Browse Source

- Echap JID on several functions to support transported contacts

- Move addContact to ContactInfo and split the function in two (roster + presence)
- CSS fix
pull/16/head
Jaussoin Timothée 13 years ago
parent
commit
75bbba3010
  1. 8
      app/widgets/Chat/Chat.php
  2. 37
      app/widgets/ContactInfo/ContactInfo.php
  3. 1
      app/widgets/ContactSummary/ContactSummary.php
  4. 78
      app/widgets/Feed/Feed.php
  5. 19
      app/widgets/Login/Login.php
  6. 20
      app/widgets/Roster/Roster.php
  7. 2
      index.php
  8. 38
      system/Logger.php
  9. 4
      system/Route.php
  10. 4
      themes/movim/css/posts.css
  11. 1
      themes/movim/main.tpl

8
app/widgets/Chat/Chat.php

@ -188,7 +188,7 @@ class Chat extends WidgetBase
$contact->chaton = 2;
$rd = new \modl\RosterLinkDAO();
$rd->setChat($jid, 2);
$rd->setChat(echapJid($jid), 2);
RPC::call('movim_prepend',
'chats',
@ -277,7 +277,7 @@ class Chat extends WidgetBase
foreach($contacts as $contact) {
if(
$contact->jid == $jid
$contact->jid == echapJid($jid)
&& (
(int)$contact->chaton == 1
|| (int)$contact->chaton == 2)
@ -288,7 +288,7 @@ class Chat extends WidgetBase
}
RPC::call('movim_delete',
'chat'.$jid);
'chat'.echapJid($jid));
$evt = new Event();
$evt->runEvent('closechat');
@ -348,7 +348,7 @@ class Chat extends WidgetBase
function prepareChat($contact)
{
$md = new \modl\MessageDAO();
$messages = $md->getContact($contact->jid, 0, 10);
$messages = $md->getContact(echapJid($contact->jid), 0, 10);
if(!empty($messages)) {
$day = '';

37
app/widgets/ContactInfo/ContactInfo.php

@ -20,20 +20,37 @@
class ContactInfo extends WidgetCommon
{
function WidgetLoad() {
/**
* @brief Adding a new contact
* @param $jid
* @param $alias
* @returns
*/
function ajaxAddContact($jid) {
$r = new moxl\RosterAddItem();
$r->setTo($jid)
->setFrom($this->user->getLogin())
->request();
}
function ajaxSubscribeContact($jid) {
$p = new moxl\PresenceSubscribe();
$p->setTo($jid)
->request();
}
function ajaxRemoveContact($jid) {
$r = new moxl\RosterRemoveItem();
$r->setTo($jid)
->request();
}
function ajaxUnsubscribeContact($jid) {
$p = new moxl\PresenceUnsubscribe();
$p->setTo($jid)
->request();
}
function prepareContactInfo()
{
@ -173,8 +190,10 @@ class ContactInfo extends WidgetCommon
$html .= '"
id="friendremoveyes"
style="margin: 1em 0px; float: left; display: none;"
onclick="'.$this->genCallAjax("ajaxRemoveContact", "'".$_GET['f']."'")
. 'this.className=\'button color green icon loading merged left\'; setTimeout(function() {location.reload(false)}, 2000);"
onclick="'.
$this->genCallAjax("ajaxRemoveContact", "'".$_GET['f']."'").
$this->genCallAjax("ajaxUnsubscribeContact", "'".$_GET['f']."'").
'this.className=\'button color green icon loading merged left\'; setTimeout(function() {location.reload(false)}, 2000);"
>
'.t('Yes').'
</a>
@ -198,8 +217,10 @@ class ContactInfo extends WidgetCommon
$html .='
<a
class="button color purple icon add"
onclick="'.$this->genCallWidget("Roster","ajaxAddContact", "'".$_GET['f']."'", "''")
. 'this.className=\'button color purple icon loading merged left\'; setTimeout(function() {location.reload(false)}, 2000);"
onclick="'.
$this->genCallAjax("ajaxAddContact", "'".$_GET['f']."'").
$this->genCallAjax("ajaxSubscribeContact", "'".$_GET['f']."'").
'this.className=\'button color purple icon loading merged left\'; setTimeout(function() {location.reload(false)}, 2000);"
>
'.t('Invite this user').'
</a>';

1
app/widgets/ContactSummary/ContactSummary.php

@ -76,7 +76,6 @@ class ContactSummary extends WidgetCommon
function build()
{
$cd = new modl\ContactDAO();
if($_GET['f'] == $this->user->getLogin())
$contact = $cd->get($this->user->getLogin());

78
app/widgets/Feed/Feed.php

@ -65,10 +65,12 @@ class Feed extends WidgetCommon {
}
function onPostPublished($post) {
$pd = new \modl\PostnDAO();
/*$pd = new \modl\PostnDAO();
$pl = $pd->getFeed(-1, $this->_feedsize);
$html = $this->preparePosts($pl);
$html = $this->preparePosts($pl);*/
$html = $this->prepareFeeds();
RPC::call('createCommentNode', $post->nodeid);
RPC::call('movim_fill', 'feedcontent', $html);
@ -119,40 +121,72 @@ class Feed extends WidgetCommon {
return $html;
}
function prepareFeed($start) {
$pd = new \modl\PostnDAO();
$pl = $pd->getFeed($start+1, $this->_feedsize);
$html = $this->preparePosts($pl);
// We ask for the HTML of all the posts
function prepareNext($start, $html = '', $posts, $function = 'ajaxGetFeed') {
// We ask for the HTML of all the posts
$next = $start + $this->_feedsize;
if(sizeof($pl) > $this->_feedsize-1 && $html != '') {
$html .= '
if(sizeof($posts) > $this->_feedsize-1 && $html != '') {
$nexthtml = '
<div class="post">
<div
class="older"
onclick="'.$this->genCallAjax('ajaxGetFeed', "'".$next."'").'; this.parentNode.style.display = \'none\'">'.
onclick="'.$this->genCallAjax($function, "'".$next."'").'; this.parentNode.style.display = \'none\'">'.
t('Get older posts').'
</div>
</div>';
}
}
return $nexthtml;
}
function prepareFeed($start) {
$pd = new \modl\PostnDAO();
$pl = $pd->getFeed($start+1, $this->_feedsize);
$html = $this->preparePosts($pl);
$html .= $this->prepareNext($start, $html, $pl, 'ajaxGetFeed');
return $html;
}
function prepareNews($start) {
$pd = new \modl\PostnDAO();
$pl = $pd->getNews($start+1, $this->_feedsize);
$html = $this->preparePosts($pl);
$html .= $this->prepareNext($start, $html, $pl, 'ajaxGetNews');
return $html;
}
function prepareFeeds() {
$html = '
<div class="tabelem" id="feedposts" title="'.t('Feed').'">
'.$this->prepareFeed(-1).'
</div>
<div class="tabelem" id="newsposts" title="'.t('News').'">
'.$this->prepareNews(-1).'
</div>';
return $html;
}
function ajaxGetFeed($start) {
$html = $this->prepareFeed($start);
RPC::call('movim_append', 'feedcontent', $html);
RPC::call('movim_append', 'feedposts', $html);
RPC::commit();
}
function ajaxGetNews($start) {
$html = $this->prepareNews($start);
RPC::call('movim_append', 'newsposts', $html);
RPC::commit();
}
function onStream($payload) {
$html = '';
$html = $this->prepareFeed(-1);
$html = $this->prepareFeeds();
if($html == '')
$html = '
@ -193,11 +227,7 @@ class Feed extends WidgetCommon {
target="_blank">
<?php echo t('Feed'); ?> (Atom)
</a>
<!--<ul class="filters">
<li class="on" onclick="showPosts(this, false);"><?php echo t('All');?></li>
<li onclick="showPosts(this, true);"><?php echo t('My Posts');?></li>
</ul>-->
<a
class="button color purple icon user oppose"
href="<?php echo Route::urlize('friend',$this->user->getLogin()); ?>">
@ -206,9 +236,7 @@ class Feed extends WidgetCommon {
</div>
<div id="feedcontent">
<?php
echo $this->prepareFeed(-1);
?>
<?php echo $this->prepareFeeds(); ?>
</div>
</div>
<?php

19
app/widgets/Login/Login.php

@ -259,18 +259,25 @@ class Login extends WidgetBase {
<div class="message warning">
'.$conf['info'].'
</div> ';
}
}
$submitevent = '
document.getElementById(\'submitb\').click();
'.$submit.'
loginButtonSet(\''.t('Connecting...').'\', true);
this.onclick=null;';
?>
<form
name="login"
id="connectform"
autocomplete="on"
target="passwordiframe"
method="POST"
action="blank.php"
onkeypress="
if(event.keyCode == 13) {
<?php echo $submit; ?> loginButtonSet('<?php echo t('Connecting...');?>', true); this.onclick=null;}">
<?php echo $submitevent; ?>
}"
>
<div class="element">
<input type="email" name="login" id="login" autofocus required
placeholder="<?php echo t("My address"); ?>"/>
@ -282,12 +289,12 @@ class Login extends WidgetBase {
<div class="element">
<a
class="button color green icon yes"
onclick="<?php echo $submit; ?> loginButtonSet('<?php echo t('Connecting...');?>', true); this.onclick=null;"
onclick="<?php echo $submitevent; ?>"
id="submit"
name="submit"><?php echo t("Come in!"); ?></a>
</div>
<input style="display: none;" type="submit" id="submitb" name="submitb" value="submit"/>
<input type="submit" id="submitb" name="submitb" value="submit" style="display: none;"/>
<div class="clear"></div>
@ -325,7 +332,7 @@ class Login extends WidgetBase {
</form>
<?php
<?php
}
?>

20
app/widgets/Roster/Roster.php

@ -226,25 +226,7 @@ class Roster extends WidgetBase
return $html;
}
/**
* @brief Adding a new contact from the Rostermenu
* @param $jid
* @param $alias
* @returns
*
*
*/
function ajaxAddContact($jid, $alias) {
$r = new moxl\RosterAddItem();
$r->setTo($jid)
->request();
$p = new moxl\PresenceSubscribe();
$p->setTo($jid)
->request();
}
/**
* @brief Toggling boolean variables in the Cache
* @param $param

2
index.php

@ -53,4 +53,6 @@ WidgetWrapper::getInstance(false);
// Closing stuff
WidgetWrapper::destroyInstance();
echo Logger::displayLog();
?>

38
system/Logger.php

@ -7,7 +7,7 @@
*/
class Logger
{
public static $logfilename = "log/movim.log";
/*public static $logfilename = "log/movim.log";
// Predefined log levels
const LOGLEVEL_CRITICAL = 0;
@ -30,5 +30,41 @@ class Logger
fwrite($lfp, date('H:i:s').' '.$message."\n");
fclose($lfp);
}
}*/
private static $logs = array();
public static function log($message)
{
self::addLog($message);
openlog('movim', LOG_NDELAY, LOG_USER);
$errlines = explode("\n",$message);
foreach ($errlines as $txt) { syslog(LOG_DEBUG, trim($txt)); }
closelog();
}
public static function addLog($message)
{
array_push(self::$logs,$message);
}
public static function getLog()
{
return self::$logs;
}
public static function displayLog()
{
$logs = self::getLog();
$html = '';
if(!empty($logs)) {
$html = '<div class="message error">';
foreach($logs as $l)
$html .= $l.'<br />';
$html .= '</div>';
}
return $html;
}
}

4
system/Route.php

@ -68,7 +68,7 @@ class Route extends ControllerBase {
if(isset($routes[$page])) {
if($params != false && count($routes[$page]) != count($params))
Logger::log(1, t('Route error, please set all the parameters for the page %s', $page));
Logger::log(t('Route error, please set all the parameters for the page %s', $page));
else {
//We construct a classic URL if the rewriting is disabled
if(!$_SERVER['HTTP_MOD_REWRITE']) {
@ -96,6 +96,6 @@ class Route extends ControllerBase {
return $uri;
}
} else
Logger::log(1, t('Route not set for the page %s', $page));
Logger::log(t('Route not set for the page %s', $page));
}
}

4
themes/movim/css/posts.css

@ -3,9 +3,7 @@
.posthead {
display: block;
width: 100%;
padding: 0em 1.5em;
padding-top: 1em;
padding: 1em 1.5em;
box-sizing: border-box;
-webkit-box-sizing: border-box;

1
themes/movim/main.tpl

@ -14,6 +14,7 @@
</div>
<div id="center">
<?php $this->widget('Tabs');?>
<?php $this->widget('Feed');?>
</div>

Loading…
Cancel
Save