Browse Source

- Add avatar in Notif widget

- Fix some littles issues
- Continue Datajar->Modl port
pull/16/head
Jaussoin Timothée 13 years ago
parent
commit
935b29329f
  1. 21
      system/Cache.php
  2. 15
      system/Controller/ControllerMain.php
  3. 15
      system/Session.php
  4. 4
      system/Widget/WidgetCommon.php
  5. 4
      system/Widget/widgets/ContactInfo/ContactInfo.php
  6. 15
      system/Widget/widgets/Logout/Logout.php
  7. 11
      system/Widget/widgets/Notifs/Notifs.php
  8. 3
      system/Widget/widgets/Notifs/notifs.css
  9. 18
      system/Widget/widgets/Roster/Roster.php
  10. 65
      system/Widget/widgets/Vcard/Vcard.php
  11. 16
      system/Widget/widgets/Wall/Wall.php

21
system/Cache.php

@ -108,23 +108,8 @@ class Cache
$md5 = md5($data);
$time = time();
$cd = new \modl\CacheDAO();
//$var = $cd->get($cache_key)
$cd = new \modl\CacheDAO();
$c = new \modl\Cache();
/*$var = new CacheVar();
$query = CacheVar::query()->select()
->where(array(
'key' => $cache_key))
->limit(0, 1);
$result = CacheVar::run_query($query);
if($result) {
$var = $result[0];
}*/
$c->key = $cache_key;
$c->data = $data;
@ -132,8 +117,6 @@ class Cache
$c->timestamp = $time;
$cd->set($c);
//$var->run_query($var->query()->save($var));
}
/**
@ -146,8 +129,6 @@ class Cache
$cd = new \modl\CacheDAO();
$var = $cd->get($cache_key);
//$var = new CacheVar();
//if($var->load(array('key' => $cache_key))) {
if(isset($var)) {
return unserialize(gzuncompress(base64_decode(str_replace("\\'", "'", $var->data))));

15
system/Controller/ControllerMain.php

@ -64,17 +64,12 @@ class ControllerMain extends ControllerBase
function friend()
{
$user = new User();
$cd = new \modl\ContactDAO();
$contact = $cd->get($_GET['f']);
$query = Contact::query()
->where(
array(
'jid' => $_GET['f']
)
);
$contact = Contact::run_query($query);
if(isset($contact[0]))
$name = $contact[0]->getTrueName();
if(isset($contact))
$name = $contact->getTrueName();
else
$name = $_GET['f'];

15
system/Session.php

@ -127,16 +127,13 @@ class Session
*/
public function remove($varname)
{
$var = new SessionVar();
$var->load(array(
'session' => self::$sid,
'container' => $this->container,
'name' => $varname));
$query = $var->query()->delete($var);
$var->run_query($query);
$sd = new modl\SessionDAO();
$sd->delete(self::$sid, $this->container, $varname);
}
/**
* Deletes all variables of the session.
*/
public function delete_container()
{
$sd = new modl\SessionDAO();

4
system/Widget/WidgetCommon.php

@ -405,9 +405,7 @@ class WidgetCommon extends WidgetBase {
return $tmp;
}
function onComment($parent) {
//list($parent, $comments) = $params;
function onComment($parent) {
$p = new \modl\ContactPost();
$p->nodeid = $parent;

4
system/Widget/widgets/ContactInfo/ContactInfo.php

@ -169,7 +169,7 @@ class ContactInfo extends WidgetCommon
id="friendremoveyes"
style="float: left; display: none;"
onclick="'.$this->genCallAjax("ajaxRemoveContact", "'".$_GET['f']."'")
. 'this.className=\'button tiny icon loading merged left\'; setTimeout(function() {location.reload(true)}, 2000);"
. 'this.className=\'button tiny icon loading merged left\'; setTimeout(function() {location.reload(false)}, 2000);"
>
'.t('Yes').'
</a>
@ -193,7 +193,7 @@ class ContactInfo extends WidgetCommon
class="button tiny icon add"
href="#"
onclick="'.$this->genCallWidget("Roster","ajaxAddContact", "'".$_GET['f']."'", "''")
. 'this.className=\'button tiny icon loading merged left\'; setTimeout(function() {location.reload(true)}, 2000);"
. 'this.className=\'button tiny icon loading merged left\'; setTimeout(function() {location.reload(false)}, 2000);"
>
'.t('Invite this user').'
</a>';

15
system/Widget/widgets/Logout/Logout.php

@ -90,21 +90,14 @@ class Logout extends WidgetBase
function preparePresence()
{
$txt = getPresences();
$txts = getPresencesTxt();
global $session;
$query = Presence::query()->select()
->where(array(
'key' => $this->user->getLogin(),
'jid' => $this->user->getLogin(),
'ressource' => $session['ressource']))
->limit(0, 1);
$data = Presence::run_query($query);
if($data)
$presence = $data[0]->getPresence();
$pd = new \modl\PresenceDAO();
$p = $pd->getPresence($this->user->getLogin(), $session['ressource']);
$html = '<div id="logouttab" class="'.$presence['presence_txt'].'" onclick="showLogoutList();">'.$txt[$presence['presence']].'</div>';
$html = '<div id="logouttab" class="'.$txts[$p->presence].'" onclick="showLogoutList();">'.$txt[$p->presence].'</div>';
$html .= '
<div id="logoutlist">

11
system/Widget/widgets/Notifs/Notifs.php

@ -163,11 +163,8 @@ class Notifs extends WidgetCommon
}
// Contact request pending
$query = RosterLink::query()->where(
array(
'key' => $this->user->getLogin(),
'rosterask' => 'subscribe'));
$subscribes = Contact::run_query($query);
$cd = new \modl\ContactDAO();
$subscribes = $cd->getRosterSubscribe();
if(sizeof($subscribes) != 0) {
$notifsnum += sizeof($subscribes);
@ -181,8 +178,8 @@ class Notifs extends WidgetCommon
foreach($subscribes as $s) {
$html .= '
<li>
<a href="?q=friend&f='.$s->getData('jid').'">
<img class="avatar" src="'.Contact::getPhotoFromJid('xs', $s->getData('jid')).'" />
<a href="?q=friend&f='.$s->jid.'">
<img class="avatar" src="'.$s->getPhoto('s').'" />
'.
$s->getTrueName().'
</a>

3
system/Widget/widgets/Notifs/notifs.css

@ -128,8 +128,7 @@
}
#notifslist ul li img {
display: none;
height: 24px;
margin-top: 2px;
max-width: 24px;
float: left;
border-radius: 2px;

18
system/Widget/widgets/Roster/Roster.php

@ -30,7 +30,6 @@ class Roster extends WidgetBase
$this->registerEvent('contactadd', 'onRoster');
$this->registerEvent('contactremove', 'onRoster');
$this->registerEvent('presence', 'onPresence');
//this->registerEvent('vcard', 'onVcard');
$this->cached = false;
}
@ -42,23 +41,6 @@ class Roster extends WidgetBase
RPC::cdata($arr['jid']), RPC::cdata($arr['presence_txt']));
}
/*function onVcard($contact)
{
$query = \Presence::query()->select()
->where(array(
'key' => $this->user->getLogin(),
'jid' => $contact->getData('jid')))
->limit(0, 1);
$data = \Presence::run_query($query);
$c = array();
$c[0] = $contact;
$c[1] = $data[0];
$html = $this->prepareRosterElement($c, true);
RPC::call('movim_fill', 'roster'.$contact->getData('jid'), RPC::cdata($html));
}*/
function onRoster()
{
$html = $this->prepareRoster();

65
system/Widget/widgets/Vcard/Vcard.php

@ -89,17 +89,13 @@ class Vcard extends WidgetBase
}
function prepareInfos($error = false) {
$query = Contact::query()
->where(
array(
'jid' => $this->user->getLogin()
)
);
$me = Contact::run_query($query);
$cd = new \modl\ContactDAO();
$me = $cd->get($this->user->getLogin());
$submit = $this->genCallAjax('ajaxVcardSubmit', "movim_parse_form('vcard')");
if(!isset($me[0])) {
if(!isset($me)) {
?>
<div class="message info">
<?php echo t("It's your first time on Movim! To fill in a
@ -115,8 +111,7 @@ class Vcard extends WidgetBase
}
if(isset($me[0])) {
$me = $me[0];
if(isset($me)) {
if($error == 'vcardfeaturenotimpl') {
$html .= '
@ -128,7 +123,7 @@ class Vcard extends WidgetBase
<div class="message error">'.t("Profile not updated : Request error").'</div>';
}
if($me->getData('public') == '1')
if($me->public == '1')
$color = 'black';
else
$color = 'red';
@ -140,17 +135,17 @@ class Vcard extends WidgetBase
$html .= '<div class="element">
<label for="fn">'.t('Name').'</label>
<input type="text" name="fn" class="content" value="'.$me->getData('fn').'">
<input type="text" name="fn" class="content" value="'.$me->fn.'">
</div>';
$html .= '<div class="element">
<label for="name">'.t('Nickname').'</label>
<input type="text" name="name" class="content" value="'.$me->getData('name').'">
<input type="text" name="name" class="content" value="'.$me->name.'">
</div>';
$html .= '<div class="element">
<label for="name">'.t('Email').'</label>
<input type="email" name="email" class="content" value="'.$me->getData('email').'">
<input type="email" name="email" class="content" value="'.$me->email.'">
</div>';
$html .= '<div class="element ">
@ -166,7 +161,7 @@ class Vcard extends WidgetBase
} else {
$j = $i;
}
if($i == substr( $me->getData('date'), 8)) {
if($i == substr( $me->date, 8)) {
$html .= '<option value="'.$j.'" selected>'.$j.'</option>';
} else {
$html .= '<option value="'.$j.'">'.$j.'</option>';
@ -186,7 +181,7 @@ class Vcard extends WidgetBase
} else {
$j = $i;
}
if($i == substr( $me->getData('date'), 5, 2)) {
if($i == substr( $me->date, 5, 2)) {
$html .= '<option value="'.$j.'" selected>'.$j.'</option>';
} else {
$html .= '<option value="'.$j.'">'.$j.'</option>';
@ -200,7 +195,7 @@ class Vcard extends WidgetBase
<select name="year" class="datepicker">
<option value="-1">'.t('Year').'</option>';
for($i=date('o'); $i>= 1920; $i--){
if($i == substr( $me->getData('date'), 0, 4)) {
if($i == substr( $me->date, 0, 4)) {
$html .= '<option value="'.$i.'" selected>'.$i.'</option>';
} else {
$html .= '<option value="'.$i.'">'.$i.'</option>';
@ -216,7 +211,7 @@ class Vcard extends WidgetBase
<div class="select"><select name="gender">';
foreach(getGender() as $key => $value) {
$html .= '<option ';
if($key == $me->getData('gender'))
if($key == $me->gender)
$html .= 'selected ';
$html .= 'value="'.$key.'">'.$value.'</option>';
}
@ -227,7 +222,7 @@ class Vcard extends WidgetBase
<div class="select"><select name="marital">';
foreach(getMarital() as $key => $value) {
$html .= '<option ';
if($key == $me->getData('marital'))
if($key == $me->marital)
$html .= 'selected ';
$html .= 'value="'.$key.'">'.$value.'</option>';
}
@ -235,19 +230,19 @@ class Vcard extends WidgetBase
</div>';
$html .= '<div class="element"><label for="url">'.t('Website').'</label>
<input type="url" name ="url" class="content" value="'.$me->getData('url').'">
<input type="url" name ="url" class="content" value="'.$me->url.'">
</div>';
$html .= '<div class="element"><label for="avatar">'.t('Avatar').'</label>
<input type="file" onchange="vCardImageLoad(this.files);">
<img id="vCardPhotoPreview" src="data:'.$me->getData('phototype').';base64,'.$me->getData('photobin').'">
<img id="vCardPhotoPreview" src="data:'.$me->phototype.';base64,'.$me->photobin.'">
<br /><span id="picturesize" class="clean"></span>
<input type="hidden" name="phototype" value="'.$me->getData('phototype').'"/>
<input type="hidden" name="photobin" value="'.$me->getData('photobin').'"/><br />
<input type="hidden" name="phototype" value="'.$me->phototype.'"/>
<input type="hidden" name="photobin" value="'.$me->photobin.'"/><br />
</div>';
$html .= '<div class="element large"><label for="desc">'.t('About Me').'</label>
<textarea name="desc" id="desctext" 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->desc).'</textarea>
</div>';
$html .= '</fieldset><br />';
@ -257,14 +252,14 @@ class Vcard extends WidgetBase
<legend>'.t('Geographic Position').'</legend>';
$html .= '<div class="element"><label for="url">'.t('Locality').'</label>
<input type="text" type="locality" name ="locality" class="content" value="'.$me->getData('adrlocality').'">
<input type="text" type="locality" name ="locality" class="content" value="'.$me->adrlocality.'">
</div>';
$html .= '<div class="element"><label for="country">'.t('Country').'</label>
<div class="select">
<select name="country">
<option value=""></option>';
$ctry = $me->adrcountry->getval();
$ctry = $me->adrcountry;
foreach(getCountries() as $value) {
$html .= '<option ';
if($value == $ctry)
@ -281,7 +276,7 @@ class Vcard extends WidgetBase
$html .= '<fieldset>
<legend>'.t('Privacy Level').'</legend>';
if($me->getData('public') == '1')
if($me->public == '1')
$checked = 'checked="true"';
else
$checked = '';
@ -300,21 +295,7 @@ class Vcard extends WidgetBase
</div>';
$html .= '</fieldset>';
/*$html .= '<br />
<fieldset>
<legend>'.t('Geographic Position').'</legend>';
$html .= '<div class="warning"><a class="button tiny" style="float: right;" onclick="getPos(this);">Récupérer ma position</a></div>';
$html .= '<div id="geolocation"></div>';
$html .= '<div class="element"><label>'.t('Latitude').'</label>
<input type="text" name="lat" class="content" value="Latitude" readonly>
</div>';
$html .= '<div class="element"><label>'.t('Longitude').'</label>
<input type="text" name="long" class="content" value="Longitude" readonly>
</div>';
$html .= '<hr />
</fieldset>';*/
$html .= '<hr /><br />';
$html .= '<a
onclick="

16
system/Widget/widgets/Wall/Wall.php

@ -25,7 +25,7 @@ class Wall extends WidgetCommon
{
$this->addcss('wall.css');
$this->addjs('wall.js');
$this->registerEvent('post', 'onNewPost');
$this->registerEvent('post', 'onStream');
$this->registerEvent('stream', 'onStream');
$this->registerEvent('comment', 'onComment');
$this->registerEvent('nocomment', 'onNoComment');
@ -34,17 +34,6 @@ class Wall extends WidgetCommon
$this->registerEvent('nostreamautorized', 'onNoStreamAutorized');
}
function onNewPost($id) {
$query = Post::query()
->where(array('key' => $this->user->getLogin(), 'nodeid' => $id));
$post = Post::run_query($query);
if($post != false) {
$html = $this->preparePost($post[0]);
RPC::call('movim_prepend', 'wall', RPC::cdata($html));
}
}
function onNoStream() {
$html = '<div style="padding: 1.5em; text-align: center;">Ain\'t Nobody Here But Us Chickens...</div>';
RPC::call('movim_fill', 'wall', RPC::cdata($html));
@ -73,9 +62,6 @@ class Wall extends WidgetCommon
$pl = $pd->getContact($from, $start+1, 10);
// We ask for the HTML of all the posts
/*foreach($pl as $post) {
$htmlmessages .= $this->printPost($post);
}*/
$htmlmessages = $this->preparePosts($pl);

Loading…
Cancel
Save