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