1 <?php
3 class goCupsServer extends plugin{
5 var $cli_summary = "This plugin is used within the ServerService Pluign \nand indicates that this server supports cups management.";
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("goCupsServer");
11 var $attributes = array("goCupsServerStatus");
12 var $StatusFlag = "goCupsServerStatus";
14 /* This class can't be assigned twice so it conflicts with itsself */
15 var $conflicts = array("goCupsServer");
17 var $DisplayName = "";
18 var $dn = NULL;
19 var $acl;
21 var $goCupsServerStatus = "";
23 function goCupsServer($config,$dn)
24 {
25 plugin::plugin($config,$dn);
26 $this->DisplayName = _("Print service");
27 }
30 function execute()
31 {
32 $smarty = get_smarty();
33 foreach($this->attributes as $attr){
34 $smarty->assign($attr,$this->$attr);
35 $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
36 }
37 return($smarty->fetch(get_template_path("goCupsServer.tpl",TRUE,dirname(__FILE__))));
38 }
41 function getListEntry()
42 {
43 $flag = $this->StatusFlag;
44 $fields['Status'] = $this->$flag;
45 $fields['Message'] = _("Print service");
46 $fields['AllowStart'] = true;
47 $fields['AllowStop'] = true;
48 $fields['AllowReset'] = true;
49 $fields['AllowRemove']= true;
50 $fields['AllowEdit'] = true;
51 return($fields);
52 }
55 function remove_from_parent()
56 {
57 plugin::remove_from_parent();
58 /* Check if this is a new entry ... add/modify */
59 $ldap = $this->config->get_ldap_link();
60 $ldap->cat($this->dn,array("objectClass"));
61 if($ldap->count()){
62 $ldap->cd($this->dn);
63 $ldap->modify($this->attrs);
64 }else{
65 $ldap->cd($this->dn);
66 $ldap->add($this->attrs);
67 }
68 show_ldap_error($ldap->get_error());
69 }
72 function save()
73 {
74 plugin::save();
75 /* Check if this is a new entry ... add/modify */
76 $ldap = $this->config->get_ldap_link();
77 $ldap->cat($this->dn,array("objectClass"));
78 if($ldap->count()){
79 $ldap->cd($this->dn);
80 $ldap->modify($this->attrs);
81 }else{
82 $ldap->cd($this->dn);
83 $ldap->add($this->attrs);
84 }
85 show_ldap_error($ldap->get_error());
86 }
89 /* Directly save new status flag */
90 function setStatus($value)
91 {
92 if($value == "none") return;
93 $ldap = $this->config->get_ldap_link();
94 $ldap->cd($this->dn);
95 $ldap->cat($this->dn,array("objectClass"));
97 if($ldap->count()){
98 $attrs =array();
99 $tmp = $ldap->fetch();
100 for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
101 $attrs['objectClass'][] = $tmp['objectClass'][$i];
102 }
103 if(!in_array("goCupsServer",$attrs['objectClass'])){
104 $attrs['objectClass'][] = "goCupsServer";
105 }
107 $flag = $this->StatusFlag;
108 $attrs[$flag] = $value;
109 $this->$flag = $value;
110 $ldap->modify($attrs);
111 show_ldap_error($ldap->get_error());
112 }
113 }
116 function check()
117 {
118 $message = plugin::check();
119 return($message);
120 }
123 function save_object()
124 {
125 plugin::save_object();
126 }
127 }
128 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
129 ?>