admin site template
This commit is contained in:
@@ -1,29 +1,58 @@
|
||||
.statusmessage {
|
||||
background-color: #DDDDFF;
|
||||
#user_sql .main {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.errormessage {
|
||||
background-color: #FFDDDD;
|
||||
#user_sql .main > div {
|
||||
float: left;
|
||||
width: 380px;
|
||||
}
|
||||
|
||||
.successmessage {
|
||||
background-color: #DDFFDD;
|
||||
}
|
||||
|
||||
.statusmessage, .errormessage, .successmessage {
|
||||
display: none;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
#sql-1 p label:first-child,
|
||||
#sql-2 p label:first-child,
|
||||
#sql-3 p label:first-child,
|
||||
#sql-4 p label:first-child,
|
||||
#sql-5 p label:first-child,
|
||||
#sql-6 p label:first-child,
|
||||
#sql-7 p label:first-child {
|
||||
#user_sql .main div > label > span {
|
||||
display: inline-block;
|
||||
text-align: right;
|
||||
width: 300px;
|
||||
padding-right: 10px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
#user_sql .main div > label > input,
|
||||
#user_sql .main div > label > select {
|
||||
width: 257px;
|
||||
}
|
||||
|
||||
#user_sql .main div > input[type="checkbox"] {
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
#user_sql .main .button-right {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#user_sql .main .button-right > input[type="submit"] {
|
||||
float: right;
|
||||
}
|
||||
|
||||
#user_sql .msg {
|
||||
left: 0;
|
||||
padding: 3px;
|
||||
position: fixed;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
#user_sql .msg.error {
|
||||
background-color: #d2322d;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#user_sql .msg.success {
|
||||
background-color: #47a447;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#user_sql .msg.waiting {
|
||||
background-color: #ff8f00;
|
||||
color: #fff;
|
||||
}
|
||||
363
js/settings.js
363
js/settings.js
@@ -1,321 +1,98 @@
|
||||
// settings.js of user_sql
|
||||
var user_sql = user_sql || {};
|
||||
var form_id = "#user_sql";
|
||||
|
||||
// declare namespace
|
||||
var user_sql = user_sql ||
|
||||
{};
|
||||
|
||||
/**
|
||||
* init admin settings view
|
||||
*/
|
||||
user_sql.adminSettingsUI = function () {
|
||||
var app_id = "user_sql";
|
||||
|
||||
if ($('#sqlDiv').length > 0) {
|
||||
// enable tabs on settings page
|
||||
$('#sqlDiv').tabs();
|
||||
if ($(form_id).length > 0) {
|
||||
|
||||
// Attach auto-completion to all column fields
|
||||
$('#col_username, #col_password, #col_displayname, #col_active, #col_email, #col_gethome').autocomplete({
|
||||
source: function (request, response) {
|
||||
var post = $('#sqlForm').serializeArray();
|
||||
var domain = $('#sql_domain_chooser option:selected').val();
|
||||
|
||||
post.push({
|
||||
name: 'function',
|
||||
value: 'getColumnAutocomplete'
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'domain',
|
||||
value: domain
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'request',
|
||||
value: request.term
|
||||
});
|
||||
|
||||
// Ajax foobar
|
||||
$.post(OC.filePath('user_sql', 'ajax', 'settings.php'), post, response, 'json');
|
||||
},
|
||||
minLength: 0,
|
||||
open: function () {
|
||||
$(this).attr('state', 'open');
|
||||
},
|
||||
close: function () {
|
||||
$(this).attr('state', 'closed');
|
||||
}
|
||||
}).focus(function () {
|
||||
if ($(this).attr('state') != 'open') {
|
||||
$(this).autocomplete("search");
|
||||
}
|
||||
});
|
||||
|
||||
// Attach auto-completion to all group column fields
|
||||
$('#col_group_name, #col_group_username').autocomplete({
|
||||
source: function (request, response) {
|
||||
var post = $('#sqlForm').serializeArray();
|
||||
var domain = $('#sql_domain_chooser option:selected').val();
|
||||
|
||||
post.push({
|
||||
name: 'groupTable',
|
||||
value: 'true'
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'function',
|
||||
value: 'getColumnAutocomplete'
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'domain',
|
||||
value: domain
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'request',
|
||||
value: request.term
|
||||
});
|
||||
|
||||
// Ajax foobar
|
||||
$.post(OC.filePath('user_sql', 'ajax', 'settings.php'), post, response, 'json');
|
||||
},
|
||||
minLength: 0,
|
||||
open: function () {
|
||||
$(this).attr('state', 'open');
|
||||
},
|
||||
close: function () {
|
||||
$(this).attr('state', 'closed');
|
||||
}
|
||||
}).focus(function () {
|
||||
if ($(this).attr('state') != 'open') {
|
||||
$(this).autocomplete("search");
|
||||
}
|
||||
});
|
||||
|
||||
// Attach auto-completion to all table fields
|
||||
$('#sql_table, #sql_group_table').autocomplete({
|
||||
source: function (request, response) {
|
||||
var post = $('#sqlForm').serializeArray();
|
||||
var domain = $('#sql_domain_chooser option:selected').val();
|
||||
|
||||
post.push({
|
||||
name: 'function',
|
||||
value: 'getTableAutocomplete'
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'domain',
|
||||
value: domain
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'request',
|
||||
value: request.term
|
||||
});
|
||||
|
||||
// Ajax foobar
|
||||
$.post(OC.filePath('user_sql', 'ajax', 'settings.php'), post, response, 'json');
|
||||
},
|
||||
minLength: 0,
|
||||
open: function () {
|
||||
$(this).attr('state', 'open');
|
||||
},
|
||||
close: function () {
|
||||
$(this).attr('state', 'closed');
|
||||
}
|
||||
}).focus(function () {
|
||||
if ($(this).attr('state') != 'open') {
|
||||
$(this).autocomplete("search");
|
||||
}
|
||||
});
|
||||
|
||||
// Verify the SQL database settings
|
||||
$('#sqlVerify').click(function (event) {
|
||||
var click = function (event, path) {
|
||||
event.preventDefault();
|
||||
|
||||
var post = $('#sqlForm').serializeArray();
|
||||
var domain = $('#sql_domain_chooser option:selected').val();
|
||||
var post = $(form_id).serializeArray();
|
||||
var msg = $("#user_sql-msg");
|
||||
var msg_body = $("#user_sql-msg-body");
|
||||
|
||||
post.push({
|
||||
name: 'function',
|
||||
value: 'verifySettings'
|
||||
});
|
||||
msg_body.html(t(app_id, "Waiting..."));
|
||||
msg.addClass("waiting");
|
||||
msg.slideDown();
|
||||
|
||||
post.push({
|
||||
name: 'domain',
|
||||
value: domain
|
||||
});
|
||||
$.post(OC.generateUrl(path), post, function (data) {
|
||||
msg_body.html(data.data.message);
|
||||
msg.removeClass("error");
|
||||
msg.removeClass("success");
|
||||
msg.removeClass("waiting");
|
||||
|
||||
$('#sql_verify_message').show();
|
||||
$('#sql_success_message').hide();
|
||||
$('#sql_error_message').hide();
|
||||
$('#sql_update_message').hide();
|
||||
// Ajax foobar
|
||||
$.post(OC.filePath('user_sql', 'ajax', 'settings.php'), post, function (data) {
|
||||
$('#sql_verify_message').hide();
|
||||
if (data.status == 'success') {
|
||||
$('#sql_success_message').html(data.data.message);
|
||||
$('#sql_success_message').show();
|
||||
window.setTimeout(function () {
|
||||
$('#sql_success_message').hide();
|
||||
}, 10000);
|
||||
if (data.status === "success") {
|
||||
msg.addClass("success");
|
||||
} else {
|
||||
$('#sql_error_message').html(data.data.message);
|
||||
$('#sql_error_message').show();
|
||||
msg.addClass("error");
|
||||
}
|
||||
}, 'json');
|
||||
return false;
|
||||
});
|
||||
|
||||
// Save the settings for a domain
|
||||
$('#sqlSubmit').click(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var post = $('#sqlForm').serializeArray();
|
||||
var domain = $('#sql_domain_chooser option:selected').val();
|
||||
|
||||
post.push({
|
||||
name: 'function',
|
||||
value: 'saveSettings'
|
||||
});
|
||||
|
||||
post.push({
|
||||
name: 'domain',
|
||||
value: domain
|
||||
});
|
||||
|
||||
$('#sql_update_message').show();
|
||||
$('#sql_success_message').hide();
|
||||
$('#sql_verify_message').hide();
|
||||
$('#sql_error_message').hide();
|
||||
// Ajax foobar
|
||||
$.post(OC.filePath('user_sql', 'ajax', 'settings.php'), post, function (data) {
|
||||
$('#sql_update_message').hide();
|
||||
if (data.status == 'success') {
|
||||
$('#sql_success_message').html(data.data.message);
|
||||
$('#sql_success_message').show();
|
||||
window.setTimeout(function () {
|
||||
$('#sql_success_message').hide();
|
||||
msg.slideUp();
|
||||
}, 10000);
|
||||
} else {
|
||||
$('#sql_error_message').html(data.data.message);
|
||||
$('#sql_error_message').show();
|
||||
}
|
||||
}, 'json');
|
||||
}, "json");
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Attach event handler to the domain chooser
|
||||
$('#sql_domain_chooser').change(function () {
|
||||
user_sql.loadDomainSettings($('#sql_domain_chooser option:selected').val());
|
||||
});
|
||||
|
||||
$('#set_gethome_mode').change(function () {
|
||||
user_sql.setGethomeMode();
|
||||
});
|
||||
|
||||
$('#set_enable_gethome').change(function () {
|
||||
user_sql.setGethomeMode();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
user_sql.setGethomeMode = function () {
|
||||
var enabled = $('#set_enable_gethome').prop('checked');
|
||||
if (enabled) {
|
||||
$('#set_gethome_mode').prop('disabled', false);
|
||||
var val = $('#set_gethome_mode option:selected').val();
|
||||
if (val === 'query') {
|
||||
$('#set_gethome').prop('disabled', true);
|
||||
$('#col_gethome').prop('disabled', false);
|
||||
var autocomplete = function (ids, path) {
|
||||
$(ids).autocomplete({
|
||||
source: function (request, response) {
|
||||
var post = $(form_id).serializeArray();
|
||||
$.post(OC.generateUrl(path), post, response, "json");
|
||||
},
|
||||
minLength: 0,
|
||||
open: function () {
|
||||
$(this).attr("state", "open");
|
||||
},
|
||||
close: function () {
|
||||
$(this).attr("state", "closed");
|
||||
}
|
||||
else if (val === 'static') {
|
||||
$('#set_gethome').prop('disabled', false);
|
||||
$('#col_gethome').prop('disabled', true);
|
||||
}
|
||||
else {
|
||||
$('#set_gethome').prop('disabled', true);
|
||||
$('#col_gethome').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#set_gethome_mode').prop('disabled', true);
|
||||
$('#set_gethome').prop('disabled', true);
|
||||
$('#col_gethome').prop('disabled', true);
|
||||
}).focus(function () {
|
||||
if ($(this).attr("state") !== "open") {
|
||||
$(this).autocomplete("search");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the settings for the selected domain
|
||||
* @param string domain The domain to load
|
||||
*/
|
||||
user_sql.loadDomainSettings = function (domain) {
|
||||
$('#sql_success_message').hide();
|
||||
$('#sql_error_message').hide();
|
||||
$('#sql_verify_message').hide();
|
||||
$('#sql_loading_message').show();
|
||||
var post = [
|
||||
{
|
||||
name: 'appname',
|
||||
value: 'user_sql'
|
||||
},
|
||||
{
|
||||
name: 'function',
|
||||
value: 'loadSettingsForDomain'
|
||||
},
|
||||
{
|
||||
name: 'domain',
|
||||
value: domain
|
||||
}
|
||||
];
|
||||
$.post(OC.filePath('user_sql', 'ajax', 'settings.php'), post, function (data) {
|
||||
$('#sql_loading_message').hide();
|
||||
if (data.status == 'success') {
|
||||
for (key in data.settings) {
|
||||
if (key == 'set_strip_domain') {
|
||||
if (data.settings[key] == 'true')
|
||||
$('#' + key).prop('checked', true);
|
||||
else
|
||||
$('#' + key).prop('checked', false);
|
||||
}
|
||||
else if (key == 'set_allow_pwchange') {
|
||||
if (data.settings[key] == 'true')
|
||||
$('#' + key).prop('checked', true);
|
||||
else
|
||||
$('#' + key).prop('checked', false);
|
||||
}
|
||||
else if (key == 'set_active_invert') {
|
||||
if (data.settings[key] == 'true')
|
||||
$('#' + key).prop('checked', true);
|
||||
else
|
||||
$('#' + key).prop('checked', false);
|
||||
}
|
||||
else if (key == 'set_enable_gethome') {
|
||||
if (data.settings[key] == 'true')
|
||||
$('#' + key).prop('checked', true);
|
||||
else
|
||||
$('#' + key).prop('checked', false);
|
||||
}
|
||||
else {
|
||||
$('#' + key).val(data.settings[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#sql_error_message').html(data.data.message);
|
||||
$('#sql_error_message').show();
|
||||
}
|
||||
user_sql.setGethomeMode();
|
||||
}, 'json'
|
||||
$("#user_sql-db_connection_verify").click(function (event) {
|
||||
return click(event, "/apps/user_sql/settings/db/verify");
|
||||
});
|
||||
|
||||
$("#user_sql-clear_cache").click(function (event) {
|
||||
return click(event, "/apps/user_sql/settings/cache/clear");
|
||||
});
|
||||
|
||||
$("#user_sql-save").click(function (event) {
|
||||
return click(event, "/apps/user_sql/settings/properties");
|
||||
});
|
||||
|
||||
autocomplete(
|
||||
"#db-table-user, #db-table-user_group, #db-table-group",
|
||||
"/apps/user_sql/settings/autocomplete/table"
|
||||
);
|
||||
|
||||
autocomplete(
|
||||
"#db-table-user-column-uid, #db-table-user-column-email, #db-table-user-column-home, #db-table-user-column-password, #db-table-user-column-name, #db-table-user-column-avatar",
|
||||
"/apps/user_sql/settings/autocomplete/table/user"
|
||||
);
|
||||
|
||||
autocomplete(
|
||||
"#db-table-user_group-column-uid, #db-table-user_group-column-gid",
|
||||
"/apps/user_sql/settings/autocomplete/table/user_group"
|
||||
);
|
||||
|
||||
autocomplete(
|
||||
"#db-table-group-column-admin, #db-table-group-column-name, #db-table-group-column-gid",
|
||||
"/apps/user_sql/settings/autocomplete/table/group"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Run our JS if the SQL settings are present
|
||||
$(document).ready(function () {
|
||||
if ($('#sqlDiv')) {
|
||||
if ($(form_id)) {
|
||||
user_sql.adminSettingsUI();
|
||||
user_sql.loadDomainSettings($('#sql_domain_chooser option:selected').val());
|
||||
user_sql.setGethomeMode();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -175,6 +175,24 @@ class SettingsController extends Controller
|
||||
|
||||
$properties = $this->properties->getArray();
|
||||
|
||||
try {
|
||||
$this->getConnection();
|
||||
} catch (Exception $exception) {
|
||||
$this->logger->debug(
|
||||
"Returning saveProperties(): error",
|
||||
["app" => $this->appName]
|
||||
);
|
||||
|
||||
return [
|
||||
"status" => "error",
|
||||
"data" => [
|
||||
"message" => $this->localization->t(
|
||||
"Error connecting to the database: "
|
||||
) . $exception->getMessage()
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
$reqValue = $this->request->getParam(str_replace(".", "-", $key));
|
||||
$appValue = $this->properties[$key];
|
||||
|
||||
@@ -1,273 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* Nextcloud - user_sql
|
||||
*
|
||||
* @copyright 2018 Marcin Łojewski <dev@mlojewski.me>
|
||||
* @author Marcin Łojewski <dev@mlojewski.me>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use OCP\IL10N;
|
||||
|
||||
script('user_sql', 'settings');
|
||||
style('user_sql', 'settings');
|
||||
$cfgClass = 'section';
|
||||
|
||||
function print_text_input(IL10N $l, $id, $label, $value = "")
|
||||
{
|
||||
echo "<div><label for=\"$id\"><span>";
|
||||
echo p($l->t($label));
|
||||
echo "</span><input type=\"text\" id=\"$id\" name=\"$id\" value=\"";
|
||||
echo p($value);
|
||||
echo "\">";
|
||||
echo "</label></div>";
|
||||
}
|
||||
|
||||
function print_checkbox_input(IL10N $l, $id, $label, $value = "", $div = true)
|
||||
{
|
||||
if ($div) {
|
||||
echo "<div>";
|
||||
}
|
||||
echo "<input type=\"checkbox\" id=\"$id\" name=\"$id\" value=\"1\"";
|
||||
if ($value === true) {
|
||||
echo " checked";
|
||||
}
|
||||
echo ">";
|
||||
echo "<label for=\"$id\">";
|
||||
echo p($l->t($label));
|
||||
echo "</label>";
|
||||
if ($div) {
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
|
||||
function print_select_options(
|
||||
IL10N $l, $id, $label, $options = [], $select = false
|
||||
) {
|
||||
echo "<div><label for=\"$id\"><span>";
|
||||
echo p($l->t($label));
|
||||
echo "</span><select id=\"$id\" name=\"$id\">";
|
||||
|
||||
foreach ($options as $name => $value) {
|
||||
echo "<option ";
|
||||
if ($select === $name) {
|
||||
echo "selected=\"selected\"";
|
||||
}
|
||||
echo "value=\"";
|
||||
echo $name;
|
||||
echo "\">";
|
||||
echo p($value);
|
||||
echo "</option>";
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
echo "</label></div>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="<?php p($cfgClass); ?>">
|
||||
<h2><?php p($l->t('SQL User Backend')); ?></h2>
|
||||
|
||||
<form id="sqlForm" action="#" method="post" class="<?php p($cfgClass); ?>">
|
||||
|
||||
<div id="sqlDiv" class="<?php p($cfgClass); ?>">
|
||||
<label for="sql_domain_chooser"><?php p($l->t('Settings for Domain')) ?></label>
|
||||
<select id="sql_domain_chooser" name="sql_domain_chooser">
|
||||
<?php foreach ($_['allowed_domains'] as $domain): ?>
|
||||
<option value="<?php p($domain); ?>"><?php p($domain); ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
<ul>
|
||||
<li><a id="sqlBasicSettings" href="#sql-1"><?php p($l->t('Connection Settings')); ?></a></li>
|
||||
<li><a id="sqlColSettings" href="#sql-2"><?php p($l->t('Column Settings')); ?></a></li>
|
||||
<li><a id="sqlEmailSettings" href="#sql-3"><?php p($l->t('E-Mail Settings')); ?></a></li>
|
||||
<li><a id="sqlDomainSettings" href="#sql-4"><?php p($l->t('Domain Settings')); ?></a></li>
|
||||
<li><a id="sqlGethomeSettings" href="#sql-5"><?php p($l->t('getHome Settings')); ?></a></li>
|
||||
<li><a id="sqlGroupsSettings" href="#sql-6"><?php p($l->t('Groups Settings')); ?></a></li>
|
||||
</ul>
|
||||
|
||||
<fieldset id="sql-1">
|
||||
<p><label for="sql_driver"><?php p($l->t('SQL Driver')); ?></label>
|
||||
<?php $db_driver = array('mysql' => 'MySQL', 'pgsql' => 'PostgreSQL'); ?>
|
||||
<select id="sql_driver" name="sql_driver">
|
||||
<?php
|
||||
foreach ($db_driver as $driver => $name):
|
||||
//echo $_['sql_driver'];
|
||||
if ($_['sql_driver'] === $driver): ?>
|
||||
<option selected="selected" value="<?php p($driver); ?>"><?php p($name); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="<?php p($driver); ?>"><?php p($name); ?></option>
|
||||
<?php endif;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p><label for="sql_hostname"><?php p($l->t('Host')); ?></label><input type="text" id="sql_hostname"
|
||||
name="sql_hostname"
|
||||
value="<?php p($_['sql_hostname']); ?>">
|
||||
</p>
|
||||
|
||||
<p><label for="sql_database"><?php p($l->t('Database')); ?></label><input type="text" id="sql_database"
|
||||
name="sql_database"
|
||||
value="<?php p($_['sql_database']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="sql_username"><?php p($l->t('Username')); ?></label><input type="text" id="sql_username"
|
||||
name="sql_username"
|
||||
value="<?php p($_['sql_username']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="sql_password"><?php p($l->t('Password')); ?></label><input type="password"
|
||||
id="sql_password"
|
||||
name="sql_password"
|
||||
value="<?php p($_['sql_password']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><input type="submit" id="sqlVerify" value="<?php p($l->t('Verify Settings')); ?>"></p>
|
||||
|
||||
</fieldset>
|
||||
<fieldset id="sql-2">
|
||||
<p><label for="sql_table"><?php p($l->t('Table')); ?></label><input type="text" id="sql_table"
|
||||
name="sql_table"
|
||||
value="<?php p($_['sql_table']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="col_username"><?php p($l->t('Username Column')); ?></label><input type="text"
|
||||
id="col_username"
|
||||
name="col_username"
|
||||
value="<?php p($_['col_username']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="col_password"><?php p($l->t('Password Column')); ?></label><input type="text"
|
||||
id="col_password"
|
||||
name="col_password"
|
||||
value="<?php p($_['col_password']); ?>"/>
|
||||
</p>
|
||||
|
||||
<form id="user_sql" action="#" method="post">
|
||||
<div id="user_sql-msg" class="msg" style="display: none">
|
||||
<p id="user_sql-msg-body"></p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<p>
|
||||
<label for="set_allow_pwchange"><?php p($l->t('Allow password changing (read README!)')); ?></label><input
|
||||
type="checkbox" id="set_allow_pwchange" name="set_allow_pwchange" value="1"<?php
|
||||
if ($_['set_allow_pwchange']) {
|
||||
p(' checked');
|
||||
}
|
||||
?>><br>
|
||||
<em><?php p($l->t('Allow changing passwords. Imposes a security risk if password salts are not recreated.')); ?></em>
|
||||
<?php p($l->t("This is the place for ")); ?>
|
||||
<b><?php p($l->t("User and Group SQL Backends")); ?></b>
|
||||
<?php p($l->t(" app settings. Please see the documentation for more information.")); ?>
|
||||
<a target="_blank" rel="noreferrer noopener" class="icon-info" title="Open documentation" href="https://github.com/nextcloud/user_sql"></a>
|
||||
</p>
|
||||
<em><?php p($l->t('Only the encryption types "System","password_hash" and "Joomla2" are safe.')); ?></em></p>
|
||||
|
||||
<p><label for="col_displayname"><?php p($l->t('Real Name Column')); ?></label><input type="text"
|
||||
id="col_displayname"
|
||||
name="col_displayname"
|
||||
value="<?php p($_['col_displayname']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="set_crypt_type"><?php p($l->t('Encryption Type')); ?></label>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="section">
|
||||
<h2><?php p($l->t("Database connection")); ?></h2>
|
||||
<p class="settings-hint"><?php p($l->t("Define your database connection parameters.")); ?></p>
|
||||
<fieldset><?php
|
||||
$drivers = ["mysql" => "MySQL", "pgsql" => "PostgreSQL"];
|
||||
print_select_options($l, "db-driver", "SQL driver", $drivers, $_['db.driver']);
|
||||
print_text_input($l, "db-hostname", "Hostname", $_['db.hostname']);
|
||||
print_text_input($l, "db-database", "Database", $_['db.database']);
|
||||
print_text_input($l, "db-username", "Username", $_['db.username']);
|
||||
print_text_input($l, "db-password", "Password", $_['db.password']); ?>
|
||||
<div class="button-right">
|
||||
<input type="submit" id="user_sql-db_connection_verify" value="<?php p($l->t("Verify settings")); ?>">
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><?php p($l->t("Options")); ?></h2>
|
||||
<p class="settings-hint"><?php p($l->t("Here are all currently supported options.")); ?></p>
|
||||
<fieldset><?php
|
||||
print_checkbox_input($l, "opt-name_change", "Allow display name change", $_['opt.name_change']);
|
||||
print_checkbox_input($l, "opt-password_change", "Allow password change", $_['opt.password_change']); ?>
|
||||
<div class="button-right"><?php
|
||||
print_checkbox_input($l, "opt-use_cache", "Use cache", $_['opt.use_cache'], false); ?>
|
||||
<input type="submit" id="user_sql-clear_cache" value="<?php p($l->t("Clear cache")); ?>">
|
||||
</div>
|
||||
<?php
|
||||
$crypt_types = array();
|
||||
|
||||
require_once __DIR__ . "/../lib/HashAlgorithm/Base/Singleton.php";
|
||||
require_once __DIR__ . "/../lib/HashAlgorithm/Base/Utils.php";
|
||||
require_once __DIR__ . "/../lib/HashAlgorithm/Base/HashAlgorithm.php";
|
||||
require_once __DIR__ . "/../lib/HashAlgorithm/Base/BaseCrypt.php";
|
||||
require_once __DIR__ . "/../lib/HashAlgorithm/Base/SSHA.php";
|
||||
|
||||
foreach (glob(__DIR__ . "/../lib/HashAlgorithm/*.php") as $filename) {
|
||||
include_once "$filename";
|
||||
/**
|
||||
* @var $clazz \OCA\UserSQL\HashAlgorithm\Base\HashAlgorithm
|
||||
*/
|
||||
$clazz = call_user_func('OCA\\UserSQL\\HashAlgorithm\\' . basename(substr($filename, 0,
|
||||
-4)) . "::getInstance");
|
||||
$crypt_types[basename(substr($filename, 0, -4))] = $clazz->getVisibleName();
|
||||
$hashing = [];
|
||||
foreach (glob(__DIR__ . "/../lib/Crypto/*.php") as $filename) {
|
||||
$class = 'OCA\\UserSQL\\Crypto\\' . basename(substr($filename, 0, -4));
|
||||
try {
|
||||
$passwordAlgorithm = new $class($l);
|
||||
if ($passwordAlgorithm instanceof
|
||||
\OCA\UserSQL\Crypto\IPasswordAlgorithm
|
||||
) {
|
||||
$hashing[$class] = $passwordAlgorithm->getVisibleName();
|
||||
}
|
||||
?>
|
||||
<select id="set_crypt_type" name="set_crypt_type">
|
||||
} catch (Throwable $e) {
|
||||
}
|
||||
}
|
||||
|
||||
print_select_options($l, "opt-crypto_class", "Hashing algorithm", $hashing, $_['opt.crypto_class']);
|
||||
print_select_options($l, "opt-email_sync", "Email sync", ["" => "None", "initial" => "Synchronise only once", "force_nc"=>"Nextcloud always wins", "force_sql"=>"SQL always wins"], $_['opt.email_sync']);
|
||||
print_select_options($l, "opt-home_mode", "Home mode", ["" => "Default", "query" => "Query", "static" => "Static"], $_['opt.home_mode']);
|
||||
print_text_input($l, "opt-home_location", "Home Location", $_['opt.home_location']); ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="section clear-left">
|
||||
<h2><?php p($l->t("User table")); ?></h2>
|
||||
<p class="settings-hint"><?php p($l->t("Table containing user accounts.")); ?></p>
|
||||
<fieldset><?php
|
||||
print_text_input($l, "db-table-user", "Table name", $_['db.table.user']) ;?>
|
||||
<h3><?php p($l->t("Columns")); ?></h3>
|
||||
<?php
|
||||
foreach ($crypt_types as $driver => $name):
|
||||
//echo $_['set_crypt_type'];
|
||||
if ($_['set_crypt_type'] === $driver): ?>
|
||||
<option selected="selected" value="<?php p($driver); ?>"><?php p($name); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="<?php p($driver); ?>"><?php p($name); ?></option>
|
||||
<?php endif;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p><label for="col_active"><?php p($l->t('User Active Column')); ?></label><input type="text"
|
||||
id="col_active"
|
||||
name="col_active"
|
||||
value="<?php p($_['col_active']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="set_active_invert"><?php p($l->t('Invert Active Value')); ?></label><input
|
||||
type="checkbox" id="set_active_invert" name="set_active_invert" value="1"<?php
|
||||
if ($_['set_active_invert']) {
|
||||
p(' checked');
|
||||
}
|
||||
?> /><br>
|
||||
<em><?php p($l->t("Invert the logic of the active column (for blocked users in the SQL DB)")); ?></em>
|
||||
</p>
|
||||
|
||||
print_text_input($l, "db-table-user-column-uid", "Username", $_['db.table.user.column.uid']);
|
||||
print_text_input($l, "db-table-user-column-email", "Email", $_['db.table.user.column.email']);
|
||||
print_text_input($l, "db-table-user-column-home", "Home", $_['db.table.user.column.home']);
|
||||
print_text_input($l, "db-table-user-column-password", "Password", $_['db.table.user.column.password']);
|
||||
print_text_input($l, "db-table-user-column-name", "Username", $_['db.table.user.column.name']);
|
||||
print_text_input($l, "db-table-user-column-avatar", "Can change avatar", $_['db.table.user.column.avatar']); ?>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="sql-3">
|
||||
|
||||
<p><label for="col_email"><?php p($l->t('E-Mail Column')); ?></label><input type="text" id="col_email"
|
||||
name="col_email"
|
||||
value="<?php p($_['col_email']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="set_mail_sync_mode"><?php p($l->t('E-Mail address sync mode')); ?></label>
|
||||
<?php $mail_modes = array(
|
||||
'none' => 'No Synchronisation',
|
||||
'initial' => 'Synchronise only once',
|
||||
'forceoc' => 'Nextcloud always wins',
|
||||
'forcesql' => 'SQL always wins'
|
||||
); ?>
|
||||
<select id="set_mail_sync_mode" name="set_mail_sync_mode">
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><?php p($l->t("Group table")); ?></h2>
|
||||
<p class="settings-hint"><?php p($l->t("Group definitions table.")); ?></p>
|
||||
<fieldset><?php
|
||||
print_text_input($l, "db-table-group", "Table name", $_['db.table.group']); ?>
|
||||
<h3><?php p($l->t("Columns")); ?></h3>
|
||||
<?php
|
||||
foreach ($mail_modes as $mode => $name):
|
||||
//echo $_['set_mail_sync_mode'];
|
||||
if ($_['set_mail_sync_mode'] === $mode): ?>
|
||||
<option selected="selected" value="<?php p($mode); ?>"><?php p($name); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="<?php p($mode); ?>"><?php p($name); ?></option>
|
||||
<?php endif;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
print_text_input($l, "db-table-group-column-admin", "Is admin", $_['db.table.group.column.admin']);
|
||||
print_text_input($l, "db-table-group-column-name", "Display name", $_['db.table.group.column.name']);
|
||||
print_text_input($l, "db-table-group-column-gid", "Group name", $_['db.table.group.column.gid']); ?>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="sql-4">
|
||||
|
||||
<p><label for="set_default_domain"><?php p($l->t('Append Default Domain')); ?></label><input type="text"
|
||||
id="set_default_domain"
|
||||
,
|
||||
name="set_default_domain"
|
||||
value="<?php p($_['set_default_domain']); ?>"/><br>
|
||||
<em><?php p($l->t('Append this string, e.g. a domain name, to each user name. The @-sign is automatically inserted.')); ?></em>
|
||||
</p>
|
||||
|
||||
<p><label for="set_strip_domain"><?php p($l->t('Strip Domain Part from Username')); ?></label><input
|
||||
type="checkbox" id="set_strip_domain" name="set_strip_domain" value="1"<?php
|
||||
if ($_['set_strip_domain']) {
|
||||
p(' checked');
|
||||
}
|
||||
?> /><br>
|
||||
<em><?php p($l->t("Strip Domain Part including @-sign from Username when logging in and retrieving username lists")); ?></em>
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="sql-5">
|
||||
<p><label for="set_enable_gethome"><?php p($l->t('Enable support for getHome()')); ?></label><input
|
||||
type="checkbox" id="set_enable_gethome" , name="set_enable_gethome" value="1" <?php
|
||||
if ($_['set_enable_gethome']) {
|
||||
p(' checked');
|
||||
}
|
||||
?>/></p>
|
||||
|
||||
<p><label for="set_gethome_mode"><?php p($l->t('Method for getHome')); ?></label>
|
||||
<?php $gethome_modes = array('query' => 'SQL Column', 'static' => 'Static (with Variables)'); ?>
|
||||
<select id="set_gethome_mode" name="set_gethome_mode">
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2><?php p($l->t("User group table")); ?></h2>
|
||||
<p class="settings-hint"><?php p($l->t("Associative table which maps users to groups.")); ?></p>
|
||||
<fieldset><?php
|
||||
print_text_input($l, "db-table-user_group", "Table name", $_['db.table.user_group']); ?>
|
||||
<h3><?php p($l->t("Columns")); ?></h3>
|
||||
<?php
|
||||
foreach ($gethome_modes as $mode => $name):
|
||||
//echo $_['set_mail_sync_mode'];
|
||||
if ($_['set_gethome_mode'] === $mode): ?>
|
||||
<option selected="selected" value="<?php p($mode); ?>"><?php p($name); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="<?php p($mode); ?>"><?php p($name); ?></option>
|
||||
<?php endif;
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p><label for="col_gethome"><?php p($l->t('Home Column')); ?></label><input type="text" id="col_gethome"
|
||||
name="col_gethome"
|
||||
value="<?php p($_['col_gethome']); ?>">
|
||||
</p>
|
||||
|
||||
<p><label for="set_gethome"><?php p($l->t('Home Dir')); ?></label><input type="text" id="set_gethome"
|
||||
name="set_gethome"
|
||||
value="<?php p($_['set_gethome']); ?>"><br>
|
||||
<em><?php p($l->t('You can use the placeholders %%u to specify the user ID (before appending the default domain), %%ud to specify the user ID (after appending the default domain) and %%d to specify the default domain')); ?></em>
|
||||
</p>
|
||||
|
||||
print_text_input($l, "db-table-user_group-column-uid", "Username", $_['db.table.user_group.column.uid']);
|
||||
print_text_input($l, "db-table-user_group-column-gid", "Group name", $_['db.table.user_group.column.gid']); ?>
|
||||
</fieldset>
|
||||
<fieldset id="sql-6">
|
||||
<p><label for="sql_group_table"><?php p($l->t('Table')); ?></label><input type="text"
|
||||
id="sql_group_table"
|
||||
name="sql_group_table"
|
||||
value="<?php p($_['sql_group_table']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="col_group_username"><?php p($l->t('Username Column')); ?></label><input type="text"
|
||||
id="col_group_username"
|
||||
name="col_group_username"
|
||||
value="<?php p($_['col_group_username']); ?>"/>
|
||||
</p>
|
||||
|
||||
<p><label for="col_group_name"><?php p($l->t('Group Name Column')); ?></label><input type="text"
|
||||
id="col_group_name"
|
||||
name="col_group_name"
|
||||
value="<?php p($_['col_group_name']); ?>"/>
|
||||
</p>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" id="requesttoken"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<input type="hidden" name="appname" value="user_sql"/>
|
||||
<input id="sqlSubmit" type="submit" value="<?php p($l->t('Save')); ?>"/>
|
||||
<div id="sql_update_message" class="statusmessage"><?php p($l->t('Saving...')); ?></div>
|
||||
<div id="sql_loading_message" class="statusmessage"><?php p($l->t('Loading...')); ?></div>
|
||||
<div id="sql_verify_message" class="statusmessage"><?php p($l->t('Verifying...')); ?></div>
|
||||
<div id="sql_error_message" class="errormessage"></div>
|
||||
<div id="sql_success_message" class="successmessage"></div>
|
||||
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" id="requesttoken"/>
|
||||
<input id="user_sql-save" type="submit" value="<?php p($l->t('Save')); ?>"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user