Code

353bf8e3fdf74250df6f0b08b8ac1baf18b9e098
[gosa.git] / plugins / admin / systems / class_glpiAccount.inc
1 <?php
3 class glpiAccount extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary= "Manage server basic objects";
7   var $cli_description= "Some longer text\nfor help";
8   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account= FALSE;
12   var $attributes= array("ID","name","contact",
13       "tech_num","comments","date_mod","os","location","domain","network","contact_num",
14       "model","type","is_template","FK_glpi_enterprise","deleted");
16   var $ID                 ;       // Is set if this entry is edited 
17   var $name               = "";    // This should be the dn of this entry 
18   var $contact            = "";    // Empty
19     
20   var $comments           = "";    // Comment
21   
22   var $contact_num        = "";    // Contact person
23   var $tech_num           = "";    // Technical responsible person
24   
25   var $addUser            = "";    // This is used to remember if a dialog was opened for tech_num or contact_num 
27   var $date_mod           = "";    // Modification timestamp
28   var $os                 = 0;     // Operating system
29   var $location           = 0;     // Not used yet
30   var $domain             = 0;     // ? Set to 0
31   var $network            = 0;     // ? Set to 0 
33   var $model              = 0;     // ? Can't remember this, it isn't used in GOsa 
34   var $type               = 0;     // System type id
35   var $is_template        = 0;     // Used as template ?
36   var $FK_glpi_enterprise = 0;     // Manufacturer id
37   var $deleted            = "N";   // Deleted entries should have this set to Y
39   var $renameTypeDialog   = false;
40   var $renameOSDialog     = false;
41   var $select_type        ;
42   
43   /* Not necessary, cause we use mysql databse */
44   var $objectclasses= array("whatever");
46   /* Used to remember if this was an account (simply: is this an edited entry) */
47   var $initialy_was_account = false;
49   /* Remember current dialog */
50   var $edit_type            = false;
51   var $edit_os              = false;
53   var $data;
54   var $handle = NULL;               // Glpi class handle used to query database
56   var $cur_dialog = NULL;           // This contains the sub dialog handle
58   var $orig_dn;                     // To check if dn, has changed 
59   var $ui;                          // Some GOsa specific user informations 
60   
61   var $usedDevices      = array();  // Which devices are currently selected 
62   var $usedAttachments  = array();  // Used Attachments 
64   /* Contructor 
65      Sets default values and checks if we already have an existing glpi account
66    */
67   function glpiAccount ($config, $dn= NULL)
68   {
69     plugin::plugin ($config, $dn);
70     $this->ui= get_userinfo();
72     /* Abort class construction, if no db is defined */
73     if(!isset($this->config->data['SERVERS']['GLPI'])){
74       return;
75     }
77     // Get informations about databse connection
78     $this->data = $this->config->data['SERVERS']['GLPI'];
80     // Abort if mysql extension is missing 
81     if(!is_callable("mysql_connect")){
82       return;
83     }
85     // Create handle of glpi class, and check if database connection is established 
86     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
88     if(!$this->handle->is_connected){
89       return;
90     } 
92     // If this dn is already used in database, then get all informations for this entry 
93     if($this->handle->is_account($this->dn)){
94       $this->is_account = true;
95       $tmp = ($this->handle->getComputerInformations($this->dn));
97       foreach(array("tech_num","os","FK_glpi_enterprise","type","comments","contact_num") as $attr){
98         $this->$attr = $tmp[0][$attr];
99       }
100       $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']);
101       $atts = $this->handle->getAssignAttachments($tmp[0]['ID']);
102       foreach($atts as $attachment){
103         
104         $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc']; 
105       }
106     }else{
107       $this->is_account = false;
108     }
110     /* set defaults */
111     $this->name                 = $this->dn;
112     $this->orig_dn              = $this->dn;
113     $this->initialy_was_account = $this->is_account;
116   }
118   function execute()
119   {
120     /* Call parent execute */
121     plugin::execute();
123     /* Fill templating stuff */
124     $smarty= get_smarty();
125     $display= "";
127     /*  Assign smarty defaults 
128         To avoid undefined indexes, if there is an error with the glpi db
129      */ 
130     foreach(array("SystemTypes","SystemTypeKeys","Manufacturers",
131                   "OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys",
132                   "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
133       $smarty->assign($attr,array());
134       $smarty->assign($attr."ACL"," disabled ");
135     }
136     foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){
137       $smarty->assign($attr,"");
138       $smarty->assign($attr."ACL"," disabled ");
139     }
141     /* Check if there is a glpi database server defined 
142       */
143     if(!isset($this->config->data['SERVERS']['GLPI'])){
144       print_red(_("There is no server with valid glpi database service."));
145       return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
146     }
148     $this->data = $this->config->data['SERVERS']['GLPI'];
150     /* Check if we can call mysql_connect 
151        If we can't, there is no the mysql-php extension
152      */
153     if(!is_callable("mysql_connect")){
154       print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
155       return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
156     }
158     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
160     /*  If handle == false, abort
161         Seems that the server, username and or password is wrong
162      */
163     if(!$this->handle->is_connected){
164       print_red(_("Can't connect to glpi database, check configuration twice."));
165       return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
166     } 
168     /*  All checks are ok
169         Lets handle Posts, templates etc below ...
170      */
171     
172     $users = $this->handle->getUsers();
173     $ldap= $this->config->get_ldap_link();
174  
175     /* Check for Trading button Post
176      */
177     if(isset($_POST['Trading'])){
178       print_red(_("This feature is not implemented yet."));
179     }
181     /* Check for Software button Post
182      */
183     if(isset($_POST['Software'])){
184       print_red(_("This feature is not implemented yet."));
185     }
187     /* Check for Contract button Post
188      */
189     if(isset($_POST['Contracts'])){
190       print_red(_("This feature is not implemented yet."));
191     }
192  
193     /* Add Device was requested, open new dialog
194      */
195     if(isset($_POST['AddDevice'])){
196       $this->dialog =true;
197       $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
198     }
200     /* Attachment pool was closed with use
201      */
202     if(isset($_POST['UseAttachment'])){
203       if(count($this->cur_dialog->check())){
204         foreach($this->cur_dialog->check() as $msg){
205           print_red($msg);
206         }
207       }else{
208         $this->cur_dialog->save_object();
209         $this->usedAttachments = $this->cur_dialog->save();
210         $this->cur_dialog = false;
211         $this->edit_type = false; 
212       }
213     }
214    
215     /* Attachment pool was closed with abort
216      */ 
217     if(isset($_POST['AbortAttachment'])){
218       $this->cur_dialog = false;
219       $this->edit_type = false; 
220     }
222     /* Open Attachment pool to add/edit Attachments
223      */
224     if(isset($_POST['AddAttachment'])){
225       $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
226       $this->dialog = true;
227     }
228     
229     /* Remove Attachment fro this tab 
230      */
231     $once = true;
232     foreach($_POST as $name => $value){
233       if((preg_match("/^delAttachment_/",$name))&&($once)){
234         $once= false;
235         $name = preg_replace("/^delAttachment_/","",$name);
236         $entry = preg_replace("/_.*$/","",$name);
237         if(isset($this->usedAttachments[$entry])){
238           unset($this->usedAttachments[$entry]);
239         }
240       }
241     }
242     if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments']))){
243       foreach($_POST['Attachments'] as $entry){
244         if(isset($this->usedAttachments[$entry])){
245           unset($this->usedAttachments[$entry]);
246         }
247       }
248     }
250     /* We have selected some devices and pressed use button 
251      */
252     if(isset($_POST['SelectDeviceSave'])){
253       $this->cur_dialog->save_object();
254       $this->usedDevices= ($this->cur_dialog->getSelected());
255       $this->cur_dialog = false;
256       $this->dialog = false;
257       $this->edit_type=false;
258     }
260     /* Aborted Device selction 
261      */
262     if(isset($_POST['SelectDeviceCancel'])){
263       $this->dialog = false;
264       $this->cur_dialog = false;
265       $this->edit_type=false;
266     }
268     /* System type management
269      */
270     if(isset($_POST['edit_type'])){
271       $this->dialog = true;
272       $this->edit_type=true;
273     }
275     /* This closes the system type editing dialog
276      */
277     if(isset($_POST['close_edit_type'])){
278       $this->edit_type=false;
279       $this->dialog = false;
280     }
282     if(isset($_POST['Rename_Cancel'])){
283       $this->renameTypeDialog = false;
284       $this->renameOSDialog = false;
285     }
287     /* This appends a new system to our sytem types
288      */
289     if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){
290       $attr = $this->handle->getSystemTypes();
291       if(in_array(trim($_POST['type_string']),$attr)){
292         print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
293       }else{
294         $this->handle->addSystemType(trim($_POST['type_string']));  
295       }
296     }
298     /* Remove selected type from our system types list
299      */
300     if((isset($_POST['del_type']))&&(!empty($_POST['select_type']))){
301       $tmp = $this->handle->is_systemTypeUsed($_POST['select_type']);
302       if(count($tmp)){
303         $names = "";
304         foreach($tmp as $name){
305           $names .= ", ".$name;
306         }
307         $names = preg_replace("/^, /","",$names); 
308         $names = trim($names);
309         if(count($tmp) == 3){
310           $names .= " ...";
311         }
312         print_red(sprintf(_("You can't delete this system type, it is still in use by these system(s) '%s'"),$names));
313       }else{
314         $this->handle->removeSystemType($_POST['select_type']); 
315       } 
316     }
318     /* Rename selected system type to given string
319      */
320     if(isset($_POST['Rename_type_OK'])){
321       $attr = $this->handle->getSystemTypes();
322       if(in_array(trim($_POST['string']),$attr)){
323         print_red(_("Rename failed, this system type name is already used.")) ;
324       }else{
325         $this->renameTypeDialog = false;
326         $this->handle->updateSystemType($_POST['string'],trim($this->select_type));
327       }
328     }
329     
330   
331     if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){
332       if(isset($_POST['select_type'])){
333         $this->select_type = $_POST['select_type'];
334       }
335       $this->renameTypeDialog = true;
336       $tmp = $this->handle->getSystemTypes();
337        
338       $smarty->assign("string",$tmp[$this->select_type]);
339       if(isset($_POST['string'])){
340         $smarty->assign("string",$_POST['string']);
341       }
342       $smarty->assign("Method","rename");
343       $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
344       return($display);
345     }
347     
349     /* Someone wants to edit the system types ... 
350        So, lets open a new dialog which provides some buttons to edit the types
351      */
352     if($this->edit_type){
353       $smarty->assign("Method","edit");
354       $smarty->assign("SystemTypes",            $this->handle->getSystemTypes());
355       $smarty->assign("SystemTypeKeys",         array_flip($this->handle->getSystemTypes()));
356       $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
357       return($display);
358     }
360     /* System os management
361      */
362     if(isset($_POST['edit_os'])){
363       $this->dialog = true;
364       $this->edit_os=true;
365     }
367     /* Close Operating system dialog
368      */
369     if(isset($_POST['close_edit_os'])){
370       $this->edit_os=false;
371       $this->dialog = false;
372     }
374     /* Add new os to the db
375      */
376     if((isset($_POST['add_os']))&&(!empty($_POST['is_string']))){
377       $attr = $this->handle->getOSTypes();
378       if(in_array(trim($_POST['is_string']),$attr)){
379         print_red(_("Adding new operating system failed, specifed name is already used.")) ;
380       }else{
381         $this->handle->addOS(trim($_POST['is_string']));  
382       }
383     }
385     /* Delete selected os from list and db
386      */
387     if((isset($_POST['del_os']))&&(!empty($_POST['select_os']))){
388       $tmp = $this->handle->is_osUsed($_POST['select_os']);
389   
390       if(count($tmp)){
392         $names = "";
393         foreach($tmp as $name){
394           $names .= ", ".$name;
395         }
396         $names = preg_replace("/^, /","",$names);
397         $names = trim($names);
398         if(count($tmp) == 3){
399           $names .= " ...";
400         }
401         print_red(sprintf(_("You can't delete this operating system, it is still in use by these system(s) '%s'"),$names));
403       }else{
404         $this->handle->removeOS_byID($_POST['select_os']);  
405       }
406     }
408     /* Rename selected os to given string
409      */
410     if(isset($_POST['Rename_os_OK'])){
411       $attr = $this->handle->getOSTypes();
412       if(in_array(trim($_POST['string']),$attr)){
413         print_red(_("Updating operating system failed, specifed name is already used.")) ;
414       }else{
415         $this->handle->updateOS($_POST['string'],$this->select_type);
416         $this->renameOSDialog = false;
417       }
418     }
419     if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){
420       if(isset($_POST['select_os'])){
421         $this->select_type = $_POST['select_os'];
422       }
423       $this->renameOSDialog = true;
424       $tmp = $this->handle->getOSTypes();
425        
426       $smarty->assign("string",$tmp[$this->select_type]);
427       if(isset($_POST['string'])){
428         $smarty->assign("string",$_POST['string']);
429       }
430       $smarty->assign("Method","rename");
431       $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
432       return($display);
433     }
435     /* Open dialog to edit os types 
436      */
437     if($this->edit_os){
438       $smarty->assign("Method","edit");
439       $smarty->assign("OSs",            $this->handle->getOSTypes());
440       $smarty->assign("OSKeys",         array_flip($this->handle->getOSTypes()));
441       $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
442       return($display);
443     }
447     /* Show dialog to select a new contact person
448      * Select a contact person
449      */
450     if(isset($_POST['SelectContactPerson'])){
451       $this->addUser = "contact";
452       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
453     }
455     /* Open dialog which allows to edit the manufacturers
456      */
457     if(isset($_POST['edit_manufacturer'])){
458       $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
459       $this->dialog = true;
460     }
462     /* Close manufacturer editing dialog
463      */
464     if(isset($_POST['close_edit_manufacturer'])){
465       $this->dialog = false;
466       $this->cur_dialog = false;
467     }
469     /* Abort user selection
470      */
471     $smarty->assign("AbortSelectUser","SelectUserCancel");
472     if(isset($_POST['SelectUserCancel'])){
473       $this->dialog = false;
474       $this->addUser ="";
475       $this->cur_dialog = false;
476     }
478     /* Selecte technical responsible person
479      */
480     if(isset($_POST['SelectTechPerson'])){
481       $this->addUser ="tech";
482       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
483     }
485     /* Technical responsible person selected*/
486     if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){
488       /* Get posted id */
489       $id = base64_decode($_GET['id']);
491       /* Check if user is already created in glpi database */
492       if(!in_array($id,$users)){
494         /* If this user doesn't exists in glpi db, we must create him */
495         $atr = $ldap->fetch($ldap->cat($id));
496         $tmp = array();
497         $use = array( "cn"              =>"name",
498             "mail"            =>"email",
499             "telephoneNumber" =>"phone");
501         /* Create array */
502         foreach($use as $gosa => $glpi){
503           if(isset($atr[$gosa])){
504             $tmp[$glpi]= $atr[$gosa][0];
505           }
506         }
508         /* Add this user */
509         $this->handle->addUser($tmp,$id);
510       }
512       /* Re-read users */
513       $users = ($this->handle->getUsers());
515       /* Get user */
516       $tmp = array_flip($users);
517       $id=$tmp[$id];
519       /* Use user id, close dialog */
520       if($this->addUser == "tech"){
521         $this->tech_num = $id;
522       }else{
523         $this->contact_num = $id;
524       }
525       $this->cur_dialog   = false;
526       $this->dialog= false;
527     }
529     /* if( cur_dialog != false || cur_dialog != NULL) 
530      * There is a dialog which wants to be displayed 
531      */
532     if($this->cur_dialog){
533       $this->cur_dialog->save_object();
534       $this->dialog=true;
535       $this->cur_dialog->parent = &$this;
536       return($this->cur_dialog->execute());
537     }else{
538       $this->dialog= false;
539     }
541     /* Assign smarty defaults */ 
542     foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
543       $smarty->assign($attr,array());
544     }
546     foreach($this->attributes as $attr){
547       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
548     }
550     /* Assign some vars to smarty 
551      */
552     foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){
553       $smarty->assign($attr,"");
554       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
555     }
557     /* Do we need to flip is_account state? */
558     if (isset($_POST['modify_state'])){
559       $this->is_account= !$this->is_account;
560     }
562     /* Show tab dialog headers */
563     if ($this->is_account){
564       $display= $this->show_header(_("Remove inventory"),
565           _("This device has inventory informations enabled. You can disable them by clicking below."));
566     } else {
567       $display= $this->show_header(_("Add inventory"),
568           _("This device has inventory informations disabled. You can enable them by clicking below."));
569       return ($display);
570     }
572     /* Assign ACLs to smarty*/
573     foreach($this->attributes as $attr){
574       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
575     }
577     /* Assign system types 
578      */
579     $smarty->assign("SystemTypeKeys",         array_flip($this->handle->getSystemTypes()));
580     $smarty->assign("SystemTypes",            $this->handle->getSystemTypes());
581     $smarty->assign("type",                   $this->type);
583     /* Assign os types
584      */
585     $smarty->assign("OSKeys",                 array_flip($this->handle->getOSTypes()));
586     $smarty->assign("OSs",                    $this->handle->getOSTypes());
587     $smarty->assign("os",                     $this->os);
589     /* Dispaly installed devices */
590     $smarty->assign("InstalledDevices"        ,$this->getDevices());
591     $smarty->assign("InstalledDeviceKeys"     ,array_flip($this->getDevices()));
593     /* Append manufacturers
594      */
595     $smarty->assign("ManufacturerKeys",       array_flip($this->handle->getEnterprises()));
596     $smarty->assign("Manufacturers",          $this->handle->getEnterprises());
597     $smarty->assign("FK_glpi_enterprise",     $this->FK_glpi_enterprise);
599     /* Assign used Attachments
600     */
602     $divlist = new divSelectBox("glpiAttachmentsList");
603     $divlist-> SetHeight(130); 
604     $atts = $this->getUsedAttachments(true);
605     $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
606     $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
607     foreach($atts as $id => $attachment){
608       $divlist->AddEntry
609           (
610         array(
611             array("string"=>$attachment['name']),
612             array("string"=>$attachment['mime']),
613             array("string"=>sprintf($downlink,$id,$attachment['filename'])),
614             array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
615              )
616           );
617     }
619     $smarty->assign("AttachmentsDiv"          ,$divlist->DrawList());
620     /* Handle contact person 
621        Assign name ... to smarty, if set
622      */ 
623     if(isset($users[$this->contact_num])){
624       $tr = $ldap->fetch($ldap->cat($users[$this->contact_num]));
625       $str = "";
626       if(isset($tr['givenName'][0])){   $str .= $tr['givenName'][0]." ";      }
627       if(isset($tr['sn'][0])) {         $str .= $tr['sn'][0]." ";             }
628       if(isset($tr['uid'][0])){         $str .= "[".$tr['uid'][0]."]";        }
629       $smarty->assign("contact_num",               $str);
630     }else{
631       $smarty->assign("contact_num",               _("N/A"));
632     }
634     /* Handle tech person 
635        Assign name ... to smarty, if set
636      */ 
637     if(isset($users[$this->tech_num])){
638       $tr = $ldap->fetch($ldap->cat($users[$this->tech_num]));
639       $str = "";
640       if(isset($tr['givenName'][0])){   $str .= $tr['givenName'][0]." ";      }
641       if(isset($tr['sn'][0])) {         $str .= $tr['sn'][0]." ";             }
642       if(isset($tr['uid'][0])){         $str .= "[".$tr['uid'][0]."]";        }
643       $smarty->assign("tech_num",               $str);
644     }else{
645       $smarty->assign("tech_num",               _("N/A"));
646     }
647     $smarty->assign("comments",               $this->comments);
649     $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE));
650     return($display);
651   }
653   function remove_from_parent()
654   {
655     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
656     if($this->initialy_was_account){
657       $this->handle->removeComputerInformations($this->dn); 
658     }
659   
660   }
662   function getDevices(){
663     $ret = array();
664     foreach($this->usedDevices as $type => $entries){
665       foreach($entries as $ent){
666         if(isset($ent['designation'])){
667           $ret[] = $ent['designation']." [".$type."]";
668         }else{
669           $ret[] = $ent['name']." [".$type."]";
670         }
671       }
672     }
673     return($ret); 
674   }
677   /* Save data to object */
678   function save_object()
679   {
680     if(!isset($_POST['glpi_tpl_posted'])) {
681       return ;
682     }
683     plugin::save_object();
684     foreach($this->attributes as $attrs){
685       if(isset($_POST[$attrs])){
686         $this->$attrs = $_POST[$attrs];
687       }
688     }
689   }
692   /* Check supplied data */
693   function check()
694   {
695     /* Call common method to give check the hook */
696     $message= plugin::check();
698     //    if($this->TechnicalResponsible == ""){
699     //      $message[] = _("Please select a technical responsible person for this entry.");
700     //    }
702     return ($message);
703   }
705   /* Save to LDAP */
706   function save()
707   {
708     if($this->is_account){
709         $attrs = array();
710       $this->date_mod = date("Y-m-d H:i:s");
711       foreach($this->attributes as $attr){
712         $attrs[$attr] = $this->$attr;
713       }
714       $attrs['name'] = $this->dn;
715       unset($attrs['ID']);
716       $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
717       if($this->initialy_was_account&&$this->is_account){
718         $this->handle->updateComputerInformations($attrs,$this->dn);
719       }elseif($this->is_account){
720         $this->handle->addComputerInformations($attrs,$this->dn);
721       }
722       $tmp = $this->handle->getComputerInformations($this->dn);
723       $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
724     }
725   }
727   /* Return used attachments */
728   function getUsedAttachments($divlist = false)
729   {
730     $atts =$this->handle->getAttachments();
731     $ret = array();
732     foreach($atts as $entry){
733       if(in_array($entry['ID'],$this->usedAttachments)){
734         if($divlist){
735           $ret[$entry['ID']] = $entry;
736         }else{
737           $cm ="";
738           if(isset($entry['comment'])){
739             $cm=" [".$entry['comment']."]";
740           }
741           if(isset($entry['mime'])){
742             $cm.=" -".$entry['mime']."";
743           }
745           $ret[$entry['ID']]= $entry['name'].$cm;
746         }
747       }
748     }
749     return($ret);
750   }
751   
755 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
756 ?>