Browse Source
- New widget, LoginAnonymous
- New widget, LoginAnonymous
- New page, room, to login anonymously on XMPP chatrooms - Add a new column in Sessionx model (mechanism)pull/16/head
25 changed files with 336 additions and 63 deletions
-
10app/controllers/RoomController.php
-
5app/models/sessionx/Sessionx.php
-
15app/models/sessionx/SessionxDAO.php
-
1app/views/login.tpl
-
11app/views/room.tpl
-
13app/widgets/Chat/Chat.php
-
48app/widgets/Chat/_chat_header_room.tpl
-
1app/widgets/Chat/chat.js
-
7app/widgets/Chat/chat.tpl
-
5app/widgets/Header/_header_room.tpl
-
23app/widgets/Login/Login.php
-
58app/widgets/LoginAnonymous/LoginAnonymous.php
-
1app/widgets/LoginAnonymous/loginanonymous.tpl
-
5app/widgets/Presence/Presence.php
-
39app/widgets/Rooms/Rooms.php
-
90app/widgets/Rooms/_rooms.tpl
-
2app/widgets/Rooms/_rooms_list.tpl
-
8app/widgets/Rooms/locales.ini
-
35app/widgets/Rooms/rooms.js
-
2linker.php
-
1locales/locales.ini
-
1system/Route.php
-
6system/Sessionx.php
-
4system/User.php
-
8system/widget/WidgetBase.php
@ -0,0 +1,10 @@ |
|||||
|
<?php |
||||
|
|
||||
|
class RoomController extends BaseController { |
||||
|
function load() { |
||||
|
} |
||||
|
|
||||
|
function dispatch() { |
||||
|
$this->page->setTitle(__('page.room')); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
<?php $this->widget('Presence'); ?> |
||||
|
<?php $this->widget('LoginAnonymous'); ?> |
||||
|
<main> |
||||
|
<?php $this->widget('Header');?> |
||||
|
<section> |
||||
|
<div> |
||||
|
<?php $this->widget('Rooms'); ?> |
||||
|
</div> |
||||
|
<?php $this->widget('Chat'); ?> |
||||
|
</section> |
||||
|
</main> |
||||
@ -0,0 +1,5 @@ |
|||||
|
<div> |
||||
|
<span id="menu" class="on_mobile icon active" onclick="MovimTpl.toggleMenu()"><i class="md md-menu"></i></span> |
||||
|
<span class="on_desktop icon"><i class="md md-forum"></i></span> |
||||
|
<h2 class="r1">{$c->__('page.room')}</h2> |
||||
|
</div> |
||||
@ -0,0 +1,58 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use Respect\Validation\Validator; |
||||
|
|
||||
|
class LoginAnonymous extends WidgetBase |
||||
|
{ |
||||
|
function load() |
||||
|
{ |
||||
|
$this->registerEvent('session_start_handle', 'onStart'); |
||||
|
} |
||||
|
|
||||
|
function onStart($packet) |
||||
|
{ |
||||
|
$session = \Sessionx::start(); |
||||
|
$session->load(); |
||||
|
|
||||
|
if($session->mechanism == 'ANONYMOUS') { |
||||
|
RPC::call('Rooms.anonymousJoin'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function display() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
function ajaxLogin($username) |
||||
|
{ |
||||
|
$validate_user = Validator::string()->length(4, 40); |
||||
|
if(!$validate_user->validate($username)) { |
||||
|
Notification::append(null, 'bad username'); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
// We get the Server Configuration
|
||||
|
$cd = new \Modl\ConfigDAO; |
||||
|
$config = $cd->get(); |
||||
|
|
||||
|
$host = 'anonymous.jappix.com'; |
||||
|
$password = 'AmISnowden?'; |
||||
|
|
||||
|
// We try to get the domain
|
||||
|
$domain = \Moxl\Utils::getDomain($host); |
||||
|
|
||||
|
// We launch the XMPP socket
|
||||
|
RPC::call('register', $host); |
||||
|
|
||||
|
// We set the username in the session
|
||||
|
$s = Session::start(); |
||||
|
$s->set('username', $username); |
||||
|
|
||||
|
// We create a new session or clear the old one
|
||||
|
$s = Sessionx::start(); |
||||
|
$s->init($username, $password, $host, $domain); |
||||
|
|
||||
|
\Moxl\Stanza\Stream::init($host); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
|
||||
@ -1,29 +1,67 @@ |
|||||
<ul class="middle divided spaced active"> |
|
||||
<li class="subheader"> |
|
||||
{$c->__('chatrooms.title')} |
|
||||
<span class="info">{$conferences|count}</span> |
|
||||
</li> |
|
||||
{loop="$conferences"} |
|
||||
{$connected = $c->checkConnected($value->conference, $value->nick)} |
|
||||
<li data-jid="{$value->conference}" |
|
||||
{if="$value->nick != null"} data-nick="{$value->nick}" {/if} |
|
||||
class="condensed room {if="$connected"}online{/if}"> |
|
||||
{if="$connected"} |
|
||||
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people"></i></span> |
|
||||
{else} |
|
||||
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people-outline"></i></span> |
|
||||
{/if} |
|
||||
<span>{$value->name}</span> |
|
||||
<p>{$value->conference}</p> |
|
||||
|
{if="!$c->supported('anonymous') && $c->getView() != 'room'"} |
||||
|
<ul class="middle divided spaced active"> |
||||
|
<li class="subheader"> |
||||
|
{$c->__('chatrooms.title')} |
||||
|
<span class="info">{$conferences|count}</span> |
||||
</li> |
</li> |
||||
{/loop} |
|
||||
|
{loop="$conferences"} |
||||
|
{$connected = $c->checkConnected($value->conference, $value->nick)} |
||||
|
<li data-jid="{$value->conference}" |
||||
|
{if="$value->nick != null"} data-nick="{$value->nick}" {/if} |
||||
|
class="condensed room {if="$connected"}online{/if}"> |
||||
|
{if="$connected"} |
||||
|
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people"></i></span> |
||||
|
{else} |
||||
|
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people-outline"></i></span> |
||||
|
{/if} |
||||
|
<span>{$value->name}</span> |
||||
|
<p>{$value->conference}</p> |
||||
|
</li> |
||||
|
{/loop} |
||||
|
|
||||
{if="$conferences == null"} |
|
||||
<li class="condensed"> |
|
||||
<span class="icon green"> |
|
||||
<i class="md md-people-outline"></i> |
|
||||
</span> |
|
||||
<p>{$c->__('rooms.empty_text1')} {$c->__('rooms.empty_text2')}</p> |
|
||||
</li> |
|
||||
|
{if="$conferences == null"} |
||||
|
<li class="condensed"> |
||||
|
<span class="icon green"> |
||||
|
<i class="md md-people-outline"></i> |
||||
|
</span> |
||||
|
<p>{$c->__('rooms.empty_text1')} {$c->__('rooms.empty_text2')}</p> |
||||
|
</li> |
||||
|
{/if} |
||||
|
</ul> |
||||
|
{else} |
||||
|
{if="$c->getView() == 'room'"} |
||||
|
<div class="placeholder icon"> |
||||
|
<h1>{$c->__('room.anonymous_title')}</h1> |
||||
|
<h4>{$c->__('room.anonymous_login', $room)}</h4> |
||||
|
</div> |
||||
|
<ul class="simple divided thick"> |
||||
|
<li> |
||||
|
<form |
||||
|
name="loginanonymous"> |
||||
|
<div> |
||||
|
<input type="text" name="nick" id="nick" required |
||||
|
placeholder="{$c->__('room.nick')}"/> |
||||
|
<label for="nick">{$c->__('room.nick')}</label> |
||||
|
</div> |
||||
|
<div> |
||||
|
<input |
||||
|
type="submit" |
||||
|
value="{$c->__('button.come_in')}" |
||||
|
class="button flat oppose"/> |
||||
|
</div> |
||||
|
</form> |
||||
|
</li> |
||||
|
</ul> |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
Rooms.anonymous_room = '{$room}'; |
||||
|
</script> |
||||
|
|
||||
|
{else} |
||||
|
<div class="placeholder icon"> |
||||
|
<h1>{$c->__('room.anonymous_title')}</h1> |
||||
|
<h4>{$c->__('room.anonymous_text1')}</h4> |
||||
|
<h4>{$c->__('room.anonymous_text2')}</h4> |
||||
|
</div> |
||||
{/if} |
{/if} |
||||
</ul> |
|
||||
|
{/if} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue