status = $this->status (); } //*************************** // GETTER / SETTER //*************************** public function __get ($name) { switch ($name) { case "may_set_online": return Ticket::getEditRight () & Base::MODE_ONLINE; case "historyList": return $this->status['values']; case "status": $status = $this->status; return $status; default: return $this->$name; } } public function __set ($name, $value) { } private function status () { $status = array (); $status['active_history'] = User::get ("active_history_id", 0); $last_row_id = 0; $status['values'] = array (); foreach (History::getList () as $row) { if (!empty ($_SESSION['cms']['history']['multiuser']) || $row['user_id']==User::get ("id")) { $group = null; if ($row['table_name'] == "element") { $element = new Element (array ('id' => $row['row_id'])); $group = new Group (array ('id' => $element->group_id)); } if ($row['table_name'] == "group") { $group = new Group (array ('id' => $row['row_id'])); } if ($group) { $row['url'] = $group->url; $row['may_select'] = $row['status']!=History::STATUS_ACTIVE && ((!($group->status & Base::STATUS_ONLINE) || ($group->status & Base::STATUS_ONLINE) && ($group->edit_right & User::RIGHT_ONLINE)) && ($group->edit_right & User::RIGHT_EDIT)); } else { $row['may_select'] = $row['status']!=History::STATUS_ACTIVE && (User::get ("is_admin") || $row['user_id']==User::get ("id")); } $row['is_active'] = $row['status']==History::STATUS_ACTIVE; $row['deleted'] = $row['status']==History::STATUS_ERASED; $row['title'] = User::get ('is_admin') ? "#{$row['id']}" : ""; $status['values'][] = $row; // undo / redo if ($last_row_id && $last_row_id == $status['active_history']) { $this->redo_id = $row['id']; } if ($row['id'] == $status['active_history'] || !$status['active_history'] && $last_row_id) { $this->undo_id = $last_row_id; } if ($row['may_select'] || $row['id'] == $status['active_history']) { $last_row_id = $row['id']; } } } $status['values'] = array_reverse ($status['values']); $status['messages'] = array (); $status['multiuser'] = (!empty ($_SESSION['cms']['history']['multiuser'])); $status['quickbar']['disabledButtons'] = array (); if (!$this->undo_id) { $status['quickbar']['disabledButtons']['undo'] = true; } if (!$this->redo_id) { $status['quickbar']['disabledButtons']['redo'] = true; } $status['statusbar']['value'] = ""; // Elementname, User, letzte Änderung,... if (User::get ("is_admin")) { $status['statusbar']['value'] .= ""; } return $status; } public function select ($id) { if ($row = History::get ($id)) { if ($row['table_name'] == "element") { $element = new Element (array ('id' => $row['row_id'])); $row['table_name'] = "group"; $row['row_id'] = $element->group_id; } if ($row['table_name'] == "group") { $group = new Group (array ('id' => $row['row_id'])); // Prüfen ob User berechtigt ist diese Aktion durchzuführen if ((!($group->status & Base::STATUS_ONLINE) || ($group->status & Base::STATUS_ONLINE) && ($group->edit_right & User::RIGHT_ONLINE)) && ($group->edit_right & User::RIGHT_EDIT)) { History::restore ($row['id']); } } else { History::restore ($row['id']); } User::set (User::get ('id'), array ("active_history_id"=>$id), false); } } public function undo () { $this->select ($this->undo_id); } public function redo () { $this->select ($this->redo_id); } public function multiuser () { $_SESSION['cms']['history']['multiuser'] = empty ($_SESSION['cms']['history']['multiuser']); } public function message ($text) { return I18n::tr ("edit", "show_history/$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'"); } } } ?>