Code

Added acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 31 Oct 2006 05:31:19 +0000 (05:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 31 Oct 2006 05:31:19 +0000 (05:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4965 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/logview/class_logview.inc
plugins/addons/logview/contents.tpl
plugins/addons/logview/main.inc

index e7062ff30cf67411fa5377c8d48786547b6337d9..1bde25d6865f25c9136b452fbf846e4e5ee85a05 100644 (file)
@@ -34,6 +34,8 @@ class logview extends plugin
 
       register_global("logfilter", $logfilter);
     }
+
+    $this->ui = get_userinfo();
   }
 
   function execute()
@@ -147,6 +149,27 @@ class logview extends plugin
 
     $smarty->assign("regex", $logfilter['regex']);
 
+
+    /* Get acls */
+    
+    $tmp_cat_bases = $this->ui->get_module_departments("logview");
+    $all_acls = "";
+    foreach($tmp_cat_bases as $acl_base){
+      $all_acls .= $this->ui->get_permissions($acl_base,"logview/logview");
+    }
+    if(count($tmp_cat_bases) == 0 || !preg_match("/r/",$all_acls)){
+      $res = "<tr>
+        <td colspan=4>
+        "._("You have insufficient permissions to view syslog entries.")."
+        </td>
+        </tr>";
+
+      /* Show main page */
+      $smarty->assign("range_selector", "");
+      $smarty->assign("search_result", $res);
+      return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+    }
+
     /* Query stuff */
     $res= "";
     $cfg    = $this->config->data['SERVERS']['LOG'];
@@ -220,13 +243,13 @@ class logview extends plugin
         }
         $end= date ("YmdHis");
         $query_base= "  FROM 
-                          golog 
-                        WHERE 
-                          message like '".preg_replace("/\*/","%",$logfilter['regex'])."' 
-                          $ll 
-                          $hf 
-                        AND 
-                          time_stamp <= $end AND time_stamp >= $start";
+          golog 
+          WHERE 
+          message like '".preg_replace("/\*/","%",$logfilter['regex'])."' 
+          $ll 
+          $hf 
+          AND 
+          time_stamp <= $end AND time_stamp >= $start";
 
         /* Get number of entries */
         $query= "SELECT COUNT(*)".$query_base.";";
@@ -246,7 +269,11 @@ class logview extends plugin
 
         /* Display results */
         $mod= 0;
+
+        /* Add entries to result str */
         while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
+
+          /* Toggle background color */
           if ( ($mod++) & 1){
             $col= "background-color: #ECECEC;";
           } else {
@@ -255,19 +282,19 @@ class logview extends plugin
 
           $res.=" <tr style=\"$col\">\n";
           $res.="   <td style=\"text-align:center\">
-                    <img alt=\"".$line['log_level']."\" 
-                      src=\"".get_template_path('images/log_'.strtolower($line['log_level'])).".png\" 
-                      title=\"Log level is '".$line['log_level']."'\">
-                    </td>
-                    <td>".
-                      $line['host']."
-                    </td>";
+            <img alt=\"".$line['log_level']."\" 
+            src=\"".get_template_path('images/log_'.strtolower($line['log_level'])).".png\" 
+            title=\"Log level is '".$line['log_level']."'\">
+            </td>";
           $res.="   <td>".
-                      $line['time_stamp']."
-                    </td>
-                    <td width=\"100%\">".
-                      $line['message']."
-                    </td>";
+            $line['host']."
+            </td>"; 
+            $res.=" <td>".
+            $line['time_stamp']."
+            </td>";
+          $res .= "<td width=\"100%\">".
+            $line['message']."
+            </td>";
           $res.=" </tr>\n";
         }
         mysql_close($link);
@@ -347,6 +374,24 @@ class logview extends plugin
       }
     }
   }
+
+
+  /* Return plugin informations for acl handling
+     #FIXME You can only read attributes within this report plugin */
+  function plInfo()
+  {
+    return (array(
+        "plShortName"   => _("Log view"),
+        "plDescription" => _("Log view addon"),
+        "plSelfModify"  => FALSE,
+        "plDepends"     => array(),
+        "plPriority"    => 0,
+        "plSection"     => array("addon"),
+        "plCategory"    => array("logview" => array("objectClass" => "none", "description" => _("System logs"))),
+
+        "plProvidedAcls" => array()
+        ));
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index bb62fc3ef4732b8b1192c7951d1c514457254278..2262604ad8cadd90620430d7f16e1a4d1df6dc58 100644 (file)
    <td style="border-left:1px solid #A0A0A0">
     &nbsp;
    </td>
-   
    <td>
     <table summary="" width="100%">
+  <!-- 
      <tr>
       <td><img class="center" alt="" align="middle" border=0 src="{$ruleset_image}">&nbsp;<LABEL for="edit_rules">{t}Ruleset{/t}</LABEL></td>
       <td width="100%">
        <input id="edit_rules" name="edit_rules" type="submit" value="{t}Edit{/t}" disabled>
       </td>
      </tr>
+-->
      <tr>
       <td colspan=2 style="text-align:right;">
        <input name="search" type="submit" value="{t}Search{/t}">
@@ -69,7 +70,6 @@
      </tr>
     </table>
    </td>
-
   </tr>
  </table>
 </div>
index 6b346926736f9c2298483b02ac72ff7569821941..1e4bf527843b76ac2fbbd0602a4acf3f36b51707 100644 (file)
 */
 
 if (!$remove_lock){
+
        /* Create logview object on demand */
        if (!isset($_SESSION['logview']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
                $_SESSION['logview']= new logview ($config);
+               $_SESSION['logview']->set_acl_category("logview");
        }
        $logview= $_SESSION['logview'];