74 function Log_mcal($name, $ident =
'', $conf = array(),
77 $this->_id = md5(microtime());
79 $this->_ident = $ident;
81 $this->_calendar = $conf[
'calendar'];
82 $this->_username = $conf[
'username'];
83 $this->_password = $conf[
'password'];
84 $this->_options = $conf[
'options'];
94 if (!$this->_opened) {
95 $this->_stream = mcal_open($this->_calendar, $this->_username,
96 $this->_password, $this->_options);
97 $this->_opened =
true;
109 if ($this->_opened) {
110 mcal_close($this->_stream);
111 $this->_opened =
false;
114 return ($this->_opened ===
false);
131 function log($message, $priority = null)
134 if ($priority === null) {
144 if (!$this->_opened && !$this->
open()) {
151 $date_str = date(
'Y:n:j:G:i:s');
152 $dates = explode(
':', $date_str);
154 mcal_event_init($this->_stream);
155 mcal_event_set_title($this->_stream, $this->_ident);
156 mcal_event_set_category($this->_stream, $this->_name);
157 mcal_event_set_description($this->_stream, $message);
158 mcal_event_add_attribute($this->_stream,
'priority', $priority);
159 mcal_event_set_start($this->_stream, $dates[0], $dates[1], $dates[2],
160 $dates[3], $dates[4], $dates[5]);
161 mcal_event_set_end($this->_stream, $dates[0], $dates[1], $dates[2],
162 $dates[3], $dates[4], $dates[5]);
163 mcal_append_event($this->_stream);
165 $this->
_announce(array(
'priority' => $priority,
'message' => $message));