Commit 4fc92f28 authored by Celine Noirot's avatar Celine Noirot
Browse files

Improve installation

parent 8b7bcfbc
......@@ -669,7 +669,24 @@ class tx_nG6_eid {
$smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($analysis));
$smarty->assign('login_user', $login_user);
print $smarty->fetch('analysis_table.tpl');
} elseif($type == 'install') {
print "type install";
$res = tx_nG6_db::select_user_by_username("admin_install");
if ($res != null){
$res_code = tx_nG6_db::finalize_installation($res["uid"],
print "End of pi_finalize_install<br>";
......@@ -92,7 +92,12 @@ class tx_nG6_pi1 extends tslib_pibase {
// if asked to upgrade to version 1.2
$content = tx_nG6_upgrade::upgrade($this->piVars['upgrade']);
} else {
else if(! $this->pi_is_install_finalized()) {
$content .= $this->pi_install_view();
else {
switch((string)$this->conf['view']) {
// If the plugin is configured to display results by run
case 'run':
......@@ -343,6 +348,39 @@ class tx_nG6_pi1 extends tslib_pibase {
* Return the install view
function pi_install_view() {
$smarty = new Smarty();
$smarty->security = true;
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
$smarty->assign('server_name', $this->conf["server_name"]);
$smarty->assign('server_url', $this->conf['server_url']);
$smarty->assign('pid', $this->conf['userpidList']);
$smarty->assign('current_id', intval($GLOBALS['TSFE']->id));
return $smarty->fetch('install_view.tpl');
* Does installation need is finalized ( admin_install user exist in db )
* @param integer Alternative page ID for the link. (By default this function links to the SAME page!)
* @return boolean If true, intallation allready finalysed
function pi_is_install_finalized() {
$res = tx_nG6_db::select_user_by_username("admin_install");
if ($res == null){
return true;
return false;
* Overloading of the tslib_pibase->pi_list_linkSingle function so piVars[showUid] is not set.
Copyright (C) 2009 INRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <>.
<div id="error_dialog" title=""></div>
<div class="sub-content sc-bottom">
<div id="message" class="alert alert-error hidden"><button class="close" data-dismiss="alert" type="button" >x</button></div>
<div class="tx-nG6-pi1-update-user">
<h2>Finalize installation </h2>
<h2><small>Set administrator information</small></h2>
<form class="form-horizontal" id="install_form">
<input type="hidden" id="server_name" value="{$server_name}" />
<input type="hidden" id="server_url" value="{$server_url}" />
<input type="hidden" id="pid" value="{$pid}" />
<input type="hidden" id="id" value="{$current_id}" />
<div class="control-group">
<label class="control-label">Last name</label>
<div class="controls">
<input type="text" id="last_name_val" class="typeahead" name="last_name_val" placeholder="Last name"/>
<div class="control-group">
<label class="control-label">First name</label>
<div class="controls">
<input type="text" id="first_name_val" class="typeahead" name="first_name_val" placeholder="First name"/>
<div class="control-group">
<label class="control-label">Login</label>
<div class="controls">
<input type="text" id="username_val" class="typeahead" name="username_val" placeholder="Login"/>
<div class="control-group">
<label class="control-label">Password</label>
<div class="controls">
<div class="input-append">
<input class="text" type="password" id="user_password_pwd_val" name="user_password_pwd_val" placeholder="Password"/>
<div class="control-group">
<label class="control-label">Retype password</label>
<div class="controls">
<div class="input-append">
<input class="text" type="password" id="user_password_pwd2_val" name="user_password_pwd2_val" placeholder="Password"/>
<div class="control-group">
<label class="control-label">Email</label>
<div class="controls">
<input type="text" id="email_val" class="typeahead" name="email_val" placeholder="Email"/>
<h2><small>Set first project information</small></h2>
<div class="control-group">
<label class="control-label">Project name</label>
<div class="controls">
<input type="text" id="project_name_val" class="typeahead" name="project_name_val" placeholder="Project name"/>
<div class="control-group">
<label class="control-label">Description</label>
<div class="controls">
<input type="text" id="description_val" class="typeahead" name="description_val" placeholder="Description"/>
<div style="float:right;margin-top:10px">
<button class="btn" id="raz_form_install"><i class="icon-repeat"></i> Clear form</button>
<button id="btn-install" class="btn btn-primary"> Install</button>
<div style="clear:both"></div>
\ No newline at end of file
......@@ -625,7 +625,53 @@ $(function () {
rules: {
first_name_val: { required: true },
email_val: { required: true, email: true },
last_name_val: { required: true },
username_val: { required: true },
user_password_pwd_val: { required: true },
project_name_val: { required: true },
description_val: { required: true }
messages: {
first_name_val: null,
email_val: null,
last_name_val: null,
username_val: null,
user_password_pwd_val: null,
project_name_val: null,
description_val: null
submitHandler: function(form) {
var val_url = "index.php?eID=tx_nG6&type=install";
val_url += "&username=" + $("#username_val").val();
val_url += "&first_name=" + $("#first_name_val").val();
val_url += "&last_name=" + $("#last_name_val").val();
val_url += "&password=" + MD5($("#user_password_pwd_val").val());
val_url += "&email=" + $("#email_val").val();
val_url += "&project_name=" + $("#project_name_val").val();
val_url += "&description=" + $("#description_val").val();
val_url += "&pid=" + $("#pid").val();
url: val_url,
success: function(val, status, xhr) {
$("#message").html("Installation finished with success, use the <a href=\"index.php?id="+$("#id").val()+"\">ng6</a>").removeClass("hidden alert-error");
error: function (xhr, ajaxOptions, thrownError) {
var html = '<div class="alert alert-error"><strong>Error!</strong> An error occured when attempting to finalize installation.</div>';
$("#btn-install").click( function() {
function addWorkflowsStatusOnRun() {
......@@ -32,7 +32,7 @@ class Install (Workflow):
# Set typo3 and nG6 path variables
ng6conf = NG6ConfigReader()
[db_host, db_user, db_password, db_name] = ng6conf.get_typo3_db_params()
print "Download web site."
print "Download web site source code."
dummy_tmp_zipfile = tempfile.NamedTemporaryFile(prefix = 'dummy_', suffix = '.zip').name
dummy_tmp_dir = tempfile.mkdtemp(suffix='_typo3', prefix='dummy_')
......@@ -43,7 +43,7 @@ class Install (Workflow):
# Downloading typo3 package
urllib.urlretrieve(self.get_resource("typo3_src"), dummy_tmp_zipfile)
print "Install web site."
print "Install web site source code."
# Testing and Unzipping typo3 package
with zipfile.ZipFile(dummy_tmp_zipfile, 'r') as zipf:
if zipf.testzip() is None:
......@@ -128,9 +128,9 @@ class Install (Workflow):
for i in curs.fetchall() : tables.append(i[0])
erase = "n"
if len(tables) > 0 and "tx_nG6_project" in tables :
erase = raw_input('Database allready contain a ng6 web site , do you want DROP ng6 tables (y/n) ? ')
erase = raw_input('Database allready contains a ng6 web site , do you want to DROP ng6 tables (y/n) ? ')
elif len(tables) > 0 and ("tt_content" in tables and "pages" in tables and "be_users" in tables ):
erase = raw_input('Database contain typo3 tables, do you want DROP ng6 tables (y/n) ? ')
erase = raw_input('Database contains typo3 tables, do you want DROP ng6 tables (y/n) ? ')
if erase == "y" :
print "Drop tables."
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment