From 4d63c14339cbffeedb0506f48d8928490e54b6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaussoin=20Timoth=C3=A9e?= Date: Sat, 13 Oct 2012 12:16:39 +0200 Subject: [PATCH] - Add an "Explore" page to discover new contacts - New table "RosterLink" which split the Roster informations from the Contact table - Update all the widgets for the new DB structure - Clean lot of old stuffs in the code - New time detection for the server time - Improve page loading speed by reducing number of DB request and request answer size --- image.php | 36 +- loader.php | 8 +- system/Cache.php | 10 - system/Controller/ControllerMain.php | 43 +- system/Datas/Attachment.php | 103 --- system/Datas/Contact.php | 88 +- system/Datas/Post.php | 9 - system/Datas/RosterLink.php | 31 + system/Jabber.php | 797 ------------------ system/Utils.php | 55 ++ system/Widget/WidgetCommon.php | 22 +- system/Widget/widgets/Chat/Chat.php | 63 +- system/Widget/widgets/Chat/chat.css | 8 +- .../widgets/ContactCard/ContactCard.php | 1 - .../widgets/ContactInfo/ContactInfo.php | 33 +- .../widgets/ContactSummary/ContactSummary.php | 4 - system/Widget/widgets/Explore/Explore.php | 55 ++ system/Widget/widgets/Explore/explore.css | 44 + system/Widget/widgets/Feed/Feed.php | 10 - system/Widget/widgets/Login/Login.php | 4 +- system/Widget/widgets/Logout/Logout.php | 4 - system/Widget/widgets/Notifs/Notifs.php | 78 +- system/Widget/widgets/Profile/Profile.php | 1 - .../widgets/ProfileData/ProfileData.php | 3 +- system/Widget/widgets/Roster/Roster.php | 29 +- .../widgets/Syndication/Syndication.php | 2 - system/Widget/widgets/Vcard/Vcard.php | 16 +- system/Widget/widgets/Wall/Wall.php | 1 - themes/movim/config.tpl | 1 - themes/movim/explore.tpl | 25 + themes/movim/friend.tpl | 1 - 31 files changed, 406 insertions(+), 1179 deletions(-) delete mode 100644 system/Datas/Attachment.php create mode 100644 system/Datas/RosterLink.php delete mode 100644 system/Jabber.php create mode 100644 system/Widget/widgets/Explore/Explore.php create mode 100644 system/Widget/widgets/Explore/explore.css create mode 100644 themes/movim/explore.tpl diff --git a/image.php b/image.php index bb75a20ea..9e5e92fb1 100644 --- a/image.php +++ b/image.php @@ -36,6 +36,16 @@ function display_image($hash, $type) { header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); } +function display_default() { + ob_clean(); + ob_start(); + $content = file_get_contents('themes/movim/img/default.svg'); + + display_image($hash, "image/svg+xml"); + echo $content; + exit; +} + if (!function_exists('getallheaders')) { function getallheaders() { foreach($_SERVER as $key=>$value) { @@ -51,7 +61,7 @@ if (!function_exists('getallheaders')) { } // We load the avatar from the database and we display it -if(isset($_GET['c'])) { +//if(isset($_GET['c'])) { $hash = md5($_GET['c'].$_GET['size']); $headers = getallheaders(); @@ -61,31 +71,25 @@ if(isset($_GET['c'])) { { header('HTTP/1.1 304 Not Modified'); exit; - } elseif($_GET['c'] == 'default') { - ob_clean(); - ob_start(); - $content = file_get_contents('themes/movim/img/default.svg'); - - display_image($hash, "image/svg+xml"); - echo $content; - exit; - - } + } elseif($_GET['c'] == '' || $_GET['c'] == 'default') { + display_default(); + } else { $user = new User(); if($user->isLogged()) - $where = array('key' => $user->getLogin(), 'jid' => $_GET['c']); + $where = array('jid' => $_GET['c']); else $where = array('jid' => $_GET['c']); $c = new Contact(); $query = Contact::query()->select() - ->where($where); + ->where($where); $contact = Contact::run_query($query); - if($contact[0]->getData('phototype') != '' && + if(isset($contact[0]) && + $contact[0]->getData('phototype') != '' && $contact[0]->getData('photobin') != '' && $contact[0]->getData('phototype') != 'f' && $contact[0]->getData('photobin') != 'f') { @@ -137,9 +141,11 @@ if(isset($_GET['c'])) { display_image($hash, $contact[0]->getData('phototype')); echo base64_decode($contact[0]->getData('photobin')); } + } else { + display_default(); } } -} +//} // Closing db (dirty...) global $sdb; diff --git a/loader.php b/loader.php index 566eb90ab..d7eb37410 100644 --- a/loader.php +++ b/loader.php @@ -24,14 +24,13 @@ require_once(LIB_PATH . "Datas/Contact.php"); require_once(LIB_PATH . "Datas/Presence.php"); require_once(LIB_PATH . "Datas/Message.php"); require_once(LIB_PATH . "Datas/Post.php"); -require_once(LIB_PATH . "Datas/Attachment.php"); +require_once(LIB_PATH . "Datas/RosterLink.php"); require_once(LIB_PATH . "Session.php"); require_once(LIB_PATH . "Utils.php"); require_once(LIB_PATH . "Cache.php"); require_once(LIB_PATH . "Conf.php"); require_once(LIB_PATH . "Event.php"); -//require_once(LIB_PATH . "Jabber.php"); require_once(LIB_PATH . "Logger.php"); require_once(LIB_PATH . "MovimException.php"); require_once(LIB_PATH . "RPC.php"); @@ -56,10 +55,9 @@ define('JAXL_LOG_EVENT', true); define('JAXL_LOG_LEVEL', 4); define('JAXL_LOG_ROTATE', false); -//define('JAXL_BASE_PATH', LIB_PATH . 'Jaxl/'); - // We set the default timezone to the server timezone -date_default_timezone_set('UTC'); + +date_default_timezone_set(getLocalTimezone()); $useragent = $_SERVER['HTTP_USER_AGENT']; diff --git a/system/Cache.php b/system/Cache.php index ed9e25de5..e5e7085af 100644 --- a/system/Cache.php +++ b/system/Cache.php @@ -35,11 +35,6 @@ class Cache // Saving the user's login. $user = new User(); $this->login = $user->getLogin(); - - //$this->db = new DatajarEngineWrapper(Conf::getServerConfElement('storageConnection')); - - //$var = new CacheVar(); - //$this->db->create($var); } function __destruct() @@ -113,9 +108,6 @@ class Cache $md5 = md5($data); $time = time(); - //$var = new CacheVar(); - //$this->db->load($var, array('key' => $cache_key)); - $var = new CacheVar(); /*$success = $var->load(array( @@ -140,8 +132,6 @@ class Cache $var->timestamp = $time; $var->run_query($var->query()->save($var)); - - //$this->db->save($var); } /** diff --git a/system/Controller/ControllerMain.php b/system/Controller/ControllerMain.php index c0bccbe1b..c1e9c99a7 100644 --- a/system/Controller/ControllerMain.php +++ b/system/Controller/ControllerMain.php @@ -24,6 +24,8 @@ class ControllerMain extends ControllerBase { parent::__construct(); global $sdb; + $c = new RosterLink(); + $sdb->create($c); $c = new Contact(); $sdb->create($c); $p = new Presence(); @@ -46,6 +48,7 @@ class ControllerMain extends ControllerBase } else { $this->page->setTitle(t('%s - Welcome to Movim', APP_TITLE)); $this->page->menuAddLink(t('Home'), '?q=mainPage', true); + $this->page->menuAddLink(t('Explore'), '?q=explore'); $this->page->menuAddLink(t('Profile'), '?q=profile'); $this->page->menuAddLink(t('Configuration'), '?q=config'); $this->page->menuAddLink(t('Help'), '?q=help'); @@ -63,7 +66,11 @@ class ControllerMain extends ControllerBase $user = new User(); $query = Contact::query() - ->where(array('key' => $user->getLogin(), 'jid' => $_GET['f'])); + ->where( + array( + 'jid' => $_GET['f'] + ) + ); $contact = Contact::run_query($query); if(isset($contact[0])) @@ -102,6 +109,7 @@ class ControllerMain extends ControllerBase } else { $this->page->setTitle(t('%s - Configuration', APP_TITLE)); $this->page->menuAddLink(t('Home'), '?q=mainPage'); + $this->page->menuAddLink(t('Explore'), '?q=explore'); $this->page->menuAddLink(t('Profile'), '?q=profile'); $this->page->menuAddLink(t('Configuration'), '?q=config', true); $this->page->menuAddLink(t('Help'), '?q=help'); @@ -123,6 +131,7 @@ class ControllerMain extends ControllerBase } else { $this->page->setTitle(t('%s - Profile', APP_TITLE)); $this->page->menuAddLink(t('Home'), '?q=mainPage'); + $this->page->menuAddLink(t('Explore'), '?q=explore'); $this->page->menuAddLink(t('Profile'), '?q=profile', true); $this->page->menuAddLink(t('Configuration'), '?q=config'); $this->page->menuAddLink(t('Help'), '?q=help'); @@ -201,16 +210,35 @@ class ControllerMain extends ControllerBase */ function feed() { - /*$this->page->setTitle(t('%s - Login to Movim', APP_TITLE)); - $this->page->menuAddLink(t('Home'), '?q=mainPage', true); - - $content = new TplPageBuilder($user); - $this->page->setContent($content->build('login.tpl')); - echo $this->page->build('page.tpl');*/ $content = new TplPageBuilder(); echo $content->build('feed.tpl'); } + /** + * Explore the XMPP network + */ + function explore() + { + $user = new User(); + + $this->page->setTitle(t('%s - Explore', APP_TITLE)); + + if(!$user->isLogged()) { + $this->login(); + } else { + $this->page->menuAddLink(t('Home'), '?q=mainPage'); + $this->page->menuAddLink(t('Explore'), '?q=explore', true); + $this->page->menuAddLink(t('Profile'), '?q=profile'); + $this->page->menuAddLink(t('Configuration'), '?q=config'); + $this->page->menuAddLink(t('Help'), '?q=help'); + $this->page->menuAddLink(t('Logout'), '?q=disconnect'); + } + + $content = new TplPageBuilder($user); + $this->page->setContent($content->build('explore.tpl')); + echo $this->page->build('page.tpl'); + } + /* * Show help page @@ -226,6 +254,7 @@ class ControllerMain extends ControllerBase $this->login(); } else { $this->page->menuAddLink(t('Home'), '?q=mainPage'); + $this->page->menuAddLink(t('Explore'), '?q=explore'); $this->page->menuAddLink(t('Profile'), '?q=profile'); $this->page->menuAddLink(t('Configuration'), '?q=config'); $this->page->menuAddLink(t('Help'), '?q=help', true); diff --git a/system/Datas/Attachment.php b/system/Datas/Attachment.php deleted file mode 100644 index 964fcc7b1..000000000 --- a/system/Datas/Attachment.php +++ /dev/null @@ -1,103 +0,0 @@ -key = DatajarType::varchar(128); - $this->jid = DatajarType::varchar(128); - - $this->node = DatajarType::varchar(128); - $this->attachmentid = DatajarType::varchar(128); - - $this->title = DatajarType::varchar(128); - $this->type = DatajarType::varchar(128); - - $this->length = DatajarType::int(); - - $this->link = DatajarType::varchar(128); - $this->thumb = DatajarType::varchar(128); - } - - public function getData($data) { - return $this->$data->getval(); - } -} - -class AttachmentHandler { - static function getAttachment($key, $node) { - global $sdb; - $attachment = $sdb->select('Attachment', array('key' => $key, 'node'=> $node)); - if($attachment != false) - return $attachment; - else - return false; - } - - function saveAttachment($array, $jid, $from, $node) { - global $sdb; - $attachment = $sdb->select('Attachment', array( - 'key' => $jid, - 'jid' => $from, - 'node'=> $node, - 'attachmentid' => sha1($array['@attributes']['href']. - $array['@attributes']['title']. - $array['@attributes']['length']) - )); - - if($attachment == false) { - $attachment = new Attachment(); - $attachment->key = $jid; - $attachment->jid = $from; - - $attachment->node = $node; - $attachment->attachmentid = sha1($array['@attributes']['href']. - $array['@attributes']['title']. - $array['@attributes']['length']); - - $attachment->title = $array['@attributes']['title']; - $attachment->type = $array['@attributes']['type']; - - $attachment->length = $array['@attributes']['length']; - - $attachment->link = $array['@attributes']['href']; - $attachment->thumb = $array['link'][0]['@attributes']['href']; - - $sdb->save($attachment); - } else { - global $sdb; - $attachment = new Attachment(); - $sdb->load($attachment, array( - 'key' => $jid, - 'jid' => $from, - 'node'=> $node, - 'attachmentid' => sha1($array['@attributes']['href']. - $array['@attributes']['title']. - $array['@attributes']['length']) - )); - - $attachment->title = $array['@attributes']['title']; - $attachment->type = $array['@attributes']['type']; - - $attachment->length = $array['@attributes']['length']; - - $attachment->link = $array['@attributes']['href']; - $attachment->thumb = $array['link'][0]['@attributes']['href']; - - $sdb->save($attachment); - - } - } -} diff --git a/system/Datas/Contact.php b/system/Datas/Contact.php index 071995e44..4298c88d0 100644 --- a/system/Datas/Contact.php +++ b/system/Datas/Contact.php @@ -1,7 +1,7 @@ key = DatajarType::varchar(128); $this->jid = DatajarType::varchar(128); $this->fn = DatajarType::varchar(128); @@ -73,19 +64,11 @@ class Contact extends DatajarBase { $this->gender = DatajarType::varchar(1); $this->marital = DatajarType::varchar(20); - $this->group = DatajarType::varchar(128); - - $this->rostername = DatajarType::varchar(128); - $this->rosterask = DatajarType::varchar(128); - $this->rostersubscription = DatajarType::varchar(128); - $this->phototype = DatajarType::varchar(128); $this->photobin = DatajarType::text(); $this->desc = DatajarType::text(); - - $this->vcardreceived = DatajarType::int(); - $this->chaton = DatajarType::int(); + $this->public = DatajarType::int(); $this->mood = DatajarType::varchar(128); @@ -114,46 +97,6 @@ class Contact extends DatajarBase { $this->locuri = DatajarType::varchar(128); $this->loctimestamp = DatajarType::datetime(); } - - public function setContact($array) { - $user = new User(); - - $date = strtotime($array['vCard']['BDAY']); - if($date != false) - $this->date->setval(date('Y-m-d', $date)); - - $this->key->setval($user->getLogin()); - $this->jid->setval(($array['@attributes']['from'] != NULL) ? $array['@attributes']['from'] : $user->getLogin()); - - $this->name->setval($array['vCard']['NICKNAME']); - $this->fn->setval($array['vCard']['FN']); - $this->url->setval($array['vCard']['URL']); - - $this->gender->setval($array['vCard']['X-GENDER']); - $this->marital->setval($array['vCard']['MARITAL']['STATUS']); - - if($this->rostersubscription->getval() == false) - $this->rostersubscription->setval('none'); - - $this->phototype->setval($array['vCard']['PHOTO']['TYPE']); - $this->photobin->setval($array['vCard']['PHOTO']['BINVAL']); - - $this->desc->setval($array['vCard']['DESC']); - - $this->vcardreceived->setval(1); - $this->public->setval(0); - } - - public function setContactRosterItem($item) { - $user = new User(); - - $this->key->setval($user->getLogin()); - $this->jid->setval($item['@attributes']['jid']); - $this->rostername->setval($item['@attributes']['name']); - $this->rosterask->setval($item['@attributes']['ask']); - $this->rostersubscription->setval($item['@attributes']['subscription']); - $this->group->setval($item['group']); - } public function getTrueName() { $truename = ''; @@ -163,8 +106,8 @@ class Contact extends DatajarBase { $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)) - $truename = $this->rostername->getval(); + //elseif(isset($this->rostername) && $this->rostername->getval() != '' && !filter_var($this->rostername->getval(), FILTER_VALIDATE_EMAIL)) + // $truename = $this->rostername->getval(); else $truename = $this->jid->getval(); @@ -172,7 +115,15 @@ class Contact extends DatajarBase { } public function getData($data) { - return $this->$data->getval(); + return trim($this->$data->getval()); + } + + public function getAge() { + if(isset($this->date) && $this->date->getval() != '0000-00-00') { + return floor( (strtotime(date('Y-m-d')) - strtotime($this->date->getval())) / 31556926).' '.t('yo'); + } else { + return ''; + } } public function getPlace() { @@ -216,8 +167,10 @@ class Contact extends DatajarBase { strtotime((string)$stanza->item->geoloc->timestamp))); } - public function getPhoto($size = 'normal') { - if( + public function getPhoto($size = 'normal', $jid = false) { + if($jid != false) + $str = 'image.php?c='.$jid.'&size='.$size; + elseif( isset($this->phototype) && isset($this->photobin) && $this->phototype->getval() != '' @@ -232,6 +185,11 @@ class Contact extends DatajarBase { return $str; } + static public function getPhotoFromJid($size, $jid) { + $c = new Contact(); + return $c->getPhoto($size, $jid); + } + } class ContactHandler { @@ -244,7 +202,7 @@ class ContactHandler { public function get($jid) { global $sdb; $user = new User(); - $sdb->load($this->instance, array('key' => $user->getLogin(), 'jid' => $jid)); + $sdb->load($this->instance, array('jid' => $jid)); return $this->instance; } } diff --git a/system/Datas/Post.php b/system/Datas/Post.php index 7e07020b5..6a8554f3e 100644 --- a/system/Datas/Post.php +++ b/system/Datas/Post.php @@ -103,18 +103,9 @@ class Post extends DatajarBase { $this->street->setval((string)$item->entry->geoloc->street); $this->building->setval((string)$item->entry->geoloc->building); - // If we have only one link in the entry - /*if(string)$item->entry->link->attributes()) { - (string)$item->entry->link[0]['attributes() = (string)$item->entry->link->attributes(); - unset((string)$item->entry->link->attributes()); - }*/ - $contentimg = ''; foreach($item->entry->link as $attachment) { - /*if($attachment['link[0]['attributes()->title == 'thumb') { - AttachmentHandler::saveAttachment($attachment, $key, $from, (string)$item->attributes()->id); - }*/ if(isset($attachment->link[0]) && (string)$attachment->link[0]->attributes()->title == 'thumb') { $contentimg .= ' '; diff --git a/system/Datas/RosterLink.php b/system/Datas/RosterLink.php new file mode 100644 index 000000000..c964460c9 --- /dev/null +++ b/system/Datas/RosterLink.php @@ -0,0 +1,31 @@ +key = DatajarType::varchar(128); + $this->jid = DatajarType::varchar(128); + + $this->rostername = DatajarType::varchar(128); + $this->rosterask = DatajarType::varchar(128); + $this->rostersubscription = DatajarType::varchar(128); + + $this->group = DatajarType::varchar(128); + + $this->chaton = DatajarType::int(); + } + + public function getData($data) { + return trim($this->$data->getval()); + } +} diff --git a/system/Jabber.php b/system/Jabber.php deleted file mode 100644 index cdb0df866..000000000 --- a/system/Jabber.php +++ /dev/null @@ -1,797 +0,0 @@ - - * - * @version 1.0 - * @date 13 October 2010 - * - * Copyright (C)2010 Movim Project - * - * See COPYING for licensing information. - */ - -//include(LIB_PATH . 'Jaxl/core/jaxl.class.php'); - -class Jabber -{ - private static $instance; - private $jaxl; - private $payload; - - /** - * Firing up basic parts of jaxl and setting variables. - */ - private function __construct($jid) - { - $userConf = UserConf::getConf($jid); - - $serverConf = Conf::getServerConf(); - - $sess = Session::start(APP_NAME); - - $sess->remove('jid'); // ??? - - $this->jaxl = new JAXL(array( - // User Configuration - 'resource' => "Movim", - - // Here we need to exchange the host and domain to allow the connexion, Jaxl bug ? - 'host' => $userConf['domain'], - 'domain' => $userConf['host'], - - 'boshHost' => $userConf['boshHost'], - 'boshSuffix' => $userConf['boshSuffix'], - 'boshPort' => $userConf['boshPort'], - - // Server configuration - 'boshCookieTTL' => $serverConf['boshCookieTTL'], - 'boshCookiePath' => $serverConf['boshCookiePath'], - 'boshCookieDomain' => $serverConf['boshCookieDomain'], - 'boshCookieHTTPS' => $serverConf['boshCookieHTTPS'], - 'boshCookieHTTPOnly' => $serverConf['boshCookieHTTPOnly'], - 'logLevel' => $serverConf['logLevel'], - 'boshOut'=>false, - - )); - // Loading required XEPS - $this->jaxl->requires(array( - 'JAXL0030', // Service Discovery - 'JAXL0054', // VCard - 'JAXL0060', // Pubsub - 'JAXL0107', // User Mood - 'JAXL0118', // User Tune - 'JAXL0115', // Entity Capabilities - 'JAXL0133', // Service Administration - 'JAXL0085', // Chat State Notification - 'JAXL0092', // Software Version - 'JAXL0203', // Delayed Delivery - 'JAXL0202', // Entity Time - 'JAXL0206', // Jabber over Bosh - 'JAXL0277' // Microblogging - )); - - // Defining call-backs - - // Connect-Disconnect - $this->jaxl->addPlugin('jaxl_post_auth', array(&$this, 'postAuth')); - $this->jaxl->addPlugin('jaxl_post_auth_failure', array(&$this, 'postAuthFailure')); - $this->jaxl->addPlugin('jaxl_post_disconnect', array(&$this, 'postDisconnect')); - $this->jaxl->addPlugin('jaxl_get_auth_mech', array(&$this, 'postAuthMech')); - - // The handlers - $this->jaxl->addPlugin('jaxl_get_iq', array(&$this, 'getIq')); - $this->jaxl->addPlugin('jaxl_get_message', array(&$this, 'getMessage')); - $this->jaxl->addPlugin('jaxl_get_presence', array(&$this, 'getPresence')); - - // Others hooks - $this->jaxl->addPlugin('jaxl_get_bosh_curl_error', array(&$this, 'boshCurlError')); - $this->jaxl->addplugin('jaxl_get_empty_body', array(&$this, 'getEmptyBody')); - } - - /** - * Get the current instance - * - * @param string $jid = false - * @return instance - */ - static public function getInstance($jid = false) - { - if(!is_object(self::$instance)) { - if(!$jid) { - $user = new User(); - if(!$user->isLogged()) { - return false; - throw new MovimException(t("User not logged in.")); - } else { - $jid = $user->getLogin(); - if($jid = "") - throw new MovimException(t("JID not provided.")); - } - } else { - self::$instance = new Jabber($jid); - } - } - return self::$instance; - } - - function destroy() - { - self::$instance = null; - } - - /** - * Start the BOSH connection - * - * @param string $jid - * @param string $pass - * @return void - */ - public function login($jid, $pass) - { - if(!checkJid($jid)) { - throw new MovimException(t("jid '%s' is incorrect", $jid)); - } else { - $id = explode('@',$jid); - $user = $id[0]; - - $this->jaxl->user = $user; - $this->jaxl->pass = $pass; - $this->jaxl->startCore('bosh'); - } - - self::setStatus($presence['status'], $presence['show'], false, true); - } - - /** - * postAuth - * - * @return void - */ - public function postAuth() { - - } - - /** - * postAuthFailure - * - * @return void - */ - public function postAuthFailure() { - $this->jaxl->shutdown(); - - throw new MovimException("Login error.", 300); - - $user = new User(); - $user->desauth(); - } - - /** - * Return the current ressource - * - * @return string - */ - public function getResource() - { - $res = JAXLUtil::splitJid($this->jaxl->jid); - return $res[2]; - } - - /** - * Return the current Cleaned Jid - * - * @return string - */ - public function getCleanJid() { - $jid = $this->jaxl->jid; - $res = JAXLUtil::splitJid($jid); - return $res[0].'@'.$res[1]; - } - - public function boshCurlError() { -// $this->jaxl->shutdown(); -// throw new MovimException("Bosh connection error."); -// $user = new User(); -// $user->desauth(); - } - - /** - * Auth mechanism - * - * @param array $mechanism - * @return void - */ - public function postAuthMech($mechanism) { - if(in_array("DIGEST-MD5", $mechanism)) - $this->jaxl->auth('DIGEST-MD5'); - elseif(in_array("PLAIN", $mechanism)) - $this->jaxl->auth('PLAIN'); - } - - /** - * Close the BOSH connection - * - * @return void - */ - public function logout() - { - $this->jaxl->JAXL0206('endStream'); - } - - /** - * postDisconnect - * - * @param array $data - * @return void - */ - public function postDisconnect($data) - { - $evt = new Event(); - $evt->runEvent('postdisconnected', $data); - } - - /** - * Pings the server. This must be done regularly in order to keep the - * session running - * - * @return void - */ - public function pingServer() - { - $this->jaxl->JAXL0206('ping'); - } - - /** - * Get an empty body - * - * @param array $payload - * @return void - */ - public function getEmptyBody($payload) { - $evt = new Event(); - // Oooooh, am I disconnected?? - if(preg_match('/condition=[\'"]item-not-found[\'"]/', $payload) || preg_match('/condition=[\'"]improper-addressing[\'"]/', $payload)) { - $this->postAuthFailure(); - } else { - $evt->runEvent('incomingemptybody', 'ping'); - } - } - - /** - * Iq handler - * - * @param array $payload - * @return void - */ - public function getIq($payload) { - $payload = $payload['movim']; - - global $sdb; - $evt = new Event(); - - // Holy mackerel, that's a vcard! - if(is_array($payload['vCard']) && - $payload['@attributes']['type'] != 'error') - { - $c = new ContactHandler(); - - // If the vcard is mine - if($payload['@attributes']['from'] == $this->getCleanJid() || - $payload['@attributes']['from'] == NULL ) - { - $contact = $c->get($this->getCleanJid()); - $contact->setContact($payload); - $sdb->save($contact); - $evt->runEvent('myvcard', $payload); - } - - // Yo it's your vcard dude ! - elseif(isset($payload['@attributes']['from'])) { - $contact = $c->get($payload['@attributes']['from']); - $contact->setContact($payload); - $sdb->save($contact); - $evt->runEvent('vcard', $contact); - } - } - - elseif($payload['@attributes']['xmlns'] == 'http://jabber.org/protocol/disco#info') { - global $sdb; - - $c = new CapsHandler(); - $caps = $c->get($payload['query']['@attributes']['node']); - $caps->setCaps($payload['query']); - - $sdb->save($caps); - } - - // Roster case - elseif($payload['@attributes']['xmlns'] == 'jabber:iq:roster') { - global $sdb; - - // If we got the full roster list - if($payload['@attributes']['type'] == 'result') { - - foreach($payload['query']['item'] as $item) { - // If we've got only one item in the roster we use it as the only one - if(isset($item['subscription'])) - $item = $payload['query']['item']; - - $c = new ContactHandler(); - $contact = $c->get($item['@attributes']['jid']); - $contact->setContactRosterItem($item); - $sdb->save($contact); - } - - $evt->runEvent('roster', $payload); - } - // If we got only one item - elseif($payload['@attributes']['type'] == "set") { - $c = new ContactHandler(); - - $item = $payload['query']['item']; - $contact = $c->get($item['@attributes']['jid']); - - // It's a new contact ! - if($item['@attributes']['subscription'] == 'remove') { - $evt->runEvent('contactremove', $item['@attributes']['jid']); - } - // Contact removed - elseif(in_array($item['@attributes']['subscription'], array('from', 'to', 'both'))) { - $contact->setContactRosterItem($item); - $sdb->save($contact); - $evt->runEvent('contactadd', $item['@attributes']['jid']); - } - } - } - // Pubsub case - elseif(isset($payload['pubsub']) && !(isset($payload['error']))) { - list($xmlns, $parent) = explode("/", $payload['pubsub']['items']['@attributes']['node']); - - if(isset($payload['pubsub']['items']['item'])) { - foreach($payload['pubsub']['items']['item'] as $item) { - - if(isset($item['id'])) - $item = $payload['pubsub']['items']['item']; - - // We've got a new Post ! - if(isset($item['@attributes']) && isset($item['entry'])) { - $c = new PostHandler(); - $post = $c->get($this->getCleanJid(), $item['@attributes']['id']); - - // We save it in the database - if($xmlns == 'urn:xmpp:microblog:0') - $post->setPost($item, $payload['@attributes']['from']); - elseif($xmlns == 'urn:xmpp:microblog:0:comments') - $post->setPost($item, $payload['@attributes']['from'], $parent); - - $sdb->save($post); - - // And we run the correct event - if($xmlns == 'urn:xmpp:microblog:0') { - $evt->runEvent('post', $item['@attributes']['id']); - $evt->runEvent('stream', $payload); - } elseif($xmlns == 'urn:xmpp:microblog:0:comments') - $evt->runEvent('comment', $parent); - } - } - } elseif(isset($payload['pubsub']['publish']['@attributes']['node'])) { - list($xmlns, $id) = explode("/", $payload['pubsub']['publish']['@attributes']['node']); - if($payload['pubsub']['publish']['@attributes']['node'] == 'urn:xmpp:microblog:0') { - $this->getWallItem($this->getCleanJid(), $payload['pubsub']['publish']['item']['@attributes']['id']); - } - $this->getComments($payload['@attributes']['from'], $id); - } else { - $evt->runEvent('nocomment', $parent); - if($xmlns == 'urn:xmpp:microblog:0') - $evt->runEvent('nostream', $parent); - } - } - elseif(isset($payload['pubsub']) && isset($payload['error'])) { - list($xmlns, $parent) = explode("/", $payload['pubsub']['items']['@attributes']['node']); - if(isset($payload['error']['item-not-found'])) { - if($xmlns == 'urn:xmpp:microblog:0:comments') - $evt->runEvent('nocommentstream', $parent); - else - $evt->runEvent('nostream', $parent); - } - elseif(in_array( $payload['error']['@attributes']['code'], array(501, 503)) && - $payload['pubsub']['create']['@attributes']['node'] == 'urn:xmpp:microblog:0') { - $conf = new ConfVar(); - $sdb->load($conf, array( - 'login' => $this->getCleanJid() - )); - $conf->set('first', 3); - $sdb->save($conf); - } - elseif(isset($payload['error']['feature-not-implemented']) || - isset($payload['error']['not-authorized']) || - isset($payload['error']['service-unavailable']) || - isset($payload['error']['item-not-found'])) { - $evt->runEvent('nostream'); - } - } - elseif(isset($payload['error'])) { - $evt->runEvent('nostream'); - } - - else { - $evt->runEvent('none', var_export($payload, true)); - } - - $evt->runEvent('incomingemptybody', 'ping'); - } - - /** - * Message handler - * - * @param array $payloads - * @return void - */ - public function getMessage($payloads) { - $evt = new Event(); - - foreach($payloads as $payload) { - - if($payload['offline'] != JAXL0203::$ns && $payload['type'] == 'chat') { // reject offline message - - if($payload['chatState'] == 'active' && $payload['body'] == NULL) - $evt->runEvent('incomeactive', $payload); - elseif($payload['chatState'] == 'composing') - $evt->runEvent('composing', $payload); - elseif($payload['chatState'] == 'paused') - $evt->runEvent('paused', $payload); - - else { - global $sdb; - $m = new Message(); - $m->setMessageChat($payload['movim']); - $sdb->save($m); - - $evt->runEvent('message', $m); - } - } elseif($payload['movim']['event']['items']['@attributes']['node'] == 'urn:xmpp:microblog:0') { - $payload = $payload['movim']; - - if(isset($payload['event']['items']['item'])) { - global $sdb; - $c = new PostHandler(); - $post = $c->get($this->getCleanJid(), $payload['event']['items']['item']['@attributes']['id']); - if($post->getData('nodeid') == $payload['event']['items']['item']['@attributes']['id']) - $new = true; - $post->setPost($payload['event']['items']['item'], $payload['@attributes']['from'], false, $this->getCleanJid()); - $sdb->save($post); - } - - if($new == false) { - $sess = Session::start(APP_NAME); - if($sess->get('currentcontact') == $payload['@attributes']['from']) { - $evt->runEvent('currentpost', $payload); - } - - if($payload['@attributes']['from'] != $this->getCleanJid()) - $evt->runEvent('post', $payload['event']['items']['item']['@attributes']['id']); - } - } - } - - $evt->runEvent('incomingemptybody', 'ping'); - } - - /** - * Presence handler - * - * @param array $payloads - * @return void - */ - public function getPresence($payloads) { - global $sdb; - $evt = new Event(); - - foreach($payloads as $payload) { - - $payload = $payload['movim']; - if($payload['@attributes']['type'] == 'subscribe') { - $evt->runEvent('subscribe', $payload); - } - else { - - // We update the presences - list($jid, $ressource) = explode('/',$payload['@attributes']['from']); - - // We ask for the entity-capabilities and we prevent to ask our own capabilities - if(isset($payload['c']) && $jid != $this->getCleanJid()) { - $c = new CapsHandler(); - $caps = $c->get($payload['c']['@attributes']['node'].'#'.$payload['c']['@attributes']['ver']); - - // We ask for the caps only if we haven't found it in the database - if($caps->getData('category') == null) { - $this->jaxl->JAXL0030( - 'discoInfo', - $payload['@attributes']['from'], - $this->getCleanJid(), - false, - $payload['c']['@attributes']['node'].'#'.$payload['c']['@attributes']['ver'] - ); - } - } - - $presence = $sdb->select('Presence', array( - 'key' => $this->getCleanJid(), - 'jid' => $jid, - 'ressource' => $ressource - )); - if($presence == false) { - $presence = new Presence(); - $presence->setPresence($payload); - $sdb->save($presence); - } else { - $presence = new Presence(); - $sdb->load($presence, array( - 'key' => $this->getCleanJid(), - 'jid' => $jid, - 'ressource' => $ressource - )); - $presence->setPresence($payload); - $sdb->save($presence); - } - - if($payload['@attributes']['from'] == $payload['@attributes']['to']) - $evt->runEvent('mypresence', $presence); - - $evt->runEvent('presence', $presence); - } - } - - $evt->runEvent('incomingemptybody', 'ping'); - } - - /** - * Ask for a vCard - * - * @param string $jid = false - * @return void - */ - public function getVCard($jid = false) - { - $this->jaxl->JAXL0054('getVCard', $jid, $this->jaxl->jid, false); - } - - /** - * sendVcard - * - * @param array $vcard - * @return void - */ - public function updateVcard($vcard) - { - $this->jaxl->JAXL0054('updateVCard', $vcard); - $this->jaxl->JAXL0054('getVCard', false, $this->jaxl->jid, false); - } - - /** - * Create personnal microblog node - * - * @return void - */ - - public function createNode() - { - $this->jaxl->JAXL0277('createNode', $this->getCleanJid()); - } - - /** - * Subscribe to a node - * - * @param unknown $jid = false - * @return void - */ - - public function subscribeNode($jid) - { - $this->jaxl->JAXL0277('subscribeNode', $this->getCleanJid(), $jid); - } - - /** - * Ask for some items - * - * @param unknown $jid = false - * @return void - */ - public function getWall($jid = false) { - $this->jaxl->JAXL0277('getItems', $jid); - } - - /** - * Ask for an item - * - * @param unknown $jid = false - * @return void - */ - public function getWallItem($jid = false, $id) { - $this->jaxl->JAXL0277('getItem', $jid, $id); - } - - /** - * Ask for some comments of an article - * - * @param string $jid - * @param string $id - * @return void - */ - public function getComments($place, $id) { - $this->jaxl->JAXL0277('getComments', $place, $id); - } - - /** - * Service Discovery - * - * @param string $jid = false - * @return void - */ - public function discover($jid = false) - { - $this->jaxl->JAXL0277('getItems', 'edhelas@jappix.com'); - } - - public function discoNodes($pod) - { - $this->jaxl->JAXL0060('discoNodes', $pod, $this->jaxl->jid); - } - - /** - * Get some items about a node - * - * @param string $pod - * @param string $node - * @return void - */ - public function discoItems($pod, $node) - { - $this->jaxl->JAXL0060('getNodeItems', $pod, $this->jaxl->jid, $node); - } - - /** - * Publish an item on microblog feed - * - * @param string $content - * @return void - */ - public function publishItem($content) - { - $id = md5(openssl_random_pseudo_bytes(5)); - $this->jaxl->JAXL0277('createCommentNode', $this->getCleanJid() ,$id); - $this->jaxl->JAXL0277('publishItem', $this->getCleanJid() ,$content, false, false, $id); - } - - /** - * Publish a comment on a microblog item - * - * @param string $content - * @return void - */ - public function publishComment($place, $id, $content) - { - $this->jaxl->JAXL0277('publishComment', $place, $id ,$content, $this->getCleanJid()); - } - - /** - * Ask for the roster - * - * @return void - */ - public function getRosterList() - { - $this->jaxl->getRosterList(); - } - - /** - * Set a new status - * - * @param string $status - * @param string $show - * @return void - */ - public function setStatus($status, $show) - { - $this->jaxl->setStatus($status, $show, 41, false); - } - - /** - * Send a message - * - * @param string $addressee - * @param steirng $body - * @return void - */ - public function sendMessage($addressee, $body) - { - // Checking on the jid. - if(checkJid($addressee)) { - $this->jaxl->sendMessage($addressee, $body, false, 'chat'); - } else { - throw new MovimException("Incorrect JID `$addressee'"); - } - } - - /** - * Subscribe to a contact request - * - * @param unknown $jid - * @return void - */ - public function subscribedContact($jid) { - if(checkJid($jid)) { - $this->jaxl->subscribed($jid); - $this->jaxl->addRoster($jid); - } else { - throw new MovimException("Incorrect JID `$jid'"); - } - } - - /** - * Accecpt a new contact - * - * @param string $jid - * @param string $group - * @param string $alias - * @return void - */ - public function acceptContact($jid, $group, $alias) - { - if(checkJid($jid)) { - $this->jaxl->addRoster($jid, $group, $alias); - $this->jaxl->subscribe($jid); - } else { - throw new MovimException("Incorrect JID `$jid'"); - } - } - - /** - * Add a new contact - * - * @param string $jid - * @param string $grJaxloup - * @param string $alias - * @return void - */ - public function addContact($jid, $group, $alias) { - if(checkJid($jid)) { - $this->jaxl->subscribe($jid); - } else { - throw new MovimException("Incorrect JID `$jid'"); - } - } - - /** - * Remove a contact - * - * @param string $jid - * @return void - */ - public function removeContact($jid) { - if(checkJid($jid)) { - $this->jaxl->deleteRoster($jid); - $this->jaxl->unsubscribe($jid); - } else { - throw new MovimException("Incorrect JID `$jid'"); - } - } - - /** - * Unsubscribe to a contact - * - * @param unknown $jid - * @return void - */ - public function unsubscribed($jid) { - $this->jaxl->unsubscribed($jid); - } - -} - -?> diff --git a/system/Utils.php b/system/Utils.php index 67e65f1a1..c8887d0fe 100644 --- a/system/Utils.php +++ b/system/Utils.php @@ -256,6 +256,61 @@ function getPresences() { ); } +/* + * Get the user local timezone + */ +function getLocalTimezone() +{ + $iTime = time(); + $arr = localtime($iTime); + $arr[5] += 1900; + $arr[4]++; + $iTztime = gmmktime($arr[2], $arr[1], $arr[0], $arr[4], $arr[3], $arr[5], $arr[8]); + $offset = doubleval(($iTztime-$iTime)/(60*60)); + $zonelist = + array + ( + 'Kwajalein' => -12.00, + 'Pacific/Midway' => -11.00, + 'Pacific/Honolulu' => -10.00, + 'America/Anchorage' => -9.00, + 'America/Los_Angeles' => -8.00, + 'America/Denver' => -7.00, + 'America/Tegucigalpa' => -6.00, + 'America/New_York' => -5.00, + 'America/Caracas' => -4.30, + 'America/Halifax' => -4.00, + 'America/St_Johns' => -3.30, + 'America/Argentina/Buenos_Aires' => -3.00, + 'America/Sao_Paulo' => -3.00, + 'Atlantic/South_Georgia' => -2.00, + 'Atlantic/Azores' => -1.00, + 'Europe/Dublin' => 0, + 'Europe/Belgrade' => 1.00, + 'Europe/Minsk' => 2.00, + 'Asia/Kuwait' => 3.00, + 'Asia/Tehran' => 3.30, + 'Asia/Muscat' => 4.00, + 'Asia/Yekaterinburg' => 5.00, + 'Asia/Kolkata' => 5.30, + 'Asia/Katmandu' => 5.45, + 'Asia/Dhaka' => 6.00, + 'Asia/Rangoon' => 6.30, + 'Asia/Krasnoyarsk' => 7.00, + 'Asia/Brunei' => 8.00, + 'Asia/Seoul' => 9.00, + 'Australia/Darwin' => 9.30, + 'Australia/Canberra' => 10.00, + 'Asia/Magadan' => 11.00, + 'Pacific/Fiji' => 12.00, + 'Pacific/Tongatapu' => 13.00 + ); + $index = array_keys($zonelist, $offset); + if(sizeof($index)!=1) + return false; + return $index[0]; +} + /** * Check the current Jid * diff --git a/system/Widget/WidgetCommon.php b/system/Widget/WidgetCommon.php index 971b8f715..7d2606243 100644 --- a/system/Widget/WidgetCommon.php +++ b/system/Widget/WidgetCommon.php @@ -46,7 +46,6 @@ class WidgetCommon extends WidgetBase { ->where( array( 'Post`.`key' => $this->user->getLogin(), - 'Contact`.`key' => $this->user->getLogin(), array('Post`.`parentid' => $commentid))) ->orderby('Post.published', false); $comments = Post::run_query($query); @@ -97,8 +96,13 @@ class WidgetCommon extends WidgetBase { $tmp .= 'protect black'; else $tmp .= 'protect orange'; - //$tmp .= 'me'; } + + if($message[1]->getTrueName() == null) + $name = $message[0]->getData('jid'); + else + $name = $message[1]->getTrueName(); + $tmp .= '" id="'.$message[0]->getData('nodeid').'" > @@ -106,7 +110,7 @@ class WidgetCommon extends WidgetBase { - '.$message[1]->getTrueName().' + '.$name.' '.prepareDate(strtotime($message[0]->getData('updated'))).' @@ -114,16 +118,7 @@ class WidgetCommon extends WidgetBase { $tmp .= '
'.prepareString(html_entity_decode($message[0]->getData('content'))). '
'; - - //$attachments = AttachmentHandler::getAttachment($this->user->getLogin(), $message[0]->getData('nodeid')); - /*if($attachments) { - $tmp .= '
'; - foreach($attachments as $attachment) - $tmp .= ''.$attachment->getData('title').''; - $tmp .= '
'; - }*/ - - + if($message[0]->getPlace() != false) $tmp .= ' getPhoto('s'); $name = $comment[1]->getTrueName(); diff --git a/system/Widget/widgets/Chat/Chat.php b/system/Widget/widgets/Chat/Chat.php index 03c46c938..ba0ed7c66 100644 --- a/system/Widget/widgets/Chat/Chat.php +++ b/system/Widget/widgets/Chat/Chat.php @@ -69,11 +69,11 @@ class Chat extends WidgetBase $jid = $message->getData('from'); } - $query = Contact::query()->select() + $query = RosterLink::query()->select() ->where(array( 'key' => $key, 'jid' => $jid)); - $contact = Contact::run_query($query); + $contact = RosterLink::run_query($query); if($contact) $contact = $contact[0]; @@ -120,11 +120,11 @@ class Chat extends WidgetBase function onComposing($jid) { - $query = Contact::query()->select() + $query = RosterLink::query()->select() ->where(array( 'key' => $this->user->getLogin(), 'jid' => $jid)); - $contact = Contact::run_query($query); + $contact = RosterLink::run_query($query); $contact = $contact[0]; if($contact->getData('chaton') == 1) { @@ -138,11 +138,11 @@ class Chat extends WidgetBase function onPaused($jid) { - $query = Contact::query()->select() + $query = RosterLink::query()->select() ->where(array( 'key' => $this->user->getLogin(), 'jid' => $jid)); - $contact = Contact::run_query($query); + $contact = RosterLink::run_query($query); $contact = $contact[0]; if($contact->getData('chaton') == 1) { @@ -163,21 +163,22 @@ class Chat extends WidgetBase */ function ajaxOpenTalk($jid) { - $query = Contact::query()->select() + $query = RosterLink::query()->select() ->where(array( - 'key' => $this->user->getLogin(), - 'jid' => $jid)); - $contact = Contact::run_query($query); + 'RosterLink`.`key' => $this->user->getLogin(), + 'RosterLink`.`jid' => $jid)); + $contact = RosterLink::run_query($query); $contact = $contact[0]; - + $query = Presence::query()->select() ->where(array( 'key' => $this->user->getLogin(), - 'jid' => $jid)); + 'jid' => $jid)) + ->orderby('presence', false); $presence = Presence::run_query($query); $presence = $presence[0]; - - if($contact->getData('chaton') == 0 && isset($presence) && $presence->presence->getval() != 6) { + + if($contact->getData('chaton') == 0 && isset($presence) && !in_array($presence->presence->getval(), array(5, 6))) { $contact->chaton->setval(2); $contact->run_query($contact->query()->save($contact)); @@ -229,12 +230,12 @@ class Chat extends WidgetBase */ function ajaxCloseTalk($jid) { - $query = Contact::query()->select() + $query = RosterLink::query()->select() ->where(array( 'key' => $this->user->getLogin(), 'jid' => $jid)); - $contacts = Contact::run_query($query); - //$contact = $contact[0]; + $contacts = RosterLink::run_query($query); + foreach($contacts as $contact) { if((int)$contact->getData('chaton') == 1 || (int)$contact->getData('chaton') == 2) { $contact->chaton->setval(0); @@ -246,11 +247,11 @@ class Chat extends WidgetBase function ajaxHideTalk($jid) { - $query = Contact::query()->select() + $query = RosterLink::query()->select() ->where(array( 'key' => $this->user->getLogin(), 'jid' => $jid)); - $contact = Contact::run_query($query); + $contact = RosterLink::run_query($query); $contact = $contact[0]; if($contact->getData('chaton') == 1) { @@ -324,9 +325,9 @@ class Chat extends WidgetBase
@@ -347,7 +348,7 @@ class Chat extends WidgetBase
getData('jid')."'").' showTalk(this);">
- '.$contact->getTrueName().' + '.$contact->getData('rostername').'
@@ -357,16 +358,16 @@ class Chat extends WidgetBase function build() { - $query = Contact::query() - ->where( - array( - 'key' => $this->user->getLogin(), + $query = RosterLink::query() + ->where( array( - 'chaton' => - array(1, '|2')) - ) - ); - $contacts = Contact::run_query($query); + 'RosterLink`.`key' => $this->user->getLogin(), + array( + 'chaton' => + array(1, '|2')) + ) + ); + $contacts = RosterLink::run_query($query); echo '
'; if($contacts != false) { diff --git a/system/Widget/widgets/Chat/chat.css b/system/Widget/widgets/Chat/chat.css index 31212cd2c..b4365f77c 100644 --- a/system/Widget/widgets/Chat/chat.css +++ b/system/Widget/widgets/Chat/chat.css @@ -85,6 +85,12 @@ #chats .chat .panel .head a.name { padding-right: 1em; + display: inline-block; + margin: 0px; + width: 145px; + overflow: hidden; + text-overflow: ellipsis; + margin-top: 3px; } #chats .chat .tab:hover { @@ -100,7 +106,7 @@ #chats .chat .panel .head { background-color: #242424; color: white; - line-height: 24px; + line-height: 17px; border: 1px solid #222; border-radius: 2px 2px 0px 0px; border-bottom: 1px solid #242424; diff --git a/system/Widget/widgets/ContactCard/ContactCard.php b/system/Widget/widgets/ContactCard/ContactCard.php index d3c759c56..d68986648 100644 --- a/system/Widget/widgets/ContactCard/ContactCard.php +++ b/system/Widget/widgets/ContactCard/ContactCard.php @@ -97,7 +97,6 @@ class ContactCard extends WidgetCommon { $query = Contact::query()->select() ->where(array( - 'key' => $this->user->getLogin(), 'jid' => $_GET['f'])); $contact = Contact::run_query($query); ?> diff --git a/system/Widget/widgets/ContactInfo/ContactInfo.php b/system/Widget/widgets/ContactInfo/ContactInfo.php index af8d9a660..5802b56d5 100644 --- a/system/Widget/widgets/ContactInfo/ContactInfo.php +++ b/system/Widget/widgets/ContactInfo/ContactInfo.php @@ -24,28 +24,24 @@ 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'"); - }*/ + function ajaxRemoveContact($jid) { + $r = new moxl\RosterRemoveItem(); + $r->setTo($jid) + ->request(); + + $p = new moxl\PresenceUnsubscribe(); + $p->setTo($jid) + ->request(); } function prepareContactInfo() { - $query = Contact::query()->join('Presence', + $query = Contact::query() + ->join('Presence', array('Contact.jid' => 'Presence.jid')) ->where(array( - 'Contact`.`key' => $this->user->getLogin(), 'Contact`.`jid' => $_GET['f'])); $user = Contact::run_query($query); @@ -117,9 +113,6 @@ class ContactInfo extends WidgetCommon $c = new CapsHandler(); $caps = $c->get($presence['node'].'#'.$presence['ver']); - - - if($this->testIsSet($caps->getData('type'))) { if($caps->getData('type') == 'phone') $cinfos = ''; @@ -136,7 +129,7 @@ class ContactInfo extends WidgetCommon $html .='

'.t('Actions').'

'; - if(isset($presence['presence']) && $presence['presence'] != 5) { + if(isset($presence['presence']) && !in_array($presence['presence'], array(5, 6))) { $html .= ' rostersubscription->getval() != 'vcard') { + /*if($contact->rostersubscription->getval() != 'vcard') { $html .=' '.t('Invite this user').' '; - } + }*/ } } diff --git a/system/Widget/widgets/ContactSummary/ContactSummary.php b/system/Widget/widgets/ContactSummary/ContactSummary.php index a220a953b..4afa9a28c 100644 --- a/system/Widget/widgets/ContactSummary/ContactSummary.php +++ b/system/Widget/widgets/ContactSummary/ContactSummary.php @@ -86,9 +86,6 @@ class ContactSummary extends WidgetCommon $html .= '
'; } - - if($contact->getData('vcardreceived') != 1) - $html .= ''; return $html; } @@ -97,7 +94,6 @@ class ContactSummary extends WidgetCommon { $query = \Contact::query()->select() ->where(array( - 'key' => $this->user->getLogin(), 'jid' => $_GET['f'])); $contact = \Contact::run_query($query); ?> diff --git a/system/Widget/widgets/Explore/Explore.php b/system/Widget/widgets/Explore/Explore.php new file mode 100644 index 000000000..a3ae5a3af --- /dev/null +++ b/system/Widget/widgets/Explore/Explore.php @@ -0,0 +1,55 @@ +addcss('explore.css'); + } + + function build() + { + $users_limit = 20; + + $gender = getGender(); + $marital = getMarital(); + + $query = Contact::query()->select() + ->where(array( + 'public' => 1)) + ->limit(0, $users_limit); + $users = Contact::run_query($query); + + /*$users_number = sizeof($users); + + if($users_number < $users_limit) { + $users_fill = array(); + for($i = 0; $i<$users_limit-$users_number; $i++) + array_push($users_fill, new Contact()); + + $users = array_merge($users, $users_fill); + }*/ + + shuffle($users); + ?> +
+ getData('jid').'"> +
+ +
'.prepareString($user->getData('desc')).'
+ '.$user->getTrueName().' + '. + $user->getAge().' '. + $gender[$user->getData('gender')].'
'. + $marital[$user->getData('marital')].' +
+
+ '; + } + ?> +
+ join('Contact', array('Post.jid' => 'Contact.jid')) ->where( array( - 'Contact`.`key' => $this->user->getLogin(), - array( - 'Contact`.`rostersubscription!' => 'none', - '|Contact`.`rosterask' => 'subscribe', - '|Contact`.`jid' => $this->user->getLogin()), 'Post`.`parentid' => '')) ->orderby('Post.updated', true) ->limit($start, '20'); @@ -232,11 +227,6 @@ class Feed extends WidgetCommon { $p->setTo($this->user->getLogin()) ->request(); } - - function ajaxFeed() - { - //$this->xmpp->getWall($this->xmpp->getCleanJid()); - } function build() { diff --git a/system/Widget/widgets/Login/Login.php b/system/Widget/widgets/Login/Login.php index 80b9ae5ae..602bda15d 100644 --- a/system/Widget/widgets/Login/Login.php +++ b/system/Widget/widgets/Login/Login.php @@ -250,7 +250,7 @@ class Login extends WidgetBase {
- select() @@ -278,7 +278,7 @@ class Login extends WidgetBase { else echo ''; } - ?> + */ ?>
addcss('logout.css'); $this->addjs('logout.js'); - //$this->registerEvent('postdisconnected', 'onPostDisconnect'); - //$this->registerEvent('serverdisconnect', 'onPostDisconnect'); // When you're kicked out $this->registerEvent('mypresence', 'onMyPresence'); - - //$this->cached = true; } function onMyPresence() diff --git a/system/Widget/widgets/Notifs/Notifs.php b/system/Widget/widgets/Notifs/Notifs.php index c2b2a7df6..531efbe1e 100644 --- a/system/Widget/widgets/Notifs/Notifs.php +++ b/system/Widget/widgets/Notifs/Notifs.php @@ -32,7 +32,6 @@ class Notifs extends WidgetBase function onMessage($message) { $query = Contact::query()->select() ->where(array( - 'key' => $message->getData('to'), 'jid' => $message->getData('from'))); $contact = Contact::run_query($query); @@ -97,46 +96,30 @@ class Notifs extends WidgetBase } function ajaxSubscribed($jid) { - //if(checkJid($jid)) { - $p = new moxl\PresenceSubscribed(); - $p->setTo($jid) - ->request(); - - /*$p = new moxl\PresenceSubscribe(); - $p->setTo($jid) - ->request();*/ - /*} else { - throw new MovimException("Incorrect JID `$jid'"); - }*/ + $p = new moxl\PresenceSubscribed(); + $p->setTo($jid) + ->request(); } function ajaxRefuse($jid) { - //if(checkJid($jid)) { - $p = new moxl\PresenceUnsubscribed(); - $p->setTo($jid) - ->request(); - - $notifs = Cache::c('activenotifs'); - unset($notifs[$jid]); - - Cache::c('activenotifs', $notifs); - /*} else { - throw new MovimException("Incorrect JID `$jid'"); - }*/ + $p = new moxl\PresenceUnsubscribed(); + $p->setTo($jid) + ->request(); + + $notifs = Cache::c('activenotifs'); + unset($notifs[$jid]); + + Cache::c('activenotifs', $notifs); } function ajaxAccept($jid, $alias) { - //if(checkJid($jid)) { - $r = new moxl\RosterAddItem(); - $r->setTo($jid) - ->request(); - - $p = new moxl\PresenceSubscribe(); - $p->setTo($jid) - ->request(); - /*} else { - throw new MovimException("Incorrect JID `$jid'"); - }*/ + $r = new moxl\RosterAddItem(); + $r->setTo($jid) + ->request(); + + $p = new moxl\PresenceSubscribe(); + $p->setTo($jid) + ->request(); $notifs = Cache::c('activenotifs'); unset($notifs[$jid]); @@ -145,17 +128,13 @@ class Notifs extends WidgetBase } function ajaxAddContact($jid, $alias) { - //if(checkJid($jid)) { - $r = new moxl\RosterAddItem(); - $r->setTo($jid) - ->request(); - - $p = new moxl\PresenceSubscribe(); - $p->setTo($jid) - ->request(); - /*} else { - throw new MovimException("Incorrect JID `$jid'"); - }*/ + $r = new moxl\RosterAddItem(); + $r->setTo($jid) + ->request(); + + $p = new moxl\PresenceSubscribe(); + $p->setTo($jid) + ->request(); } function build() { @@ -163,16 +142,15 @@ class Notifs extends WidgetBase if($notifs == false) $notifs = array(); - $query = Contact::query() + $query = RosterLink::query() ->where( array( - 'key' => $this->user->getLogin(), 'jid!' => $this->user->getLogin(), array( 'rostersubscription!' => 'none', - 'Contact`.`rostersubscription!' => 'vcard', + 'rostersubscription!' => 'vcard', '|rosterask' => 'subscribe'))); - $contacts = Contact::run_query($query); + $contacts = RosterLink::run_query($query); ?>
diff --git a/system/Widget/widgets/Profile/Profile.php b/system/Widget/widgets/Profile/Profile.php index eae82f6cc..3a04c787a 100644 --- a/system/Widget/widgets/Profile/Profile.php +++ b/system/Widget/widgets/Profile/Profile.php @@ -77,7 +77,6 @@ class Profile extends WidgetBase { $query = Contact::query()->select() ->where(array( - 'key' => $this->user->getLogin(), 'jid' => $this->user->getLogin())); $contact = Contact::run_query($query); diff --git a/system/Widget/widgets/ProfileData/ProfileData.php b/system/Widget/widgets/ProfileData/ProfileData.php index d602894c6..cbd37764d 100644 --- a/system/Widget/widgets/ProfileData/ProfileData.php +++ b/system/Widget/widgets/ProfileData/ProfileData.php @@ -87,8 +87,7 @@ class ProfileData extends WidgetBase $query = Contact::query() ->select() ->where( - array('key' => $this->user->getLogin(), - 'jid' => $this->user->getLogin()) + array('jid' => $this->user->getLogin()) ); $c = Contact::run_query($query); diff --git a/system/Widget/widgets/Roster/Roster.php b/system/Widget/widgets/Roster/Roster.php index 556801992..9dd1b5735 100644 --- a/system/Widget/widgets/Roster/Roster.php +++ b/system/Widget/widgets/Roster/Roster.php @@ -30,7 +30,7 @@ class Roster extends WidgetBase $this->registerEvent('contactadd', 'onRoster'); $this->registerEvent('contactremove', 'onRoster'); $this->registerEvent('presence', 'onPresence'); - $this->registerEvent('vcard', 'onVcard'); + //this->registerEvent('vcard', 'onVcard'); $this->cached = false; } @@ -42,7 +42,7 @@ class Roster extends WidgetBase RPC::cdata($arr['jid']), RPC::cdata($arr['presence_txt'])); } - function onVcard($contact) + /*function onVcard($contact) { $query = \Presence::query()->select() ->where(array( @@ -57,7 +57,7 @@ class Roster extends WidgetBase $html = $this->prepareRosterElement($c, true); RPC::call('movim_fill', 'roster'.$contact->getData('jid'), RPC::cdata($html)); - } + }*/ function onRoster() { @@ -98,8 +98,8 @@ class Roster extends WidgetBase $middle .= '"'; $middle .= ' href="?q=friend&f='.$contact[0]->getData('jid').'" > - '. - ''.$contact[0]->getTrueName(); + '. + ''.$contact[0]->getData('rostername'); if($contact[0]->getData('rosterask') == 'subscribe') $middle .= " #"; if($presence['ressource'] != '') @@ -120,18 +120,17 @@ class Roster extends WidgetBase function prepareRoster() { - $query = Contact::query()->join('Presence', - array('Contact.jid' => + $query = RosterLink::query()->join('Presence', + array('RosterLink.jid' => 'Presence.jid')) - ->where( - array( - 'Contact`.`key' => $this->user->getLogin(), - 'Contact`.`jid!' => $this->user->getLogin(), + ->where( array( - 'Contact`.`rostersubscription!' => 'none', - 'Contact`.`rostersubscription!' => 'vcard', - '|Contact`.`rosterask' => 'subscribe'))) - ->orderby('Contact.group', true); + 'RosterLink`.`key' => $this->user->getLogin(), + array( + 'RosterLink`.`rostersubscription!' => 'none', + 'RosterLink`.`rostersubscription!' => 'vcard', + '|RosterLink`.`rosterask' => 'subscribe'))) + ->orderby('RosterLink.group', true); $contactsq = Contact::run_query($query); diff --git a/system/Widget/widgets/Syndication/Syndication.php b/system/Widget/widgets/Syndication/Syndication.php index a62d67aa6..249ca3927 100644 --- a/system/Widget/widgets/Syndication/Syndication.php +++ b/system/Widget/widgets/Syndication/Syndication.php @@ -25,9 +25,7 @@ class Syndication extends WidgetBase if(isset($from)) { // We query the last messages $query = Post::query() - //->join('Contact', array('Post.jid' => 'Contact.jid')) ->where(array( - 'key' => $from, 'jid' => $from, 'public' => 1, 'parentid' => '')) diff --git a/system/Widget/widgets/Vcard/Vcard.php b/system/Widget/widgets/Vcard/Vcard.php index a7e3c09a6..a8dbad94f 100644 --- a/system/Widget/widgets/Vcard/Vcard.php +++ b/system/Widget/widgets/Vcard/Vcard.php @@ -55,15 +55,14 @@ class Vcard extends WidgetBase $query = \Contact::query()->select() ->where(array( - 'key' => $this->user->getLogin(), - 'jid' => $this->user->getLogin())); + 'jid' => $this->user->getLogin()) + ); $data = \Contact::run_query($query); if($data) { $c = $data[0]; } - $c->key->setval($this->user->getLogin()); $c->jid->setval($this->user->getLogin()); $date = strtotime($vcard['date']); @@ -75,16 +74,13 @@ class Vcard extends WidgetBase $c->gender->setval($vcard['gender']); $c->marital->setval($vcard['marital']); - - if($c->rostersubscription->getval() == false) - $c->rostersubscription->setval('none'); + $c->phototype->setval($vcard['phototype']); $c->photobin->setval($vcard['photobin']); $c->desc->setval(trim($vcard['desc'])); - $c->vcardreceived->setval(0); if($vcard['public'] == 'true') $c->public->setval(1); else @@ -98,7 +94,11 @@ class Vcard extends WidgetBase function prepareInfos($error = false) { $query = Contact::query() - ->where(array('key' => $this->user->getLogin(), 'jid' => $this->user->getLogin())); + ->where( + array( + 'jid' => $this->user->getLogin() + ) + ); $me = Contact::run_query($query); $submit = $this->genCallAjax('ajaxVcardSubmit', "movim_parse_form('vcard')"); diff --git a/system/Widget/widgets/Wall/Wall.php b/system/Widget/widgets/Wall/Wall.php index 74f529e83..9382cb5f7 100644 --- a/system/Widget/widgets/Wall/Wall.php +++ b/system/Widget/widgets/Wall/Wall.php @@ -87,7 +87,6 @@ class Wall extends WidgetCommon $query = Post::query() ->join('Contact', array('Post.jid' => 'Contact.jid')) ->where(array( - 'Contact`.`key' => $this->user->getLogin(), 'Post`.`jid' => $from, 'Post`.`parentid' => '')) ->orderby('Post.updated', true) diff --git a/themes/movim/config.tpl b/themes/movim/config.tpl index 4e3c8d5fd..cc857f003 100644 --- a/themes/movim/config.tpl +++ b/themes/movim/config.tpl @@ -3,7 +3,6 @@ widget('Poller');?> widget('Logout');?> widget('Chat');?> -widget('Log');*/?>