From: hickert Date: Mon, 29 Jan 2007 08:32:37 +0000 (+0000) Subject: Intitial setup rework. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2847407c21d5b5bffc413bb62271394c822094a6;p=gosa.git Intitial setup rework. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5640 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/html/setup.old b/html/setup.old new file mode 100644 index 000000000..3320ffd20 --- /dev/null +++ b/html/setup.old @@ -0,0 +1,158 @@ +'; + echo ' location = "setup.php?js=true";'; + echo ''; + + $_SESSION['js']= FALSE; +} elseif(isset($_GET['js'])) { + $_SESSION['js']= TRUE; +} + +/* Load required includes */ +require_once ("../include/php_setup.inc"); +require_once ("functions.inc"); +require_once ("functions_setup.inc"); + +// Save the Post Data (back and forward button) +foreach ($_POST as $key => $val){ + $_SESSION['ldapconf'][$key] = $val; +} + +/* Don't call setup if gosa.conf exists */ +if (file_exists(CONFIG_DIR."/gosa.conf")){ + header("location:index.php"); + exit(); +} + +// Check if theres the example +if (!file_exists(CONFIG_TEMPLATE_DIR."/gosa.conf")){ + echo "error example of gosa.conf not present!"; +} + +// No Errors occured yet +$_SESSION['errors']= ""; +$_SESSION['errors'] = ""; +$_SESSION['errorsAlreadyPosted']= array(); +$_SESSION['LastError'] = ""; + + +// Print out gosa.conf +//if(isset($_SESSION['classes'])) print "\$_SESSION['classes']=ok"; +//if(isset($_SESSION['ldapconf'])) print "\$_SESSION['ldapconf']=ok"; +//if(isset($_POST['getconf'])) print "\$_POST['getconf']=ok"; + +if (( + isset($_SESSION['classes']) && + isset($_SESSION['ldapconf']) && + ( + isset($_POST['getconf']) || isset($_GET['getconfig']) ))){ + echo parse_contrib_conf(); + exit; +} + +/* Set detected samba version */ +if (isset($classes['samba2'])) { + $samba= "3"; +} else { + $samba= "2"; +} + +/* Set template compile directory */ +$smarty->compile_dir= '/var/spool/gosa'; + +/* Check for compile directory */ +if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){ + print_red(_("Directory '%s' specified as smarty compile directory is not accessible, please check existence and rights of this directory!"), $smarty->compile_dir); + echo $_SESSION['errors']; + exit(); +} + +/* Language setup */ +$lang= get_browser_language(); +header("Content-type: text/html; charset=UTF-8"); +$lang.=".UTF-8"; +putenv("LANGUAGE="); +putenv("LANG=$lang"); +setlocale(LC_ALL, $lang); +$GLOBALS['t_language']= $lang; +$GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/'; + +/* Set the text domain as 'messages' */ +$domain = 'messages'; +bindtextdomain($domain, "$BASE_DIR/locale"); +textdomain($domain); + +if ($_SERVER["REQUEST_METHOD"] != "POST"){ + // @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to"); +} + +/* Fill template with required values */ +$smarty->assign ('date', gmdate("D, d M Y H:i:s")); + +if(isset ($_POST['next'])){ + $next = $_POST['next']; +} else { + $next = 1; +} + +if(isset($_POST['back'])) { + $next = $next -2 ; +} + +if($next < 1){ + $next = 1; +} + +// How this works + +// Every functioon called below, has two modes +// If the parameter is false, we only test if this function +// is called witout an error +// Is the return value = false, then there was an error +// and we call this func again, to output the error + +// I hope this will work fine ^^ +if((show_setup_page1(false))||($next == 1)) { + show_setup_page1(); +} elseif((show_setup_page2(false))||($next==2)) { + show_setup_page2(); +} elseif((show_setup_page3(false))||($next==3)) { + show_setup_page3(); +} elseif((show_setup_page4(false))||($next==4)) { + show_setup_page4(); +} +// This is called to test if we have an administrative Group with a User in it +elseif((!create_user_for_setup(false))) { + create_user_for_setup(); +} +// this is the last Page which shows the downloadable conf file +else { + show_setup_page5(); +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/html/setup.php b/html/setup.php deleted file mode 100644 index 3320ffd20..000000000 --- a/html/setup.php +++ /dev/null @@ -1,158 +0,0 @@ -'; - echo ' location = "setup.php?js=true";'; - echo ''; - - $_SESSION['js']= FALSE; -} elseif(isset($_GET['js'])) { - $_SESSION['js']= TRUE; -} - -/* Load required includes */ -require_once ("../include/php_setup.inc"); -require_once ("functions.inc"); -require_once ("functions_setup.inc"); - -// Save the Post Data (back and forward button) -foreach ($_POST as $key => $val){ - $_SESSION['ldapconf'][$key] = $val; -} - -/* Don't call setup if gosa.conf exists */ -if (file_exists(CONFIG_DIR."/gosa.conf")){ - header("location:index.php"); - exit(); -} - -// Check if theres the example -if (!file_exists(CONFIG_TEMPLATE_DIR."/gosa.conf")){ - echo "error example of gosa.conf not present!"; -} - -// No Errors occured yet -$_SESSION['errors']= ""; -$_SESSION['errors'] = ""; -$_SESSION['errorsAlreadyPosted']= array(); -$_SESSION['LastError'] = ""; - - -// Print out gosa.conf -//if(isset($_SESSION['classes'])) print "\$_SESSION['classes']=ok"; -//if(isset($_SESSION['ldapconf'])) print "\$_SESSION['ldapconf']=ok"; -//if(isset($_POST['getconf'])) print "\$_POST['getconf']=ok"; - -if (( - isset($_SESSION['classes']) && - isset($_SESSION['ldapconf']) && - ( - isset($_POST['getconf']) || isset($_GET['getconfig']) ))){ - echo parse_contrib_conf(); - exit; -} - -/* Set detected samba version */ -if (isset($classes['samba2'])) { - $samba= "3"; -} else { - $samba= "2"; -} - -/* Set template compile directory */ -$smarty->compile_dir= '/var/spool/gosa'; - -/* Check for compile directory */ -if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){ - print_red(_("Directory '%s' specified as smarty compile directory is not accessible, please check existence and rights of this directory!"), $smarty->compile_dir); - echo $_SESSION['errors']; - exit(); -} - -/* Language setup */ -$lang= get_browser_language(); -header("Content-type: text/html; charset=UTF-8"); -$lang.=".UTF-8"; -putenv("LANGUAGE="); -putenv("LANG=$lang"); -setlocale(LC_ALL, $lang); -$GLOBALS['t_language']= $lang; -$GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/'; - -/* Set the text domain as 'messages' */ -$domain = 'messages'; -bindtextdomain($domain, "$BASE_DIR/locale"); -textdomain($domain); - -if ($_SERVER["REQUEST_METHOD"] != "POST"){ - // @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to"); -} - -/* Fill template with required values */ -$smarty->assign ('date', gmdate("D, d M Y H:i:s")); - -if(isset ($_POST['next'])){ - $next = $_POST['next']; -} else { - $next = 1; -} - -if(isset($_POST['back'])) { - $next = $next -2 ; -} - -if($next < 1){ - $next = 1; -} - -// How this works - -// Every functioon called below, has two modes -// If the parameter is false, we only test if this function -// is called witout an error -// Is the return value = false, then there was an error -// and we call this func again, to output the error - -// I hope this will work fine ^^ -if((show_setup_page1(false))||($next == 1)) { - show_setup_page1(); -} elseif((show_setup_page2(false))||($next==2)) { - show_setup_page2(); -} elseif((show_setup_page3(false))||($next==3)) { - show_setup_page3(); -} elseif((show_setup_page4(false))||($next==4)) { - show_setup_page4(); -} -// This is called to test if we have an administrative Group with a User in it -elseif((!create_user_for_setup(false))) { - create_user_for_setup(); -} -// this is the last Page which shows the downloadable conf file -else { - show_setup_page5(); -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setup.inc b/setup/class_setup.inc new file mode 100644 index 000000000..89949ecd2 --- /dev/null +++ b/setup/class_setup.inc @@ -0,0 +1,142 @@ +i_steps; $i ++ ){ + $class= "setup_step_".$i; + $this->o_steps[$i] = new $class(); + } + } + + function execute() + { + $smarty = get_smarty(); + $this->o_steps[$this->i_last]->set_active(FALSE); + $this->o_steps[$this->i_current]->set_active(); + $content = $this->o_steps[$this->i_current]->execute(); + return($content); + } + + + /* Save posted attributes */ + function save_object() + { + /* Call save_object for current setup step */ + $this->o_steps[$this->i_current] -> save_object(); + + /* Get attributes from setup step */ + $tmp = $this->o_steps[$this->i_current]->get_attributes(); + foreach($tmp as $name => $value){ + $this->captured_values[$name] = $value; + } + + /* check if current setup step is completed now + and activate the next step if possible */ + for($i = 1 ; $i <= $this->i_steps ; $i ++ ){ + if($this->o_steps[$i]->is_completed()){ + if(isset($this->o_steps[($i+1)])){ + $this->o_steps[($i+1)]->set_enabled(); + } + } + } + + /* Check if step was selected */ + if(isset($_GET['step'])){ + $step = $_GET['step']; + + if($this->selectable_step($step)){ + $this->i_last = $this->i_current; + $this->i_current = $_GET['step']; + } + } + } + + + /* Create navigation menu */ + function get_navigation_html() + { + $str = ""; + + foreach($this->o_steps as $key => $step){ + + $s_title = $step -> get_title(); + $s_info = $step -> get_small_info(); + $b_active = $step -> is_active(); + $b_enabled = $step -> is_enabled(); + + $str .= ""; + } + $str .="
"; + if($b_enabled){ + $str .= ""; + $str .= "".$s_title.""; + if($b_active){ + $str .= "
"; + $str .= " ".$s_info.""; + $str .= "
"; + } + $str .= "
"; + }else{ + $str .= "".$s_title.""; + } + $str .= "

 

