Code

Udpated logging
[gosa.git] / plugins / admin / systems / class_goNtpServer.inc
1 <?php
3 require_once("class_goService.inc");
5 class goNtpServer extends goService{
7   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports NTP service.";
8   var $cli_description  = "Some longer text\nfor help";
9   var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
11   /* This plugin only writes its objectClass */
12   var $objectclasses    = array("goNtpServer");
13   var $attributes       = array("goTimeSource");
14   var $StatusFlag       = "goNtpServerStatus";
16   /* This class can't be assigned twice so it conflicts with itsself */
17   var $conflicts        = array("goNtpServer");
19   var $DisplayName      = "";
20   var $dn               = NULL;
21   var $goTimeSource     = array();
22   var $goNtpServerStatus= "";
23   var $acl;
24   var $cn               = "";
25   var $view_logged  =FALSE;
27   function goNtpServer($config,$dn)
28   {
29     goService::goService($config,$dn);
30     $this->DisplayName = _("Time service (NTP)");
32     /* Load arrays */
33     $tmp = array();
34     if (isset($this->attrs['goTimeSource'])){
35       for ($i= 0; $i<$this->attrs['goTimeSource']['count']; $i++){
36         $tmp[$this->attrs['goTimeSource'][$i]]= $this->attrs['goTimeSource'][$i];
37       }
38     }
39     $this->goTimeSource= $tmp;
40   }
43   function execute()
44   { 
45     $smarty = get_smarty(); 
47     if($this->is_account && !$this->view_logged){
48       $this->view_logged = TRUE;
49       new log("view","server/".get_class($this),$this->dn);
50     }
52     /* Here we add a new entry  */
53     if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "" && $this->acl_is_writeable("goTimeSource")) {
54       $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport'];
55       asort($this->goTimeSource);
56     }
58     /* Deleting an Entry, is a bit more complicated than adding one*/
59     if((isset($_POST['DelNTPEnt'])) && (isset($_POST['goTimeSource'])) && $this->acl_is_writeable("goTimeSource")) {
60       foreach ($_POST['goTimeSource'] as $entry){
61         if (isset($this->goTimeSource[$entry])){
62           unset($this->goTimeSource[$entry]);
63         }
64       }
65     }
67     $smarty->assign("goNtpServerACL", $this->getacl("goNtpServer")) ;
68     $smarty->assign("goTimeSource" , $this->goTimeSource); 
69     return($smarty->fetch(get_template_path("goNtpServer.tpl",TRUE,dirname(__FILE__))));
70   }
73   function getListEntry()
74   {
75     $fields               = goService::getListEntry();
76     $fields['Message']    = _("Time service (NTP)");
77     $fields['AllowEdit']  = true;
78     return($fields);
79   }
82   function save()
83   {
84     plugin::save();
85     $this->attrs['goTimeSource'] =array();
86     foreach($this->goTimeSource as $entry){
87       $this->attrs['goTimeSource'][] = $entry;
88     }
89     /* Check if this is a new entry ... add/modify */
90     $ldap = $this->config->get_ldap_link();
91     $ldap->cat($this->dn,array("objectClass"));
92     if($ldap->count()){
93       $ldap->cd($this->dn);
94       $ldap->modify($this->attrs);
95     }else{
96       $ldap->cd($this->dn);
97       $ldap->add($this->attrs);
98     }
99     show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/goNtpServer with dn '%s' failed."),$this->dn));
100     if($this->initially_was_account){
101       $this->handle_post_events("modify");
102       new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
103     }else{
104       $this->handle_post_events("add");
105       new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
106     }
107   }
110   /* Return plugin informations for acl handling */
111   function plInfo()
112   {
113     return (array(
114           "plShortName"   => _("Time service"),
115           "plDescription" => _("Time service - NTP")." ("._("Services").")",
116           "plSelfModify"  => FALSE,
117           "plDepends"     => array(),
118           "plPriority"    => 91,
119           "plSection"     => array("administration"),
120           "plCategory"    => array("server"),
122           "plProvidedAcls"=> array(
123             "goTimeSource"        =>_("Ntp source"))
124           ));
125   }
128   function check(){ return array();}
130   function save_object(){;}
132 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
133 ?>