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 if (!$ldap->success()){
98 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
99 }
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 static 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 PrepareForCopyPaste($source)
129 {
130 plugin::PrepareForCopyPaste($source);
132 /* Load arrays */
133 $tmp = array();
134 if (isset($source['goTimeSource'])){
135 for ($i= 0; $i<$source['goTimeSource']['count']; $i++){
136 $tmp[$source['goTimeSource'][$i]]= $source['goTimeSource'][$i];
137 }
138 }
139 $this->goTimeSource= $tmp;
142 }
144 function check(){ return array();}
146 function save_object(){;}
147 }
148 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
149 ?>