c048c17bf8e0c4d8b332ec82ae442cd4448d8225
1 <?php
3 class sudoldapEditRole extends plugin
4 {
5 /* Plugin specific values */
6 var $attributes = array("sudoUser",
7 "sudoHost",
8 "sudoCommand",
9 "sudoRunAs",
10 "sudoOption");
12 var $objectclasses = array("sudoRole");
14 var $roleName = ""; // cn
16 var $sudoUser = "";
17 var $sudoHost = "";
18 var $sudoCommand = "";
19 var $sudoRunAs = "";
20 var $sudoOption = "";
22 function sudoldapEditRole ($config, $dn= NULL,$attrs = array())
23 {
24 plugin::plugin ($config, $dn);
26 }
28 function execute()
29 {
30 /* Call parent execute */
31 plugin::execute();
34 /* Fill templating stuff */
35 $smarty= get_smarty();
36 $display= "";
38 $smarty->assign("roleName", $this->roleName);
39 $smarty->assign("sudoUser", $this->sudoUser);
40 $smarty->assign("sudoHost", $this->sudoHost);
41 $smarty->assign("sudoCommand", $this->sudoCommand);
42 $smarty->assign("sudoRunAs", $this->sudoRunAs);
43 $smarty->assign("sudoOption", $this->sudoOption);
45 /* Display template */
46 $display.= $smarty->fetch(
47 get_template_path('sudoldapeditrole.tpl', TRUE));
48 return($display);
49 }
51 /* Save data to object */
52 function save_object()
53 {
54 //plugin::save_object();
55 foreach($this->attributes as $attr){
56 if(isset($_POST[$attr])){
57 $this->$attr = $_POST[$attr];
58 }
59 }
60 }
63 /* Check supplied data */
64 function check()
65 {
66 }
69 /* Save to LDAP */
70 function save()
71 {
72 $ldap= $this->config->get_ldap_link();
74 /* $dn was posted as parameter */
75 //$this->dn = $dn;
77 /* Save */
78 plugin::save();
80 echo $this->dn;
82 /* Write back to ldap */
83 $ldap->cd($this->dn);
84 //$this->cleanup();
85 $ldap->add($this->attrs);
87 /* Display errors
88 */
89 if($ldap->get_error() != "Success"){
90 show_ldap_error("Record:".$ldap->get_error(), _("Saving failed!"));
91 }
93 //$ret =array();
94 //foreach($this->attributes as $name){
95 //$ret[$name] = $this->$name;
96 //}
98 //return($ret);
99 }
102 }
104 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
105 ?>