update the gui for per user legal hold

This commit is contained in:
SJ 2015-03-29 16:27:44 +02:00
parent aaa16d0151
commit 1c57a4a1e4
21 changed files with 420 additions and 0 deletions

View File

@ -9,5 +9,12 @@ alter table retention_rule add column `body` varchar(128) default null;
create unique index `entry` on archiving_rule (`domain`,`from`,`to`,`subject`,`body`,`_size`,`size`,`attachment_name`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`);
create unique index `entry` on retention_rule (`domain`,`from`,`to`,`subject`,`body`,`_size`,`size`,`attachment_name`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`);
-- 2015.03.29
create index metadata_idx10 on metadata(`from`);
create table if not exists `legal_hold` (
email varchar(128) default not null
) Engine=InnoDB;

View File

@ -19,6 +19,7 @@ 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 ^legalhold.php /index.php?route=policy/legalhold [QSA,L]
RewriteRule ^view/javascript/piler.js /js.php [QSA,L]
<IfModule auth_ntlm_winbind_module>

View File

@ -355,6 +355,7 @@ define('TABLE_IMPORT', 'import');
define('TABLE_GOOGLE', 'google');
define('TABLE_GOOGLE_IMAP', 'google_imap');
define('TABLE_AUTOSEARCH', 'autosearch');
define('TABLE_LEGAL_HOLD', 'legal_hold');
define('VIEW_MESSAGES', 'v_messages');
define('EOL', "\n");

View File

