Code

Skip executing FAI repository if FAI is not active.
[gosa.git] / plugins / admin / systems / class_glpiPrinterAccount.inc
1 <?php
3 class glpiPrinterAccount 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","ramSize","flags_serial","flags_par","flags_usb",
13       "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial",
14       "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 $FK_glpi_enterprise = 0;     // Manufacturer id
19   var $tech_num           = "";    // Technical responsible person
20   var $contact_num        = "";    // Contact person
21   
22   var $comments           = "";    // Comment
23   
24   var $type               = 0;     // printer type id
25   var $serial             = "";   
26   var $otherserial        = "";  
27   var $ramSize            = 0;
28   var $flags_serial       = false;
29   var $flags_par          = false;
30   var $flags_usb          = false;
32   var $date_mod           = "";    // Modification timestamp
33   
34   var $location           = 0;     // Not used yet
35   var $domain             = 0;     // ? Set to 0
36   var $network            = 0;     // ? Set to 0 
38   var $is_template        = 0;     // Used as template ?
39   var $contact            = "";    // Empty
40   var $deleted            = "N";   // Deleted entries should have this set to Y
42   var $rename             = false;
43   var $select_type        ;
45   var $editManufacturer   = false;
47   /* Not necessary, cause we use mysql databse */
48   var $objectclasses= array("whatever");
50   /* Used to remember if this was an account (simply: is this an edited entry) */
51   var $initially_was_account = false;
53   /* Remember current dialog */
54   var $edit_type            = false;
55   var $edit_os              = false;
57   var $data;
58   var $handle = NULL;               // Glpi class handle used to query database
60   var $cur_dialog = NULL;           // This contains the sub dialog handle
62   var $orig_dn;                     // To check if dn, has changed 
63   var $ui;                          // Some GOsa specific user informations 
64   
65   var $usedDevices      = array();  // Which devices are currently selected 
66   var $usedAttachments  = array();  // Used Attachments 
67   var $usedCartridges   = array();  // Used Cartridges
69   /* Contructor 
70      Sets default values and checks if we already have an existing glpi account
71    */
72   function glpiPrinterAccount ($config, $dn= NULL, $parent= NULL)
73   {
74     plugin::plugin ($config, $dn, $parent);
75     $this->ui= get_userinfo();
77     $this->is_account = false;
79     /* Abort class construction, if no db is defined */
80     if(!isset($this->config->data['SERVERS']['GLPI'])){
81       return;
82     }
84     // Get informations about databse connection
85     $this->data = $this->config->data['SERVERS']['GLPI'];
87     // Abort if mysql extension is missing 
88     if(!is_callable("mysql_connect")){
89       return;
90     }
92     // Create handle of glpi class, and check if database connection is established 
93     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
95     if(!$this->handle->is_connected){
96       return;
97     } 
99     // If this dn is already used in database, then get all informations for this entry 
100     if($this->handle->is_printer_account($this->dn)){
101       $this->is_account = true;
102       $tmp = ($this->handle->getPrinterInformations($this->dn));
104       foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){
105         $this->$attr = $tmp[0][$attr];
106       }
107       
108       $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']);
109       foreach($atts as $attachment){
110         $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc']; 
111       }
113       $cart= $this->handle->getUsedCartridges($tmp[0]['ID']);
114       foreach($cart as $key => $cartridge){
115         $this->usedCartridges[$key]=$cartridge; 
116         $this->usedCartridges[$key]['status']="exists"; 
117       }
120     }else{
121       $this->is_account = false;
122     }
124     /* set defaults */
125     $this->name                 = $this->dn;
126     $this->orig_dn              = $this->dn;
127     $this->initially_was_account = $this->is_account;
128   }
130   function execute()
131   {
132     /* Call parent execute */
133     plugin::execute();
135     /* Fill templating stuff */
136     $smarty= get_smarty();
137     $display= "";
139     $smarty->assign("CartridgesACL",chkacl($this->acl,"Cartridges"));
141     /*  Assign smarty defaults 
142         To avoid undefined indexes, if there is an error with the glpi db
143      */ 
144     foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers","Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
145       $smarty->assign($attr,array());
146       $smarty->assign($attr."ACL"," disabled ");
147     }
148     foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){
149       $smarty->assign($attr,"");
150       $smarty->assign($attr."ACL"," disabled ");
151     }
153     /* Check if there is a glpi database server defined 
154       */
155     if(!isset($this->config->data['SERVERS']['GLPI'])){
156       print_red(_("There is no server with valid glpi database service."));
157       return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
158     }
160     $this->data = $this->config->data['SERVERS']['GLPI'];
162     /* Check if we can call mysql_connect 
163        If we can't, there is no the mysql-php extension
164      */
165     if(!is_callable("mysql_connect")){
166       print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
167       return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
168     }
170     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
172     /*  If handle == false, abort
173         Seems that the server, username and or password is wrong
174      */
175     if(!$this->handle->is_connected){
176       print_red(_("Can't connect to glpi database, check configuration twice."));
177       return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
178     } 
180     /*  All checks are ok
181         Lets handle Posts, templates etc below ...
182      */
183     
184     $users = $this->handle->getUsers();
185     $ldap= $this->config->get_ldap_link();
187     
188     /*  ##########################################################################
189      *  Some tab management   
190      */
192     /* Do we need to flip is_account state? */
193     if (isset($_POST['modify_state'])){
194       $this->is_account= !$this->is_account;
195     }
197     /* Show tab dialog headers */
198     if ($this->is_account){
199       $display= $this->show_header(_("Remove inventory"),
200           _("This server has inventory features enabled. You can disable them by clicking below."));
201     } else {
202       $display= $this->show_header(_("Add inventory"),
203           _("This server has inventory features disabled. You can enable them by clicking below."));
204       return ($display);
205     }
207     
208     /*  ##########################################################################
209      *  Printer type management 
210      *  Dialog 
211      */
213     /* Rename was requested */
214     if(isset($_POST['Rename_PType_OK'])){
215       $tmp = $this->handle->getPrinterTypes();
216       $allok = true;
217       foreach($tmp as $id => $name){
218         if(trim($name) == trim($_POST['string'])){
219           $allok = false;
220         }
221       }
222       if($allok){
223         $this->handle->updatePrinterType($_POST['string'],$this->select_type);
224         $this->rename = false;
225       }else{
226         print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string']));
227       }
228     }
230     /* abort rename 
231      */
232     if(isset($_POST['Rename_Cancel'])){
233       $this->rename = false;
234     }
236     /* Printer type management
237      */
238     if(isset($_POST['edit_type'])){
239       $this->dialog = true;
240       $this->edit_type=true;
241     }
243     /* This closes the printer type editing dialog
244      */
245     if(isset($_POST['close_edit_type'])){
246       $this->edit_type=false;
247       $this->dialog = false;
248     }
250     /* This appends a new printer to our sytem types
251      */
252     if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){
253     
254       $tmp = $this->handle->getPrinterTypes();
255       $allok = true;
256       foreach($tmp as $id => $name){
257         if(trim($name) == trim($_POST['type_string'])){
258           $allok = false;
259         }
260       }
261       if($allok){
262         $this->handle->addPrinterType($_POST['type_string']);  
263       }else{
264         print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string']));
265       }
266     }
268     /* Remove selected type from our printer types list
269      */
270     if((isset($_POST['del_type']))&&(!empty($_POST['select_type']))){
271       $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']);
272       if(count($tmp)){
273         $str = "";
274         foreach($tmp as $id => $name){
275           $str .= $name.", ";
276         }
277         $str = preg_replace("/, $/","",$str); 
278         print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str));
279       }else{
280         $this->handle->removePrinterType($_POST['select_type']);  
281       }
282     }
284     /* Rename selected printer type to given string
285      */
286     if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename)){
287       $this->rename = true;
289       $smarty->assign("Method","rename");
291       $tmp = $this->handle->getPrinterTypes();
293       if(isset($_POST['select_type'])){
294         $this->select_type = $_POST['select_type'];
295       }  
296       $smarty->assign("string",$tmp[$this->select_type]);
297       if(isset($_POST['string'])){
298         $smarty->assign("string",$_POST['string']);
299       }
301       $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
302       return($display);
303     }  
305     /* Someone wants to edit the printer types ... 
306        So, lets open a new dialog which provides some buttons to edit the types
307      */
308     if($this->edit_type){
309       $smarty->assign("Method","edit");
310       $smarty->assign("PrinterTypes",            $this->handle->getPrinterTypes());
311       $smarty->assign("PrinterTypeKeys",         array_flip($this->handle->getPrinterTypes()));
312       $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
313       return($display);
314     }
317     /*  ##########################################################################
318      *  Edit manufacturers 
319      *  Dialog 
320      */
322     /* Open dialog which allows to edit the manufacturers
323      */
324     if(isset($_POST['edit_manufacturer'])){
325       $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
326       $this->dialog = true;
327       $this->editManufacturer =true;
328     }
330     /* Close manufacturer editing dialog
331      */
332     if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
333       $this->dialog = false;
334       $this->cur_dialog = false;
335       $this->editManufacturer=false;
336     }
339     /*  ##########################################################################
340      *  Technical responsible person
341      *  Contact person 
342      *  Dialog 
343      */
345     /* Show dialog to select a new contact person
346      * Select a contact person
347      */
348     if(isset($_POST['SelectContactPerson'])){
349       $this->addUser = "contact";
350       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
351     }
353     /* Selecte technical responsible person
354      */
355     if(isset($_POST['SelectTechPerson'])){
356       $this->addUser ="tech";
357       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
358     }
360     /* Abort user selection
361      */
362     $smarty->assign("AbortSelectUser","SelectUserCancel");
363     if(isset($_POST['SelectUserCancel'])){
364       $this->dialog = false;
365       $this->addUser ="";
366       $this->cur_dialog = false;
367     }
369     /* Technical responsible/contact person selected */
370     if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){
372       /* Get posted id */
373       $id = base64_decode($_GET['id']);
375       /* Check if user is already created in glpi database */
376       if(!in_array($id,$users)){
378         /* If this user doesn't exists in glpi db, we must create him */
379         $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
380         $atr = $ldap->fetch();
381         $tmp = array();
382         $use = array( "cn"              =>"name",
383             "mail"            =>"email",
384             "telephoneNumber" =>"phone");
386         /* Create array */
387         foreach($use as $gosa => $glpi){
388           if(isset($atr[$gosa])){
389             $tmp[$glpi]= $atr[$gosa][0];
390           }
391         }
393         /* Add this user */
394         $this->handle->addUser($tmp,$id);
395       }
397       /* Re-read users */
398       $users = ($this->handle->getUsers());
400       /* Get user */
401       $tmp = array_flip($users);
402       $id=$tmp[$id];
404       /* Use user id, close dialog */
405       if($this->addUser == "tech"){
406         $this->tech_num = $id;
407       }else{
408         $this->contact_num = $id;
409       }
410       $this->cur_dialog   = false;
411       $this->dialog= false;
412     }
415     /*  ##########################################################################
416      *  Handle attachments 
417      */
418     
419     /* Attachment pool was closed with use
420      */
421     if(isset($_POST['UseAttachment'])){
422       if(count($this->cur_dialog->check())){
423         foreach($this->cur_dialog->check() as $msg){
424           print_red($msg);
425         }
426       }else{
427         $this->cur_dialog->save_object();
428         $this->usedAttachments = $this->cur_dialog->save();
429         $this->cur_dialog = false;
430         $this->edit_type = false; 
431       }
432     }
433    
434     /* Attachment pool was closed with abort
435      */ 
436     if(isset($_POST['AbortAttachment'])){
437       $this->cur_dialog = false;
438       $this->edit_type = false; 
439     }
441     /* Open Attachment pool to add/edit Attachments
442      */
443     if(isset($_POST['AddAttachment'])){
444       $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
445       $this->dialog = true;
446     }
447     
448     /* Remove Attachment from this tab 
449      */
450     $once = true;
451     foreach($_POST as $name => $value){
452       if((preg_match("/^delAttachment_/",$name))&&($once)){
453         $once= false;
454         $name = preg_replace("/^delAttachment_/","",$name);
455         $entry = preg_replace("/_.*$/","",$name);
456         if(isset($this->usedAttachments[$entry])){
457           unset($this->usedAttachments[$entry]);
458         }
459       }
460     }
461     if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments']))){
462       if(isset($this->usedAttachments[$_POST['Attachments']])){
463         unset($this->usedAttachments[$_POST['Attachments']]);
464       }
465     }
467     /*  ##########################################################################
468      *  Printer Cartridge handling 
469      */
471     /* Abort cartridge select dialog
472      */
473     if(isset($_POST['SelectCartridgeCancel'])){
474       $this->cur_dialog = false;
475       $this->edit_type = false; 
476     }
478     /* Get selected cartridges and add them to our list 
479      */ 
480     if(isset($_POST['SelectCartridgeSave'])){
481       $this->cur_dialog->save_object();
482       $carts = $this->cur_dialog->save();
483       foreach($carts as $cart){
484         $cart['status'] = "new";
485         $this->usedCartridges[] = $cart;
486       }
487       $this->cur_dialog = false;
488       $this->edit_type = false; 
489     }
491     /* Remove cartridge  
492      */
493     if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges']))){
495       foreach($_POST['Cartridges'] as $cartID){
497         if(isset($this->usedCartridges[$cartID])){
498           if($this->usedCartridges[$cartID]['status'] == "exists"){
499             $this->usedCartridges[$cartID]['status'] = "deleted";
500           }else{
501             unset($this->usedCartridges[$cartID]);
502           }
503         }
504       }
505     }
507     /* Open Attachment pool to add/edit Attachments
508      */
509     if(isset($_POST['AddCartridge'])){
510       $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
511       $this->dialog = true;
512     }
515     /*  ##########################################################################
516      *  Draw Dialogs
517      */
518     /* if( cur_dialog != false || cur_dialog != NULL) 
519      * There is a dialog which wants to be displayed 
520      */
521     if($this->cur_dialog){
522       $this->cur_dialog->save_object();
523       $this->dialog=true;
524       $this->cur_dialog->parent = &$this;
525       return($this->cur_dialog->execute());
526     }else{
527       $this->dialog= false;
528     }
531     /*  ##########################################################################
532      *  Assign listbox / checkbox .... values to smarty  
533      */
534     /* Assign smarty defaults */ 
535     foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){
536       $smarty->assign($attr,array());
537       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
538     }
540     /* Assign some vars to smarty 
541      */
542     foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){
543       $smarty->assign($attr,"");
544       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
545     }
548     /* Assign ACLs to smarty*/
549     foreach($this->attributes as $attr){
550       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
551     }
553     $smarty->assign("comments",               $this->comments);
554     $smarty->assign("flags_serial",            $this->flags_serial);
555     $smarty->assign("flags_par",               $this->flags_par);
556     $smarty->assign("flags_usb",               $this->flags_usb);
558     /* Assign system types 
559      */
560     $smarty->assign("PrinterTypes",           $this->handle->getPrinterTypes());
561     $smarty->assign("PrinterTypeKeys",        array_flip($this->handle->getPrinterTypes()));
562     $smarty->assign("type",                   $this->type);
564     /* Append manufacturers
565      */
566     $smarty->assign("ManufacturerKeys",       array_flip($this->handle->getEnterprises()));
567     $smarty->assign("Manufacturers",          $this->handle->getEnterprises());
568     $smarty->assign("FK_glpi_enterprise",     $this->FK_glpi_enterprise);
570     /* Assign used Attachments
571     */
573     $divlist = new divSelectBox("glpiAttachmentsList");
574     $divlist-> SetHeight(120);
575     $atts = $this->getUsedAttachments(true);
576     $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
577     $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
578     foreach($atts as $id => $attachment){
579       $divlist->AddEntry
580           (
581         array(
582             array("string"=>$attachment['name']),
583             array("string"=>$attachment['mime']),
584             array("string"=>sprintf($downlink,$id,$attachment['filename'])),
585             array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
586              )
587           );
588     }
590     $smarty->assign("AttachmentsDiv"          ,$divlist->DrawList());
591     $smarty->assign("Attachments",            $this->getUsedAttachments());
592     $smarty->assign("AttachmentKeys",         array_flip($this->getUsedAttachments()));
594     /* Assign Cartridges 
595      */
596     $smarty->assign("Cartridges",            $this->getUsedCartridges());
597     $smarty->assign("CartridgeKeys",         $this->getUsedCartridges(true));
599     /*  ##########################################################################
600      *  Assign contact and technical responsible person 
601      */
602     if(isset($users[$this->contact_num])){
603       $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid'));
604       $tr = $ldap->fetch();
605       $str = "";
606       if(isset($tr['givenName'][0])){   $str .= $tr['givenName'][0]." ";      }
607       if(isset($tr['sn'][0])) {         $str .= $tr['sn'][0]." ";             }
608       if(isset($tr['uid'][0])){         $str .= "[".$tr['uid'][0]."]";        }
609       $smarty->assign("contact_num",               $str);
610     }else{
611       $smarty->assign("contact_num",               _("N/A"));
612     }
614     /* Handle tech person 
615        Assign name ... to smarty, if set
616      */ 
617     if(isset($users[$this->tech_num])){
618       $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
619       $tr = $ldap->fetch();
620       $str = "";
621       if(isset($tr['givenName'][0])){   $str .= $tr['givenName'][0]." ";      }
622       if(isset($tr['sn'][0])) {         $str .= $tr['sn'][0]." ";             }
623       if(isset($tr['uid'][0])){         $str .= "[".$tr['uid'][0]."]";        }
624       $smarty->assign("tech_num",               $str);
625     }else{
626       $smarty->assign("tech_num",               _("N/A"));
627     }
629     /* If theres a cartridge selected, you can't change the printer type.
630      */ 
631     $disp = true;
633     foreach($this->usedCartridges as $cart){
634       if($cart['status'] != "deleted"){
635         $disp = false;
636       }
637     }
638     if($disp==false){
639       $smarty->assign("typeACL","disabled");
640     }
642     $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
643     return($display);
644   }
646   function remove_from_parent()
647   {
648     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
649     if($this->initially_was_account){
650       $this->handle->removePrinterInformations($this->dn); 
651     }
652   }
655   /* Save data to object */
656   function save_object()
657   {
658     if(isset($_POST['glpiPrinterFlagsPosted'])){
659       plugin::save_object();
660       foreach($this->attributes as $attrs){
661         if(isset($_POST[$attrs])){
662           $this->$attrs = $_POST[$attrs];
663         }
664       }
666       foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
667         if(isset($_POST[$checkboxes])){
668           $this->$checkboxes = 1;
669         }else{
670           $this->$checkboxes = 0;
671         }
672       }
673     }
675   }
678   /* Check supplied data */
679   function check()
680   {
681     /* Call common method to give check the hook */
682     $message= plugin::check();
684     //    if($this->TechnicalResponsible == ""){
685     //      $message[] = _("Please select a technical responsible person for this entry.");
686     //    }
688     return ($message);
689   }
691   /* Save to LDAP */
692   function save()
693   {
694     if($this->is_account){
695         $attrs = array();
696       $this->date_mod = date("Y-m-d H:i:s");
697       foreach($this->attributes as $attr){
698         $attrs[$attr] = $this->$attr;
699       }
700       $attrs['name'] = $this->dn;
701       unset($attrs['ID']);
702       $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
703       if($this->initially_was_account&&$this->is_account){
704         $this->handle->updatePrinterInformations($attrs,$this->dn);
705       }elseif($this->is_account){
706         $this->handle->addPrinterInformations($attrs,$this->dn);
707       }
708       $tmp = $this->handle->getPrinterInformations($this->dn);
709       $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);
711       foreach($this->usedCartridges as $cart){
712         if($cart['status'] == "deleted"){
713           $this->handle->removeCartridgeFromPrinter($cart['ID']);
714         }elseif($cart['status'] == "new"){
715           $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']);
716         }
717       }
718     }
719   }
721   /* Return used attachments */
722   function getUsedAttachments($divlist = false)
723   {
724     $atts =$this->handle->getAttachments();
725     $ret = array();
726     foreach($atts as $entry){
727       if(in_array($entry['ID'],$this->usedAttachments)){
728         if($divlist){
729           $ret[$entry['ID']] = $entry;
730         }else{
731           $cm ="";
732           if(isset($entry['comment'])){
733             $cm=" [".$entry['comment']."]";
734           }
735           if(isset($entry['mime'])){
736             $cm.=" -".$entry['mime']."";
737           }
739           $ret[$entry['ID']]= $entry['name'].$cm;
740         }
741       }
742     }
743     return($ret);
744   }
746   function getUsedCartridges($flip = false)
747   {
748     $ret = array();
749     foreach($this->usedCartridges as $key => $value){
750       if($value['status'] == "deleted") continue;
751       if($flip){
752         $ret[$key] = $key;    
753       }else{
754         $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use'];
755       }
756     }
757     return($ret);
758   }  
762 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
763 ?>