summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 976248a)
raw | patch | inline | side by side (parent: 976248a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 23 Mar 2010 06:52:06 +0000 (06:52 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 23 Mar 2010 06:52:06 +0000 (06:52 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16999 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/goto/addons/goto/class_gotoLogView.inc | patch | blob | history | |
gosa-plugins/goto/addons/goto/log_view.tpl | patch | blob | history |
diff --git a/gosa-plugins/goto/addons/goto/class_gotoLogView.inc b/gosa-plugins/goto/addons/goto/class_gotoLogView.inc
index 12937512cab55acd559ab13410dc3a005e42788a..740808b9df88062b31710344fde1f7a0b9e16c93 100644 (file)
var $ignore_account = TRUE;
var $standalone = FALSE;
+
+ var $logSelector = NULL;
function __construct(&$config,$dn,$parent)
{
$res = $this->o_queue->get_log_info_for_mac($this->mac);
if($this->o_queue->is_configured() && $this->o_queue->is_error()){
msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
- }
-
- /* Check if there is at least one log file
- */
- if(!isset($res[$this->mac]) || !is_array($res[$this->mac])){
- $this->logs = array();
}else{
- $this->selected_date = key($res[$this->mac]);
- $this->logs = $res;
+ $tmp = array();
+ foreach($res as $mac => $logs){
+ if($mac != $this->mac) continue;
+
+ foreach($logs as $name => $log){
+ if(isset($log['FILES'])){
+ foreach($log['FILES'] as $fkey => $fval){
+ $tmp[] = array(
+ 'MAC' => $mac,
+ 'DATE' => $log['REAL_DATE'],
+ 'DATE_STR'=> $log['DATE_STR'],
+ 'FILE' => $fval);
+ }
+ }
+ }
+ }
+
+ /* Check if there is at least one log file
+ */
+ $this->logs = $tmp;
}
+ // Create the filter list
+ $this->logSelector= new sortableListing($this->logs, $this->convertFilterList($this->logs));
+ $this->logSelector->setDeleteable(false);
+ $this->logSelector->setEditable(true);
+ $this->logSelector->setAcl("rwcdm");
+ $this->logSelector->setWidth("100%");
+ $this->logSelector->setHeight("120px");
+ $this->logSelector->setHeader(array(_("Date"),_("Filename")));
+ $this->logSelector->setColspecs(array('80px', '100px', '200px', '120px','150px'));
+ }
+
+
+ /*! \brief Converts the list of filters ($this->filters) into data which is useable
+ * for the sortableList object ($this->filterWidget).
+ * @return Array An array containg data useable for sortableLists ($this->filterWidget)
+ */
+ function convertFilterList($logs)
+ {
+ $data = array();
+ foreach($logs as $key => $log){
+ $data[$key] = array('data' =>
+ array(date('d.m.Y H:i:s',$log['DATE']),$log['FILE']));
+ }
+ return($data);
}
{
plugin::execute();
+ // Act on edit requests
+ $this->logSelector->save_object();
+ $action = $this->logSelector->getAction();
+
+ if(isset($action['action']) && $action['action'] == 'edit'){
+ $id = $action['targets'][0];
+ $entry = $this->logs[$id];
+ $this->selected_file = $entry['FILE'];
+ $this->selected_date = $entry['DATE'];
+ }
+
+
$smarty = get_smarty();
$smarty->assign("logs",$this->logs);
- $smarty->assign("logs_available", isset($this->logs[$this->mac]));
+ $smarty->assign("logs_available", count($this->logs));
$smarty->assign("mac",$this->mac);
$smarty->assign("selected_file",$this->selected_file);
$smarty->assign("selected_date",$this->selected_date);
$smarty->assign("log_file", $this->get_log($this->mac,$this->selected_date,$this->selected_file));
$smarty->assign("standalone",$this->standalone);
-
if (isset($this->logs[$this->mac])){
$date = date("d.m.Y H:i:s",$this->logs[$this->mac][$this->selected_date]['REAL_DATE']);
}
$file = $this->selected_file;
$smarty->assign("selected_log",_("none"));
if(!empty($file)){
- $smarty->assign("selected_log",$file.", ".$date);
+ $smarty->assign("selected_log", $file.", ".date('d.m.Y H:i:s', $this->selected_date));
}
-
- $divlist = new divlist("log_view");
-
- /* Create sort direction images
- */
- if($this->sort_dir){
- $img = "<img src='images/lists/sort-down.png' border='0' alt='\\/'>";
- }else{
- $img = "<img src='images/lists/sort-up.png' border='0' alt='/\\'";
- }
- if($this->sort_by == "file"){
- $img1 = $img;
- $img2 = "";
- }else{
- $img1 = "";
- $img2 = $img;
- }
-
-
- /* Create list header
- */
- $divlist->SetHeader(array(
- array("string"=>"<a href='?plug=".$_GET['plug']."&sort_by=file'>"._("File")." ".$img1."</a>",
- "attach"=>"width='200px;'"),
- array("string"=>"<a href='?plug=".$_GET['plug']."&sort_by=time'>"._("Date")." ".$img2."</a>",
- "attach" => "style='border-right:none;'"),
- ));
-
- /* Create divlist list
- */
- $divlist->SetEntriesPerPage(0);
- $divlist->SetHeight(150);
-
- /* Create sortable array
- */
- $link = "<a href='?plug=".$_GET['plug']."&time=%time%&file=%file%&mac=%mac%'>%str%</a>";
- $to_add = array();
- $sort_by = $this->sort_by;
- foreach($this->logs as $mac => $times){
- foreach($times as $time => $data){
- $rtime = $data['REAL_DATE'];
- foreach($data['FILES'] as $file){
-
- $highlight = "";
- if($file == $this->selected_file && $time == $this->selected_date && $mac == $this->mac){
- $highlight = "background-color:#CCCCCC";
- }
-
- $use_link = preg_replace(array("/%mac%/","/%time%/","/%file%/"),array($mac,$time,$file),$link);
- $to_add[$$sort_by.$file.$time] = array(
- array("string" => preg_replace("/%str%/",$file,$use_link),
- "attach" => "style='width:200px; $highlight'"),
- array("string" => preg_replace("/%str%/",date("d.m.Y H:i:s",$rtime),$use_link),
- "attach" => "style='border-right:none; $highlight'"),
- );
- }
- }
- }
-
- /* Sort entries
- */
- if(!$this->sort_dir){
- uksort($to_add, "strnatcasecmp");
- }else{
- uksort($to_add, "strnatcasecmp");
- $to_add = array_reverse($to_add);
- }
-
- /* Append entries to list
- */
- foreach($to_add as $entry){
- $divlist->AddEntry($entry);
- }
-
$smarty->assign("ACL",preg_match("/r/",$this->getacl("")));
- $smarty->assign("divlist",$divlist->DrawList());
+ $this->logSelector->setAcl($this->getacl(""));
+ $smarty->assign("divlist", $this->logSelector->render());
return($smarty->fetch(get_template_path('log_view.tpl', TRUE,dirname(__FILE__))));
}
diff --git a/gosa-plugins/goto/addons/goto/log_view.tpl b/gosa-plugins/goto/addons/goto/log_view.tpl
index 0989935dd467baa2fefca9f5045ac5eef7eb2da3..05ae69742813cbdd80db03af74b5956b8bc803ba 100644 (file)
{if $logs_available}
<h3>{t}Available logs{/t}</h3>
- <div style="width:99%;border: solid 1px #CCCCCC;">{$divlist}</div>
+
+ <table style='width:100%;height:40px;'><tr><td>
+ {$divlist}
+ </td></tr></table>
<br>
<hr>
<h3>{t}Selected log{/t}: {$selected_log}</h3>
- <div style="width:99%;height:350px;padding:3px;background-color:white; overflow-y: scroll;border: solid 1px;">
{$log_file}
- </div>
{else}
<h3>{t}No logs for this host available!{/t}</h3>
{/if}