Browse Source

- New widget ProfileData

- Fix some UI bug
- Fix add/remove contact error in the RosterList
- Fix contact name displayed
pull/16/head
Jaussoin Timothée 13 years ago
parent
commit
ad51d8837f
  1. 2
      system/Datas/Contact.php
  2. 33
      system/Widget/widgets/ContactInfo/ContactInfo.php
  3. 18
      system/Widget/widgets/ContactSummary/ContactSummary.php
  4. 27
      system/Widget/widgets/Notifs/Notifs.php
  5. 2
      system/Widget/widgets/Poller/poller.js
  6. 7
      system/Widget/widgets/Profile/Profile.php
  7. 80
      system/Widget/widgets/ProfileData/ProfileData.php
  8. 67
      system/Widget/widgets/ProfileData/profiledata.js
  9. 4
      system/Widget/widgets/Roster/Roster.php
  10. 4
      system/Widget/widgets/Vcard/Vcard.php
  11. 2
      themes/movim/main.tpl
  12. 2
      themes/movim/page.tpl

2
system/Datas/Contact.php

@ -160,7 +160,7 @@ class Contact extends DatajarBase {
if(isset($this->fn) && $this->fn->getval() != '' && !filter_var($this->fn->getval(), FILTER_VALIDATE_EMAIL))
$truename = $this->fn->getval();
elseif(isset($this->nickname) && $this->nickname->getval() != '' && !filter_var($this->nickname->getval(), FILTER_VALIDATE_EMAIL))
$truename = $this->fn->getval();
$truename = $this->nickname->getval();
elseif(isset($this->name) && $this->name->getval() != '' && !filter_var($this->name->getval(), FILTER_VALIDATE_EMAIL))
$truename = $this->name->getval();
elseif(isset($this->rostername) && $this->rostername->getval() != '' && !filter_var($this->rostername->getval(), FILTER_VALIDATE_EMAIL))

33
system/Widget/widgets/ContactInfo/ContactInfo.php

@ -24,6 +24,25 @@ class ContactInfo extends WidgetCommon
}
function ajaxRemoveContact($jid) {
//if(checkJid($jid)) {
$r = new moxl\RosterRemoveItem();
$r->setTo($jid)
->request();
$p = new moxl\PresenceUnsubscribe();
$p->setTo($jid)
->request();
/*} else {
throw new MovimException("Incorrect JID `$jid'");
}*/
/*global $sdb;
$contact = $sdb->select('Contact', array('key' => $this->user->getLogin(), 'jid' => $jid));
$sdb->delete($contact[0]);*/
}
function prepareContactInfo()
{
$query = Contact::query()->join('Presence',
@ -36,17 +55,12 @@ class ContactInfo extends WidgetCommon
$html = '';
if(isset($user)) {
if(isset($user) && isset($user[0][1])) {
$contact = $user[0][0];
$presence = $user[0][1]->getPresence();
/*if($this->testIsSet(prepareString($contact->getData('desc')))) {
$html .= '
<div class="textbubble">
'.prepareString($contact->getData('desc')).'
</div>';
}*/
// Mood
if($contact->mood->getval() != '') {
$mood = '';
foreach(unserialize($contact->mood->getval()) as $m)
@ -95,7 +109,6 @@ class ContactInfo extends WidgetCommon
}
// Client informations
if($presence['node'] != '' && $presence['ver'] != '') {
$clienttype =
array(
@ -141,7 +154,7 @@ class ContactInfo extends WidgetCommon
$html .= '<div style="clear: both;"></div>';
if($contact->getData('rostersubscription') != 'none') {
if($contact->rostersubscription->getval() != 'vcard') {
$html .='
<a
class=""

18
system/Widget/widgets/ContactSummary/ContactSummary.php

@ -39,24 +39,6 @@ class ContactSummary extends WidgetCommon
$r->setTo($jid)->request();
}
function ajaxRemoveContact($jid) {
if(checkJid($jid)) {
$r = new moxl\RosterRemoveItem();
$r->setTo($jid)
->request();
$p = new moxl\PresenceUnsubscribe();
$p->setTo($jid)
->request();
} else {
throw new MovimException("Incorrect JID `$jid'");
}
global $sdb;
$contact = $sdb->select('Contact', array('key' => $this->user->getLogin(), 'jid' => $jid));
$sdb->delete($contact[0]);
}
function prepareContactSummary($contact)
{
$gender = getGender();

27
system/Widget/widgets/Notifs/Notifs.php

@ -42,9 +42,10 @@ class Notifs extends WidgetBase
RPC::commit();
}
function onSubscribe($from) {
$notifs = Cache::c('activenotifs');
$html = '
function prepareNotifs($from) {
$html = '';
$html .= '
<li>
<form id="acceptcontact">
'.$from.' '.t('wants to talk with you'). ' <br />
@ -78,9 +79,19 @@ class Notifs extends WidgetBase
</a>
</form>
</li>';
$notifs['sub'.$from] = $html;
return $html;
}
function onSubscribe($from) {
$notifs = Cache::c('activenotifs');
$html = '';
foreach($notifs as $key => $value)
$html .= $this->prepareNotifs($key);
//$notifs['sub'.$from] = $html;
RPC::call('movim_prepend', 'notifslist', RPC::cdata($html));
RPC::call('movim_fill', 'notifslist', RPC::cdata($html));
Cache::c('activenotifs', $notifs);
}
@ -106,7 +117,7 @@ class Notifs extends WidgetBase
->request();
$notifs = Cache::c('activenotifs');
unset($notifs['sub'.$jid]);
unset($notifs[$jid]);
Cache::c('activenotifs', $notifs);
} else {
@ -128,7 +139,7 @@ class Notifs extends WidgetBase
}
$notifs = Cache::c('activenotifs');
unset($notifs['sub'.$jid]);
unset($notifs[$jid]);
Cache::c('activenotifs', $notifs);
}
@ -174,7 +185,7 @@ class Notifs extends WidgetBase
<?php
ksort($notifs);
foreach($notifs as $key => $value) {
echo $value;
echo $this->prepareNotifs($key);
}
?>
<li>

2
system/Widget/widgets/Poller/poller.js

@ -38,7 +38,7 @@ function movim_poll()
movim_disconnect('&err=internal');
}
if(poller.status > 0) {
if(poller.status == 200) {
// Restarting polling.
movim_poll();
}

7
system/Widget/widgets/Profile/Profile.php

@ -120,8 +120,11 @@ class Profile extends WidgetBase
</div>
';
} else {
$html .= t('No profile yet ?').'<br /><br />';
$html .= '<a class="button icon add" style="padding-left: 25px;" href="?q=profile">'.t("Create my vCard").'</a><br /><br />';
$html .= '
<div class="block">
'.t('No profile yet ?').'<br /><br />
<a class="button icon add" style="text-shadow: none; color: rgb(43, 43, 43); text-decoration: none;" href="?q=profile">'.t("Create my vCard").'</a><br /><br />
</div>';
}
return $html;

80
system/Widget/widgets/ProfileData/ProfileData.php

@ -0,0 +1,80 @@
<?php
/**
* @package Widgets
*
* @file Profile.php
* This file is part of MOVIM.
*
* @brief The Profile widget
*
* @author Timothée Jaussoin <edhelas_at_gmail_dot_com>
*
* @version 1.0
* @date 20 October 2010
*
* Copyright (C)2010 MOVIM project
*
* See COPYING for licensing information.
*/
class ProfileData extends WidgetBase
{
function WidgetLoad()
{
$this->addjs('profiledata.js');
}
function ajaxLocationPublish($pos)
{
movim_log($pos = json_decode($pos));
if($pos->place_id) {
$geo = array(
'latitude' => (string)$pos->lat,
'longitude' => (string)$pos->lon,
'altitude' => (string)$pos->alt,
'country' => (string)$pos->address->country,
'countrycode' => (string)$pos->address->country_code,
'region' => (string)$pos->address->county,
'postalcode' => (string)$pos->address->postcode,
'locality' => (string)$pos->address->city,
'street' => (string)$pos->address->path,
'building' => (string)$pos->address->building,
'text' => (string)$pos->display_name,
'uri' => ''//'http://www.openstreetmap.org/'.urlencode('?lat='.(string)$pos->lat.'&lon='.(string)$pos->lon.'&zoom=10')
);
movim_log($geo);
$p = new moxl\LocationPublish();
$p->setTo($this->user->getLogin())
->setGeo($geo)
->request();
} else {
$html = '
<div class="message error">'.t('Wrong position').'</div>';
RPC::call('movim_fill', 'maperror', RPC::cdata($html));
RPC::commit();
}
}
function prepareProfileData()
{
$submit = $this->genCallAjax('ajaxLocationPublish', "getMyPositionData()");
$html = '';
$html .= '
<h2>'.t('Location').'</h2>
<div id="maperror"></div>
<div id="mapdata"></div>
<div id="mapdiv" style="width: auto; height: 250px; display: none;"></div><br />
<a class="button tiny icon add" onclick="getMyPosition(); this.style.display = \'none\';">'.t('Get my position').'</a>
<a id="mypossubmit" style="display: none;" class="button tiny icon yes merged left" onclick="'.$submit.'">'.t('Accept').'</a><a style="display: none;" id="myposrefuse" class="button tiny icon yes merged right">'.t('Cancel').'</a>';
return $html;
}
function build()
{
echo $this->prepareProfileData();
}
}

67
system/Widget/widgets/ProfileData/profiledata.js

@ -0,0 +1,67 @@
var myposition = 0;
function getMyPositionData() { return myposition; }//return myposition.latitude; }
window.cb = function cb(json) {
document.getElementById('mapdata').innerHTML = json.display_name + ',' + json.address.city;
myposition = JSON.stringify(json);
}
function getMyPosition() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function (position) {
document.querySelector("#mapdiv").style.display = 'block';
map = new OpenLayers.Map("mapdiv");
map.addLayer(new OpenLayers.Layer.OSM());
var lonLat = new OpenLayers.LonLat( position.coords.longitude ,position.coords.latitude )
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
var zoom=11;
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
markers.addMarker(new OpenLayers.Marker(lonLat));
map.setCenter (lonLat, zoom);
var s = document.createElement('script');
s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat='+position.coords.latitude+'&lon='+position.coords.longitude+'&zoom=27&addressdetails=1';
document.getElementsByTagName('head')[0].appendChild(s);
document.querySelector("#mypossubmit").style.display = 'inline-block';
document.querySelector("#myposrefuse").style.display = 'inline-block';
},
// next function is the error callback
function (error)
{
switch(error.code)
{
case error.TIMEOUT:
alert ('Timeout');
break;
case error.POSITION_UNAVAILABLE:
alert ('Position unavailable');
break;
case error.PERMISSION_DENIED:
alert ('Permission denied');
break;
case error.UNKNOWN_ERROR:
alert ('Unknown error');
break;
}
}
);
}
else {
}
}

4
system/Widget/widgets/Roster/Roster.php

@ -126,9 +126,9 @@ class Roster extends WidgetBase
->where(
array(
'Contact`.`key' => $this->user->getLogin(),
array(
/*array(
'Contact`.`rostersubscription!' => 'none',
'|Contact`.`rosterask' => 'subscribe')))
'|Contact`.`rosterask' => 'subscribe')*/))
->orderby('Contact.group', true);
$contacts = Contact::run_query($query);

4
system/Widget/widgets/Vcard/Vcard.php

@ -32,6 +32,7 @@ class Vcard extends WidgetBase
function onMyVcardReceived()
{
$html = $this->prepareInfos();
RPC::call('movim_textarea_autoheight(document.querySelector("#desctext"))');
RPC::call('movim_fill', 'vcard', RPC::cdata($html));
}
@ -235,7 +236,7 @@ class Vcard extends WidgetBase
</div>';
$html .= '<div class="element"><label for="desc">'.t('About Me').'</label>
<textarea name ="desc" class="content" onkeyup="movim_textarea_autoheight(this);">'.trim($me->getData('desc')).'</textarea>
<textarea name ="desc" id="desctext" class="content" onkeyup="movim_textarea_autoheight(this);">'.trim($me->getData('desc')).'</textarea>
</div>';
$html .= '</fieldset>';
@ -292,6 +293,7 @@ class Vcard extends WidgetBase
<?php
echo $this->prepareInfos();
?>
<div class="clear"></div>
</div>
<?php
}

2
themes/movim/main.tpl

@ -10,7 +10,7 @@
<div id="main">
<div id="left">
<?php $this->widget('ProfileData');?>
</div>
<div id="center" class="protect orange">
<h1><?php echo t('Feed'); ?></h1>

2
themes/movim/page.tpl

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php $this->title();?></title>
<link rel="shortcut icon" href="<?php $this->link_file('img/favicon.ico');?>" />
<script src="http://openlayers.org/api/2.12/OpenLayers.js"></script>
<script src="http://localhost/OpenLayers.js"></script>
<?php
$this->addCss('css/style2.css');
$this->addCss('css/posts.css');

Loading…
Cancel
Save