summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 21268ef)
raw | patch | inline | side by side (parent: 21268ef)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 5 May 2008 12:38:09 +0000 (12:38 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 5 May 2008 12:38:09 +0000 (12:38 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10762 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/goto/addons/goto/class_goto_log_view.inc b/gosa-plugins/goto/addons/goto/class_goto_log_view.inc
index 11fd58f2ddbb4c38e0bfbe1613e18fba7db5aa7b..a75aba78cedb92d3f7ca412707ef00a0b6638795 100644 (file)
var $selected_date;
var $selected_file = 0;
- var $attributes = array("selected_file","selected_date");
+ var $attributes = array("macAddress");
+ var $macAddress = "";
+
+ var $sort_by = "file";
+ var $sort_dir = 1; // 1 => up, 0 => down
+
+ var $ignore_account = TRUE;
- function __construct($config,$event,&$parent)
+ function __construct(&$config,$dn,$parent)
{
$this->config = $config;
- $this->event = $event;
$this->parent = $parent;
-
+
/* Try to fetch logs for the given event (mac)
*/
$this->o_queue = new gosaSupportDaemon();
- /* Fetch logs for this event (mac)
+ /* Load ldap object if given
+ and use this macAddress.
+ */
+ if(is_object($parent) && $dn != "" && $dn != "new"){
+ plugin::plugin($config,$dn,$parent);
+ }
+
+ /* Get correct macAddress.
+ Check if an event is given or a ldap object.
*/
- if(isset($this->event['MACADDRESS'])){
- $this->mac = $this->event['MACADDRESS'];
+ if(is_array($this->parent) && isset($this->parent['MACADDRESS'])){
+ $this->mac = $this->parent['MACADDRESS'];
+ }elseif(isset($parent->attrs['macAddress'][0])){
+ $this->mac = $parent->attrs['macAddress'][0];
}
+
+ /* Query for log files
+ */
$res = $this->o_queue->get_log_info_for_mac($this->mac);
if($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{
}
}
+
function execute()
{
$smarty = get_smarty();
$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));
- return($smarty->fetch(get_template_path('log_view.tpl', TRUE)));
+
+ $divlist = new divlist("log_view");
+
+ /* Create sort direction images
+ */
+ if($this->sort_dir){
+ $img = "<img src='images/down-arrow.png' border='0' alt='\\/'>";
+ }else{
+ $img = "<img src='images/up-arrow.png' border='0' alt='/\\'";
+ }
+
+ /* Create list header
+ */
+ $divlist->SetHeader(array(
+ array("string"=>"<a href='?plug=".$_GET['plug']."&sort_by=file'>"._("Log file")." ".$img."</a>",
+ "attach"=>"width='200px;'"),
+ array("string"=>"<a href='?plug=".$_GET['plug']."&sort_by=time'>"._("Log date")." ".$img."</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){
+ $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;'"),
+ array("string" => preg_replace("/%str%/",date("d.m.Y H:i:s",$rtime),$use_link),
+ "attach" => "style='border-right:none;'"),
+ );
+ }
+ }
+ }
+
+ /* 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("divlist",$divlist->DrawList());
+ return($smarty->fetch(get_template_path('log_view.tpl', TRUE,dirname(__FILE__))));
}
function get_log($mac,$date,$file)
{
- $this->mac = "00:01:6c:9d:b9:fa";
$res = $this->o_queue->get_log_file($mac,$date,$file);
if($this->o_queue->is_error()){
msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
function save_object()
{
- plugin::save_object();
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = get_post($attr);
+ foreach(array("time"=>"selected_date","file"=>"selected_file") as $attr => $dest){
+ if(isset($_GET[$attr])){
+ $this->$dest = $_GET[$attr];
}
}
+ if(isset($_GET['sort_by']) && in_array($_GET['sort_by'],array("file","time"))){
+ if($_GET['sort_by'] == $this->sort_by){
+ $this->sort_dir = !$this->sort_dir;
+ }
+ $this->sort_by = $_GET['sort_by'];
+ }
}
-
}
-
-
-
-
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/goto/addons/goto/class_gotomasses.inc b/gosa-plugins/goto/addons/goto/class_gotomasses.inc
index baf158da4d1f360e7c444cc4bf81fe44edd80d34..1e3bf689eaa71cda285d7a1e3b7d43c5b56717b4 100644 (file)
$type = FALSE;
if(isset($this->entries[$id])){
$event = $this->entries[$s_entry];
- $this->dialog = new goto_log_view($this->config,$event,$this);
+ $this->dialog = new goto_log_view($this->config,"",$event,$this);
}
}
diff --git a/gosa-plugins/goto/addons/goto/log_view.tpl b/gosa-plugins/goto/addons/goto/log_view.tpl
index 9ee5bbcea03cc0afa787b63ec9ed66814549d308..459ff9b2d83db5613825825add7106bd2d9d5d9f 100644 (file)
<h2>{t}Log view{/t}</h2>
{if $logs_available}
- <table>
- <tr>
- <td>{t}Creation time{/t}: </td>
- <td>
- <select name="selected_date" onChange="document.mainform.submit();">
- {foreach from=$logs.$mac item=stuff key=date}
- {if $date == $selected_date}
- <option value="{$date}" selected>{$stuff.REAL_DATE|date_format:"%d.%m.%Y %H:%m:%S"}</option>
- {else}
- <option value="{$date}">{$stuff.REAL_DATE|date_format:"%d.%m.%Y %H:%m:%S"}</option>
- {/if}
- {/foreach}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Log file{/t}: </td>
- <td>
- <select name="selected_file" onChange="document.mainform.submit();">
- {foreach from=$logs.$mac.$selected_date.FILES item=filename}
- {if $filename == $selected_file}
- <option value="{$filename}" selected>{$filename}</option>
- {else}
- <option value="{$filename}">{$filename}</option>
- {/if}
- {/foreach}
- </select>
- </td>
- </tr>
- </table>
-
+ <div style="width:100%;border: solid 1px #CCCCCC;">{$divlist}</div>
<h2>{t}Log file{/t}</h2>
- <div style="width:100%;height:350px; overflow-y: scroll; background-color:#EEEEEE; border: solid 1px;">
+ <div style="width:100%;height:350px; overflow-y: scroll;border: solid 1px;">
{$log_file}
</div>
{else}