Code

95d5d87dc3755c73eef15ac6c2f7f51db827366d
[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     goService::goService($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']])){
67         $tmp = $this->plInfo();
68         foreach($tmp['plProvidedAcls'] as $name => $translation) {
69           if(preg_match("/^".$_POST['action']."$/i",$name)){
70             if($this->acl_is_writeable($name)){
71               $this->setStatus($_POST['action']);
72             }
73           }
74         }
76       }
77     }
79     foreach($this->attributes as $attr){
80       $smarty->assign($attr,$this->$attr);  
81     }
83     $tmp = $this->plInfo();
84     foreach($tmp['plProvidedAcls'] as $name => $translation){
85       $smarty->assign($name."ACL",$this->getacl($name));
86     }
87     $smarty->assign("Actions",$this->Actions);
88     $smarty->assign("is_new",$this->dn);
89     $smarty->assign("is_acc",$this->initially_was_account);
90     return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__))));
91   }
93   function getListEntry()
94   {
95     $fields               = goService::getListEntry();
96     $fields['Message']    = _("IMAP/POP3 (Cyrus) service");
97     $fields['AllowRemove']= true;
98     $fields['AllowEdit']  = true;
99     return($fields);
100   }
102   function check()
103   { 
104     $message = plugin::check();
105     if(empty($this->goImapName)){
106       $message[] =_("Please specify a server identifier.");
107     }  
108     if(empty($this->goImapConnect)){
109       $message[] =_("Please specify a connect url.");
110     }  
111     if(empty($this->goImapAdmin)){
112       $message[] =_("Please specify an admin user.");
113     }  
114     if(empty($this->goImapPassword)){
115       $message[] =_("Please specify a password for the admin user.");
116     } 
118     /* Check connect string */
119     if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
120       $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."),
121           '{server-name:port/options}');
122     }
123     if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){
124       $message[]= _("The sieve port needs to be numeric.");
125     }
126  
127     return ($message);
128   }
131   function save_object()
132   {
133     if(isset($_POST['goImapServerPosted'])){
134       plugin::save_object(); 
136       foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) { 
138         if($this->acl_is_writeable($checkbox)){
139           if(!isset($_POST[$checkbox])){
140             $this->$checkbox = false;
141           }else{
142             $this->$checkbox = true;
143           }
144         }
145       }
146     }
147   }
150   /* Return plugin informations for acl handling */
151   function plInfo()
152   {
153     return (array(
154           "plShortName"   => _("IMAP/POP3"),
155           "plDescription" => _("IMAP/POP3")." ("._("Services").")",
156           "plSelfModify"  => FALSE,
157           "plDepends"     => array(),
158           "plPriority"    => 94,
159           "plSection"     => array("administration"),
160           "plCategory"    => array("server"),
162           "plProvidedAcls"=> array(
164             "start"           => _("Start"),
165             "stop"            => _("Stop"),
166             "restart"         => _("Restart"),
167             "repair_database" => _("Repair database"),
169             "goImapName"        =>_("Server identifier"),
170             "goImapConnect"     =>_("Connect URL"),
171             "goImapAdmin"       =>_("Admin user"),
172             "goImapPassword"    =>_("Admin password"),
173             "goImapSievePort"   =>_("Sieve port"),
174             "cyrusImap"         =>_("Start IMAP service"),
175             "cyrusImapSSL"      =>_("Start IMAP SSL service"),
176             "cyrusPop3"         =>_("Start POP3 service"),
177             "cyrusPop3SSL"      =>_("Start POP3 SSL service"))
178           ));
179   }
182 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
183 ?>