Merge pull request #403 from RelaxedArcher/master

Added settings menu for multi-user and registration control
This commit is contained in:
Matt Pass
2014-06-04 07:47:09 +01:00
3 changed files with 34 additions and 2 deletions

View File

@@ -29,14 +29,14 @@ echo $ICEcoder["password"] == "" && !$ICEcoder["multiUser"] ? "Setup" : "Login";
<input type="submit" name="submit" value="<?php if ($ICEcoder["multiUser"] && $ICEcoderSettings["enableRegistration"]) {echo "set password / login";} else {echo $ICEcoder["password"] == "" ? "set password" : "login";}; ?>" class="button">
<?php
if($ICEcoder["multiUser"] && $ICEcoderSettings["enableRegistration"]){
echo '<div class="text"><a href="javascript:alert(\'To disable registration mode, open lib/config___settings.php and change enableRegistration to false then reload this page\')">Registration mode enabled</a></div>';
echo '<div class="text"><a href="javascript:alert(\'To disable registration mode, open the settings menu or open lib/config___settings.php and change enableRegistration to false then reload this page\')">Registration mode enabled</a></div>';
}
?>
<?php
if ($ICEcoder["password"] == "" || $ICEcoder["multiUser"]) {
echo '<div class="text"><input type="checkbox" name="checkUpdates" value="true" checked> auto-check for updates</div>';
}
if (!$ICEcoder["multiUser"]) { echo '<div class="text"><a href="javascript:alert(\'To put into multi-user mode, open lib/config___settings.php and change multiUser to true then reload this page\')">multi-user?</a></div>';};
if (!$ICEcoder["multiUser"]) { echo '<div class="text"><a href="javascript:alert(\'To put into multi-user mode, open the settings menu or open lib/config___settings.php and change multiUser to true then reload this page\')">multi-user?</a></div>';};
?>
<input type="hidden" name="csrf" value="<?php echo $_SESSION["csrf"]; ?>">
</form>

View File

@@ -201,6 +201,20 @@ function findSequence(goal) {
<span style="display: inline-block; padding: 4px 5px 0 5px">secs, getting last</span>
<input type="text" name="bugFileMaxLines" style="width: 50px" onkeydown="showButton()" value="<?php echo $ICEcoder["bugFileMaxLines"];?>">
<span style="display: inline-block; padding: 4px 5px 0 5px">lines</span>
<br><br>
<div>
<h2> multi-user <span class="info" title="Make sure you don't lock yourself out">[?]</span> </h2>
<input type="checkbox" name="multiUser" value="true" onclick="showButton();changeEnableRegistrationStatus();"<?php if($ICEcoder["multiUser"]){echo ' checked';} ?>>Multi-User
<?php
echo '<input type="checkbox" name="enableRegistration" value="true"';
if($ICEcoder["enableRegistration"]){echo ' checked';}
if(!$ICEcoder["multiUser"]){
echo ' disabled=""';
}
echo ' onclick="showButton()" id="enableRegistration"> Registration </input>';
?>
</div>
</span>
<script>
@@ -232,6 +246,9 @@ function changeFontSize() {
cMCSS[strCSS][0].style['fontSize'] = document.getElementById("fontSize").value;
}
var changeEnableRegistrationStatus = function(){
document.getElementById('enableRegistration').disabled=!document.getElementById('enableRegistration').disabled;
}
var showButton = function() {
document.getElementById('updateButton').style.opacity = 1;
}

View File

@@ -63,6 +63,21 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset
// Do we need a file manager refresh?
$refreshFM = $_POST['changedFileSettings']=="true" ? "true" : "false";
// Change multiUser and enableRegistration in config___settings.php
$generalSettingsContents = file_get_contents($configSettings,false,$context);
$isMultiUser = $_POST['multiUser'] ? "true" : "false";
$generalSettingsContents = str_replace('"multiUser" => true,','"multiUser" => '.$isMultiUser.',',$generalSettingsContents);
$generalSettingsContents = str_replace('"multiUser" => false,','"multiUser" => '.$isMultiUser.',',$generalSettingsContents);
$isEnableRegistration = $_POST['enableRegistration'] ? "true" : "false";
$generalSettingsContents = str_replace('"enableRegistration" => true','"enableRegistration" => '.$isEnableRegistration,$generalSettingsContents);
$generalSettingsContents = str_replace('"enableRegistration" => false','"enableRegistration" => '.$isEnableRegistration,$generalSettingsContents);
$fConfigSettings = fopen($configSettings, 'w') or die("Can't update config file. Please set public write permissions on ".$configSettings." and press refresh");
fwrite($fConfigSettings, $generalSettingsContents);
fclose($fConfigSettings);
// With all that worked out, we can now hide the settings screen and apply the new settings
$jsBugFilePaths = "['".str_replace(",","','",str_replace(" ","",strClean($_POST['bugFilePaths'])))."']";
echo "<script>top.ICEcoder.settingsScreen('hide');top.ICEcoder.useNewSettings('".$themeURL."',".$ICEcoder["codeAssist"].",".$ICEcoder["lockedNav"].",'".$ICEcoder["tagWrapperCommand"]."','".$ICEcoder["autoComplete"]."',".$ICEcoder["visibleTabs"].",'".$ICEcoder["fontSize"]."',".$ICEcoder["lineWrapping"].",".$ICEcoder["indentWithTabs"].",".$ICEcoder["indentSize"].",'".$ICEcoder["pluginPanelAligned"]."',".$jsBugFilePaths.",".$ICEcoder["bugFileCheckTimer"].",".$ICEcoder["bugFileMaxLines"].",".$refreshFM.");</script>";