示例#1
0
文件: Set.php 项目: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     $sd = new \modl\SubscriptionDAO();
     $cd = new \modl\ConferenceDAO();
     // We clear the old Bookmarks
     $sd->delete();
     $cd->delete();
     // We save the bookmarks as Subscriptions in the database
     foreach ($this->_arr as $c) {
         if ($c['type'] == 'subscription') {
             $su = new \modl\Subscription();
             $su->jid = $this->_to;
             $su->server = (string) $c['server'];
             $su->node = (string) $c['node'];
             $su->subscription = 'subscribed';
             $su->subid = (string) $c['subid'];
             $sd->set($su);
         } elseif ($c['type'] == 'conference') {
             $co = new \modl\Conference();
             $co->jid = $this->_to;
             $co->conference = (string) $c['jid'];
             $co->name = (string) $c['name'];
             $co->nick = (string) $c['nick'];
             $co->autojoin = (int) $c['autojoin'];
             $co->status = 0;
             $cd->set($co);
         }
     }
     $this->deliver();
 }
示例#2
0
文件: Get.php 项目: Hywan/moxl
 public function handle($stanza, $parent = false)
 {
     if ($stanza->pubsub->items->item->storage) {
         $sd = new \modl\SubscriptionDAO();
         $cd = new \modl\ConferenceDAO();
         // We clear the old Bookmarks
         $sd->delete();
         $cd->delete();
         if ($stanza->pubsub->items->item->count() == 1) {
             // We save the bookmarks as Subscriptions in the database
             foreach ($stanza->pubsub->items->item->storage->children() as $c) {
                 $this->saveItem($c);
             }
         } else {
             // We parse non-standard XML where the items are in many <item>
             foreach ($stanza->pubsub->items->children() as $c) {
                 foreach ($c->storage->children() as $s) {
                     $this->saveItem($s);
                 }
             }
         }
         $this->deliver();
     }
 }