1 <?php
3 class goLdapServer extends plugin{
5 var $cli_summary = "This plugin is used within the ServerService Pluign \nand indicates that this server has goLdapServer defined.";
6 var $cli_description = "Some longer text\nfor help";
7 var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9 /* This plugin only writes its objectClass */
10 var $objectclasses = array("goLdapServer");
11 var $attributes = array("goLdapServerStatus","goLdapBase");
12 var $StatusFlag = "goLdapServerStatus";
14 /* This class can't be assigned twice so it conflicts with itsself */
15 var $conflicts = array("goLdapServer");
17 var $DisplayName = "";
18 var $dn = NULL;
19 var $acl;
21 var $goLdapServerStatus = "";
22 var $goLdapBase = "";
24 function goLdapServer($config,$dn)
25 {
26 plugin::plugin($config,$dn);
27 $this->DisplayName = _("LDAP service");
28 }
31 function execute()
32 {
33 $smarty = get_smarty();
34 foreach($this->attributes as $attr){
35 $smarty->assign($attr,$this->$attr);
36 $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
37 }
38 return($smarty->fetch(get_template_path("goLdapServer.tpl",TRUE,dirname(__FILE__))));
39 }
42 function getListEntry()
43 {
44 $flag = $this->StatusFlag;
45 $fields['Status'] = $this->$flag;
46 $fields['Message'] = _("LDAP Service");
47 $fields['AllowStart'] = true;
48 $fields['AllowStop'] = true;
49 $fields['AllowRestart'] = true;
50 $fields['AllowRemove']= true;
51 $fields['AllowEdit'] = true;
52 return($fields);
53 }
56 function remove_from_parent()
57 {
58 plugin::remove_from_parent();
59 /* Check if this is a new entry ... add/modify */
60 $ldap = $this->config->get_ldap_link();
61 $ldap->cat($this->dn,array("objectClass"));
62 if($ldap->count()){
63 $ldap->cd($this->dn);
64 $ldap->modify($this->attrs);
65 }else{
66 $ldap->cd($this->dn);
67 $ldap->add($this->attrs);
68 }
69 show_ldap_error($ldap->get_error());
70 }
73 function save()
74 {
75 plugin::save();
76 /* Check if this is a new entry ... add/modify */
77 $ldap = $this->config->get_ldap_link();
78 $ldap->cat($this->dn,array("objectClass"));
79 if($ldap->count()){
80 $ldap->cd($this->dn);
81 $ldap->modify($this->attrs);
82 }else{
83 $ldap->cd($this->dn);
84 $ldap->add($this->attrs);
85 }
86 show_ldap_error($ldap->get_error());
87 }
90 /* Directly save new status flag */
91 function setStatus($value)
92 {
93 if($value == "none") return;
94 if(!$this->initially_was_account) return;
95 $ldap = $this->config->get_ldap_link();
96 $ldap->cd($this->dn);
97 $ldap->cat($this->dn,array("objectClass"));
98 if($ldap->count()){
100 $tmp = $ldap->fetch();
101 for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
102 $attrs['objectClass'][] = $tmp['objectClass'][$i];
103 }
104 $flag = $this->StatusFlag;
105 $attrs[$flag] = $value;
106 $this->$flag = $value;
107 $ldap->modify($attrs);
108 show_ldap_error($ldap->get_error());
109 }
110 }
113 function check()
114 {
115 $message = plugin::check();
116 return($message);
117 }
120 function save_object()
121 {
122 if(isset($_POST['goLdapServerPosted'])){
123 plugin::save_object();
124 }
125 }
126 }
127 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
128 ?>