Code

Fixed application base selection && checks
[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       $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
131     }
133     /* Get icon data */
134     if(isset($this->attrs['gotoMimeIcon'])){
135       $ldap = $this->config->get_ldap_link();
136       $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon");
137       $this->saved_attributes['gotoMimeIcon'] = $this->iconData;
138     }
139     if ($this->iconData == ""){
140       $this->set_new_picture("");
141     }
142     $_SESSION['binary']                 = $this->iconData;
143     $_SESSION['binarytype']             = "image/jpeg";
144   }
147   function execute()
148   {
149     $smarty = get_smarty();
151     $tmp = $this->plInfo();
152     foreach($tmp['plProvidedAcls'] as $name => $translation){
153       $smarty->assign($name."ACL",$this->getacl($name));
154     }
156     /* Assign base ACL */
157     $smarty->assign("baseACL", $this->getacl("base"));
159     /* Base select dialog */
160     $once = true;
161     foreach($_POST as $name => $value){
162       if(preg_match("/^chooseBase/",$name) && $once){
163         $once = false;
164         $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
165         $this->dialog->setCurrentBase($this->base);
166       }
167     }
169     /* Dialog handling */
170     if(is_object($this->dialog)){
172       /* Must be called before save_object */
173       $this->dialog->save_object();
175       if($this->dialog->isClosed()){
176         $this->dialog = false;
177       }elseif($this->dialog->isSelected()){
179         /* A new base was selected, check if it is a valid one */
180         $tmp = $this->get_allowed_bases();
181         if(isset($tmp[$this->dialog->isSelected()])){
182           $this->base = $this->dialog->isSelected();
183         }
185         $this->dialog= false;
186       }else{
187         return($this->dialog->execute());
188       }
189     }
191     /* Check Posts */
192     $posts = array(     
193         "/^Pattern_SortUp_/"    => array("Action" => "Pattern_SortUp",  "Func" => "ArrayUp",    "Attr" => "use_gotoMimeFilePattern"),
194         "/^Pattern_SortDown_/"  => array("Action" => "Pattern_SortDown","Func" => "ArrayDown",  "Attr" => "use_gotoMimeFilePattern"),
195         "/^Pattern_Remove_/"    => array("Action" => "Pattern_Remove",  "Func" => "ArrayRemove","Attr" => "use_gotoMimeFilePattern"),
196         "/^Apps_SortUp_/"               => array("Action" => "Apps_SortUp",             "Func" => "ArrayUp",    "Attr" => "use_gotoMimeApplication"),
197         "/^Apps_SortDown_/"     => array("Action" => "Apps_SortDown",   "Func" => "ArrayDown",  "Attr" => "use_gotoMimeApplication"),
198         "/^Apps_Remove_/"               => array("Action" => "Apps_Remove",             "Func" => "ArrayRemove","Attr" => "use_gotoMimeApplication"),
199         "/^EApps_SortUp_/"              => array("Action" => "EApps_SortUp",    "Func" => "ArrayUp",    "Attr" => "use_gotoMimeEmbeddedApplication"),
200         "/^EApps_SortDown_/"    => array("Action" => "EApps_SortDown",  "Func" => "ArrayDown",  "Attr" => "use_gotoMimeEmbeddedApplication"),
201         "/^EApps_Remove_/"              => array("Action" => "EApps_Remove",    "Func" => "ArrayRemove","Attr" => "use_gotoMimeEmbeddedApplication"));          
202     $once = true;
204     /* Walk through posts and try to find some commands for us. */
205     foreach($_POST as $name => $value){
207       /* Walk through possible commands */
208       foreach($posts as $regex => $action){
210         /* Check if there is a command posted */
211         if(preg_match($regex,$name) && $once){
212           $once = false;
214           /* Get action vars */
215           $func                 = $action['Func'];              // Get function name 
216           $attr                 = $action['Attr'];              // Get attribute name
218           /* Get entry id */
219           $s_entry      = preg_replace($regex,"",$name);
220           $s_entry      = preg_replace("/_[xy]$/","",$s_entry); 
222           /* Execute a command with the given attribute and entry 
223              e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */
224           if($this->acl_is_writeable($attr)){
225             $this->$attr= $this->$func($s_entry,$this->$attr,true);                                      
226           }
227         }
228       }
229     }
231     /* Set a new icon was requested */
232     if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){
233       $this->set_new_picture($_FILES['picture_file']['tmp_name']);              
234     }
236     /* Add gotoMimeFilePattern */
237     if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
238       if($this->acl_is_writeable("gotoMimeFilePattern")){
239         $str = $_POST['NewFilePattern'];
240         if(!empty($str)){
241           $this->use_gotoMimeFilePattern[] = $str;
242         }
243       }
244     }   
246     /* Add gotoMimeFilePattern */
247     if(isset($_POST['AddNewApplication']) && isset($_POST['NewApplication'])){
248       if($this->acl_is_writeable("gotoMimeApplication")){
249         $str = $_POST['NewApplication'];
250         if(!empty($str)){
251           $this->use_gotoMimeApplication[] = $str;
252         }
253       }
254     }   
256     /* Add gotoMimeFilePattern */
257     if(isset($_POST['AddNewEmbeddedApplication']) && isset($_POST['NewEmbeddedApplication'])){
258       if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
259         $str = $_POST['NewEmbeddedApplication'];
260         if(!empty($str)){
261           $this->use_gotoMimeEmbeddedApplication[] = $str;
262         }
263       }
264     }   
266     /* Create divlists */
267     $DivPatterns        = new DivSelectBox("gotoMimePatterns");
268     $DivApps            = new DivSelectBox("gotoMimeApplications");
269     $DivEApps           = new DivSelectBox("gotoMimeEmbeddedApplications");
270     $DivPatterns        -> SetHeight(100);
271     $DivApps            -> SetHeight(100);
272     $DivEApps           -> SetHeight(100);
275     if($this->acl_is_writeable("gotoMimeFilePattern")){
276       $Pattern_Actions= " <input type='image' src='images/sort_up.png'  class='center'  name='Pattern_SortUp_%s' >&nbsp;
277       <input type='image' src='images/sort_down.png'    class='center'  name='Pattern_SortDown_%s'>&nbsp;
278       <input type='image' src='images/edittrash.png'    class='center'  name='Pattern_Remove_%s'>";
279     }else{
280       $Pattern_Actions= "";     
281     }
283     if($this->acl_is_writeable("gotoMimeApplication")){
284       $Apps_Actions     = " <input type='image' src='images/sort_up.png'        class='center'  name='Apps_SortUp_%s' >&nbsp;
285       <input type='image' src='images/sort_down.png'    class='center'  name='Apps_SortDown_%s'>&nbsp;
286       <input type='image' src='images/edittrash.png'    class='center'  name='Apps_Remove_%s'>";
287     }else{
288       $Apps_Actions= "";        
289     }
291     if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
292       $EApps_Actions    = " <input type='image' src='images/sort_up.png'        class='center'  name='EApps_SortUp_%s' >&nbsp;
293       <input type='image' src='images/sort_down.png'    class='center'  name='EApps_SortDown_%s'>&nbsp;
294       <input type='image' src='images/edittrash.png'    class='center'  name='EApps_Remove_%s'>";
295     }else{
296       $EApps_Actions= "";       
297     }
299     /* Before adding some entries check acls */
300     if($this->acl_is_readable("gotoMimeFilePattern")){
301       foreach($this->use_gotoMimeFilePattern as $key => $pattern){
302         $field1 = array("string" => $pattern);
303         $field2 = array("string" => preg_replace("/%s/",$key,$Pattern_Actions),"attach"=>"style='border-right:0px;width:50px;'");
304         $fields = array($field1,$field2);
305         $DivPatterns -> AddEntry($fields);
306       }                 
307     }
309     if($this->acl_is_readable("gotoMimeApplication")){
310       foreach($this->use_gotoMimeApplication as $key => $pattern){
311         $field1 = array("string" => $pattern);
312         $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
313         $fields = array($field1,$field2);
314         $DivApps -> AddEntry($fields);
315       }                 
316     }                   
317     if($this->acl_is_readable("gotoMimeEmbeddedApplication")){
318       foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){
319         $field1 = array("string" => $pattern);
320         $field2 = array("string" => preg_replace("/%s/",$key,$EApps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
321         $fields = array($field1,$field2);
322         $DivEApps -> AddEntry($fields);
323       }
324     }                   
325     $smarty->assign("bases",                                            $this->get_allowed_bases());            
326     $smarty->assign("base_select",                                      $this->base);           
327     $smarty->assign("isReleaseMimeType",                        $this->isReleaseMimeType);
328     $smarty->assign("gotoMimeFilePatterns",                     $DivPatterns->DrawList());
329     $smarty->assign("gotoMimeApplications",                     $DivApps->DrawList());
330     $smarty->assign("gotoMimeEmbeddedApplications",     $DivEApps->DrawList());
332     /* Assign class vars to smarty */
333     foreach($this->attributes as $attr){
334       $smarty->assign($attr,$this->$attr);
335     }   
337     /* Assign additional vars that are not included in attributes*/
338     foreach(array("gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q") as $attr){
339       $smarty->assign($attr,$this->$attr);
340     }   
342     /* Assign select box options */
343     $smarty->assign("gotoMimeGroups",$this->MimeGroups);
344     $smarty->assign("gotoMimeIcon"      ,$this->get_picture());
345     return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
346   }
349   function save_object()
350   {
351     if(isset($_POST['MimeGeneric'])){
353       /* Create a base backup and reset the
354          base directly after calling plugin::save_object();
355          Base will be set seperatly a few lines below */
356       $base_tmp = $this->base;
357       plugin::save_object();
358       $this->base = $base_tmp;
359   
360       /* Only save base if we are not in release mode */
361       if(!$this->isReleaseMimeType){
363         /* Set new base if allowed */
364         $tmp = $this->get_allowed_bases();
365         if(isset($_POST['base'])){
366           if(isset($tmp[$_POST['base']])){
367             $this->base= $_POST['base'];
368           }
369         }
371       }
373       /* Save radio buttons */
374       if($this->acl_is_writeable("gotoMimeLeftClickAction")){
375         if(isset($_POST['gotoMimeLeftClickAction_IE'])){
376           $chr = $_POST['gotoMimeLeftClickAction_IE'];
377           if($chr == "E"){
378             $this->gotoMimeLeftClickAction_E = true;
379             $this->gotoMimeLeftClickAction_I = false;
380           }else{
381             $this->gotoMimeLeftClickAction_E = false;
382             $this->gotoMimeLeftClickAction_I = true;
383           }
384         }
385         if(isset($_POST['gotoMimeLeftClickAction_Q'])){
386           $this->gotoMimeLeftClickAction_Q = true;
387         }else{
388           $this->gotoMimeLeftClickAction_Q = false;
389         }
390       }
391     }
392   }
395   /* save current changes */
396   function save()
397   {
398     /* Create gotoMimeLeftClickAction out of checkboxes and radio buttons */    
399     $arr = array ("E","I","Q");
400     $str = "";
401     foreach ($arr as $Chr){
402       $var = "gotoMimeLeftClickAction_".$Chr;
403       if($this->$var){
404         $str .= $Chr;
405       }
406     }
407     $this->gotoMimeLeftClickAction = $str;
409     /* Create array entries with priority tag ( Test|3 )*/
410     foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication") as $attr){
411       $i                                = 0;
412       $use_attr                 = "use_".$attr;
413       $tmp                      = array();
414       $this->$attr      = array();
415       foreach($this->$use_attr as $entry){
416         $tmp[] = $entry."|".$i ++;
417       }
418       $this->$attr = $tmp;
419     }
421     /* Create array entries */
422     foreach(array("gotoMimeFilePattern") as $attr){
423       $i                                = 0;
424       $use_attr                 = "use_".$attr;
425       $tmp                      = array();
426       $this->$attr      = array();
427       foreach($this->$use_attr as $entry){
428         $tmp[] = $entry;
429       }
430       $this->$attr = $tmp;
431     }
433     /* Remove Icon if requested  */
434     if($this->use_gotoMimeIcon != "*removed*"){
435       $this->gotoMimeIcon = $this->iconData;
436     }else{
437       $this->gotoMimeIcon = "";
438     }
440     plugin::save();
442     /* If this is a newly created object, skip storing those 
443        attributes that contain an empty array */
444     if($this->orig_dn == "new"){
445       foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){
446         if(!count($this->$attr)){
447           unset($this->attrs[$attr]);
448         }
449       }
450     }
452     $ldap = $this->config->get_ldap_link();
453     $ldap-> cd ( $this->config->current['BASE']);
454     $ldap->cat($this->dn);
455     if($ldap->count()){
456       $ldap->cd($this->dn);
457       $this->cleanup();
458       $ldap->modify($this->attrs);
459     }else{
460       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
461       $ldap->cd($this->dn);
462       $ldap->add($this->attrs);
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     $ldap = $this->config->get_ldap_link();
472     $ldap->rmDir($this->dn);
473     show_ldap_error($ldap->get_error(), sprintf(_("Removing of mime type/generic with dn '%s' failed."),$this->dn));
475     /* Optionally execute a command after we're done */
476     $this->handle_post_events("remove");
478     /* Delete references to object groups */
479     $ldap->cd ($this->config->current['BASE']);
480     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
481     while ($ldap->fetch()){
482       $og= new ogroup($this->config, $ldap->getDN());
483       unset($og->member[$this->dn]);
484       $og->save ();
485       show_ldap_error($ldap->get_error(), sprintf(_("Removing mime type from objectgroup '%s' failed"), $og->dn));
486     }
487   }
490   /* Check given values */
491   function check()
492   {
493     $message = plugin::check();
494     if(empty($this->cn)){
495       $message[] = _("Please specify a valid name for this mime type.");
496     }
497     if(!count($this->use_gotoMimeFilePattern)){
498       $message[] = _("Please specify at least one file pattern.") ;
499     }
501     /* Check if there is already a mime type with this cn */
502     $ldap = $this->config->get_ldap_link();
503     $ldap->cd($this->config->current["BASE"]);
504     if($this->isReleaseMimeType && (isset($_SESSION['mimefilter']['release']))){
505       $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['mimefilter']['release']);
506       $baseDn = preg_replace("/ou=mime,.*/","ou=mime,".$this->base,$_SESSION['mimefilter']['release']);
507       $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$baseDn,array("cn"));
508       if($ldap->count()){
509         $attrs = $ldap->fetch();
510         if($this->dn != $attrs['dn']) {
511           $message[]= _("There's already a mime type with this 'Name'.");
512         }
513       }
514     }else{
515       $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))","ou=mime,".$this->base,array("cn"));
516       if ($ldap->count()){
517         $attrs = $ldap->fetch();
518         if($this->dn != $attrs['dn']) {
519           $message[]= _("There's already an mime with this 'Name'.");
520         }
521       }
522     }
524     /* Check permissions for that base? */
525     if ($this->base != ""){
526       $new_dn= "cn=".$this->cn.",ou=mime,".$this->base;
527     } else {
528       $new_dn= $this->dn;
529     }
531     /* Set new acl base */
532     if($this->dn == "new") {
533       $this->set_acl_base($new_dn);
534     }
536     if (!$this->acl_is_createable() && $this->dn == "new"){
537       $message[]= _("You have no permissions to create a mime type on this 'Base'.");
538     }
540     return($message);
541   }
543   /** Helper functions **/
545   /* Set a new picture */       
546   function set_new_picture($filename)
547   {
548     if (empty($filename)){
549       $filename= "./images/default_icon.png";
550       $this->use_gotoMimeIcon= "*removed*";
551     }else{
552       $this->use_gotoMimeIcon= $filename;
553     }
555     if (file_exists($filename)){
556       $fd = fopen ($filename, "rb");
557       $this->iconData= fread ($fd, filesize ($filename));
558       $_SESSION['binary']= $this->iconData;
559       $_SESSION['binarytype']= "image/jpeg";
560       fclose ($fd);
561     }
562   }
564   /* Get picture link */
565   function get_picture()
566   {
567     $_SESSION['binary']= $this->iconData;
568     $_SESSION['binarytype']= "image/jpeg";
569     return("getbin.php");
570   }
572   /* Transports the given Arraykey one position up*/
573   function ArrayUp($atr,$attrs)
574   {
575     $ret = $attrs;
576     $pos = $this->getpos($atr,$attrs) ;
577     $cn = count($attrs);
578     if(!(($pos == -1)||($pos == 1))){
579       $before = array_slice($attrs,0,($pos-2));
580       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
581       $unten  = array_slice($attrs,$pos);
582       $ret = array();
583       $ret = $this->combineArrays($before,$mitte,$unten);
584     }
585     return($ret);
586   }
589   /* Transports the given Arraykey one position down*/
590   function ArrayDown($atr,$attrs)
591   {
592     $ret = $attrs;
593     $pos = $this->getpos($atr,$attrs) ;
594     $cn = count($attrs);
595     if(!(($pos == -1)||($pos == $cn))){
596       $before = array_slice($attrs,0,($pos-1));
597       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
598       $unten  = array_slice($attrs,($pos+1));
599       $ret = array();
600       $ret = $this->combineArrays($before,$mitte,$unten);
601     }
602     return($ret);
603   }
606   /* return the position of the element in the array */
607   function getpos($atr,$attrs)
608   {
609     $i = 0;
610     foreach($attrs as $attr => $name)    {
611       $i++;
612       if($attr == $atr){
613         return($i);
614       }
615     }
616     return(-1);
617   }
620   /* Remove this element from array */
621   function ArrayRemove($key,$array,$reorder = false)    
622   {
623     if(isset($array[$key])){
624       unset($array[$key]);
625       if($reorder){
626         $tmp = array();
627         foreach($array as $entry){
628           $tmp[] = $entry;
629         }
630         $array = $tmp;
631       }
632     }   
633     return($array);
634   }
637   /* Combine new array */
638   function combineArrays($ar0,$ar1,$ar2)
639   {
640     $ret = array();
641     if(is_array($ar0))
642       foreach($ar0 as $ar => $a){
643         $ret[]=$a;
644       }
645     if(is_array($ar1))
646       foreach($ar1 as $ar => $a){
647         $ret[]=$a;
648       }
649     if(is_array($ar2))
650       foreach($ar2 as $ar => $a){
651         $ret[]=$a;
652       }
653     return($ret);
654   }
657   /* Return a dialog with all fields that must be changed, 
658      if we want to copy this entry */
659   function getCopyDialog()
660   {
661     $str = "";
663     $smarty = get_smarty();
664     $smarty->assign("cn",               $this->cn);
665     $smarty->assign("description",  $this->description);
666     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
668     $ret = array();
669     $ret['string'] = $str;
670     $ret['status'] = "";
671     return($ret);
672   }
675   /* Save all */
676   function saveCopyDialog()
677   {
678     $attrs = array("cn","description");
679     foreach($attrs as $attr){
680       if(isset($_POST[$attr])){
681         $this->$attr = $_POST[$attr];
682       }
683     }
684   }
686   /* Return plugin informations for acl handling  */ 
687   function plInfo()
688   {
689     return (array(
690           "plShortName"   => _("Generic"),
691           "plDescription" => _("Mime type generic"),
692           "plSelfModify"  => FALSE,
693           "plDepends"     => array(),
694           "plPriority"    => 0,
695           "plSection"     => array("administration"),
696           "plCategory"    => array("mimetypes" => array("description"  => _("Mime types"),
697                                                         "objectClass"  => "gotoMimeType")),
698           "plProvidedAcls"=> array(
699             "cn"                          => _("Name"),
700             "gotoMimeGroup"               => _("Mime group"),
701             "description"                 => _("Description"),
702             "base"                        => _("Base"),
703             "gotoMimeApplication"         => _("Application"),
704             "gotoMimeLeftClickAction"     => _("Left click action"),
705             "gotoMimeIcon"                => _("Icon"),
706             "gotoMimeFilePattern"         => _("File patterns"),
707             "gotoMimeEmbeddedApplication" => _("Embedded applications"))
708           ));
710   }
712   function PrepareForCopyPaste($source)
713   {
714     plugin::PrepareForCopyPaste($source);
715     $this->gotoMimeIcon       = $this->iconData;
716     $this->use_gotoMimeIcon   = $source->use_gotoMimeIcon;
717   }
719 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
720 ?>