コード例 #1
0
ファイル: Contact.php プロジェクト: Trim/movim
 function ajaxRefreshVcard($jid)
 {
     if (!$this->validateJid($jid)) {
         return;
     }
     $a = new Moxl\Xec\Action\Avatar\Get();
     $a->setTo(echapJid($jid))->request();
     $r = new Get();
     $r->setTo(echapJid($jid))->request();
 }
コード例 #2
0
ファイル: Notifs.php プロジェクト: Anon215/movim
 function ajaxRefuse($jid)
 {
     $jid = echapJid($jid);
     $p = new Unsubscribed();
     $p->setTo($jid)->request();
     // TODO : move in Moxl
     $session = \Session::start();
     $notifs = $session->get('activenotifs');
     unset($notifs[$jid]);
     $session->set('activenotifs', $notifs);
     $this->onNotifs();
     Notification::ajaxClear('invite|' . $jid);
 }
コード例 #3
0
ファイル: Chats.php プロジェクト: christine-ho-dev/movim
 /**
  * @brief Get history
  */
 function ajaxGetHistory($jid)
 {
     if (!$this->validateJid($jid)) {
         return;
     }
     $md = new \Modl\MessageDAO();
     $messages = $md->getContact(echapJid($jid), 0, 1);
     $g = new \Moxl\Xec\Action\MAM\Get();
     $g->setJid(echapJid($jid));
     if (!empty($messages)) {
         $g->setStart(strtotime($messages[0]->published));
     }
     $g->request();
 }
コード例 #4
0
ファイル: Stickers.php プロジェクト: Anon215/movim
 function ajaxSend($to, $pack, $file)
 {
     if (!$this->validateJid($to)) {
         return;
     }
     list($key, $ext) = explode('.', $file);
     $filepath = dirname(__FILE__) . '/stickers/' . $pack . '/' . $key . '.png';
     if (!file_exists($filepath)) {
         return;
     }
     // We get the base64
     $base64 = base64_encode(file_get_contents($filepath));
     // Caching the picture
     if (!file_exists(CACHE_PATH . md5($key) . '.png')) {
         $p = new Picture();
         $p->fromBase($base64);
         $p->set($key, 'png');
     }
     // Creating a message
     $m = new \Modl\Message();
     $m->session = $this->user->getLogin();
     $m->jidto = echapJid($to);
     $m->jidfrom = $this->user->getLogin();
     $m->sticker = $key;
     $m->body = $this->__('sticker.sent');
     $m->published = gmdate('Y-m-d H:i:s');
     $session = \Session::start();
     $m->id = Uuid::uuid4();
     $m->type = 'chat';
     $m->resource = $session->get('resource');
     // Sending the sticker
     $html = "<p><img alt='Sticker' src='cid:sha1+" . $key . "@bob.xmpp.org'/></p>";
     $p = new Publish();
     $p->setTo($m->jidto)->setContent($m->body)->setHTML($html)->setId($m->id)->request();
     $md = new \Modl\MessageDAO();
     $md->set($m);
     // Sending it to Chat
     $packet = new Moxl\Xec\Payload\Packet();
     $packet->content = $m;
     $c = new Chat();
     $c->onMessage($packet);
 }
コード例 #5
0
ファイル: Chat.php プロジェクト: Trim/movim
 function prepareMessages($jid)
 {
     if (!$this->validateJid($jid)) {
         return;
     }
     $md = new \Modl\MessageDAO();
     $messages = $md->getContact(echapJid($jid), 0, 30);
     if (is_array($messages)) {
         $messages = array_reverse($messages);
         foreach ($messages as $message) {
             $this->prepareMessage($message);
         }
     }
     $view = $this->tpl();
     $view->assign('jid', $jid);
     $cd = new \Modl\ContactDAO();
     $contact = $cd->get($jid);
     $me = $cd->get();
     if ($me == null) {
         $me = new \Modl\Contact();
     }
     $view->assign('contact', $contact);
     $view->assign('me', false);
     $left = $view->draw('_chat_bubble', true);
     $view->assign('contact', $me);
     $view->assign('me', true);
     $right = $view->draw('_chat_bubble', true);
     $room = $view->draw('_chat_bubble_room', true);
     RPC::call('Chat.setBubbles', $left, $right, $room);
     RPC::call('Chat.appendMessages', $messages);
 }
コード例 #6
0
ファイル: Request.php プロジェクト: movim/moxl
 public function setTo($to)
 {
     $this->_to = echapJid($to);
     return $this;
 }
