Code

Added "Force localboot"
[gosa.git] / plugins / admin / systems / class_goFonServer.inc
1 <?php
3 require_once("class_goService.inc");
5 class goFonServer extends goService{
6         
7   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports asterisk management.";
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("goFonServer");
13   var $attributes       = array("goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode");
14   var $StatusFlag       = "goFonServerStatus";
15  
16   /* This class can't be assigned twice so it conflicts with itsself */
17   var $conflicts        = array("goFonServer");
19   var $DisplayName      = "";
20   var $dn               = NULL;
21   var $cn               ="";
22   var $acl;
24   var $goFonServerStatus  = "";
25   var $goFonPassword      = "";
26   var $goFonAdmin         = "";
27   var $goFonAreaCode      = "";
28   var $goFonCountryCode   = "";
29    
30  
31   function goFonServer($config,$dn)
32   {
33     plugin::plugin($config,$dn);
34     $this->DisplayName = _("VoIP service");
35   }
38   function execute()
39   { 
40     $smarty = get_smarty(); 
41     foreach($this->attributes as $attr){
42       $smarty->assign($attr,$this->$attr);
43     }
45     /* Assign acls */
46     $tmp = $this->plInfo();
47     foreach($tmp['plProvidedAcls'] as $name => $translation){
48       $smarty->assign($name."ACL",$this->getacl($name));
49     }
51     return($smarty->fetch(get_template_path("goFonServer.tpl",TRUE,dirname(__FILE__))));
52   }
55   function getListEntry()
56   {
57     $fields = goService::getListEntry();
58     $fields['Message']    = _("VoIP service - Asterisk management");
59     $fields['AllowEdit']  = true;
60     return($fields);
61   }
63   function check()
64   { 
65     $message = plugin::check();
66     if (empty($this->goFonAdmin)){
67       $message[]= _("The attribute DB user is empty or contains invalid characters.");
68     }
69     if (empty($this->goFonPassword)){
70       $message[]= _("The attribute password is empty or contains invalid characters.");
71     }
72     if (empty($this->goFonAreaCode)){
73       $message[]= _("The attribute local dial prefix is empty or contains invalid characters.");
74     }
75     if (empty($this->goFonCountryCode)){
76       $message[]= _("The attribute country dial prefix is empty or contains invalid characters.");
77     }
78     return($message);
79   }
80   
82   function save_object()
83   {
84     if(isset($_POST['goFonServerPosted'])){
85       plugin::save_object();
86     }
87   } 
90   function allow_remove()
91   {
92     /* Check if we are able to remove the asterisk database. If the database is still in use skip */
93     if($this->is_account){
94       $ldap = $this->config->get_ldap_link();
95       $ldap->cd($this->config->current['BASE']);
96       $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer"));
97       if($ldap->count()){
99         /* Number of entries shown in warning */
100         $i    = 3;
101         $str  = "";
102         while(($attrs = $ldap->fetch()) && $i >= 0){
103           $i --;
104           if(isset($attrs['uid'][0])){
105             $str .= $attrs['uid'][0]." ";
106           }else{
107             $str .= $attrs['cn'][0]." ";
108           }
109         }
111         /* Some entries found */
112         if($i != 3){
113           return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str)));
114         }
115       }
116     }
117   }
119  
120   /* Return plugin informations for acl handling */
121   function plInfo()
122   {
123     return (array(
124           "plShortName"   => _("VoIP service"),
125           "plDescription" => _("VoIP - asterisk management")." ("._("Services").")",
126           "plSelfModify"  => FALSE,
127           "plDepends"     => array(),
128           "plPriority"    => 92,
129           "plSection"     => array("administration"),
130           "plCategory"    => array("server"),
132           "plProvidedAcls"=> array(
133             "start"         => _("Start"),
134             "stop"          => _("Stop"),
135             "restart"       => _("Restart"),
137               "goFonAdmin"      => _("Admin"), 
138               "goFonPassword"   => _("Password"),
139               "goFonAreaCode"   => _("Area code"), 
140               "goFonCountryCode"=> _("Country code"))
141           ));
142   }
144 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
145 ?>