From: zeph Date: Tue, 25 Mar 2008 17:36:28 +0000 (+0000) Subject: sudo-ldap parameters passing X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6f456fe2f84ae749c36ad85bbaeb8cd26fdac740;p=gosa.git sudo-ldap parameters passing git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5-plugins@9980 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/sudo-ldap/src/class_sudoldap.inc b/sudo-ldap/src/class_sudoldap.inc index 10b59b4fc..335416373 100644 --- a/sudo-ldap/src/class_sudoldap.inc +++ b/sudo-ldap/src/class_sudoldap.inc @@ -29,7 +29,7 @@ class sudoldap extends plugin var $objectclasses = array("sudoRole"); - var $roles_list = array(); + var $Roles = array(); /* constructor, if 'dn' is set, the node loads the given 'dn' from LDAP */ @@ -42,7 +42,6 @@ class sudoldap extends plugin plugin::plugin($config, $dn, $parent); $ldap= $this->config->get_ldap_link(); - } @@ -54,6 +53,7 @@ class sudoldap extends plugin $display= ""; $smarty= get_smarty(); + $this->Roles = $this->getRoles(); /* Edited or Added zone */ @@ -73,7 +73,7 @@ class sudoldap extends plugin //if(!$this->dialog->isNew){ // unset($this->Roles[$this->dialog->OldRoleName]); //} - $this->Roles[$ret['roleName']] = $ret; + $this->Roles[$ret['cn']] = $ret; $this->dialog = NULL; } } @@ -91,6 +91,36 @@ class sudoldap extends plugin $this->dialog = new sudoldapEditRole($this->config); } + /* Check for edit role request + */ + $once = false; + foreach( $_POST as $name => $value){ + + /* check all post for edit request + */ + //if(preg_match("/^editRole_/",$name)&&!$once && chkacl($this->acl,"sudoldap") == ""){ + if(preg_match("/^editRole_/",$name)&&!$once){ + $once =true; + $tmp = preg_replace("/^editRole_/","",$name); + $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); + $this->dialog= new sudoldapeditRole($this->config,$this->dn,$this->Roles[$tmp]); + } + + /* check posts for delete zone + */ + //if(preg_match("/^delRole_/",$name)&&!$once && chkacl($this->acl,"sudoldap") == ""){ + if(preg_match("/^delRole_/",$name)&&!$once){ + + $once =true; + $tmp = preg_replace("/^delRole_/","",$name); + $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); + + /* Initiate deletion + */ + $this->RemoveRole($tmp); + } + } + /* Show dialog */ if($this->dialog!= NULL){ @@ -103,8 +133,7 @@ class sudoldap extends plugin $RoleList -> SetHeight(300); $editImg = " "; - $this->roles_list = $this->get_list_of_roles(); - foreach($this->roles_list as $role => $values ){ + foreach($this->Roles as $role => $values ){ $link = "%s"; $RoleList->AddEntry(array( array("string" => sprintf($link,base64_encode($role),$role)), @@ -122,20 +151,19 @@ class sudoldap extends plugin return($display); } - function get_list_of_roles() + function getRoles() { $ret = array(); $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=sudoRole)",array("cn","description")); + $ldap->search("(objectClass=sudoRole)",$this->attributes); while ($attrs= $ldap->fetch()){ - $cn= $attrs['cn'][0]; - if (isset($attrs['description'])){ - $description= " - ".$attrs['description'][0]; - } else { - $description= ""; - } - $ret[$cn]= "$description"; + $cn= $attrs['cn'][0]; + foreach($this->attributes as $value){ + if(isset($attrs[$value])){ + $ret[$cn][$value] = $attrs[$value][0]; + } + } } return($ret); } diff --git a/sudo-ldap/src/class_sudoldapEditRole.inc b/sudo-ldap/src/class_sudoldapEditRole.inc index acbfeefd7..ef9446584 100644 --- a/sudo-ldap/src/class_sudoldapEditRole.inc +++ b/sudo-ldap/src/class_sudoldapEditRole.inc @@ -23,9 +23,24 @@ class sudoldapEditRole extends plugin var $isNew = true; - function sudoldapEditRole ($config, $dn= NULL) + function sudoldapEditRole ($config, $dn= NULL, $attrs = array()) { plugin::plugin ($config, $dn); + + echo '
';
+    print_r($attrs);
+    echo '
'; + + if(!count($attrs)){ + $this->isNew = true; + }else{ + $this->isNew = false; + foreach($this->attributes as $value){ + if(isset($attrs[$value])){ + $this->$value = $attrs[$value]; + } + } + } } function execute() @@ -79,10 +94,6 @@ class sudoldapEditRole extends plugin $this->dn = "cn=".$this->cn.",ou=SUDOers,".$this->config->current['BASE']; $this->attrs['objectClass'] = array("sudoRole"); - echo '
';
-    print_r($this->attrs);
-    echo '
'; - $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); $ldap->cd($this->dn); $ldap->add($this->attrs);