@ -0,0 +1,108 @@
<?php
class ControllerPolicyLegalhold extends Controller {
private $error = array();
public function index(){
$this->id = "content";
$this->template = "policy/legalhold.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$ldap_id = 0;
$this->load->model('policy/hold');
$this->document->title = $this->data['text_legal_hold'];
$this->data['username'] = Registry::get('username');
$this->data['page'] = 0;
$this->data['page_len'] = get_page_length();
$this->data['total'] = 0;
$this->data['emails'] = array();
/* get search term if there's any */
$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 */
if(isset($this->request->get['page']) && is_numeric($this->request->get['page']) && $this->request->get['page'] > 0) {
$this->data['page'] = $this->request->get['page'];
}
/* check if we are admin */
if(Registry::get('admin_user') == 1) {
if($this->request->server['REQUEST_METHOD'] == 'POST') {
if($this->validate() == true) {
if($this->model_policy_hold->add_email($this->request->post['email']) == 1) {
$this->data['x'] = $this->data['text_successfully_added'];
} else {
$this->data['errorstring'] = $this->data['text_failed_to_add'];
}
}
else {
$this->data['errorstring'] = $this->data['text_error_message'];
$this->data['errors'] = $this->error;
$this->data['post'] = $this->request->post;
}
}
/* get list of emails */
$this->data['emails'] = $this->model_policy_hold->get_emails($this->data['search']);
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = $this->data['text_you_are_not_admin'];
}
$this->data['prev_page'] = $this->data['page'] - 1;
$this->data['next_page'] = $this->data['page'] + 1;
$this->data['total'] = floor(count($this->data['emails']) / $this->data['page_len']);
$this->render();
}
private function validate() {
if(!isset($this->request->post['email']) || strlen($this->request->post['email']) < 3 || !validemail($this->request->post['email'])) {
$this->error['email'] = $this->data['text_invalid_data'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -0,0 +1,75 @@
<?php
class ControllerPolicyRemovehold extends Controller {
private $error = array();
private $domains = array();
private $d = array();
public function index(){
$this->id = "content";
$this->template = "policy/removehold.tpl";
$this->layout = "common/layout";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('policy/hold');
$this->document->title = $this->data['text_legal_hold'];
$this->data['username'] = Registry::get('username');
$this->data['email'] = @$this->request->get['name'];
$this->data['confirmed'] = (int)@$this->request->get['confirmed'];
if($this->validate() == true) {
if($this->data['confirmed'] == 1) {
$ret = $this->model_policy_hold->delete_email($this->data['email']);
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_removed'];
}
else {
$this->data['x'] = $this->data['text_failed_to_remove'];
}
}
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = array_pop($this->error);
}
$this->render();
}
private function validate() {
if(Registry::get('admin_user') == 0) {
$this->error['admin'] = $this->data['text_you_are_not_admin'];
}
if(!isset($this->request->get['name']) || strlen($this->request->get['name']) < 3 || !validemail($this->request->get['name'])) {
$this->error['domain'] = $this->data['text_invalid_data'];
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>

View File

@ -481,5 +481,6 @@ $_['text_cumulative_counts'] = "Cumulative counts";
$_['text_message_disposition'] = "Message Disposition";
$_['text_assigned_email_addresses'] = "Assigned email addresses";
$_['text_storage'] = "Storage";
$_['text_legal_hold'] = "Legal hold";
?>

View File

@ -197,6 +197,7 @@ $_['text_ldap_bind_dn'] = "LDAP bind DN";
$_['text_ldap_bind_pw'] = "LDAP bind password";
$_['text_ldap_host'] = "LDAP host";
$_['text_ldap_type'] = "LDAP type";
$_['text_legal_hold'] = "Legal hold";
$_['text_load'] = "Load";
$_['text_loading'] = "loading";
$_['text_logged_in'] = "Logged in";

View File

@ -480,5 +480,6 @@ $_['text_cumulative_counts'] = "Cumulative counts";
$_['text_message_disposition'] = "Message Disposition";
$_['text_assigned_email_addresses'] = "Assigned email addresses";
$_['text_storage'] = "Storage";
$_['text_legal_hold'] = "Legal hold";
?>

View File

@ -477,5 +477,6 @@ $_['text_ldap_delete_confirm_message'] = "Souhaitez-vous supprimer l'entrée LDA
$_['text_customer_delete_confirm_message'] = 'Souhaitez-vous supprimer le client';
$_['text_with_selected'] = 'Selection';
$_['text_storage'] = "Stockage";
$_['text_legal_hold'] = "Legal hold";
?>

View File

@ -198,6 +198,7 @@ $_['text_ldap_bind_dn'] = "LDAP csatlakoz
$_['text_ldap_bind_pw'] = "LDAP csatlakozási jelszó";
$_['text_ldap_host'] = "LDAP kiszolgáló";
$_['text_ldap_type'] = "LDAP típus";
$_['text_legal_hold'] = "Legal hold";
$_['text_load'] = "Betöltés";
$_['text_loading'] = "töltõdik";
$_['text_logged_in'] = "Bejelentkezés";

View File

@ -198,6 +198,7 @@ $_['text_ldap_bind_dn'] = "LDAP csatlakozási DN";
$_['text_ldap_bind_pw'] = "LDAP csatlakozási jelszó";
$_['text_ldap_host'] = "LDAP kiszolgáló";
$_['text_ldap_type'] = "LDAP típus";
$_['text_legal_hold'] = "Legal hold";
$_['text_load'] = "Betöltés";
$_['text_loading'] = "töltődik";
$_['text_logged_in'] = "Bejelentkezés";

View File

@ -470,5 +470,6 @@ $_['text_cumulative_counts'] = "Cumulative counts";
$_['text_message_disposition'] = "Message Disposition";
$_['text_assigned_email_addresses'] = "Assigned email addresses";
$_['text_storage'] = "Storage";
$_['text_legal_hold'] = "Legal hold";
?>

View File

@ -478,5 +478,6 @@ $_['text_with_selected'] = 'С выделенным';
$_['text_assigned_email_addresses'] = "Assigned email addresses";
$_['text_storage'] = "Storage";
$_['text_legal_hold'] = "Legal hold";
?>

View File

@ -478,5 +478,6 @@ $_['text_cumulative_counts'] = "Cumulative counts";
$_['text_message_disposition'] = "Message Disposition";
$_['text_assigned_email_addresses'] = "Assigned email addresses";
$_['text_storage'] = "Storage";
$_['text_legal_hold'] = "Legal hold";
?>

View File

@ -0,0 +1,50 @@
<?php
class ModelPolicyHold extends Model {
public function get_emails($s = '') {
if($s) {
$query = $this->db->query("SELECT email FROM " . TABLE_LEGAL_HOLD . " WHERE email LIKE ? ORDER BY email ASC", array('%' . $s . '%'));
} else {
$query = $this->db->query("SELECT email FROM " . TABLE_LEGAL_HOLD . " ORDER BY email ASC");
}
if(isset($query->rows)) { return $query->rows; }
return array();
}
public function delete_email($email = '') {
if($email == "") { return 0; }
$query = $this->db->query("DELETE FROM " . TABLE_LEGAL_HOLD . " WHERE email=?", array($email));
$rc = $this->db->countAffected();
LOGGER("remove from legal hold: $email (rc=$rc)");
return $rc;
}
public function add_email($email = '') {
if($email == "") { return 0; }
$email = strtolower($email);
$query = $this->db->query("INSERT INTO " . TABLE_LEGAL_HOLD . " (email) VALUES (?)", array($email));
$rc = $this->db->countAffected();
if($rc == 1) {
LOGGER("add legal hold: $email (rc=$rc)");
}
return $rc;
}
}
?>

View File

@ -41,6 +41,7 @@
<?php } ?>
<li><a href="index.php?route=policy/archiving"><i class="icon-folder-open"></i>&nbsp;<?php print $text_archiving_rules; ?></a></li>
<li><a href="index.php?route=policy/retention"><i class="icon-time"></i>&nbsp;<?php print $text_retention_rules; ?></a></li>
<li><a href="index.php?route=policy/legalhold"><i class="icon-legal"></i>&nbsp;<?php print $text_legal_hold; ?></a></li>
<li><a href="index.php?route=search/autosearch"><i class="icon-search"></i>&nbsp;<?php print $text_automated_search; ?></a></li>
</ul>
</li>

View File

@ -0,0 +1,74 @@
<div id="deleteconfirm-modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" role="dialog" aria-hidden="true"><i class="icon-remove"></i></button>
<h3><?php print $text_confirm; ?> <?php print $text_delete; ?></h3>
</div>
<div class="modal-body">
<p><?php print $text_user_delete_confirm_message; ?> <span id="name">ERROR</span>?</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true"><?php print $text_close; ?></a>
<a href="index.php?route=policy/removehold&amp;id=-1&amp;email=Error&amp;confirmed=0" class="btn btn-primary" id="id"><?php print $text_delete; ?></a>
</div>
</div>
<form method="get" name="search1" action="legalhold.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_entry; ?></h4>
<?php if(isset($errorstring)){ ?><div class="alert alert-danger"><?php print $text_error; ?>: <?php print $errorstring; ?></div><?php } ?>
<?php if(isset($x)){ ?>
<div class="alert alert-success"><?php print $x; ?></div>
<?php } ?>
<form method="post" name="add1" action="index.php?route=policy/legalhold" class="form-horizontal">
<div class="control-group<?php if(isset($errors['email'])){ print " error"; } ?>">
<label class="control-label" for="email"><?php print $text_email; ?>:</label>
<div class="controls">
<input type="text" name="email" placeholder="Email"<?php if(isset($post['email'])){ echo " value='".$post['email']."'"; } ?> />
<?php if ( isset($errors['email']) ) { ?><span class="help-inline"><?php print $errors['email']; ?></span><?php } ?>
</div>
</div>
<div class="form-actions">
<input type="submit" value="<?php print $text_add; ?>" class="btn btn-primary" />
<input type="reset" value="<?php print $text_clear; ?>" class="btn" />
</div>
</form>
<h4><?php print $text_existing_email; ?></h4>
<div class="listarea">
<?php if(isset($emails) && count($emails) > 0){ ?>
<table id="ss1" class="table table-striped table-condensed">
<tr>
<th><?php print $text_email; ?></th>
<th>&nbsp;</th>
</tr>
<?php foreach($emails as $email) { ?>
<tr>
<td><?php print $email['email']; ?></a></td>
<td><a href="index.php?route=policy/removehold&amp;id=1&amp;email=<?php print urlencode($email['email']); ?>" class="confirm-delete" data-id="1" data-name="<?php print $email['email']; ?>"><i class="icon-remove-sign"></i>&nbsp;<?php print $text_remove; ?></a></td>
</tr>
<?php } ?>
</div>
<?php } else { ?>
<div class="alert alert-error lead">
<?php print $text_not_found; ?>
</div>
<?php } ?>
</div>

View File

@ -0,0 +1,14 @@
<div>
<?php if($confirmed){ ?>
<div class="alert alert-success"><?php print $x; ?>.</div>
<p><a href="index.php?route=policy/legalhold"><i class="icon-circle-arrow-left"></i>&nbsp;<?php print $text_back; ?></a></p>
<?php } else { ?>
<p><a href="index.php?route=policy/legalhold"><i class="icon-circle-arrow-left"></i>&nbsp;<?php print $text_back; ?></a> | <a href="index.php?route=policy/removehold&amp;email=<?php print $email; ?>&amp;confirmed=1"><i class="icon-remove-sign"></i>&nbsp;<?php print $text_remove_this_user; ?>: <?php print $email; ?></a></p>
<?php } ?>
</div>

View File

@ -37,6 +37,7 @@
<?php } ?>
<li><a href="index.php?route=policy/archiving"><?php print $text_archiving_rules; ?></a></li>
<li><a href="index.php?route=policy/retention"><?php print $text_retention_rules; ?></a></li>
<li><a href="index.php?route=policy/legalhold"><?php print $text_legal_hold; ?></a></li>
<li><a href="index.php?route=search/autosearch"><?php print $text_automated_search; ?></a></li>
</ul>
</li>

View File

@ -0,0 +1,67 @@
<div id="deleteconfirm-modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" role="dialog" aria-hidden="true"><i class="icon-remove"></i></button>
<h3><?php print $text_confirm; ?> <?php print $text_delete; ?></h3>
</div>
<div class="modal-body">
<p><?php print $text_user_delete_confirm_message; ?> <span id="name">ERROR</span>?</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true"><?php print $text_close; ?></a>
<a href="index.php?route=policy/removehold&amp;id=-1&amp;email=Error&amp;confirmed=0" class="btn btn-primary" id="id"><?php print $text_delete; ?></a>
</div>
</div>
<form method="get" name="search1" action="legalhold.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_entry; ?></h4>
<form method="post" name="add1" action="index.php?route=policy/legalhold" class="formbottom">
<div id="ss1">
<div class="row">
<div class="domaincell"><?php print $text_email; ?>:</div>
<div class="domaincell"><input type="text" class="text" name="email" /></div>
</div>
<div class="row">
<div class="domaincell">&nbsp;</div>
<div class="domaincell"><input type="submit" class="btn btn-primary" value="<?php print $text_add; ?>" /> <input type="reset" class="btn" value="<?php print $text_cancel; ?>" /></div>
</div>
</div>
</form>
<h4><?php print $text_existing_email; ?></h4>
<div class="listarea">
<?php if(count($emails) > 0){ ?>
<div id="ss1">
<div class="domainrow">
<div class="domaincell"><?php print $text_email; ?></div>
<div class="domaincell">&nbsp;</div>
</div>
<?php foreach($emails as $email) { ?>
<div class="domainrow">
<div class="domaincell"><?php print $email['email']; ?></div>
<div class="domaincell"><a href="index.php?route=policy/removehold&amp;id=1&amp;email=<?php print urlencode($email['email']); ?>" class="confirm-delete" data-id="1" data-name="<?php print $email['email']; ?>"><i class="icon-remove-sign"></i>&nbsp;<?php print $text_remove; ?></a></div>
</div>
<?php } ?>
</div>
<?php } else { ?>
<?php print $text_not_found; ?>
<?php } ?>
</div>

View File

@ -0,0 +1,12 @@
<?php if($confirmed){ ?>
<div class="alert alert-success"><?php print $x; ?>.</div>
<p><a href="index.php?route=policy/legalhold"><i class="icon-circle-arrow-left"></i>&nbsp;<?php print $text_back; ?></a></p>
<?php } else { ?>
<p><a href="index.php?route=policy/legalhold"><i class="icon-circle-arrow-left"></i>&nbsp;<?php print $text_back; ?></a> | <a href="index.php?route=policy/removehold&amp;email=<?php print $email; ?>&amp;confirmed=1"><i class="icon-remove-sign"></i>&nbsp;<?php print $text_remove_this_user; ?>: <?php print $email; ?></a></p>
<?php } ?>