Browse Source

- Finish the Account widget (with some bugs)

pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
4e18b0ae45
  1. 2
      app/views/conf.tpl
  2. 29
      app/widgets/Account/Account.php
  3. 18
      app/widgets/Account/_account_remove.tpl
  4. 11
      app/widgets/Account/account.js
  5. 4
      app/widgets/Account/account.tpl
  6. 3
      app/widgets/Account/locales.ini
  7. 2
      system/User.php

2
app/views/conf.tpl

@ -11,7 +11,7 @@
<?php $this->widget('Vcard4');?>
<?php $this->widget('Avatar');?>
<?php $this->widget('Config');?>
<?php //$this->widget('Account');?>
<?php $this->widget('Account');?>
<?php $this->widget('AdHoc');?>
<?php //$this->widget('ConfigData');?>
<?php //$this->widget('PubsubSubscriptionConfig');?>

29
app/widgets/Account/Account.php

@ -8,14 +8,26 @@ class Account extends WidgetBase
{
function load()
{
$this->addjs('account.js');
$this->registerEvent('register_changepassword_handle', 'onPasswordChanged');
$this->registerEvent('register_remove_handle', 'onRemoved');
}
function onPasswordChanged()
{
RPC::call('Account.resetPassword');
Notification::append(null, $this->__('account.password_changed'));
}
function onRemoved()
{
$md = new Modl\MessageDAO;
$mp->clearMessage();
// TODO : fix it
RPC::call('Account.clearAccount');
RPC::call('Presence_ajaxLogout');
}
function ajaxChangePassword($form)
{
$validate = Validator::string()->length(6, 40);
@ -25,23 +37,34 @@ class Account extends WidgetBase
if($validate->validate($p1)
&& $validate->validate($p2)) {
if($p1 == $p2) {
// TODO send the password
$arr = explodeJid($this->user->getLogin());
$cp = new ChangePassword;
$cp->setTo($arr['server'])
->setUsername($arr['username'])
->setPassword($p1)
->request();
} else {
RPC::call('Account.resetPassword');
Notification::append(null, $this->__('account.password_not_same'));
}
} else {
RPC::call('Account.resetPassword');
Notification::append(null, $this->__('account.password_not_valid'));
}
}
function ajaxRemoveAccount()
{
$view = $this->tpl();
$view->assign('jid', $this->user->getLogin());
Dialog::fill($view->draw('_account_remove', true));
}
function ajaxRemoveAccountConfirm()
{
$da = new Remove;
$da->request();
}
function display()

18
app/widgets/Account/_account_remove.tpl

@ -0,0 +1,18 @@
<section>
<h3>{$c->__('account.delete_title')}</h3>
<br />
<h4 class="gray">{$c->__('account.delete_text')}</h4>
<br />
<h4 class="gray">{$c->__('account.delete_text_confirm')}</h4>
</section>
<div class="no_bar">
<a onclick="Dialog.clear()" class="button flat">
{$c->__('button.cancel')}
</a>
<a
name="submit"
class="button flat"
onclick="Account_ajaxRemoveAccountConfirm(); Dialog.clear()">
{$c->__('button.delete')}
</a>
</div>

11
app/widgets/Account/account.js

@ -0,0 +1,11 @@
var Account = {
resetPassword : function() {
var form = document.querySelector('form[name=password]');
form.reset();
form.querySelector('a.button').className = 'button color oppose';
},
clearAccount : function() {
var username = localStorage.getItem("username").replace("@", "at");
localStorage.removeItem(username + '_Init');
}
}

4
app/widgets/Account/account.tpl

@ -16,13 +16,13 @@
</div>
<a onclick="
Account_ajaxChangePassword(movim_form_to_json('password'));
//this.className='button oppose inactive';" class="button color oppose">
this.className='button oppose inactive';" class="button color oppose">
{$c->__('button.submit')}
</a>
</form>
</li>
<li class="subheader">Delete my account</li>
<li class="action">
<li class="action" onclick="Account_ajaxRemoveAccount()">
<span class="icon red">
<i class="md md-delete"></i>
</span>

3
app/widgets/Account/locales.ini

@ -2,3 +2,6 @@ account.title = 'Account'
account.password_changed = 'The password has been updated'
account.password_not_valid = 'Please provide a valid password (6 characters minimum)'
account.password_not_same = 'The provided passwords are not the same'
account.delete_title = 'Delete my account'
account.delete_text = 'You will delete your XMPP account and all the relative information linked to it (profile, contacts and publications).'
account.delete_text_confirm = 'Are you sure that you want to delete it ?'

2
system/User.php

@ -17,7 +17,7 @@
class User {
private $xmppSession;
public $username = '';
public $username = '';
private $password = '';
private $config = array();

Loading…
Cancel
Save