Skip to content

Commit

Permalink
Updating installation code
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Apr 21, 2013
1 parent cb5da59 commit 86ef6fb
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 29 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// if need be, redirect to the install instructions page // if need be, redirect to the install instructions page
Utils::maybeShowInstallationPage(); Utils::maybeShowInstallationPage();


if (!Core::checkIsLoggedIn() && !Core::checkDemoModeAllowAnonymousUse()) { if (!Core::checkIsLoggedIn() && !Core::checkAllowMultiUserAnonymousUse()) {
header("location: login.php#t1"); header("location: login.php#t1");
exit; exit;
} }
Expand Down
2 changes: 1 addition & 1 deletion login.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Utils::maybeShowInstallationPage(); Utils::maybeShowInstallationPage();


$isLoggedIn = Core::checkIsLoggedIn(); $isLoggedIn = Core::checkIsLoggedIn();
if ($isLoggedIn || (!$isLoggedIn && Core::checkDemoModeAllowAnonymousUse())) { if ($isLoggedIn || (!$isLoggedIn && Core::checkAllowMultiUserAnonymousUse())) {
header("location: ./"); header("location: ./");
exit; exit;
} }
Expand Down
20 changes: 10 additions & 10 deletions resources/classes/Account.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ public static function createAccount($accountInfo) {
first_name, last_name, email, password) first_name, last_name, email, password)
VALUES ('$now', '$now', '$now', NULL, '$accountType', '$firstName', '$lastName', '$email', '$password') VALUES ('$now', '$now', '$now', NULL, '$accountType', '$firstName', '$lastName', '$email', '$password')
"); ");

if ($autoEmail) { if ($autoEmail) {
$content = $L["account_created_msg"] + "\n"; $content = $L["account_created_msg"] . "\n\n";
if (isset($_SERVER["HTTP_REFERER"]) && !empty($_SERVER["HTTP_REFERER"])) { if (isset($_SERVER["HTTP_REFERER"]) && !empty($_SERVER["HTTP_REFERER"])) {
$content .= "Login URL: {$_SERVER["HTTP_REFERER"]}\n"; $content .= "{$L["login_url_c"]} {$_SERVER["HTTP_REFERER"]}\n";
} }
$content .= "Email: $email\nPassword: {$accountInfo["password"]}\n"; $content .= "{$L["email_c"]} $email\n{$L["password_c"]} {$accountInfo["password"]}\n";


$response = Emails::sendEmail(array( $response = Emails::sendEmail(array(
"recipient" => $email, "recipient" => $email,
Expand All @@ -411,12 +411,12 @@ public static function createAccount($accountInfo) {
)); ));
} }


// if ($result["success"]) { if ($result["success"]) {
// $accountID = mysql_insert_id();; $accountID = mysql_insert_id();
// Core::initSessions(); Core::initSessions();
// $_SESSION["account_id"] = $accountID; $_SESSION["account_id"] = $accountID;
// Core::initUser(true); Core::initUser(true);
// } }
} }




