Permalink
Browse files

Updating installation code

  • Loading branch information...
1 parent cb5da59 commit 86ef6fbfe2963cf6aafc366ee654faa8c6a54811 @benkeen committed Apr 21, 2013
View
@@ -6,7 +6,7 @@
// if need be, redirect to the install instructions page
Utils::maybeShowInstallationPage();
-if (!Core::checkIsLoggedIn() && !Core::checkDemoModeAllowAnonymousUse()) {
+if (!Core::checkIsLoggedIn() && !Core::checkAllowMultiUserAnonymousUse()) {
header("location: login.php#t1");
exit;
}
View
@@ -7,7 +7,7 @@
Utils::maybeShowInstallationPage();
$isLoggedIn = Core::checkIsLoggedIn();
-if ($isLoggedIn || (!$isLoggedIn && Core::checkDemoModeAllowAnonymousUse())) {
+if ($isLoggedIn || (!$isLoggedIn && Core::checkAllowMultiUserAnonymousUse())) {
header("location: ./");
exit;
}
@@ -396,13 +396,13 @@ public static function createAccount($accountInfo) {
first_name, last_name, email, password)
VALUES ('$now', '$now', '$now', NULL, '$accountType', '$firstName', '$lastName', '$email', '$password')
");
-
+
if ($autoEmail) {
- $content = $L["account_created_msg"] + "\n";
+ $content = $L["account_created_msg"] . "\n\n";
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(
"recipient" => $email,
@@ -411,12 +411,12 @@ public static function createAccount($accountInfo) {
));
}
- // if ($result["success"]) {
- // $accountID = mysql_insert_id();;
- // Core::initSessions();
- // $_SESSION["account_id"] = $accountID;
- // Core::initUser(true);
- // }
+ if ($result["success"]) {
+ $accountID = mysql_insert_id();
+ Core::initSessions();
+ $_SESSION["account_id"] = $accountID;
+ Core::initUser(true);
+ }
}
@@ -77,6 +77,8 @@ public function __construct($action, $post = array()) {
Settings::setSetting("userAccountSetup", $post["userAccountSetup"]);
Settings::setSetting("installationStepComplete_Core", "yes");
Settings::setSetting("defaultLanguage", $post["defaultLanguage"]);
+ Settings::setSetting("allowAnonymousAccess", $post["allowAnonymousAccess"]);
+ Settings::setSetting("anonymousUserPermissionDeniedMsg", $post["anonymousUserPermissionDeniedMsg"]);
$this->response["success"] = 1;
$this->response["content"] = "";
@@ -106,6 +108,7 @@ public function __construct($action, $post = array()) {
} catch (Exception $e) {
$this->response["success"] = false;
$this->response["content"] = "Unknown error.";
+
}
}
break;
@@ -13,7 +13,7 @@ class Core {
// overridable settings that the user may define in settings.php
private static $demoMode = false;
- private static $allowDemoModeAnonymousUse = true;
+ private static $allowMultiUserAnonymousUse = true;
private static $dbHostname;
private static $dbName;
private static $dbUsername;
@@ -77,7 +77,7 @@ public static function init($runtimeContext = "ui") {
// the order is significant in all of this
if ($runtimeContext != "installation" || $runtimeContext != "installation_db_ready") {
self::initDatabase();
- if ($runtimeContext == "ui" || $runtimeContext == "generation") {
+ if ($runtimeContext == "installation_db_ready" || $runtimeContext == "ui" || $runtimeContext == "generation") {
self::initSessions();
}
@@ -161,8 +161,8 @@ public function checkDemoMode() {
/**
* @access public
*/
- public function checkDemoModeAllowAnonymousUse() {
- return self::$allowDemoModeAnonymousUse;
+ public function checkAllowMultiUserAnonymousUse() {
+ return self::$allowMultiUserAnonymousUse;
}
/**
@@ -342,7 +342,6 @@ private function initGeoData() {
self::$geoData = new GeoData();
}
-
/**
* Initializes the Database object and stores it in Core::$db.
* @access private
@@ -382,9 +381,9 @@ private function initExportTypes($runtimeContext) {
* 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
* 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()) {
$setup = Settings::getSetting("userAccountSetup");
if ($setup == "anonymousAdmin") {
@@ -46,6 +46,7 @@ public static function createDatabase() {
if ($response["success"] == 1) {
return array(true, "");
} else {
+ print_r($response);
return array(false, "There was a problem creating the Core tables. Please report this problem.");
}
}
@@ -141,9 +142,10 @@ public static function createCoreTables() {
('installedDataTypes', ''),
('installedExportTypes', ''),
('installedCountries', ''),
+ ('allowAnonymousAccess', ''),
+ ('anonymousUserPermissionDeniedMsg', ''),
('theme', '$defaultTheme')
";
-
$queries[] = "
CREATE TABLE {$prefix}sessions (
session_id varchar(100) NOT NULL default '',
@@ -274,5 +274,8 @@
$L["feature_enabled"] = "Enabled";
$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_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["login_url_c"] = "Login URL:";
+$L["email_c"] = "Email:";
+$L["password_c"] = "Password:";
@@ -70,7 +70,6 @@ require([
}
function _toggleAnonymousAccess(e) {
- console.log(e, e.target);
if (e.target.checked) {
$("#anonymousUserPermissionDeniedMsg").removeClass("gdDisabled").removeAttr("disabled");
} else {
@@ -208,6 +207,8 @@ require([
var lastName = "";
var email = "";
var password = "";
+ var allowAnonymousAccess = "";
+ var anonymousUserPermissionDeniedMsg = "";
if (userAccountSetup == "single" || userAccountSetup == "multiple") {
firstName = $.trim($("#firstName").val());
@@ -226,6 +227,11 @@ require([
if (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) {
@@ -248,6 +254,8 @@ require([
lastName: lastName,
email: email,
password: password,
+ allowAnonymousAccess: allowAnonymousAccess,
+ anonymousUserPermissionDeniedMsg: anonymousUserPermissionDeniedMsg,
// weird, because the field was on the first page
defaultLanguage: _defaultLanguage
@@ -89,9 +89,8 @@
</div>
<div class="gdFields">
-
<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="lastName_error"></div>
@@ -124,9 +123,9 @@
<span class="rightBox">
<input type="checkbox" id="allowAnonymousAccess" /><label for="allowAnonymousAccess">{$L.feature_enabled}</label>
</span>
- <h4>{$L.anonymous_access}</h4>
+ <h3>{$L.anonymous_access}</h3>
<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"
disabled="disabled">{$L.anonymous_user_default_message}</textarea>
</div>
@@ -100,7 +100,7 @@ ul {
.gdFields .gdCol {
float: left;
width: 350px; }
- .gdFields .gdCol h4 {
+ .gdFields .gdCol h3 {
margin-top: 0px; }
.gdFields .gdCol .rightBox {
float: right; }
@@ -100,7 +100,7 @@ ul {
.gdFields .gdCol {
float: left;
width: 350px; }
- .gdFields .gdCol h4 {
+ .gdFields .gdCol h3 {
margin-top: 0px; }
.gdFields .gdCol .rightBox {
float: right; }
@@ -109,7 +109,7 @@ ul {
.gdCol {
float: left;
width: 350px;
- h4 {
+ h3 {
margin-top: 0px;
}
.rightBox {

0 comments on commit 86ef6fb

Please sign in to comment.