Code

Added logging to mimetypes
[gosa.git] / plugins / admin / mimetypes / class_mimetypeGeneric.inc
1 <?php
2 class mimetype extends plugin
3 {
4         /* CLI vars */
5         var $cli_summary                  = "This tab allows you to modify, add or remove mime types in the selected department.";
6         var $cli_description    = "Management dialog to handle mime types";
7         var $ignore_account     = true; // This is always a valid account
8         var $cli_parameters             = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9         var $objectclasses              = array("top","gotoMimeType");
10         var $attributes                   = array("cn","gotoMimeApplication","gotoMimeLeftClickAction","gotoMimeIcon",
11                                                                         "description","gotoMimeFilePattern","gotoMimeEmbeddedApplication",
12                                                                         "gotoMimeGroup");       
14         /* Class vars */
15         var $ui;
16         var $cn                                                                               = "";                                     
17         var $gotoMimeLeftClickAction                        = "I";
18         var $gotoMimeLeftClickAction_I              = true;
19         var $gotoMimeLeftClickAction_E              = false;
20         var $gotoMimeLeftClickAction_Q              = false;
21         var $gotoMimeIcon                                                         = "*removed*";
22         var $description                                                          = "";
23         var $gotoMimeFilePattern                                      = array();
24         var $gotoMimeApplication                                      = array();
25         var $gotoMimeEmbeddedApplication            = array();
26         var $gotoMimeGroup                                                      = "";
27         var $iconData                                                               = NULL;     
28         var $base                                                                             = "";
30   /* To prevent errors when using the 'apply' button, we use this variables 
31       to manage array attributes */
32         var $use_gotoMimeIcon                                           = NULL;
33         var $use_gotoMimeFilePattern                        = array();
34         var $use_gotoMimeApplication                        = array();
35         var $use_gotoMimeEmbeddedApplication    = array();
37   /* divLists */
38   var $DivPatterns                                                        = NULL;
39   var $DivApps                                                              = NULL;
40   var $DivEApps                                                             = NULL;
42   /* Mime type release mode */
43   var $isReleaseMimeType                                              = false;
44   var $dialog                                                                       = NULL;
46   /* These vars will be copied too, if you use copy&paste mode */
47   var $CopyPasteVars        = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData",
48                                     "gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q","use_gotoMimeIcon");
50   /* Select options */
51   var $MimeGroups                             = array("application","audio","chemical","image","inode","message","model",
52                                       "multipart","text","video","x-conference","x-world");
54   /* Orig_Dn is used to verify if this object is new or only edited */          
55   var $orig_dn                  = "";
57   function mimetype($config,$dn= NULL)
58   {
59     plugin::plugin ($config, $dn);
61     /* Save original dn */
62     $this->orig_dn = $dn;       
64     /* get gotoMimeLeftClickActions I/E/Q */
65     if(isset($this->gotoMimeLeftClickAction)){
66       $str = $this->gotoMimeLeftClickAction;
67       for($i = 0 ; $i < strlen($str) ; $i ++ ){
68         $varna = "gotoMimeLeftClickAction_". $str[$i];
69         if(isset($this->$varna)){
70           $this->$varna = true;
71         }
72       }
73     }
75     /* If both radio buttons arn't set, set option I */
76     if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){
77       $this->gotoMimeLeftClickAction_I = true;
78     }
80     /* Get list of array attributes */
81     foreach(array("gotoMimeFilePattern") as $attr){
82       $this->$attr = array();
83       if(isset($this->attrs[$attr])){
84         $tmp = array();
85         for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
86           $str = $this->attrs[$attr][$i];
87           $tmp[] = $str;
88         }
89         $use_attr = "use_".$attr;
90         $this->$use_attr = $tmp;
91       }
92     }
94     /* Get list of array attributes with priority tag ( Test|32 )*/
95     foreach(array("gotoMimeApplication","gotoMimeEmbeddedApplication") as $attr){
96       $this->$attr = array();
97       if(isset($this->attrs[$attr])){
98         $tmp = array();
99         for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
100           $str = $this->attrs[$attr][$i];
101           $tmp2= split("\|",$str);
103           if(count($tmp2) == 2){
104             $name = $tmp2[0];
105             $prio = $tmp2[1];
106             $tmp[$prio] = $name;
107           }
108         }
109         ksort($tmp);
110         $use_attr = "use_".$attr;
111         $this->$use_attr = $tmp;
112       }
113     }
115     /* Check if release Management is enabled */
116     $tmp = search_config($this->config->data,"faiManagement","CLASS");
117     if(!empty($tmp)) {
118       $this->isReleaseMimeType= true;
119     }
121     /* Set base */      
122     if ($this->dn == "new"){
123       if(isset($_SESSION['CurrentMainBase'])){
124         $this->base= $_SESSION['CurrentMainBase'];
125       }else{
126         $ui= get_userinfo();
127         $this->base= dn2base($ui->dn);
128       }
129     } else {
130       @log::log("view","mimetypes/".get_class($this),$this->dn);
131       $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
132     }
134     /* Get icon data */
135     if(isset($this->attrs['gotoMimeIcon'])){
136       $ldap = $this->config->get_ldap_link();
137       $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon");
138       $this->saved_attributes['gotoMimeIcon'] = $this->iconData;
139     }
140     if ($this->iconData == ""){
141       $this->set_new_picture("");
142     }
143     $_SESSION['binary']                 = $this->iconData;
144     $_SESSION['binarytype']             = "image/jpeg";
145   }
148   function execute()
149   {
150     $smarty = get_smarty();
152     $tmp = $this->plInfo();
153     foreach($tmp['plProvidedAcls'] as $name => $translation){
154       $smarty->assign($name."ACL",$this->getacl($name));
155     }
157     /* Base select dialog */
158     $once = true;
159     foreach($_POST as $name => $value){
160       if(preg_match("/^chooseBase/",$name) && $once){
161         $once = false;
162         $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
163         $this->dialog->setCurrentBase($this->base);
164       }
165     }
167     /* Dialog handling */
168     if(is_object($this->dialog)){
170       /* Must be called before save_object */
171       $this->dialog->save_object();
173       if($this->dialog->isClosed()){
174         $this->dialog = false;
175       }elseif($this->dialog->isSelected()){
177         /* A new base was selected, check if it is a valid one */
178         $tmp = $this->get_allowed_bases();
179         if(isset($tmp[$this->dialog->isSelected()])){
180           $this->base = $this->dialog->isSelected();
181         }
183         $this->dialog= false;
184       }else{
185         return($this->dialog->execute());
186       }
187     }
189     /* Check Posts */
190     $posts = array(     
191         "/^Pattern_SortUp_/"    => array("Action" => "Pattern_SortUp",  "Func" => "ArrayUp",    "Attr" => "use_gotoMimeFilePattern"),
192         "/^Pattern_SortDown_/"  => array("Action" => "Pattern_SortDown","Func" => "ArrayDown",  "Attr" => "use_gotoMimeFilePattern"),
193         "/^Pattern_Remove_/"    => array("Action" => "Pattern_Remove",  "Func" => "ArrayRemove","Attr" => "use_gotoMimeFilePattern"),
194         "/^Apps_SortUp_/"               => array("Action" => "Apps_SortUp",             "Func" => "ArrayUp",    "Attr" => "use_gotoMimeApplication"),
195         "/^Apps_SortDown_/"     => array("Action" => "Apps_SortDown",   "Func" => "ArrayDown",  "Attr" => "use_gotoMimeApplication"),
196         "/^Apps_Remove_/"               => array("Action" => "Apps_Remove",             "Func" => "ArrayRemove","Attr" => "use_gotoMimeApplication"),
197         "/^EApps_SortUp_/"              => array("Action" => "EApps_SortUp",    "Func" => "ArrayUp",    "Attr" => "use_gotoMimeEmbeddedApplication"),
198         "/^EApps_SortDown_/"    => array("Action" => "EApps_SortDown",  "Func" => "ArrayDown",  "Attr" => "use_gotoMimeEmbeddedApplication"),
199         "/^EApps_Remove_/"              => array("Action" => "EApps_Remove",    "Func" => "ArrayRemove","Attr" => "use_gotoMimeEmbeddedApplication"));          
200     $once = true;
202     /* Walk through posts and try to find some commands for us. */
203     foreach($_POST as $name => $value){
205       /* Walk through possible commands */
206       foreach($posts as $regex => $action){
208         /* Check if there is a command posted */
209         if(preg_match($regex,$name) && $once){
210           $once = false;
212           /* Get action vars */
213           $func                 = $action['Func'];              // Get function name 
214           $attr                 = $action['Attr'];              // Get attribute name
216           /* Get entry id */
217           $s_entry      = preg_replace($regex,"",$name);
218           $s_entry      = preg_replace("/_[xy]$/","",$s_entry); 
220           /* Execute a command with the given attribute and entry 
221              e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */
222           if($this->acl_is_writeable($attr)){
223             $this->$attr= $this->$func($s_entry,$this->$attr,true);                                      
224           }
225         }
226       }
227     }
229     /* Set a new icon was requested */
230     if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){
231       $this->set_new_picture($_FILES['picture_file']['tmp_name']);              
232     }
234     /* Add gotoMimeFilePattern */
235     if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
236       if($this->acl_is_writeable("gotoMimeFilePattern")){
237         $str = $_POST['NewFilePattern'];
238         if(!empty($str)){
239           $this->use_gotoMimeFilePattern[] = $str;
240         }
241       }
242     }   
244     /* Add gotoMimeFilePattern */
245     if(isset($_POST['AddNewApplication']) && isset($_POST['NewApplication'])){
246       if($this->acl_is_writeable("gotoMimeApplication")){
247         $str = $_POST['NewApplication'];
248         if(!empty($str)){
249           $this->use_gotoMimeApplication[] = $str;
250         }
251       }
252     }   
254     /* Add gotoMimeFilePattern */
255     if(isset($_POST['AddNewEmbeddedApplication']) && isset($_POST['NewEmbeddedApplication'])){
256       if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
257         $str = $_POST['NewEmbeddedApplication'];
258         if(!empty($str)){
259           $this->use_gotoMimeEmbeddedApplication[] = $str;
260         }
261       }
262     }   
264     /* Create divlists */
265     $DivPatterns        = new DivSelectBox("gotoMimePatterns");
266     $DivApps            = new DivSelectBox("gotoMimeApplications");
267     $DivEApps           = new DivSelectBox("gotoMimeEmbeddedApplications");
268     $DivPatterns        -> SetHeight(100);
269     $DivApps            -> SetHeight(100);
270     $DivEApps           -> SetHeight(100);
273     if($this->acl_is_writeable("gotoMimeFilePattern")){
274       $Pattern_Actions= " <input type='image' src='images/sort_up.png'  class='center'  name='Pattern_SortUp_%s' >&nbsp;
275       <input type='image' src='images/sort_down.png'    class='center'  name='Pattern_SortDown_%s'>&nbsp;
276       <input type='image' src='images/edittrash.png'    class='center'  name='Pattern_Remove_%s'>";
277     }else{
278       $Pattern_Actions= "";     
279     }
281     if($this->acl_is_writeable("gotoMimeApplication")){
282       $Apps_Actions     = " <input type='image' src='images/sort_up.png'        class='center'  name='Apps_SortUp_%s' >&nbsp;
283       <input type='image' src='images/sort_down.png'    class='center'  name='Apps_SortDown_%s'>&nbsp;
284       <input type='image' src='images/edittrash.png'    class='center'  name='Apps_Remove_%s'>";
285     }else{
286       $Apps_Actions= "";        
287     }
289     if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
290       $EApps_Actions    = " <input type='image' src='images/sort_up.png'        class='center'  name='EApps_SortUp_%s' >&nbsp;
291       <input type='image' src='images/sort_down.png'    class='center'  name='EApps_SortDown_%s'>&nbsp;
292       <input type='image' src='images/edittrash.png'    class='center'  name='EApps_Remove_%s'>";
293     }else{
294       $EApps_Actions= "";       
295     }
297     /* Before adding some entries check acls */
298     if($this->acl_is_readable("gotoMimeFilePattern")){
299       foreach($this->use_gotoMimeFilePattern as $key => $pattern){
300         $field1 = array("string" => $pattern);
301         $field2 = array("string" => preg_replace("/%s/",$key,$Pattern_Actions),"attach"=>"style='border-right:0px;width:50px;'");
302         $fields = array($field1,$field2);
303         $DivPatterns -> AddEntry($fields);
304       }                 
305     }
307     if($this->acl_is_readable("gotoMimeApplication")){
308       foreach($this->use_gotoMimeApplication as $key => $pattern){
309         $field1 = array("string" => $pattern);
310         $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
311         $fields = array($field1,$field2);
312         $DivApps -> AddEntry($fields);
313       }                 
314     }                   
315     if($this->acl_is_readable("gotoMimeEmbeddedApplication")){
316       foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){
317         $field1 = array("string" => $pattern);
318         $field2 = array("string" => preg_replace("/%s/",$key,$EApps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
319         $fields = array($field1,$field2);
320         $DivEApps -> AddEntry($fields);
321       }
322     }                   
323     $smarty->assign("bases",                                            $this->get_allowed_bases());            
324     $smarty->assign("base_select",                                      $this->base);           
325     $smarty->assign("isReleaseMimeType",                        $this->isReleaseMimeType);
326     $smarty->assign("gotoMimeFilePatterns",                     $DivPatterns->DrawList());
327     $smarty->assign("gotoMimeApplications",                     $DivApps->DrawList());
328     $smarty->assign("gotoMimeEmbeddedApplications",     $DivEApps->DrawList());
330     /* Assign class vars to smarty */
331     foreach($this->attributes as $attr){
332       $smarty->assign($attr,$this->$attr);
333     }   
335     /* Assign additional vars that are not included in attributes*/
336     foreach(array("gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q") as $attr){
337       $smarty->assign($attr,$this->$attr);
338     }   
340     /* Assign select box options */
341     $smarty->assign("gotoMimeGroups",$this->MimeGroups);
342     $smarty->assign("gotoMimeIcon"      ,$this->get_picture());
343     return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
344   }
347   function save_object()
348   {
349     if(isset($_POST['MimeGeneric'])){
351       /* Create a base backup and reset the
352          base directly after calling plugin::save_object();
353          Base will be set seperatly a few lines below */
354       $base_tmp = $this->base;
355       plugin::save_object();
356       $this->base = $base_tmp;
357   
358       /* Only save base if we are not in release mode */
359       if(!$this->isReleaseMimeType){
361         /* Set new base if allowed */
362         $tmp = $this->get_allowed_bases();
363         if(isset($_POST['base'])){
364           if(isset($tmp[$_POST['base']])){
365             $this->base= $_POST['base'];
366           }
367         }
369       }
371       /* Save radio buttons */
372       if($this->acl_is_writeable("gotoMimeLeftClickAction")){
373         if(isset($_POST['gotoMimeLeftClickAction_IE'])){
374           $chr = $_POST['gotoMimeLeftClickAction_IE'];
375           if($chr == "E"){
376             $this->gotoMimeLeftClickAction_E = true;
377             $this->gotoMimeLeftClickAction_I = false;
378           }else{
379             $this->gotoMimeLeftClickAction_E = false;
380             $this->gotoMimeLeftClickAction_I = true;
381           }
382         }
383         if(isset($_POST['gotoMimeLeftClickAction_Q'])){
384           $this->gotoMimeLeftClickAction_Q = true;
385         }else{
386           $this->gotoMimeLeftClickAction_Q = false;
387         }
388       }
389     }
390   }
393   /* save current changes */
394   function save()
395   {
396     /* Create gotoMimeLeftClickAction out of checkboxes and radio buttons */    
397     $arr = array ("E","I","Q");
398     $str = "";
399     foreach ($arr as $Chr){
400       $var = "gotoMimeLeftClickAction_".$Chr;
401       if($this->$var){
402         $str .= $Chr;
403       }
404     }
405     $this->gotoMimeLeftClickAction = $str;
407     /* Create array entries with priority tag ( Test|3 )*/
408     foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication") as $attr){
409       $i                                = 0;
410       $use_attr                 = "use_".$attr;
411       $tmp                      = array();
412       $this->$attr      = array();
413       foreach($this->$use_attr as $entry){
414         $tmp[] = $entry."|".$i ++;
415       }
416       $this->$attr = $tmp;
417     }
419     /* Create array entries */
420     foreach(array("gotoMimeFilePattern") as $attr){
421       $i                                = 0;
422       $use_attr                 = "use_".$attr;
423       $tmp                      = array();
424       $this->$attr      = array();
425       foreach($this->$use_attr as $entry){
426         $tmp[] = $entry;
427       }
428       $this->$attr = $tmp;
429     }
431     /* Remove Icon if requested  */
432     if($this->use_gotoMimeIcon != "*removed*"){
433       $this->gotoMimeIcon = $this->iconData;
434     }else{
435       $this->gotoMimeIcon = "";
436     }
438     plugin::save();
440     /* If this is a newly created object, skip storing those 
441        attributes that contain an empty array */
442     if($this->orig_dn == "new"){
443       foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){
444         if(!count($this->$attr)){
445           unset($this->attrs[$attr]);
446         }
447       }
448     }
450     $ldap = $this->config->get_ldap_link();
451     $ldap-> cd ( $this->config->current['BASE']);
452     $ldap->cat($this->dn);
453     if($ldap->count()){
454       $ldap->cd($this->dn);
455       $this->cleanup();
456       $ldap->modify($this->attrs);
457       @log::log("modify","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
458     }else{
459       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
460       $ldap->cd($this->dn);
461       $ldap->add($this->attrs);
462       @log::log("create","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
463     }
464     show_ldap_error($ldap->get_error(), sprintf(_("Saving of mime type/generic with dn '%s' failed."),$this->dn));
465   }
468   /* Remove current mime type */
469   function remove_from_parent()
470   {
471     plugin::remove_from_parent();
472     $ldap = $this->config->get_ldap_link();
473     $ldap->rmDir($this->dn);
474     show_ldap_error($ldap->get_error(), sprintf(_("Removing of mime type/generic with dn '%s' failed."),$this->dn));
475     @log::log("remove","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
477     /* Optionally execute a command after we're done */
478     $this->handle_post_events("remove");
480     /* Delete references to object groups */
481     $ldap->cd ($this->config->current['BASE']);
482     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
483     while ($ldap->fetch()){
484       $og= new ogroup($this->config, $ldap->getDN());
485       unset($og->member[$this->dn]);
486       $og->save ();
487       show_ldap_error($ldap->get_error(), sprintf(_("Removing mime type from objectgroup '%s' failed"), $og->dn));
488     }
489   }
492   /* Check given values */
493   function check()
494   {
495     $message = plugin::check();
496     if(empty($this->cn)){
497       $message[] = _("Please specify a valid name for this mime type.");
498     }
499     if(!count($this->use_gotoMimeFilePattern)){
500       $message[] = _("Please specify at least one file pattern.") ;
501     }
503     /* Check if there is already a mime type with this cn */
504     $ldap = $this->config->get_ldap_link();
505     $ldap->cd($this->config->current["BASE"]);
506     if($this->isReleaseMimeType && (isset($_SESSION['mimefilter']['release']))){
507       $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['mimefilter']['release']);
508       $baseDn = preg_replace("/ou=mime,.*/","ou=mime,".$this->base,$_SESSION['mimefilter']['release']);
509       $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$baseDn,array("cn"));
510       if($ldap->count()){
511         $attrs = $ldap->fetch();
512         if($this->dn != $attrs['dn']) {
513           $message[]= _("There's already a mime type with this 'Name'.");
514         }
515       }
516     }else{
517       $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))","ou=mime,".$this->base,array("cn"));
518       if ($ldap->count()){
519         $attrs = $ldap->fetch();
520         if($this->dn != $attrs['dn']) {
521           $message[]= _("There's already an mime with this 'Name'.");
522         }
523       }
524     }
526     return($message);
527   }
529   /** Helper functions **/
531   /* Set a new picture */       
532   function set_new_picture($filename)
533   {
534     if (empty($filename)){
535       $filename= "./images/default_icon.png";
536       $this->use_gotoMimeIcon= "*removed*";
537     }else{
538       $this->use_gotoMimeIcon= $filename;
539     }
541     if (file_exists($filename)){
542       $fd = fopen ($filename, "rb");
543       $this->iconData= fread ($fd, filesize ($filename));
544       $_SESSION['binary']= $this->iconData;
545       $_SESSION['binarytype']= "image/jpeg";
546       fclose ($fd);
547     }
548   }
550   /* Get picture link */
551   function get_picture()
552   {
553     $_SESSION['binary']= $this->iconData;
554     $_SESSION['binarytype']= "image/jpeg";
555     return("getbin.php");
556   }
558   /* Transports the given Arraykey one position up*/
559   function ArrayUp($atr,$attrs)
560   {
561     $ret = $attrs;
562     $pos = $this->getpos($atr,$attrs) ;
563     $cn = count($attrs);
564     if(!(($pos == -1)||($pos == 1))){
565       $before = array_slice($attrs,0,($pos-2));
566       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
567       $unten  = array_slice($attrs,$pos);
568       $ret = array();
569       $ret = $this->combineArrays($before,$mitte,$unten);
570     }
571     return($ret);
572   }
575   /* Transports the given Arraykey one position down*/
576   function ArrayDown($atr,$attrs)
577   {
578     $ret = $attrs;
579     $pos = $this->getpos($atr,$attrs) ;
580     $cn = count($attrs);
581     if(!(($pos == -1)||($pos == $cn))){
582       $before = array_slice($attrs,0,($pos-1));
583       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
584       $unten  = array_slice($attrs,($pos+1));
585       $ret = array();
586       $ret = $this->combineArrays($before,$mitte,$unten);
587     }
588     return($ret);
589   }
592   /* return the position of the element in the array */
593   function getpos($atr,$attrs)
594   {
595     $i = 0;
596     foreach($attrs as $attr => $name)    {
597       $i++;
598       if($attr == $atr){
599         return($i);
600       }
601     }
602     return(-1);
603   }
606   /* Remove this element from array */
607   function ArrayRemove($key,$array,$reorder = false)    
608   {
609     if(isset($array[$key])){
610       unset($array[$key]);
611       if($reorder){
612         $tmp = array();
613         foreach($array as $entry){
614           $tmp[] = $entry;
615         }
616         $array = $tmp;
617       }
618     }   
619     return($array);
620   }
623   /* Combine new array */
624   function combineArrays($ar0,$ar1,$ar2)
625   {
626     $ret = array();
627     if(is_array($ar0))
628       foreach($ar0 as $ar => $a){
629         $ret[]=$a;
630       }
631     if(is_array($ar1))
632       foreach($ar1 as $ar => $a){
633         $ret[]=$a;
634       }
635     if(is_array($ar2))
636       foreach($ar2 as $ar => $a){
637         $ret[]=$a;
638       }
639     return($ret);
640   }
643   /* Return a dialog with all fields that must be changed, 
644      if we want to copy this entry */
645   function getCopyDialog()
646   {
647     $str = "";
649     $smarty = get_smarty();
650     $smarty->assign("cn",               $this->cn);
651     $smarty->assign("description",  $this->description);
652     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
654     $ret = array();
655     $ret['string'] = $str;
656     $ret['status'] = "";
657     return($ret);
658   }
661   /* Save all */
662   function saveCopyDialog()
663   {
664     $attrs = array("cn","description");
665     foreach($attrs as $attr){
666       if(isset($_POST[$attr])){
667         $this->$attr = $_POST[$attr];
668       }
669     }
670   }
672   /* Return plugin informations for acl handling  */ 
673   function plInfo()
674   {
675     return (array(
676           "plShortName"   => _("Generic"),
677           "plDescription" => _("Mime type generic"),
678           "plSelfModify"  => FALSE,
679           "plDepends"     => array(),
680           "plPriority"    => 0,
681           "plSection"     => array("administration"),
682           "plCategory"    => array("mimetypes" => array("description"  => _("Mime types"),
683                                                         "objectClass"  => "gotoMimeType")),
684           "plProvidedAcls"=> array(
685             "cn"                          => _("Name"),
686             "gotoMimeGroup"               => _("Mime group"),
687             "description"                 => _("Description"),
688             "base"                        => _("Base"),
689             "gotoMimeApplication"         => _("Application"),
690             "gotoMimeLeftClickAction"     => _("Left click action"),
691             "gotoMimeIcon"                => _("Icon"),
692             "gotoMimeFilePattern"         => _("File patterns"),
693             "gotoMimeEmbeddedApplication" => _("Embedded applications"))
694           ));
696   }
698   function PrepareForCopyPaste($source)
699   {
700     plugin::PrepareForCopyPaste($source);
701     $this->gotoMimeIcon       = $this->iconData;
702     $this->use_gotoMimeIcon   = $source->use_gotoMimeIcon;
703   }
705 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
706 ?>