Exemplo n.º 1
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));
 }
Exemplo n.º 2
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;
 }