Code

Switched log call
[gosa.git] / plugins / admin / systems / class_goImapServer.inc
1 <?php
3 require_once ("class_goService.inc");
5 class goImapServer extends goService {
6         
7   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports mailqueue listings and so on.";
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("goImapServer");
13   
14   /* This class can't be assigned twice so it conflicts with itsself */
16   var $DisplayName      = "";
17   var $dn               = NULL;
18   var $StatusFlag       = "goImapServerStatus";
19   var $attributes       = array("goImapName","goImapConnect","goImapAdmin","goImapPassword",
20                                 "goImapSieveServer","goImapSievePort",
21                                 "cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL");
23   var $cn                   = "";
25   var $goImapName           = "";
26   var $goImapConnect        = "";
27   var $goImapAdmin          = "";
28   var $goImapPassword       = "";
29   
30   var $goImapSieveServer    = "";
31   var $goImapSievePort      = "";
32   
33   var $goImapServerStatus   = "";
34   
35   var $cyrusImap            = false;
36   var $cyrusImapSSL         = false;
37   var $cyrusPop3            = false;
38   var $cyrusPop3SSL         = false;
39   var $is_account           = false;
40   var $view_logged  =FALSE;
42   var $acl; 
44   var $Actions              = array();  
45   var $conflicts            = array("goImapServer","kolab");
46  
47   function goImapServer($config,$dn)
48   {
49     goService::goService($config,$dn);
50   
51     $this->DisplayName = _("IMAP/POP3 service");
53     $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
54                             SERVICE_STARTED => SERVICE_STARTED,
55                             SERVICE_RESTARTED=>SERVICE_RESTARTED,
56                             "repair_database"=>_("Repair database"));
57     
58   }
60   function execute()
61   { 
62     $smarty = get_smarty();
63  
64     if($this->is_account && !$this->view_logged){
65       $this->view_logged = TRUE;
66       new log("view","server/".get_class($this),$this->dn);
67     }
68  
69     /* set new status */
70     if(isset($_POST['ExecAction'])){
71       if(isset($this->Actions[$_POST['action']])){
73         $tmp = $this->plInfo();
74         foreach($tmp['plProvidedAcls'] as $name => $translation) {
75           if(preg_match("/^".$_POST['action']."$/i",$name)){
76             if($this->acl_is_writeable($name)){
77               $this->setStatus($_POST['action']);
78             }
79           }
80         }
82       }
83     }
85     foreach($this->attributes as $attr){
86       $smarty->assign($attr,$this->$attr);  
87     }
89     $tmp = $this->plInfo();
90     foreach($tmp['plProvidedAcls'] as $name => $translation){
91       $smarty->assign($name."ACL",$this->getacl($name));
92     }
93     $smarty->assign("Actions",$this->Actions);
94     $smarty->assign("is_new",$this->dn);
95     $smarty->assign("is_acc",$this->initially_was_account);
96     return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__))));
97   }
99   function getListEntry()
100   {
101     $fields               = goService::getListEntry();
102     $fields['Message']    = _("IMAP/POP3 (Cyrus) service");
103     $fields['AllowRemove']= true;
104     $fields['AllowEdit']  = true;
105     return($fields);
106   }
108   function check()
109   { 
110     $message = plugin::check();
111     if(empty($this->goImapName)){
112       $message[] =_("Please specify a server identifier.");
113     }  
114     if(empty($this->goImapConnect)){
115       $message[] =_("Please specify a connect url.");
116     }  
117     if(empty($this->goImapAdmin)){
118       $message[] =_("Please specify an admin user.");
119     }  
120     if(empty($this->goImapPassword)){
121       $message[] =_("Please specify a password for the admin user.");
122     } 
124     /* Check connect string */
125     if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
126       $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."),
127           '{server-name:port/options}');
128     }
129     if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){
130       $message[]= _("The sieve port needs to be numeric.");
131     }
132  
133     return ($message);
134   }
137   function save_object()
138   {
139     if(isset($_POST['goImapServerPosted'])){
140       plugin::save_object(); 
142       foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) { 
144         if($this->acl_is_writeable($checkbox)){
145           if(!isset($_POST[$checkbox])){
146             $this->$checkbox = false;
147           }else{
148             $this->$checkbox = true;
149           }
150         }
151       }
152     }
153   }
156   /* Return plugin informations for acl handling */
157   function plInfo()
158   {
159     return (array(
160           "plShortName"   => _("IMAP/POP3"),
161           "plDescription" => _("IMAP/POP3")." ("._("Services").")",
162           "plSelfModify"  => FALSE,
163           "plDepends"     => array(),
164           "plPriority"    => 94,
165           "plSection"     => array("administration"),
166           "plCategory"    => array("server"),
168           "plProvidedAcls"=> array(
170             "start"           => _("Start"),
171             "stop"            => _("Stop"),
172             "restart"         => _("Restart"),
173             "repair_database" => _("Repair database"),
175             "goImapName"        =>_("Server identifier"),
176             "goImapConnect"     =>_("Connect URL"),
177             "goImapAdmin"       =>_("Admin user"),
178             "goImapPassword"    =>_("Admin password"),
179             "goImapSievePort"   =>_("Sieve port"),
180             "cyrusImap"         =>_("Start IMAP service"),
181             "cyrusImapSSL"      =>_("Start IMAP SSL service"),
182             "cyrusPop3"         =>_("Start POP3 service"),
183             "cyrusPop3SSL"      =>_("Start POP3 SSL service"))
184           ));
185   }
188 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
189 ?>