diff --git a/ajax/settings.php b/ajax/settings.php new file mode 100644 index 0000000..08adf92 --- /dev/null +++ b/ajax/settings.php @@ -0,0 +1,39 @@ + array( "message" => $l->t("Not submitted for us.") ))); + return false; +} + +OCP\JSON::success(array('data' => array( 'message' => $l->t('Application settings successfully stored.') ))); +return true; diff --git a/css/settings.css b/css/settings.css new file mode 100644 index 0000000..9c45085 --- /dev/null +++ b/css/settings.css @@ -0,0 +1,14 @@ +.statusmessage { + background-color: #DDDDFF; +} +.errormessage { + background-color: #FFDDDD; +} +.successmessage { + background-color: #DDFFDD; +} +.statusmessage,.errormessage,.successmessage{ + display:none; + padding: 1; +} + diff --git a/js/settings.js b/js/settings.js index 8337712..ad8d982 100644 --- a/js/settings.js +++ b/js/settings.js @@ -1 +1,45 @@ -// +// declare namespace +var user_sql = user_sql || {}; + +/** + * init admin settings view + */ +user_sql.adminSettingsUI = function() { + + if ($('#sql').length > 0) { + // enable tabs on settings page + $('#sql').tabs(); + + $('#sqlSubmit').click(function(event) { + event.preventDefault(); + + var self = $(this); + var post = $('#sqlForm').serialize(); + $('#sql_update_message').show(); + $('#sql_success_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(); + }, 10000); + } else { + $('#sql_error_message').html(data.data.message); + $('#sql_error_message').show(); + } + }, 'json'); + return false; + }); + } +} + +$(document).ready(function() { + if ($('#sql')) { + user_sql.adminSettingsUI(); + } +}); + diff --git a/settings.php b/settings.php index 9c500ab..c140ad9 100644 --- a/settings.php +++ b/settings.php @@ -20,11 +20,16 @@ * License along with this library. If not, see . * */ -$params = array('sql_host', 'sql_user', 'sql_database', 'sql_password', 'sql_table', 'sql_column_username', 'sql_column_password', 'sql_type', 'sql_column_active', 'strip_domain', 'default_domain', 'crypt_type', 'sql_column_displayname'); +$params = array('sql_host', 'sql_user', 'sql_database', 'sql_password', + 'sql_table', 'sql_column_username', 'sql_column_password', + 'sql_type', 'sql_column_active', 'strip_domain', 'default_domain', + 'crypt_type', 'sql_column_displayname'); -OCP\Util::addscript('user_sql', 'settings'); +OCP\Util::addStyle('user_sql', 'settings'); +OCP\Util::addScript('user_sql', 'settings'); OCP\User::checkAdminUser(); +/* if ($_POST) { OCP\JSON::callCheck(); foreach($params as $param){ @@ -38,6 +43,7 @@ if ($_POST) { } } } +*/ // fill template $tmpl = new OCP\Template( 'user_sql', 'settings'); @@ -61,4 +67,9 @@ $tmpl->assign( 'default_domain', OCP\Config::getAppValue( 'user_sql', 'default_d $tmpl->assign( 'crypt_type', OCP\Config::getAppValue( 'user_sql', 'crypt_type', 'mysql_encrypt')); $tmpl->assign( 'sql_column_displayname', OCP\Config::getAppValue( 'user_sql', 'sql_column_displayname', '')); +// workaround to detect OC version +$ocVersion = @reset(OCP\Util::getVersion()); +$tmpl->assign('ocVersion', $ocVersion); + + return $tmpl->fetchPage(); diff --git a/templates/settings.php b/templates/settings.php index b0e6790..9e0c1d1 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,9 +1,24 @@ -
-
- t('SQL'); ?> -

+= 7 ? 'section' : 'personalblock'; + +?> + + + + +

+ t('SQL'); ?> + + +
+ + 'MySQL', 'pgsql' => 'PostgreSQL');?> - + -

-

-

-

-

-

-

-

-

+

+ + + + +
-

+
+
+
+ + + + + 'MD5', 'md5crypt' => 'MD5 Crypt', 'cleartext' => 'Cleartext', 'mysql_encrypt' => 'mySQL ENCRYPT()', 'system' => 'System (crypt)', 'mysql_password' => 'mySQL PASSWORD()', 'joomla' => 'Joomla MD5 Encryption');?> - + + + + +
-

-

-

title="Strip Domain Part from Username when logging in and retrieving username lists">

-

+
title="Strip Domain Part from Username when logging in and retrieving username lists">
+
- -
+ + +
t('Saving...'); ?>
+
+
+