Skip to content

Commit bb8e05b

Browse files
committed
Options to enable execute DMLs on tables
1 parent 3546682 commit bb8e05b

2 files changed

Lines changed: 39 additions & 33 deletions

File tree

lib/Constant/Opt.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ final class Opt
3232
const EMAIL_SYNC = "opt.email_sync";
3333
const HOME_LOCATION = "opt.home_location";
3434
const HOME_MODE = "opt.home_mode";
35+
const MODIFY_GROUP = "opt.modify_group";
36+
const MODIFY_USER = "opt.modify_user";
37+
const MODIFY_USER_GROUP = "opt.modify_user_group";
3538
const NAME_CHANGE = "opt.name_change";
3639
const PASSWORD_CHANGE = "opt.password_change";
3740
const USE_CACHE = "opt.use_cache";

templates/admin.php

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
use OCP\IL10N;
2323

24-
script('user_sql', 'settings');
25-
style('user_sql', 'settings');
24+
script("user_sql", "settings");
25+
style("user_sql", "settings");
2626

2727
function print_text_input(IL10N $l, $id, $label, $value = "", $type = "text")
2828
{
@@ -94,11 +94,11 @@ function print_select_options(
9494
<p class="settings-hint"><?php p($l->t("Define your database connection parameters.")); ?></p>
9595
<fieldset><?php
9696
$drivers = ["mysql" => "MySQL", "pgsql" => "PostgreSQL"];
97-
print_select_options($l, "db-driver", "SQL driver", $drivers, $_['db.driver']);
98-
print_text_input($l, "db-hostname", "Hostname", $_['db.hostname']);
99-
print_text_input($l, "db-database", "Database", $_['db.database']);
100-
print_text_input($l, "db-username", "Username", $_['db.username']);
101-
print_text_input($l, "db-password", "Password", $_['db.password'], "password"); ?>
97+
print_select_options($l, "db-driver", "SQL driver", $drivers, $_["db.driver"]);
98+
print_text_input($l, "db-hostname", "Hostname", $_["db.hostname"]);
99+
print_text_input($l, "db-database", "Database", $_["db.database"]);
100+
print_text_input($l, "db-username", "Username", $_["db.username"]);
101+
print_text_input($l, "db-password", "Password", $_["db.password"], "password"); ?>
102102
<div class="button-right">
103103
<input type="submit" id="user_sql-db_connection_verify" value="<?php p($l->t("Verify settings")); ?>">
104104
</div>
@@ -108,16 +108,16 @@ function print_select_options(
108108
<h2><?php p($l->t("Options")); ?></h2>
109109
<p class="settings-hint"><?php p($l->t("Here are all currently supported options.")); ?></p>
110110
<fieldset><?php
111-
print_checkbox_input($l, "opt-name_change", "Allow display name change", $_['opt.name_change']);
112-
print_checkbox_input($l, "opt-password_change", "Allow password change", $_['opt.password_change']); ?>
111+
print_checkbox_input($l, "opt-name_change", "Allow display name change", $_["opt.name_change"]);
112+
print_checkbox_input($l, "opt-password_change", "Allow password change", $_["opt.password_change"]); ?>
113113
<div class="button-right"><?php
114-
print_checkbox_input($l, "opt-use_cache", "Use cache", $_['opt.use_cache'], false); ?>
114+
print_checkbox_input($l, "opt-use_cache", "Use cache", $_["opt.use_cache"], false); ?>
115115
<input type="submit" id="user_sql-clear_cache" value="<?php p($l->t("Clear cache")); ?>">
116116
</div>
117117
<?php
118118
$hashing = [];
119119
foreach (glob(__DIR__ . "/../lib/Crypto/*.php") as $filename) {
120-
$class = 'OCA\\UserSQL\\Crypto\\' . basename(substr($filename, 0, -4));
120+
$class = "OCA\\UserSQL\\Crypto\\" . basename(substr($filename, 0, -4));
121121
try {
122122
$passwordAlgorithm = new $class($l);
123123
if ($passwordAlgorithm instanceof
@@ -129,56 +129,59 @@ function print_select_options(
129129
}
130130
}
131131

132-
print_select_options($l, "opt-crypto_class", "Hashing algorithm", $hashing, $_['opt.crypto_class']);
133-
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']);
134-
print_select_options($l, "opt-home_mode", "Home mode", ["" => "Default", "query" => "Query", "static" => "Static"], $_['opt.home_mode']);
135-
print_text_input($l, "opt-home_location", "Home Location", $_['opt.home_location']); ?>
132+
print_select_options($l, "opt-crypto_class", "Hashing algorithm", $hashing, $_["opt.crypto_class"]);
133+
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"]);
134+
print_select_options($l, "opt-home_mode", "Home mode", ["" => "Default", "query" => "Query", "static" => "Static"], $_["opt.home_mode"]);
135+
print_text_input($l, "opt-home_location", "Home Location", $_["opt.home_location"]); ?>
136136
</fieldset>
137137
</div>
138138
<div class="section clear-left">
139139
<h2><?php p($l->t("User table")); ?></h2>
140140
<p class="settings-hint"><?php p($l->t("Table containing user accounts.")); ?></p>
141141
<fieldset><?php
142-
print_text_input($l, "db-table-user", "Table name", $_['db.table.user']) ;?>
142+
print_text_input($l, "db-table-user", "Table name", $_["db.table.user"]);
143+
print_checkbox_input($l, "opt-modify_user", "Allow DML statements on table", $_["opt.modify_user"]); ?>
143144
<h3><?php p($l->t("Columns")); ?></h3>
144145
<?php
145-
print_text_input($l, "db-table-user-column-uid", "Username", $_['db.table.user.column.uid']);
146-
print_text_input($l, "db-table-user-column-email", "Email", $_['db.table.user.column.email']);
147-
print_text_input($l, "db-table-user-column-home", "Home", $_['db.table.user.column.home']);
148-
print_text_input($l, "db-table-user-column-password", "Password", $_['db.table.user.column.password']);
149-
print_text_input($l, "db-table-user-column-name", "Display name", $_['db.table.user.column.name']);
150-
print_text_input($l, "db-table-user-column-active", "Active", $_['db.table.user.column.active']);
151-
print_text_input($l, "db-table-user-column-avatar", "Can change avatar", $_['db.table.user.column.avatar']);
152-
print_text_input($l, "db-table-user-column-salt", "Salt", $_['db.table.user.column.salt']); ?>
146+
print_text_input($l, "db-table-user-column-uid", "Username", $_["db.table.user.column.uid"]);
147+
print_text_input($l, "db-table-user-column-email", "Email", $_["db.table.user.column.email"]);
148+
print_text_input($l, "db-table-user-column-home", "Home", $_["db.table.user.column.home"]);
149+
print_text_input($l, "db-table-user-column-password", "Password", $_["db.table.user.column.password"]);
150+
print_text_input($l, "db-table-user-column-name", "Display name", $_["db.table.user.column.name"]);
151+
print_text_input($l, "db-table-user-column-active", "Active", $_["db.table.user.column.active"]);
152+
print_text_input($l, "db-table-user-column-avatar", "Can change avatar", $_["db.table.user.column.avatar"]);
153+
print_text_input($l, "db-table-user-column-salt", "Salt", $_["db.table.user.column.salt"]); ?>
153154
</fieldset>
154155
</div>
155156
<div class="section">
156157
<h2><?php p($l->t("Group table")); ?></h2>
157158
<p class="settings-hint"><?php p($l->t("Group definitions table.")); ?></p>
158159
<fieldset><?php
159-
print_text_input($l, "db-table-group", "Table name", $_['db.table.group']); ?>
160+
print_text_input($l, "db-table-group", "Table name", $_["db.table.group"]);
161+
print_checkbox_input($l, "opt-modify_group", "Allow DML statements on table", $_["opt.modify_group"]); ?>
160162
<h3><?php p($l->t("Columns")); ?></h3>
161163
<?php
162-
print_text_input($l, "db-table-group-column-admin", "Is admin", $_['db.table.group.column.admin']);
163-
print_text_input($l, "db-table-group-column-name", "Display name", $_['db.table.group.column.name']);
164-
print_text_input($l, "db-table-group-column-gid", "Group name", $_['db.table.group.column.gid']); ?>
164+
print_text_input($l, "db-table-group-column-admin", "Is admin", $_["db.table.group.column.admin"]);
165+
print_text_input($l, "db-table-group-column-name", "Display name", $_["db.table.group.column.name"]);
166+
print_text_input($l, "db-table-group-column-gid", "Group name", $_["db.table.group.column.gid"]); ?>
165167
</fieldset>
166168
</div>
167169
<div class="section">
168170
<h2><?php p($l->t("User group table")); ?></h2>
169171
<p class="settings-hint"><?php p($l->t("Associative table which maps users to groups.")); ?></p>
170172
<fieldset><?php
171-
print_text_input($l, "db-table-user_group", "Table name", $_['db.table.user_group']); ?>
173+
print_text_input($l, "db-table-user_group", "Table name", $_["db.table.user_group"]);
174+
print_checkbox_input($l, "opt-modify_user_group", "Allow DML statements on table", $_["opt.modify_user_group"]); ?>
172175
<h3><?php p($l->t("Columns")); ?></h3>
173176
<?php
174-
print_text_input($l, "db-table-user_group-column-uid", "Username", $_['db.table.user_group.column.uid']);
175-
print_text_input($l, "db-table-user_group-column-gid", "Group name", $_['db.table.user_group.column.gid']); ?>
177+
print_text_input($l, "db-table-user_group-column-uid", "Username", $_["db.table.user_group.column.uid"]);
178+
print_text_input($l, "db-table-user_group-column-gid", "Group name", $_["db.table.user_group.column.gid"]); ?>
176179
</fieldset>
177180
</div>
178181
</div>
179182
<div class="section">
180183
<input type="hidden" name="appname" value="user_sql"/>
181-
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" id="requesttoken"/>
182-
<input id="user_sql-save" type="submit" value="<?php p($l->t('Save')); ?>"/>
184+
<input type="hidden" name="requesttoken" value="<?php p($_["requesttoken"]); ?>" id="requesttoken"/>
185+
<input id="user_sql-save" type="submit" value="<?php p($l->t("Save")); ?>"/>
183186
</div>
184187
</form>

0 commit comments

Comments
 (0)