Code

sudo-ldap, now it saves, but with some tricks
[gosa.git] / sudo-ldap / src / class_sudoldapEditRole.inc
1 <?php
3 class sudoldapEditRole extends plugin
4 {
5   /* Plugin specific values */
6   var $attributes       = array("cn",
7                                 "description",
8                                 "sudoUser", 
9                                 "sudoHost", 
10                                 "sudoCommand", 
11                                 "sudoRunAs", 
12                                 "sudoOption");
13   
14   var $objectclasses    = array("sudoRole");
16   var $cn               = "";
17   var $description      = "";
18   var $sudoUser         = "";
19   var $sudoHost         = "";
20   var $sudoCommand      = "";
21   var $sudoRunAs        = "";
22   var $sudoOption       = "";
24   var $isNew            = true; 
26   function sudoldapEditRole ($config, $dn= NULL)
27   {
28     plugin::plugin ($config, $dn);
29   }
31   function execute()
32   {
33     /* Call parent execute */
34     plugin::execute();
37     /* Fill templating stuff */
38     $smarty= get_smarty();
39     $display= "";
41     $smarty->assign("cn",               $this->cn);
42     $smarty->assign("description",      $this->description);
43     $smarty->assign("sudoUser",         $this->sudoUser);
44     $smarty->assign("sudoHost",         $this->sudoHost);
45     $smarty->assign("sudoCommand",      $this->sudoCommand);
46     $smarty->assign("sudoRunAs",        $this->sudoRunAs);
47     $smarty->assign("sudoOption",       $this->sudoOption);
49     /* Display template */
50     $display.= $smarty->fetch(
51         get_template_path('sudoldapeditrole.tpl', TRUE));
52     return($display);
53   }
55   /* Save data to object */
56   function save_object()
57   {
58      //plugin::save_object();
59      foreach($this->attributes as $attr){
60         if(isset($_POST[$attr])){
61                 $this->$attr = $_POST[$attr];
62         }
63      }
64   }
67   /* Check supplied data */
68   function check()
69   {
70   }
73   /* Save to LDAP */
74   function save()
75   {
76     plugin::save();
77     $ldap= $this->config->get_ldap_link();
79     $this->dn = "cn=".$this->cn.",ou=SUDOers,".$this->config->current['BASE'];
80     $this->attrs['objectClass'] = array("sudoRole");
82     echo '<pre>';
83     print_r($this->attrs);
84     echo '</pre>';
86     $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
87     $ldap->cd($this->dn);
88     $ldap->add($this->attrs); 
90     /* Display errors 
91      */
92     if($ldap->get_error() != "Success"){
93         show_ldap_error("Record:".$ldap->get_error(), _("Saving failed!")); 
94     }
96   }
98   
99 }
101 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
102 ?>