You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

  1. <?php
  2. namespace modl;
  3. class Item extends ModlModel {
  4. public $server;
  5. public $jid;
  6. public $name;
  7. public $node;
  8. public $updated;
  9. public $subscription;
  10. public $num;
  11. public function __construct() {
  12. $this->_struct = '
  13. {
  14. "server" :
  15. {"type":"string", "size":128, "mandatory":true, "key":true },
  16. "jid" :
  17. {"type":"string", "size":128, "mandatory":true, "key":true },
  18. "node" :
  19. {"type":"string", "size":128, "mandatory":true, "key":true },
  20. "name" :
  21. {"type":"string", "size":128 },
  22. "updated" :
  23. {"type":"date"}
  24. }';
  25. parent::__construct();
  26. }
  27. public function set($item, $from) {
  28. $this->server = $from;
  29. $this->node = (string)$item->attributes()->node;
  30. $this->jid = (string)$item->attributes()->jid;
  31. if($this->jid == null)
  32. $this->jid = $this->node;
  33. $this->name = (string)$item->attributes()->name;
  34. $this->updated = date('Y-m-d H:i:s');
  35. }
  36. public function getName() {
  37. if($this->name != null)
  38. return $this->name;
  39. elseif($this->node != null)
  40. return $this->node;
  41. else
  42. return $this->jid;
  43. }
  44. }
  45. class Server extends ModlModel {
  46. public $server;
  47. public $number;
  48. }