Code

d4e32eeeefbec99c1ac7d192fa06f3cd3ee883dc
[gosa.git] / plugins / admin / systems / class_goKrbServer.inc
1 <?php
3 class goKrbServer extends plugin{
4         
5   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports NTP service.";
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("goKrbServer");
11   var $attributes       = array("goKrbServerStatus","goKrbRealm", "goKrbAdmin","goKrbPassword");
12   var $StatusFlag       = "goKrbServerStatus";
13  
14   /* This class can't be assigned twice so it conflicts with itsself */
15   var $conflicts        = array("goKrbServer");
17   var $DisplayName      = "";
18   var $dn               = NULL;
19   var $goKrbServerStatus= "";
20   var $acl;
22   var $goKrbRealm     = "";
23   var $goKrbAdmin     = "";
24   var $goKrbPassword  ="";  
25  
26   function goKrbServer($config,$dn)
27   {
28     plugin::plugin($config,$dn);
29     $this->DisplayName = _("Kerberos kadmin access informations");
30   }
33   function execute()
34   { 
35     $smarty = get_smarty(); 
36     foreach($this->attributes as $attr){
37       $smarty->assign($attr,$this->$attr);
38       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
39     }
40     return($smarty->fetch(get_template_path("goKrbServer.tpl",TRUE,dirname(__FILE__))));
41   }
44   function getListEntry()
45   {
46     $flag = $this->StatusFlag;
47     $fields['Status']      = $this->$flag;
48     $fields['Message']    = _("Kerberos kadmin access informations");
49     $fields['AllowStart'] = true;
50     $fields['AllowStop']  = true;
51     $fields['AllowReset'] = true;
52     $fields['AllowRemove']= true;
53     $fields['AllowEdit']  = true;
54     return($fields);
55   }
58   function remove_from_parent()
59   {
60     plugin::remove_from_parent();
61     /* Check if this is a new entry ... add/modify */
62     $ldap = $this->config->get_ldap_link();
63     $ldap->cat($this->dn,array("objectClass"));
64     if($ldap->count()){
65       $ldap->cd($this->dn);
66       $ldap->modify($this->attrs);
67     }else{
68       $ldap->cd($this->dn);
69       $ldap->add($this->attrs);
70     }
71     show_ldap_error($ldap->get_error());
72   }
75   function save()
76   {
77     plugin::save();
78     /* Check if this is a new entry ... add/modify */
79     $ldap = $this->config->get_ldap_link();
80     $ldap->cat($this->dn,array("objectClass"));
81     if($ldap->count()){
82       $ldap->cd($this->dn);
83       $ldap->modify($this->attrs);
84     }else{
85       $ldap->cd($this->dn);
86       $ldap->add($this->attrs);
87     }
88     show_ldap_error($ldap->get_error());
89   }
92   /* Directly save new status flag */
93   function setStatus($value)
94   {
95     $ldap = $this->config->get_ldap_link();
96     $ldap->cd($this->dn);
97     $ldap->cat($this->dn,array("objectClass","goKrbRealm","goKrbAdmin","goKrbPassword"));
98       
99     if($ldap->count()){
100       $attrs =array();
101       foreach(array("goKrbRealm","goKrbAdmin","goKrbPassword") as $req) {
102         if(!isset($attrs[$req])){
103           if(empty($this->$req)){
104             print_red(sprintf(_("The required attribute '%s' is not set."),$req));
105           }else{
106             $attrs[$req] = $this->$req;
107           }
108         }else{
109           $attrs[$req] = $attrs[$req][0];
110         }
111       }
113       $tmp = $ldap->fetch();
114       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
115         $attrs['objectClass'][] = $tmp['objectClass'][$i];
116       }    
117       if(!in_array("goKrbServer",$attrs['objectClass'])){
118         $attrs['objectClass'][] = "goKrbServer";
119       }
121       $flag = $this->StatusFlag;
122       $attrs[$flag] = $value;
123       $this->$flag = $value;
124       $ldap->modify($attrs);
125       show_ldap_error($ldap->get_error());
126     }    
127   }
129   
130   function check()
131   { 
132     $message = plugin::check();
133     foreach (array("goKrbAdmin", "goKrbRealm") as $attr){
134         if ($this->$attr == "" || preg_match("/ /", $this->$attr)){
135           $message[]= sprintf(_("The attribute '%s' is empty or contains invalid characters."), $attr);
136         }
137       }
138       /* goKrbPassword is a must field, if goKrbServer is used as objectClass */
139       if ($this->goKrbPassword == "" ){
140         $message[]= sprintf(_("The specified kerberos password is empty."), $attr);
141       }
143     return($message);
144   }
145   
147   function save_object()
148   {
149     if(isset($_POST['goKrbServerPosted'])){
150       plugin::save_object();
151     }
152   }  
154 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
155 ?>