Code

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