Code

bea2dc1af1070aa826e775cf49a8887a5cd801c9
[gosa.git] / plugins / admin / systems / class_goNtpServer.inc
1 <?php
3 class goNtpServer 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("goNtpServer");
11   var $attributes       = array("goTimeSource","goNtpServerStatus");
12   var $StatusFlag       = "goNtpServerStatus";
13  
14   /* This class can't be assigned twice so it conflicts with itsself */
15   var $conflicts        = array("goNtpServer");
17   var $DisplayName      = "";
18   var $dn               = NULL;
19   var $goTimeSource     = array();
20   var $goNtpServerStatus= "";
21   var $acl;
22   
23  
24   function goNtpServer($config,$dn)
25   {
26     plugin::plugin($config,$dn);
27     $this->DisplayName = _("NTP Service");
28     
29     /* Load arrays */
30     $tmp = array();
31     if (isset($this->attrs['goTimeSource'])){
32       for ($i= 0; $i<$this->attrs['goTimeSource']['count']; $i++){
33         $tmp[$this->attrs['goTimeSource'][$i]]= $this->attrs['goTimeSource'][$i];
34       }
35     }
36     $this->goTimeSource= $tmp;
37   }
40   function execute()
41   { 
42     $smarty = get_smarty(); 
44      /* Here we add a new entry  */
45     if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "") {
46       $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport'];
47       asort($this->goTimeSource);
48     }
50     /* Deleting an Entry, is a bit more complicated than adding one*/
51     if(isset($_POST['DelNTPEnt'])) {
52       foreach ($_POST['goTimeSource'] as $entry){
53         if (isset($this->goTimeSource[$entry])){
54           unset($this->goTimeSource[$entry]);
55         }
56       }
57     }
59     $smarty->assign("goNtpServerACL",chkacl($this->acl,"goNtpServer")) ;
60     $smarty->assign("goTimeSource" , $this->goTimeSource); 
61     return($smarty->fetch(get_template_path("goNtpServer.tpl",TRUE,dirname(__FILE__))));
62   }
65   function getListEntry()
66   {
67     $flag = $this->StatusFlag;
68     $fields['Status']      = $this->$flag;
69     $fields['Message']    = _("NTP service");
70     $fields['AllowStart'] = true;
71     $fields['AllowStop']  = true;
72     $fields['AllowReset'] = true;
73     $fields['AllowRemove']= true;
74     $fields['AllowEdit']  = true;
75     return($fields);
76   }
79   function remove_from_parent()
80   {
81     plugin::remove_from_parent();
82     /* Check if this is a new entry ... add/modify */
83     $ldap = $this->config->get_ldap_link();
84     $ldap->cat($this->dn,array("objectClass"));
85     if($ldap->count()){
86       $ldap->cd($this->dn);
87       $ldap->modify($this->attrs);
88     }else{
89       $ldap->cd($this->dn);
90       $ldap->add($this->attrs);
91     }
92     show_ldap_error($ldap->get_error());
93   }
96   function save()
97   {
98     plugin::save();
99     $this->attrs['goTimeSource'] =array();
100     foreach($this->goTimeSource as $entry){
101       $this->attrs['goTimeSource'][] = $entry;
102     }
103     /* Check if this is a new entry ... add/modify */
104     $ldap = $this->config->get_ldap_link();
105     $ldap->cat($this->dn,array("objectClass"));
106     if($ldap->count()){
107       $ldap->cd($this->dn);
108       $ldap->modify($this->attrs);
109     }else{
110       $ldap->cd($this->dn);
111       $ldap->add($this->attrs);
112     }
113     show_ldap_error($ldap->get_error());
114   }
117   /* Directly save new status flag */
118   function setStatus($value)
119   {
120     $ldap = $this->config->get_ldap_link();
121     $ldap->cd($this->dn);
122     $ldap->cat($this->dn,array("objectClass"));
123       
124     if($ldap->count()){
125       $attrs =array();
126       $tmp = $ldap->fetch();
127       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
128         $attrs['objectClass'][] = $tmp['objectClass'][$i];
129       }    
130       if(!in_array("goNtpServer",$attrs['objectClass'])){
131         $attrs['objectClass'][] = "goNtpServer";
132       }
134       $flag = $this->StatusFlag;
135       $attrs[$flag] = $value;
136       $this->$flag = $value;
137       $ldap->modify($attrs);
138       show_ldap_error($ldap->get_error());
139     }    
140   }
141   
142   function check(){ return array();}
143   
144 function save_object(){;}
146 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
147 ?>