function onLocationPublishError($error) { Notification::append(null, $error); RPC::call('movim_delete', 'mapdiv'); RPC::call('movim_delete', 'mapdata'); RPC::commit(); }
function onConfigured($package) { $node = $package->content; switch ($node) { case 'storage:bookmarks': $notif = $this->__('init.bookmark'); break; case 'urn:xmpp:vcard4': $notif = $this->__('init.vcard4'); break; case 'urn:xmpp:avatar:data': $notif = $this->__('init.avatar'); break; case 'http://jabber.org/protocol/geoloc': $notif = $this->__('init.location'); break; case 'urn:xmpp:pubsub:subscription': $notif = $this->__('init.subscriptions'); break; case 'urn:xmpp:microblog:0': $notif = $this->__('init.microblog'); break; } RPC::call('Init.setNode', $node); Notification::append(null, $notif); }
function onMyAvatarError() { $cd = new \modl\ContactDAO(); $me = $cd->get(); $html = $this->prepareForm($me); RPC::call('movim_fill', 'avatar_form', $html); Notification::append(null, $this->__('avatar.not_updated')); }
function onMyPresence($packet) { $html = $this->preparePresence(); RPC::call('MovimTpl.fill', '#presence_widget', $html); Notification::append(null, $this->__('status.updated')); RPC::call('Presence.refresh'); RPC::call('MovimUtils.removeClass', '#presence_widget', 'unfolded'); }
function onConfig($package) { $data = (array) $package->content; $this->user->setConfig($data); $html = $this->prepareConfigForm(); RPC::call('movim_fill', 'config_widget', $html); RPC::call('Config.load'); Notification::append(null, $this->__('config.updated')); }
function ajaxRefresh() { Notification::append(null, $this->__('menu.refresh')); $sd = new \modl\SubscriptionDAO(); $subscriptions = $sd->getSubscribed(); foreach ($subscriptions as $s) { $r = new GetItems(); $r->setTo($s->server)->setNode($s->node)->request(); } }
function ajaxRegister() { $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $json = requestURL(MOVIM_API . 'register', 3, array('uri' => BASE_URI, 'rewrite' => false)); $json = json_decode($json); if (isset($json) && $json->status == 200) { RPC::call('MovimUtils.reloadThis'); Notification::append(null, $this->__('api.conf_updated')); } }
function onDelete($packet) { $content = $packet->content; if (substr($content['node'], 0, 29) == 'urn:xmpp:microblog:0:comments') { Notification::append(false, $this->__('post.comment_deleted')); $this->ajaxGetComments($content['server'], substr($content['node'], 30)); } else { Notification::append(false, $this->__('post.deleted')); $this->ajaxClear(); RPC::call('MovimTpl.hidePanel'); RPC::call('Menu_ajaxGetAll'); } }
function ajaxRegister() { $rewrite = false; if (isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) { $rewrite = true; } $json = requestURL(MOVIM_API . 'register', 1, array('uri' => BASE_URI, 'rewrite' => $rewrite)); $json = json_decode($json); if (isset($json) && $json->status == 200) { RPC::call('movim_reload_this'); Notification::append(null, $this->__('api.conf_updated')); } }
function ajaxSubmit($data) { if (!$this->validateForm($data)) { $this->refreshConfig(); Notification::append(null, $this->__('config.not_valid')); return; } $config = $this->user->getConfig(); if (isset($config)) { $data = array_merge($config, $data); } $s = new Set(); $s->setXmlns('movim:prefs')->setData(serialize($data))->request(); }
function onNotifs($from = false) { $html = $this->prepareNotifs(); RPC::call('MovimTpl.fill', '#notifs_widget', $html); RPC::call('Notifs.refresh'); if (is_string($from)) { $cd = new \Modl\ContactDAO(); $contact = $cd->get($from); $avatar = $contact->getPhoto('s'); if ($avatar == false) { $avatar = null; } Notification::append('invite|' . $from, $contact->getTrueName(), $this->__('notifs.wants_to_talk', $contact->getTrueName()), $avatar, 4); } }
function ajaxChangePassword($form) { $validate = Validator::string()->length(6, 40); $p1 = $form->password->value; $p2 = $form->password_confirmation->value; if ($validate->validate($p1) && $validate->validate($p2)) { if ($p1 == $p2) { $arr = explodeJid($this->user->getLogin()); $cp = new ChangePassword(); $cp->setTo($arr['server'])->setUsername($arr['username'])->setPassword($p1)->request(); } else { RPC::call('Account.resetPassword'); Notification::append(null, $this->__('account.password_not_same')); } } else { RPC::call('Account.resetPassword'); Notification::append(null, $this->__('account.password_not_valid')); } }
function ajaxLogin($username) { $validate_user = Validator::string()->length(4, 40); if (!$validate_user->validate($username)) { Notification::append(null, $this->__('login_anonymous.bad_username')); return; } // We get the Server Configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $host = 'anonymous.jappix.com'; $password = '******'; // We try to get the domain $domain = \Moxl\Utils::getDomain($host); // We launch the XMPP socket RPC::call('register', $host); // We set the username in the session $s = Session::start(); $s->set('username', $username); // We create a new session or clear the old one $s = Sessionx::start(); $s->init($username, $password, $host, $domain); \Moxl\Stanza\Stream::init($host); }
function checkConnected($room, $resource = false) { if (!$this->validateRoom($room)) { return; } if ($resource && !$this->validateResource($resource)) { Notification::append(null, $this->__('chatrooms.bad_id')); return; } $pd = new \Modl\PresenceDAO(); if ($resource == false) { $session = \Session::start(); $resource = $session->get('username'); } $presence = $pd->getPresence($room, $resource); if ($presence != null) { return true; } else { return false; } }
/** * @brief Get the chat history * * @param string jid * @param string time */ function ajaxGetHistory($jid, $date) { if (!$this->validateJid($jid)) { return; } $md = new \Modl\MessageDAO(); $messages = $md->getHistory(echapJid($jid), date(DATE_ISO8601, strtotime($date)), $this->_pagination); if (count($messages) > 0) { Notification::append(false, $this->__('message.history', count($messages))); foreach ($messages as $message) { if (!preg_match('#^\\?OTR#', $message->body)) { //RPC::call('Chat.appendMessage', $this->prepareMessage($message), true); //$this->_msgMap[$message->published.$message->jid] = $message; $this->prepareMessage($message); } } //foreach($this->_msgMap as $message) // $this->prepareMessage($message); RPC::call('Chat.appendMessagesWrapper', $this->_wrapper, true); $this->_wrapper = array(); //RPC::call('Chat.cleanBubbles'); } }
function onUnsubscribed($packet) { $arr = $packet->content; // Set the bookmark $r = new Rooms(); $r->setBookmark(); Notification::append(null, $this->__('group.unsubscribed')); }
function ajaxAddConfirm($server, $form) { if (!$this->validateServer($server)) { return; } $validate_name = Validator::string()->length(4, 80); if (!$validate_name->validate($form->name->value)) { Notification::append(null, $this->__('groups.name_error')); return; } $uri = stringToUri($form->name->value); $c = new Create(); $c->setTo($server)->setNode($uri)->setData($form->name->value)->request(); }
function ajaxEmbedTest($url) { if ($url == '') { return; } elseif (!filter_var($url, FILTER_VALIDATE_URL)) { Notification::append(false, $this->__('publish.valid_url')); return; } $embed = Embed\Embed::create($url); $html = $this->prepareEmbed($embed); if ($embed->type == 'photo') { RPC::call('movim_fill', 'gallery', $this->prepareGallery($embed)); RPC::call('movim_fill', 'preview', ''); } else { RPC::call('movim_fill', 'preview', $html); RPC::call('movim_fill', 'gallery', ''); } }
function onServiceUnavailable() { Notification::append(null, $this->__('error.service_unavailable')); RPC::call('remoteUnregister'); }
function ajaxEmbedTest($url) { if ($url == '') { return; } elseif (!filter_var($url, FILTER_VALIDATE_URL)) { Notification::append(false, $this->__('publish.valid_url')); return; } try { $embed = Embed\Embed::create($url); $html = $this->prepareEmbed($embed); RPC::call('movim_fill', 'preview', ''); RPC::call('movim_fill', 'gallery', ''); if (in_array($embed->type, array('photo', 'rich'))) { RPC::call('movim_fill', 'gallery', $this->prepareGallery($embed)); } if ($embed->type !== 'photo') { RPC::call('movim_fill', 'preview', $html); } } catch (Exception $e) { error_log($e->getMessage()); } }
function onServiceUnavailable() { Notification::append(null, $this->__('error.service_unavailable')); RPC::call('remoteUnregister'); RPC::call('movim_redirect', $this->route('account')); }
function ajaxChangePrivacy($value) { if ($value == true) { \modl\Privacy::set($this->user->getLogin(), 1); Notification::append(null, $this->__('vcard.public')); } else { \modl\Privacy::set($this->user->getLogin(), 0); Notification::append(null, $this->__('vcard.restricted')); } }
/** * @brief Search for a contact to add */ function ajaxSearchContact($jid) { if (filter_var($jid, FILTER_VALIDATE_EMAIL)) { RPC::call('movim_redirect', Route::urlize('contact', $jid)); RPC::commit(); } else { Notification::append(null, $this->__('roster.jid_error')); } }
public function onContactEdited($packet) { Notification::append(null, $this->__('edit.updated')); }
function onGroupRemoved($node) { Notification::append(null, $this->__('public_groups.removed', $node)); }
function onSubmit($stanza) { Notification::append(null, $this->__('affiliations.saved')); RPC::commit(); }
function onRoomConfigSaved($packet) { Notification::append(false, $this->__('chatroom.config_saved')); }
/** * @brief Get the chat history * * @param string jid * @param string time */ function ajaxGetHistory($jid, $date) { if (!$this->validateJid($jid)) { return; } $md = new \Modl\MessageDAO(); $messages = $md->getHistory(echapJid($jid), date(DATE_ISO8601, strtotime($date)), $this->_pagination); if (count($messages) > 0) { Notification::append(false, $this->__('message.history', count($messages))); } foreach ($messages as $message) { if (!preg_match('#^\\?OTR#', $message->body)) { RPC::call('Chat.appendMessage', $this->prepareMessage($message), true); } } }
function ajaxTogglePrivacy($id) { $validate = Validator::string()->length(6, 128); if (!$validate->validate($id)) { return; } $pd = new \Modl\PrivacyDAO(); $p = $pd->get($id); $pd = new \Modl\PostnDAO(); $po = $pd->getItem($id); if ($po->isMine()) { if ($po->privacy == 1) { Notification::append(false, $this->__('post.public_no')); \Modl\Privacy::set($id, 0); } if ($po->privacy == 0) { Notification::append(false, $this->__('post.public_yes')); \Modl\Privacy::set($id, 1); } } }
function onBookmarkError($error) { Notification::append(null, $this->__('bookmarks.error') . $error); }