summaryrefslogtreecommitdiffstats
path: root/library/Icinga/Web/Announcement.php
blob: 9835ce0ca218bfd0b049bcf0f09f38bb7142224d (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */

namespace Icinga\Web;

/**
 * An announcement to be displayed prominently in the web UI
 */
class Announcement
{
    /**
     * @var string
     */
    protected $author;

    /**
     * @var string
     */
    protected $message;

    /**
     * @var int
     */
    protected $start;

    /**
     * @var int
     */
    protected $end;

    /**
     * Hash of the message
     *
     * @var string|null
     */
    protected $hash = null;

    /**
     * Announcement constructor
     *
     * @param array $properties
     */
    public function __construct(array $properties = array())
    {
        foreach ($properties as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
    }

    /**
     * Get the author of the acknowledged
     *
     * @return string
     */
    public function getAuthor()
    {
        return $this->author;
    }

    /**
     * Set the author of the acknowledged
     *
     * @param   string $author
     *
     * @return  $this
     */
    public function setAuthor($author)
    {
        $this->author = $author;
        return $this;
    }

    /**
     * Get the message of the acknowledged
     *
     * @return string
     */
    public function getMessage()
    {
        return $this->message;
    }

    /**
     * Set the message of the acknowledged
     *
     * @param   string $message
     *
     * @return  $this
     */
    public function setMessage($message)
    {
        $this->message = $message;
        $this->hash = null;
        return $this;
    }

    /**
     * Get the start date and time of the acknowledged
     *
     * @return int
     */
    public function getStart()
    {
        return $this->start;
    }

    /**
     * Set the start date and time of the acknowledged
     *
     * @param   int $start
     *
     * @return  $this
     */
    public function setStart($start)
    {
        $this->start = $start;
        return $this;
    }

    /**
     * Get the end date and time of the acknowledged
     *
     * @return int
     */
    public function getEnd()
    {
        return $this->end;
    }

    /**
     * Set the end date and time of the acknowledged
     *
     * @param   int $end
     *
     * @return  $this
     */
    public function setEnd($end)
    {
        $this->end = $end;
        return $this;
    }

    /**
     * Get the hash of the acknowledgement
     *
     * @return string
     */
    public function getHash()
    {
        if ($this->hash === null) {
            $this->hash = md5($this->message);
        }
        return $this->hash;
    }
}