1: <?php
2: /**
3: * A view for regenerating the Kolab Free/Busy cache.
4: *
5: * Copyright 2009 Klarälvdalens Datakonsult AB
6: *
7: * @author Gunnar Wrobel <p@rdus.de>
8: * @package Kolab_FreeBusy
9: */
10:
11: class Horde_Kolab_FreeBusy_Report {
12:
13: var $_break = '<br/>';
14:
15: var $_errors = array();
16:
17: function Horde_Kolab_FreeBusy_Report()
18: {
19: if (PHP_SAPI == 'cli') {
20: $this->_break = "\n";
21:
22: /* Display errors if we are working on the command line */
23: ini_set('display_errors', 1);
24:
25: /** Don't report notices */
26: error_reporting(E_ALL & ~E_NOTICE);
27: }
28: }
29:
30: function start()
31: {
32: echo Horde_Kolab_FreeBusy_Translation::t("Starting to regenerate the free/busy cache...");
33: $this->linebreak(2);
34: }
35:
36: function success($calendar)
37: {
38: echo sprintf(Horde_Kolab_FreeBusy_Translation::t("Successfully regenerated calendar \"%s\"!"),
39: $calendar);
40: $this->linebreak(1);
41: }
42:
43: function failure($calendar, $error)
44: {
45: $this->_errors[] = sprintf(Horde_Kolab_FreeBusy_Translation::t("Failed regenerating calendar %s: %s"),
46: $calendar, $error->getMessage());
47: }
48:
49: function stop()
50: {
51: if (!empty($this->_errors)) {
52: $this->linebreak(1);
53: echo Horde_Kolab_FreeBusy_Translation::t("Errors:");
54: $this->linebreak(1);
55: foreach ($this->_errors as $error) {
56: echo $error;
57: }
58: return false;
59: } else {
60: $this->linebreak(1);
61: echo Horde_Kolab_FreeBusy_Translation::t("Successfully regenerated all calendar caches!");
62: $this->linebreak(1);
63: return true;
64: }
65: }
66:
67: function linebreak($count = 1)
68: {
69: for ($i = 0; $i < $count; $i++) {
70: echo $this->_break;
71: }
72: }
73: }
74: