Code

msgPool
[gosa.git] / gosa-plugins / mail / admin / systems / services / imap / 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[] = msgPool::required(_("Server identifier"));
111     }  
112     if(empty($this->goImapConnect)){
113       $message[] = msgPool::required(_("Connect URL"));
114     }  
115     if(empty($this->goImapAdmin)){
116       $message[] = msgPool::required(_("Admin user"));
117     }  
118     if(empty($this->goImapPassword)){
119       $message[] = msgPool::required(_("Password"));
120     } 
122     /* Check connect string */
123     if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
124       $message[]= msgPool::invalid(_("Connect URL"),"","{server-name:port/options}");
125     }
126     if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){
127       $message[]= msgPool::invalid(_("Sieve port"),$this->goImapSievePort,"/[0-9]/");
128     }
129  
130     return ($message);
131   }
134   function save_object()
135   {
136     if(isset($_POST['goImapServerPosted'])){
137       plugin::save_object(); 
139       foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) { 
141         if($this->acl_is_writeable($checkbox)){
142           if(!isset($_POST[$checkbox])){
143             $this->$checkbox = false;
144           }else{
145             $this->$checkbox = true;
146           }
147         }
148       }
149     }
150   }
153   /* Return plugin informations for acl handling */
154   static function plInfo()
155   {
156     return (array(
157           "plShortName"   => _("IMAP/POP3"),
158           "plDescription" => _("IMAP/POP3")." ("._("Services").")",
159           "plSelfModify"  => FALSE,
160           "plDepends"     => array(),
161           "plPriority"    => 94,
162           "plSection"     => array("administration"),
163           "plCategory"    => array("server"),
165           "plProvidedAcls"=> array(
167             "start"           => _("Start"),
168             "stop"            => _("Stop"),
169             "restart"         => _("Restart"),
170             "repair_database" => _("Repair database"),
172             "goImapName"        =>_("Server identifier"),
173             "goImapConnect"     =>_("Connect URL"),
174             "goImapAdmin"       =>_("Admin user"),
175             "goImapPassword"    =>_("Admin password"),
176             "goImapSievePort"   =>_("Sieve port"),
177             "cyrusImap"         =>_("Start IMAP service"),
178             "cyrusImapSSL"      =>_("Start IMAP SSL service"),
179             "cyrusPop3"         =>_("Start POP3 service"),
180             "cyrusPop3SSL"      =>_("Start POP3 SSL service"))
181           ));
182   }
185 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
186 ?>