Code

Added new policy class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Apr 2008 13:44:18 +0000 (13:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Apr 2008 13:44:18 +0000 (13:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10655 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc
gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc [new file with mode: 0644]
gosa-plugins/heimdal/admin/systems/services/kerberos/krb5_policy.tpl [new file with mode: 0644]

index 8d00fedc22013d6d9fe0a9070f65c984992dae41..4887b92041a28c25ff048ef7abc0c482061e7069 100644 (file)
@@ -37,7 +37,7 @@ class goKrbServer extends goService{
     }else{
       $this->policies = array();
       foreach($tmp as $policy){
-        $this->policies[] = array("NAME" => $policy,"STATUS" => "LOADED");
+        $this->policies[] = array("NAME" => $policy,"STATUS" => "LOADED","DATA" => array());
       }
     }
   }
@@ -47,11 +47,74 @@ class goKrbServer extends goService{
   { 
     $smarty = get_smarty(); 
 
-    if($this->is_account && !$this->view_logged){
+    if(!$this->view_logged){
       $this->view_logged = TRUE;
       new log("view","server/".get_class($this),$this->dn);
     }
 
+    /*******  
+      Display sub dialogs
+     *******/
+
+    /* Add new Policy requested 
+     */
+    if(isset($_POST['policy_add'])){
+      $this->dialog = new krb5_policy($this->config,array());
+    }
+
+
+    /* Walk through POSTs an check for image-button posts 
+     */
+    foreach($_POST as $name => $value){
+
+      /* Remove policy requested 
+       */
+      if(preg_match("/^policy_del/",$name)){
+        $id = preg_replace("/^policy_del_([0-9]*)_.*/i","\\1",$name);
+        if(isset($this->policies[$id])){
+          $this->policies[$id]['STATUS'] = "REMOVED";
+        }
+        break;
+      }
+
+      /* Edit Policy requested 
+       */
+      if(preg_match("/^policy_edit/",$name)){
+        $id = preg_replace("/^policy_edit_([0-9]*)_.*/i","\\1",$name);
+        if(isset($this->policies[$id])){
+           
+          /* Load policy information, if not done before 
+           */ 
+          if($this->policies[$id]['STATUS'] == "LOADED" && empty($this->policies[$id]['DATA'])){
+            $o = new gosaSupportDaemon();
+            $this->policies[$id]['DATA'] = $o->krb5_get_policy("00:01:6c:9d:aa:16",$this->policies[$id]['NAME']);
+          }
+
+          /* Open dialog */ 
+          $this->dialog = new krb5_policy($this->config,$this->policies[$id]);
+        }
+        break;
+      }
+    }
+
+  
+    if(isset($_POST['cancel_policy'])){
+      $this->dialog = NULL;
+    }
+    if(isset($_POST['save_policy'])){
+      $this->dialog->save_object();
+      echo "NYI";
+      $this->dialog = NULL;
+    }
+    if($this->dialog instanceof krb5_policy){
+      $this->dialog->save_object();
+      return($this->dialog->execute());
+    } 
+
+    /*******
+      Create HTML output for this plugin
+     *******/  
+
     $tmp = $this->plinfo();
     foreach($tmp['plProvidedAcls'] as $name => $translation){
       $smarty->assign($name."ACL",$this->getacl($name));
@@ -101,32 +164,10 @@ class goKrbServer extends goService{
     if(isset($_POST['goKrbServerPosted'])){
       plugin::save_object();
     }
-
-    /* */
-    if(isset($_POST['policy_add'])){
-      echo "add";
-      // $this->dialog = new krb5_policy($this->config,array());
-    }
-    foreach($_POST as $name => $value){
-      if(preg_match("/^policy_del/",$name)){
-        $id = preg_replace("/^policy_del_([0-9]*)_.*/i","\\1",$name);
-        if(isset($this->policies[$id])){
-          unset($this->policies[$id]);
-        }
-        break;
-      }
-      if(preg_match("/^policy_edit/",$name)){
-        $id = preg_replace("/^policy_edit_([0-9]*)_.*/i","\\1",$name);
-        if(isset($this->policies[$id])){
-          echo "edit $id";
-        // $this->dialog = new krb5_policy($this->config,$this->policies[$id]);
-        }
-        break;
-      }
-    }
   } 
 
-    /* Return plugin informations for acl handling */
+
+  /* Return plugin informations for acl handling */
   static function plInfo()
   {
     return (array(
diff --git a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc
new file mode 100644 (file)
index 0000000..6f993e8
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+
+class krb5_policy extends plugin
+{
+  var $name   = "";
+  var $data   = array();
+  var $is_new = TRUE;
+  var $config;
+  var $attributes = array("MASK","POLICY_REFCNT","PW_HISTORY_NUM","PW_MAX_LIFE","PW_MIN_CLASSES","PW_MIN_LENGTH","PW_MIN_LIFE");
+
+       public function __construct($config,$entry = array())
+       {
+    $this->config = $config;
+    if(count($entry)){
+      $this->is_new =FALSE;
+      $this->name = $entry['NAME'];
+      $this->data = $entry['DATA'];
+    }
+    $this->init_name = $this->name; 
+       }
+
+  public function execute()
+  {
+    $display = plugin::execute();
+    $smarty = get_smarty();    
+
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr,$this->data[$attr]);
+    }
+    return($smarty->fetch(get_template_path("krb5_policy.tpl",TRUE,dirname(__FILE__))));
+  }
+
+
+  public function save_object()
+  {
+    if(isset($_POST['Policy_Posted'])){
+      foreach($this->attributes as $attr){
+        if(isset($_POST[$attr])){
+          $this->data[$attr] = get_post($attr);
+        }
+      }
+    }
+  }
+    
+
+  public function save()
+  {
+    $ret = array();
+    $ret['INITIAL_NAME']= $this->init_name;
+    $ret['NAME']        = $this->name;
+    $ret['DATA']        = $this->data;
+    return($ret);
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/heimdal/admin/systems/services/kerberos/krb5_policy.tpl b/gosa-plugins/heimdal/admin/systems/services/kerberos/krb5_policy.tpl
new file mode 100644 (file)
index 0000000..d528532
--- /dev/null
@@ -0,0 +1,34 @@
+<table>
+       <tr>
+               <td>{t}Mask{/t}</td>
+               <td><input type="text" name="MASK" value="{$MASK}"></td>
+       </tr>
+       <tr>
+               <td>{t}POLICY_REFCNT{/t}</td>
+               <td><input type="text" name="POLICY_REFCNT" value="{$POLICY_REFCNT}"></td>
+       </tr>
+       <tr>
+               <td>{t}PW_HISTORY_NUM{/t}</td>
+               <td><input type="text" name="PW_HISTORY_NUM" value="{$PW_HISTORY_NUM}"></td>
+       </tr>
+       <tr>
+               <td>{t}PW_MAX_LIFE{/t}</td>
+               <td><input type="text" name="PW_MAX_LIFE" value="{$PW_MAX_LIFE}"></td>
+       </tr>
+       <tr>
+               <td>{t}PW_MIN_CLASSES{/t}</td>
+               <td><input type="text" name="PW_MIN_CLASSES" value="{$PW_MIN_CLASSES}"></td>
+       </tr>
+       <tr>
+               <td>{t}PW_MIN_LIFE{/t}</td>
+               <td><input type="text" name="PW_MIN_LIFE" value="{$PW_MIN_LIFE}"></td>
+       </tr>
+</table>
+<input type="hidden" name="Policy_Posted" value="1">
+<p class="seperator">&nbsp;</p>
+
+<div style="text-align:right; padding:4px;">
+       <input type='submit' name="save_policy" value="{msgPool type=okButton}">
+       &nbsp;
+       <input type='submit' name="cancel_policy" value="{msgPool type=cancelButton}">
+</div>