diff --git a/webui/controller/domain/domain.php b/webui/controller/domain/domain.php index 1e3460b..e2597ff 100644 --- a/webui/controller/domain/domain.php +++ b/webui/controller/domain/domain.php @@ -64,18 +64,17 @@ if($this->model_domain_domain->addDomain($this->request->post['domain'], $this->request->post['mapped'], $ldap_id) == 1) { $this->data['x'] = $this->data['text_successfully_added']; } else { - $this->template = "common/error.tpl"; $this->data['errorstring'] = $this->data['text_failed_to_add']; } } else { - $this->template = "common/error.tpl"; - $this->data['errorstring'] = array_pop($this->error); + $this->data['errorstring'] = $this->data['text_error_message']; + $this->data['errors'] = $this->error; + $this->data['post'] = $this->request->post; } } - /* get list of current policies */ - + /* get list of domains */ $this->data['domains'] = $this->model_domain_domain->getDomains(); } @@ -98,20 +97,24 @@ private function validate() { if(!isset($this->request->post['domain']) || strlen($this->request->post['domain']) < 3) { - $this->error['email'] = $this->data['text_invalid_data']; + $this->data['text_field_length'] = str_replace("?",3,$this->data['text_field_length']); + $this->error['domain'] = $this->data['text_field_length']; } else { $domains = explode("\n", $this->request->post['domain']); foreach ($domains as $domain) { $domain = rtrim($domain); if(!preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $domain) ) { - $this->error['email'] = $this->data['text_invalid_data'] . ": $domain"; + $this->error['domain'] = $this->data['text_field_domain']; } } } - if(!isset($this->request->post['mapped']) || strlen($this->request->post['mapped']) < 3 || !preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $this->request->post['mapped']) ) { - $this->error['domain'] = $this->data['text_invalid_data'] . ": " . $this->request->post['mapped']; + if(!isset($this->request->post['mapped']) || strlen($this->request->post['mapped']) < 3) { + $this->data['text_field_length'] = str_replace("?",3,$this->data['text_field_length']); + $this->error['mapped'] = $this->data['text_field_length']; + } elseif( !preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $this->request->post['mapped']) ) { + $this->error['mapped'] = $this->data['text_field_domain']; } if (!$this->error) { diff --git a/webui/controller/domain/remove.php b/webui/controller/domain/remove.php index 222f0d3..459f7a5 100644 --- a/webui/controller/domain/remove.php +++ b/webui/controller/domain/remove.php @@ -23,7 +23,7 @@ $this->data['username'] = Registry::get('username'); - $this->data['domain'] = @$this->request->get['domain']; + $this->data['domain'] = @$this->request->get['name']; $this->data['confirmed'] = (int)@$this->request->get['confirmed']; @@ -56,7 +56,7 @@ $this->error['admin'] = $this->data['text_you_are_not_admin']; } - if(!isset($this->request->get['domain']) || strlen($this->request->get['domain']) < 3 || ($this->request->get['domain'] != "local" && !preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $this->request->get['domain'])) ) { + if(!isset($this->request->get['name']) || strlen($this->request->get['name']) < 3 || ($this->request->get['domain'] != "local" && !preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/', $this->request->get['name'])) ) { $this->error['domain'] = $this->data['text_invalid_data']; } diff --git a/webui/controller/user/add.php b/webui/controller/user/add.php index e9ae310..b541cda 100644 --- a/webui/controller/user/add.php +++ b/webui/controller/user/add.php @@ -50,7 +50,8 @@ } } else { - $this->data['errorstring'] = array_pop($this->error); + $this->data['errorstring'] = $this->data['text_error_message']; + $this->data['errors'] = $this->error; } if($ret == 0) { @@ -62,6 +63,7 @@ } else { $this->data['next_user_id'] = $this->model_user_user->get_next_uid(); + // not sure these are needed $this->data['groups'] = $this->model_group_group->get_groups(); $this->data['folders'] = $this->model_folder_folder->get_folders(); } @@ -71,31 +73,32 @@ $this->data['errorstring'] = $this->data['text_you_are_not_admin']; } - - - $this->render(); } - private function validate() { - - if(!isset($this->request->post['password']) || !isset($this->request->post['password2']) ) { +private function validate() { + //password is required and must be greater than the MIN_PASSWORD_LENGTH + if(!isset($this->request->post['password'])) { $this->error['password'] = $this->data['text_missing_password']; - } - - if(strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH || strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) { + } elseif (strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH) { $this->error['password'] = $this->data['text_too_short_password']; } - - if($this->request->post['password'] != $this->request->post['password2']) { - $this->error['password'] = $this->data['text_password_mismatch']; + //password2 is required and must be greater than the MIN_PASSWORD_LENGTH + if(!isset($this->request->post['password2'])) { + $this->error['password2'] = $this->data['text_missing_password']; + } elseif (strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) { + $this->error['password2'] = $this->data['text_too_short_password']; } - + //passwords must match (put here to override the password2 missing message, if also present) + if($this->request->post['password'] != $this->request->post['password2']) { + $this->error['password2'] = $this->data['text_password_mismatch']; + } + //uid is required and must be numeric & 0 or greater if(!isset($this->request->post['uid']) || !is_numeric($this->request->post['uid']) || $this->request->post['uid'] < 0) { $this->error['uid'] = $this->data['text_invalid_uid']; } - + //email address is required and must be in the proper format if(!isset($this->request->post['email']) || strlen($this->request->post['email']) < 3) { $this->error['email'] = $this->data['text_invalid_email']; } @@ -114,15 +117,15 @@ } } } - + //username is required and must be greater than 2 chars if(!isset($this->request->post['username']) || strlen($this->request->post['username']) < 2) { $this->error['username'] = $this->data['text_invalid_username']; } - + //username is required and must be unique if(isset($this->request->post['username']) && $this->model_user_user->get_uid_by_name($this->request->post['username']) > 0) { $this->error['username'] = $this->data['text_existing_user']; } - + //primary domain is required if(!isset($this->request->post['domain'])) { $this->error['domain'] = $this->data['text_missing_data']; } diff --git a/webui/controller/user/edit.php b/webui/controller/user/edit.php index f31effe..8c7152b 100644 --- a/webui/controller/user/edit.php +++ b/webui/controller/user/edit.php @@ -66,11 +66,11 @@ $__username = $this->request->post['username']; } else { - $this->template = "common/error.tpl"; - $this->data['errorstring'] = array_pop($this->error); + $this->data['errorstring'] = $this->data['text_error_message']; + $this->data['errors'] = $this->error; } } - else { + //else { $this->data['user'] = $this->model_user_user->get_user_by_uid($this->data['uid']); $this->data['user']['domains'] = $this->model_user_user->get_domains_by_uid($this->data['uid']); @@ -80,22 +80,28 @@ $this->data['emails'] = $this->model_user_user->get_emails($this->data['user']['username']); - } + //} } else { $this->template = "common/error.tpl"; $this->data['errorstring'] = $this->data['text_you_are_not_admin']; } - - - $this->render(); } private function validate() { + //if provided, the password must be greater than the MIN_PASSWORD_LENGTH + if(isset($this->request->post['password']) && strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH) { + $this->error['password'] = $this->data['text_too_short_password']; + } + //if provided, the password2 must be greater than the MIN_PASSWORD_LENGTH + if(isset($this->request->post['password2']) && strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) { + $this->error['password2'] = $this->data['text_too_short_password']; + } + if(isset($this->request->post['password']) && strlen(@$this->request->post['password']) > 1) { if(strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH || strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) { diff --git a/webui/controller/user/list.php b/webui/controller/user/list.php index 010232e..d3918dc 100644 --- a/webui/controller/user/list.php +++ b/webui/controller/user/list.php @@ -91,6 +91,9 @@ $this->data['total_pages'] = floor($this->data['total_users'] / $this->data['page_len']); + $this->data['querystring'] = ''; + if ($this->data['page'] != 1) { $this->data['querystring'] .= "&page=".$this->data['page']; } + if (strlen($this->data['search']) > 0) { $this->data['querystring'] .= "&search=".$this->data['search']; } $this->render(); } diff --git a/webui/controller/user/remove.php b/webui/controller/user/remove.php index e897a20..13457d5 100644 --- a/webui/controller/user/remove.php +++ b/webui/controller/user/remove.php @@ -23,7 +23,7 @@ $this->data['username'] = Registry::get('username'); - $this->data['uid'] = (int)@$this->request->get['uid']; + $this->data['uid'] = (int)@$this->request->get['id']; $this->data['user'] = @$this->request->get['user']; $this->data['confirmed'] = (int)@$this->request->get['confirmed']; @@ -57,7 +57,7 @@ $this->error['admin'] = $this->data['text_you_are_not_admin']; } - if(!isset($this->request->get['uid']) || !is_numeric($this->request->get['uid']) || $this->request->get['uid'] < 1 ) { + if(!isset($this->request->get['id']) || !is_numeric($this->request->get['id']) || $this->request->get['id'] < 1 ) { $this->error['username'] = $this->data['text_invalid_uid']; } diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index 31e04b2..a9a9c41 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -432,4 +432,14 @@ $_['text_items'] = 'Items'; $_['text_average_size'] = 'Avg size'; +$_['text_return_to'] = 'Return to'; +$_['text_error_message'] = 'Please correct the below errors and re-submit.'; +$_['text_field_required'] = 'This field is required.'; +$_['text_field_length'] = 'This field is required to be longer than ? characters.'; +$_['text_field_domain'] = 'This field must be a valid domain (ie - domain.com).'; +$_['text_delete'] = 'Delete'; +$_['text_confirm'] = 'Confirm'; +$_['text_user_delete_confirm_message'] = 'Do you wish to delete the user'; +$_['text_domain_delete_confirm_message'] = 'Do you wish to delete the domain'; +$_['text_with_selected'] = 'With Selected'; ?> diff --git a/webui/view/javascript/piler-in.js b/webui/view/javascript/piler-in.js index 15057b8..c1c497a 100644 --- a/webui/view/javascript/piler-in.js +++ b/webui/view/javascript/piler-in.js @@ -1072,5 +1072,52 @@ }); +// modal additions + +$(document).on("click", ".confirm-delete", function (e) { + e.preventDefault(); + + + var id = $(this).data('id'), + name = $(this).data('name'), + url = $(".modal-footer #id").attr("href"); + + //set id + url = UpdateQueryString('id',id,url); + //set name + url = UpdateQueryString('name',name,url); + //set confirmation + url = UpdateQueryString('confirmed',1,url); + //set href + $(".modal-footer #id").attr("href",url); + //set display text + $(".modal-body #name").html( name ); + //finally, display the confirm modal box + $('#deleteconfirm-modal').modal('show'); +}); + +function UpdateQueryString(key, value, url) { // from http://stackoverflow.com/questions/5999118/add-or-update-query-string-parameter/11654596#11654596 + if (!url) url = window.location.href; + var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi"); + + if (re.test(url)) { + if (typeof value !== 'undefined' && value !== null) + return url.replace(re, '$1' + key + "=" + value + '$2$3'); + else { + return url.replace(re, '$1$3').replace(/(&|\?)$/, ''); + } + } + else { + if (typeof value !== 'undefined' && value !== null) { + var separator = url.indexOf('?') !== -1 ? '&' : '?', + hash = url.split('#'); + url = hash[0] + separator + key + '=' + value; + if (hash[1]) url += '#' + hash[1]; + return url; + } + else + return url; + } +} diff --git a/webui/view/theme/default/templates/common/layout-audit.tpl b/webui/view/theme/default/templates/common/layout-audit.tpl index 469a5b7..6285ef5 100644 --- a/webui/view/theme/default/templates/common/layout-audit.tpl +++ b/webui/view/theme/default/templates/common/layout-audit.tpl @@ -35,14 +35,14 @@ - +
- -
@@ -50,18 +50,17 @@
-
- -
- - +
+
+ + +
+
+ +
-
-
+
- - -
diff --git a/webui/view/theme/default/templates/common/layout-search.tpl b/webui/view/theme/default/templates/common/layout-search.tpl index ac19f6b..6f9b0f0 100644 --- a/webui/view/theme/default/templates/common/layout-search.tpl +++ b/webui/view/theme/default/templates/common/layout-search.tpl @@ -36,14 +36,13 @@ +
- -
@@ -52,14 +51,15 @@
-
- -
+
+
+ -
+
+
- +