Code

f7dc508ef081323da6ab72c3571f1f09ef3144c1
[gosa.git] / setup / class_setupStep8.inc
1 <?php
3 /*
4    This code is part of GOsa (https://gosa.gonicus.de)
5    Copyright (C) 2007 Fabian Hickert
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
23 class setup_step_8 extends setup_step
24 {
25   var $create_backup = TRUE;
26   var $gosa_conf_name = "/gosa.conf";
28   function setup_step_8()
29   {
30     $this->s_title      = _("Configuration file");
31     $this->s_title_long = _("In this step the configuration file will be created.");
32     $this->s_info       = _("Saving configuration file");
33   }
36   function execute()
37   {
39     /* Check if there is currently an active gosa.conf 
40      */
41     $exists = file_exists(CONFIG_DIR.$this->gosa_conf_name); 
43     /* Check if existing config file is writeable */
44     if($exists){
45       $writeable = is_writeable(CONFIG_DIR.$this->gosa_conf_name);
46     }else{
47       $writeable = is_writeable(CONFIG_DIR);
48     }
50     $smarty = get_smarty();
51   
52     $info= posix_getgrgid(posix_getgid());
53     $smarty->assign("webgroup", $info['name']);
55     $smarty->assign("gosa_conf_name" , $this->gosa_conf_name);
56     $smarty->assign("create_backup" , $this->create_backup);
57     $smarty->assign("CONFIG_DIR",CONFIG_DIR);
58   
59     $smarty->assign("msg_permissions",sprintf(_("The following file(s), folders(s) must be writeable for the web-user '%s'."),$info['name']));
60  
61     $smarty->assign("exists",$exists);
62     $smarty->assign("writeable",$writeable);
63  
64     $smarty->assign("cv",$this->parent->captured_values);
65     return($smarty -> fetch (get_template_path("../setup/setup_step8.tpl")));
66   }
69   /* Create a backup of the currently existing configuration file. 
70    */
71   function create_backup()
72   {
73     if(is_writeable(CONFIG_DIR) && is_writeable(CONFIG_DIR.$this->gosa_conf_name)){
74       $src = CONFIG_DIR.$this->gosa_conf_name;
75       $dst = CONFIG_DIR.$this->gosa_conf_name."_".date("Ymd");
76       $dst_backup= $dst;
77       $i = 1;
78       while(file_exists($dst)){
79         $dst = $dst_backup."-".$i;
80         $i ++;
81       }
82       return(rename($src,$dst));
83     }else{
84       return(FALSE);
85     }
86   }
89   function save_object()
90   {
91     if(isset($_POST['step8_posted'])){
93       /* Get attributes */
94       foreach($this->attributes as $attr){
95         if(isset($_POST[$attr])){
96           $this->$attr = validate($_POST[$attr]);
97         }
98       }
100       /* Backup toggle */
101       if(isset($_POST['create_backup'])){
102         $this->create_backup = TRUE;
103       }else{
104         $this->create_backup = FALSE;
105       }
106     }
107   }
110 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
111 ?>