1 <?php
2 class ArpNewDevice extends plugin
3 {
4 var $cn= "";
5 var $description = "";
6 var $netConfigDNS = NULL;
7 var $attributes= array("cn","description");
8 var $objectclasses = array("gotoHard");
9 var $ignore_account = TRUE;
11 var $ObjectGroups = array();
12 var $SystemTypes = array();
14 var $ObjectGroup = "none";
15 var $SystemType = "gotoWorkstation";
17 var $gotoIntegration = FALSE;
19 function ArpNewDevice ($config, $dn= NULL, $parent= NULL)
20 {
21 plugin :: plugin($config,$dn);
22 $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
23 $this->acl = "#all#";
24 $this->netConfigDNS->acl = $this->acl;
25 $this->netConfigDNS->force_dns();
27 /* Get object groups */
28 $ldap = $this->config->get_ldap_link();
29 $ldap->cd ($this->config->current['BASE']);
30 $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
31 $tmp= array();
32 while($attrs = $ldap->fetch()){
33 $tmp[$attrs['dn']]= $attrs['cn'][0];
34 }
35 asort($tmp, SORT_LOCALE_STRING);
36 $this->ObjectGroups= $tmp;
38 $this->SystemTypes =array("gotoWorkstation"=>_("Workstation"), "gotoTermminal"=>_("Terminal"), "goServer"=>_("Server"));
39 if(class_available("opsi")){
40 $this->SystemTypes["FAKE_OC_OpsiHost"]= _("Windows workstation");
41 }
42 }
44 function execute()
45 {
46 plugin::execute();
48 /* Get object groups */
49 $ldap = $this->config->get_ldap_link();
50 $ldap->cd ($this->config->current['BASE']);
51 $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("gosaGroupObjects","cn"));
52 $tmp= array("W" => array(),"T" => array(), "S" => array(),"O" => array());
53 while($attrs = $ldap->fetch()){
54 $tmp[preg_replace("/[\[\] ]/","",$attrs['gosaGroupObjects'][0])][$attrs['dn']] = $attrs['cn'][0];
55 }
57 $smarty = get_smarty();
58 foreach($this->attributes as $attr){
59 $smarty->assign($attr,$this->$attr);
60 }
61 $this->netConfigDNS->cn= $this->cn;
63 $map = array("gotoWorkstation" => "W","gotoTerminal" => "T","goServer" => "S", "FAKE_OC_OpsiHost" => "O");
64 $smarty->assign("netconfig", $this->netConfigDNS->execute());
65 $smarty->assign("ogroups", $tmp[$map[$this->SystemType]]);
66 $smarty->assign("SystemTypes" ,$this->SystemTypes);
67 $smarty->assign("SystemTypeKeys" ,array_flip($this->SystemTypes));
68 $smarty->assign("ObjectGroup",$this->ObjectGroup);
69 $smarty->assign("SystemType",$this->SystemType);
71 $smarty->assign("gotoIntegration",$this->gotoIntegration);
73 /* Display sub dialog from network settings */
74 $this->netConfigDNS->acl = $this->acl;
75 if($this->netConfigDNS->dialog){
76 $this->dialog = TRUE;
77 return($this->netConfigDNS->execute());
78 }else{
79 $this->dialog = FALSE;
80 }
82 return($smarty->fetch (get_template_path('ArpNewDevice.tpl', TRUE,dirname(__FILE__))));
83 }
85 function check()
86 {
87 $message= plugin::check();
88 $message= array_merge($message, $this->netConfigDNS->check());
89 if(empty($this->cn)){
90 $message[] = msgPool::required(_("Name"));
91 }
92 return($message);
93 }
95 function save_object()
96 {
97 if(isset($_POST['ArpNewDevice_posted'])){
98 plugin::save_object();
99 $this->netConfigDNS->save_object();
101 $this->gotoIntegration = isset($_POST['gotoIntegration']);
102 if($this->gotoIntegration){
103 if(isset($_POST['SystemType'])){
104 $this->SystemType = get_post('SystemType');
105 }
106 if(isset($_POST['ObjectGroup'])){
107 $this->ObjectGroup = get_post('ObjectGroup');
108 }
109 }
110 }
111 }
113 function save()
114 {
116 $this->netConfigDNS->acl = $this->acl;
117 plugin::save();
118 $this->netConfigDNS->cn = $this->cn;
119 $this->netConfigDNS->save($this->dn);
121 // Do not remove this Arp-Device if gotoIntegration was selected.
122 if(!$this->gotoIntegration){
124 $ldap = $this->config->get_ldap_link();
125 $ldap->cd($this->config->current['BASE']);
126 $ldap->rmdir_recursive($this->dn);
127 if (!$ldap->success()){
128 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $key->dn, LDAP_DEL, get_class()));
129 }
130 }
131 }
134 /*! \brief !! Incoming dummy acls, required to defined acls for incoming objects
135 */
136 static function plInfo()
137 {
138 return (array(
139 "plShortName" => _("Unknown incoming objects"),
140 "plDescription" => _("Unknown incoming objects"),
141 "plSelfModify" => FALSE,
142 "plDepends" => array(),
143 "plPriority" => 99,
144 "plSection" => array("administration"),
146 "plProperties" =>
147 array(
148 array(
149 "name" => "systemIncomingRDN",
150 "type" => "rdn",
151 "default" => "ou=incoming,",
152 "description" => "The 'systemIncomingRDN' statement defines the location where incoming systems are stored. The default is 'ou=incoming,'.",
153 "check" => "gosaProperty::isRdn",
154 "migrate" => "",
155 "group" => "plugin",
156 "mandatory" => FALSE)),
158 "plCategory" => array("incoming" => array( "description" => _("Incoming"),
159 "objectClass" => "")),
160 "plProvidedAcls"=> array(
161 "cn" => _("Name"),
162 "description" => _("Description")
164 )
165 ));
166 }
168 }
170 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
171 ?>