active = &$_SESSION['cms']['edit']['ticket']['activ_id']; $this->status = $this->status (); } //*************************** // GETTER / SETTER //*************************** public function __get ($name) { switch ($name) { case "timers": return Timer::getList (-1); case "may_set_online": return Ticket::getEditRight () & Base::MODE_ONLINE; case "may_edit": return Ticket::getEditRight () & Base::MODE_EDIT; default: return $this->$name; } } public function __set ($name, $value) { } private function status () { $status = array (); if ($this->active==-1) { $status['values'] = array ('name' => "", 'timer_id' => 0); } else { $status['values'] = Ticket::get ($this->active); } $status['messages'] = array (); $status['delQuestion'] = I18n::tr ("edit", "set_ticket/del this Ticket?", "del this Ticket?"); $status['quickbar']['disabledButtons']['save'] = true; if (!History::getFirstUndo ($this->active, "ticket", false)) { $status['quickbar']['disabledButtons']['undo'] = true; } if (!History::getFirstRedo ($this->active, "ticket", false)) { $status['quickbar']['disabledButtons']['redo'] = true; } $status['quickbar']['disabledButtons']['edit'] = !Ticket::selected (); $status['quickbar']['disabledButtons']['delete'] = !Ticket::selected () || Ticket::selected ()==Ticket::SERVER_ID; $status['statusbar']['value'] = ""; // Elementname, User, letzte Änderung,... if (User::get ("is_admin")) { $status['statusbar']['value'] .= " #{$this->active}"; } return $status; } public function ticketList () { $values = Ticket::getList (); foreach ($values as $key => $row) { $values[$key]['status'] = $row['timer_id'] ? "timer" : "ticket"; } return $values; } public function save ($values) { $history = new History ("ticket set"); $history->groupStart (); if (isset ($values['name']) && $values['name']) { $this->active = Ticket::setName ($this->active, $values['name']); if (!Ticket::selected ()) { $this->select ($this->active); } } if (isset ($values['timer_id']) && $this->may_set_online) { Ticket::setTimer ($this->active, $values['timer_id']); } $history->groupEnd(); $this->active = 0; $this->status = $this->status (); } public function undo () { if ($undo = History::getFirstUndo ($this->active, "ticket", false)) { History::restore ($undo['id']); $this->status = $this->status (); } } public function redo () { if ($redo = History::getFirstRedo ($this->active, "ticket", false)) { History::restore ($redo['id']); $this->status = $this->status (); } } public function select ($id) { $this->active = 0; if (!Ticket::selected ($id)) { Group::setEditMode (0, Base::MODE_ONLINE); } else if (Group::getEditMode () & Base::MODE_ONLINE) { Group::setEditMode (0, Base::MODE_VIEW); } } public function edit () { $this->active = Ticket::selected (); } public function add () { $this->active = -1; Ticket::selected (-1); Group::setEditMode (0, Base::MODE_ONLINE); } public function del () { Ticket::del ($this->active); Ticket::selected (-1); Group::setEditMode (0, Base::MODE_ONLINE); $this->active = 0; } public function message ($text) { return I18n::tr ("edit", "set_ticket/$text", $text); } // Wandelt das gegebene Array/Text in eine Form um, die direkt einer JavaScript Variablen zugewiesen werden kann public function toJavaScript ($value) { if (is_array ($value)) { $values = array (); foreach ($value as $key => $val) { $values[] = "'$key':".$this->toJavaScript ($val); } return "{".implode (",", $values)."}"; } else { $value = Database::escape ($value); return ($value===true) ? "true" : (($value===false) ? "false" : "'$value'"); } } } ?>