Code

96ddbdb787b6a46120924122e92f5038dcf74644
[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;
41   var $acl; 
43   var $Actions              = array();  
44   var $conflicts            = array("goImapServer","kolab");
45  
46   function goImapServer($config,$dn)
47   {
48     plugin::plugin($config,$dn);
49   
50     $this->DisplayName = _("IMAP/POP3 service");
52     $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
53                             SERVICE_STARTED => SERVICE_STARTED,
54                             SERVICE_RESTARTED=>SERVICE_RESTARTED,
55                             "repair_database"=>_("Repair database"));
56     
57   }
59   function execute()
60   { 
61     $smarty = get_smarty();
62   
63     /* set new status */
64     if(isset($_POST['ExecAction'])){
65       if(isset($this->Actions[$_POST['action']])){
66         $this->setStatus($_POST['action']);
67       }
68     }
70     foreach($this->attributes as $attr){
71       $smarty->assign($attr,$this->$attr);  
72     }
74     $tmp = $this->plInfo();
75     foreach($tmp['plProvidedAcls'] as $name => $translation){
76       $smarty->assign($name."ACL",$this->getacl($name));
77     }
78     $smarty->assign("Actions",$this->Actions);
79     $smarty->assign("is_new",$this->dn);
80     $smarty->assign("is_acc",$this->initially_was_account);
81     return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__))));
82   }
84   function getListEntry()
85   {
86     $fields               = goService::getListEntry();
87     $fields['Message']    = _("Cyrus service");
88     $fields['AllowRemove']= true;
89     $fields['AllowEdit']  = true;
90     return($fields);
91   }
93   function check()
94   { 
95     $message = plugin::check();
96     if(empty($this->goImapName)){
97       $message[] =_("Please specify a server identifier.");
98     }  
99     if(empty($this->goImapConnect)){
100       $message[] =_("Please specify a connect url.");
101     }  
102     if(empty($this->goImapAdmin)){
103       $message[] =_("Please specify an admin user.");
104     }  
105     if(empty($this->goImapPassword)){
106       $message[] =_("Please specify a password for the admin user.");
107     } 
109     /* Check connect string */
110     if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
111       $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."),
112           '{server-name:port/options}');
113     }
114     if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){
115       $message[]= _("The sieve port needs to be numeric.");
116     }
117  
118     return ($message);
119   }
122   function save_object()
123   {
124     if(isset($_POST['goImapServerPosted'])){
125       plugin::save_object(); 
127       foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) { 
128         if(!isset($_POST[$checkbox])){
129           $this->$checkbox = false;
130         }else{
131           $this->$checkbox = true;
132         }
133       }
134     }
135   }
138   /* Return plugin informations for acl handling */
139   function plInfo()
140   {
141     return (array(
142           "plShortName"   => _("Imap"),
143           "plDescription" => _("Imap service"),
144           "plSelfModify"  => FALSE,
145           "plDepends"     => array(),
146           "plPriority"    => 0,
147           "plSection"     => array("administration"),
148           "plCategory"    => array("server"),
150           "plProvidedAcls"=> array(
152             "start"         => _("Start"),
153             "stop"          => _("Stop"),
154             "restart"       => _("Restart"),
156             "goImapName"        =>_("Server identifier"),
157             "goImapConnect"     =>_("Connect URL"),
158             "goImapAdmin"       =>_("Admin user"),
159             "goImapPassword"    =>_("Admin password"),
160             "goImapSievePort"   =>_("Sieve port"),
161             "cyrusImap"         =>_("Start IMAP service"),
162             "cyrusImapSSL"      =>_("Start IMAP SSL service"),
163             "cyrusPop3"         =>_("Start POP3 service"),
164             "cyrusPop3SSL"      =>_("Start POP3 SSL service"))
165           ));
166   }
169 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
170 ?>