Code

Password is must too
[gosa.git] / plugins / admin / systems / class_goFonServer.inc
1 <?php
3 class goFonServer extends plugin{
4         
5   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports asterisk management.";
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("goFonServer");
11   var $attributes       = array("goFonServerStatus","goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode");
12   var $StatusFlag       = "goFonServerStatus";
13  
14   /* This class can't be assigned twice so it conflicts with itsself */
15   var $conflicts        = array("goFonServer");
17   var $DisplayName      = "";
18   var $dn               = NULL;
19   var $acl;
21   var $goFonServerStatus  = "";
22   var $goFonPassword      = "";
23   var $goFonAdmin         = "";
24   var $goFonAreaCode      = "";
25   var $goFonCountryCode   = "";
26    
27  
28   function goFonServer($config,$dn)
29   {
30     plugin::plugin($config,$dn);
31     $this->DisplayName = _("VoIP service");
32   }
35   function execute()
36   { 
37     $smarty = get_smarty(); 
38     foreach($this->attributes as $attr){
39       $smarty->assign($attr,$this->$attr);
40       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
41     }
42     return($smarty->fetch(get_template_path("goFonServer.tpl",TRUE,dirname(__FILE__))));
43   }
46   function getListEntry()
47   {
48     $flag = $this->StatusFlag;
49     $fields['Status']     = $this->$flag;
50     $fields['Message']    = _("Asterisk management");
51     $fields['AllowStart'] = true;
52     $fields['AllowStop']  = true;
53     $fields['AllowRestart'] = true;
54     $fields['AllowRemove']= true;
55     $fields['AllowEdit']  = true;
56     return($fields);
57   }
60   function remove_from_parent()
61   {
62     plugin::remove_from_parent();
63     /* Check if this is a new entry ... add/modify */
64     $ldap = $this->config->get_ldap_link();
65     $ldap->cat($this->dn,array("objectClass"));
66     if($ldap->count()){
67       $ldap->cd($this->dn);
68       $ldap->modify($this->attrs);
69     }else{
70       $ldap->cd($this->dn);
71       $ldap->add($this->attrs);
72     }
73     show_ldap_error($ldap->get_error());
74   }
77   function save()
78   {
79     plugin::save();
80     /* Check if this is a new entry ... add/modify */
81     $ldap = $this->config->get_ldap_link();
82     $ldap->cat($this->dn,array("objectClass"));
83     if($ldap->count()){
84       $ldap->cd($this->dn);
85       $ldap->modify($this->attrs);
86     }else{
87       $ldap->cd($this->dn);
88       $ldap->add($this->attrs);
89     }
90     show_ldap_error($ldap->get_error());
91   }
94   /* Directly save new status flag */
95   function setStatus($value)
96   {
97     if($value == "none") return;
98     if(!$this->initially_was_account) return;
99     $ldap = $this->config->get_ldap_link();
100     $ldap->cd($this->dn);
101     $ldap->cat($this->dn,array("objectClass"));
102     if($ldap->count()){
104       $tmp = $ldap->fetch();
105       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
106         $attrs['objectClass'][] = $tmp['objectClass'][$i];
107       }
108       $flag = $this->StatusFlag;
109       $attrs[$flag] = $value;
110       $this->$flag = $value;
111       $ldap->modify($attrs);
112       show_ldap_error($ldap->get_error());
113     }
114   }
117   function check()
118   { 
119     $message = plugin::check();
120     if (empty($this->goFonAdmin)){
121       $message[]= sprintf(_("The attribute DB user is empty or contains invalid characters."), $attr);
122     }
123     if (empty($this->goFonPassword)){
124       $message[]= sprintf(_("The attribute password is empty or contains invalid characters."), $attr);
125     }
126     if (empty($this->goFonAreaCode)){
127       $message[]= sprintf(_("The attribute local dial prefix is empty or contains invalid characters."), $attr);
128     }
129     if (empty($this->goFonCountryCode)){
130       $message[]= sprintf(_("The attribute country dial prefix is empty or contains invalid characters."), $attr);
131     }
132     return($message);
133   }
134   
136   function save_object()
137   {
138     if(isset($_POST['goFonServerPosted'])){
139       plugin::save_object();
140     }
141   }  
143 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
144 ?>