1 <?php
3 class goNtpServer extends goService{
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");
12 var $StatusFlag = "goNtpServerStatus";
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 var $cn = "";
23 var $view_logged =FALSE;
25 function goNtpServer(&$config,$dn)
26 {
27 goService::goService($config,$dn);
28 $this->DisplayName = _("Time service (NTP)");
30 /* Load arrays */
31 $tmp = array();
32 if (isset($this->attrs['goTimeSource'])){
33 for ($i= 0; $i<$this->attrs['goTimeSource']['count']; $i++){
34 $tmp[$this->attrs['goTimeSource'][$i]]= $this->attrs['goTimeSource'][$i];
35 }
36 }
37 $this->goTimeSource= $tmp;
38 }
41 function execute()
42 {
43 $smarty = get_smarty();
45 if($this->is_account && !$this->view_logged){
46 $this->view_logged = TRUE;
47 new log("view","server/".get_class($this),$this->dn);
48 }
50 /* Here we add a new entry */
51 if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "" && $this->acl_is_writeable("goTimeSource")) {
52 $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport'];
53 asort($this->goTimeSource);
54 }
56 /* Deleting an Entry, is a bit more complicated than adding one*/
57 if((isset($_POST['DelNTPEnt'])) && (isset($_POST['goTimeSource'])) && $this->acl_is_writeable("goTimeSource")) {
58 foreach ($_POST['goTimeSource'] as $entry){
59 if (isset($this->goTimeSource[$entry])){
60 unset($this->goTimeSource[$entry]);
61 }
62 }
63 }
65 $smarty->assign("goNtpServerACL", $this->getacl("goNtpServer")) ;
66 $smarty->assign("goTimeSource" , $this->goTimeSource);
67 return($smarty->fetch(get_template_path("goNtpServer.tpl",TRUE,dirname(__FILE__))));
68 }
71 function getListEntry()
72 {
73 $fields = goService::getListEntry();
74 $fields['Message'] = _("Time service (NTP)");
75 $fields['AllowEdit'] = true;
76 return($fields);
77 }
80 function save()
81 {
82 plugin::save();
83 $this->attrs['goTimeSource'] =array();
84 foreach($this->goTimeSource as $entry){
85 $this->attrs['goTimeSource'][] = $entry;
86 }
87 /* Check if this is a new entry ... add/modify */
88 $ldap = $this->config->get_ldap_link();
89 $ldap->cat($this->dn,array("objectClass"));
90 if($ldap->count()){
91 $ldap->cd($this->dn);
92 $ldap->modify($this->attrs);
93 }else{
94 $ldap->cd($this->dn);
95 $ldap->add($this->attrs);
96 }
97 show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/goNtpServer with dn '%s' failed."),$this->dn));
98 if($this->initially_was_account){
99 $this->handle_post_events("modify");
100 new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
101 }else{
102 $this->handle_post_events("add");
103 new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
104 }
105 }
108 /* Return plugin informations for acl handling */
109 static function plInfo()
110 {
111 return (array(
112 "plShortName" => _("Time service"),
113 "plDescription" => _("Time service - NTP")." ("._("Services").")",
114 "plSelfModify" => FALSE,
115 "plDepends" => array(),
116 "plPriority" => 91,
117 "plSection" => array("administration"),
118 "plCategory" => array("server"),
120 "plProvidedAcls"=> array(
121 "goTimeSource" =>_("Ntp source"))
122 ));
123 }
126 function PrepareForCopyPaste($source)
127 {
128 plugin::PrepareForCopyPaste($source);
130 /* Load arrays */
131 $tmp = array();
132 if (isset($source['goTimeSource'])){
133 for ($i= 0; $i<$source['goTimeSource']['count']; $i++){
134 $tmp[$source['goTimeSource'][$i]]= $source['goTimeSource'][$i];
135 }
136 }
137 $this->goTimeSource= $tmp;
140 }
142 function check(){ return array();}
144 function save_object(){;}
145 }
146 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
147 ?>