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);
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)){
333 // Act on list actions here
334 $this->patternList->save_object();
335 $this->applicationList->save_object();
336 $this->embeddedList->save_object();
338 $action=$this->patternList->getAction();
339 if(in_array($action['action'],array('delete', 'reorder'))){
340 $this->use_gotoMimeFilePattern = array_values($this->patternList->getMaintainedData());
341 }
342 $action=$this->applicationList->getAction();
343 if(in_array($action['action'],array('delete', 'reorder'))){
344 $this->use_gotoMimeApplication = array_values($this->applicationList->getMaintainedData());
345 }
346 $action=$this->embeddedList->getAction();
347 if(in_array($action['action'],array('delete', 'reorder'))){
348 $this->use_gotoMimeEmbeddedApplication = array_values($this->embeddedList->getMaintainedData());
349 }
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;
358 /* Only save base if we are not in release mode */
359 if(!$this->is_release()){
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 /* Refresh base */
372 if ($this->acl_is_moveable($this->base)){
373 if (!$this->baseSelector->update()) {
374 msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
375 }
376 if ($this->base != $this->baseSelector->getBase()) {
377 $this->base= $this->baseSelector->getBase();
378 $this->is_modified= TRUE;
379 }
380 }
382 /* Save radio buttons */
383 if($this->acl_is_writeable("gotoMimeLeftClickAction")){
384 if(isset($_POST['gotoMimeLeftClickAction_IE'])){
385 $chr = $_POST['gotoMimeLeftClickAction_IE'];
386 if($chr == "E"){
387 $this->gotoMimeLeftClickAction_E = true;
388 $this->gotoMimeLeftClickAction_I = false;
389 }else{
390 $this->gotoMimeLeftClickAction_E = false;
391 $this->gotoMimeLeftClickAction_I = true;
392 }
393 }
394 if(isset($_POST['gotoMimeLeftClickAction_Q'])){
395 $this->gotoMimeLeftClickAction_Q = true;
396 }else{
397 $this->gotoMimeLeftClickAction_Q = false;
398 }
399 }
400 }
401 }
404 /* save current changes */
405 function save()
406 {
407 /* Create gotoMimeLeftClickAction out of checkboxes and radio buttons */
408 $arr = array ("E","I","Q");
409 $str = "";
410 foreach ($arr as $Chr){
411 $var = "gotoMimeLeftClickAction_".$Chr;
412 if($this->$var){
413 $str .= $Chr;
414 }
415 }
416 $this->gotoMimeLeftClickAction = $str;
418 /* Create array entries with priority tag ( Test|3 )*/
419 foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication") as $attr){
420 $i = 0;
421 $use_attr = "use_".$attr;
422 $tmp = array();
423 $this->$attr = array();
424 foreach($this->$use_attr as $entry){
425 $tmp[] = $entry."|".$i ++;
426 }
427 $this->$attr = $tmp;
428 }
430 /* Create array entries */
431 foreach(array("gotoMimeFilePattern") as $attr){
432 $i = 0;
433 $use_attr = "use_".$attr;
434 $tmp = array();
435 $this->$attr = array();
436 foreach($this->$use_attr as $entry){
437 $tmp[] = $entry;
438 }
439 $this->$attr = $tmp;
440 }
442 /* Remove Icon if requested */
443 if($this->use_gotoMimeIcon != "*removed*"){
444 $this->gotoMimeIcon = $this->iconData;
445 }else{
446 $this->gotoMimeIcon = "";
447 }
449 plugin::save();
451 /* If this is a newly created object, skip storing those
452 attributes that contain an empty array */
453 if($this->orig_dn == "new"){
454 foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){
455 if(!count($this->$attr)){
456 unset($this->attrs[$attr]);
457 }
458 }
459 }
461 $ldap = $this->config->get_ldap_link();
462 $ldap-> cd ( $this->config->current['BASE']);
463 $ldap->cat($this->dn);
464 if($ldap->count()){
465 $ldap->cd($this->dn);
466 $this->cleanup();
467 $ldap->modify($this->attrs);
468 new log("modify","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
469 }else{
470 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
471 $ldap->cd($this->dn);
472 $ldap->add($this->attrs);
473 new log("create","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
474 }
475 if (!$ldap->success()){
476 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
477 }
478 }
481 /* Remove current mime type */
482 function remove_from_parent()
483 {
484 plugin::remove_from_parent();
485 $ldap = $this->config->get_ldap_link();
486 $ldap->rmDir($this->dn);
487 if (!$ldap->success()){
488 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
489 }
490 new log("remove","mimetypes/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
492 /* Optionally execute a command after we're done */
493 $this->handle_post_events("remove");
495 /* Delete references to object groups */
496 $ldap->cd ($this->config->current['BASE']);
497 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
498 while ($ldap->fetch()){
499 $og= new ogroup($this->config, $ldap->getDN());
500 unset($og->member[$this->dn]);
501 $og->save ();
502 if (!$ldap->success()){
503 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $og->dn, 0, get_class()));
504 }
505 }
506 }
509 /* Check given values */
510 function check()
511 {
512 $message = plugin::check();
513 if($this->cn == "" ){
514 $message[] = msgPool::required(_("Name"));
515 }
516 if(!count($this->use_gotoMimeFilePattern)){
517 $message[] = msgPool::required(_("File pattern"));
518 }
520 // Check if a wrong base was supplied
521 if(!$this->baseSelector->checkLastBaseUpdate()){
522 $message[]= msgPool::check_base();;
523 }
525 /* Check if there is already a mime type with this cn */
526 $ldap = $this->config->get_ldap_link();
527 $ldap->cd($this->config->current["BASE"]);
529 if($this->is_release()){
530 $base = $this->parent->parent->mime_release;
531 }else{
532 $base = get_ou("mimetypeRDN").$this->base;
533 }
535 $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$base,array("cn"));
536 if($ldap->count()){
537 $attrs = $ldap->fetch();
538 if($this->dn != $attrs['dn']) {
539 $message[]= msgPool::duplicated("cn");
540 }
541 }
543 /* Check if we are allowed to create or move this object
544 */
545 if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
546 $message[] = msgPool::permCreate();
547 }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
548 $message[] = msgPool::permMove();
549 }
551 return($message);
552 }
555 /** Helper functions **/
557 /* Set a new picture */
558 function set_new_picture($filename)
559 {
560 if (empty($filename)){
561 $filename= "./plugins/goto/images/default_icon.png";
562 $this->use_gotoMimeIcon= "*removed*";
563 }else{
564 $this->use_gotoMimeIcon= $filename;
565 }
567 if (file_exists($filename)){
568 $fd = fopen ($filename, "rb");
569 $this->iconData= fread ($fd, filesize ($filename));
570 session::set('binary',$this->iconData);
571 session::set('binarytype',"image/jpeg");
572 fclose ($fd);
573 }
574 }
576 /* Get picture link */
577 function get_picture()
578 {
579 session::set('binary',$this->iconData);
580 session::set('binarytype',"image/jpeg");
581 return("getbin.php");
582 }
584 /* Transports the given Arraykey one position up*/
585 function ArrayUp($atr,$attrs)
586 {
587 $ret = $attrs;
588 $pos = $this->getpos($atr,$attrs) ;
589 $cn = count($attrs);
590 if(!(($pos == -1)||($pos == 1))){
591 $before = array_slice($attrs,0,($pos-2));
592 $mitte = array_reverse(array_slice($attrs,($pos-2),2));
593 $unten = array_slice($attrs,$pos);
594 $ret = array();
595 $ret = $this->combineArrays($before,$mitte,$unten);
596 }
597 return($ret);
598 }
601 /* Transports the given Arraykey one position down*/
602 function ArrayDown($atr,$attrs)
603 {
604 $ret = $attrs;
605 $pos = $this->getpos($atr,$attrs) ;
606 $cn = count($attrs);
607 if(!(($pos == -1)||($pos == $cn))){
608 $before = array_slice($attrs,0,($pos-1));
609 $mitte = array_reverse(array_slice($attrs,($pos-1),2));
610 $unten = array_slice($attrs,($pos+1));
611 $ret = array();
612 $ret = $this->combineArrays($before,$mitte,$unten);
613 }
614 return($ret);
615 }
618 /* return the position of the element in the array */
619 function getpos($atr,$attrs)
620 {
621 $i = 0;
622 foreach($attrs as $attr => $name) {
623 $i++;
624 if($attr == $atr){
625 return($i);
626 }
627 }
628 return(-1);
629 }
632 /* Remove this element from array */
633 function ArrayRemove($key,$array,$reorder = false)
634 {
635 if(isset($array[$key])){
636 unset($array[$key]);
637 if($reorder){
638 $tmp = array();
639 foreach($array as $entry){
640 $tmp[] = $entry;
641 }
642 $array = $tmp;
643 }
644 }
645 return($array);
646 }
649 /* Combine new array */
650 function combineArrays($ar0,$ar1,$ar2)
651 {
652 $ret = array();
653 if(is_array($ar0))
654 foreach($ar0 as $ar => $a){
655 $ret[]=$a;
656 }
657 if(is_array($ar1))
658 foreach($ar1 as $ar => $a){
659 $ret[]=$a;
660 }
661 if(is_array($ar2))
662 foreach($ar2 as $ar => $a){
663 $ret[]=$a;
664 }
665 return($ret);
666 }
669 /* Return a dialog with all fields that must be changed,
670 if we want to copy this entry */
671 function getCopyDialog()
672 {
673 $str = "";
675 $smarty = get_smarty();
676 $smarty->assign("cn", $this->cn);
677 $smarty->assign("description", $this->description);
678 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
680 $ret = array();
681 $ret['string'] = $str;
682 $ret['status'] = "";
683 return($ret);
684 }
687 /* Save all */
688 function saveCopyDialog()
689 {
690 $attrs = array("cn","description");
691 foreach($attrs as $attr){
692 if(isset($_POST[$attr])){
693 $this->$attr = $_POST[$attr];
694 }
695 }
696 }
698 /* Return plugin informations for acl handling */
699 static function plInfo()
700 {
701 return (array(
702 "plShortName" => _("Generic"),
703 "plDescription" => _("Mime type generic"),
704 "plSelfModify" => FALSE,
705 "plDepends" => array(),
706 "plPriority" => 0,
707 "plSection" => array("administration"),
708 "plCategory" => array("mimetypes" => array("description" => _("Mime types"),
709 "objectClass" => "gotoMimeType")),
710 "plProvidedAcls"=> array(
711 "cn" => _("Name"),
712 "gotoMimeGroup" => _("Mime group"),
713 "description" => _("Description"),
714 "base" => _("Base"),
715 "gotoMimeApplication" => _("Application"),
716 "gotoMimeLeftClickAction" => _("Left click action"),
717 "gotoMimeIcon" => _("Icon"),
718 "gotoMimeFilePattern" => _("File patterns"),
719 "gotoMimeEmbeddedApplication" => _("Embedded applications"))
720 ));
722 }
725 function is_release()
726 {
727 if(is_object($this->parent->parent)){
728 return($this->parent->parent->IsReleaseManagementActivated());
729 }else{
730 /* Check if we should enable the release selection */
731 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
732 if(!empty($tmp)){
733 return(true);
734 }
735 }
736 return(FALSE);
737 }
740 function PrepareForCopyPaste($source)
741 {
742 plugin::PrepareForCopyPaste($source);
744 $source_o = new mimetype($this->config,$source['dn'],$this->parent);
746 foreach(array("gotoMimeLeftClickAction_Q","gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern","gotoMimeIcon","iconData") as $name){
747 $use_attr = "use_".$name;
748 if(isset($this->$use_attr)){
749 $this->$use_attr= $source_o->$use_attr;
750 }
751 $this->$name = $source_o->$name;
752 }
753 foreach($this->attributes as $name){
754 $this->$name = $source_o->$name;
755 }
757 if($this->iconData){
758 $this->use_gotoMimeIcon ="Not emtpy, causes icon to be written.";
759 }
760 }
761 }
762 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
763 ?>