c3ee3c88dd65c38d54b4795a70e49b31fa5b597a
1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 require "tabs_terminal.inc";
21 require "tabs_workstation.inc";
22 require "tabs_printers.inc";
23 require "tabs_phone.inc";
24 require "tabs_server.inc";
25 require "tabs_component.inc";
26 require "tabs_winstation.inc";
29 class systems extends plugin
30 {
31 /* Definitions */
32 var $plHeadline= "Systems";
33 var $plDescription= "This does something";
34 var $departments=array();
36 /* Dialog attributes */
37 var $systab= NULL;
38 var $terminals= array();
39 var $ui= NULL;
40 var $acl= "";
41 var $DivListSystem;
43 function systems ($config, $ui)
44 {
45 /* Save configuration for internal use */
46 $this->config= $config;
47 $this->ui= $ui;
49 /* Creat dialog object */
50 $this->DivListSystem = new divListSystem($this->config,$this);
51 }
53 function execute()
54 {
55 /* Call parent execute */
56 plugin::execute();
58 $_SESSION['LOCK_VARS_TO_USE'] = array("/^user_edit_/i","/^user_del_/","/^act/","/^id/");
60 /********************
61 Check for functional posts, edit|delete|add|... system devices
62 ********************/
63 $s_action = ""; // Contains the action to proceed
64 $s_entry = ""; // The value for s_action
65 $base_back = ""; // The Link for Backbutton
66 $smarty = get_smarty();
68 /* Test Posts */
69 foreach($_POST as $key => $val){
70 // Post for delete
71 if(preg_match("/user_del.*/",$key)){
72 $s_action = "del";
73 $s_entry = preg_replace("/user_".$s_action."_/i","",$key);
74 // Post for edit
75 }elseif(preg_match("/user_edit_.*/",$key)){
76 $s_action="edit";
77 $s_entry = preg_replace("/user_".$s_action."_/i","",$key);
78 // Post for new
79 }elseif(preg_match("/user_new.*/",$key)){
80 $s_action="new";
81 }elseif(preg_match("/user_tplnew.*/i",$key)){
82 $s_action="new_tpl";
83 }elseif(preg_match("/user_setpwd_.*/i",$key)){
84 $s_action="change_pw";
85 $s_entry = preg_replace("/user_setpwd_/i","",$key);
86 }elseif(preg_match("/newsystem_.*/i",$key)){
87 $s_action="newsystem";
88 $s_entry = preg_replace("/newsystem_/i","",$key);
89 }
90 }
92 /* Incoming handling
93 * If someone made a systemtype and ogroup selection
94 * Display the new requested entry type ... servtab in case of server and so on.
95 */
96 if(isset($_POST['SystemTypeChoosen'])){
97 $s_action = "SelectedSystemType";
98 $s_entry = $_POST['SystemType'];
99 $_SESSION['SelectedSystemType']['ogroup'] = $_POST['ObjectGroup'];
100 $this->systab = NULL;
101 }
103 /* remove image tags from posted entry (posts looks like this 'name_x')*/
104 $s_entry = preg_replace("/_.$/","",$s_entry);
106 /* Edit was requested by pressing the name(link) of an item */
107 if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
108 $s_action ="edit";
109 $s_entry = $_GET['id'];
110 }
112 /* Save Termfilter .... */
113 $this->reload();
115 /* Check for exeeded sizelimit */
116 if (($message= check_sizelimit()) != ""){
117 return($message);
118 }
120 /* Try to get informations about what kind of system to create */
121 if ($s_action=="new") {
122 return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
123 }
125 /********************
126 Create new system ...
127 ********************/
128 /* Create new default terminal
129 * Or create specified object of selected system type, from given incoming object
130 */
131 if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") {
133 /* If the current entry is an incoming object
134 * $sw = System type as posted in new incoming handling dialog
135 */
136 if($s_action == "SelectedSystemType") {
137 $sw = $s_entry;
138 }else{
139 if(isset($_POST['system'])){
140 $sw = $_POST['system'];
141 }else{
142 $sw = $s_entry;
143 }
144 $this->dn= "new";
145 }
146 $this->acl= array(":all");
147 $tabs = array(
148 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs"),
149 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs"),
150 "server" => array("CLASS"=>"SERVTABS", "TABNAME"=>"servgeneric", "TABCLASS" =>"servtabs"),
151 "printer" => array("CLASS"=>"PRINTTABS", "TABNAME"=>"printgeneric", "TABCLASS" =>"printtabs"),
152 "phone" => array("CLASS"=>"PHONETABS", "TABNAME"=>"phonegeneric", "TABCLASS" =>"phonetabs"),
153 "component" => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentgeneric","TABCLASS" =>"componenttabs"));
155 if(isset($tabs[$sw])){
156 $class = $tabs[$sw]["CLASS"];
157 $tabname = $tabs[$sw]["TABNAME"];
158 $tabclass = $tabs[$sw]["TABCLASS"];
159 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn);
160 $this->systab->set_acl ($this->acl);
161 $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
162 $this->systab->base = $this->DivListSystem->selectedBase;
163 }
164 }
166 /********************
167 Edit system ...
168 ********************/
170 /* User wants to edit data? */
171 if (($s_action == "edit") && (!isset($this->systab->config))){
173 $this->dn= $this->terminals[$s_entry]['dn'];
175 /* Check locking, save current plugin in 'back_plugin', so
176 the dialog knows where to return. */
177 if (($user= get_lock($this->dn)) != ""){
178 return(gen_locked_message ($user, $this->dn));
179 }
181 /* Set up the users ACL's for this 'dn' */
182 $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
184 /* Find out more about the object type */
185 $ldap= $this->config->get_ldap_link();
186 $ldap->cat($this->dn);
187 $attrs= $ldap->fetch();
188 $type= $this->get_system_type($attrs['objectClass']);
190 /* Lock the current entry, so everyone will get the
191 above dialog */
192 $tabs = array(
193 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs"),
194 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs"),
195 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs"),
196 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs"),
197 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs"),
198 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs"),
199 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs"));
202 if($type == "NewDevice"){
203 $this->systab = new SelectDeviceType($this->config,$this->dn) ;
204 }elseif(isset($tabs[$type])){
206 $class = $tabs[$type]["CLASS"];
207 $tabclass = $tabs[$type]["TABCLASS"];
209 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn);
210 $this->systab->set_acl($acl);
211 $_SESSION['objectinfo']= $this->dn;
212 add_lock ($this->dn, $this->ui->dn);
213 }else{
214 print_red (_("You can't edit this object type yet!"));
215 del_lock($this->dn);
216 }
217 }
220 /********************
221 Change password ...
222 ********************/
224 /* Set terminals root password */
225 if ($s_action=="change_pw"){
226 $this->dn= $this->terminals[$s_entry]['dn'];
227 $_SESSION['objectinfo']= $this->dn;
228 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
229 }
232 /********************
233 Password cahnge finish, but check if entered data is ok
234 ********************/
236 /* Correctly specified? */
237 if (isset($_POST['password_finish'])){
238 if ($_POST['new_password'] != $_POST['repeated_password']){
239 print_red (_("Passwords entered as new and repeated do not match!"));
240 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
241 }
242 }
244 /********************
245 Password change finish
246 ********************/
248 /* Change terminal password */
249 if (isset($_POST['password_finish']) &&
250 $_POST['new_password'] == $_POST['repeated_password']){
252 /* Check if user is allowed to set password */
253 $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
254 $acl= get_module_permission($acl, "terminal", $this->dn);
255 if (chkacl($acl, "password") != ""){
256 print_red (_("You are not allowed to set this systems password!"));
257 } else {
258 $ldap= $this->config->get_ldap_link();
259 $ldap->cd($this->dn);
261 $attrs= array();
262 if ($_POST['new_password'] == ""){
263 $attrs['gotoRootPasswd']= array();
264 } else {
265 $attrs['gotoRootPasswd']= crypt($_POST['new_password'],
266 substr(session_id(),0,2));
267 }
268 $ldap->modify($attrs);
269 gosa_log ("Password for '".$this->dn."' has been changed");
270 }
271 unset($_SESSION['objectinfo']);
272 }
275 /********************
276 Delete system cancel
277 ********************/
279 /* Delete terminal canceled? */
280 if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
281 del_lock ($this->dn);
282 unset($_SESSION['objectinfo']);
283 }
286 /********************
287 Delete system, confirm dialog
288 ********************/
290 /* Remove terminal was requested */
291 if ($s_action=="del"){
293 /* Get 'dn' from posted termlinst */
294 $this->dn= $this->terminals[$s_entry]['dn'];
296 /* Load permissions for selected 'dn' and check if
297 we're allowed to remove this 'dn' */
298 $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
299 $this->acl= get_module_permission($acl, "terminal", $this->dn);
300 if (chkacl($this->acl, "delete") == ""){
302 /* Check locking, save current plugin in 'back_plugin', so
303 the dialog knows where to return. */
304 if (($user= get_lock($this->dn)) != ""){
305 return(gen_locked_message ($user, $this->dn));
306 }
308 /* Lock the current entry, so nobody will edit it during deletion */
309 add_lock ($this->dn, $this->ui->dn);
310 $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), LDAP::fix($this->dn)));
311 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
312 } else {
314 /* Obviously the user isn't allowed to delete. Show message and
315 clean session. */
316 print_red (_("You are not allowed to delete this component!"));
317 }
318 }
321 /********************
322 Delete system, confirmed
323 ********************/
324 /* Confirmation for deletion has been passed. Terminal should be deleted. */
325 if (isset($_POST['delete_terminal_confirm'])){
327 /* Some nice guy may send this as POST, so we've to check
328 for the permissions again. */
329 if (chkacl($this->acl, "delete") == ""){
331 /* Find out more about the object type */
332 $ldap= $this->config->get_ldap_link();
333 $ldap->cat($this->dn);
334 $attrs= $ldap->fetch();
335 $type= $this->get_system_type($attrs['objectClass']);
337 $tabs = array(
338 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs"),
339 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs"),
340 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs"),
341 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs"),
342 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs"),
343 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs"),
344 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs"));
346 /* get object type */
347 $tabtype = "termtabs";
348 $tabobj = "TERMTABS";
349 if(isset($tabs[$type])){
350 $tabtype = $tabs[$type]['TABCLASS'];
351 $tabobj = $tabs[$type]['CLASS'];
352 }
354 /* Delete request is permitted, perform LDAP action */
355 if($tabtype=="phonetabs"){
356 $this->systab= new $tabtype($this->config,
357 $this->config->data['TABS'][$tabobj], $this->dn);
358 $this->systab->set_acl(array($this->acl));
359 $this->systab->by_object['phonegeneric']->remove_from_parent ();
360 }else{
361 $this->systab= new $tabtype($this->config,
362 $this->config->data['TABS'][$tabobj], $this->dn);
363 $this->systab->set_acl(array($this->acl));
364 $this->systab->delete();
365 #$this->systab->by_object['termgeneric']->remove_from_parent ();
366 }
367 unset ($this->systab);
368 gosa_log ("System object'".$this->dn."' has been removed");
369 $this->systab= NULL;
371 /* Terminal list has changed, reload it. */
372 $this->reload ();
373 } else {
375 /* Normally this shouldn't be reached, send some extra
376 logs to notify the administrator */
377 print_red (_("You are not allowed to delete this component!"));
378 gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
379 "deletion.");
380 }
382 /* Remove lock file after successfull deletion */
383 del_lock ($this->dn);
384 }
387 /********************
388 Edit system type finished, check if everything went ok
389 ********************/
390 /* Finish user edit is triggered by the tabulator dialog, so
391 the user wants to save edited data. Check and save at this
392 point. */
393 if ((isset($_POST['edit_finish'])) && (isset($this->systab->config))){
395 /* Check tabs, will feed message array */
396 $message= $this->systab->check();
398 /* Save, or display error message? */
399 if (count($message) == 0){
401 /* Save terminal data to ldap */
402 gosa_log ("System object'".$this->dn."' has been saved");
403 $this->systab->save();
405 /* Incoming behavior; you can select a system type and an ogroup membership.
406 * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset.
407 * Check if we must add the new object to an object group.
408 *
409 * If this is done, delete the old incoming entry... it is still there, because this is a new
410 * entry and not an edited one, so we will delete it.
411 */
413 if(isset($_SESSION['SelectedSystemType'])){
414 $SelectedSystemType= $_SESSION['SelectedSystemType'];
415 unset($_SESSION['SelectedSystemType']);
416 if($SelectedSystemType['ogroup'] != "none"){
417 $og = new ogroup($this->config,$SelectedSystemType['ogroup']);
418 if($og){
419 $og->AddDelMembership($this->systab->dn);
420 $og->save();
421 }
422 }
423 if(!isset($ldap)){
424 $ldap = $this->config->get_ldap_link();
425 }
426 $ldap->cd ($this->dn);
427 $ldap->cat($this->dn);
428 if(count($ldap->fetch())){
429 $ldap->cd($this->dn);
430 $ldap->rmDir($this->dn);
431 }
432 $ldap->cd($this->config->current['BASE']);
433 }
435 /* Terminal has been saved successfully, remove lock from
436 LDAP. */
437 if ($this->dn != "new"){
438 del_lock ($this->dn);
439 }
441 /* There's no page reload so we have to read new terminals at
442 this point. */
443 $this->reload ();
444 unset ($this->systab);
445 $this->systab= NULL;
446 unset($_SESSION['objectinfo']);
447 } else {
448 /* Ok. There seem to be errors regarding to the tab data,
449 show message and continue as usual. */
450 show_errors($message);
451 }
452 }
454 /********************
455 Edit system was canceled
456 ********************/
457 /* Cancel dialogs */
458 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){
459 if (isset($this->systab)){
460 del_lock ($this->systab->dn);
461 unset ($this->systab);
462 }
463 $this->systab= NULL;
464 unset($_SESSION['objectinfo']);
466 /* Remove ogroup selection, which was set while editing a new incoming entry */
467 if(isset($_SESSION['SelectedSystemType'])){
468 unset($_SESSION['SelectedSystemType']);
469 }
470 }
472 /********************
473 Display edit dialog, or some other
474 ********************/
476 /* Show tab dialog if object is present */
477 if (isset($this->systab->config)){
478 $display= $this->systab->execute();
480 /* Don't show buttons if tab dialog requests this */
481 if ((isset($this->systab->by_object))&&(!$this->systab->by_object[$this->systab->current]->dialog)){
482 $display.= "<p style=\"text-align:right\">\n";
483 $display.= "<input type=\"submit\" name=\"edit_finish\" value=\""._("Save")."\">\n";
484 $display.= " \n";
485 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
486 $display.= "</p>";
487 }
488 return ($display);
489 }
491 /* Display dialog with system list */
492 $this->DivListSystem->execute();
493 $this->DivListSystem->setEntries($this->terminals);
494 return($this->DivListSystem->Draw());
495 }
499 function remove_from_parent()
500 {
501 /* Optionally execute a command after we're done */
502 $this->postremove();
503 }
506 /* Save data to object */
507 function save_object()
508 {
509 $this->DivListSystem->save_object();
510 }
513 /* Check values */
514 function check()
515 {
516 }
519 /* Save to LDAP */
520 function save()
521 {
522 }
524 function adapt_from_template($dn)
525 {
526 }
528 function password_change_needed()
529 {
530 }
532 function reload()
533 {
534 /* Load terminal shortcuts */
535 $responsible= array();
536 foreach ($this->config->departments as $key => $value){
537 if (get_module_permission(get_permissions ($value, $this->ui->subtreeACL),
538 "terminal", $value) == "#all#"){
539 $responsible[$key]= $value;
540 }
541 }
543 /* some var init */
544 $res = array();
545 $this->terminals = array();
546 $userregex = "";
548 /* Set base for all searches */
549 $base= $this->DivListSystem->selectedBase;
551 /* Prepare samba class name */
552 $samba ="";
553 if ($this->DivListSystem->ShowWinWorkstations){
554 if ($this->config->current['SAMBAVERSION'] == "3"){
555 $samba= "sambaSamAccount";
556 } else {
557 $samba= "sambaAccount";
558 }
559 }
561 /* This array represents the combination between checkboxes and search filters */
562 $objs = array( "ShowServers" => array("CLASS" => "goServer" ,"TREE" => "ou=servers,ou=systems," ),
563 "ShowTerminals" => array("CLASS" => "goHard" ,"TREE" => "ou=terminals,ou=systems,"),
564 "ShowPrinters" => array("CLASS" => "gotoPrinter" ,"TREE" => "ou=printers,ou=systems," ),
565 "ShowDevices" => array("CLASS" => "ieee802Device" ,"TREE" => "ou=netdevices,ou=systems," ),
566 "ShowPhones" => array("CLASS" => "goFonHardware" ,"TREE" => "ou=phones,ou=systems," ),
567 "ShowWorkstations" => array("CLASS" => "gotoWorkstation" ,"TREE" => "ou=workstations,ou=systems," ),
568 "ShowWinWorkstations"=> array("CLASS" => $samba ,"TREE" => get_winstations_ou() ));
570 /* Include the 'Display Systems of user' attribute */
571 if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){
572 $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")";
573 }
575 /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled */
576 foreach($objs as $checkBox => $oc){
578 if($this->DivListSystem->$checkBox){
579 /* User filter? */
580 if($oc['CLASS'] != ""){
581 $filter = "(|(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex.")))";
582 $res = array_merge($res,get_list($filter,$this->ui->subtreeACL, $oc['TREE'].$base,
583 array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), GL_NONE));
584 }
585 }
586 }
588 /* Search for incoming objects */
589 $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
590 $res = array_merge($res,get_list($filter,$this->ui->subtreeACL, "ou=incoming,".$base,
591 array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), GL_NONE));
593 /* Get all gotoTerminal's */
594 foreach ($res as $value){
596 $tmp= $value['dn'];
597 $add= "";
599 /* Extract base */
600 foreach($objs as $obj){
601 if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){
602 $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn']));
603 }
604 }
606 /* check if current object is a new one */
607 if (preg_match ("/,ou=incoming,/i", $tmp)){
608 if (in_array('gotoTerminal', $value['objectClass'])){
609 $add= "- "._("New terminal");
610 }elseif (in_array('gotoWorkstation', $value['objectClass'])){
611 $add= "- "._("New workstation");
612 }elseif (in_array('GOhard', $value['objectClass'])){
613 $add= "- "._("New Device");
614 }
615 }
617 /* Detect type of object and create an entry for $this->terminals */
618 $terminal = array();
619 if ((in_array ($tmp, $responsible)) || ($add != "")){
620 if (in_array('gotoTerminal', $value["objectClass"])){
621 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
622 $terminal = $value;
623 $terminal['type'] = "T";
624 $terminal['is_new'] = $add;
625 } else {
626 $terminal = $value;
627 $terminal['type'] = "D";
628 $terminal['message'] = _("Terminal template for");
629 $terminal['location'] = array_search($tmp, $this->config->departments);
630 }
631 } elseif (in_array('gotoWorkstation', $value["objectClass"])){
632 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
633 $terminal = $value;
634 $terminal['type'] = "L";
635 $terminal['is_new'] = $add;
636 } else {
637 $terminal = $value;
638 $terminal['type'] = "D";
639 $terminal['location'] = array_search($tmp, $this->config->departments);
640 $terminal['message'] = _("Workstation template for");
641 }
642 } elseif (in_array('gotoPrinter', $value["objectClass"])){
643 $terminal = $value;
644 $terminal['type'] = "P";
645 } elseif (in_array('goServer', $value["objectClass"])){
646 $terminal = $value;
647 $terminal['type'] = "S";
648 } elseif (in_array('goFonHardware', $value["objectClass"])){
649 $terminal = $value;
650 $terminal['type'] = "F";
651 }elseif (in_array("GOhard",$value['objectClass'])){
652 $terminal = $value;
653 $terminal['type'] = "Q";
654 $terminal['is_new'] = $add;
655 } elseif (in_array('ieee802Device', $value["objectClass"])){
656 $terminal = $value;
657 $terminal['type'] = "C";
658 } else{
659 $name= preg_replace('/\$$/', '', $value['cn'][0]);
660 if (isset($value['sambaDomainName'])){
661 $domain= " [".$value['sambaDomainName'][0]."]";
662 } else {
663 $domain= "";
664 }
665 $terminal=$value;
666 $terminal['type'] ="W";
667 $terminal['domain'] = $name.$domain;
668 }
669 $this->terminals[]=$terminal;
670 }
671 }
673 $tmp=array();
674 foreach($this->terminals as $tkey => $val ){
675 $tmp[strtolower($val['cn'][0]).$val['dn']]=$val;
676 }
677 ksort($tmp);
678 $this->terminals=array();
679 foreach($tmp as $val){
680 $this->terminals[]=$val;
681 }
682 reset ($this->terminals);
683 }
685 function remove_lock()
686 {
687 if (isset($this->systab->dn)){
688 del_lock ($this->systab->dn);
689 }
690 }
693 function get_system_type($classes)
694 {
695 $type= "";
696 if (in_array('ieee802Device', $classes)){
697 $type= "component";
698 }elseif (in_array('gotoTerminal', $classes)){
699 $type= "terminal";
700 }elseif (in_array('gotoWorkstation', $classes)){
701 $type= "workstation";
702 }elseif (in_array('gotoPrinter', $classes)){
703 $type= "printer";
704 }elseif (in_array('goFonHardware', $classes)){
705 $type= "phone";
706 }elseif (in_array('goServer', $classes)){
707 $type= "server";
708 }elseif (in_array('GOhard', $classes)){
709 $type= "NewDevice";
710 }elseif (in_array('sambaAccount', $classes) ||
711 in_array('sambaSamAccount', $classes)){
712 $type= "winstation";
713 }
714 return ($type);
715 }
718 function convert_list($input)
719 {
720 $temp= "";
721 $conv= array(
722 "NQ" => array("select_newsystem.png",_("New System from incoming")),
723 "D" => array("select_default.png",_("Template")),
724 "T" => array("select_terminal.png",_("Terminal")),
725 "L" => array("select_workstation.png",_("Workstation")),
726 "F" => array("select_phone.png",_("Phone")),
727 "S" => array("select_server.png",_("Server")),
728 "W" => array("select_winstation.png",_("Winstation")),
729 "C" => array("select_component.png",_("Network Device")),
730 "NT"=> array("select_new_terminal.png",_("New Terminal")),
731 "NL"=> array("select_new_workstation.png",_("New Workstation")),
732 "P" => array("select_printer.png",_("Printer")));
734 if((isset($input['is_new']))&&(!empty($input['is_new']))){
735 $input['type']="N".$input['type'];
736 }
737 foreach ($conv as $key => $value){
738 if($input['type']==$key){
739 $tmp['img'] ="<img class='center' src='images/".$value[0]."' alt='".$key."' title='".$value['1']."'>";
740 $tmp['class']=$key;
741 return $tmp;
742 }
743 }
744 }
746 }
748 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
749 ?>