Code

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