diff --git a/webui/controller/customer/list.php b/webui/controller/customer/list.php index cec7916b..7cf2fd4e 100644 --- a/webui/controller/customer/list.php +++ b/webui/controller/customer/list.php @@ -35,44 +35,56 @@ class ControllerCustomerList extends Controller { if(isset($this->request->get['id'])) { $this->data['id'] = $this->request->get['id']; } /* check if we are admin */ - + if(Registry::get('admin_user') == 1) { if($this->request->server['REQUEST_METHOD'] == 'POST') { if($this->validate() == true) { - + if(isset($this->request->post['id'])) { if($this->model_saas_customer->update($this->request->post) == 1) { $this->data['x'] = $this->data['text_successfully_modified']; } else { - $this->template = "common/error.tpl"; $this->data['errorstring'] = $this->data['text_failed_to_modify']; + // set customer ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; } } } else { if($this->model_saas_customer->add($this->request->post) == 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); + else { + $this->data['errorstring'] = $this->data['text_error_message']; + $this->data['errors'] = $this->error; + // set customer ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; print_r($this->data['id']);} } } $this->data['domains'] = $this->model_domain_domain->get_mapped_domains(); - if(isset($this->request->get['id'])) { - $this->data['a'] = $this->model_saas_customer->get($this->request->get['id']); + if($this->data['id'] != -1) { + $this->data['a'] = $this->model_saas_customer->get($this->data['id']); } else { $this->data['entries'] = $this->model_saas_customer->get(); } - + + if ( isset($this->data['errorstring']) ) { + // use posted values if they differ from database values (ie - form was submitted but failed validation) + if (isset($this->request->post['domain'])) { $this->data['a']['domain'] = $this->request->post['domain'];} + if (isset($this->request->post['branding_text'])) { $this->data['a']['branding_text'] = $this->request->post['branding_text'];} + if (isset($this->request->post['branding_url'])) { $this->data['a']['branding_url'] = $this->request->post['branding_url'];} + if (isset($this->request->post['branding_logo'])) { $this->data['a']['branding_logo'] = $this->request->post['branding_logo'];} + if (isset($this->request->post['support_link'])) { $this->data['a']['support_link'] = $this->request->post['support_link'];} + if (isset($this->request->post['colour'])) { $this->data['a']['colour'] = $this->request->post['colour'];} + } + } else { $this->template = "common/error.tpl"; @@ -85,15 +97,19 @@ class ControllerCustomerList extends Controller { private function validate() { - + // domain is required and must be 1 or more characters in length to meet this if(!isset($this->request->post['domain']) || strlen($this->request->post['domain']) < 1) { $this->error['domain'] = $this->data['text_invalid_data']; } - + // branding text is required and must be 1 or more characters in length to meet this if(!isset($this->request->post['branding_text']) || strlen($this->request->post['branding_text']) < 1) { - $this->error['branding_text'] = $this->data['text_invalid_data']; + $this->error['branding_text'] = $this->data['text_field_required']; } - + // if colour is provided it must be in the format #fcfcfc or #fcf + if(isset($this->request->post['colour']) && strlen($this->request->post['colour']) > 0 && !preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $this->request->post['colour'])) { + $this->error['colour'] = $this->data['text_field_colour']; + } + if (!$this->error) { return true; } else { diff --git a/webui/controller/customer/remove.php b/webui/controller/customer/remove.php index ca28870c..d8e02a8b 100644 --- a/webui/controller/customer/remove.php +++ b/webui/controller/customer/remove.php @@ -24,7 +24,7 @@ class ControllerCustomerRemove extends Controller { $this->data['username'] = Registry::get('username'); $this->data['id'] = $this->request->get['id']; - $this->data['domain'] = $this->request->get['domain']; + $this->data['domain'] = $this->request->get['name']; $this->data['confirmed'] = (int)$this->request->get['confirmed']; @@ -57,7 +57,7 @@ class ControllerCustomerRemove extends Controller { $this->error['admin'] = $this->data['text_you_are_not_admin']; } - if(!isset($this->request->get['domain']) || strlen($this->request->get['domain']) < 1) { + if(!isset($this->request->get['name']) || strlen($this->request->get['name']) < 1) { $this->error['domain'] = $this->data['text_invalid_data']; } diff --git a/webui/controller/domain/domain.php b/webui/controller/domain/domain.php index e2597ff0..302c191b 100644 --- a/webui/controller/domain/domain.php +++ b/webui/controller/domain/domain.php @@ -21,7 +21,11 @@ class ControllerDomainDomain extends Controller { if(ENABLE_SAAS == 1) { $this->load->model('saas/ldap'); $this->data['ldap'] = $this->model_saas_ldap->get(); - $ldap_id = $this->request->post['ldap_id']; + if ( isset($this->request->post['ldap_id']) ) { + $ldap_id = $this->request->post['ldap_id']; + } else { + $ldap_id = 0; + } } $this->document->title = $this->data['text_domain']; diff --git a/webui/controller/domain/remove.php b/webui/controller/domain/remove.php index 459f7a53..8c873beb 100644 --- a/webui/controller/domain/remove.php +++ b/webui/controller/domain/remove.php @@ -56,7 +56,7 @@ class ControllerDomainRemove extends Controller { $this->error['admin'] = $this->data['text_you_are_not_admin']; } - 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'])) ) { + if(!isset($this->request->get['name']) || strlen($this->request->get['name']) < 3 || ($this->request->get['name'] != "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/ldap/list.php b/webui/controller/ldap/list.php index b0eee06d..92f6bc73 100644 --- a/webui/controller/ldap/list.php +++ b/webui/controller/ldap/list.php @@ -46,22 +46,24 @@ class ControllerLdapList extends Controller { if($this->model_saas_ldap->update($this->request->post) == 1) { $this->data['x'] = $this->data['text_successfully_modified']; } else { - $this->template = "common/error.tpl"; $this->data['errorstring'] = $this->data['text_failed_to_modify']; + // set ldap ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; } } } else { if($this->model_saas_ldap->add($this->request->post) == 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; + // set ldap ID to be the submitted id + if (isset($this->request->post['id'])) { $this->data['id'] = $this->request->post['id']; } } } @@ -71,7 +73,13 @@ class ControllerLdapList extends Controller { else { $this->data['entries'] = $this->model_saas_ldap->get(); } - + + if ( isset($this->data['errorstring']) ) { + // use posted values if they differ from database values (ie - form was submitted but failed validation) + if (isset($this->request->post['ldap_type'])) { $this->data['a']['ldap_type'] = $this->request->post['ldap_type'];} + if (isset($this->request->post['description'])) { $this->data['a']['description'] = $this->request->post['description'];} + } + } else { $this->template = "common/error.tpl"; @@ -84,25 +92,25 @@ class ControllerLdapList extends Controller { private function validate() { - + // description is required and must be 1 or more characters in length to meet this if(!isset($this->request->post['description']) || strlen($this->request->post['description']) < 1) { - $this->error['description'] = $this->data['text_invalid_data']; + $this->error['description'] = $this->data['text_field_required']; } - + // ldap_host is required and must be 1 or more characters in length to meet this if(!isset($this->request->post['ldap_host']) || strlen($this->request->post['ldap_host']) < 1) { - $this->error['ldap_host'] = $this->data['text_invalid_data']; + $this->error['ldap_host'] = $this->data['text_field_required']; } - + // ldap_base_dn is required and must be 1 or more characters in length to meet this if(!isset($this->request->post['ldap_base_dn']) || strlen($this->request->post['ldap_base_dn']) < 1) { - $this->error['ldap_base_dn'] = $this->data['text_invalid_data']; + $this->error['ldap_base_dn'] = $this->data['text_field_required']; } - + // ldap_bind_dn is required and must be 1 or more characters in length to meet this if(!isset($this->request->post['ldap_bind_dn']) || strlen($this->request->post['ldap_bind_dn']) < 1) { - $this->error['ldap_bind_dn'] = $this->data['text_invalid_data']; + $this->error['ldap_bind_dn'] = $this->data['text_field_required']; } - + // ldap_bind_pw is required and must be 1 or more characters in length to meet this if(!isset($this->request->post['ldap_bind_pw']) || strlen($this->request->post['ldap_bind_pw']) < 1) { - $this->error['ldap_bind_pw'] = $this->data['text_invalid_data']; + $this->error['ldap_bind_pw'] = $this->data['text_field_required']; } if (!$this->error) { diff --git a/webui/controller/ldap/remove.php b/webui/controller/ldap/remove.php index 4f942a41..f5efccda 100644 --- a/webui/controller/ldap/remove.php +++ b/webui/controller/ldap/remove.php @@ -24,7 +24,7 @@ class ControllerLdapRemove extends Controller { $this->data['username'] = Registry::get('username'); $this->data['id'] = $this->request->get['id']; - $this->data['description'] = $this->request->get['description']; + $this->data['description'] = $this->request->get['name']; $this->data['confirmed'] = (int)$this->request->get['confirmed']; @@ -57,7 +57,7 @@ class ControllerLdapRemove extends Controller { $this->error['admin'] = $this->data['text_you_are_not_admin']; } - if(!isset($this->request->get['description']) || strlen($this->request->get['description']) < 1) { + if(!isset($this->request->get['name']) || strlen($this->request->get['name']) < 1) { $this->error['description'] = $this->data['text_invalid_data']; } diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index a9a9c413..3f519e17 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -437,9 +437,13 @@ $_['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_field_colour'] = 'This field must be a valid color code (ie - #fcfcfc).'; $_['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_group_delete_confirm_message'] = 'Do you wish to delete the group'; +$_['text_ldap_delete_confirm_message'] = 'Do you wish to delete the LDAP entry'; +$_['text_customer_delete_confirm_message'] = 'Do you wish to delete the customer'; $_['text_with_selected'] = 'With Selected'; ?> diff --git a/webui/model/saas/customer.php b/webui/model/saas/customer.php index 5b21d505..87bccd63 100644 --- a/webui/model/saas/customer.php +++ b/webui/model/saas/customer.php @@ -36,7 +36,7 @@ class ModelSaasCustomer extends Model if(!isset($arr['domain']) || !isset($arr['branding_text'])) { return 0; } - if(isset($_FILES['branding_logo']['name'])) { + if(isset($_FILES['branding_logo']['name']) && strlen($_FILES['branding_logo']['name'])>0) { $branding_logo = $_FILES['branding_logo']['name']; move_uploaded_file($_FILES['branding_logo']['tmp_name'], DIR_BASE . "/images/" . $_FILES['branding_logo']['name']); } @@ -55,10 +55,10 @@ class ModelSaasCustomer extends Model public function update($arr = array()) { $branding_logo = ''; - + if(!isset($arr['id']) || !isset($arr['domain']) || !isset($arr['branding_text'])) { return 0; } - if(isset($_FILES['branding_logo']['name'])) { + if(isset($_FILES['branding_logo']['name']) && strlen($_FILES['branding_logo']['name'])>0) { $branding_logo = $_FILES['branding_logo']['name']; move_uploaded_file($_FILES['branding_logo']['tmp_name'], DIR_BASE . "/images/" . $_FILES['branding_logo']['name']); diff --git a/webui/view/javascript/piler-in.js b/webui/view/javascript/piler-in.js index c1c497a9..c65cb89b 100644 --- a/webui/view/javascript/piler-in.js +++ b/webui/view/javascript/piler-in.js @@ -1085,7 +1085,7 @@ $(document).on("click", ".confirm-delete", function (e) { //set id url = UpdateQueryString('id',id,url); //set name - url = UpdateQueryString('name',name,url); + url = UpdateQueryString('name',encodeURIComponent(name),url); //set confirmation url = UpdateQueryString('confirmed',1,url); //set href diff --git a/webui/view/theme/default/templates/common/menu.tpl b/webui/view/theme/default/templates/common/menu.tpl index b2a34f4e..1f110137 100644 --- a/webui/view/theme/default/templates/common/menu.tpl +++ b/webui/view/theme/default/templates/common/menu.tpl @@ -63,11 +63,17 @@