added search capabilities to admin sections

This commit is contained in:
SJ 2013-08-24 13:53:14 +02:00
parent 899d97edfa
commit 1d8dc6a046
24 changed files with 153 additions and 35 deletions

View File

@ -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]
<IfModule auth_ntlm_winbind_module>

View File

@ -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']) ) {

View File

@ -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 {
@ -79,7 +77,7 @@ class ControllerDomainDomain extends Controller {
}
/* get list of domains */
$this->data['domains'] = $this->model_domain_domain->getDomains();
$this->data['domains'] = $this->model_domain_domain->getDomains($this->data['search']);
}
else {

View File

@ -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']) ) {

View File

@ -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();

View File

@ -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();

View File

@ -2,10 +2,14 @@
class ModelDomainDomain extends Model {
public function getDomains() {
public function getDomains($s = '') {
$data = array();
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) {

View File

@ -3,8 +3,12 @@
class ModelPolicyArchiving extends Model {
public function get_rules() {
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; }

View File

@ -3,8 +3,12 @@
class ModelPolicyRetention extends Model {
public function get_rules() {
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; }

View File

@ -10,7 +10,16 @@ class ModelSaasCustomer extends Model
if($query->num_rows > 0) { return $query->row; }
}
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; }

View File

@ -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; }
}
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; }

View File

@ -12,6 +12,13 @@
</div>
</div>
<form method="get" name="search1" action="customer.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php if(isset($id) && ($id > 0)) { print $text_edit_entry; } else { print $text_add_new_entry; } ?></h4>
<?php if(isset($errorstring)){ ?><div class="alert alert-danger"><?php print $text_error; ?>: <?php print $errorstring; ?></div><?php } ?>

View File

@ -12,6 +12,13 @@
</div>
</div>
<form method="get" name="search1" action="domain.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php print $text_add_new_domain; ?></h4>
<?php if(isset($errorstring)){ ?><div class="alert alert-danger"><?php print $text_error; ?>: <?php print $errorstring; ?></div><?php } ?>

View File

@ -12,6 +12,13 @@
</div>
</div>
<form method="get" name="search1" action="ldap.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php if(isset($id) && ($id > 0)) { print $text_edit_entry; } else { print $text_add_new_entry; } ?></h4>
<?php if(isset($errorstring)){ ?><div class="alert alert-danger"><?php print $text_error; ?>: <?php print $errorstring; ?></div><?php } ?>

View File

@ -1,3 +1,9 @@
<form method="get" name="search1" action="archiving.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php print $text_add_new_rule; ?></h4>

View File

@ -1,3 +1,9 @@
<form method="get" name="search1" action="retention.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php print $text_add_new_rule; ?></h4>

View File

@ -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; }

View File

@ -45,7 +45,7 @@ if(isset($this->request->get['route'])) {
<?php print $menu; ?>
</div>
<div id="mainscreen">
<div id="mainscreen" class="with20margin">
<?php if($title) { ?><h3 class="title"><?php print $title; ?></h3><?php } ?>

View File

@ -12,6 +12,13 @@
</div>
</div>
<form method="get" name="search1" action="customer.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php if(isset($a['domain'])) { print $text_edit_entry; } else { print $text_add_new_entry; } ?></h4>
<?php if(isset($x)){ ?>

View File

@ -12,6 +12,13 @@
</div>
</div>
<form method="get" name="search1" action="domain.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php print $text_add_new_domain; ?></h4>
<form method="post" name="add1" action="index.php?route=domain/domain" class="formbottom">

View File

@ -12,20 +12,17 @@
</div>
</div>
<p/>
<form method="post" name="search1" action="index.php?route=group/list" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<p><a href="index.php?route=group/add"><?php print $text_add_new_group; ?></a></p>
<h4><?php print $text_existing_groups; ?></h4>
<form method="post" name="search1" class="form-search" action="index.php?route=group/list">
<input type="text" name="search" value="<?php print $search; ?>" />
<input type="submit" class="btn btn-primary" value="<?php print $text_search; ?>" />
</form>
<p>&nbsp;</p>
<?php if(isset($groups) && count($groups) > 0){ ?>
<div id="pagenav">

View File

@ -12,6 +12,13 @@
</div>
</div>
<form method="get" name="search1" action="ldap.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php if(isset($a['description'])) { print $text_edit_entry; } else { print $text_add_new_entry; } ?></h4>
<?php if(isset($x)){ ?>

View File

@ -1,3 +1,9 @@
<form method="get" name="search1" action="archiving.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php print $text_add_new_rule; ?></h4>

View File

@ -1,3 +1,9 @@
<form method="get" name="search1" action="retention.php" class="form-inline pull-right">
<div class="input-append">
<input type="text" name="search" class="input-medium" value="<?php print $search; ?>" />
<input type="submit" class="btn" value="<?php print $text_search; ?>" />
</div>
</form>
<h4><?php print $text_add_new_rule; ?></h4>