Code

sudo-ldap: still not working stuff
authorzeph <zeph@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 25 Mar 2008 11:18:02 +0000 (11:18 +0000)
committerzeph <zeph@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 25 Mar 2008 11:18:02 +0000 (11:18 +0000)
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
sudo-ldap/src/class_sudoldapEditRole.inc
sudo-ldap/src/sudoldapeditrole.tpl

index b4384cf748ab5a1d27564fdaf4b66a41a868ae11..4db97485f6285aa6046fa3cdca99302e1384405d 100644 (file)
@@ -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 = "<input type='image' src='images/edit.png' name='editZone_%s'>
-       <input type='image' src='images/edittrash.png' name='delZone_%s'>";
+       $editImg = "<input type='image' src='images/edit.png' name='editRole_%s'>
+       <input type='image' src='images/edittrash.png' name='delRole_%s'>";
        /*
        foreach($this->Zones as $zone => $values ){
                $link = "<a href='?plug=".$_GET['plug']."&act=edit&id=%s'>%s</a>";
index 093d30056f7a0b06dc1ca4e999ec8427c187b05d..c048c17bf8e0c4d8b332ec82ae442cd4448d8225 100644 (file)
@@ -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);
   }
 
   
index 1f1b72219c866b06d26a6af3953b6dbec8a48dcc..8eea267eb30a17418c53601de4551d9f93469638 100644 (file)
@@ -1,9 +1,28 @@
 <h2>{t}sudo-ldap role{/t}</h2>
 <table summary="" width="100%">
        <tr>
-               <td>
-                       {t}form{/t}
-               </td>
+               <td> {t}Role name (cn){/t}{$must} </td>
+               <td> <input type="text" name="roleName" value="{$roleName}"> </td>
+       </tr>
+       <tr>
+               <td> {t}sudoUser{/t}{$must} </td>
+               <td> <input type="text" name="sudoUser" value="{$sudoUser}"> </td>
+       </tr>
+       <tr>
+               <td> {t}sudoHost{/t}{$must} </td>
+               <td> <input type="text" name="sudoHost" value="{$sudoHost}"> </td>
+       </tr>
+       <tr>
+               <td> {t}sudoCommand{/t}{$must} </td>
+               <td> <input type="text" name="sudoCommand" value="{$sudoCommand}"> </td>
+       </tr>
+       <tr>
+               <td> {t}sudoRunAs{/t}{$must} </td>
+               <td> <input type="text" name="sudoRunAs" value="{$sudoRunAs}"> </td>
+       </tr>
+       <tr>
+               <td> {t}sudoOption{/t}{$must} </td>
+               <td> <input type="text" name="sudoOption" value="{$sudoOption}"> </td>
        </tr>
 </table>
 <div style="text-align:right;" align="right">