From 054f5b4d01de259688f1c66a6cbb2d7077067a6d Mon Sep 17 00:00:00 2001 From: zeph Date: Tue, 25 Mar 2008 11:18:02 +0000 Subject: [PATCH] sudo-ldap: still not working stuff git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5-plugins@9968 594d385d-05f5-0310-b6e9-bd551577e9d8 --- sudo-ldap/src/class_sudoldap.inc | 37 ++++++++++++++++-- sudo-ldap/src/class_sudoldapEditRole.inc | 48 ++++++++++++++++++++++++ sudo-ldap/src/sudoldapeditrole.tpl | 25 ++++++++++-- 3 files changed, 104 insertions(+), 6 deletions(-) diff --git a/sudo-ldap/src/class_sudoldap.inc b/sudo-ldap/src/class_sudoldap.inc index b4384cf74..4db97485f 100644 --- a/sudo-ldap/src/class_sudoldap.inc +++ b/sudo-ldap/src/class_sudoldap.inc @@ -50,9 +50,40 @@ class sudoldap extends plugin $display= ""; $smarty= get_smarty(); + + /* Edited or Added zone + */ + if((isset($_POST['SaveRoleChanges'])) && is_object($this->dialog)){ + $this->dialog->save_object(); + + /* Check for errors + */ + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msgs){ + print_red($msgs); + } + }else{ + /* add new/edited zone + */ + $ret = $this->dialog->save(); + if(!$this->dialog->isNew){ + unset($this->Roles[$this->dialog->OldRoleName]); + } + $this->Roles[$ret['roleName']] = $ret; + $this->dialog = NULL; + } + } + + /* Cancel zone edit / new + */ + if(isset($_POST['CancelRoleChanges'])){ + $this->dialog = NULL; + } + /* Add empty new zone */ - if(isset($_POST['AddRole']) && chkacl($this->acl,"sudoldap") == ""){ + //if(isset($_POST['AddRole']) && chkacl($this->acl,"sudoldap") == ""){ + if(isset($_POST['AddRole'])){ $this->dialog = new sudoldapEditRole($this->config,$this->dn); } @@ -66,8 +97,8 @@ class sudoldap extends plugin $RoleList = new divSelectBox("sudoRoles"); $RoleList -> SetHeight(300); - $editImg = " - "; + $editImg = " + "; /* foreach($this->Zones as $zone => $values ){ $link = "%s"; diff --git a/sudo-ldap/src/class_sudoldapEditRole.inc b/sudo-ldap/src/class_sudoldapEditRole.inc index 093d30056..c048c17bf 100644 --- a/sudo-ldap/src/class_sudoldapEditRole.inc +++ b/sudo-ldap/src/class_sudoldapEditRole.inc @@ -11,6 +11,14 @@ class sudoldapEditRole extends plugin var $objectclasses = array("sudoRole"); + var $roleName = ""; // cn + + var $sudoUser = ""; + var $sudoHost = ""; + var $sudoCommand = ""; + var $sudoRunAs = ""; + var $sudoOption = ""; + function sudoldapEditRole ($config, $dn= NULL,$attrs = array()) { plugin::plugin ($config, $dn); @@ -27,6 +35,13 @@ class sudoldapEditRole extends plugin $smarty= get_smarty(); $display= ""; + $smarty->assign("roleName", $this->roleName); + $smarty->assign("sudoUser", $this->sudoUser); + $smarty->assign("sudoHost", $this->sudoHost); + $smarty->assign("sudoCommand", $this->sudoCommand); + $smarty->assign("sudoRunAs", $this->sudoRunAs); + $smarty->assign("sudoOption", $this->sudoOption); + /* Display template */ $display.= $smarty->fetch( get_template_path('sudoldapeditrole.tpl', TRUE)); @@ -36,6 +51,12 @@ class sudoldapEditRole extends plugin /* Save data to object */ function save_object() { + //plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } } @@ -48,6 +69,33 @@ class sudoldapEditRole extends plugin /* Save to LDAP */ function save() { + $ldap= $this->config->get_ldap_link(); + + /* $dn was posted as parameter */ + //$this->dn = $dn; + + /* Save */ + plugin::save(); + + echo $this->dn; + + /* Write back to ldap */ + $ldap->cd($this->dn); + //$this->cleanup(); + $ldap->add($this->attrs); + + /* Display errors + */ + if($ldap->get_error() != "Success"){ + show_ldap_error("Record:".$ldap->get_error(), _("Saving failed!")); + } + + //$ret =array(); + //foreach($this->attributes as $name){ + //$ret[$name] = $this->$name; + //} + + //return($ret); } diff --git a/sudo-ldap/src/sudoldapeditrole.tpl b/sudo-ldap/src/sudoldapeditrole.tpl index 1f1b72219..8eea267eb 100644 --- a/sudo-ldap/src/sudoldapeditrole.tpl +++ b/sudo-ldap/src/sudoldapeditrole.tpl @@ -1,9 +1,28 @@

{t}sudo-ldap role{/t}

- + + + + + + + + + + + + + + + + + + + + + +
- {t}form{/t} - {t}Role name (cn){/t}{$must}
{t}sudoUser{/t}{$must}
{t}sudoHost{/t}{$must}
{t}sudoCommand{/t}{$must}
{t}sudoRunAs{/t}{$must}
{t}sudoOption{/t}{$must}
-- 2.30.2