Expand Down
3 changes: 3 additions & 0 deletions resources/classes/AjaxRequest.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function __construct($action, $post = array()) {
Settings::setSetting("userAccountSetup", $post["userAccountSetup"]); Settings::setSetting("userAccountSetup", $post["userAccountSetup"]);
Settings::setSetting("installationStepComplete_Core", "yes"); Settings::setSetting("installationStepComplete_Core", "yes");
Settings::setSetting("defaultLanguage", $post["defaultLanguage"]); Settings::setSetting("defaultLanguage", $post["defaultLanguage"]);
Settings::setSetting("allowAnonymousAccess", $post["allowAnonymousAccess"]);
Settings::setSetting("anonymousUserPermissionDeniedMsg", $post["anonymousUserPermissionDeniedMsg"]);


$this->response["success"] = 1; $this->response["success"] = 1;
$this->response["content"] = ""; $this->response["content"] = "";
Expand Down Expand Up @@ -106,6 +108,7 @@ public function __construct($action, $post = array()) {
} catch (Exception $e) { } catch (Exception $e) {
$this->response["success"] = false; $this->response["success"] = false;
$this->response["content"] = "Unknown error."; $this->response["content"] = "Unknown error.";

} }
} }
break; break;
Expand Down
13 changes: 6 additions & 7 deletions resources/classes/Core.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Core {


// overridable settings that the user may define in settings.php // overridable settings that the user may define in settings.php
private static $demoMode = false; private static $demoMode = false;
private static $allowDemoModeAnonymousUse = true; private static $allowMultiUserAnonymousUse = true;
private static $dbHostname; private static $dbHostname;
private static $dbName; private static $dbName;
private static $dbUsername; private static $dbUsername;
Expand Down Expand Up @@ -77,7 +77,7 @@ public static function init($runtimeContext = "ui") {
// the order is significant in all of this // the order is significant in all of this
if ($runtimeContext != "installation" || $runtimeContext != "installation_db_ready") { if ($runtimeContext != "installation" || $runtimeContext != "installation_db_ready") {
self::initDatabase(); self::initDatabase();
if ($runtimeContext == "ui" || $runtimeContext == "generation") { if ($runtimeContext == "installation_db_ready" || $runtimeContext == "ui" || $runtimeContext == "generation") {
self::initSessions(); self::initSessions();
} }


Expand Down Expand Up @@ -161,8 +161,8 @@ public function checkDemoMode() {
/** /**
* @access public * @access public
*/ */
public function checkDemoModeAllowAnonymousUse() { public function checkAllowMultiUserAnonymousUse() {
return self::$allowDemoModeAnonymousUse; return self::$allowMultiUserAnonymousUse;
} }


/** /**
Expand Down Expand Up @@ -342,7 +342,6 @@ private function initGeoData() {
self::$geoData = new GeoData(); self::$geoData = new GeoData();
} }



/** /**
* Initializes the Database object and stores it in Core::$db. * Initializes the Database object and stores it in Core::$db.
* @access private * @access private
Expand Down Expand Up @@ -382,9 +381,9 @@ private function initExportTypes($runtimeContext) {
* if self::allowDemoModeAnonymousUse is enabled and the user isn't logged in, this won't * if self::allowDemoModeAnonymousUse is enabled and the user isn't logged in, this won't
* initialize the user - however, they can still access the script (just not save anything). You * initialize the user - however, they can still access the script (just not save anything). You
* can always detect for this by checking self::$isLoggedIn * can always detect for this by checking self::$isLoggedIn
* @access private * @access public
*/ */
private function initUser($bypass = false) { public function initUser($bypass = false) {
if ($bypass || self::checkIsInstalled()) { if ($bypass || self::checkIsInstalled()) {
$setup = Settings::getSetting("userAccountSetup"); $setup = Settings::getSetting("userAccountSetup");
if ($setup == "anonymousAdmin") { if ($setup == "anonymousAdmin") {
Expand Down
4 changes: 3 additions & 1 deletion resources/classes/Installation.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static function createDatabase() {
if ($response["success"] == 1) { if ($response["success"] == 1) {
return array(true, ""); return array(true, "");
} else { } else {
print_r($response);
return array(false, "There was a problem creating the Core tables. Please report this problem."); return array(false, "There was a problem creating the Core tables. Please report this problem.");
} }
} }
Expand Down Expand Up @@ -141,9 +142,10 @@ public static function createCoreTables() {
('installedDataTypes', ''), ('installedDataTypes', ''),
('installedExportTypes', ''), ('installedExportTypes', ''),
('installedCountries', ''), ('installedCountries', ''),
('allowAnonymousAccess', ''),
('anonymousUserPermissionDeniedMsg', ''),
('theme', '$defaultTheme') ('theme', '$defaultTheme')
"; ";

$queries[] = " $queries[] = "
CREATE TABLE {$prefix}sessions ( CREATE TABLE {$prefix}sessions (
session_id varchar(100) NOT NULL default '', session_id varchar(100) NOT NULL default '',
Expand Down
5 changes: 4 additions & 1 deletion resources/lang/en.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -274,5 +274,8 @@
$L["feature_enabled"] = "Enabled"; $L["feature_enabled"] = "Enabled";
$L["anonymous_access"] = "Anonymous access"; $L["anonymous_access"] = "Anonymous access";
$L["anonymous_user_desc"] = "Anonymous users can use the script but have limited access: they cannot save, link to their data sets or generate more than 200 rows at a time."; $L["anonymous_user_desc"] = "Anonymous users can use the script but have limited access: they cannot save, link to their data sets or generate more than 200 rows at a time.";
$L["anonymous_user_message"] = "Message to display to anonymous users when trying to save."; $L["anonymous_user_message"] = "Message to display to anonymous users when trying to save:";
$L["anonymous_user_default_message"] = "Please email someone@yoursite.com to get a user account."; $L["anonymous_user_default_message"] = "Please email someone@yoursite.com to get a user account.";
$L["login_url_c"] = "Login URL:";
$L["email_c"] = "Email:";
$L["password_c"] = "Password:";
10 changes: 9 additions & 1 deletion resources/scripts/install.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ require([
} }


function _toggleAnonymousAccess(e) { function _toggleAnonymousAccess(e) {
console.log(e, e.target);
if (e.target.checked) { if (e.target.checked) {
$("#anonymousUserPermissionDeniedMsg").removeClass("gdDisabled").removeAttr("disabled"); $("#anonymousUserPermissionDeniedMsg").removeClass("gdDisabled").removeAttr("disabled");
} else { } else {
Expand Down Expand Up @@ -208,6 +207,8 @@ require([
var lastName = ""; var lastName = "";
var email = ""; var email = "";
var password = ""; var password = "";
var allowAnonymousAccess = "";
var anonymousUserPermissionDeniedMsg = "";


if (userAccountSetup == "single" || userAccountSetup == "multiple") { if (userAccountSetup == "single" || userAccountSetup == "multiple") {
firstName = $.trim($("#firstName").val()); firstName = $.trim($("#firstName").val());
Expand All @@ -226,6 +227,11 @@ require([
if (password === "") { if (password === "") {
errors.push({ fieldId: "password", error: _L.validation_no_password }); errors.push({ fieldId: "password", error: _L.validation_no_password });
} }

if (userAccountSetup == "multiple") {
allowAnonymousAccess = $("#allowAnonymousAccess").attr("checked") ? "yes" : "no";
anonymousUserPermissionDeniedMsg = $("#anonymousUserPermissionDeniedMsg").val();
}
} }


if (errors.length) { if (errors.length) {
Expand All @@ -248,6 +254,8 @@ require([
lastName: lastName, lastName: lastName,
email: email, email: email,
password: password, password: password,
allowAnonymousAccess: allowAnonymousAccess,
anonymousUserPermissionDeniedMsg: anonymousUserPermissionDeniedMsg,


// weird, because the field was on the first page // weird, because the field was on the first page
defaultLanguage: _defaultLanguage defaultLanguage: _defaultLanguage
Expand Down
7 changes: 3 additions & 4 deletions resources/templates/install.tab1.tpl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@
</div> </div>


<div class="gdFields"> <div class="gdFields">

<div class="gdCol" id="gdInstallAccountDetails" style="display:none"> <div class="gdCol" id="gdInstallAccountDetails" style="display:none">
<h4 id="gdInstallAccountDetailsMessage"></h4> <h3 id="gdInstallAccountDetailsMessage"></h3>


<div class="gdError" id="firstName_error"></div> <div class="gdError" id="firstName_error"></div>
<div class="gdError" id="lastName_error"></div> <div class="gdError" id="lastName_error"></div>
Expand Down Expand Up @@ -124,9 +123,9 @@
<span class="rightBox"> <span class="rightBox">
<input type="checkbox" id="allowAnonymousAccess" /><label for="allowAnonymousAccess">{$L.feature_enabled}</label> <input type="checkbox" id="allowAnonymousAccess" /><label for="allowAnonymousAccess">{$L.feature_enabled}</label>
</span> </span>
<h4>{$L.anonymous_access}</h4> <h3>{$L.anonymous_access}</h3>
<div>{$L.anonymous_user_desc}</div> <div>{$L.anonymous_user_desc}</div>
<div>{$L.anonymous_user_message}</div> <div><i>{$L.anonymous_user_message}</i></div>
<textarea id="anonymousUserPermissionDeniedMsg" name="anonymousUserPermissionDeniedMsg" class="gdDisabled" <textarea id="anonymousUserPermissionDeniedMsg" name="anonymousUserPermissionDeniedMsg" class="gdDisabled"
disabled="disabled">{$L.anonymous_user_default_message}</textarea> disabled="disabled">{$L.anonymous_user_default_message}</textarea>
</div> </div>
Expand Down
2 changes: 1 addition & 1 deletion resources/themes/classic/compiled/general.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ul {
.gdFields .gdCol { .gdFields .gdCol {
float: left; float: left;
width: 350px; } width: 350px; }
.gdFields .gdCol h4 { .gdFields .gdCol h3 {
margin-top: 0px; } margin-top: 0px; }
.gdFields .gdCol .rightBox { .gdFields .gdCol .rightBox {
float: right; } float: right; }
Expand Down
2 changes: 1 addition & 1 deletion resources/themes/classic/compiled/styles.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ul {
.gdFields .gdCol { .gdFields .gdCol {
float: left; float: left;
width: 350px; } width: 350px; }
.gdFields .gdCol h4 { .gdFields .gdCol h3 {
margin-top: 0px; } margin-top: 0px; }
.gdFields .gdCol .rightBox { .gdFields .gdCol .rightBox {
float: right; } float: right; }
Expand Down
2 changes: 1 addition & 1 deletion resources/themes/classic/sass/general.scss
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ul {
.gdCol { .gdCol {
float: left; float: left;
width: 350px; width: 350px;
h4 { h3 {
margin-top: 0px; margin-top: 0px;
} }
.rightBox { .rightBox {
Expand Down

0 comments on commit 86ef6fb

Please sign in to comment.