summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c2c9f0e)
raw | patch | inline | side by side (parent: c2c9f0e)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Apr 2008 08:05:38 +0000 (08:05 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Apr 2008 08:05:38 +0000 (08:05 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10663 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc b/gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc
index 4887b92041a28c25ff048ef7abc0c482061e7069..979da7f5677593b5a8dc2dcb638d88e3e26f593b 100644 (file)
var $view_logged = FALSE;
var $policies = array();
+ var $id = -1;
function goKrbServer(&$config,$dn)
{
Display sub dialogs
*******/
- /* Add new Policy requested
+ /* CANCEL Policy dialog
*/
- 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'])){
+
+ /* SAVE Policy dialog
+ */
+ if($this->dialog instanceof krb5_policy && isset($_POST['save_policy'])){
$this->dialog->save_object();
- echo "NYI";
- $this->dialog = NULL;
+ $msgs = $this->dialog->check();
+ if(count($msgs)){
+ msg_dialog::displayChecks($msgs);
+ }else{
+ $this->AddPolicy($this->id,$this->dialog->save());
+ $this->dialog = NULL;
+ }
}
+
+ /* DISPLAY policy dialog
+ */
if($this->dialog instanceof krb5_policy){
$this->dialog->save_object();
return($this->dialog->execute());
$action = "<input type='image' src='images/lists/edit.png' class='center' name='policy_edit_%id'>";
$action .= "<input type='image' src='images/lists/trash.png' class='center' name='policy_del_%id'>";
foreach($this->policies as $key => $policy){
+ if($policy['STATUS'] == "REMOVED") continue;
+
$actions = preg_replace("/%id/",$key,$action);
$field1 = array("string" => $policy['NAME']);
$field3 = array("string" => $actions,
}
+
+ function AddPolicy($id,$policy)
+ {
+ if($id != -1 && $this->policies[$id]['NAME'] == $policy['NAME']){
+
+ /* Policy was edited
+ */
+ if($this->policies[$id]['STATUS'] == "LOADED"){
+ $policy['STATUS'] = "EDITED";
+ }else{
+ $policy['STATUS'] = $this->policies[$id]['STATUS'];
+ }
+ $this->policies[$this->id] = $policy;
+
+ }elseif($id != -1 && $this->policies[$id]['NAME'] != $policy['NAME']){
+
+ /* Policy was renamed, remove old and add new policy
+ */
+ $this->RemovePolicy($id);
+ $this->AddPolicy(-1,$policy);
+ }else{
+
+ /* Policy was added
+ */
+ $name = $policy['NAME'];
+
+ /* Check if there is already a policy with this name
+ which was removed before
+ */
+ foreach($this->policies as $pid => $entry){
+ if($entry['NAME'] == $name && $entry['STATUS'] == "REMOVED"){
+ $id = $pid;
+ break;
+ }
+ }
+
+ /* Update existing policy or create new one
+ */
+ if(isset($this->policies[$id])){
+ $policy['STATUS'] = "EDITED";
+ $this->policies[$id] = $policy;
+ }else{
+ $policy['STATUS'] = "ADDED";
+ $this->policies[] = $policy;
+ }
+ }
+ }
+
+
+ function getPolicyNames()
+ {
+ $ret = array();
+ foreach($this->policies as $policy){
+ if($policy['STATUS'] == "REMOVED") continue;
+ $ret[] = $policy['NAME'];
+ }
+ return($ret);
+ }
+
+
+ function RemovePolicy($id)
+ {
+ if($this->policies[$id]['STATUS'] == "ADDED"){
+ unset($this->policies[$id]);
+ }else{
+ $this->policies[$id]['STATUS'] = "REMOVED";
+ }
+ }
+
+
function save_object()
{
if(isset($_POST['goKrbServerPosted'])){
plugin::save_object();
+
+ /* Add new Policy requested
+ */
+ if(isset($_POST['policy_add'])){
+ $this->dialog = new krb5_policy($this->config,array(),&$this);
+ $this->id = -1;
+ }
+
+ /* 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->RemovePolicy($id);
+ }
+ 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->id = $id;
+ $this->dialog = new krb5_policy($this->config,$this->policies[$id],&$this);
+ }
+ break;
+ }
+ }
}
}
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
index 06479b7e193cc65a5033737c1202cbf2e9e976c4..18ee90b81db4879f81ba7256039bbb3c10387b83 100644 (file)
var $name = "";
var $data = array();
var $is_new = TRUE;
- var $config;
- var $attributes = array("MASK","POLICY","PW_HISTORY_NUM","PW_MAX_LIFE",
- "PW_MIN_CLASSES","PW_MIN_LENGTH","PW_MIN_LIFE","REF_COUNT");
+ var $init_name ="";
+ var $parent ;
+ 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())
+ public function __construct($config,$entry,$parent)
{
$this->config = $config;
+ $this->parent = $parent;
if(count($entry)){
$this->is_new =FALSE;
$this->name = $entry['NAME'];
$this->data = $entry['DATA'];
}
- $this->init_name = $this->name;
+ $this->init_name = $this->name;
}
public function execute()
$display = plugin::execute();
$smarty = get_smarty();
+ $smarty->assign("name",$this->name);
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->data[$attr]);
}
public function save_object()
{
if(isset($_POST['Policy_Posted'])){
+ if(isset($_POST['name'])){
+ $this->name = get_post("name");
+ }
foreach($this->attributes as $attr){
if(isset($_POST[$attr])){
$this->data[$attr] = get_post($attr);
}
}
}
-
+
+
+ public function check()
+ {
+ $messages = array();
+ $names = $this->parent->getPolicyNames();
+ if($this->name != $this->init_name && in_array($this->name,$names)){
+ $messages[] = msgPool::duplicated(_("Name"));
+ }
+ return($messages);
+ }
+
public function save()
{
$ret = array();
- $ret['INITIAL_NAME']= $this->init_name;
$ret['NAME'] = $this->name;
$ret['DATA'] = $this->data;
return($ret);
diff --git a/gosa-plugins/heimdal/admin/systems/services/kerberos/krb5_policy.tpl b/gosa-plugins/heimdal/admin/systems/services/kerberos/krb5_policy.tpl
index 5284734cdf7ba5115598d37f5cef49a4a56b02ce..a33e643c8c3c9cb1892128966f8e771bceaeddc3 100644 (file)
<table>
<tr>
- <td>{t}Mask{/t}</td>
- <td><input type="text" name="MASK" value="{$MASK}"></td>
- </tr>
- <tr>
- <td>{t}POLICY{/t}</td>
- <td><input type="text" name="POLICY" value="{$POLICY}"></td>
+ <td>{t}Policy name{/t}</td>
+ <td><input type="text" name="name" value="{$name}"></td>
</tr>
<tr>
- <td>{t}REF_COUNT{/t}</td>
- <td><input type="text" name="REF_COUNT" value="{$REF_COUNT}"></td>
+ <td>{t}Mask{/t}</td>
+ <td><input type="text" name="MASK" value="{$MASK}"></td>
</tr>
<tr>
- <td>{t}PW_MIN_LENGTH{/t}</td>
+ <td>{t}Password minimum length{/t}</td>
<td><input type="text" name="PW_MIN_LENGTH" value="{$PW_MIN_LENGTH}"></td>
</tr>
<tr>
- <td>{t}POLICY_REFCNT{/t}</td>
- <td><input type="text" name="POLICY_REFCNT" value="{$POLICY_REFCNT}"></td>
+ <td>{t}Password history{/t}</td>
+ <td><input type="text" name="PW_HISTORY_NUM" value="{$PW_HISTORY_NUM}"></td>
</tr>
<tr>
- <td>{t}PW_HISTORY_NUM{/t}</td>
- <td><input type="text" name="PW_HISTORY_NUM" value="{$PW_HISTORY_NUM}"></td>
+ <td>{t}Password minimum lifetime{/t}</td>
+ <td><input type="text" name="PW_MIN_LIFE" value="{$PW_MIN_LIFE}">{t}seconds{/t}</td>
</tr>
<tr>
- <td>{t}PW_MAX_LIFE{/t}</td>
- <td><input type="text" name="PW_MAX_LIFE" value="{$PW_MAX_LIFE}"></td>
+ <td>{t}Password lifetime{/t}</td>
+ <td><input type="text" name="PW_MAX_LIFE" value="{$PW_MAX_LIFE}">{t}seconds{/t}</td>
</tr>
<tr>
- <td>{t}PW_MIN_CLASSES{/t}</td>
+ <td>{t}Password min characters{/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>
+ <td colspan="2">{t}Number of principals referring to this policy{/t}: {$POLICY_REFCNT}</td>
</tr>
</table>
<input type="hidden" name="Policy_Posted" value="1">