"; + $str .= "
"; + return($str); + } + + + /* Create header entry */ + function get_header_html() + { + $str =""; + $str.= $this->o_steps[$this->i_current]->get_long_title(); + $str.=""; + return ($str); + } + + + /* Check if the given step id is valid and selectable */ + function selectable_step($id) + { + if(isset($this->o_steps[$id]) && $this->o_steps[$id]->is_enabled()){ + return(true); + } + return(false); + } +} + + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep.inc b/setup/class_setupStep.inc new file mode 100644 index 000000000..52cfbdc79 --- /dev/null +++ b/setup/class_setupStep.inc @@ -0,0 +1,105 @@ +s_title); + } + + function get_long_title() + { + return($this->s_title_long); + } + + function get_small_info() + { + return($this->s_info); + } + + function is_active() + { + return($this->is_active); + } + + function is_enabled() + { + return($this->is_enabled); + } + + function is_completed() + { + return($this->is_completed); + } + + function set_active($value = TRUE) + { + if($value){ + $this->is_active = TRUE; + }else{ + $this->is_active = FALSE; + } + } + + function set_enabled($value = TRUE) + { + if($value){ + $this->is_enabled = TRUE; + }else{ + $this->is_enabled = FALSE; + } + } + + function set_completed($value = TRUE) + { + if($value){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + } + + /* Return attributes handled by this setup step */ + function get_attributes() + { + $tmp = array(); + foreach($this->attributes as $attr){ + $tmp[$attr] = $this->$attr; + } + return($tmp); + } +} + + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep1.inc b/setup/class_setupStep1.inc new file mode 100644 index 000000000..de6c1017b --- /dev/null +++ b/setup/class_setupStep1.inc @@ -0,0 +1,63 @@ +is_enabled = TRUE; + $this->is_active = TRUE; + + $this->s_title = _("Language selection"); + $this->s_title_long = _("Please choose a language"); + $this->s_info = _("This step is allows you to define your prefered language."); + + $this->languages = array("de_DE" => _("German"), + "fr_FR" => _("French"), + "en_EN" => _("English"), + "ru_RU" => _("Russian")); + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("languages", $this->languages); + $smarty->assign("lang", $this->lang); + return($smarty->fetch(get_template_path("setup_step1.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + if((isset($_POST['lang'])) && isset($this->languages[$_POST['lang']])) { + $this->lang = $_POST['lang']; + $this->is_completed = TRUE; + $_SESSION['lang'] = $this->lang; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep2.inc b/setup/class_setupStep2.inc new file mode 100644 index 000000000..e037f9c24 --- /dev/null +++ b/setup/class_setupStep2.inc @@ -0,0 +1,39 @@ + diff --git a/setup/class_setupStep3.inc b/setup/class_setupStep3.inc new file mode 100644 index 000000000..7e359482e --- /dev/null +++ b/setup/class_setupStep3.inc @@ -0,0 +1,39 @@ + diff --git a/setup/class_setupStep4.inc b/setup/class_setupStep4.inc new file mode 100644 index 000000000..860aedb0d --- /dev/null +++ b/setup/class_setupStep4.inc @@ -0,0 +1,39 @@ + diff --git a/setup/class_setupStep5.inc b/setup/class_setupStep5.inc new file mode 100644 index 000000000..b801d421d --- /dev/null +++ b/setup/class_setupStep5.inc @@ -0,0 +1,39 @@ + diff --git a/setup/main.inc b/setup/main.inc new file mode 100644 index 000000000..fe41c8030 --- /dev/null +++ b/setup/main.inc @@ -0,0 +1,37 @@ +save_object(); +$display= $setup->execute(); + +/* Store changes in session */ +$_SESSION['setup']= $setup; + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/setup.tpl b/setup/setup.tpl new file mode 100644 index 000000000..3bb21f795 --- /dev/null +++ b/setup/setup.tpl @@ -0,0 +1,4 @@ +
+{$php_errors} +sadffasdsdfa +
diff --git a/setup/setup_frame.tpl b/setup/setup_frame.tpl new file mode 100644 index 000000000..888a8bcbf --- /dev/null +++ b/setup/setup_frame.tpl @@ -0,0 +1,27 @@ + + +{$php_errors} +
+ + + + + + + + + + + +
+ GOsa Setup blabla +
+ {$navigation} + + {$header} +
+ {$contents} +
+
+ + diff --git a/setup/setup_step1.tpl b/setup/setup_step1.tpl new file mode 100644 index 000000000..7c8fc338f --- /dev/null +++ b/setup/setup_step1.tpl @@ -0,0 +1,6 @@ +{t}Language{/t} + + +