1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
24 #
25 # NewDevices
26 # -> Edit
27 # |- SelectDeviceType() (Allows to select target SystemType and OGroup)
28 # -> Save
29 # |-> systemTypeChosen() (Queue entry to be activated)
30 # |-> handleActivationQueue() (Now acticvate queued objects)
31 # |-> Ogroup selected
32 # | |-> Try to adapt values from ogroup and save directly.
33 # |
34 # |-> NO Ogroup selected
35 # | |-> Open dialogs of the target system type and allow modifcations.
36 # |
37 # |->activate_new_device() (Finally activate the device - FAIsate=..)
38 #
39 #
40 # NewArpDevices (NewUnknwonDevices )
41 # -> Edit
42 # |-> editEntry - ArpNewDeviceTabs
43 # -> Save
44 # |-> NO gotoIntegeration
45 # | |-> Save DHCP and DNS entries, then remove the source entry from ldap.
46 # |
47 # |-> gotoIntegration selected (Handle object like a NewDevice now)
48 # |-> systemTypeChosen() (Queue entry to be activated)
49 # |-> handleActivationQueue() (Now acticvate queued objects)
50 # |-> Ogroup selected
51 # | |-> Try to adapt values from ogroup and save directly.
52 # |
53 # |-> NO Ogroup selected
54 # | |-> Open dialogs of the target system type and allow modifcations.
55 # |
56 # |->activate_new_device() (Finally activate the device - FAIsate=..)
57 #
58 class systemManagement extends management
59 {
60 var $plHeadline = "Systems";
61 var $plDescription = "Systems";
62 var $plIcon = "plugins/systems/images/plugin.png";
64 // Tab definition
65 protected $tabClass = "";
66 protected $tabType = "";
67 protected $aclCategory = "";
68 protected $aclPlugin = "";
69 protected $objectName = "system";
70 protected $objectInfo = array();
71 protected $opsi = NULL;
72 protected $activationQueue = array();
74 function __construct($config,$ui)
75 {
76 $this->config = $config;
77 $this->ui = $ui;
79 // Set storage points
80 $tD = $this->getObjectDefinitions();
81 $sP = array();
82 foreach($tD as $entry){
83 if(!empty($entry['ou']))
84 $sP[] = $entry['ou'];
85 }
86 $this->storagePoints = array_unique($sP);
88 // Build filter
89 # if (session::global_is_set(get_class($this)."_filter")){
90 # $filter= session::global_get(get_class($this)."_filter");
91 # } else {
92 $filter = new filter(get_template_path("system-filter.xml", true));
93 $filter->setObjectStorage($this->storagePoints);
94 # }
95 $this->setFilter($filter);
97 // Build headpage
98 $headpage = new listing(get_template_path("system-list.xml", true));
99 $headpage->registerElementFilter("systemDescription", "systemManagement::systemDescription");
100 $headpage->setFilter($filter);
101 $filter->setConverter('INCOMING', 'systemManagement::incomingFilterConverter');
103 // Register Daemon Events
104 if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
105 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
106 foreach($events['TRIGGERED'] as $name => $data){
107 $this->registerAction("T_".$name,"handleEvent");
108 $this->registerAction("S_".$name,"handleEvent");
109 }
110 $this->registerAction("activateMultiple","activateMultiple");
111 }
112 $this->registerAction("saveEvent","saveEventDialog");
113 $this->registerAction("createISO","createISO");
114 $this->registerAction("initiateISOcreation","initiateISOcreation");
115 $this->registerAction("performIsoCreation","performIsoCreation");
116 $this->registerAction("systemTypeChosen","systemTypeChosen");
117 $this->registerAction("handleActivationQueue","handleActivationQueue");
119 $this->registerAction("new_goServer", "newEntry");
120 $this->registerAction("new_gotoWorkstation", "newEntry");
121 $this->registerAction("new_gotoTerminal", "newEntry");
122 $this->registerAction("new_gotoPrinter", "newEntry");
123 $this->registerAction("new_goFonHardware", "newEntry");
124 $this->registerAction("new_ieee802Device", "newEntry");
125 $this->registerAction("new_FAKE_OC_OpsiHost", "newEntry");
127 $this->registerAction("setPassword", "setPassword");
128 $this->registerAction("passwordChangeConfirmed", "passwordChangeConfirmed");
130 // Add copy&paste and snapshot handler.
131 if ($this->config->boolValueIsTrue("main", "copyPaste")){
132 $this->cpHandler = new CopyPasteHandler($this->config);
133 }
134 if($this->config->get_cfg_value("enableSnapshots") == "true"){
135 $this->snapHandler = new SnapshotHandler($this->config);
136 }
138 // Check if we are able to communicate with the GOsa supprot daemon
139 if(class_available("gosaSupportDaemon")){
140 $o = new gosaSupportDaemon();
141 $this->si_active = $o->connect() && class_available("DaemonEvent");
142 }
144 // Check if we are able to communicate with the GOsa supprot daemon
145 if(class_available("opsi")){
146 $this->opsi = new opsi($this->config);
147 }
148 parent::__construct($config, $ui, "systems", $headpage);
150 // Used to generate an 'ogroup' icon within the description field.
151 session::set('SYSTEMS_DESCRIPTION_FILTER', $headpage);
152 }
155 /*! \brief Act on password change requests.
156 */
157 function setPassword($action,$target)
158 {
159 if(count($target) == 1){
160 $tDefs= $this->getObjectDefinitions();
161 $headpage = $this->getHeadpage();
162 $dn = array_pop($target);
163 $type = $headpage->getType($dn);
164 $entry = $headpage->getEntry($dn);
165 $ui = get_userinfo();
166 $smarty = get_smarty();
167 if(in_array("FAKE_OC_PWD_changeAble", $entry['objectClass'])){
168 $acl = $tDefs[$type]['aclCategory'].'/'.$tDefs[$type]['aclClass'];
169 $tabacl = $ui->get_permissions($dn,$acl,"userPassword");
170 if(preg_match("/w/",$tabacl)){
171 $this->dn= $dn;
172 set_object_info($this->dn);
173 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
174 }else{
175 msg_dialog::display(_("Permission error"), _("You have no permission to change this password!"), ERROR_DIALOG);
176 }
177 }
178 }
179 }
182 /*! \brief This method is used to queue and process copy&paste actions.
183 * Allows to copy, cut and paste mutliple entries at once.
184 * @param String 'action' The name of the action which was the used as trigger.
185 * @param Array 'target' A list of object dns, which should be affected by this method.
186 * @param Array 'all' A combination of both 'action' and 'target'.
187 */
188 function copyPasteHandler($action="",$target=array(),$all=array(),
189 $altTabClass ="", $altTabType = "", $altAclCategory="",$altAclPlugin="")
190 {
191 // Return without any actions while copy&paste handler is disabled.
192 if(!is_object($this->cpHandler)) return("");
194 // Save user input
195 $this->cpHandler->save_object();
197 // Add entries to queue
198 if($action == "copy" || $action == "cut"){
200 $tDefs= $this->getObjectDefinitions();
201 $headpage = $this->getHeadpage();
202 $ui = get_userinfo();
203 $this->cpHandler->cleanup_queue();
204 foreach($target as $dn){
206 $type = $headpage->getType($dn);
207 $entry = $headpage->getEntry($dn);
209 $aclCategory = $tDefs[$type]['aclCategory'];
210 $aclPlugin = $tDefs[$type]['aclClass'];
211 $tabClass = $tDefs[$type]['tabClass'];
212 $tabType = $tDefs[$type]['tabDesc'];
214 if($action == "copy" && $this->ui->is_copyable($dn,$aclCategory,$aclPlugin)){
215 $this->cpHandler->add_to_queue($dn,"copy",$tabClass,$tabType,$aclCategory,$this);
216 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Entry copied!");
217 }
218 if($action == "cut" && $this->ui->is_cutable($dn,$aclCategory,$aclPlugin)){
219 $this->cpHandler->add_to_queue($dn,"cut",$tabClass,$tabType,$aclCategory,$this);
220 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Entry cutted!");
221 }
222 }
223 }
225 // Initiate pasting
226 if($action == "paste"){
227 $this->cpPastingStarted = TRUE;
228 }
230 // Display any c&p dialogs, eg. object modifications required before pasting.
231 if($this->cpPastingStarted && $this->cpHandler->entries_queued()){
232 $headpage = $this->getHeadpage();
233 $this->cpHandler->SetVar("base",$headpage->getBase());
234 $data = $this->cpHandler->execute();
235 if(!empty($data)){
236 return($data);
237 }
238 }
240 // Automatically disable pasting process since there is no entry left to paste.
241 if(!$this->cpHandler->entries_queued()){
242 $this->cpPastingStarted = FALSE;
243 }
244 return("");
245 }
248 /*! \brief Password change confirmed, now try to change the systems pwd.
249 */
250 function passwordChangeConfirmed()
251 {
252 $tDefs= $this->getObjectDefinitions();
253 $headpage = $this->getHeadpage();
254 $type = $headpage->getType($this->dn);
255 $entry = $headpage->getEntry($this->dn);
256 $ui = get_userinfo();
257 $smarty = get_smarty();
259 if(!in_array('FAKE_OC_PWD_changeAble', $entry['objectClass'])){
260 trigger_error("Tried to change pwd, for invalid object!");
261 }elseif ($_POST['new_password'] != $_POST['repeated_password']){
262 msg_dialog::display(_("Error"),
263 _("The passwords you've entered as 'New password' and 'Repeated password' do not match!"), ERROR_DIALOG);
264 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
265 }else{
266 $acl = $tDefs[$type]['aclCategory'].'/'.$tDefs[$type]['aclClass'];
267 $tabacl = $ui->get_permissions($this->dn,$acl,"userPassword");
269 // Check acls
270 if(!preg_match("/w/",$tabacl)){
271 msg_dialog::display(_("Permission error"), _("You have no permission to change this password!"), ERROR_DIALOG);
272 }else{
273 $ldap = $this->config->get_ldap_link();
274 $ldap->cd($this->dn);
275 $ldap->cat($this->dn);
276 $old_attrs = $ldap->fetch();
278 $attrs= array();
279 if ($_POST['new_password'] == ""){
281 /* Remove password attribute
282 */
283 if(in_array("simpleSecurityObject",$old_attrs['objectClass'])){
284 $attrs['objectClass'] = array();
285 for($i = 0 ; $i < $old_attrs['objectClass']['count'] ; $i ++){
286 if(!preg_match("/simpleSecurityObject/i",$old_attrs['objectClass'][$i])){
287 $attrs['objectClass'][] = $old_attrs['objectClass'][$i];
288 }
289 }
290 }
291 $attrs['userPassword']= array();
292 } else {
294 /* Add/modify password attribute
295 */
296 if(!in_array("simpleSecurityObject",$old_attrs['objectClass'])){
297 $attrs['objectClass'] = array();
298 for($i = 0 ; $i < $old_attrs['objectClass']['count'] ; $i ++){
299 $attrs['objectClass'][] = $old_attrs['objectClass'][$i];
300 }
301 $attrs['objectClass'][] = "simpleSecurityObject";
302 }
304 if(class_available("passwordMethodCrypt")){
305 $pwd_m = new passwordMethodCrypt($this->config);
306 $pwd_m->set_hash("crypt/md5");
307 $attrs['userPassword'] = $pwd_m->generate_hash($_POST['new_password']);
308 }else{
309 msg_dialog::display(_("Password method"),_("Password method crypt is missing. Cannot set system password."));
310 $attrs = array();
311 }
312 }
313 $ldap->modify($attrs);
314 if (!$ldap->success()){
315 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, $type));
316 }else{
317 if(class_available($tDefs[$type]['plugClass'])){
318 $plug = $tDefs[$type]['plugClass'];
319 $p = new $plug($this->config,$this->dn);
320 $p->handle_post_events("modify");
321 }
322 }
323 new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error());
324 }
325 set_object_info();
326 }
327 }
330 /*! \brief The method gets called when somebody clicked the CD icon
331 * in the system listing.
332 * A confirmation will be shown to acknowledge the creation.
333 */
334 function createISO($action,$target)
335 {
336 if(count($target) == 1){
337 $smarty = get_smarty();
338 $this->dn= array_pop($target);
339 set_object_info($this->dn);
340 return ($smarty->fetch(get_template_path('goto/gencd.tpl', TRUE)));
342 }
343 }
346 /*! \brief Once the user has confirmed the ISO creation in 'createISO',
347 * this method gets called.
348 * An iFrame is shown which then used 'performIsoCreation' as contents.
349 */
350 function initiateISOcreation()
351 {
352 $smarty = get_smarty();
353 $smarty->assign("src", "?plug=".$_GET['plug']."&PerformIsoCreation");
354 return ($smarty->fetch(get_template_path('goto/gencd_frame.tpl', TRUE)));
355 }
358 /*! \brief ISO creation confirmed and iFrame is visible, now create the ISO
359 * and display the status to fill the iFrame.
360 */
361 function performIsoCreation()
362 {
363 $return_button = "<form method='get' action='main.php' target='_parent'>
364 <input type='submit' value='"._("Back")."'>
365 <input type='hidden' name='plug' value='".$_GET['plug']."'/>
366 </form>";
368 $dsc = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
370 /* Get and check command */
371 $command= $this->config->search("workgeneric", "SYSTEMISOHOOK",array('tabs'));
372 if (check_command($command)){
373 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
375 /* Print out html introduction */
376 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
377 <html>
378 <head>
379 <title></title>
380 <style type="text/css">@import url("themes/default/style.css");</style>
381 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
382 </head>
383 <body style="background: none; margin:4px;" id="body" >
384 <pre>';
386 /* Open process handle and check if it is a valid process */
387 $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
388 if (is_resource($process)) {
389 fclose($pipes[0]);
391 /* Print out returned lines && write JS to scroll down each line */
392 while (!feof($pipes[1])){
393 $cur_dat = fgets($pipes[1], 1024);
394 echo $cur_dat;
395 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
396 flush();
397 }
398 }
400 /* Get error string && close streams */
401 $buffer= stream_get_contents($pipes[2]);
403 fclose($pipes[1]);
404 fclose($pipes[2]);
405 echo "</pre>";
407 /* Check return code */
408 $ret= proc_close($process);
409 if ($ret != 0){
410 echo "<h1 style='color:red'>"._("Creating the image failed. Please see the report below.")."</h1>";
411 echo "<pre style='color:red'>$buffer</pre>";
412 }
413 echo $return_button."<br>";
414 } else {
415 $tmp= "<h1 style='color:red'>".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."</h1>";
416 echo $tmp;
417 echo $return_button."<br>";
418 }
420 /* Scroll down completly */
421 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
422 echo '</body></html>';
423 flush();
424 exit;
425 }
428 /*! \brief Handle GOsa-si events
429 * All schedules and triggered events are handled here.
430 */
431 function handleEvent($action="",$target=array(),$all=array())
432 {
433 // Detect whether this event is scheduled or triggered.
434 $triggered = TRUE;
435 if(preg_match("/^S_/",$action)){
436 $triggered = FALSE;
437 }
439 // Detect triggere or scheduled actions
440 $headpage = $this->getHeadpage();
441 $event = preg_replace("/^[TS]_/","",$action);
442 if(preg_match("/^[TS]_/", $action)){
444 // Send special reinstall action for opsi hosts
445 if($event == "DaemonEvent_reinstall" && $this->si_active && $this->opsi){
446 foreach($target as $key => $dn){
447 $type = $headpage->getType($dn);
449 // Send Reinstall event for opsi hosts
450 if($type == "FAKE_OC_OpsiHost"){
451 $obj = $headpage->getEntry($dn);
452 $this->opsi->job_opsi_install_client($obj['cn'][0],$obj['macAddress'][0]);
453 unset($target[$key]);
454 }
455 }
456 }
457 }
459 // Now send remaining FAI/GOsa-si events here.
460 if(count($target) && $this->si_active){
461 $mac= array();
463 // Collect target mac addresses
464 $ldap = $this->config->get_ldap_link();
465 $tD = $this->getObjectDefinitions();
466 $events = DaemonEvent::get_event_types(SYSTEM_EVENT);
467 $o_queue = new gosaSupportDaemon();
468 foreach($target as $dn){
469 $type = $headpage->getType($dn);
470 if($tD[$type]['sendEvents']){
471 $obj = $headpage->getEntry($dn);
472 if(isset($obj['macAddress'][0])){
473 $mac[] = $obj['macAddress'][0];
474 }
475 }
476 }
478 /* Skip installation or update trigerred events,
479 * if this entry is currently processing.
480 */
481 if($triggered && in_array($event,array("DaemonEvent_reinstall","DaemonEvent_update"))){
482 foreach($mac as $key => $mac_address){
483 foreach($o_queue->get_entries_by_mac(array($mac_address)) as $entry){
484 $entry['STATUS'] = strtoupper($entry['STATUS']);
485 if($entry['STATUS'] == "PROCESSING" &&
486 isset($events['QUEUED'][$entry['HEADERTAG']]) &&
487 in_array($events['QUEUED'][$entry['HEADERTAG']],array("DaemonEvent_reinstall","DaemonEvent_update"))){
488 unset($mac[$key]);
490 new log("security","systems/".get_class($this),"",array(),"Skip adding 'DaemonEvent::".$type."' for mac '".$mac_address."', there is already a job in progress.");
491 break;
492 }
493 }
494 }
495 }
497 // Prepare event to be added
498 if(count($mac) && isset($events['BY_CLASS'][$event]) && $this->si_active){
499 $event = $events['BY_CLASS'][$event];
500 $this->dialogObject = new $event['CLASS_NAME']($this->config);
501 $this->dialogObject->add_targets($mac);
503 if($triggered){
504 $this->dialogObject->set_type(TRIGGERED_EVENT);
505 $o_queue->append($this->dialogObject);
506 if($o_queue->is_error()){
507 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
508 }else{
509 $this->closeDialogs();
510 }
511 }else{
512 $this->dialogObject->set_type(SCHEDULED_EVENT);
513 }
514 }
515 }
516 }
519 /*! \brief Close all dialogs and reset the activationQueue.
520 */
521 function cancelEdit()
522 {
523 management::cancelEdit();
524 $this->activationQueue = array();
525 }
528 /*! \brief Save event dialogs.
529 * And append the new GOsa-si event.
530 */
531 function saveEventDialog()
532 {
533 $o_queue = new gosaSupportDaemon();
534 $o_queue->append($this->dialogObject);
535 if($o_queue->is_error()){
536 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
537 }else{
538 $this->closeDialogs();
539 }
540 }
543 /*! \brief Update filter part for INCOMING.
544 * Allows us to search for "systemIncomingRDN".
545 */
546 static function incomingFilterConverter($filter)
547 {
548 $rdn = preg_replace("/^[^=]*=/", "", get_ou('systemIncomingRDN'));
549 $rdn = preg_replace("/,.*$/","",$rdn);
550 return(preg_replace("/%systemIncomingRDN/", $rdn,$filter));
551 }
554 /*! \brief Queue selected objects to be removed.
555 * Checks ACLs, Locks and ask for confirmation.
556 */
557 protected function removeEntryRequested($action="",$target=array(),$all=array())
558 {
559 $disallowed = array();
560 $this->dns = array();
562 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel requested!");
564 // Check permissons for each target
565 $tInfo = $this->getObjectDefinitions();
566 $headpage = $this->getHeadpage();
567 foreach($target as $dn){
568 $type = $headpage->getType($dn);
569 if(!isset($tInfo[$type])){
570 trigger_error("Unknown object type received '".$type."' please update systemManagement::getObjectDefinitions()!");
571 }else{
572 $info = $tInfo[$type];
573 $acl = $this->ui->get_permissions($dn, $info['aclCategory']."/".$info['aclClass']);
574 if(preg_match("/d/",$acl)){
575 $this->dns[] = $dn;
576 }else{
577 $disallowed[] = $dn;
578 }
579 }
580 }
581 if(count($disallowed)){
582 msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
583 }
585 // We've at least one entry to delete.
586 if(count($this->dns)){
588 // check locks
589 if ($user= get_multiple_locks($this->dns)){
590 return(gen_locked_message($user,$this->dns));
591 }
593 // Add locks
594 $dns_names = array();
595 foreach($this->dns as $dn){
596 $dns_names[] =LDAP::fix($dn);
597 }
598 add_lock ($this->dns, $this->ui->dn);
600 // Display confirmation dialog.
601 $smarty = get_smarty();
602 $smarty->assign("info", msgPool::deleteInfo($dns_names,_($this->objectName)));
603 $smarty->assign("multiple", true);
604 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
605 }
606 }
609 /*! \brief Object removal was confirmed, now remove the requested entries.
610 *
611 * @param String 'action' The name of the action which was the used as trigger.
612 * @param Array 'target' A list of object dns, which should be affected by this method.
613 * @param Array 'all' A combination of both 'action' and 'target'.
614 */
615 function removeEntryConfirmed($action="",$target=array(),$all=array(),
616 $altTabClass="",$altTabType="",$altAclCategory="")
617 {
618 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel confirmed!");
620 // Check permissons for each target
621 $tInfo = $this->getObjectDefinitions();
622 $headpage = $this->getHeadpage();
623 $disallowed = array();
624 foreach($this->dns as $key => $dn){
625 $type = $headpage->getType($dn);
626 if(!isset($tInfo[$type])){
627 trigger_error("Unknown object type received '".$type."' please update systemManagement::getObjectDefinitions()!");
628 }else{
630 $info = $tInfo[$type];
631 $acl = $this->ui->get_permissions($dn, $info['aclCategory']."/".$info['aclClass']);
632 if(preg_match("/d/",$acl)){
634 // Delete the object
635 $this->dn = $dn;
636 if($info['tabClass'] == "phonetabs"){
637 $this->tabObject= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
638 $this->tabObject->set_acl_base($dn);
639 $this->tabObject->by_object['phoneGeneric']->remove_from_parent ();
640 }else{
641 $this->tabObject= new $info['tabClass']($this->config,$this->config->data['TABS'][$info['tabDesc']],
642 $this->dn, $info['aclCategory'], true, true);
643 $this->tabObject->set_acl_base($this->dn);
644 $this->tabObject->parent = &$this;
645 $this->tabObject->delete ();
646 }
648 // Remove the lock for the current object.
649 del_lock($this->dn);
651 }else{
652 $disallowed[] = $dn;
653 new log("security","system/".get_class($this),$dn,array(),"Tried to trick deletion.");
654 }
655 }
656 }
657 if(count($disallowed)){
658 msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
659 }
661 // Cleanup
662 $this->remove_lock();
663 $this->closeDialogs();
664 }
667 /*! \brief Edit the selected system type.
668 * NewDevice and ArpNewDevice are handled here separately
669 */
670 function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
671 {
672 if(count($target) == 1){
673 $tInfo = $this->getObjectDefinitions();
674 $headpage = $this->getHeadpage();
675 $dn = $target[0];
676 $type =$headpage->getType($dn);
677 $tData = $tInfo[$type];
679 if($type == "FAKE_OC_ArpNewDevice"){
680 if(!class_available("ArpNewDeviceTabs")){
681 msg_dialog::display(_("Error"), msgPool::class_not_found("ArpNewDevice"), ERROR_DIALOG);
682 }else{
683 return(management::editEntry($action,$target,$all,"ArpNewDeviceTabs","ARPNEWDEVICETABS","incoming"));
684 }
685 }elseif($type == "FAKE_OC_NewDevice"){
686 if(!class_available("SelectDeviceType")){
687 msg_dialog::display(_("Error"), msgPool::class_not_found("SelectDeviceType"), ERROR_DIALOG);
688 }else{
689 $this->activationQueue[$dn] = array();
690 $this->dialogObject = new SelectDeviceType($this->config,$dn);
691 $this->skipFooter = TRUE;
692 $this->displayApplyBtn = FALSE;
693 // see condition -$s_action == "::systemTypeChosen"- for further handling
694 }
695 }else{
696 return(management::editEntry($action,$target,$all,$tData['tabClass'],$tData['tabDesc'],$tData['aclCategory']));
697 }
698 }
699 }
702 /*! \brief Edit the selected system type.
703 *
704 * @param String 'action' The name of the action which was the used as trigger.
705 * @param Array 'target' A list of object dns, which should be affected by this method.
706 * @param Array 'all' A combination of both 'action' and 'target'.
707 */
708 function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
709 {
710 $tInfo = $this->getObjectDefinitions();
711 $info = preg_replace("/^new_/","",$action);
712 if(!isset($tInfo[$info])){
713 trigger_error("Unknown action type '".$action."' cant create a new system!");
714 }else{
715 return(management::newEntry($action,$target,$all,
716 $tInfo[$info]['tabClass'],
717 $tInfo[$info]['tabDesc'],
718 $tInfo[$info]['aclCategory']));
719 }
720 }
723 /*! \brief Activates all selcted 'NewDevices' at once.
724 * Enqueues the selected Devices in the activation queue.
725 */
726 function activateMultiple($action,$target)
727 {
728 $headpage = $this->getHeadpage();
729 foreach($target as $dn) {
730 if($headpage->getType($dn) == "FAKE_OC_NewDevice"){
731 $this->activationQueue[$dn] = array();
732 }
733 }
734 if(count($this->activationQueue)){
735 $this->dialogObject = new SelectDeviceType($this->config, array_keys($this->activationQueue));
736 $this->skipFooter = TRUE;
737 }
738 }
741 /*! \brief The system selection dialog was closed.
742 * We will now queue the given entry to be activated.
743 */
744 function systemTypeChosen()
745 {
746 // Detect the systems target type
747 $tInfo = $this->getObjectDefinitions();
748 $selected_group = "none";
749 if(isset($_POST['ObjectGroup'])){
750 $selected_group = $_POST['ObjectGroup'];
751 }
752 $selected_system = $_POST['SystemType'];
753 $tmp = array();
754 foreach($this->activationQueue as $dn => $data){
755 $tmp[$dn]['OG'] = $selected_group;
756 $tmp[$dn]['SS'] = $selected_system;
757 }
758 $this->closeDialogs();
759 $this->activationQueue = $tmp;
760 return($this->handleActivationQueue());
761 }
764 /*! \brief Activate queued goto systems.
765 */
766 function handleActivationQueue()
767 {
768 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
769 'Entries left: '.count($this->activationQueue), "<b>Handling system activation queue!</b>");
771 if(!count($this->activationQueue)) return("");
773 $ldap = $this->config->get_ldap_link();
774 $pInfo = $this->getObjectDefinitions();
775 $ui = get_userinfo();
776 $headpage = $this->getHeadpage();
777 $ldap->cd($this->config->current['BASE']);
779 // Walk through systems to activate
780 while(count($this->activationQueue)){
782 // Get next entry
783 reset($this->activationQueue);
784 $dn = key($this->activationQueue);
785 $data= $this->activationQueue[$dn];
787 // Validate the given system type.
788 if(!isset($data['SS'])) continue;
789 $sysType = $data['SS'];
790 if(!isset($pInfo[$sysType])){
791 trigger_error('Unknown type \''.$sysType.'\'!');
792 continue;
793 }
794 $type = $pInfo[$sysType];
796 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
797 $dn, "<b>Try to activate:</b>");
799 // Get target type definition
800 $plugClass = $type["plugClass"];
801 $tabClass = $type["tabClass"];
802 $aclCategory = $type["aclCategory"];
803 $tabDesc = $type["tabDesc"];
805 if(!class_available($tabClass)){
806 msg_dialog::display(_("Error"), msgPool::class_not_found($tabclass), ERROR_DIALOG);
807 unset($this->activationQueue[$dn]);
808 continue;
809 }else{
811 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
812 $sysType, "<b>System type:</b>");
814 // Load permissions for selected 'dn' and check if we're allowed to create this 'dn'
815 $this->dn = $dn;
816 $acls = $ui->get_permissions($this->dn,$aclCategory."/".$plugClass);
818 // Check permissions
819 if(!preg_match("/c/",$acls)){
820 unset($this->activationQueue[$dn]);
821 msg_dialog::display(_("Error"), msgPool::permCreate(), ERROR_DIALOG);
823 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
824 $acls, "<b>Insufficient permissions!</b>");
825 continue;
826 }else{
828 // Open object an preset some values like the objects base
829 del_lock($dn);
830 management::editEntry('editEntry',array($dn),array(),$tabClass,$tabDesc, $aclCategory);
831 $this->displayApplyBtn = FALSE;
832 $this->tabObject->set_acl_base($headpage->getBase());
834 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
835 $data['OG'], "<b>Selected ogroup:</b>");
837 if($data['OG'] != "none"){
838 $this->tabObject->base = preg_replace("/^[^,]+,".preg_quote(get_ou('ogroupRDN'), '/')."/i", "", $data['OG']);
839 $this->tabObject->by_object[$plugClass]->base = $this->tabObject->base;
840 } else {
841 $this->tabObject->by_object[$plugClass]->base = $headpage->getBase();
842 $this->tabObject->base = $headpage->getBase();
843 }
845 // Assign some default values for opsi hosts
846 if($this->tabObject instanceOf opsi_tabs){
847 $ldap = $this->config->get_ldap_link();
848 $ldap->cat($dn);
849 $source_attrs = $ldap->fetch();
850 foreach(array("macAddress" => "mac" ,"cn" => "hostId","description" => "description") as $src => $attr){
851 if(isset($source_attrs[$src][0])){
852 $this->tabObject->by_object['opsiGeneric']->$attr = $source_attrs[$src][0];
853 }
854 }
855 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
856 "", "<b>OPSI attributes adapted</b>");
857 }
859 // Queue entry to be activated, when it is saved.
860 if($data['OG'] != "none"){
862 // Set gotoMode to active if there was an ogroup selected.
863 $found = false;
864 foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"active") as $tab => $value){
865 if(isset($this->tabObject->by_object[$tab]->gotoMode)) {
866 $found = true;
867 $this->tabObject->by_object[$tab]->gotoMode = $value;
868 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
869 $tab."->gotoMode = {$value}", "<b>Setting gotoMode to: </b>");
870 }
871 }
872 if(!$found){
873 msg_dialog::display(_("Internal error"), _("Cannot set mode to 'active'!"), ERROR_DIALOG);
874 }
876 // Update object group membership
877 $og = new ogroup($this->config,$data['OG']);
878 if($og){
879 $og->AddDelMembership($this->tabObject->dn);
880 $og->save();
881 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
882 $og->dn, "<b>Adding system to ogroup</b>");
883 }
885 // Set default system specific attributes
886 foreach (array("workgeneric", "termgeneric") as $cls){
887 if (isset($this->tabObject->by_object[$cls])){
888 $this->tabObject->by_object[$cls]->set_everything_to_inherited();
889 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
890 $og->dn, "<b>Calling {$cls}->set_everything_to_inherited()</b>");
891 }
892 }
894 // Enable activation
895 foreach (array("servgeneric", "workgeneric", "termgeneric") as $cls){
896 if (isset($this->tabObject->by_object[$cls])){
897 $this->tabObject->by_object[$cls]->auto_activate= TRUE;
898 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
899 $cls, "<b>Setting auto_activate=TRUE for</b>");
900 }
901 }
903 // Enable sending of LDAP events
904 if (isset($this->tabObject->by_object["workstartup"])){
905 $this->tabObject->by_object["workstartup"]->gotoLdap_inherit= TRUE;
906 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
907 "", "<b>Setting workstartup->gotoLdap_inherit=TRUE</b>");
908 }
909 }
911 // Try to inherit everythin from the selected object group and then save
912 // the entry, normally this should work without any problems.
913 // But if there is any, then display the dialogs.
914 if($data['OG'] != "none"){
915 $str = $this->saveChanges();
917 // There was a problem, skip activation here and allow to fix the problems..
918 if(is_object($this->tabObject)){
919 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
920 "", "<b>Automatic saving failed, let the user fix the issues now.</b>");
921 return;
922 }
923 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
924 "", "<b>System activated!</b>");
925 }else{
926 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
927 "", "<b>Open dialogs now</b>");
928 return;
929 }
930 }
931 }
932 }
933 }
936 /*! \brief Save object modifications here and any dialogs too.
937 * After a successfull update of the object data, close
938 * the dialogs.
939 */
940 protected function saveChanges()
941 {
942 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
943 get_class($this->tabObject).": ".$this->tabObject->dn, "<b>Save</b>");
945 // Handle 'New Unknown Devices' here.
946 if($this->tabObject instanceOf ArpNewDeviceTabs){
947 $this->tabObject->save_object();
949 if($this->tabObject->by_object['ArpNewDevice']->gotoIntegration){
950 $message = $this->tabObject->check();
951 if(count($message)){
952 msg_dialog::displayChecks($message);
953 }else{
954 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
955 get_class($this->tabObject).": ".$this->tabObject->dn, "<b>Queued for goto activation</b>");
956 $this->tabObject->save();
957 $this->activationQueue[$this->tabObject->dn]=array();
958 $this->closeDialogs();
959 $this->systemTypeChosen();
960 }
961 return;
962 }
963 }
965 // Try to save changes here.
966 $str = management::saveChanges();
967 if($this->tabObject) return("");
969 // Activate system if required..
970 if(isset($this->activationQueue[$this->last_dn])){
971 $dn = $this->last_tabObject->dn;
972 $this->activate_new_device($dn);
973 unset($this->activationQueue[$this->last_dn]);
974 }
976 /* Post handling for activated systems
977 target opsi -> Remove source.
978 target gosa -> Activate system.
979 */
980 if($this->last_tabObject instanceOf opsi_tabs){
981 $ldap = $this->config->get_ldap_link();
982 $ldap->cd($this->config->current['BASE']);
983 $ldap->rmdir ($this->last_tabObject->dn);
984 @DEBUG(DEBUG_LDAP,__LINE__, __FUNCTION__, __FILE__,
985 "Source removed: ".$this->tabObject->dn,"<b>Opsi host activated</b>");
987 $hostId = $this->last_tabObject->by_object['opsiGeneric']->hostId;
988 $mac = $this->last_tabObject->by_object['opsiGeneric']->mac;
989 $this->opsi->job_opsi_activate_client($hostId,$mac);
991 }elseif(isset($this->last_tabObject->was_activated) && $this->last_tabObject->was_activated){
992 $this->activate_new_device($this->last_tabObject->dn);
993 }
995 // Avoid using values from an older input dialog
996 $_POST = array();
997 $this->handleActivationQueue();
998 }
1001 /*! \brief Save object modifications here and any dialogs too.
1002 * Keep dialogs opened.
1003 */
1004 protected function applyChanges()
1005 {
1006 $str = management::applyChanges();
1007 if($str) return($str);
1009 /* Post handling for activated systems
1010 target opsi -> Remove source.
1011 target gosa -> Activate system.
1012 */
1013 if($this->tabObject instanceOf opsi_tabs){
1014 $ldap = $this->config->get_ldap_link();
1015 $ldap->cd($this->config->current['BASE']);
1016 $ldap->rmdir ($this->tabObject->dn);
1017 @DEBUG(DEBUG_LDAP,__LINE__, __FUNCTION__, __FILE__,
1018 "Source removed: ".$this->tabObject->dn,"<b>Opsi host activated</b>");
1020 $hostId = $this->tabObject->by_object['opsiGeneric']->hostId;
1021 $mac = $this->tabObject->by_object['opsiGeneric']->mac;
1022 $this->opsi->job_opsi_activate_client($hostId,$mac);
1024 }elseif(isset($this->tabObject->was_activated) && $this->tabObject->was_activated){
1025 $this->activate_new_device($this->tabObject->dn);
1026 }
1027 }
1030 /*! \brief Sets FAIstate to "install" for "New Devices".
1031 This function is some kind of "Post handler" for activated systems,
1032 it is called directly after the object (workstabs,servtabs) gets saved.
1033 @param String $dn The dn of the newly activated object.
1034 @return Boolean TRUE if activated else FALSE
1035 */
1036 function activate_new_device($dn)
1037 {
1038 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
1039 $dn, "<b>Activating system:</b>");
1040 $ldap = $this->config->get_ldap_link();
1041 $ldap->cd($this->config->current['BASE']);
1042 $ldap->cat($dn);
1043 if($ldap->count()){
1044 $attrs = $ldap->fetch();
1045 if(count(array_intersect(array('goServer','gotoWorkstation'), $attrs['objectClass']))){
1046 $ocs = $attrs['objectClass'];
1047 unset($ocs['count']);
1048 $new_attrs = array();
1049 if(!in_array("FAIobject",$ocs)){
1050 $ocs[] = "FAIobject";
1051 $new_attrs['objectClass'] = $ocs;
1052 }
1053 $new_attrs['FAIstate'] = "install";
1054 $ldap->cd($dn);
1055 $ldap->modify($new_attrs);
1056 if (!$ldap->success()){
1057 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn,
1058 LDAP_MOD, "activate_new_device($dn)"));
1059 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
1060 $dn, "<b>Failed!</b>");
1061 }else{
1062 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
1063 $dn, "<b>Success</b>");
1064 return(TRUE);
1065 }
1066 }else{
1067 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
1068 $dn, "<b>FAIstate not set to install, this is only done for gotoWorkstation/goServer!</b>");
1069 }
1070 }
1071 return(FALSE);
1072 }
1075 /*! \brief Opens the snapshot creation dialog for the given target.
1076 *
1077 * @param String 'action' The name of the action which was the used as trigger.
1078 * @param Array 'target' A list of object dns, which should be affected by this method.
1079 * @param Array 'all' A combination of both 'action' and 'target'.
1080 */
1081 function createSnapshotDialog($action="",$target=array(),$all=array())
1082 {
1083 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Snaptshot creation initiated!");
1085 $pInfo = $this->getObjectDefinitions();
1086 $headpage = $this->getHeadpage();
1087 foreach($target as $dn){
1089 $entry = $headpage->getEntry($dn);
1090 $type = $headpage->getType($dn);
1091 if(!isset($pInfo[$type])) {
1092 trigger_error('Unknown system type \''.$type.'\'!');
1093 return;
1094 }
1096 if(!empty($dn) && $this->ui->allow_snapshot_create($dn,$pInfo[$type]['aclCategory'])){
1097 $this->dialogObject = new SnapShotDialog($this->config,$dn,$this);
1098 $this->dialogObject->aclCategories = array($pInfo[$type]['aclCategory']);
1099 $this->dialogObject->parent = &$this;
1101 }else{
1102 msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to create a snapshot for %s."),$dn),
1103 ERROR_DIALOG);
1104 }
1105 }
1106 }
1109 /*! \brief Displays the "Restore snapshot dialog" for a given target.
1110 * If no target is specified, open the restore removed object
1111 * dialog.
1112 * @param String 'action' The name of the action which was the used as trigger.
1113 * @param Array 'target' A list of object dns, which should be affected by this method.
1114 * @param Array 'all' A combination of both 'action' and 'target'.
1115 */
1116 function restoreSnapshotDialog($action="",$target=array(),$all=array())
1117 {
1118 // Set current restore base for snapshot handling.
1119 $headpage = $this->getHeadpage();
1120 $pInfo = $this->getObjectDefinitions();
1121 if(is_object($this->snapHandler)){
1122 $bases = array();
1123 foreach($this->storagePoints as $sp){
1124 $bases[] = $sp.$headpage->getBase();
1125 }
1126 }
1128 // No bases specified? Try base
1129 if(!count($bases)) $bases[] = $this->headpage->getBase();
1131 // No target, open the restore removed object dialog.
1132 if(!count($target)){
1134 $cats = array();
1135 foreach($pInfo as $data){
1136 $cats[] = $data['aclCategory'];
1137 }
1138 $cats = array_unique($cats);
1140 $entry = $headpage->getBase();
1141 if(!empty($entry) && $this->ui->allow_snapshot_restore($entry,$cats)){
1142 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$entry,"Snaptshot restoring initiated!");
1143 $this->dialogObject = new SnapShotDialog($this->config,$entry,$this);
1144 $this->dialogObject->set_snapshot_bases($bases);
1145 $this->dialogObject->display_all_removed_objects = true;
1146 $this->dialogObject->display_restore_dialog = true;
1147 $this->dialogObject->parent = &$this;
1148 }else{
1149 msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s."),$entry),
1150 ERROR_DIALOG);
1151 }
1152 }else{
1154 // Display the restore points for a given object.
1155 $dn = array_pop($target);
1156 $entry = $headpage->getEntry($dn);
1157 $type = $headpage->getType($dn);
1158 if(!isset($pInfo[$type])) {
1159 trigger_error('Unknown system type \''.$type.'\'!');
1160 return;
1161 }
1163 if(!empty($dn) && $this->ui->allow_snapshot_create($dn,$pInfo[$type]['aclCategory'])){
1164 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Snaptshot restoring initiated!");
1165 $this->dialogObject = new SnapShotDialog($this->config,$dn,$this);
1166 $this->dialogObject->set_snapshot_bases($bases);
1167 $this->dialogObject->display_restore_dialog = true;
1168 $this->dialogObject->parent = &$this;
1169 }else{
1170 msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s."),$dn),
1171 ERROR_DIALOG);
1172 }
1173 }
1174 }
1177 /*! \brief Restores a snapshot object.
1178 * The dn of the snapshot entry has to be given as ['target'] parameter.
1179 *
1180 * @param String 'action' The name of the action which was the used as trigger.
1181 * @param Array 'target' A list of object dns, which should be affected by this method.
1182 * @param Array 'all' A combination of both 'action' and 'target'.
1183 */
1184 function restoreSnapshot($action="",$target=array(),$all=array())
1185 {
1186 $dn = array_pop($target);
1187 $this->snapHandler->restore_snapshot($dn);
1188 @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Snaptshot restored!");
1189 $this->closeDialogs();
1190 }
1193 /*! \brief Detects actions/events send by the ui
1194 * and the corresponding targets.
1195 */
1196 function detectPostActions()
1197 {
1198 $action= management::detectPostActions();
1199 if(isset($_POST['abort_event_dialog'])) $action['action'] = "cancel";
1200 if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEvent";
1201 if(isset($_POST['cd_create'])) $action['action'] = "initiateISOcreation";
1202 if(isset($_GET['PerformIsoCreation'])) $action['action'] = "performIsoCreation";
1203 if(isset($_POST['SystemTypeAborted'])) $action['action'] = "cancel";
1204 if(isset($_POST['password_cancel'])) $action['action'] = "cancel";
1205 if(isset($_POST['password_finish'])) $action['action'] = "passwordChangeConfirmed";
1207 if(isset($_POST['new_goServer'])) $action['action'] = "new_goServer";
1208 if(isset($_POST['new_gotoWorkstation'])) $action['action'] = "new_gotoWorkstation";
1209 if(isset($_POST['new_gotoTerminal'])) $action['action'] = "new_gotoTerminal";
1210 if(isset($_POST['new_gotoPrinter'])) $action['action'] = "new_gotoPrinter";
1211 if(isset($_POST['new_goFonHardware'])) $action['action'] = "new_goFonHardware";
1212 if(isset($_POST['new_ieee802Device'])) $action['action'] = "new_ieee802Device";
1213 if(isset($_POST['new_FAKE_OC_OpsiHost'])) $action['action'] = "new_FAKE_OC_OpsiHost";
1215 if(!is_object($this->tabObject) && !is_object($this->dialogObject)){
1216 if(count($this->activationQueue)) $action['action'] = "handleActivationQueue";
1217 }
1219 if(isset($_POST['systemTypeChosen'])) $action['action'] = "systemTypeChosen";
1221 return($action);
1222 }
1225 /*! \brief Overridden render method of class management.
1226 * this allows us to add a release selection box.
1227 */
1228 function renderList()
1229 {
1230 $headpage = $this->getHeadpage();
1231 $headpage->update();
1233 $tD = $this->getObjectDefinitions();
1234 $smarty = get_smarty();
1235 foreach($tD as $name => $obj){
1236 $smarty->assign("USE_".$name, (empty($obj['TABNAME']) || class_available($obj['TABNAME'])));
1237 }
1239 $display = $headpage->render();
1240 return($this->getHeader().$display);
1241 }
1244 public function getObjectDefinitions()
1245 {
1246 $tabs = array(
1247 "FAKE_OC_OpsiHost" => array(
1248 "ou" => "",
1249 "plugClass" => "opsiGeneric",
1250 "tabClass" => "opsi_tabs",
1251 "tabDesc" => "OPSITABS",
1252 "aclClass" => "opsiGeneric",
1253 "sendEvents" => TRUE,
1254 "aclCategory" => "opsi"),
1256 "goServer" => array(
1257 "ou" => get_ou('serverRDN'),
1258 "plugClass" => "servgeneric",
1259 "tabClass" => "servtabs",
1260 "tabDesc" => "SERVTABS",
1261 "aclClass" => "servgeneric",
1262 "sendEvents" => TRUE,
1263 "aclCategory" => "server"),
1265 "gotoWorkstation" => array(
1266 "ou" => get_ou('workstationRDN'),
1267 "plugClass" => "workgeneric",
1268 "tabClass" => "worktabs",
1269 "tabDesc" => "WORKTABS",
1270 "aclClass" => "workgeneric",
1271 "sendEvents" => TRUE,
1272 "aclCategory" => "workstation"),
1274 "gotoTerminal" => array(
1275 "ou" => get_ou('terminalRDN'),
1276 "plugClass" => "termgeneric",
1277 "tabClass" => "termtabs",
1278 "sendEvents" => TRUE,
1279 "tabDesc" => "TERMTABS",
1280 "aclClass" => "termgeneric",
1281 "aclCategory" => "terminal"),
1283 "gotoPrinter" => array(
1284 "ou" => get_ou('printerRDN'),
1285 "plugClass" => "printgeneric",
1286 "tabClass" => "printtabs",
1287 "tabDesc" => "PRINTTABS",
1288 "aclClass" => "printgeneric",
1289 "sendEvents" => FALSE,
1290 "aclCategory" => "printer"),
1292 "FAKE_OC_NewDevice" => array(
1293 "ou" => get_ou('systemIncomingRDN'),
1294 "plugClass" => "termgeneric",
1295 "tabClass" => "termtabs",
1296 "sendEvents" => TRUE,
1297 "tabDesc" => "TERMTABS",
1298 "aclClass" => "termgeneric",
1299 "aclCategory" => "terminal"),
1301 "goFonHardware" => array(
1302 "ou" => get_ou('phoneRDN'),
1303 "plugClass" => "phoneGeneric",
1304 "tabClass" => "phonetabs",
1305 "tabDesc" => "PHONETABS",
1306 "sendEvents" => FALSE,
1307 "aclClass" => "phoneGeneric",
1308 "aclCategory" => "phone"),
1310 "FAKE_OC_winstation" => array(
1311 "ou" => get_winstations_ou(),
1312 "plugClass" => "wingeneric",
1313 "sendEvents" => TRUE,
1314 "tabClass" => "wintabs",
1315 "tabDesc" => "WINTABS",
1316 "aclClass" => "wingeneric",
1317 "aclCategory" => "winworkstation"),
1319 "ieee802Device" => array(
1320 "ou" => get_ou('componentRDN'),
1321 "plugClass" => "componentGeneric",
1322 "sendEvents" => FALSE,
1323 "tabClass" => "componenttabs",
1324 "tabDesc" => "COMPONENTTABS",
1325 "aclClass" => "componentGeneric",
1326 "aclCategory" => "component"),
1327 );
1329 // Now map some special types
1330 $tabs['FAKE_OC_NewWorkstation'] = &$tabs['gotoWorkstation'];
1331 $tabs['FAKE_OC_NewTerminal'] = &$tabs['gotoTerminal'];
1332 $tabs['FAKE_OC_NewServer'] = &$tabs['gotoWorkstation'];
1333 $tabs['gotoWorkstation__IS_BUSY'] = &$tabs['gotoWorkstation'];
1334 $tabs['gotoWorkstation__IS_ERROR'] = &$tabs['gotoWorkstation'];
1335 $tabs['gotoWorkstation__IS_LOCKED'] = &$tabs['gotoWorkstation'];
1336 $tabs['gotoTerminal__IS_BUSY'] = &$tabs['gotoTerminal'];
1337 $tabs['gotoTerminal__IS_ERROR'] = &$tabs['gotoTerminal'];
1338 $tabs['gotoTerminal__IS_LOCKED'] = &$tabs['gotoTerminal'];
1339 $tabs['FAKE_OC_TerminalTemplate'] = &$tabs['gotoTerminal'];
1340 $tabs['FAKE_OC_WorkstationTemplate'] = &$tabs['gotoTerminal'];
1341 $tabs['goServer__IS_BUSY'] = &$tabs['goServer'];
1342 $tabs['goServer__IS_ERROR'] = &$tabs['goServer'];
1343 $tabs['goServer__IS_LOCKED'] = &$tabs['goServer'];
1345 $tabs['FAKE_OC_ArpNewDevice'] = &$tabs['FAKE_OC_NewDevice'];
1347 return($tabs);
1348 }
1351 function systemDescription($a,$b,$c,$d)
1352 {
1353 global $config;
1355 // A ... solution, but I can't figure out a better solution right now.
1356 $headpage = session::get('SYSTEMS_DESCRIPTION_FILTER');
1357 if(!is_object($headpage)) return($str);
1358 $str = $headpage->filterLink($a,$b,$c,$d);
1359 $ldap = $config->get_ldap_link();
1360 $ldap->cd($config->current['BASE']);
1361 $ldap->search("(&(objectClass=gosaGroupOfNames)(member=".$b."))");
1362 while($attrs = $ldap->fetch()){
1363 $str .= " <img class='center' src='plugins/ogroups/images/ogroup.png'
1364 title='"._("Object group member")."'
1365 alt='("._("Object group member").")' >";
1366 return($str);
1367 }
1369 return($str);
1370 }
1373 /*! \brief !! Incoming dummy acls, required to defined acls for incoming objects
1374 */
1375 static function plInfo()
1376 {
1377 return (array(
1378 "plShortName" => _("Incoming objects"),
1379 "plDescription" => _("Incoming objects"),
1380 "plSelfModify" => FALSE,
1381 "plDepends" => array(),
1382 "plPriority" => 99,
1383 "plSection" => array("administration"),
1384 "plCategory" => array("incoming" => array( "description" => _("Incoming"),
1385 "objectClass" => "")),
1386 "plProvidedAcls"=> array()
1387 ));
1388 }
1389 }
1390 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1391 ?>