Code

Integrated acl/reference dialog by default.
[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 $acl;
16         var $ui;
17         var $cn                                                                               = "";                                     
18         var $gotoMimeLeftClickAction                        = "I";
19         var $gotoMimeLeftClickAction_I              = true;
20         var $gotoMimeLeftClickAction_E              = false;
21         var $gotoMimeLeftClickAction_Q              = false;
22         var $gotoMimeIcon                                                         = "*removed*";
23         var $description                                                          = "";
24         var $gotoMimeFilePattern                                      = array();
25         var $gotoMimeApplication                                      = array();
26         var $gotoMimeEmbeddedApplication            = array();
27         var $gotoMimeGroup                                                      = "";
28         var $iconData                                                               = NULL;     
29         var $base                                                                             = "";
31   /* To prevent errors when using the 'apply' button, we use this variables 
32       to manage array attributes */
33         var $use_gotoMimeIcon                                           = NULL;
34         var $use_gotoMimeFilePattern                        = array();
35         var $use_gotoMimeApplication                        = array();
36         var $use_gotoMimeEmbeddedApplication    = array();
38   /* divLists */
39   var $DivPatterns                                                        = NULL;
40   var $DivApps                                                              = NULL;
41   var $DivEApps                                                             = NULL;
43   /* Mime type release mode */
44   var $isReleaseMimeType                                              = false;
45   var $dialog                                                                       = NULL;
47   /* These vars will be copied too, if you use copy&paste mode */
48   var $CopyPasteVars        = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData");
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                  = "";
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     /* If both radio buttons arn't set, set option I */
77     if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){
78       $this->gotoMimeLeftClickAction_I = true;
79     }
81     /* Get list of array attributes */
82     foreach(array("gotoMimeFilePattern") as $attr){
83       $this->$attr = array();
84       if(isset($this->attrs[$attr])){
85         $tmp = array();
86         for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
87           $str = $this->attrs[$attr][$i];
88           $tmp[] = $str;
89         }
90         $use_attr = "use_".$attr;
91         $this->$use_attr = $tmp;
92       }
93     }
95     /* Get list of array attributes with priority tag ( Test|32 )*/
96     foreach(array("gotoMimeApplication","gotoMimeEmbeddedApplication") as $attr){
97       $this->$attr = array();
98       if(isset($this->attrs[$attr])){
99         $tmp = array();
100         for($i = 0 ; $i < $this->attrs[$attr]['count'] ; $i ++){
101           $str = $this->attrs[$attr][$i];
102           $tmp2= split("\|",$str);
104           if(count($tmp2) == 2){
105             $name = $tmp2[0];
106             $prio = $tmp2[1];
107             $tmp[$prio] = $name;
108           }
109         }
110         ksort($tmp);
111         $use_attr = "use_".$attr;
112         $this->$use_attr = $tmp;
113       }
114     }
116     /* Check if release Management is enabled */
117     $tmp = search_config($this->config->data,"faiManagement","CLASS");
118     if(!empty($tmp)) {
119       $this->isReleaseMimeType= true;
120     }
122     /* Set base */      
123     if ($this->dn == "new"){
124       if(isset($_SESSION['CurrentMainBase'])){
125         $this->base= $_SESSION['CurrentMainBase'];
126       }else{
127         $ui= get_userinfo();
128         $this->base= dn2base($ui->dn);
129       }
130     } else {
131       $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
132     }
134     /* Get icon data */
135     if(isset($this->attrs['gotoMimeIcon'])){
136       $ldap = $this->config->get_ldap_link();
137       $this->iconData = $ldap->get_attribute($this->dn,"gotoMimeIcon");
138       $this->saved_attributes['gotoMimeIcon'] = $this->iconData;
139     }
140     if ($this->iconData == ""){
141       $this->set_new_picture("");
142     }
143     $_SESSION['binary']                 = $this->iconData;
144     $_SESSION['binarytype']             = "image/jpeg";
145   }
148   function execute()
149   {
150     $smarty = get_smarty();
152     /* Base select dialog */
153     $once = true;
154     foreach($_POST as $name => $value){
155       if(preg_match("/^chooseBase/",$name) && $once){
156         $once = false;
157         $this->dialog = new baseSelectDialog($this->config,$this);
158         echo $this->base;
159         $this->dialog->setCurrentBase($this->base);
160       }
161     }
163     /* Dialog handling */
164     if(is_object($this->dialog)){
166       /* Must be called before save_object */
167       $this->dialog->save_object();
169       if($this->dialog->isClosed()){
170         $this->dialog = false;
171       }elseif($this->dialog->isSelected()){
172         $this->base = $this->dialog->isSelected();
173         $this->dialog= false;
174       }else{
175         return($this->dialog->execute());
176       }
177     }
179     /* Check Posts */
180     $posts = array(     
181         "/^Pattern_SortUp_/"    => array("Action" => "Pattern_SortUp",  "Func" => "ArrayUp",    "Attr" => "use_gotoMimeFilePattern"),
182         "/^Pattern_SortDown_/"  => array("Action" => "Pattern_SortDown","Func" => "ArrayDown",  "Attr" => "use_gotoMimeFilePattern"),
183         "/^Pattern_Remove_/"    => array("Action" => "Pattern_Remove",  "Func" => "ArrayRemove","Attr" => "use_gotoMimeFilePattern"),
184         "/^Apps_SortUp_/"               => array("Action" => "Apps_SortUp",             "Func" => "ArrayUp",    "Attr" => "use_gotoMimeApplication"),
185         "/^Apps_SortDown_/"     => array("Action" => "Apps_SortDown",   "Func" => "ArrayDown",  "Attr" => "use_gotoMimeApplication"),
186         "/^Apps_Remove_/"               => array("Action" => "Apps_Remove",             "Func" => "ArrayRemove","Attr" => "use_gotoMimeApplication"),
187         "/^EApps_SortUp_/"              => array("Action" => "EApps_SortUp",    "Func" => "ArrayUp",    "Attr" => "use_gotoMimeEmbeddedApplication"),
188         "/^EApps_SortDown_/"    => array("Action" => "EApps_SortDown",  "Func" => "ArrayDown",  "Attr" => "use_gotoMimeEmbeddedApplication"),
189         "/^EApps_Remove_/"              => array("Action" => "EApps_Remove",    "Func" => "ArrayRemove","Attr" => "use_gotoMimeEmbeddedApplication"));          
190     $once = true;
192     /* Walk through posts and try to find some commands for us. */
193     foreach($_POST as $name => $value){
195       /* Walk through possible commands */
196       foreach($posts as $regex => $action){
198         /* Check if there is a command posted */
199         if(preg_match($regex,$name) && $once){
200           $once = false;
202           /* Get action vars */
203           $func                 = $action['Func'];              // Get function name 
204           $attr                 = $action['Attr'];              // Get attribute name
206           /* Get entry id */
207           $s_entry      = preg_replace($regex,"",$name);
208           $s_entry      = preg_replace("/_[xy]$/","",$s_entry); 
210           /* Execute a command with the given attribute and entry 
211              e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */
212           if(chkacl($this->acl,$attr) == ""){
213             $this->$attr= $this->$func($s_entry,$this->$attr,true);                                      
214           }
215         }
216       }
217     }
219     /* Set a new icon was requested */
220     if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){
221       $this->set_new_picture($_FILES['picture_file']['tmp_name']);              
222     }
224     /* Add gotoMimeFilePattern */
225     if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){
226       if(chkacl($this->acl,"gotoMimeFilePattern") == ""){
227         $str = $_POST['NewFilePattern'];
228         if(!empty($str)){
229           $this->use_gotoMimeFilePattern[] = $str;
230         }
231       }
232     }   
234     /* Add gotoMimeFilePattern */
235     if(isset($_POST['AddNewApplication']) && isset($_POST['NewApplication'])){
236       if(chkacl($this->acl,"gotoMimeApplication") == ""){
237         $str = $_POST['NewApplication'];
238         if(!empty($str)){
239           $this->use_gotoMimeApplication[] = $str;
240         }
241       }
242     }   
244     /* Add gotoMimeFilePattern */
245     if(isset($_POST['AddNewEmbeddedApplication']) && isset($_POST['NewEmbeddedApplication'])){
246       if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){
247         $str = $_POST['NewEmbeddedApplication'];
248         if(!empty($str)){
249           $this->use_gotoMimeEmbeddedApplication[] = $str;
250         }
251       }
252     }   
254     /* Create divlists */
255     $DivPatterns        = new DivSelectBox("gotoMimePatterns");
256     $DivApps            = new DivSelectBox("gotoMimeApplications");
257     $DivEApps           = new DivSelectBox("gotoMimeEmbeddedApplications");
258     $DivPatterns        -> SetHeight(100);
259     $DivApps            -> SetHeight(100);
260     $DivEApps           -> SetHeight(100);
263     if(chkacl($this->acl,"gotoMimeFilePattern") == ""){
264       $Pattern_Actions= " <input type='image' src='images/sort_up.png'  class='center'  name='Pattern_SortUp_%s' >&nbsp;
265       <input type='image' src='images/sort_down.png'    class='center'  name='Pattern_SortDown_%s'>&nbsp;
266       <input type='image' src='images/edittrash.png'    class='center'  name='Pattern_Remove_%s'>";
267     }else{
268       $Pattern_Actions= "";     
269     }
271     if(chkacl($this->acl,"gotoMimeApplication") == ""){
272       $Apps_Actions     = " <input type='image' src='images/sort_up.png'        class='center'  name='Apps_SortUp_%s' >&nbsp;
273       <input type='image' src='images/sort_down.png'    class='center'  name='Apps_SortDown_%s'>&nbsp;
274       <input type='image' src='images/edittrash.png'    class='center'  name='Apps_Remove_%s'>";
275     }else{
276       $Apps_Actions= "";        
277     }
279     if(chkacl($this->acl,"gotoMimeEmbeddedApplication") == ""){
280       $EApps_Actions    = " <input type='image' src='images/sort_up.png'        class='center'  name='EApps_SortUp_%s' >&nbsp;
281       <input type='image' src='images/sort_down.png'    class='center'  name='EApps_SortDown_%s'>&nbsp;
282       <input type='image' src='images/edittrash.png'    class='center'  name='EApps_Remove_%s'>";
283     }else{
284       $EApps_Actions= "";       
285     }
287     foreach($this->use_gotoMimeFilePattern as $key => $pattern){
288       $field1 = array("string" => $pattern);
289       $field2 = array("string" => preg_replace("/%s/",$key,$Pattern_Actions),"attach"=>"style='border-right:0px;width:50px;'");
290       $fields = array($field1,$field2);
291       $DivPatterns -> AddEntry($fields);
292     }                   
293     foreach($this->use_gotoMimeApplication as $key => $pattern){
294       $field1 = array("string" => $pattern);
295       $field2 = array("string" => preg_replace("/%s/",$key,$Apps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
296       $fields = array($field1,$field2);
297       $DivApps -> AddEntry($fields);
298     }                   
299     foreach($this->use_gotoMimeEmbeddedApplication as $key => $pattern){
300       $field1 = array("string" => $pattern);
301       $field2 = array("string" => preg_replace("/%s/",$key,$EApps_Actions),"attach"=>"style='border-right:0px;width:50px;'");
302       $fields = array($field1,$field2);
303       $DivEApps -> AddEntry($fields);
304     }
305     $smarty->assign("baseACL",                                          chkacl($this->acl,"base"));     
306     $smarty->assign("bases",                                            $this->config->idepartments);           
307     $smarty->assign("base_select",                                      $this->base);           
308     $smarty->assign("isReleaseMimeType",                        $this->isReleaseMimeType);
309     $smarty->assign("gotoMimeFilePatterns",                     $DivPatterns->DrawList());
310     $smarty->assign("gotoMimeApplications",                     $DivApps->DrawList());
311     $smarty->assign("gotoMimeEmbeddedApplications",     $DivEApps->DrawList());
313     /* Assign class vars to smarty */
314     foreach($this->attributes as $attr){
315       $smarty->assign($attr,$this->$attr);
316       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
317     }   
319     /* Assign additional vars that are not included in attributes*/
320     foreach(array("gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q") as $attr){
321       $smarty->assign($attr,$this->$attr);
322     }   
324     /* Assign select box options */
325     $smarty->assign("gotoMimeGroups",$this->MimeGroups);
326     $smarty->assign("gotoMimeIcon"      ,$this->get_picture());
327     return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
328   }
331   function save_object()
332   {
333     if(isset($_POST['MimeGeneric'])){
334       plugin::save_object();
336       /* Only save base if we are not in release mode */
337       if(!$this->isReleaseMimeType){
338         if(isset($_POST['base'])){
339           $this->base = $_POST['base'];
340         }
341       }
343       /* Save radio buttons */
344       if(chkacl($this->acl,"gotoMimeLeftClickAction")== ""){
345         if(isset($_POST['gotoMimeLeftClickAction_IE'])){
346           $chr = $_POST['gotoMimeLeftClickAction_IE'];
347           if($chr == "E"){
348             $this->gotoMimeLeftClickAction_E = true;
349             $this->gotoMimeLeftClickAction_I = false;
350           }else{
351             $this->gotoMimeLeftClickAction_E = false;
352             $this->gotoMimeLeftClickAction_I = true;
353           }
354         }
355         if(isset($_POST['gotoMimeLeftClickAction_Q'])){
356           $this->gotoMimeLeftClickAction_Q = true;
357         }else{
358           $this->gotoMimeLeftClickAction_Q = false;
359         }
360       }
361     }
362   }
365   /* save current changes */
366   function save()
367   {
368     /* Create gotoMimeLeftClickAction out of checkboxes and radio buttons */    
369     $arr = array ("E","I","Q");
370     $str = "";
371     foreach ($arr as $Chr){
372       $var = "gotoMimeLeftClickAction_".$Chr;
373       if($this->$var){
374         $str .= $Chr;
375       }
376     }
377     $this->gotoMimeLeftClickAction = $str;
379     /* Create array entries with priority tag ( Test|3 )*/
380     foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication") as $attr){
381       $i                                = 0;
382       $use_attr                 = "use_".$attr;
383       $tmp                      = array();
384       $this->$attr      = array();
385       foreach($this->$use_attr as $entry){
386         $tmp[] = $entry."|".$i ++;
387       }
388       $this->$attr = $tmp;
389     }
391     /* Create array entries */
392     foreach(array("gotoMimeFilePattern") as $attr){
393       $i                                = 0;
394       $use_attr                 = "use_".$attr;
395       $tmp                      = array();
396       $this->$attr      = array();
397       foreach($this->$use_attr as $entry){
398         $tmp[] = $entry;
399       }
400       $this->$attr = $tmp;
401     }
403     /* Remove Icon if requested  */
404     if($this->use_gotoMimeIcon != "*removed*"){
405       $this->gotoMimeIcon = $this->iconData;
406     }else{
407       $this->gotoMimeIcon = "";
408     }
410     plugin::save();
412     /* If this is a newly created object, skip storing those 
413        attributes that contain an empty array */
414     if($this->orig_dn == "new"){
415       foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){
416         if(!count($this->$attr)){
417           unset($this->attrs[$attr]);
418         }
419       }
420     }
422     $ldap = $this->config->get_ldap_link();
423     $ldap-> cd ( $this->config->current['BASE']);
424     $ldap->cat($this->dn);
425     if($ldap->count()){
426       $ldap->cd($this->dn);
427       $this->cleanup();
428       $ldap->modify($this->attrs);
429     }else{
430       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
431       $ldap->cd($this->dn);
432       $ldap->add($this->attrs);
433     }
434     show_ldap_error($ldap->get_error(), sprintf(_("Saving of mime type/generic with dn '%s' failed."),$this->dn));
435   }
438   /* Remove current mime type */
439   function remove_from_parent()
440   {
441     $ldap = $this->config->get_ldap_link();
442     $ldap->rmDir($this->dn);
443     show_ldap_error($ldap->get_error(), sprintf(_("Removing of mime type/generic with dn '%s' failed."),$this->dn));
445     /* Optionally execute a command after we're done */
446     $this->handle_post_events("remove");
448     /* Delete references to object groups */
449     $ldap->cd ($this->config->current['BASE']);
450     $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
451     while ($ldap->fetch()){
452       $og= new ogroup($this->config, $ldap->getDN());
453       unset($og->member[$this->dn]);
454       $og->save ();
455       show_ldap_error($ldap->get_error(), sprintf(_("Removing mime type from objectgroup '%s' failed"), $og->dn));
456     }
457   }
460   /* Check given values */
461   function check()
462   {
463     $message = plugin::check();
464     if(empty($this->cn)){
465       $message[] = _("Please specify a valid name for this mime type.");
466     }
467     if(!count($this->use_gotoMimeFilePattern)){
468       $message[] = _("Please specify at least one file pattern.") ;
469     }
471     /* Check if there is already a mime type with this cn */
472     $ldap = $this->config->get_ldap_link();
473     $ldap->cd($this->config->current["BASE"]);
474     if($this->isReleaseMimeType && (isset($_SESSION['mimefilter']['release']))){
475       $baseDn = str_replace($this->config->current['BASE'],$this->base,$_SESSION['mimefilter']['release']);
476       $baseDn = preg_replace("/ou=mime,.*/","ou=mime,".$this->base,$_SESSION['mimefilter']['release']);
477       $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))",$baseDn,array("cn"));
478       if($ldap->count()){
479         $attrs = $ldap->fetch();
480         if($this->dn != $attrs['dn']) {
481           $message[]= _("There's already a mime type with this 'Name'.");
482         }
483       }
484     }else{
485       $ldap->ls("(&(objectClass=gotoMimeType)(cn=".$this->cn."))","ou=mime,".$this->base,array("cn"));
486       if ($ldap->count()){
487         $attrs = $ldap->fetch();
488         if($this->dn != $attrs['dn']) {
489           $message[]= _("There's already an mime with this 'Name'.");
490         }
491       }
492     }
494     /* Check permissions for that base? */
495     if ($this->base != ""){
496       $new_dn= "cn=".$this->cn.",ou=mime,".$this->base;
497     } else {
498       $new_dn= $this->dn;
499     }
500     if (chkacl($this->acl, "create") != ""){
501       $message[]= _("You have no permissions to create a mime type on this 'Base'.");
502     }
504     return($message);
505   }
507   /** Helper functions **/
509   /* Set a new picture */       
510   function set_new_picture($filename)
511   {
512     if (empty($filename)){
513       $filename= "./images/default_icon.png";
514       $this->use_gotoMimeIcon= "*removed*";
515     }
517     if (file_exists($filename)){
518       $fd = fopen ($filename, "rb");
519       $this->iconData= fread ($fd, filesize ($filename));
520       $_SESSION['binary']= $this->iconData;
521       $_SESSION['binarytype']= "image/jpeg";
522       fclose ($fd);
523     }
524   }
526   /* Get picture link */
527   function get_picture()
528   {
529     $_SESSION['binary']= $this->iconData;
530     $_SESSION['binarytype']= "image/jpeg";
531     return("getbin.php");
532   }
534   /* Transports the given Arraykey one position up*/
535   function ArrayUp($atr,$attrs)
536   {
537     $ret = $attrs;
538     $pos = $this->getpos($atr,$attrs) ;
539     $cn = count($attrs);
540     if(!(($pos == -1)||($pos == 1))){
541       $before = array_slice($attrs,0,($pos-2));
542       $mitte  = array_reverse(array_slice($attrs,($pos-2),2));
543       $unten  = array_slice($attrs,$pos);
544       $ret = array();
545       $ret = $this->combineArrays($before,$mitte,$unten);
546     }
547     return($ret);
548   }
551   /* Transports the given Arraykey one position down*/
552   function ArrayDown($atr,$attrs)
553   {
554     $ret = $attrs;
555     $pos = $this->getpos($atr,$attrs) ;
556     $cn = count($attrs);
557     if(!(($pos == -1)||($pos == $cn))){
558       $before = array_slice($attrs,0,($pos-1));
559       $mitte  = array_reverse(array_slice($attrs,($pos-1),2));
560       $unten  = array_slice($attrs,($pos+1));
561       $ret = array();
562       $ret = $this->combineArrays($before,$mitte,$unten);
563     }
564     return($ret);
565   }
568   /* return the position of the element in the array */
569   function getpos($atr,$attrs)
570   {
571     $i = 0;
572     foreach($attrs as $attr => $name)    {
573       $i++;
574       if($attr == $atr){
575         return($i);
576       }
577     }
578     return(-1);
579   }
582   /* Remove this element from array */
583   function ArrayRemove($key,$array,$reorder = false)    
584   {
585     if(isset($array[$key])){
586       unset($array[$key]);
587       if($reorder){
588         $tmp = array();
589         foreach($array as $entry){
590           $tmp[] = $entry;
591         }
592         $array = $tmp;
593       }
594     }   
595     return($array);
596   }
599   /* Combine new array */
600   function combineArrays($ar0,$ar1,$ar2)
601   {
602     $ret = array();
603     if(is_array($ar0))
604       foreach($ar0 as $ar => $a){
605         $ret[]=$a;
606       }
607     if(is_array($ar1))
608       foreach($ar1 as $ar => $a){
609         $ret[]=$a;
610       }
611     if(is_array($ar2))
612       foreach($ar2 as $ar => $a){
613         $ret[]=$a;
614       }
615     return($ret);
616   }
619   /* Return a dialog with all fields that must be changed, 
620      if we want to copy this entry */
621   function getCopyDialog()
622   {
623     $str = "";
625     $smarty = get_smarty();
626     $smarty->assign("cn",               $this->cn);
627     $smarty->assign("description",  $this->description);
628     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
630     $ret = array();
631     $ret['string'] = $str;
632     $ret['status'] = "";
633     return($ret);
634   }
637   /* Save all */
638   function saveCopyDialog()
639   {
640     $attrs = array("cn","description");
641     foreach($attrs as $attr){
642       if(isset($_POST[$attr])){
643         $this->$attr = $_POST[$attr];
644       }
645     }
646   }
648 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
649 ?>