From 1d8dc6a0460f320d5e757c3f794f1af9bcc6d1b4 Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 24 Aug 2013 13:53:14 +0200 Subject: [PATCH] added search capabilities to admin sections --- webui/.htaccess | 5 +++++ webui/controller/customer/list.php | 8 +++++++- webui/controller/domain/domain.php | 16 +++++++--------- webui/controller/ldap/list.php | 13 +++++++++---- webui/controller/policy/archiving.php | 7 ++++++- webui/controller/policy/retention.php | 7 ++++++- webui/model/domain/domain.php | 8 ++++++-- webui/model/policy/archiving.php | 8 ++++++-- webui/model/policy/retention.php | 8 ++++++-- webui/model/saas/customer.php | 11 ++++++++++- webui/model/saas/ldap.php | 13 +++++++++++-- .../theme/default/templates/customer/list.tpl | 7 +++++++ .../view/theme/default/templates/domain/list.tpl | 7 +++++++ webui/view/theme/default/templates/ldap/list.tpl | 7 +++++++ .../theme/default/templates/policy/archiving.tpl | 6 ++++++ .../theme/default/templates/policy/retention.tpl | 6 ++++++ .../theme/mobile/stylesheet/style-mobile.css | 1 + .../theme/mobile/templates/common/layout.tpl | 2 +- .../theme/mobile/templates/customer/list.tpl | 7 +++++++ .../view/theme/mobile/templates/domain/list.tpl | 7 +++++++ webui/view/theme/mobile/templates/group/list.tpl | 15 ++++++--------- webui/view/theme/mobile/templates/ldap/list.tpl | 7 +++++++ .../theme/mobile/templates/policy/archiving.tpl | 6 ++++++ .../theme/mobile/templates/policy/retention.tpl | 6 ++++++ 24 files changed, 153 insertions(+), 35 deletions(-) diff --git a/webui/.htaccess b/webui/.htaccess index 4aee82a7..0c914083 100644 --- a/webui/.htaccess +++ b/webui/.htaccess @@ -13,6 +13,11 @@ RewriteRule ^settings.php /index.php?route=user/settings [L] RewriteRule ^login.php /index.php?route=login/login [L] RewriteRule ^logout.php /index.php?route=login/logout [L] RewriteRule ^google.php /index.php?route=login/google [QSA,L] +RewriteRule ^domain.php /index.php?route=domain/domain [QSA,L] +RewriteRule ^ldap.php /index.php?route=ldap/list [QSA,L] +RewriteRule ^customer.php /index.php?route=customer/list [QSA,L] +RewriteRule ^retention.php /index.php?route=policy/retention [QSA,L] +RewriteRule ^archiving.php /index.php?route=policy/archiving [QSA,L] RewriteRule ^view/javascript/piler.js /js.php [QSA,L] diff --git a/webui/controller/customer/list.php b/webui/controller/customer/list.php index 25fe05b6..bf900f02 100644 --- a/webui/controller/customer/list.php +++ b/webui/controller/customer/list.php @@ -34,6 +34,12 @@ class ControllerCustomerList extends Controller { if(isset($this->request->get['id'])) { $this->data['id'] = $this->request->get['id']; } + $this->data['search'] = ''; + + if(isset($this->request->post['search'])) { $this->data['search'] = $this->request->post['search']; } + else if(isset($this->request->get['search'])) { $this->data['search'] = $this->request->get['search']; } + + /* check if we are admin */ if(Registry::get('admin_user') == 1) { @@ -72,7 +78,7 @@ class ControllerCustomerList extends Controller { $this->data['a'] = $this->model_saas_customer->get($this->data['id']); } else { - $this->data['entries'] = $this->model_saas_customer->get(); + $this->data['entries'] = $this->model_saas_customer->search($this->data['search']); } if ( isset($this->data['errorstring']) ) { diff --git a/webui/controller/domain/domain.php b/webui/controller/domain/domain.php index 302c191b..068ccf0e 100644 --- a/webui/controller/domain/domain.php +++ b/webui/controller/domain/domain.php @@ -42,12 +42,11 @@ class ControllerDomainDomain extends Controller { /* get search term if there's any */ - if($this->request->server['REQUEST_METHOD'] == 'POST'){ - $this->data['search'] = @$this->request->post['search']; - } - else { - $this->data['search'] = @$this->request->get['search']; - } + $this->data['search'] = ''; + + if(isset($this->request->post['search'])) { $this->data['search'] = $this->request->post['search']; } + else if(isset($this->request->get['search'])) { $this->data['search'] = $this->request->get['search']; } + /* get page */ @@ -64,7 +63,6 @@ class ControllerDomainDomain extends Controller { if($this->request->server['REQUEST_METHOD'] == 'POST') { if($this->validate() == true) { - 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 { @@ -75,11 +73,11 @@ class ControllerDomainDomain extends Controller { $this->data['errorstring'] = $this->data['text_error_message']; $this->data['errors'] = $this->error; $this->data['post'] = $this->request->post; - } + } } /* get list of domains */ - $this->data['domains'] = $this->model_domain_domain->getDomains(); + $this->data['domains'] = $this->model_domain_domain->getDomains($this->data['search']); } else { diff --git a/webui/controller/ldap/list.php b/webui/controller/ldap/list.php index 99d57079..5174ffe6 100644 --- a/webui/controller/ldap/list.php +++ b/webui/controller/ldap/list.php @@ -35,6 +35,12 @@ class ControllerLdapList extends Controller { if(isset($this->request->get['id'])) { $this->data['id'] = $this->request->get['id']; } + $this->data['search'] = ''; + + if(isset($this->request->post['search'])) { $this->data['search'] = $this->request->post['search']; } + else if(isset($this->request->get['search'])) { $this->data['search'] = $this->request->get['search']; } + + /* check if we are admin */ if(Registry::get('admin_user') == 1) { @@ -68,11 +74,10 @@ class ControllerLdapList extends Controller { } } - if(isset($this->request->get['id'])) { + if($this->data['id'] != -1) { $this->data['a'] = $this->model_saas_ldap->get($this->data['id']); - } - else { - $this->data['entries'] = $this->model_saas_ldap->get(); + } else { + $this->data['entries'] = $this->model_saas_ldap->search($this->data['search']); } if ( isset($this->data['errorstring']) ) { diff --git a/webui/controller/policy/archiving.php b/webui/controller/policy/archiving.php index c4d8532c..43e7dc1a 100644 --- a/webui/controller/policy/archiving.php +++ b/webui/controller/policy/archiving.php @@ -24,6 +24,11 @@ class ControllerPolicyArchiving extends Controller { $this->data['error'] = ''; + $this->data['search'] = ''; + + if(isset($this->request->post['search'])) { $this->data['search'] = $this->request->post['search']; } + else if(isset($this->request->get['search'])) { $this->data['search'] = $this->request->get['search']; } + if(Registry::get('admin_user') == 0) { die("go away"); } @@ -36,7 +41,7 @@ class ControllerPolicyArchiving extends Controller { } } - $this->data['rules'] = $this->model_policy_archiving->get_rules(); + $this->data['rules'] = $this->model_policy_archiving->get_rules($this->data['search']); $this->render(); diff --git a/webui/controller/policy/retention.php b/webui/controller/policy/retention.php index 9c4e8977..f42d00ee 100644 --- a/webui/controller/policy/retention.php +++ b/webui/controller/policy/retention.php @@ -22,6 +22,11 @@ class ControllerPolicyRetention extends Controller { $this->data['rules'] = array(); $this->data['error'] = ''; + $this->data['search'] = ''; + + if(isset($this->request->post['search'])) { $this->data['search'] = $this->request->post['search']; } + else if(isset($this->request->get['search'])) { $this->data['search'] = $this->request->get['search']; } + if(Registry::get('admin_user') == 0) { die("go away"); } @@ -37,7 +42,7 @@ class ControllerPolicyRetention extends Controller { } - $this->data['rules'] = $this->model_policy_retention->get_rules(); + $this->data['rules'] = $this->model_policy_retention->get_rules($this->data['search']); $this->render(); diff --git a/webui/model/domain/domain.php b/webui/model/domain/domain.php index 89735b2f..a27c0527 100644 --- a/webui/model/domain/domain.php +++ b/webui/model/domain/domain.php @@ -2,10 +2,14 @@ class ModelDomainDomain extends Model { - public function getDomains() { + public function getDomains($s = '') { $data = array(); - $query = $this->db->query("SELECT domain, mapped, ldap_id FROM " . TABLE_DOMAIN . " ORDER BY domain ASC"); + if($s) { + $query = $this->db->query("SELECT domain, mapped, ldap_id FROM " . TABLE_DOMAIN . " WHERE domain LIKE ? ORDER BY domain ASC", array('%' . $s . '%')); + } else { + $query = $this->db->query("SELECT domain, mapped, ldap_id FROM " . TABLE_DOMAIN . " ORDER BY domain ASC"); + } if(isset($query->rows)) { foreach($query->rows as $q) { diff --git a/webui/model/policy/archiving.php b/webui/model/policy/archiving.php index 40112ede..c957638b 100644 --- a/webui/model/policy/archiving.php +++ b/webui/model/policy/archiving.php @@ -3,8 +3,12 @@ class ModelPolicyArchiving extends Model { - public function get_rules() { - $query = $this->db->query("SELECT * FROM " . TABLE_ARCHIVING_RULE . " ORDER BY id"); + public function get_rules($s = '') { + if($s) { + $query = $this->db->query("SELECT * FROM " . TABLE_ARCHIVING_RULE . " WHERE `from` LIKE ? OR `to` LIKE ? OR subject LIKE ? ORDER BY domain, id", array('%' . $s . '%', '%' . $s . '%', '%' . $s . '%')); + } else { + $query = $this->db->query("SELECT * FROM " . TABLE_ARCHIVING_RULE . " ORDER BY id"); + } if(isset($query->rows)) { return $query->rows; } diff --git a/webui/model/policy/retention.php b/webui/model/policy/retention.php index 0b2af7e4..fb614af8 100644 --- a/webui/model/policy/retention.php +++ b/webui/model/policy/retention.php @@ -3,8 +3,12 @@ class ModelPolicyRetention extends Model { - public function get_rules() { - $query = $this->db->query("SELECT * FROM " . TABLE_RETENTION_RULE . " ORDER BY domain, id"); + public function get_rules($s = '') { + if($s) { + $query = $this->db->query("SELECT * FROM " . TABLE_RETENTION_RULE . " WHERE domain LIKE ? OR `from` LIKE ? OR subject LIKE ? ORDER BY domain, id", array('%' . $s . '%', '%' . $s . '%', '%' . $s . '%')); + } else { + $query = $this->db->query("SELECT * FROM " . TABLE_RETENTION_RULE . " ORDER BY domain, id"); + } if(isset($query->rows)) { return $query->rows; } diff --git a/webui/model/saas/customer.php b/webui/model/saas/customer.php index dd09a245..cd991b4f 100644 --- a/webui/model/saas/customer.php +++ b/webui/model/saas/customer.php @@ -10,7 +10,16 @@ class ModelSaasCustomer extends Model if($query->num_rows > 0) { return $query->row; } } - $query = $this->db->query("SELECT * FROM " . TABLE_CUSTOMER_SETTINGS . " ORDER BY domain ASC"); + return array(); + } + + + public function search($s = '') { + if($s) { + $query = $this->db->query("SELECT * FROM " . TABLE_CUSTOMER_SETTINGS . " WHERE domain LIKE ? ORDER BY domain ASC", array('%' . $s . '%')); + } else { + $query = $this->db->query("SELECT * FROM " . TABLE_CUSTOMER_SETTINGS . " ORDER BY domain ASC"); + } if($query->num_rows > 0) { return $query->rows; } diff --git a/webui/model/saas/ldap.php b/webui/model/saas/ldap.php index ecdd36ac..8eff6e35 100644 --- a/webui/model/saas/ldap.php +++ b/webui/model/saas/ldap.php @@ -5,12 +5,21 @@ class ModelSaasLdap extends Model public function get($id = -1) { - if($id >= 0) { + if(is_numeric($id) && $id >= 0) { $query = $this->db->query("SELECT id, description, ldap_type, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_bind_pw, ldap_auditor_member_dn FROM " . TABLE_LDAP . " WHERE id=?", array($id)); if($query->num_rows > 0) { return $query->row; } } - $query = $this->db->query("SELECT id, description, ldap_type, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_auditor_member_dn FROM " . TABLE_LDAP . " ORDER BY description ASC"); + return array(); + } + + + public function search($s = '') { + if($s) { + $query = $this->db->query("SELECT id, description, ldap_type, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_auditor_member_dn FROM " . TABLE_LDAP . " WHERE description LIKE ? ORDER BY description ASC", array('%' . $s . '%')); + } else { + $query = $this->db->query("SELECT id, description, ldap_type, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_auditor_member_dn FROM " . TABLE_LDAP . " ORDER BY description ASC"); + } if($query->num_rows > 0) { return $query->rows; } diff --git a/webui/view/theme/default/templates/customer/list.tpl b/webui/view/theme/default/templates/customer/list.tpl index ff9e85d6..ef3fe37f 100644 --- a/webui/view/theme/default/templates/customer/list.tpl +++ b/webui/view/theme/default/templates/customer/list.tpl @@ -12,6 +12,13 @@ +
+
+ + +
+
+

0)) { print $text_edit_entry; } else { print $text_add_new_entry; } ?>

:
diff --git a/webui/view/theme/default/templates/domain/list.tpl b/webui/view/theme/default/templates/domain/list.tpl index 81223dc3..f713c966 100644 --- a/webui/view/theme/default/templates/domain/list.tpl +++ b/webui/view/theme/default/templates/domain/list.tpl @@ -12,6 +12,13 @@ +
+
+ + +
+
+

:
diff --git a/webui/view/theme/default/templates/ldap/list.tpl b/webui/view/theme/default/templates/ldap/list.tpl index b7f6e074..980ad3b0 100644 --- a/webui/view/theme/default/templates/ldap/list.tpl +++ b/webui/view/theme/default/templates/ldap/list.tpl @@ -12,6 +12,13 @@ +
+
+ + +
+
+

0)) { print $text_edit_entry; } else { print $text_add_new_entry; } ?>

:
diff --git a/webui/view/theme/default/templates/policy/archiving.tpl b/webui/view/theme/default/templates/policy/archiving.tpl index c3ed7424..66977954 100644 --- a/webui/view/theme/default/templates/policy/archiving.tpl +++ b/webui/view/theme/default/templates/policy/archiving.tpl @@ -1,3 +1,9 @@ +
+
+ + +
+

diff --git a/webui/view/theme/default/templates/policy/retention.tpl b/webui/view/theme/default/templates/policy/retention.tpl index 3e609d33..03139436 100644 --- a/webui/view/theme/default/templates/policy/retention.tpl +++ b/webui/view/theme/default/templates/policy/retention.tpl @@ -1,3 +1,9 @@ +
+
+ + +
+

diff --git a/webui/view/theme/mobile/stylesheet/style-mobile.css b/webui/view/theme/mobile/stylesheet/style-mobile.css index 4b2bf8e7..118835b9 100644 --- a/webui/view/theme/mobile/stylesheet/style-mobile.css +++ b/webui/view/theme/mobile/stylesheet/style-mobile.css @@ -142,6 +142,7 @@ .left { text-align: left; } .center { text-align: center; } .sleek { margin:0; padding:0; } + .with20margin{ margin-left:20%; margin-right:20%; } .messagecontents {background-color:#fff; padding:8px; font-size:14px; font-family: "Trebuchet MS", Arial, Verdana; } diff --git a/webui/view/theme/mobile/templates/common/layout.tpl b/webui/view/theme/mobile/templates/common/layout.tpl index c82905c6..4f798839 100644 --- a/webui/view/theme/mobile/templates/common/layout.tpl +++ b/webui/view/theme/mobile/templates/common/layout.tpl @@ -45,7 +45,7 @@ if(isset($this->request->get['route'])) { -
+

diff --git a/webui/view/theme/mobile/templates/customer/list.tpl b/webui/view/theme/mobile/templates/customer/list.tpl index 9ad39409..6d4dd44b 100644 --- a/webui/view/theme/mobile/templates/customer/list.tpl +++ b/webui/view/theme/mobile/templates/customer/list.tpl @@ -12,6 +12,13 @@
+
+
+ + +
+
+

diff --git a/webui/view/theme/mobile/templates/domain/list.tpl b/webui/view/theme/mobile/templates/domain/list.tpl index 18b1d32d..33e4ea18 100644 --- a/webui/view/theme/mobile/templates/domain/list.tpl +++ b/webui/view/theme/mobile/templates/domain/list.tpl @@ -12,6 +12,13 @@ +
+
+ + +
+
+

diff --git a/webui/view/theme/mobile/templates/group/list.tpl b/webui/view/theme/mobile/templates/group/list.tpl index a0592df6..cf8edff5 100644 --- a/webui/view/theme/mobile/templates/group/list.tpl +++ b/webui/view/theme/mobile/templates/group/list.tpl @@ -12,20 +12,17 @@ -

+ +

+ + +
+

- - - -

 

- 0){ ?> +
+
+ + +
+
+

diff --git a/webui/view/theme/mobile/templates/policy/archiving.tpl b/webui/view/theme/mobile/templates/policy/archiving.tpl index 89c1942b..01a84335 100644 --- a/webui/view/theme/mobile/templates/policy/archiving.tpl +++ b/webui/view/theme/mobile/templates/policy/archiving.tpl @@ -1,3 +1,9 @@ +
+
+ + +
+

diff --git a/webui/view/theme/mobile/templates/policy/retention.tpl b/webui/view/theme/mobile/templates/policy/retention.tpl index 6ee92182..812c83ed 100644 --- a/webui/view/theme/mobile/templates/policy/retention.tpl +++ b/webui/view/theme/mobile/templates/policy/retention.tpl @@ -1,3 +1,9 @@ +
+
+ + +
+