コード例 #7
0
ファイル: Contact.php プロジェクト: sugaryog/movim
 public function set($vcard, $jid)
 {
     $this->__set('jid', \echapJid($jid));
     $validate_date = Validator::date('Y-m-d');
     if (isset($vcard->vCard->BDAY) && $validate_date->validate($vcard->vCard->BDAY)) {
         $this->__set('date', (string) $vcard->vCard->BDAY);
     }
     $this->__set('date', date(DATE_ISO8601, strtotime($this->date)));
     $this->__set('name', (string) $vcard->vCard->NICKNAME);
     $this->__set('fn', (string) $vcard->vCard->FN);
     $this->__set('url', (string) $vcard->vCard->URL);
     $this->__set('gender', (string) $vcard->vCard->{'X-GENDER'});
     $this->__set('marital', (string) $vcard->vCard->MARITAL->STATUS);
     $this->__set('email', (string) $vcard->vCard->EMAIL->USERID);
     $this->__set('adrlocality', (string) $vcard->vCard->ADR->LOCALITY);
     $this->__set('adrpostalcode', (string) $vcard->vCard->ADR->PCODE);
     $this->__set('adrcountry', (string) $vcard->vCard->ADR->CTRY);
     if (filter_var((string) $vcard->vCard->PHOTO, FILTER_VALIDATE_URL)) {
         $this->__set('photobin', base64_encode(requestUrl((string) $vcard->vCard->PHOTO, 1)));
     } else {
         $this->__set('photobin', (string) $vcard->vCard->PHOTO->BINVAL);
     }
     $this->__set('description', (string) $vcard->vCard->DESC);
 }
コード例 #8
0
ファイル: Chat.php プロジェクト: Anon215/movim
 function prepareMessages($jid, $muc = false)
 {
     if (!$this->validateJid($jid)) {
         return;
     }
     $md = new \Modl\MessageDAO();
     if ($muc) {
         $messages = $md->getRoom(echapJid($jid));
     } else {
         $messages = $md->getContact(echapJid($jid), 0, $this->_pagination);
     }
     if (is_array($messages)) {
         $messages = array_reverse($messages);
         /*foreach($messages as $message) {
                         $this->_msgMap[$message->published.$message->jid] = $message;
                     }
         
                     foreach($this->_msgMap as $message) {*/
         foreach ($messages as $message) {
             $this->prepareMessage($message);
         }
     }
     $view = $this->tpl();
     $view->assign('jid', $jid);
     $cd = new \Modl\ContactDAO();
     $contact = $cd->get($jid);
     $me = $cd->get();
     if ($me == null) {
         $me = new \Modl\Contact();
     }
     $view->assign('contact', $contact);
     $view->assign('me', false);
     $left = $view->draw('_chat_bubble', true);
     $view->assign('contact', $me);
     $view->assign('me', true);
     $right = $view->draw('_chat_bubble', true);
     $room = $view->draw('_chat_bubble_room', true);
     RPC::call('Chat.setBubbles', $left, $right, $room);
     //RPC::call('Chat.appendMessages', $messages);
     RPC::call('Chat.appendMessagesWrapper', $this->_wrapper);
     RPC::call('MovimTpl.scrollPanel');
 }
コード例 #9
0
ファイル: Contact.php プロジェクト: Nyco/movim
 public function set($vcard, $jid)
 {
     $this->jid = \echapJid($jid);
     if (isset($vcard->vCard->BDAY) && (string) $vcard->vCard->BDAY != '') {
         $this->date = (string) $vcard->vCard->BDAY;
     } else {
         $this->date = null;
     }
     $this->date = date(DATE_ISO8601, strtotime($this->date));
     $this->name = (string) $vcard->vCard->NICKNAME;
     $this->fn = (string) $vcard->vCard->FN;
     $this->url = (string) $vcard->vCard->URL;
     $this->gender = (string) $vcard->vCard->{'X-GENDER'};
     $this->marital = (string) $vcard->vCard->MARITAL->STATUS;
     $this->email = (string) $vcard->vCard->EMAIL->USERID;
     $this->adrlocality = (string) $vcard->vCard->ADR->LOCALITY;
     $this->adrpostalcode = (string) $vcard->vCard->ADR->PCODE;
     $this->adrcountry = (string) $vcard->vCard->ADR->CTRY;
     if (filter_var((string) $vcard->vCard->PHOTO, FILTER_VALIDATE_URL)) {
         $this->photobin = base64_encode(requestUrl((string) $vcard->vCard->PHOTO, 1));
     } else {
         $this->photobin = (string) $vcard->vCard->PHOTO->BINVAL;
     }
     $this->description = (string) $vcard->vCard->DESC;
 }
コード例 #10
0
ファイル: Chats.php プロジェクト: Anon215/movim
 /**
  * @brief Get history
  */
 function ajaxGetHistory($jid = false)
 {
     $g = new \Moxl\Xec\Action\MAM\Get();
     $md = new \Modl\MessageDAO();
     if ($jid == false) {
         $chats = Cache::c('chats');
         foreach ($chats as $jid => $value) {
             $messages = $md->getContact(echapJid($jid), 0, 1);
             $g->setJid(echapJid($jid));
             if (!empty($messages)) {
                 $g->setStart(strtotime($messages[0]->published) + 10);
             }
             $g->request();
         }
     } elseif ($this->validateJid($jid)) {
         $messages = $md->getContact(echapJid($jid), 0, 1);
         $g->setJid(echapJid($jid));
         if (!empty($messages)) {
             // We add a little delay of 10sec to prevent some sync issues
             $g->setStart(strtotime($messages[0]->published) + 10);
         }
         $g->request();
     }
 }
コード例 #11
0
ファイル: Notifs.php プロジェクト: Nyco/movim
 function ajaxRefuse($jid)
 {
     $jid = echapJid($jid);
     $p = new Unsubscribed();
     $p->setTo($jid)->request();
     // TODO : move in Moxl
     $notifs = Cache::c('activenotifs');
     unset($notifs[$jid]);
     Cache::c('activenotifs', $notifs);
     $this->onNotifs();
 }