Code

The setStatus function expects that the service was already saved.
[gosa.git] / plugins / admin / systems / class_goFaxServer.inc
1 <?php
3 class goFaxServer extends plugin{
4         
5   var $cli_summary      = "This pluign is used within the ServerService Pluign \nand indicates that this server supports fax informations.";
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("goFaxServer");
11   var $attributes       = array("goFaxServerStatus","goFaxAdmin", "goFaxPassword");
12   var $StatusFlag       = "goFaxServerStatus";
13  
14   /* This class can't be assigned twice so it conflicts with itsself */
15   var $conflicts        = array("goFaxServer");
17   var $DisplayName      = "";
18   var $dn               = NULL;
19   var $acl;
21   var $goFaxAdmin         = "";
22   var $goFaxPassword      = "";
23   var $goFaxServerStatus  = "";
24  
25   function goFaxServer($config,$dn)
26   {
27     plugin::plugin($config,$dn);
28     $this->DisplayName = _("FAX service");
29   }
32   function execute()
33   { 
34     $smarty = get_smarty(); 
35     foreach($this->attributes as $attr){
36       $smarty->assign($attr,$this->$attr);
37       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
38     }
39     return($smarty->fetch(get_template_path("goFaxServer.tpl",TRUE,dirname(__FILE__))));
40   }
43   function getListEntry()
44   {
45     $flag = $this->StatusFlag;
46     $fields['Status']      = $this->$flag;
47     $fields['Message']    = _("FAX database configuration");
48     $fields['AllowStart'] = true;
49     $fields['AllowStop']  = true;
50     $fields['AllowRestart'] = true;
51     $fields['AllowRemove']= true;
52     $fields['AllowEdit']  = true;
53     return($fields);
54   }
57   function remove_from_parent()
58   {
59     plugin::remove_from_parent();
60     /* Check if this is a new entry ... add/modify */
61     $ldap = $this->config->get_ldap_link();
62     $ldap->cat($this->dn,array("objectClass"));
63     if($ldap->count()){
64       $ldap->cd($this->dn);
65       $ldap->modify($this->attrs);
66     }else{
67       $ldap->cd($this->dn);
68       $ldap->add($this->attrs);
69     }
70     show_ldap_error($ldap->get_error());
71   }
74   function save()
75   {
76     plugin::save();
77     /* Check if this is a new entry ... add/modify */
78     $ldap = $this->config->get_ldap_link();
79     $ldap->cat($this->dn,array("objectClass"));
80     if($ldap->count()){
81       $ldap->cd($this->dn);
82       $ldap->modify($this->attrs);
83     }else{
84       $ldap->cd($this->dn);
85       $ldap->add($this->attrs);
86     }
87     show_ldap_error($ldap->get_error());
88   }
91   /* Directly save new status flag */
92   function setStatus($value)
93   {
94     if($value == "none") return;
95     if(!$this->initially_was_account) return;
96     $ldap = $this->config->get_ldap_link();
97     $ldap->cd($this->dn);
98     $ldap->cat($this->dn,array("objectClass"));
99     if($ldap->count()){
101       $tmp = $ldap->fetch();
102       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
103         $attrs['objectClass'][] = $tmp['objectClass'][$i];
104       }
105       $flag = $this->StatusFlag;
106       $attrs[$flag] = $value;
107       $this->$flag = $value;
108       $ldap->modify($attrs);
109       show_ldap_error($ldap->get_error());
110     }
111   }
113   
114   function check()
115   { 
116     $message = plugin::check();
117     if ($this->goFaxAdmin == "" || preg_match("/ /", $this->goFaxAdmin)){
118       $message[]= sprintf(_("The attribute '%s' is empty or contains invalid characters."), "goFaxAdmin");
119     }
120     return($message);
121   }
122   
124   function save_object()
125   {
126     if(isset($_POST['goFaxServerPosted'])){
127       plugin::save_object();
128     }
129   }  
131 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
132 ?>