Code

7457444c8e796beb03b2eaed7a447a50903adaaa
[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   var $view_logged  =FALSE;
30    
31  
32   function goFonServer($config,$dn)
33   {
34     goService::goService($config,$dn);
35     $this->DisplayName = _("VoIP service");
36   }
39   function execute()
40   { 
41     if($this->is_account && !$this->view_logged){
42       $this->view_logged = TRUE;
43       @log::log("view","server/".get_class($this),$this->dn);
44     }
46     $smarty = get_smarty(); 
47     foreach($this->attributes as $attr){
48       $smarty->assign($attr,$this->$attr);
49     }
51     /* Assign acls */
52     $tmp = $this->plInfo();
53     foreach($tmp['plProvidedAcls'] as $name => $translation){
54       $smarty->assign($name."ACL",$this->getacl($name));
55     }
57     return($smarty->fetch(get_template_path("goFonServer.tpl",TRUE,dirname(__FILE__))));
58   }
61   function getListEntry()
62   {
63     $fields = goService::getListEntry();
64     $fields['Message']    = _("VoIP service - Asterisk management");
65     $fields['AllowEdit']  = true;
66     return($fields);
67   }
69   function check()
70   { 
71     $message = plugin::check();
72     if (empty($this->goFonAdmin)){
73       $message[]= _("The attribute DB user is empty or contains invalid characters.");
74     }
75     if (empty($this->goFonPassword)){
76       $message[]= _("The attribute password is empty or contains invalid characters.");
77     }
78     if (empty($this->goFonAreaCode)){
79       $message[]= _("The attribute local dial prefix is empty or contains invalid characters.");
80     }
81     if (empty($this->goFonCountryCode)){
82       $message[]= _("The attribute country dial prefix is empty or contains invalid characters.");
83     }
84     return($message);
85   }
86   
88   function save_object()
89   {
90     if(isset($_POST['goFonServerPosted'])){
91       plugin::save_object();
92     }
93   } 
96   function allow_remove()
97   {
98     /* Check if we are able to remove the asterisk database. If the database is still in use skip */
99     if($this->is_account){
100       $ldap = $this->config->get_ldap_link();
101       $ldap->cd($this->config->current['BASE']);
102       $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer"));
103       if($ldap->count()){
105         /* Number of entries shown in warning */
106         $i    = 3;
107         $str  = "";
108         while(($attrs = $ldap->fetch()) && $i >= 0){
109           $i --;
110           if(isset($attrs['uid'][0])){
111             $str .= $attrs['uid'][0]." ";
112           }else{
113             $str .= $attrs['cn'][0]." ";
114           }
115         }
117         /* Some entries found */
118         if($i != 3){
119           return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str)));
120         }
121       }
122     }
123   }
125  
126   /* Return plugin informations for acl handling */
127   function plInfo()
128   {
129     return (array(
130           "plShortName"   => _("VoIP service"),
131           "plDescription" => _("VoIP - asterisk management")." ("._("Services").")",
132           "plSelfModify"  => FALSE,
133           "plDepends"     => array(),
134           "plPriority"    => 92,
135           "plSection"     => array("administration"),
136           "plCategory"    => array("server"),
138           "plProvidedAcls"=> array(
139             "start"         => _("Start"),
140             "stop"          => _("Stop"),
141             "restart"       => _("Restart"),
143               "goFonAdmin"      => _("Admin"), 
144               "goFonPassword"   => _("Password"),
145               "goFonAreaCode"   => _("Area code"), 
146               "goFonCountryCode"=> _("Country code"))
147           ));
148   }
150 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
151 ?>