Merge branch 'maint/7.0'
[ninja.git] / modules / orm / models / recurringdowntime.php
blob7f251de577f31c094e0fe14db39012142ff80161
1 <?php
3 require_once( dirname(__FILE__).'/base/baserecurringdowntime.php' );
5 /**
6 * Autogenerated class RecurringDowntime_Model
8 * @todo: documentation
9 */
10 class RecurringDowntime_Model extends BaseRecurringDowntime_Model {
11 static public $rewrite_columns = array(
12 'objects' => array('id'),
13 'end_time_string' => array('end_time'),
14 'start_time_string' => array('start_time'),
15 'duration_string' => array('duration'),
18 public function get_weekdays()
20 $weekdays = parent::get_weekdays();
21 if (is_string($weekdays))
22 $weekdays = unserialize($weekdays);
23 if (!$weekdays)
24 $weekdays = array();
25 return $weekdays;
28 public function get_months()
30 $months = parent::get_months();
31 if (is_string($months))
32 $months = unserialize($months);
33 if (!$months)
34 $months = array();
35 return $months;
38 /**
39 * Get the start time, but format it the way times are usually
40 * formatted: hh:mm:ss
42 public function get_start_time_string()
44 $start_time = $this->get_start_time();
45 return sprintf("%02d:%02d:%02d", (int)($start_time / 3600 % 24), (int)($start_time / 60 % 60), (int)($start_time % 60));
48 /**
49 * Get the end time, but format it the way times are usually
50 * formatted: hh:mm:ss
52 public function get_end_time_string()
54 $end_time = $this->get_end_time();
55 return sprintf("%02d:%02d:%02d", (int)($end_time / 3600 % 24), (int)($end_time / 60 % 60), (int)($end_time % 60));
58 /**
59 * Get the duration, but format it the way times are usually
60 * formatted: hh:mm:ss
62 public function get_duration_string()
64 $duration = $this->get_duration();
65 return sprintf("%02d:%02d:%02d", (int)($duration / 3600 % 24), (int)($duration / 60 % 60), (int)($duration % 60));
68 /**
69 * Get all objects in this schedule as a list
71 public function get_objects()
73 $ret = array();
74 $id = $this->get_id();
75 if ($id) {
76 $db = Database::instance();
77 $res = $db->query('SELECT object_name from recurring_downtime_objects WHERE recurring_downtime_id = '.$id);
78 foreach ($res->result(false) as $row) {
79 $ret[] = $row['object_name'];
82 return $ret;