Пример #1
0
 /**
  * Class constructor.
  *
  * @param \SimpleXMLElement $message The XML of the message.
  */
 public function __construct(\SimpleXMLElement $message)
 {
     parent::__construct($message);
     // Get the type of the message
     if (isset($message['type']) && ((string) $message['type'] == self::TYPE_CHAT || (string) $message['type'] == self::TYPE_ERROR || (string) $message['type'] == self::TYPE_GROUPCHAT || (string) $message['type'] == self::TYPE_HEADLINE)) {
         $this->type = (string) $message['type'];
     } else {
         $this->type = self::TYPE_NORMAL;
     }
     if ($this->type == self::TYPE_ERROR) {
         if (isset($message->error[0])) {
             $this->error = (string) $message->error[0];
         } else {
             $this->error = '';
         }
     }
     if (isset($message['xml:lang'])) {
         $this->lang = (string) $message['xml:lang'];
     }
     foreach ($message->subject as $subject) {
         $thisSubject = array('content' => (string) $subject);
         if (isset($subject['xml:lang'])) {
             $thisSubject['lang'] = (string) $subject['xml:lang'];
         }
         $this->subjects[] = $thisSubject;
     }
     foreach ($message->body as $body) {
         $thisBody = array('content' => (string) $body);
         if (isset($body['xml:lang'])) {
             $thisBody['lang'] = (string) $body['xml:lang'];
         }
         $this->bodies[] = $thisBody;
     }
     if (isset($message->delay[0])) {
         $this->delayed = true;
     }
     if (isset($message->thread[0])) {
         $this->thread = (string) $message->thread[0];
     } else {
         $this->thread = '';
     }
 }
Пример #2
0
 function readAll($obj)
 {
     if (!$obj instanceof Struttura) {
         return false;
     }
     $this->open();
     $query = 'SELECT * FROM stanza WHERE nomestruttura = "%s" AND codicefiscaleproprietario = "%s"';
     $query = sprintf($query, $obj->getNome(), $obj->getCodiceFiscaleAnagrafica());
     $result = mysql_query($query);
     if (mysql_num_rows($result) <= 0) {
         return false;
     }
     $this->close();
     $toReturn = array();
     for ($i = 0; $i < mysql_num_rows($result); $i++) {
         $res = mysql_fetch_assoc($result);
         $tmp = new Stanza();
         $tmp->setNomeStruttura($res['nomestruttura']);
         $tmp->setCodiceFiscaleProprietario($res['codicefiscaleproprietario']);
         $tmp->setNumero($res['numero']);
         $tmp->setTipo($res['tipo']);
         $tmp->setDescrizione($res['descrizione']);
         $tmp->setMq($res['mq']);
         $tmp->setAgibile($res['agibile']);
         $tmp->setPermanenza($res['permanenza']);
         $tmp->setVisita($res['visita']);
         $toReturn[$i] = $tmp->toArray();
     }
     return $toReturn;
 }
Пример #3
0
 private function handleStanza(Stanza $stanza)
 {
     if (!in_array($name = $stanza->name(), array('stream:error', 'handshake'))) {
         $this->log("got <{$name}> from {$stanza->from()} to {$stanza->to()}", PHP_COMPONENT_MESSAGE_INFO, true);
     }
     if (!is_callable(@$this->handlers[$stanza->name()])) {
         if ($stanza->name() == 'iq') {
             return $this->handleIQ($stanza);
         }
         $this->log('no handler for stanza: ' . $stanza->name(), PHP_COMPONENT_MESSAGE_WARNING, true);
     } else {
         if (!is_null($this->file_handler) && $stanza->name() == 'message' && $stanza->tag()->hasChild('data')) {
             return $this->handleFileChunk($stanza);
         }
         return call_user_func($this->handlers[$stanza->name()], $stanza);
     }
 }
Пример #4
0
 public static function fromIQStanza(Stanza &$stanza)
 {
     return new self($stanza->tag()->getChild('query/x'));
 }
Пример #5
0
            }
            break;
        case "29":
            // READ ALL ANAGSTANZA IN CORSO
            require_once '../server/manager/AnagraficaStanzaManager.php';
            $struttura = new Struttura();
            $struttura->setNome($_POST['nomeStruttura']);
            $struttura->setCodiceFiscaleAnagrafica($_POST['cfProprietario']);
            $manager = new AnagraficaStanzaManager();
            $permanenze = $manager->readAllInCorso($struttura);
            echo json_encode($permanenze);
            break;
        case "30":
            // OCCUPA STANZA
            require_once '../server/manager/StanzaManager.php';
            $manager = new StanzaManager();
            $res = json_decode($_POST['json'], true);
            $newStanza = new Stanza();
            $newStanza->setNomeStruttura($res['nomeStruttura']);
            $newStanza->setCodiceFiscaleProprietario($res['codiceFiscaleProprietario']);
            $newStanza->setNumero($res['numero']);
            $newStanza->setPermanenza($res['permanenza']);
            $newStanza->setVisita($res['visita']);
            if ($manager->occupaStanza($newStanza)) {
                echo 'DONE';
            } else {
                echo 'NOT DONE';
            }
            break;
    }
}