Exemple #1
0
 public function handle($stanza, $parent = false)
 {
     $rd = new \Modl\RosterLinkDAO();
     $rd->delete($this->_to);
     $this->pack($this->_to);
     $this->deliver();
 }
Exemple #2
0
 public function handle($stanza, $parent = false)
 {
     if ((string) $parent->attributes()->type == 'set') {
         $rd = new \Modl\RosterLinkDAO();
         $jid = current(explode('/', (string) $parent->query->item->attributes()->jid));
         if ((string) $parent->query->item->attributes()->subscription == 'remove') {
             $rd->delete($jid);
         } else {
             $from = current(explode('/', (string) $parent->attributes()->from));
             $name = (string) $parent->query->item->attributes()->name;
             $subscription = (string) $parent->query->item->attributes()->subscription;
             $group = (string) $parent->query->item->group;
             // If not found, we create it
             $r = new \Modl\RosterLink();
             $r->key = $from;
             $r->jid = $jid;
             $r->groupname = $group;
             $r->rostername = $name;
             $r->rostersubscription = $subscription;
             $rd->delete($jid);
             $rd->set($r);
         }
         $this->deliver();
     }
 }
Exemple #3
0
 public function handle($stanza, $parent = false)
 {
     $r = new \Modl\RosterLink();
     $r->key = $this->_from;
     $r->jid = $this->_to;
     $rd = new \Modl\RosterLinkDAO();
     $rd->setNow($r);
     $this->pack($this->_to);
     $this->deliver();
 }
Exemple #4
0
 function ajaxEditContact($jid)
 {
     if (!$this->validateJid($jid)) {
         return;
     }
     $rd = new \Modl\RosterLinkDAO();
     $groups = $rd->getGroups();
     $rl = $rd->get($jid);
     $view = $this->tpl();
     if (isset($rl)) {
         $view->assign('submit', $this->call('ajaxEditSubmit', "movim_form_to_json('manage')"));
         $view->assign('contact', $rl);
         $view->assign('groups', $groups);
     }
     Dialog::fill($view->draw('_contact_edit', true));
 }
Exemple #5
0
 public function handle($stanza, $parent = false)
 {
     $evt = new Event();
     $rd = new \Modl\RosterLinkDAO();
     $list = [];
     foreach ($stanza->query->item as $item) {
         $r = new \Modl\RosterLink();
         $r->set($item);
         array_push($list, $r);
     }
     $rd->clearRosterLink();
     if (!empty($list)) {
         $rd->setList($list);
     }
     $this->deliver();
 }
Exemple #6
0
 function ajaxAccept($jid)
 {
     $jid = echapJid($jid);
     $rd = new \Modl\RosterLinkDAO();
     $c = $rd->get($jid);
     if (isset($c) && $c->groupname) {
         $ui = new UpdateItem();
         $ui->setTo($jid)->setFrom($this->user->getLogin())->setName($c->rostername)->setGroup($c->groupname)->request();
     } else {
         $r = new AddItem();
         $r->setTo($jid)->setFrom($this->user->getLogin())->request();
     }
     $p = new Subscribe();
     $p->setTo($jid)->request();
     $p = new Subscribed();
     $p->setTo($jid)->request();
     // TODO : move in Moxl
     $notifs = Cache::c('activenotifs');
     unset($notifs[$jid]);
     Cache::c('activenotifs', $notifs);
 }
Exemple #7
0
 function ajaxAccept($jid)
 {
     $jid = echapJid($jid);
     $rd = new \Modl\RosterLinkDAO();
     $c = $rd->get($jid);
     if (isset($c) && $c->groupname) {
         $ui = new UpdateItem();
         $ui->setTo($jid)->setFrom($this->user->getLogin())->setName($c->rostername)->setGroup($c->groupname)->request();
     } else {
         $r = new AddItem();
         $r->setTo($jid)->setFrom($this->user->getLogin())->request();
     }
     $p = new Subscribe();
     $p->setTo($jid)->request();
     $p = new Subscribed();
     $p->setTo($jid)->request();
     // TODO : move in Moxl
     $session = \Session::start();
     $notifs = $session->get('activenotifs');
     unset($notifs[$jid]);
     $session->set('activenotifs', $notifs);
     Notification::ajaxClear('invite|' . $jid);
 }
Exemple #8
0
 /**
  * @brief Get data from database to pass it on to angular in JSON
  * @param
  * @returns $result: a json for the contacts and one for the groups
  */
 function prepareRoster()
 {
     //Contacts
     $contactdao = new \Modl\ContactDAO();
     $contacts = $contactdao->getRoster();
     $capsarr = $this->getCaps();
     $result = array();
     $farray = array();
     //final array
     if (isset($contacts)) {
         /* Init */
         $c = array_shift($contacts);
         if ($c->groupname == '') {
             $c->groupname = $this->__('roster.ungrouped');
         }
         $jid = $c->jid;
         $groupname = $c->groupname;
         $ac = $c->toRoster();
         $this->prepareContact($ac, $c, $capsarr);
         $garray = array();
         //group array
         $garray['agroup'] = $groupname;
         $garray['tombstone'] = false;
         $garray['agroupitems'] = array();
         //group array of jids
         $jarray = array();
         //jid array
         $jarray['ajid'] = $jid;
         $jarray['atruename'] = $ac['rosterview']['name'];
         $jarray['aval'] = $ac['value'];
         $jarray['tombstone'] = false;
         $jarray['ajiditems'] = $ac;
         //jid array of resources
         array_push($garray['agroupitems'], $jarray);
         foreach ($contacts as &$c) {
             /*jid has changed*/
             if ($jid != $c->jid) {
                 if ($c->groupname == '') {
                     $c->groupname = $this->__('roster.ungrouped');
                 }
                 $ac = $c->toRoster();
                 $this->prepareContact($ac, $c, $capsarr);
                 if ($groupname != $c->groupname && $c->groupname != "") {
                     //close group
                     array_push($farray, $garray);
                     //next group
                     $groupname = $ac['groupname'];
                     $garray = array();
                     $garray['agroup'] = $groupname;
                     $garray['tombstone'] = false;
                     $garray['agroupitems'] = array();
                 }
                 //push new jid in group
                 $jid = $ac['jid'];
                 $jarray['ajid'] = $jid;
                 $jarray['atruename'] = $ac['rosterview']['name'];
                 $jarray['aval'] = $ac['value'];
                 $jarray['tombstone'] = false;
                 $jarray['ajiditems'] = $ac;
                 //jid array of resources
                 array_push($garray['agroupitems'], $jarray);
             }
             if ($c == $contacts[count($contacts) - 1]) {
                 array_push($farray, $garray);
             }
         }
     }
     $result['contacts'] = json_encode($farray);
     //Groups
     $rd = new \Modl\RosterLinkDAO();
     $groups = $rd->getGroups();
     if (is_array($groups) && !in_array("Ungrouped", $groups)) {
         $groups[] = "Ungrouped";
     } else {
         $groups = array();
     }
     $groups = array_flip($groups);
     $result['groups'] = json_encode($groups);
     return $result;
 }