Browse Source

- Update correctly the Avatar and Vcard4 and force the refresh if they're not present

- Fix some warnings and old lines
pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
07243c6f51
  1. 20
      app/models/contact/Contact.php
  2. 4
      app/models/subscription/Subscription.php
  3. 9
      app/models/subscription/SubscriptionDAO.php
  4. 36
      app/widgets/Avatar/Avatar.php
  5. 47
      app/widgets/Avatar/_avatar_form.tpl
  6. 53
      app/widgets/Avatar/avatar.tpl
  7. 1
      app/widgets/Bookmark/Bookmark.php
  8. 3
      app/widgets/Chat/_chat_contact.tpl
  9. 9
      app/widgets/Explore/Explore.php
  10. 2
      app/widgets/Location/Location.php
  11. 4
      app/widgets/Node/Node.php
  12. 5
      app/widgets/Node/_node_content.tpl
  13. 36
      app/widgets/Roster/Roster.php
  14. 66
      app/widgets/Vcard4/Vcard4.php
  15. 172
      app/widgets/Vcard4/_vcard4_form.tpl
  16. 178
      app/widgets/Vcard4/vcard4.tpl
  17. 2
      lib/XMPPtoForm.php

20
app/models/contact/Contact.php

@ -228,6 +228,26 @@ class Contact extends ModlModel {
$this->tunetitle = (string)$stanza->items->item->tune->title;
$this->tunetrack = (string)$stanza->items->item->tune->track;
}
public function setVcard4($vcard) {
$date = strtotime($vcard->bday->date);
$this->date = date('Y-m-d', $date);
$this->name = $vcard->nickname->text;
$this->fn = $vcard->fn->text;
$this->url = $vcard->url->uri;
$this->gender = $vcard->gender->sex->text;
$this->marital = $vcard->marital->status->text;
$this->adrlocality = $vcard->adr->locality;
$this->adrcountry = $vcard->adr->country;
$this->adrpostalcode = $vcard->adr->code;
$this->email = $vcard->email->text;
$this->description = trim($vcard->note->text);
}
public function getPlace() {
$place = '';

4
app/models/subscription/Subscription.php

@ -9,6 +9,7 @@ class Subscription extends ModlModel {
public $subscription;
public $subid;
public $title;
public $tags;
public $timestamp;
public $name;
@ -27,6 +28,8 @@ class Subscription extends ModlModel {
{"type":"string", "size":128 },
"title" :
{"type":"string", "size":128 },
"tags" :
{"type":"text" },
"timestamp" :
{"type":"date" }
}';
@ -41,6 +44,7 @@ class Subscription extends ModlModel {
$this->jid = (string)$s->attributes()->jid;
$this->subscription = (string)$s->attributes()->subscription;
$this->subid = (string)$s->attributes()->subid;
$this->tags = serialize(array());
$this->timestamp = date('Y-m-d H:i:s', rand(1111111111, 8888888888));
if($this->subid = '')

9
app/models/subscription/SubscriptionDAO.php

@ -8,6 +8,7 @@ class SubscriptionDAO extends ModlSQL {
update subscription
set subscription = :subscription,
timestamp = :timestamp,
tags = :tags,
subid = :subid
where jid = :jid
and server = :server
@ -21,6 +22,7 @@ class SubscriptionDAO extends ModlSQL {
'jid' => $s->jid,
'server'=> $s->server,
'node' => $s->node,
'tags' => $s->tags,
'subid' => $s->subid
)
);
@ -30,8 +32,8 @@ class SubscriptionDAO extends ModlSQL {
if(!$this->_effective) {
$this->_sql = '
insert into subscription
(jid, server, node, subscription, subid, timestamp)
values (:jid, :server, :node, :subscription, :subid, :timestamp)';
(jid, server, node, subscription, subid, tags, timestamp)
values (:jid, :server, :node, :subscription, :subid, :tags, :timestamp)';
$this->prepare(
'Subscription',
@ -40,7 +42,8 @@ class SubscriptionDAO extends ModlSQL {
'timestamp' => $s->timestamp,
'jid' => $s->jid,
'server'=> $s->server,
'node' =>$s->node,
'node' => $s->node,
'tags' => $s->tags,
'subid' => $s->subid
)
);

36
app/widgets/Avatar/Avatar.php

@ -21,17 +21,42 @@ class Avatar extends WidgetBase
{
$this->registerEvent('myavatarvalid', 'onAvatarPublished');
$this->registerEvent('myavatarinvalid', 'onAvatarNotPublished');
$this->registerEvent('myvcard', 'onMyAvatar');
$this->addcss('avatar.css');
$this->addjs('avatar.js');
$cd = new \modl\ContactDAO();
$me = $cd->get($this->user->getLogin());
$this->view->assign('me', $me);
$this->view->assign(
if($me->photobin == "") {
$this->view->assign(
'getavatar',
$this->genCallAjax('ajaxGetAvatar')
);
$this->view->assign('form', $this->prepareForm(new \modl\Contact()));
} else {
$this->view->assign('form', $this->prepareForm($me));
}
}
function onMyAvatar($c) {
$html = $this->prepareForm($c);
RPC::call('movim_fill', 'avatar_form', $html);
RPC::commit();
}
function prepareForm($me) {
$avatarform = $this->tpl();
$avatarform->assign('me', $me);
$avatarform->assign(
'submit',
$this->genCallAjax('ajaxAvatarSubmit', "movim_form_to_json('avatarform')")
);
return $avatarform->draw('_avatar_form', true);
}
function onAvatarPublished()
@ -46,6 +71,13 @@ class Avatar extends WidgetBase
Notification::appendNotification(t('Avatar Not Updated'), 'error');
RPC::commit();
}
function ajaxGetAvatar() {
$r = new moxl\AvatarGet();
$r->setTo($this->user->getLogin())
->setMe()
->request();
}
function ajaxAvatarSubmit($avatar)
{

47
app/widgets/Avatar/_avatar_form.tpl

@ -0,0 +1,47 @@
<form name="avatarform" id="avatarform">
<fieldset>
<legend>{$c->t('Avatar')}</legend>
<div class="element">
<label for="avatar">{$c->t('Avatar')}</label>
<img id="vCardPhotoPreview" src="data:'.$me->phototype.';base64,{$me->photobin}">
<br /><span id="picturesize" class="clean"></span><br /><br />
<input type="file" onchange="vCardImageLoad(this.files);">
<input type="hidden" name="phototype" value="{$me->phototype}"/>
<input type="hidden" name="photobin" value="{$me->photobin}"/>
</div>
<div class="element" id="camdiv">
<label for="url">{$c->t('Webcam')}</label>
<video id="runningcam" class="squares" autoplay></video>
<canvas style="display:none;"></canvas>
<a
id="shoot"
class="button icon preview color green"
onclick="return false;">
{$c->t("Cheese !")}
</a>
<a
id="capture"
class="button icon image color purple"
onclick="
showVideo();
return false;">
{$c->t("Take a webcam snapshot")}
</a>
</div>
</fieldset>
<a
onclick="
{$submit}
movim_button_save('#avatarvalidate');
this.value = '{$c->t('Submitting')}';
this.className='button color orange icon loading inactive';"
class="button icon color green yes"
id="avatarvalidate"
style="float: right;"
>{$c->t('Submit')}</a>
</form>

53
app/widgets/Avatar/avatar.tpl

@ -1,50 +1,9 @@
<div class="tabelem padded" title="{$c->t('Avatar')}" id="avatar" >
<div class="protect orange"></div>
<form name="avatarform" id="avatarform">
<fieldset>
<legend>{$c->t('Avatar')}</legend>
<div class="element">
<label for="avatar">{$c->t('Avatar')}</label>
<img id="vCardPhotoPreview" src="data:'.$me->phototype.';base64,{$me->photobin}">
<br /><span id="picturesize" class="clean"></span><br /><br />
<input type="file" onchange="vCardImageLoad(this.files);">
<input type="hidden" name="phototype" value="{$me->phototype}"/>
<input type="hidden" name="photobin" value="{$me->photobin}"/>
</div>
<div class="element" id="camdiv">
<label for="url">{$c->t('Webcam')}</label>
<video id="runningcam" class="squares" autoplay></video>
<canvas style="display:none;"></canvas>
<a
id="shoot"
class="button icon preview color green"
onclick="return false;">
{$c->t("Cheese !")}
</a>
<a
id="capture"
class="button icon image color purple"
onclick="
showVideo();
return false;">
{$c->t("Take a webcam snapshot")}
</a>
</div>
</fieldset>
<a
onclick="
{$submit}
movim_button_save('#avatarvalidate');
this.value = '{$c->t('Submitting')}';
this.className='button color orange icon loading inactive';"
class="button icon color green yes"
id="avatarvalidate"
style="float: right;"
>{$c->t('Submit')}</a>
</form>
{if="$getavatar != null"}
<script type="text/javascript">setTimeout('{$getavatar}', 1000);</script>
{/if}
<div id="avatar_form">
{$form}
</div>
</div>

1
app/widgets/Bookmark/Bookmark.php

@ -109,6 +109,7 @@ class Bookmark extends WidgetBase
'server' => $s->server,
'title' => $s->title,
'subid' => $s->subid,
'tags' => unserialize($s->tags),
'node' => $s->node));
}
}

3
app/widgets/Chat/_chat_contact.tpl

@ -19,9 +19,6 @@
<textarea
rows="1"
id="textarea{$contact->jid}"
{if="$publickey"}
data-publickey="{$publickey}"
{/if}
onkeypress="
if(event.keyCode == 13) {
state = 0;

9
app/widgets/Explore/Explore.php

@ -40,8 +40,8 @@ class Explore extends WidgetCommon {
$pubsubs = '';
foreach($servers as $s) {
list($type) = explode('.', $s->server);
list($type, $server,$ext) = explode('.', $s->server);
switch ($type) {
case 'conference':
$cat = 'chatroom';
@ -56,7 +56,10 @@ class Explore extends WidgetCommon {
$cat = 'pubsub';
break;
default:
$cat = null;
if($ext == null)
$cat = null;
else
$cat = 'pubsub';
break;
}

2
app/widgets/Location/Location.php

@ -114,7 +114,7 @@ class Location extends WidgetBase
{
?>
<div class="tabelem padded" title="<?php echo t('Location'); ?>" id="location" >
<div class="protect orange" title="<?php echo getFlagTitle($color); ?>"></div>
<div class="protect orange" title="<?php echo getFlagTitle('orange'); ?>"></div>
<form>
<fieldset>
<legend><?php echo t('Location'); ?></legend>

4
app/widgets/Node/Node.php

@ -78,8 +78,10 @@ class Node extends WidgetCommon
}
if($this->searchSubscription($params[1], $params[2])
&& ($this->role == 'owner' || $this->role == 'publisher'))
&& ($this->role == 'owner' || $this->role == 'publisher')) {
RPC::call('movim_toggle_display', '#formpublish');
RPC::call('movim_toggle_display', '#configbutton');
}
}
function onPubsubMetadata($params) {

5
app/widgets/Node/_node_content.tpl

@ -36,13 +36,12 @@
onclick="{$getsubscription}"
>{$c->t('Get Subscription')}</a>
{if="$role == 'owner'"}
<a
class="button color icon user"
style="float: right;"
style="float: right; display: none;"
id="configbutton"
href="{$c->route('nodeconfig', array($serverid,$groupid))}"
>{$c->t('Configuration')}</a>
{/if}
</div>
<div class="popup" id="groupsubscribe">

36
app/widgets/Roster/Roster.php

@ -334,42 +334,6 @@ class Roster extends WidgetBase
RPC::commit();
}
/*function ajaxToggleChat()
{
//$bool = !currentValue
$bool = (Cache::c('chatpop') == true) ? false : true;
//toggling value in cache
Cache::c('chatpop', $bool);
RPC::call('movim_fill', 'chattoggle', $this->prepareChatToggle());
RPC::commit();
}*/
/*function prepareChatToggle()
{
$chatpop = Cache::c('chatpop');
if($chatpop) {
$arrow = 'expand';
$ptoggle = 'openPopup();';
} else {
$arrow = 'contract';
$ptoggle = 'closePopup();';
}
$call = $this->genCallAjax('ajaxToggleChat');
$html = '
<li
onclick="'.$call.' '.$ptoggle.'"
title="'.t('Show/Hide').'">
<a class="'.$arrow.'" href="#"></a>
</li>';
return $html;
}*/
/**
* @brief Show/Hide the Roster
*/

66
app/widgets/Vcard4/Vcard4.php

@ -21,21 +21,37 @@ class Vcard4 extends WidgetBase
{
$this->registerEvent('myvcard4valid', 'onMyVcard4Received');
$this->registerEvent('myvcard4invalid', 'onMyVcard4NotReceived');
$this->registerEvent('myvcard', 'onMyVcard4');
$cd = new \modl\ContactDAO();
$me = $cd->get($this->user->getLogin());
$this->view->assign('me', $me);
$this->view->assign('desc', trim($me->description));
$this->view->assign('gender', getGender());
$this->view->assign('marital', getMarital());
$this->view->assign('countries',getCountries());
if($me == null) {
$this->view->assign(
'getvcard',
$this->genCallAjax('ajaxGetVcard')
);
$this->view->assign('form', $this->prepareForm(new \modl\Contact()));
} else {
$this->view->assign('form', $this->prepareForm($me));
}
}
function prepareForm($me) {
$vcardform = $this->tpl();
$vcardform->assign('me', $me);
$vcardform->assign('desc', trim($me->description));
$vcardform->assign('gender', getGender());
$vcardform->assign('marital', getMarital());
$vcardform->assign('countries',getCountries());
$this->view->assign(
$vcardform->assign(
'submit',
$this->genCallAjax('ajaxVcardSubmit', "movim_form_to_json('vcard4')")
);
$this->view->assign(
$vcardform->assign(
'privacy',
$this->genCallAjax('ajaxChangePrivacy', "this.checked")
);
@ -62,26 +78,41 @@ class Vcard4 extends WidgetBase
}
for($i=date('o'); $i>= 1920; $i--) { array_push($years, $i); }
$this->view->assign('days', $days);
$this->view->assign('months', $months);
$this->view->assign('years', $years);
$vcardform->assign('days', $days);
$vcardform->assign('months', $months);
$vcardform->assign('years', $years);
return $vcardform->draw('_vcard4_form', true);
}
function onMyVcard4($c) {
$html = $this->prepareForm($c);
function onMyVcard4Received()
{
Notification::appendNotification(t('Profile Updated'), 'success');
RPC::call('movim_fill', 'vcard_form', $html);
RPC::commit();
}
function onMyVcard4Received() {
RPC::call('movim_button_reset', '#vcard4validate');
Notification::appendNotification(t('Profile Updated'), 'success');
RPC::commit();
}
function onMyVcard4NotReceived()
{
function onMyVcard4NotReceived() {
Notification::appendNotification(t('Profile Not Updated'), 'error');
RPC::commit();
}
function ajaxGetVcard() {
$r = new moxl\Vcard4Get();
$r->setTo($this->user->getLogin())
->setMe()
->request();
}
function ajaxVcardSubmit($vcard)
{
function ajaxVcardSubmit($vcard) {
# Format it ISO 8601:
if($vcard->year->value != -1
&& $vcard->month->value != -1
@ -132,8 +163,7 @@ class Vcard4 extends WidgetBase
$r->setData($vcard)->request();
}
function ajaxChangePrivacy($value)
{
function ajaxChangePrivacy($value) {
if($value == true) {
\modl\Privacy::set($this->user->getLogin(), 1);
Notification::appendNotification(t('Your profile is now public'), 'success');

172
app/widgets/Vcard4/_vcard4_form.tpl

@ -0,0 +1,172 @@
<form name="vcard4" id="vcard4form">
<fieldset>
<legend>{$c->t('General Informations')}</legend>
<div class="element">
<label for="fn">{$c->t('Name')}</label>
<input type="text" name="fn" class="content" value="{$me->fn}">
</div>
<div class="element">
<label for="fn">{$c->t('Nickname')}</label>
<input type="text" name="name" class="content" value="{$me->name}">
</div>
<div class="element">
<label for="fn">{$c->t('Email')}</label>
<input type="email" name="email" class="content" value="{$me->email}">
</div>
<!-- The date picker -->
<div class="element ">
<label for="day">{$c->t('Date of Birth')}</label>
<div class="select" style="width: 33%; float: left;">
<select name="day" class="datepicker">
<option value="-1">{$c->t('Day')}</option>
{loop="$days"}
<option value="{$value}"
{if="$key == substr($me->date, 8)"}
selected
{/if}
>{$value}</option>
{/loop}
</select>
</div>
<div class="select" style="width: 34%; float: left;">
<select name="month" class="datepicker">
<option value="-1">{$c->t('Month')}</option>
{loop="$months"}
<option value="{$key}"
{if="$key == substr($me->date,5,2)"}
selected
{/if}
>{$value}</option>
{/loop}
</select>
</div>
<div class="select" style="width: 33%; float: left;">
<select name="year" class="datepicker">
<option value="-1">{$c->t('Year')}</option>
{loop="$years"}
<option value="{$value}"
{if="$value == substr($me->date,0,4)"}
selected
{/if}
>{$value}</option>
{/loop}
</select>
</div>
</div>
<div class="element">
<label for="gender">{$c->t('Gender')}</label>
<div class="select">
<select name="gender">
{loop="$gender"}
<option
{if="$key == $me->gender"}
selected
{/if}
value="{$key}">{$value}</option>
{/loop}
</select>
</div>
</div>
<div class="element">
<label for="marital">{$c->t('Marital Status')}</label>
<div class="select">
<select name="marital">
{loop="$marital"}
<option
{if="$key == $me->marital"}
selected
{/if}
value="{$key}">{$value}</option>
{/loop}
</select>
</div>
</div>
<div class="element large">
<label for="url">{$c->t('Website')}</label>
<input type="url" name ="url" class="content" value="{$me->url}">
</div>
<div class="element large">
<label for="desc">{$c->t('About Me')}</label>
<textarea name="desc" id="desctext" class="content" onkeyup="movim_textarea_autoheight(this);">{$desc}</textarea>
</div>
</fieldset>
<fieldset>
<legend>{$c->t('Geographic Position')}</legend>
<div class="element">
<label for="url">{$c->t('Locality')}</label>
<input type="text" type="locality" name ="locality" class="content" value="{$me->adrlocality}">
</div>
<div class="element">
<label for="country">{$c->t('Country')}</label>
<div class="select">
<select name="country">
<option value=""></option>
{loop="$countries"}
<option
{if="$value == $me->adrcountry"}
selected
{/if}
value="{$value}">{$value}</option>
{/loop}
</select>
</div>
</div>
</fieldset>
<fieldset>
<a
onclick="
{$submit}
movim_button_save('#vcard4validate');
this.value = '{$c->t('Submitting')}';
this.className='button color orange icon loading merged right inactive';"
class="button icon merged right color green yes"
style="float: right;"
id="vcard4validate"
>{$c->t('Submit')}</a>
<a
onclick="document.querySelector('#vcard4form').reset();"
class="button icon no merged left color orange"
style="float: right;">{$c->t('Reset')}</a>
</fieldset>
<fieldset>
<legend>{$c->t('Privacy Level')}</legend>
<div class="element">
<label>{$c->t('Is this profile public ?')}</label>
<div class="checkbox">
<input
type="checkbox"
id="privacy"
name="privacy"
{if="$me->privacy"}
checked
{/if}
onchange="{$privacy}"/>
<label for="privacy"></label>
</div>
</div>
<div class="element">
<div class="message info">
{$c->t('Please pay attention ! By making your profile public, all the information listed above will be available for all the Movim users and on the whole Internet.')}
</div>
</div>
<!--<div class="element">
</div>-->
</fieldset>
</form>

178
app/widgets/Vcard4/vcard4.tpl

@ -1,174 +1,8 @@
<div class="tabelem padded" title="{$c->t('Data')}" id="vcard4" >
<form name="vcard4" id="vcard4form">
<fieldset>
<legend>{$c->t('General Informations')}</legend>
<div class="element">
<label for="fn">{$c->t('Name')}</label>
<input type="text" name="fn" class="content" value="{$me->fn}">
</div>
<div class="element">
<label for="fn">{$c->t('Nickname')}</label>
<input type="text" name="name" class="content" value="{$me->name}">
</div>
<div class="element">
<label for="fn">{$c->t('Email')}</label>
<input type="email" name="email" class="content" value="{$me->email}">
</div>
<!-- The date picker -->
<div class="element ">
<label for="day">{$c->t('Date of Birth')}</label>
<div class="select" style="width: 33%; float: left;">
<select name="day" class="datepicker">
<option value="-1">{$c->t('Day')}</option>
{loop="$days"}
<option value="{$value}"
{if="$key == substr($me->date, 8)"}
selected
{/if}
>{$value}</option>
{/loop}
</select>
</div>
<div class="select" style="width: 34%; float: left;">
<select name="month" class="datepicker">
<option value="-1">{$c->t('Month')}</option>
{loop="$months"}
<option value="{$key}"
{if="$key == substr($me->date,5,2)"}
selected
{/if}
>{$value}</option>
{/loop}
</select>
</div>
<div class="select" style="width: 33%; float: left;">
<select name="year" class="datepicker">
<option value="-1">{$c->t('Year')}</option>
{loop="$years"}
<option value="{$value}"
{if="$value == substr($me->date,0,4)"}
selected
{/if}
>{$value}</option>
{/loop}
</select>
</div>
</div>
<div class="element">
<label for="gender">{$c->t('Gender')}</label>
<div class="select">
<select name="gender">
{loop="$gender"}
<option
{if="$key == $me->gender"}
selected
{/if}
value="{$key}">{$value}</option>
{/loop}
</select>
</div>
</div>
<div class="element">
<label for="marital">{$c->t('Marital Status')}</label>
<div class="select">
<select name="marital">
{loop="$marital"}
<option
{if="$key == $me->marital"}
selected
{/if}
value="{$key}">{$value}</option>
{/loop}
</select>
</div>
</div>
<div class="element large">
<label for="url">{$c->t('Website')}</label>
<input type="url" name ="url" class="content" value="{$me->url}">
</div>
<div class="element large">
<label for="desc">{$c->t('About Me')}</label>
<textarea name="desc" id="desctext" class="content" onkeyup="movim_textarea_autoheight(this);">{$desc}</textarea>
</div>
</fieldset>
<fieldset>
<legend>{$c->t('Geographic Position')}</legend>
<div class="element">
<label for="url">{$c->t('Locality')}</label>
<input type="text" type="locality" name ="locality" class="content" value="{$me->adrlocality}">
</div>
<div class="element">
<label for="country">{$c->t('Country')}</label>
<div class="select">
<select name="country">
<option value=""></option>
{loop="$countries"}
<option
{if="$value == $me->adrcountry"}
selected
{/if}
value="{$value}">{$value}</option>
{/loop}
</select>
</div>
</div>
</fieldset>
<fieldset>
<a
onclick="
{$submit}
movim_button_save('#vcard4validate');
this.value = '{$c->t('Submitting')}';
this.className='button color orange icon loading merged right inactive';"
class="button icon merged right color green yes"
style="float: right;"
id="vcard4validate"
>{$c->t('Submit')}</a>
<a
onclick="document.querySelector('#vcard4form').reset();"
class="button icon no merged left color orange"
style="float: right;">{$c->t('Reset')}</a>
</fieldset>
<fieldset>
<legend>{$c->t('Privacy Level')}</legend>
<div class="element">
<label>{$c->t('Is this profile public ?')}</label>
<div class="checkbox">
<input
type="checkbox"
id="privacy"
name="privacy"
{if="$me->privacy"}
checked
{/if}
onchange="{$privacy}"/>
<label for="privacy"></label>
</div>
</div>
<div class="element">
<div class="message info">
{$c->t('Please pay attention ! By making your profile public, all the information listed above will be available for all the Movim users and on the whole Internet.')}
</div>
</div>
<!--<div class="element">
</div>-->
</fieldset>
</form>
{if="$me == null"}
<script type="text/javascript">setTimeout('{$getvcard}', 500);</script>
{/if}
<div id="vcard_form">
{$form}
</div>
</div>

2
lib/XMPPtoForm.php

@ -175,7 +175,7 @@ class XMPPtoForm{
foreach($s->children() as $value){
if($value->getName() == "value"){
$this->html .= $value.' ';
$this->html .= $value;
}
}

Loading…
Cancel
Save