mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-13 01:37:02 +02:00
update the gui for per user legal hold
This commit is contained in:
108
webui/controller/policy/legalhold.php
Normal file
108
webui/controller/policy/legalhold.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
75
webui/controller/policy/removehold.php
Normal file
75
webui/controller/policy/removehold.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user