Browse Source

- Use the username instead of the true name when adding a chatroom

pull/56/head
Jaussoin Timothée 10 years ago
parent
commit
a30bb591f1
  1. 24
      app/widgets/Rooms/Rooms.php
  2. 2
      app/widgets/Rooms/_rooms_add.tpl
  3. 9
      system/User.php

24
app/widgets/Rooms/Rooms.php

@ -52,7 +52,7 @@ class Rooms extends WidgetBase
$view = $this->tpl(); $view = $this->tpl();
$cd = new \Modl\ContactDAO; $cd = new \Modl\ContactDAO;
$view->assign('me', $cd->get());
$view->assign('username', $this->user->getUser());
Dialog::fill($view->draw('_rooms_add', true)); Dialog::fill($view->draw('_rooms_add', true));
} }
@ -95,7 +95,7 @@ class Rooms extends WidgetBase
$cd = new \modl\ConferenceDAO(); $cd = new \modl\ConferenceDAO();
$cd->deleteNode($room); $cd->deleteNode($room);
$this->setBookmark(); $this->setBookmark();
} }
@ -151,7 +151,7 @@ class Rooms extends WidgetBase
/** /**
* @brief Confirm the room add * @brief Confirm the room add
*/ */
function ajaxChatroomAdd($form)
function ajaxChatroomAdd($form)
{ {
if(!filter_var($form['jid'], FILTER_VALIDATE_EMAIL)) { if(!filter_var($form['jid'], FILTER_VALIDATE_EMAIL)) {
Notification::append(null, $this->__('chatrooms.bad_nickname')); Notification::append(null, $this->__('chatrooms.bad_nickname'));
@ -163,20 +163,20 @@ class Rooms extends WidgetBase
'name' => $form['name'], 'name' => $form['name'],
'autojoin' => $form['autojoin'], 'autojoin' => $form['autojoin'],
'nick' => $form['nick'], 'nick' => $form['nick'],
'jid' => $form['jid']);
'jid' => $form['jid']);
$this->setBookmark($item); $this->setBookmark($item);
RPC::call('Dialog.clear'); RPC::call('Dialog.clear');
} }
} }
public function setBookmark($item = false)
public function setBookmark($item = false)
{ {
$arr = array(); $arr = array();
if($item) { if($item) {
array_push($arr, $item); array_push($arr, $item);
} }
$sd = new \modl\SubscriptionDAO(); $sd = new \modl\SubscriptionDAO();
$cd = new \modl\ConferenceDAO(); $cd = new \modl\ConferenceDAO();
@ -188,7 +188,7 @@ class Rooms extends WidgetBase
'title' => $s->title, 'title' => $s->title,
'subid' => $s->subid, 'subid' => $s->subid,
'tags' => unserialize($s->tags), 'tags' => unserialize($s->tags),
'node' => $s->node));
'node' => $s->node));
} }
foreach($cd->getAll() as $c) { foreach($cd->getAll() as $c) {
@ -198,10 +198,10 @@ class Rooms extends WidgetBase
'name' => $c->name, 'name' => $c->name,
'autojoin' => $c->autojoin, 'autojoin' => $c->autojoin,
'nick' => $c->nick, 'nick' => $c->nick,
'jid' => $c->conference));
'jid' => $c->conference));
} }
$b = new Set; $b = new Set;
$b->setArr($arr) $b->setArr($arr)
->setTo($this->user->getLogin()) ->setTo($this->user->getLogin())
@ -243,7 +243,7 @@ class Rooms extends WidgetBase
} }
/** /**
* @brief Validate the room
* @brief Validate the room
* *
* @param string $room * @param string $room
*/ */
@ -255,7 +255,7 @@ class Rooms extends WidgetBase
} }
/** /**
* @brief Validate the resource
* @brief Validate the resource
* *
* @param string $resource * @param string $resource
*/ */

2
app/widgets/Rooms/_rooms_add.tpl

@ -11,7 +11,7 @@
<label>{$c->__('chatrooms.name')}</label> <label>{$c->__('chatrooms.name')}</label>
</div> </div>
<div> <div>
<input name="nick" placeholder="{$me->getTrueName()}" value="{$me->getTrueName()}"/>
<input name="nick" placeholder="{$username}" value="{$username}"/>
<label>{$c->__('chatrooms.nickname')}</label> <label>{$c->__('chatrooms.nickname')}</label>
</div> </div>
<!-- <!--

9
system/User.php

@ -38,9 +38,6 @@ class User {
if($session->active) { if($session->active) {
$this->username = $session->user.'@'.$session->host; $this->username = $session->user.'@'.$session->host;
//$this->reload();
//$this->sizelimit = (int)$config->sizelimit;
$this->userdir = DOCUMENT_ROOT.'/users/'.$this->username.'/'; $this->userdir = DOCUMENT_ROOT.'/users/'.$this->username.'/';
$this->useruri = BASE_URI.'users/'.$this->username.'/'; $this->useruri = BASE_URI.'users/'.$this->username.'/';
} }
@ -144,6 +141,12 @@ class User {
return $exp['server']; return $exp['server'];
} }
function getUser()
{
$exp = explodeJid($this->username);
return $exp['username'];
}
function getPass() function getPass()
{ {
return $this->password; return $this->password;

Loading…
Cancel
Save