8629e73f303e8c22ee0fa1fefb82e5c6ac1cfd77
1 <?php
2 /*!
3 \brief sudo-ldap plugin
4 \author Guido Serra <gserra@guidoserra.it>
5 \version 1.00
6 \date 22.03.2008
8 This class provides the functionality to read and write all attributes
9 relevant for sudo-ldap from/to the LDAP.
10 */
12 class sudoldap extends plugin
13 {
14 /* Definitions */
15 var $plHeadline= "sudo-ldap";
16 var $plDescription= "This does something";
18 /* Plugin specific values */
20 var $dialog = NULL;
22 var $attributes = array("cn",
23 "description",
24 "sudoUser",
25 "sudoHost",
26 "sudoCommand",
27 "sudoRunAs",
28 "sudoOption");
30 var $objectclasses = array("sudoRole");
32 /* constructor, if 'dn' is set, the node loads the given
33 'dn' from LDAP */
34 function sudoldap ($config, $dn= NULL, $parent= NULL)
35 {
36 /* Configuration is fine, allways */
37 $this->config= $config;
39 /* Load bases attributes */
40 plugin::plugin($config, $dn, $parent);
42 $ldap= $this->config->get_ldap_link();
44 }
47 /* execute generates the html output for this node */
48 function execute($isCopyPaste = false)
49 {
50 /* Call parent execute */
51 plugin::execute();
52 $display= "";
53 $smarty= get_smarty();
56 /* Edited or Added zone
57 */
58 if((isset($_POST['SaveRoleChanges'])) && is_object($this->dialog)){
59 $this->dialog->save_object();
61 /* Check for errors
62 */
63 if(count($this->dialog->check())){
64 foreach($this->dialog->check() as $msgs){
65 print_red($msgs);
66 }
67 }else{
68 /* add new/edited zone
69 */
70 $ret = $this->dialog->save();
71 //if(!$this->dialog->isNew){
72 // unset($this->Roles[$this->dialog->OldRoleName]);
73 //}
74 $this->Roles[$ret['roleName']] = $ret;
75 $this->dialog = NULL;
76 }
77 }
79 /* Cancel zone edit / new
80 */
81 if(isset($_POST['CancelRoleChanges'])){
82 $this->dialog = NULL;
83 }
85 /* Add empty new zone
86 */
87 //if(isset($_POST['AddRole']) && chkacl($this->acl,"sudoldap") == ""){
88 if(isset($_POST['AddRole'])){
89 $this->dialog = new sudoldapEditRole($this->config);
90 }
92 /* Show dialog
93 */
94 if($this->dialog!= NULL){
95 $this->dialog->save_object();
96 $this->dialog->parent = $this;
97 return($this->dialog->execute());
98 }
100 $RoleList = new divSelectBox("sudoRoles");
101 $RoleList -> SetHeight(300);
102 $editImg = "<input type='image' src='images/edit.png' name='editRole_%s'>
103 <input type='image' src='images/edittrash.png' name='delRole_%s'>";
104 /*
105 foreach($this->Zones as $zone => $values ){
106 $link = "<a href='?plug=".$_GET['plug']."&act=edit&id=%s'>%s</a>";
107 $ZoneList->AddEntry(array(
108 array("string" => sprintf($link,base64_encode($zone),getNameFromMix($zone))),
109 array("string" => sprintf($link,base64_encode($zone),_("Reverse zone")." : ".getNameFromMix($values['ReverseZone']))),
110 array("string" => _("TTL")." : ".$values['sOAttl']),
111 array("string" => _("Class")." : ".$values['dNSClass']),
112 array("string" => str_replace("%s",base64_encode($zone),$editImg))
113 ));
114 }
115 */
117 $smarty->assign("sudoldapACL",chkacl($this->acl,"sudoldap"));
119 $smarty->assign("RoleList",$RoleList->DrawList());
120 $display.= $smarty->fetch(get_template_path('sudoldap.tpl', TRUE));
121 return($display);
122 }
124 }
126 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
127 ?>