summaryrefslogtreecommitdiffstats
path: root/hosted
diff options
context:
space:
mode:
authorTorsten Grote <grote@kolabsys.com>2012-07-03 15:06:54 +0200
committerTorsten Grote <grote@kolabsys.com>2012-07-03 15:06:54 +0200
commitfaa9766c57200518071e7977959f07d00487dee3 (patch)
treea726d36059a16ac5781a09c01cc5002df56d05f1 /hosted
parent299f8175e9c3b8f8c1091bada1e7293ddb126a70 (diff)
downloadwebadmin-faa9766c57200518071e7977959f07d00487dee3.tar.gz
added js based checking of user alias availability
Diffstat (limited to 'hosted')
l---------hosted/js1
l---------hosted/js/jquery.min.js1
l---------hosted/js/kolab_admin.js1
-rw-r--r--hosted/js/kolab_hosted.js67
4 files changed, 69 insertions, 1 deletions
diff --git a/hosted/js b/hosted/js
deleted file mode 120000
index 0723f3a..0000000
--- a/hosted/js
+++ /dev/null
@@ -1 +0,0 @@
-../public_html/js/ \ No newline at end of file
diff --git a/hosted/js/jquery.min.js b/hosted/js/jquery.min.js
new file mode 120000
index 0000000..c3b1873
--- /dev/null
+++ b/hosted/js/jquery.min.js
@@ -0,0 +1 @@
+../../public_html/js/jquery.min.js \ No newline at end of file
diff --git a/hosted/js/kolab_admin.js b/hosted/js/kolab_admin.js
new file mode 120000
index 0000000..ea11949
--- /dev/null
+++ b/hosted/js/kolab_admin.js
@@ -0,0 +1 @@
+../../public_html/js/kolab_admin.js \ No newline at end of file
diff --git a/hosted/js/kolab_hosted.js b/hosted/js/kolab_hosted.js
new file mode 100644
index 0000000..5d98c13
--- /dev/null
+++ b/hosted/js/kolab_hosted.js
@@ -0,0 +1,67 @@
+/*
+ +--------------------------------------------------------------------------+
+ | This file is part of the Kolab Web Admin Panel |
+ | |
+ | Copyright (C) 2011-2012, Kolab Systems AG |
+ | |
+ | 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 kadm program. If not, see <http://www.gnu.org/licenses/> |
+ +--------------------------------------------------------------------------+
+ | Author: Torsten Grote <grote@kolabsys.com> |
+ +--------------------------------------------------------------------------+
+*/
+
+kadm.check_user_availability = function(userid)
+{
+ // get form data and build new email address
+ data = kadm.serialize_form('#signup-form');
+ uid = data['alias'] + '@' + data['domain'];
+
+ if(isValidEmailAddress(uid)) {
+ // update future mail form field
+ $('input[name="mail"]').val(uid);
+
+ // check if user with that email address already exists
+ kadm.api_post('users.list', {'search': {'mail': {'value': uid} } }, 'check_user_availability_response');
+ } else {
+ update_user_info('This is not a valid email address!');
+ }
+};
+
+kadm.check_user_availability_response = function(response)
+{
+ if (!kadm.api_response(response))
+ return;
+
+ // setup up user message
+ var msg = '';
+ if(response['result']['count'] > 0) msg = 'User does already exist!';
+
+ update_user_info(msg);
+};
+
+function update_user_info(msg) {
+ if($('span[id="availability"]').length) {
+ // update existing span area
+ $('span[id="availability"]').html(msg);
+ }
+ else {
+ // add span area and inform about non-availability
+ $('input[name="alias"]').after(' <span id="availability" style="font-weight:bold;margin-left:1em;color:red;">' + msg + '</span>');
+ }
+}
+
+function isValidEmailAddress(emailAddress) {
+ var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
+ return pattern.test(emailAddress);
+};