Code

Updated browser detection-
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiManagement.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
22 class faiManagement extends plugin
23 {
24         /* Definitions */
25   var $plHeadline     = "Software deployment";
26   var $plDescription    = "Manage software packages and deployment reciepes";
28         /* Headpage attributes */
29   var $lock_type    = "";    // should be branch/freeze
30   var $lock_name    = "";
31   var $lock_dn      = "";  
33         /* attribute list for save action */
34         var $attributes         = array("lock_type","lock_name","lock_dn");     //      Attributes Managed by this plugin 
35         var $objectclasses= array();    //      ObjectClasses which the attributes are related to
36         var $dialog                             = array();      //      This object contains every dialog we have currently opened
38         var $objects                    = array();      //      This array contains all available objects shown in divlist
39         var $is_dialog          = false;
41   var $dispNewBranch= false;
42   var $dispNewFreeze= false;
44   var $DivListFai;
45   var $start_pasting_copied_objects = FALSE;
46   var $CopyPasteHandler = FALSE;
48   /* Allow inserting of new elements if freezed releases 
49   */
50   var $allow_freeze_object_attach = TRUE;
52   var $no_save;
53   var $fai_base     ="";
54   var $fai_release  ="";
56   var $acl_module = array("fai");
58         /* construction/reconstruction 
59          */
60         function faiManagement (&$config, $ui)
61         {
62                 /* Set defaults */
63                 $this->dn                       = "";
64                 $this->config   = $config;
65                 $this->ui                       = $ui;  
66     
67     /* Creat dialog object */
68     $this->DivListFai = new divListFai($this->config,$this);
70     /* Copy & Paste handler */
71     if ($this->config->boolValueIsTrue("main", "enableCopyPaste")){
72       $this->CopyPasteHandler= new CopyPasteHandler($this->config);
73     }
75     /* Set default release */
76     $this->fai_base = get_ou("faiou").$this->config->current['BASE'];
77     if(!session::is_set("fai_filter")){
78       session::set("fai_filter",array("fai_release" => $this->fai_base));
79     }
81     $fai_filter = session::get("fai_filter");
82     $this->fai_release = $fai_filter['fai_release'];
83         }
85         function execute()
86         {
87     /* Call parent execute */
88     plugin::execute();
90     /* Initialise vars and smarty */
91                 $smarty         = get_smarty();
92                 $smarty->assign("BranchName","");
93     
94                 $display        = "";
95     $s_action   = "";
96                 $s_entry        = "";
97     $no_save = FALSE;   // hide Apply / Save buttons
98     
99     /* If an entry was locked, these vars will be stored in a session to allow direct edit */
100     session::set('LOCK_VARS_TO_USE',array("/^edit_freeze_entry$/","/^edit_entry$/","/^id$/","/^entry_edit_/","/^entry_delete_/","/^item_selected/","/^remove_multiple_fai_objects/","/^menu_action/"));
103     /****************
104       Handle posts 
105      ****************/
107                 /* Check ImageButton posts
108                  * Create new tab ich new_xx is posted
109                  */
110     $posts = array( "/remove_branch/"=>"remove_branch",    "/branch_branch/"=>"branch_branch",
111                     "/freeze_branch/"=>"freeze_branch",    "/create_partition/i"=>"new_partition",
112                     "/create_script/i"=>"new_script",      "/create_hook/i"=>"new_hook",
113                     "/create_variable/i"=>"new_variable",  "/create_template/i"=>"new_template",
114                     "/create_package/i"=>"new_package",    "/create_profile/i"=>"new_profile",
115                     "/edit_continue/"=>"select_class_name_finished",
116                     "/^multiple_copy_fai/" => "copy_multiple", 
117                     "/^multiple_cut_fai/" => "cut_multiple", 
118                     "/^copy/" => "copy",
119                     "/^remove_multiple_fai_objects/" => "del_multiple");
121                 foreach($_POST as $name => $value){
122       foreach($posts as $reg => $act ){
123         if(preg_match($reg,$name)){
124           $s_action = $act;
125           $s_entry = ltrim(preg_replace($reg,"",$name),"_");
126           $s_entry = preg_replace("/_.*$/","",$s_entry);
127         }
128       }
129                         if(preg_match("/^entry_edit_.*/",$name)){
130                                 $s_entry = preg_replace("/^entry_edit_/","",$name);
131                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
132                                 $s_action = "edit";
133                         }elseif(preg_match("/^entry_freeze_edit_.*/",$name)){
134                                 $s_entry = preg_replace("/^entry_freeze_edit_/","",$name);
135                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
136                                 $s_action = "edit";
137         $no_save = TRUE;
138                         }elseif(preg_match("/^entry_delete_.*/",$name)){
139                                 $s_entry = preg_replace("/^entry_delete_/","",$name);
140                                 $s_entry = preg_replace("/_.*$/","",$s_entry);
141         $s_action = "delete";
142       }
143     }
145                 if(isset($_GET['edit_entry'])){
146                         $s_entry = $_GET['edit_entry'];
147                         $s_action = "edit";
148                 }
150                 if(isset($_GET['edit_freeze_entry'])){
151                         $s_entry = $_GET['edit_freeze_entry'];
152                         $s_action = "edit";
153       $no_save = TRUE;
154                 }
156     if(isset($_GET['act']) && $_GET['act'] == "freeze_branch"){
157       $s_action = "freeze_branch";
158     }
159     if(isset($_GET['act']) && $_GET['act'] == "branch_branch"){
160       $s_action = "branch_branch";
161     }
162     if(isset($_GET['act']) && $_GET['act'] == "remove_branch"){
163       $s_action = "remove_branch";
164     }
165     
166     if((isset($_POST['CancelBranchName'])) || (isset($_POST['CloseIFrame']))){
167       $this->dispNewBranch = false;
168       $this->dispNewFreeze = false;
169     }
172     $type_acl_mapping = array(
173         "FAIpartitionTable"  => "faiPartitionTable", 
174         "FAIpackageList"     => "faiPackage",
175         "FAIscript"          => "faiScript",
176         "FAIvariable"        => "faiVariable",
177         "FAIhook"            => "faiHook",
178         "FAIprofile"         => "faiProfile",
179         "FAItemplate"        => "faiTemplate");
182     /* handle C&P from layers menu */
183     if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
184       $s_action = "copy_multiple";
185     }
186     if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
187       $s_action = "cut_multiple";
188     }
189     if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
190       $s_action = "editPaste";
191     }
193     /* Create options */
194     if(isset($_POST['menu_action']) && preg_match("/^Create_/",$_POST['menu_action'])){
195       $s_action = "new_".preg_replace("/^Create_/","",$_POST['menu_action']);;
196       $s_entry  = preg_replace("/^Create_/","",$_POST['menu_action']);
197     }
199     /* handle remove from layers menu */
200     if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
201       $s_action = "del_multiple";
202     }
205     if(!empty($s_action)){
206       $this->no_save = $no_save;
207     }
209     /********************
210       Copy & Paste
211      ********************/
213     /* Display the copy & paste dialog, if it is currently open */
214     $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
215     if($ret){
216       return($ret);
217     }
220     /****************
221       Delete confirme dialog 
222      ****************/
224                 if ($s_action=="delete"){
226       /* Get 'dn' from posted termlinst */
227       $this->dn= $this->objects[$s_entry]['dn'];
229                         /* Load permissions for selected 'dn' and check if
230                            we're allowed to remove this 'dn' */
231       $acl  = $this->ui->get_permissions($this->dn,"fai/".$type_acl_mapping[$this->objects[$s_entry]['type']]);
232       if(preg_match("/d/",$acl)){
234                                 /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
235                                 if (($user= get_lock($this->dn)) != ""){
236                                         return(gen_locked_message ($user, $this->dn));
237                                 }
239                                 /* Lock the current entry, so nobody will edit it during deletion */
240                                 add_lock ($this->dn, $this->ui->dn);
241                                 $smarty->assign("warning",msgPool::deleteInfo(@LDAP::fix($this->dn),_("FAI object")));
242         $smarty->assign("multiple", false);
243                                 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
244                         } else {
246                                 /* Obviously the user isn't allowed to delete. Show message and clean session. */
247         msg_dialog::display(_("Permission error"), msgPool::permDelete(),ERROR_DIALOG);
248                         }
249                 }
252     /********************
253       Delete MULTIPLE entries requested, display confirm dialog
254      ********************/
256     if ($s_action=="del_multiple"){
257       $this->dns = array();
258       $ids = $this->list_get_selected_items();
260       if(count($ids)){
262         $errors = "";
263         foreach($ids as $id){
264           $dn = $this->objects[$id]['dn'];
265           $cn = $this->objects[$id]['cn'];
266           if(!preg_match('/^freeze/', $this->objects[$id]['FAIstate'])){
267             $this->dns[$id] = $dn;
268           }else{
269             $errors .= $cn.", ";
270           }
271         }
272         if ($user= get_multiple_locks($this->dns)){
273           return(gen_locked_message($user,$this->dns));
274         }
276         if($errors != ""){
277           msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
278             "<br><br>".trim($errors,", ")),INFO_DIALOG);
279         }
281         if(count($this->dns)){
283           $dns_names = array();
284           foreach($this->dns as $dn){
285             add_lock ($dn, $this->ui->dn);
286             $dns_names[] = @LDAP::fix($dn);
287           }
289           /* Lock the current entry, so nobody will edit it during deletion */
290                                   $smarty->assign("warning",msgPool::deleteInfo($dns_names,_("FAI object")));
291           $smarty->assign("multiple", true);
292           return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
293         }
294       }
295     }
298     /********************
299       Delete MULTIPLE entries confirmed
300      ********************/
302     /* Confirmation for deletion has been passed. Users should be deleted. */
303     if (isset($_POST['delete_multiple_fai_object_confirm'])){
305       /* Find out more about the object type */
306       $ldap   = $this->config->get_ldap_link();
308       /* Remove user by user and check acls before removeing them */
309       foreach($this->dns as $key => $dn){
311         $ldap->cat($dn, array('objectClass'));
312         $attrs  = $ldap->fetch();
313         $type   = $this->get_type($attrs);
315         $acl  = $this->ui->get_permissions($dn,"fai/".$type[1]);
316         if(preg_match("/d/",$acl)){
318           $this->dialog = new $type[0]($this->config, $this->config->data['TABS'][$type[2]], $dn,"fai");
319           $this->dialog->parent = &$this;
320           $this->dialog->set_acl_base($dn);
321           $this->dialog->by_object[$type[1]]->remove_from_parent ();
322           unset ($this->dialog);
323           $this->dialog= FALSE;
324           $to_del = FAI::clean_up_releases($dn);
325           FAI::save_release_changes_now();
327           foreach($to_del as $dn){
328             $ldap->rmdir_recursive($dn);
329           }
331         } else {
333           /* Normally this shouldn't be reached, send some extra
334              logs to notify the administrator */
335           msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
336           new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
337         }
338       }
340       /* Remove lock file after successfull deletion */
341       $this->remove_lock();
342       $this->dns = array();
343     }
346     /********************
347       Delete MULTIPLE entries Canceled
348      ********************/
350     /* Remove lock */
351     if(isset($_POST['delete_multiple_fai_object_cancel'])){
352       $this->dns = array();
353       $this->remove_lock();
354     }
357     /****************
358       Delete aborted  
359      ****************/
361                 /* Delete canceled? */
362                 if (isset($_POST['delete_cancel'])){
363       $this->remove_lock();
364                 }
367     /****************
368       Delete confirmed 
369      ****************/
371                 /* Deltetion was confirmed, so delete this entry
372      */
373     if (isset($_POST['delete_terminal_confirm'])){
375       /* Some nice guy may send this as POST, so we've to check
376          for the permissions again. */
378       /* Find out more about the object type */
379       $ldap       = $this->config->get_ldap_link();
380       $ldap->cat($this->dn, array('objectClass'));
381       if($ldap->count()){
382         $attrs  = $ldap->fetch();
383         $type     = $this->get_type($attrs);                    
385         $acl  = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
386         if(preg_match("/d/",$acl)){
388           $this->dialog = new $type[0]($this->config,   $this->config->data['TABS'][$type[2]], $this->dn,"fai");
389           $this->dialog->set_acl_base($this->dn);
390           $this->dialog->parent = &$this;
391           $this->dialog->by_object[$type[1]]->remove_from_parent ();
392           unset ($this->dialog);
393           $this->dialog= FALSE;
394           $to_del = FAI::clean_up_releases($this->dn);
395           FAI::save_release_changes_now();
397           foreach($to_del as $dn){
398             $ldap->rmdir_recursive($dn);
399           }
401         } else {
403           /* Normally this shouldn't be reached, send some extra
404              logs to notify the administrator */
405           msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
406           new log("security","fai/".get_class($this),$dn,array(),"Tried to trick deletion.");
407         }
409       }else{
410         msg_dialog::display(_("Error"), sprintf(_("Cannot delete '%s': object does not exist!"), $this->dn) , ERROR_DIALOG);
411       }
413       /* Remove lock file after successfull deletion */
414       $this->remove_lock();
415     }
418     /****************
419       Edit entry 
420      ****************/
422                 if(($s_action == "edit") && (!isset($this->dialog->config))){
423                         $entry    = $this->objects[$s_entry];
424                         $a_setup  = $this->get_type($entry);
425                         $this->dn = $entry['dn'];
427                         /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */
428                         if (($user= get_lock($this->dn)) != ""){
429                                 return(gen_locked_message ($user, $this->dn));
430                         }
431                         add_lock ($this->dn, $this->ui->dn);
433                         $this->dialog     = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
434       $this->dialog->parent = &$this;
435       $this->dialog->set_acl_base($this->dn);
436                         $this->is_dialog  = true;
438       if(preg_match("/^freeze/", $entry['FAIstate']) || $this->no_save){
439 #        $this->dialog->set_acl_base("freezed")  ;    
440       }
441                         session::set('objectinfo',$this->dn);
442                 }
445     /*  Branch handling 
446         09.01.2006
447     */
449     /****************
450       Remove branch
451      ****************/
453     /* Remove branch 
454      */
455     if($s_action == "remove_branch"){
456       $base= $this->fai_release;
458       /* Check if we have a post remove method configured
459        *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
460        */
461       if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
462         /* Load permissions for selected 'dn' and check if
463            we're allowed to remove this 'dn' */
464         if($this->acl_is_removeable()){
465           $smarty->assign("release_hidden",base64_encode($this->fai_release));
466           $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->fai_release),_("FAI branch/freeze")));
467           return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
468         } else {
469           msg_dialog::display(_("Permission error"), _("You have no permission to delete this release!"), ERROR_DIALOG);
470         }
471       }
472     }
474     
475     /****************
476       Remove branch confirmed
477      ****************/
479     if(isset($_POST['delete_branch_confirm'])){
481       /* Check if we have a post remove method configured
482        *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
483        */
484       if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
486         if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
487           msg_dialog::display(_("Warning"),_("Release remove aborted because the release name check failed!"));
488         }else{
490           $bb =  $this->fai_release;
491           if(!isset($ldap)){
492             $ldap = $this->config->get_ldap_link();
493           }
495           $br = $this->getBranches();
497           if(isset($br[$bb]) && $this->acl_is_removeable()){
498             $name = $br[$bb];
500             $ldap->cd($bb);
501             $ldap->recursive_remove();
502             $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('applicationou'), $bb));
503             $ldap->recursive_remove();
504             $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('mimetypeou'), $bb));
505             $ldap->recursive_remove();
507             /* Search for all groups with configured application menus.
508               - First search all groups, to ensure that we only remove entries form whithin groups. 
509               - The search für menu configuration for the specified release and collect all those dns.
510               - Remove entries
511              */
512             $release_ou = preg_replace("/".normalizePreg(get_ou("faiou")).".*$/","",$bb);
513             $ldap->cd($this->config->current['BASE']);
514             $ldap->search("(objectClass=posixGroup)",array("dn"));
515           
516             /* Collect all group dns 
517              */
518             $groups = array();
519             while($attrs = $ldap->fetch()){
520               $groups[] = $attrs['dn'];
521             }
523             /* Collect all group menu release dns that match the release we have removed 
524              */
525             $dns = array();
526             foreach($groups as $dn){
527               $ldap->cd($dn);
528               $ldap->search("(objectClass=FAIbranch)",array("dn"));
529               while($attrs = $ldap->fetch()){
530                 if(preg_match("/^".normalizePreg($release_ou)."/",$attrs['dn'])){
531                   $dns[] = $attrs['dn'];
532                 }
533               }
534             }
535             
536             /* Finally remove collected release dns 
537              */
538             foreach($dns as $dn){
539               $ldap->cd($dn);
540               $ldap->recursive_remove();
541             }
543             /* Post remove */
544             $this->fai_release = $this->fai_base;
545             $this->lock_name   = $name;
546             $this->lock_dn     = $bb;
547             $this->postremove();
549             $fai_filter = session::get("fai_filter");
550             $fai_filter['fai_release'] = $this->fai_release;
551             session::set("fai_filter",$fai_filter);
553             new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
554           }
555         }
556       }
557     }
560     /****************
561       Create a new branch "insert Name"
562      ****************/
564     if((isset($_POST['UseBranchName']))&&(($this->dispNewBranch)||($this->dispNewFreeze))){
565       session::set('LASTPOST',$_POST);
567       if($this->dispNewBranch){
568         $type = "branch";
569       }else{
570         $type = "freeze";
571       }
573       /* Check branch name */
574       $name = $_POST['BranchName'];
575       $is_ok = true;
576       $smarty->assign("BranchName",$name);
577       $base= $this->fai_base;
579       /* Check used characters */
580       if(!preg_match("/^[0-9a-z\.]*$/",$name)){
581         msg_dialog::display(_("Error"), msgPool::invalid(_("Name"),$name,"/[0-9a-z\.]/"), ERROR_DIALOG);
582         $is_ok = false;
583       }
585       /* Check if this name is already in use */
586       if(!$this->CheckNewBranchName($_POST['BranchName'],$this->fai_release)){
587         msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG);
588         $is_ok = false;
589       }
591       if($is_ok){
593         if(session::is_set('LASTPOST')){
594           $LASTPOST = session::get('LASTPOST');
595         }else{
596           $LASTPOST = array();
597         }
598         $LASTPOST['base'] = $base;
599         $LASTPOST['type'] = $type;
600         session::set('LASTPOST',$LASTPOST);
601         $smarty->assign("iframe", true);
602         $smarty->assign("plugID", $_GET['plug']);
603         $display        = $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
604         return($display);
605       }
606     }
609     /****************
610       Create a new branch 
611      ****************/
613     if(isset($_GET['PerformBranch'])){
614     
615       if(!$this->acl_is_createable()){
616         msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
617       }else{
619         /* In order to see error messages we have to reset the error handler.
620             Due to the exit(); 
621          */
622         restore_error_handler();
624         /* Create it know */
625         $this->dispNewBranch = false;
626         $this->dispNewFreeze = false;
628         $LASTPOST = session::get('LASTPOST');
629         $base = $LASTPOST['base'];
630         $_POST  = session::get('LASTPOST');      
631         $name = $_POST['BranchName'];
633         $type = $LASTPOST['type'];
634         $ldap = $this->config->get_ldap_link();
636         $baseToUse = $base;
637         if($this->fai_release !=  $this->fai_base){
638           $baseToUse = $this->fai_release;
639         }
641         /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
643         $CurrentReleases  = $this->getBranches();
644         $NewReleaseName   = $name;
645         if(isset($CurrentReleases[$this->fai_release])) {
646           if($this->fai_release != $this->fai_base){
647             $NewReleaseName = $CurrentReleases[$this->fai_release]."/".$name;
648             $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName); 
649           }else{
650             $NewReleaseName   = $name;
651           }
652         }
654         $appsrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),$baseToUse); 
655         $appdst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('applicationou'),"ou=".$name.",".$baseToUse) ; 
657         $mimesrc = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),$baseToUse); 
658         $mimedst = preg_replace("/".normalizePreg(get_ou('faiou'))."/",get_ou('mimetypeou'),"ou=".$name.",".$baseToUse) ; 
660         /* Check if source depeartments exist */
661         foreach(array($baseToUse,$appsrc,$mimesrc) as $dep){
662           $ldap->cd($this->config->current['BASE']);
663           $ldap->cat($dep);
664           if(!$ldap->count()){
665             $ldap->create_missing_trees($dep);
666           }
667         }
669         /* Print header to have styles included */
670         echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
671           <html>
672           <head>
673           <title></title>
674           <style type="text/css">@import url("themes/default/style.css");</style>
675           <script language="javascript" src="include/focus.js" type="text/javascript"></script>
676           </head>
677           <body style="background: none;margin:3px;color:black">
678           ';
680         new log("create","fai/".get_class($this),$NewReleaseName,array(),"New $type created");
682         /* Duplicate group application releases 
683          */
684         FAI::copy_FAI_group_releases($CurrentReleases[$this->fai_release],$name,$type);
686         /* Duplicate applications 
687          */
688         $ldap->cat($appsrc,array("dn")) ;
689         if($ldap->count()){
690           $ldap->cd ($appdst);
691           $ldap->recursive_remove();
692           FAI::copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
693         }
695         /* Duplicate mime types 
696          */
697         $ldap->cat($mimesrc,array("dn")) ;
698         if($ldap->count()){
699           $ldap->cd ($mimedst);
700           $ldap->recursive_remove();
701           FAI::copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
702         }
704         $attr = array();
705         $attr['objectClass'] = array("organizationalUnit","FAIbranch");
706         $attr['ou']       = $name;
707         $attr['FAIstate'] = $type;
708         $ldap->cd($this->config->current['BASE']);
709         $ldap->cd("ou=".$name.",".$baseToUse);
710         $ldap->cat("ou=".$name.",".$baseToUse);
711         if($ldap->count()){
712           $ldap->modify($attr);
713         }else{
714           $ldap->add($attr);
715         }
717         /* Duplicate fai objects 
718          */
719         //      $ldap->cd ("ou=".$name.",".$baseToUse);
720         //      $ldap->recursive_remove();
721         //      FAI::copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
723         echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
724           <br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
725           </form></div>";
727         echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
729         /* Print footer to have valid html */
730         echo "</body></html>";
732         $this->dispNewFreeze = false; 
734         /* Postcreate */ 
736         /* Assign possible attributes */
737         $this->lock_type  = $type; 
738         $this->lock_name  = $name; 
739         $this->lock_dn    = $baseToUse;
740         $this->postcreate();
743         /* Send daemon event to reload the fai release database 
744          */
745         if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
746           $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
747           if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'])){
748             $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_release_db'];
749             $tmp = new $evt['CLASS_NAME']($this->config);
750             $tmp->set_type(TRIGGERED_EVENT);
751             $tmp->add_targets(array("GOsa"));
752             $o_queue = new gosaSupportDaemon();
753             if(!$o_queue->append($tmp)){
754               msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
755             }
756           }
757         }else{  
758           trigger_error("Unknown class DaemonEvent / gosaSupportDaemon");
759         }
760         exit();
761       }
762     }
764     /****************
765       Display dialog to enter new Branch name
766      ****************/
768     /* Check if we have a post create method configured
769      *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
770      */
771     if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
772       if(($s_action == "branch_branch")||($this->dispNewBranch)){
773         if(!$this->acl_is_createable()){
774         msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
775         }else{
776           $this->dispNewBranch=true;
777           $smarty->assign("iframe",false);
778           $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
779           return($display);
780         }
781       } 
782     }
784  
785     /****************
786       Display dialog to enter new Freeze name
787      ****************/
789     /* Check if we have a post create method configured
790      *  else skip this operation. (Skip:Button in the ui should be disabled in this case too)
791      */
792     if("" != $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'))){
793       if(($s_action == "freeze_branch")||($this->dispNewFreeze)){
794         if(!$this->acl_is_createable()){
795           msg_dialog::display(_("Permission error"), msgPool::permCreate(_("Branch")), ERROR_DIALOG);
796         }else{
797           $this->dispNewFreeze = true;
798           $smarty->assign("iframe",false);
799           $display      .= $smarty->fetch(get_template_path('faiNewBranch.tpl', TRUE, dirname(__FILE__)));
800           return($display);
801         }
802       }
803     }
806     /****************
807       Create a new object 
808      ****************/
810     $types = array( "new_partition"     =>  "FAIpartitionTable",
811                     "new_script"        =>  "FAIscript",
812                     "new_hook"          =>  "FAIhook",
813                     "new_variable"      =>  "FAIvariable",
814                     "new_template"      =>  "FAItemplate",
815                     "new_package"       =>  "FAIpackageList");
816     $types_i18n = array( "new_partition"     =>  _("partition table"),
817                     "new_script"        =>  _("script"),
818                     "new_hook"          =>  _("hook"),
819                     "new_variable"      =>  _("variable"),
820                     "new_template"      =>  _("template"),
821                     "new_package"       =>  _("package list"));
823     if(isset($types[$s_action])){
824       $acl = $this->ui->get_permissions($this->fai_base,"fai/".$type_acl_mapping[$types[$s_action]]);
825       if(preg_match("/c/",$acl)){
826         $this->dialog = new askClassName($this->config,$this->dn,$this->ui,$types[$s_action]);
827         $this->dialog->parent = &$this;
828       }else{
829         msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), $types_i18n[$s_action]), ERROR_DIALOG);
830       }
831     }
833     /* New Profile */
834     if($s_action == "new_profile"){
835       $this->dn = "new" ;
837       $acl = $this->ui->get_permissions($this->fai_base,"fai/faiProfile");
838       if(preg_match("/c/",$acl)){
839         $a_setup= $this->get_type(array("objectClass"=>array("FAIprofile")));
840         $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
841         $this->dialog->set_acl_base($this->base);
842         $this->dialog->parent = &$this;
844         $this->is_dialog = false;
845       }else{
846         msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to create a new %s!"), _("profile")), ERROR_DIALOG);
847       }
848     }
851     /****************
852       Get from ask class name dialog 
853      ****************/
855     if($s_action == "select_class_name_finished"){
856       $this->dialog->save_object();
857       if(count($this->dialog->check())!=0){
858         foreach($this->dialog->check() as $msg){
859           msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
860         }               
861       }elseif(isset($this->dialog->objectClass)){
862         $this->dn = "new" ;
863         $a_setup= $this->get_type(array("objectClass"=>array($this->dialog->objectClass)));
864         $name = $this->dialog->save();
866         if(class_exists($a_setup[0])){
867           $this->dialog = new $a_setup[0]($this->config,$this->config->data['TABS'][$a_setup[2]],$this->dn,"fai");
868           $this->dialog->set_acl_base($this->base);
869           $this->dialog->by_object[$a_setup[1]]->cn = $name;
870           $this->dialog->parent = &$this;
871           $this->is_dialog = true;
872         }
873       }         
874     }   
877     /****************
878      Cancel dialogs 
879      ****************/
881                 if(isset($_POST['edit_cancel'])){
882                         $this->dialog=FALSE;
883                         $this->is_dialog = false;
884                         session::un_set('objectinfo');
885       $this->remove_lock();
886                 }
889     /****************
890       Save sub dialogs 
891      ****************/
893                 /* This check if the given tab could be saved 
894                  * If it was possible to save it, remove dialog object. 
895                  * If it wasn't possible, show errors and keep dialog.
896                  */
897                 if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
898                         $this->dialog->save_object();
899       $msgs= $this->dialog->check();
900                         if(count($msgs)!=0){
901                                 foreach($msgs as $msg){
902           msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
903                                 }
904                         }else{
905                                 $this->dialog->save();
906         FAI::save_release_changes_now();
907         if (!isset($_POST['edit_apply'])){
908           $this->remove_lock();
909           $this->dialog=FALSE;
910           $this->is_dialog=false;
911           session::un_set('objectinfo');
912         }else{
914           /* Reinitialize tab */
915           if($this->dialog instanceof tabs){
916             $this->dialog->re_init();
917           }
918         }
919                         }
920                 }
923     /****************
924       Display currently open dialog 
925      ****************/
927                 /* If dialog is set, but $this->is_dialog==false, then 
928                  *  only the "abort" button is shown, this are dialogs that must not be saved.  
929                  * If is_dialog == true, we are currently editing tab objects.
930                  *  Here we need both, save and cancel
931                  */ 
933                 if(is_object($this->dialog)){
934                         $display .= $this->dialog->execute();
935                         /* Don't show buttons if tab dialog requests this */
937       if(isset($this->dialog->current)){
939         $obj = $this->dialog->by_object[$this->dialog->current];
941         if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
943           $display.= "<p style=\"text-align:right\">\n";
944           if(!$this->no_save){
945             $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
946             $display.= "&nbsp;\n";
947             if ($this->dn != "new"){
948               $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
949               $display.= "&nbsp;\n";
950             }
951           }
952           $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
953           $display.= "</p>";
954         }elseif(!isset($this->dialog->current)){
955           $display.= "<p style=\"text-align:right\">\n";
956           $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
957           $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
958           $display.= "</p>";
959         }
960       }else{
961         $display.= "<p style=\"text-align:right\">\n";
962         $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\">&nbsp;";
963         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
964         $display.= "</p>";
966       }
967       return($display);
968                 }
969                 
971     /****************
972       Dialog display
973      ****************/
975     /* Check if there is a snapshot dialog open */
976     $base = $this->fai_base;
977     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
978       return($str);
979     }
981     /* Display dialog with system list */
982     $this->reload();
983     $this->DivListFai->parent = &$this;
984     $this->DivListFai->execute();
985     $this->DivListFai->setEntries($this->objects);
986     return($this->DivListFai->Draw());
987         }
990   /* Return departments, that will be included within snapshot detection */
991   function get_used_snapshot_bases()
992   {
993     $tmp = array();
994     $types = array("faipartitionou","faiscriptou","faitemplateou","faihookou","faiprofileou","faivariableou","faipackageou");
995     foreach($types as $type){
996       $tmp[] = get_ou($type).$this->fai_release;
997     }
998     return($tmp);
999   }
1002   /* Get available branches for current base */
1003   function getBranches($base = false,$prefix = "")
1004   {
1005     $ret = array("/"=>$this->fai_base);
1006     $ldap = $this->config->get_ldap_link();
1007     if(!$base){
1008       $base = $this->fai_base;
1009     }
1010     $tmp = FAI::get_all_releases_from_base($base,true);
1011     foreach($tmp as $dn => $name){
1012       $ret[$name]=$dn;
1013     }
1014     ksort($ret);
1015     $ret = array_flip($ret);
1017     return ($ret);
1018   }
1019   
1021   function list_get_selected_items()
1022   {
1023     $ids = array();
1024     foreach($_POST as $name => $value){
1025       if(preg_match("/^item_selected_[0-9]*$/",$name)){
1026         $id   = preg_replace("/^item_selected_/","",$name);
1027         $ids[$id] = $id;
1028       }
1029     }
1030     return($ids);
1031   }
1034   /* reload list of objects */
1035   function reload()
1036   {
1037     /* Variable initialisation */
1038     $str            = "";
1039     $Regex          = $this->DivListFai->Regex;
1040     $this->objects  = array();
1042     /* Get base */
1043     $base = $this->fai_base;
1044     if($this->fai_release != $this->fai_base){
1045       $br = $this->getBranches();
1046       if(isset($br[$this->fai_release])){
1047         $base = $this->fai_release;
1048       }else{
1049         $base = $this->fai_base;
1050       }
1051     }
1052     $this->base = $base;
1053     $this->set_acl_base($this->base);
1055     $this->lock_type = FAI::get_release_tag(FAI::get_release_dn($base));
1057     /* Create a new list of FAI object 
1058      * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ... 
1059      */
1060     $ObjectTypes = array(
1061         "FAIpartitionTable"  => array("OU"=> get_ou('faipartitionou') , "CHKBOX"=>"ShowPartitions"  ,"ACL" => "faiPartitionTable"),
1062         "FAIpackageList"     => array("OU"=> get_ou('faipackageou')   , "CHKBOX"=>"ShowPackages"    ,"ACL" => "faiPackage"),
1063         "FAIscript"          => array("OU"=> get_ou('faiscriptou')    , "CHKBOX"=>"ShowScripts"     ,"ACL" => "faiScript"),
1064         "FAIvariable"        => array("OU"=> get_ou('faivariableou')  , "CHKBOX"=>"ShowVariables"   ,"ACL" => "faiVariable"),
1065         "FAIhook"            => array("OU"=> get_ou('faihookou')      , "CHKBOX"=>"ShowHooks"       ,"ACL" => "faiHook"),
1066         "FAIprofile"         => array("OU"=> get_ou('faiprofileou')   , "CHKBOX"=>"ShowProfiles"    ,"ACL" => "faiProfile"),
1067         "FAItemplate"        => array("OU"=> get_ou('faitemplateou')  , "CHKBOX"=>"ShowTemplates"   ,"ACL" => "faiTemplate"));
1069     $filter = "";
1070     foreach($ObjectTypes as $key => $data){
1071       if($this->DivListFai->$data['CHKBOX']){
1072         $filter.= "(objectClass=".$key.")";
1073       }
1074     }
1075     $filter = "(&(|".$filter.")(cn=$Regex))";
1076     
1077     /* Get resolved release dependencies */
1078     $tmp = FAI::get_all_objects_for_given_base($base,$filter);
1080     /* Ge listed ldap objects */
1081     $ldap = $this->config->get_ldap_link();
1082     $ldap->cd($this->config->current['BASE']);
1084     /* Get release tag 
1085        If current release is freezed, all objects are freezed to.
1086      */
1087     $ldap->cat($base);
1088     $release_attrs = $ldap->fetch();
1089     $force_freezed = FALSE;
1090     if(isset($release_attrs['FAIstate'][0]) && preg_match("/freeze/i",$release_attrs['FAIstate'][0])){
1091       $force_freezed = TRUE;
1092     }
1094     foreach($tmp as $entry){
1096       /* Get some more informations about the object */ 
1097       $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
1098       $object  = $ldap->fetch();
1100       /* Walk through possible types */
1101       foreach($ObjectTypes as $type => $rest){  
1103         $acl = $this->ui->get_permissions($object['dn'],"fai/".$rest ['ACL']);
1105         if(in_array($type,$object['objectClass']) && preg_match("/r/",$acl)){
1107           /* Prepare object */
1108           unset($object['objectClass']['count']);
1109           if(!isset($object['description'][0])){
1110             $object['description'][0]="";
1111           }
1113           /* Clean up object informations */
1114           $obj                  = array();
1115           $obj['cn']                          = $object['cn'][0];
1116           $obj['dn']                          = $object['dn'];
1117           $obj['acl']                       = $acl;
1118           $obj['class']                           = $rest ['ACL'];
1119           $obj['description']   = $object['description'][0];
1120           $obj['objectClass']   = $object['objectClass'];
1122           /* Append type to this string, to be able to check if the selected 
1123            * entry is of type 'freeze' or 'branch'
1124            */
1125           if(!isset($object['FAIstate'])){
1126             
1127             /* Is this entry inherited from an earlier release? 
1128                In this case inherit the FAIstate from the release container.
1129                If this is a newly created entry (allow_freeze_object_attach == TRUE) 
1130                 then allow to edit this entry by setting its FAIstate manually to branch. 
1131              */
1132             if($this->allow_freeze_object_attach && preg_match("/".normalizePreg($this->fai_release)."$/i",$object['dn'])){
1133               $obj['FAIstate'] = "branch|overridden_by_management_reload";
1134             }else{
1135               $obj['FAIstate'] = $this->lock_type;
1136             }
1137   
1138           }else{
1139             $obj['FAIstate'] = $object['FAIstate'][0]; 
1140           }
1142           if($force_freezed && !$this->allow_freeze_object_attach){
1143             $obj['FAIstate'] = "freeze";
1144           }
1146           $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
1147           $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
1148         }
1149                         }
1150                 }
1152                 ksort($this->objects);
1153                 reset ($this->objects);
1154         
1155                 /* use numeric index, thats a bit more secure */        
1156                 $tmp0 = array();
1157                 foreach($this->objects as $obj){
1158                         $tmp0[]= $obj;
1159                 }
1160                 $this->objects = array();
1161                 $this->objects = $tmp0;
1162         }
1164         function remove_lock()
1165         {
1166                 if (isset($this->dn)){
1167                         del_lock ($this->dn);
1168                 }
1169     if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
1170       del_lock ($this->dns);
1171     }
1172         }
1174         function get_type($array){
1175                 if(in_array("FAIpartitionTable",$array['objectClass'])){
1176                         return(array("tabsPartition","faiPartitionTable","FAIPARTITIONTABS"));
1177                 }
1178                 if(in_array("FAIscript",$array['objectClass'])){
1179                         return(array("tabsScript","faiScript","FAISCRIPTTABS"));
1180                 }
1181                 if(in_array("FAItemplate",$array['objectClass'])){
1182                         return(array("tabsTemplate","faiTemplate","FAITEMPLATETABS"));
1183                 }
1184                 if(in_array("FAIhook",$array['objectClass'])){
1185                         return(array("tabsHook","faiHook","FAIHOOKTABS"));
1186                 }
1187                 if(in_array("FAIvariable",$array['objectClass'])){
1188                         return(array("tabsVariable","faiVariable","FAIVARIABLETABS"));
1189                 }
1190                 if(in_array("FAIprofile",$array['objectClass'])){
1191                         return(array("tabsProfile","faiProfile","FAIPROFILETABS"));
1192                 }
1193                 
1194                 if(in_array("FAIpackageList",$array['objectClass'])){
1195                         return(array("tabsPackage","faiPackage","FAIPACKAGETABS"));
1196                 }
1197         }
1199   function CheckNewBranchName($name,$base)
1200   {
1201     $f = $this->fai_release;
1202     if($name == ""){
1203       return(false);
1204     }elseif(in_array($name,$this->getBranches($f))) {
1205       return(false);
1206     }elseif(tests::is_department_name_reserved($name,$base)){
1207       return(false);
1208     }
1209     return(true);
1210   }
1212   function save_object()
1213   {
1214     $this->DivListFai->save_object();
1216     /* Get posted release */
1217     $r_releases = array_flip($this->getBranches());
1218     if(isset($_POST['fai_release']) && isset($r_releases[get_post('fai_release')])){
1220       /* Ensure that we have a valid release selected */
1221       if(!isset($r_releases[get_post('fai_release')])){
1222         msg_dialog::display(_("Warning"),_("The selected release is not available anymore. All triggered actions are skipped."));
1223         $_POST = array();
1224         $plug =$_GET['plug'];
1225         $_GET  = array("plug" => $plug);
1226         $this->fai_release = $this->fai_base;
1227       }else{
1228         $this->fai_release = $r_releases[get_post('fai_release')];
1229       }
1231       $fai_filter = session::get("fai_filter");
1232       $fai_filter['fai_release'] = $this->fai_release;
1233       session::set("fai_filter",$fai_filter);
1234     }
1236     if(is_object($this->CopyPasteHandler)){
1237       $this->CopyPasteHandler->save_object();
1238     }
1239   }
1242   function copyPasteHandling_from_queue($s_action,$s_entry)
1243   {
1244     /* Check if Copy & Paste is disabled */
1245     if(!is_object($this->CopyPasteHandler)){
1246       return("");
1247     }
1249     $ui = get_userinfo();
1251     /* Add a single entry to queue */
1252     if($s_action == "copy"){
1254       /* Cleanup object queue */
1255       $this->CopyPasteHandler->cleanup_queue();
1256       $entry    = $this->objects[$s_entry];
1257       $a_setup  = $this->get_type($entry);
1258       $dn = $entry['dn'];
1260       if($ui->is_copyable($dn,"fai",$a_setup[1])){
1261         $this->CopyPasteHandler->add_to_queue($dn,$s_action,$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1262       }
1263     }
1265     /* Add entries to queue */
1266     if($s_action == "copy_multiple"){
1268       /* Cleanup object queue */
1269       $this->CopyPasteHandler->cleanup_queue();
1271       /* Add new entries to CP queue */
1272       foreach($this->list_get_selected_items() as $id){
1274         /* Cleanup object queue */
1275         $entry    = $this->objects[$id];
1276         $a_setup  = $this->get_type($entry);
1277         $dn = $entry['dn'];
1279         if($s_action == "copy_multiple" && $ui->is_copyable($dn,"fai",$a_setup[1])){
1280           $this->CopyPasteHandler->add_to_queue($dn,"copy",$a_setup[0],$a_setup[2],"fai");//$a_setup[1]);
1281         }
1282       }
1283     }
1285     /* Start pasting entries */
1286     if($s_action == "editPaste" && !($this->lock_type == "freeze" && !$this->allow_freeze_object_attach)){
1287       $this->start_pasting_copied_objects = TRUE;
1288     }
1290     /* Return C&P dialog */
1291     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1293       /* Get dialog */
1294       $this->CopyPasteHandler->SetVar("parent",$this);
1295       $data = $this->CopyPasteHandler->execute();
1297       FAI::save_release_changes_now();
1299       /* Return dialog data */
1300       if(!empty($data)){
1301         return($data);
1302       }
1303     }
1305     /* Automatically disable status for pasting */
1306     if(!$this->CopyPasteHandler->entries_queued()){
1307       $this->start_pasting_copied_objects = FALSE;
1308     }
1309     return("");
1310   }
1313   /* Check if the given FAI class is used in this release 
1314    */
1315   static function check_class_name($oc,$name,$dn)
1316   {
1317     $base = FAI::get_release_dn($dn);
1318     $res  = FAI::get_all_objects_for_given_base($base,"(objectClass=".$oc.")",TRUE);
1319     $delete = array();
1320     $used   = array();
1321     foreach($res as $object){
1322       $used[$object['cn'][0]]= $object['cn'][0];
1323     }
1324     return($used);
1325   }
1328   /* Return plugin informations for acl handling */ 
1329   static function plInfo()
1330   {
1331     return (array( 
1332           "plShortName"   => _("FAI releases"),
1333           "plDescription" => _("FAI release management"),
1334           "plSelfModify"  => FALSE,
1335           "plDepends"     => array(),
1336           "plPriority"    => 0,
1337           "plSection"     => array("administration"),           
1338           "plCategory"    => array("fai"=> array("description" => _("FAI"),
1339                                                  "objectClass" => "FAIclass")),
1340           "plProvidedAcls"=> array()));
1341   }
1343 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1344 ?>