mirror of
https://github.com/moparisthebest/user_sql
synced 2024-11-21 08:45:02 -05:00
Add support for getHome()
This commit is contained in:
parent
b6034665c1
commit
98e164b27a
@ -78,6 +78,10 @@ if(isset($_POST['appname']) && ($_POST['appname'] === 'user_sql') && isset($_POS
|
|||||||
{
|
{
|
||||||
\OC::$server->getConfig()->setAppValue('user_sql', 'set_active_invert_'.$domain, 'true');
|
\OC::$server->getConfig()->setAppValue('user_sql', 'set_active_invert_'.$domain, 'true');
|
||||||
}
|
}
|
||||||
|
elseif($param === 'set_enable_gethome')
|
||||||
|
{
|
||||||
|
\OC::$server->getConfig()->setAppValue('user_sql', 'set_enable_gethome_'.$domain, 'true');
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
\OC::$server->getConfig()->setAppValue('user_sql', $param.'_'.$domain, $_POST[$param]);
|
\OC::$server->getConfig()->setAppValue('user_sql', $param.'_'.$domain, $_POST[$param]);
|
||||||
@ -96,6 +100,10 @@ if(isset($_POST['appname']) && ($_POST['appname'] === 'user_sql') && isset($_POS
|
|||||||
{
|
{
|
||||||
\OC::$server->getConfig()->setAppValue('user_sql', 'set_active_invert_'.$domain, 'false');
|
\OC::$server->getConfig()->setAppValue('user_sql', 'set_active_invert_'.$domain, 'false');
|
||||||
}
|
}
|
||||||
|
elseif($param === 'set_enable_gethome')
|
||||||
|
{
|
||||||
|
\OC::$server->getConfig()->setAppValue('user_sql', 'set_enable_gethome_'.$domain, 'false');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$response->setData(array('status' => 'success',
|
$response->setData(array('status' => 'success',
|
||||||
|
@ -30,13 +30,3 @@ $backend = new \OCA\user_sql\OC_USER_SQL;
|
|||||||
// register user backend
|
// register user backend
|
||||||
OC_User::registerBackend($backend);
|
OC_User::registerBackend($backend);
|
||||||
OC_User::useBackend($backend);
|
OC_User::useBackend($backend);
|
||||||
|
|
||||||
// add settings page to navigation
|
|
||||||
$entry = array(
|
|
||||||
'id' => "user_sql_settings",
|
|
||||||
'order'=>1,
|
|
||||||
'href' => OC_Helper::linkTo( "user_sql", "settings.php" ),
|
|
||||||
'name' => 'SQL'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Andreas Boehler <dev (at) aboehler
|
<author>Andreas Boehler <dev (at) aboehler
|
||||||
(dot) at ></author>
|
(dot) at ></author>
|
||||||
<version>2.0</version>
|
<version>2.1</version>
|
||||||
<requiremin>8.1</requiremin>
|
<requiremin>8.1</requiremin>
|
||||||
<shipped>false</shipped>
|
<shipped>false</shipped>
|
||||||
<namespace>user_sql</namespace>
|
<namespace>user_sql</namespace>
|
||||||
|
@ -12,3 +12,13 @@
|
|||||||
padding: 1px;
|
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 {
|
||||||
|
display: inline-block;
|
||||||
|
text-align: right;
|
||||||
|
width: 300px;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
@ -17,7 +17,7 @@ user_sql.adminSettingsUI = function()
|
|||||||
$('#sql').tabs();
|
$('#sql').tabs();
|
||||||
|
|
||||||
// Attach auto-completion to all column fields
|
// Attach auto-completion to all column fields
|
||||||
$('#col_username, #col_password, #col_displayname, #col_active, #col_email').autocomplete({
|
$('#col_username, #col_password, #col_displayname, #col_active, #col_email, #col_gethome').autocomplete({
|
||||||
source: function(request, response)
|
source: function(request, response)
|
||||||
{
|
{
|
||||||
var post = $('#sqlForm').serializeArray();
|
var post = $('#sqlForm').serializeArray();
|
||||||
@ -184,6 +184,45 @@ user_sql.adminSettingsUI = function()
|
|||||||
$('#sql_domain_chooser').change(function() {
|
$('#sql_domain_chooser').change(function() {
|
||||||
user_sql.loadDomainSettings($('#sql_domain_chooser option:selected').val());
|
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);
|
||||||
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -239,6 +278,13 @@ user_sql.loadDomainSettings = function(domain)
|
|||||||
else
|
else
|
||||||
$('#' + key).prop('checked', false);
|
$('#' + key).prop('checked', false);
|
||||||
}
|
}
|
||||||
|
else if(key == 'set_allow_gethome')
|
||||||
|
{
|
||||||
|
if(data.settings[key] == 'true')
|
||||||
|
$('#' + key).prop('checked', true);
|
||||||
|
else
|
||||||
|
$('#' + key).prop('checked', false);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$('#' + key).val(data.settings[key]);
|
$('#' + key).val(data.settings[key]);
|
||||||
@ -261,6 +307,7 @@ $(document).ready(function()
|
|||||||
{
|
{
|
||||||
user_sql.adminSettingsUI();
|
user_sql.adminSettingsUI();
|
||||||
user_sql.loadDomainSettings($('#sql_domain_chooser option:selected').val());
|
user_sql.loadDomainSettings($('#sql_domain_chooser option:selected').val());
|
||||||
|
user_sql.setGethomeMode();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -55,12 +55,16 @@ class Helper {
|
|||||||
'col_active',
|
'col_active',
|
||||||
'col_displayname',
|
'col_displayname',
|
||||||
'col_email',
|
'col_email',
|
||||||
|
'col_gethome',
|
||||||
'set_active_invert',
|
'set_active_invert',
|
||||||
'set_allow_pwchange',
|
'set_allow_pwchange',
|
||||||
'set_default_domain',
|
'set_default_domain',
|
||||||
'set_strip_domain',
|
'set_strip_domain',
|
||||||
'set_crypt_type',
|
'set_crypt_type',
|
||||||
'set_mail_sync_mode'
|
'set_mail_sync_mode',
|
||||||
|
'set_enable_gethome',
|
||||||
|
'set_gethome_mode',
|
||||||
|
'set_gethome'
|
||||||
);
|
);
|
||||||
|
|
||||||
return $params;
|
return $params;
|
||||||
@ -107,6 +111,9 @@ class Helper {
|
|||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
|
case 'getHome':
|
||||||
|
$query = "SELECT ".$this->settings['col_gethome']." FROM ".$this->settings['sql_table']." WHERE ".$this->settings['col_username']." = :uid";
|
||||||
|
break;
|
||||||
case 'getMail':
|
case 'getMail':
|
||||||
$query = "SELECT ".$this->settings['col_email']." FROM ".$this->settings['sql_table']." WHERE ".$this->settings['col_username']." = :uid";
|
$query = "SELECT ".$this->settings['col_email']." FROM ".$this->settings['sql_table']." WHERE ".$this->settings['col_username']." = :uid";
|
||||||
break;
|
break;
|
||||||
|
@ -16,14 +16,16 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
|
|||||||
</select>
|
</select>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a id="sqlBasicSettings" href="#sql-1"><?php p($l -> t('Connection Settings')); ?></a></li>
|
<li><a id="sqlBasicSettings" href="#sql-1"><?php p($l -> t('Connection Settings')); ?></a></li>
|
||||||
<li><a id="sqlAdvSettings" href="#sql-2"><?php p($l -> t('Advanced 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>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<fieldset id="sql-1">
|
<fieldset id="sql-1">
|
||||||
<table>
|
<p><label for="sql_driver"><?php p($l -> t('SQL Driver')); ?></label>
|
||||||
<tr><td><label for="sql_driver"><?php p($l -> t('SQL Driver')); ?></label></td>
|
|
||||||
<?php $db_driver = array('mysql' => 'MySQL', 'pgsql' => 'PostgreSQL'); ?>
|
<?php $db_driver = array('mysql' => 'MySQL', 'pgsql' => 'PostgreSQL'); ?>
|
||||||
<td><select id="sql_driver" name="sql_driver">
|
<select id="sql_driver" name="sql_driver">
|
||||||
<?php
|
<?php
|
||||||
foreach ($db_driver as $driver => $name):
|
foreach ($db_driver as $driver => $name):
|
||||||
//echo $_['sql_driver'];
|
//echo $_['sql_driver'];
|
||||||
@ -34,29 +36,38 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
|
|||||||
<?php endif;
|
<?php endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</select></td>
|
</select>
|
||||||
</tr>
|
</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_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_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_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>
|
||||||
|
|
||||||
<tr><td><label for="sql_hostname"><?php p($l -> t('Host')); ?></label></td><td><input type="text" id="sql_hostname" name="sql_hostname" value="<?php p($_['sql_hostname']); ?>"></td></tr>
|
|
||||||
<tr><td><label for="sql_username"><?php p($l -> t('Username')); ?></label></td><td><input type="text" id="sql_username" name="sql_username" value="<?php p($_['sql_username']); ?>" /></td></tr>
|
|
||||||
<tr><td><label for="sql_database"><?php p($l -> t('Database')); ?></label></td><td><input type="text" id="sql_database" name="sql_database" value="<?php p($_['sql_database']); ?>" /></td></tr>
|
|
||||||
<tr><td><label for="sql_password"><?php p($l -> t('Password')); ?></label></td><td><input type="password" id="sql_password" name="sql_password" value="<?php p($_['sql_password']); ?>" /></td></tr>
|
|
||||||
<tr><td></td><td><input type="submit" id="sqlVerify" value="<?php p($l -> t('Verify Settings')); ?>"></td></tr>
|
|
||||||
</table>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset id="sql-2">
|
<fieldset id="sql-2">
|
||||||
<table>
|
<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>
|
||||||
<tr><td><label for="sql_table"><?php p($l -> t('Table')); ?></label></td><td><input type="text" id="sql_table" name="sql_table" value="<?php p($_['sql_table']); ?>" /></td></tr>
|
|
||||||
<tr><td><label for="col_username"><?php p($l -> t('Username Column')); ?></label></td><td><input type="text" id="col_username" name="col_username" value="<?php p($_['col_username']); ?>" /></td></tr>
|
<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>
|
||||||
<tr><td><label for="col_password"><?php p($l -> t('Password Column')); ?></label></td><td><input type="text" id="col_password" name="col_password" value="<?php p($_['col_password']); ?>" /></td></tr>
|
|
||||||
<tr><td><label for="set_allow_pwchange"><?php p($l -> t('Allow password changing (read README!)')); ?></label></td><td><input type="checkbox" id="set_allow_pwchange" name="set_allow_pwchange" value="1"<?php
|
<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>
|
||||||
|
|
||||||
|
<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'])
|
if($_['set_allow_pwchange'])
|
||||||
p(' checked');
|
p(' checked');
|
||||||
?> title="Allow changing passwords. Imposes a security risk as password salts are not recreated"></td></tr>
|
?>><br>
|
||||||
<tr><td><label for="col_displayname"><?php p($l -> t('Real Name Column')); ?></label></td><td><input type="text" id="col_displayname" name="col_displayname" value="<?php p($_['col_displayname']); ?>" /></td></tr>
|
<em><?php p($l -> t('Allow changing passwords. Imposes a security risk as password salts are not recreated')); ?></em></p>
|
||||||
<tr><td><label for="set_crypt_type"><?php p($l -> t('Encryption Type')); ?></label></td>
|
|
||||||
|
<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>
|
||||||
<?php $crypt_types = array('md5' => 'MD5', 'md5crypt' => 'MD5 Crypt', 'cleartext' => 'Cleartext', 'mysql_encrypt' => 'mySQL ENCRYPT()', 'system' => 'System (crypt)', 'mysql_password' => 'mySQL PASSWORD()', 'joomla' => 'Joomla MD5 Encryption', 'joomla2' => 'Joomla > 2.5.18 phpass', 'ssha256' => 'Salted SSHA256', 'redmine' => 'Redmine'); ?>
|
<?php $crypt_types = array('md5' => 'MD5', 'md5crypt' => 'MD5 Crypt', 'cleartext' => 'Cleartext', 'mysql_encrypt' => 'mySQL ENCRYPT()', 'system' => 'System (crypt)', 'mysql_password' => 'mySQL PASSWORD()', 'joomla' => 'Joomla MD5 Encryption', 'joomla2' => 'Joomla > 2.5.18 phpass', 'ssha256' => 'Salted SSHA256', 'redmine' => 'Redmine'); ?>
|
||||||
<td><select id="set_crypt_type" name="set_crypt_type">
|
<select id="set_crypt_type" name="set_crypt_type">
|
||||||
<?php
|
<?php
|
||||||
foreach ($crypt_types as $driver => $name):
|
foreach ($crypt_types as $driver => $name):
|
||||||
//echo $_['set_crypt_type'];
|
//echo $_['set_crypt_type'];
|
||||||
@ -67,17 +78,26 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
|
|||||||
<?php endif;
|
<?php endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</select></td>
|
</select>
|
||||||
</tr>
|
</p>
|
||||||
<tr><td><label for="col_active"><?php p($l -> t('User Active Column')); ?></label></td><td><input type="text" id="col_active" name="col_active" value="<?php p($_['col_active']); ?>" /></td></tr>
|
|
||||||
<tr><td><label for="set_active_invert"><?php p($l -> t('Invert Active Value')); ?></label></td><td><input type="checkbox" id="set_active_invert" name="set_active_invert" value="1"<?php
|
<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'])
|
if($_['set_active_invert'])
|
||||||
p(' checked');
|
p(' checked');
|
||||||
?> title="Invert the logic of the active column (for blocked users in the SQL DB)" /></td></tr>
|
?> /><br>
|
||||||
<tr><td><label for="col_email"><?php p($l -> t('E-Mail Column')); ?></label></td><td><input type="text" id="col_email" name="col_email" value="<?php p($_['col_email']); ?>" /></td></tr>
|
<em><?php p($l -> t("Invert the logic of the active column (for blocked users in the SQL DB)")); ?></em></p>
|
||||||
<tr><td><label for="set_mail_sync_mode"><?php p($l -> t('E-Mail address sync mode')); ?></label></td>
|
|
||||||
|
</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' => 'ownCloud always wins', 'forcesql' => 'SQL always wins'); ?>
|
<?php $mail_modes = array('none' => 'No Synchronisation', 'initial' => 'Synchronise only once', 'forceoc' => 'ownCloud always wins', 'forcesql' => 'SQL always wins'); ?>
|
||||||
<td><select id="set_mail_sync_mode" name="set_mail_sync_mode">
|
<select id="set_mail_sync_mode" name="set_mail_sync_mode">
|
||||||
<?php
|
<?php
|
||||||
foreach ($mail_modes as $mode => $name):
|
foreach ($mail_modes as $mode => $name):
|
||||||
//echo $_['set_mail_sync_mode'];
|
//echo $_['set_mail_sync_mode'];
|
||||||
@ -89,13 +109,51 @@ $cfgClass = $ocVersion >= 7 ? 'section' : 'personalblock';
|
|||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</td></tr>
|
</p>
|
||||||
<tr><td><label for="set_default_domain"><?php p($l -> t('Append Default Domain')); ?></label></td><td><input type="text" id="set_default_domain", name="set_default_domain" value="<?php p($_['set_default_domain']); ?>" /></td></tr>
|
|
||||||
<tr><td><label for="set_strip_domain"><?php p($l -> t('Strip Domain Part from Username')); ?></label></td><td><input type="checkbox" id="set_strip_domain" name="set_strip_domain" value="1"<?php
|
</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'])
|
if($_['set_strip_domain'])
|
||||||
p(' checked');
|
p(' checked');
|
||||||
?> title="Strip Domain Part from Username when logging in and retrieving username lists"></td></tr>
|
?> /><br>
|
||||||
</table>
|
<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">
|
||||||
|
<?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>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" id="requesttoken" />
|
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']); ?>" id="requesttoken" />
|
||||||
<input type="hidden" name="appname" value="user_sql" />
|
<input type="hidden" name="appname" value="user_sql" />
|
||||||
|
42
user_sql.php
42
user_sql.php
@ -149,6 +149,8 @@ class OC_USER_SQL extends \OC_User_Backend implements \OCP\IUserBackend, \OCP\Us
|
|||||||
return (bool)((\OC_User_Backend::CHECK_PASSWORD
|
return (bool)((\OC_User_Backend::CHECK_PASSWORD
|
||||||
| \OC_User_Backend::GET_DISPLAYNAME
|
| \OC_User_Backend::GET_DISPLAYNAME
|
||||||
| \OC_User_Backend::COUNT_USERS
|
| \OC_User_Backend::COUNT_USERS
|
||||||
|
| $this -> settings['set_allow_pwchange'] === 'true' ? \OC_User_Backend::SET_PASSWORD : 0
|
||||||
|
| $this -> settings['set_enable_gethome'] === 'true' ? \OC_User_Backend::GET_HOME : 0
|
||||||
) & $actions);
|
) & $actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +163,46 @@ class OC_USER_SQL extends \OC_User_Backend implements \OCP\IUserBackend, \OCP\Us
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the user's home directory, if enabled
|
||||||
|
* @param string $uid The user's ID to retrieve
|
||||||
|
* @return mixed The user's home directory or false
|
||||||
|
*/
|
||||||
|
public function getHome($uid)
|
||||||
|
{
|
||||||
|
\OCP\Util::writeLog('OC_USER_SQL', "Entering getHome for UID: $uid", \OCP\Util::DEBUG);
|
||||||
|
|
||||||
|
if($this -> settings['set_enable_gethome'] !== 'true')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$uidMapped = $this -> doUserDomainMapping($uid);
|
||||||
|
$home = false;
|
||||||
|
|
||||||
|
switch($this->settings['set_gethome_mode'])
|
||||||
|
{
|
||||||
|
case 'query':
|
||||||
|
\OCP\Util::writeLog('OC_USER_SQL', "getHome with Query selected, running Query...", \OCP\Util::DEBUG);
|
||||||
|
$row = $this -> helper -> runQuery('getHome', array('uid' => $uidMapped));
|
||||||
|
if($row === false)
|
||||||
|
{
|
||||||
|
\OCP\Util::writeLog('OC_USER_SQL', "Got no row, return false", \OCP\Util::DEBUG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$home = $row[$this -> settings['col_gethome']];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'static':
|
||||||
|
\OCP\Util::writeLog('OC_USER_SQL', "getHome with static selected", \OCP\Util::DEBUG);
|
||||||
|
$home = $this -> settings['set_gethome'];
|
||||||
|
$home = str_replace('%ud', $uidMapped, $home);
|
||||||
|
$home = str_replace('%u', $uid, $home);
|
||||||
|
$home = str_replace('%d', $this -> settings['set_default_domain'], $home);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
\OCP\Util::writeLog('OC_USER_SQL', "Returning getHome for UID: $uid with Home $home", \OCP\Util::DEBUG);
|
||||||
|
return $home;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new user account using this backend
|
* Create a new user account using this backend
|
||||||
* @return bool always false, as we can't create users
|
* @return bool always false, as we can't create users
|
||||||
|
Loading…
Reference in New Issue
Block a user