Code

Removed old style lists
[gosa.git] / gosa-plugins / goto / admin / mimetypes / class_mimetypeGeneric.inc
1 <?php
2 class mimetype extends plugin
3 {
4         var $ignore_account     = true; // This is always a valid account
5         var $objectclasses              = array("top","gotoMimeType");
6         var $attributes                   = array("cn","gotoMimeApplication","gotoMimeLeftClickAction","gotoMimeIcon",
7                                                                         "description","gotoMimeFilePattern","gotoMimeEmbeddedApplication",
8                                                                         "gotoMimeGroup");       
10         /* Class vars */
11         var $ui;
12         var $cn                                                                               = "";                                     
13         var $gotoMimeLeftClickAction                        = "I";
14         var $gotoMimeLeftClickAction_I              = true;
15         var $gotoMimeLeftClickAction_E              = false;
16         var $gotoMimeLeftClickAction_Q              = false;
17         var $gotoMimeIcon                                                         = "*removed*";
18         var $description                                                          = "";
19         var $gotoMimeFilePattern                                      = array();
20         var $gotoMimeApplication                                      = array();
21         var $gotoMimeEmbeddedApplication            = array();
22         var $gotoMimeGroup                                                      = "";
23         var $iconData                                                               = NULL;     
24         var $base                                                                             = "";
25   var $ApplicationList                  = array();  
28   /* To prevent errors when using the 'apply' button, we use this variables 
29       to manage array attributes */
30         var $use_gotoMimeIcon                                           = NULL;
31         var $use_gotoMimeFilePattern                        = array();
32         var $use_gotoMimeApplication                        = array();
33         var $use_gotoMimeEmbeddedApplication    = array();
35   /* divLists */
36   var $DivPatterns                                                        = NULL;
37   var $DivApps                                                              = NULL;
38   var $DivEApps                                                             = NULL;
40   var $FAIstate ="";
42   /* These vars will be copied too, if you use copy&paste mode */
43   var $CopyPasteVars        = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData",
44                                     "gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q","use_gotoMimeIcon");
46   var $view_logged  = FALSE;
48   /* Select options */
49   var $MimeGroups                             = array("application","audio","chemical","image","inode","message","model",
50                                       "multipart","text","video","x-conference","x-world");
52   /* Orig_Dn is used to verify if this object is new or only edited */          
53   var $orig_dn                  = "";
54   var $orig_base          = "";
56   var $baseSelector;
58   function mimetype(&$config,$dn= NULL)
59   {
60     plugin::plugin ($config, $dn);
62     /* Save original dn */
63     $this->orig_dn = $dn;       
65     /* get gotoMimeLeftClickActions I/E/Q */
66     if(isset($this->gotoMimeLeftClickAction)){
67       $str = $this->gotoMimeLeftClickAction;
68       for($i = 0 ; $i < strlen($str) ; $i ++ ){
69         $varna = "gotoMimeLeftClickAction_". $str[$i];
70         if(isset($this->$varna)){
71           $this->$varna = true;
72         }
73       }
74     }
76     /* Create list of defined applications in GOsa */
77     $ldap = $this->config->get_ldap_link();
78     $ldap->cd($this->config->current['BASE']);
79     $ldap->search("(&(objectClass=gosaApplication)(cn=*))",array('cn'));
80     $this->ApplicationList = array();
81     while($attrs = $ldap->fetch()){
82       $this->ApplicationList[$attrs['cn'][0]] = $attrs['cn'][0];
83     }
85     /* If both radio buttons arn't set, set option I */
86     if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){
87       $this->gotoMimeLeftClickAction_I = true;
88     }
90     /* Get list of array attributes */
91     foreach(array("gotoMimeFilePattern") as $attr){
92       $this->$attr = array();
93       if(isset($this->attrs[$attr])){
94         $tmp = array();
95         for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
96           $str = $this->attrs[$attr][$i];
97           $tmp[] = $str;
98         }
99         $use_attr = "use_".$attr;
100         $this->$use_attr = $tmp;
101       }
102     }
104     /* Get list of array attributes with priority tag ( Test|32 )*/
105     foreach(array("gotoMimeApplication","gotoMimeEmbeddedApplication") as $attr){
106       $this->$attr = array();
107       if(isset($this->attrs[$attr])){
108         $tmp = array();
109         for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
110           $str = $this->attrs[$attr][$i];
111           $tmp2= explode("|",$str);
113           if(count($tmp2) == 2){
114             $name = $tmp2[0];
115             $prio = $tmp2[1];
116             $tmp[$prio] = $name;
117           }
118         }
119         ksort($tmp);
120         $use_attr = "use_".$attr;
121         $this->$use_attr = $tmp;
122       }
123     }
125     /* Set base */      
126     if ($this->dn == "new"){
127       if(session::is_set('CurrentMainBase')){
128         $this->base= session::get('CurrentMainBase');
129       }else{
130         $ui= get_userinfo();
131         $this->base= dn2base($ui->dn);
132       }
133     } else {
134       $this->base= preg_replace ("/^.*,".preg_quote(get_ou("mimetypeRDN"), '/')."/i", "", $this->dn);
135     }
137     /* Get icon data */
138     if(isset($this->attrs['gotoMimeIcon'])){
139       $ldap = $this->config->get_ldap_link();
140       $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon");
141       $this->saved_attributes['gotoMimeIcon'] = $this->iconData;
142     }
143     if ($this->iconData == ""){
144       $this->set_new_picture("");
145     }
146     session::set('binary',$this->iconData);
147     session::set('binarytype',"image/jpeg");
149     /* Instanciate base selector */
150     $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
151     $this->baseSelector->setSubmitButton(false);
152     $this->baseSelector->setHeight(300);
153     $this->baseSelector->update(true);
155     $this->orig_base = $this->base;
158     // Prepare lists
159     $this->patternList = new sortableListing(array(),array(),TRUE);
160     $this->patternList->setDeleteable(true);
161     $this->patternList->setInstantDelete(true);
162     $this->patternList->setEditable(false);
163     $this->patternList->setWidth("100%");
164     $this->patternList->setHeight("100px");
165     $this->patternList->setColspecs(array('200px','*'));
166     $this->patternList->setHeader(array(_("Section"),_("Description")));
167     $this->patternList->setDefaultSortColumn(1);
168     $this->patternList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
170     $this->applicationList = new sortableListing(array(),array(),TRUE);
171     $this->applicationList->setDeleteable(true);
172     $this->applicationList->setEditable(false);
173     $this->applicationList->setWidth("100%");
174     $this->applicationList->setHeight("100px");
175     $this->applicationList->setColspecs(array('200px','*'));
176     $this->applicationList->setHeader(array(_("Section"),_("Description")));
177     $this->applicationList->setInstantDelete(true);
178     $this->applicationList->setDefaultSortColumn(1);
179     $this->applicationList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
181     $this->embeddedList = new sortableListing(array(),array(),TRUE);
182     $this->embeddedList->setDeleteable(true);
183     $this->embeddedList->setEditable(false);
184     $this->embeddedList->setWidth("100%");
185     $this->embeddedList->setInstantDelete(true);
186     $this->embeddedList->setHeight("100px");
187     $this->embeddedList->setColspecs(array('200px','*'));
188     $this->embeddedList->setHeader(array(_("Section"),_("Description")));
189     $this->embeddedList->setDefaultSortColumn(1);
190     $this->embeddedList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
191   }
194   function execute()
195   {
196     plugin::execute();
197     $smarty = get_smarty();
199     /* Assign base ACL */
200     $smarty->assign("base", $this->baseSelector->render());
202     if(!$this->view_logged){
203       $this->view_logged =TRUE;
204       new log("view","mimetypes/".get_class($this),$this->dn);
205     }
207     $tmp = $this->plInfo();
208     foreach($tmp['plProvidedAcls'] as $name => $translation){
209       $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/i",$this->FAIstate)));
210     }
211     $smarty->assign("IconReadable", preg_match("/r/",$this->getacl("gotoMimeIcon",preg_match("/freeze/i",$this->FAIstate))));
213     /* Walk through posts and try to find some commands for us. */
214     if(!preg_match("/freeze/i",$this->FAIstate)){
216       /* Set a new icon was requested */
217       if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){
218         $this->set_new_picture($_FILES['picture_file']['tmp_name']);            
219       }
221       /* Add gotoMimeFilePattern */
222       if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
223         if($this->acl_is_writeable("gotoMimeFilePattern")){
224           $str = trim($_POST['NewFilePattern']);
225           if($str != ""){
226             $this->use_gotoMimeFilePattern[] = $str;
227           }
228         }
229       } 
231       /* Add gotoMimeFilePattern */
232       if(isset($_POST['AddNewApplication']) && 
233           (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){
234         if($this->acl_is_writeable("gotoMimeApplication")){
235           $str = "";
236           if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){
237             $str = trim(get_post("NewApplicationSelect"));
238           }
239           if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){
240             $str = trim(get_post("NewApplication"));
241           }
242           if($str != "" && !in_array($str,$this->use_gotoMimeApplication)){
243             $this->use_gotoMimeApplication[] = $str;
244           }
245         }
246       } 
248       /* Add embedded application 
249        *  - From input or from select box 
250        */
251       if(isset($_POST['AddNewEmbeddedApplication']) && 
252           (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){
253         if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
254           $str = "";
255           if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){
256             $str = trim(get_post('NewEmbeddedApplicationSelect'));
257           }
258           if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){
259             $str = trim(get_post('NewEmbeddedApplication'));
260           }
261           if($str != "" && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){
262             $this->use_gotoMimeEmbeddedApplication[] = $str;
263           }
264         }
265       } 
266     }   
268     // Set list acls 
269     $this->patternList->setAcl($this->getacl("gotoMimeFilePattern", 
270                 preg_match("/freeze/i",$this->FAIstate)));
271     $this->applicationList->setAcl($this->getacl("gotoMimeApplication",
272                 preg_match("/freeze/i",$this->FAIstate)));
273     $this->embeddedList->setAcl($this->getacl("gotoMimeEmbeddedApplication",
274                 preg_match("/freeze/i",$this->FAIstate)));
277     /* Before adding some entries check acls */
278     $data = $lData = array();
279     foreach($this->use_gotoMimeFilePattern as $key => $pattern){
280         $data[$key] = $pattern;
281         $lData[$key] = array('data'=>array($pattern));
282     }                   
283     $this->patternList->setListData($data, $lData);
284     $this->patternList->update();
286     $data = $lData = array();
287     foreach($this->use_gotoMimeApplication as $key => $pattern){
288         $data[$key] = $pattern;
289         $lData[$key] = array('data'=>array($pattern));
290     }                   
291     $this->applicationList->setListData($data, $lData);
292     $this->applicationList->update();
294     $data = $lData = array();
295     foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){
296         $data[$key] = $pattern;
297         $lData[$key] = array('data'=>array($pattern));
298     }
299     $this->embeddedList->setListData($data, $lData);
300     $this->embeddedList->update();
302     $smarty->assign("usePrototype", "true");
303     $smarty->assign("bases",                                            $this->get_allowed_bases());            
304     $smarty->assign("base_select",                                      $this->base);           
305     $smarty->assign("isReleaseMimeType",                        $this->is_release());
306     $smarty->assign("gotoMimeFilePatterns",                     $this->patternList->render());
307     $smarty->assign("gotoMimeApplications",                     $this->applicationList->render());
308     $smarty->assign("gotoMimeEmbeddedApplications",     $this->embeddedList->render());
310     $smarty->assign("ApplicationList",$this->ApplicationList);
311   
312     /* Assign class vars to smarty */
313     foreach($this->attributes as $attr){
314       $smarty->assign($attr,$this->$attr);
315     }   
317     /* Assign additional vars that are not included in attributes*/
318     foreach(array("gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q") as $attr){
319       $smarty->assign($attr,$this->$attr);
320     }   
322     /* Assign select box options */
323     $smarty->assign("gotoMimeGroups",$this->MimeGroups);
324     $smarty->assign("gotoMimeIcon"      ,$this->get_picture());
325     return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
326   }
329   function save_object()
330   {
331       if(isset($_POST['MimeGeneric']) && !preg_match("/freeze/i",$this->FAIstate)){
334           // Act on list actions here
335           $this->patternList->save_object();
336           $this->applicationList->save_object();
337           $this->embeddedList->save_object();
339           $this->use_gotoMimeFilePattern = array_values($this->patternList->getMaintainedData());
340           $this->use_gotoMimeApplication = array_values($this->applicationList->getMaintainedData());
341           $this->use_gotoMimeEmbeddedApplication = array_values($this->embeddedList->getMaintainedData());
343       /* Create a base backup and reset the
344          base directly after calling plugin::save_object();
345          Base will be set seperatly a few lines below */
346       $base_tmp = $this->base;
347       plugin::save_object();
348       $this->base = $base_tmp;
349   
350       /* Only save base if we are not in release mode */
351       if(!$this->is_release()){
353         /* Set new base if allowed */
354         $tmp = $this->get_allowed_bases();
355         if(isset($_POST['base'])){
356           if(isset($tmp[$_POST['base']])){
357             $this->base= $_POST['base'];
358           }
359         }
361       }
363       /* Refresh base */
364       if ($this->acl_is_moveable($this->base)){
365         if (!$this->baseSelector->update()) {
366           msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
367         }
368         if ($this->base != $this->baseSelector->getBase()) {
369           $this->base= $this->baseSelector->getBase();
370           $this->is_modified= TRUE;
371         }
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       new log("modify","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
461     }else{
462       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
463       $ldap->cd($this->dn);
464       $ldap->add($this->attrs);
465       new log("create","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
466     }
467     if (!$ldap->success()){
468       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
469     }
470   }
473   /* Remove current mime type */
474   function remove_from_parent()
475   {
476     plugin::remove_from_parent();
477     $ldap = $this->config->get_ldap_link();
478     $ldap->rmDir($this->dn);
479     if (!$ldap->success()){
480       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
481     }
482     new log("remove","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
484     /* Optionally execute a command after we're done */
485     $this->handle_post_events("remove");
487     /* Delete references to object groups */
488     $ldap->cd ($this->config->current['BASE']);
489     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
490     while ($ldap->fetch()){
491       $og= new ogroup($this->config, $ldap->getDN());
492       unset($og->member[$this->dn]);
493       $og->save ();
494       if (!$ldap->success()){
495         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $og->dn, 0, get_class()));
496       }
497     }
498   }
501   /* Check given values */
502   function check()
503   {
504     $message = plugin::check();
505     if($this->cn == "" ){
506       $message[] = msgPool::required(_("Name"));
507     }
508     if(!count($this->use_gotoMimeFilePattern)){
509       $message[] = msgPool::required(_("File pattern"));
510     }
512     // Check if a wrong base was supplied
513     if(!$this->baseSelector->checkLastBaseUpdate()){
514       $message[]= msgPool::check_base();;
515     }
517     /* Check if there is already a mime type with this cn */
518     $ldap = $this->config->get_ldap_link();
519     $ldap->cd($this->config->current["BASE"]);
521     if($this->is_release()){
522       $base = $this->parent->parent->mime_release;
523     }else{
524       $base = get_ou("mimetypeRDN").$this->base;
525     }
527     $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$base,array("cn"));
528     if($ldap->count()){
529       $attrs = $ldap->fetch();
530       if($this->dn != $attrs['dn']) {
531         $message[]= msgPool::duplicated("cn");
532       }
533     }
535     /* Check if we are allowed to create or move this object
536      */
537     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
538       $message[] = msgPool::permCreate();
539     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
540       $message[] = msgPool::permMove();
541     }
543     return($message);
544   }
547   /** Helper functions **/
549   /* Set a new picture */       
550   function set_new_picture($filename)
551   {
552     if (empty($filename)){
553       $filename= "./plugins/goto/images/default_icon.png";
554       $this->use_gotoMimeIcon= "*removed*";
555     }else{
556       $this->use_gotoMimeIcon= $filename;
557     }
559     if (file_exists($filename)){
560       $fd = fopen ($filename, "rb");
561       $this->iconData= fread ($fd, filesize ($filename));
562       session::set('binary',$this->iconData);
563       session::set('binarytype',"image/jpeg");
564       fclose ($fd);
565     }
566   }
568   /* Get picture link */
569   function get_picture()
570   {
571     session::set('binary',$this->iconData);
572     session::set('binarytype',"image/jpeg");
573     return("getbin.php");
574   }
576   /* Transports the given Arraykey one position up*/
577   function ArrayUp($atr,$attrs)
578   {
579     $ret = $attrs;
580     $pos = $this->getpos($atr,$attrs) ;
581     $cn = count($attrs);
582     if(!(($pos == -1)||($pos == 1))){
583       $before = array_slice($attrs,0,($pos-2));
584       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
585       $unten  = array_slice($attrs,$pos);
586       $ret = array();
587       $ret = $this->combineArrays($before,$mitte,$unten);
588     }
589     return($ret);
590   }
593   /* Transports the given Arraykey one position down*/
594   function ArrayDown($atr,$attrs)
595   {
596     $ret = $attrs;
597     $pos = $this->getpos($atr,$attrs) ;
598     $cn = count($attrs);
599     if(!(($pos == -1)||($pos == $cn))){
600       $before = array_slice($attrs,0,($pos-1));
601       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
602       $unten  = array_slice($attrs,($pos+1));
603       $ret = array();
604       $ret = $this->combineArrays($before,$mitte,$unten);
605     }
606     return($ret);
607   }
610   /* return the position of the element in the array */
611   function getpos($atr,$attrs)
612   {
613     $i = 0;
614     foreach($attrs as $attr => $name)    {
615       $i++;
616       if($attr == $atr){
617         return($i);
618       }
619     }
620     return(-1);
621   }
624   /* Remove this element from array */
625   function ArrayRemove($key,$array,$reorder = false)    
626   {
627     if(isset($array[$key])){
628       unset($array[$key]);
629       if($reorder){
630         $tmp = array();
631         foreach($array as $entry){
632           $tmp[] = $entry;
633         }
634         $array = $tmp;
635       }
636     }   
637     return($array);
638   }
641   /* Combine new array */
642   function combineArrays($ar0,$ar1,$ar2)
643   {
644     $ret = array();
645     if(is_array($ar0))
646       foreach($ar0 as $ar => $a){
647         $ret[]=$a;
648       }
649     if(is_array($ar1))
650       foreach($ar1 as $ar => $a){
651         $ret[]=$a;
652       }
653     if(is_array($ar2))
654       foreach($ar2 as $ar => $a){
655         $ret[]=$a;
656       }
657     return($ret);
658   }
661   /* Return a dialog with all fields that must be changed, 
662      if we want to copy this entry */
663   function getCopyDialog()
664   {
665     $str = "";
667     $smarty = get_smarty();
668     $smarty->assign("cn",               $this->cn);
669     $smarty->assign("description",  $this->description);
670     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
672     $ret = array();
673     $ret['string'] = $str;
674     $ret['status'] = "";
675     return($ret);
676   }
679   /* Save all */
680   function saveCopyDialog()
681   {
682     $attrs = array("cn","description");
683     foreach($attrs as $attr){
684       if(isset($_POST[$attr])){
685         $this->$attr = $_POST[$attr];
686       }
687     }
688   }
690   /* Return plugin informations for acl handling  */ 
691   static function plInfo()
692   {
693     return (array(
694           "plShortName"   => _("Generic"),
695           "plDescription" => _("Mime type generic"),
696           "plSelfModify"  => FALSE,
697           "plDepends"     => array(),
698           "plPriority"    => 0,
699           "plSection"     => array("administration"),
700           "plCategory"    => array("mimetypes" => array("description"  => _("Mime types"),
701                                                         "objectClass"  => "gotoMimeType")),
702           "plProvidedAcls"=> array(
703             "cn"                          => _("Name"),
704             "gotoMimeGroup"               => _("Mime group"),
705             "description"                 => _("Description"),
706             "base"                        => _("Base"),
707             "gotoMimeApplication"         => _("Application"),
708             "gotoMimeLeftClickAction"     => _("Left click action"),
709             "gotoMimeIcon"                => _("Icon"),
710             "gotoMimeFilePattern"         => _("File patterns"),
711             "gotoMimeEmbeddedApplication" => _("Embedded applications"))
712           ));
714   }
717   function is_release()
718   {
719     if(is_object($this->parent->parent)){
720       return($this->parent->parent->IsReleaseManagementActivated());
721     }else{
722       /* Check if we should enable the release selection */
723       $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
724       if(!empty($tmp)){
725         return(true);
726       }
727     }
728     return(FALSE);
729   }
732   function PrepareForCopyPaste($source)
733   {
734     plugin::PrepareForCopyPaste($source);
736     $source_o = new mimetype($this->config,$source['dn'],$this->parent);
738     foreach(array("gotoMimeLeftClickAction_Q","gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern","gotoMimeIcon","iconData") as $name){
739       $use_attr     = "use_".$name;
740       if(isset($this->$use_attr)){
741         $this->$use_attr= $source_o->$use_attr;
742       }
743       $this->$name = $source_o->$name;
744     } 
745     foreach($this->attributes as $name){
746       $this->$name = $source_o->$name;
747     }
749     if($this->iconData){
750       $this->use_gotoMimeIcon ="Not emtpy, causes icon to be written.";
751     }
752   }
754 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
755 ?>