Code

Added status "" none
[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 database");
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['AllowReset'] = 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     $ldap = $this->config->get_ldap_link();
96     $ldap->cd($this->dn);
97     $ldap->cat($this->dn,array("objectClass","goFaxAdmin", "goFaxPassword"));
98       
99     if($ldap->count()){
100       $attrs =array();
101       foreach(array("goFaxAdmin", "goFaxPassword") as $req) {
102         if(!isset($attrs[$req])){
103           if(empty($this->$req)){
104             print_red(sprintf(_("The required attribute '%s' is not set."),$req));
105           }else{
106             $attrs[$req] = $this->$req;
107           }
108         }else{
109           $attrs[$req] = $attrs[$req][0];
110         }
111       }
113       $tmp = $ldap->fetch();
114       for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
115         $attrs['objectClass'][] = $tmp['objectClass'][$i];
116       }    
117       if(!in_array("goFaxServer",$attrs['objectClass'])){
118         $attrs['objectClass'][] = "goFaxServer";
119       }
121       $flag = $this->StatusFlag;
122       $attrs[$flag] = $value;
123       $this->$flag = $value;
124       $ldap->modify($attrs);
125       show_ldap_error($ldap->get_error());
126     }    
127   }
129   
130   function check()
131   { 
132     $message = plugin::check();
133     if ($this->goFaxAdmin == "" || preg_match("/ /", $this->goFaxAdmin)){
134       $message[]= sprintf(_("The attribute '%s' is empty or contains invalid characters."), "goFaxAdmin");
135     }
136     return($message);
137   }
138   
140   function save_object()
141   {
142     if(isset($_POST['goFaxServerPosted'])){
143       plugin::save_object();
144     }
145   }  
147 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
148 ?>