blob: 6ef2f8ec63113c0c546ba8ea5dce8847360172f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<?php
namespace OCA\OJSXC\Db;
use OCA\OJSXC\AppInfo\Application;
use \OCP\AppFramework\Db\Entity;
use Sabre\Xml\Reader;
use Sabre\Xml\Writer;
use Sabre\Xml\XmlDeserializable;
use Sabre\Xml\XmlSerializable;
/**
* Class Stanza
* @package OCA\OJSXC\Db
* @brief this class is used as the entity which is fetched from the stanza table OR extended by a specific stanza
* for inserting into the stanza table
* @method string getStanza()
* @method void setStanza($stanza)
*/
class Stanza extends Entity implements XmlSerializable
{
public function __construct($stanza = '')
{
$this->setStanza($stanza);
}
/**
* @var string $to
*/
public $to;
/**
* @var string $to
*/
public $from;
/**
* @var string $stanza
*/
public $stanza;
public function getTo()
{
return $this->to;
}
/**
* Sets the to user as a `user`.
*
* @see setFullTo
* @param $userId
* @param null $host_and_or_resource
*/
public function setTo($userId, $host_and_or_resource = null)
{
if (is_array($userId)) {
// support mapFromRow
$host_and_or_resource = $userId[1];
$userId = $userId[0];
}
$this->to = Application::sanitizeUserId($userId);
if (!is_null($host_and_or_resource)) {
$this->to .= '@' . $host_and_or_resource;
}
}
/**
* Sets the from user as a `user`.
*
* @see setFullFrom
* @param $userId
* @param null $host_and_or_resource
*/
public function setFrom($userId, $host_and_or_resource = null)
{
if (is_array($userId)) {
// support mapFromRow
$host_and_or_resource = $userId[1];
$userId = $userId[0];
}
$this->from = Application::sanitizeUserId($userId);
if (!is_null($host_and_or_resource)) {
$this->from .= '@' . $host_and_or_resource;
}
}
public function getFrom()
{
return $this->from;
}
public function xmlSerialize(Writer $writer)
{
$writer->writeRaw($this->getStanza());
}
}
|