From ee9c2af1b211d4f80d1967e762e4b02861933929 Mon Sep 17 00:00:00 2001 From: SJ Date: Mon, 20 Feb 2012 14:20:19 +0100 Subject: [PATCH] added retention policy web part --- webui/controller/policy/removeretention.php | 76 ++++++++++++ webui/controller/policy/retention.php | 41 +++++++ webui/language/en/messages.php | 2 + webui/language/hu/messages.iso-8859-2.php | 2 + webui/language/hu/messages.php | 2 + webui/model/policy/retention.php | 39 +++++++ .../templates/policy/removeretention.tpl | 22 ++++ .../default/templates/policy/retention.tpl | 110 ++++++++++++++++++ 8 files changed, 294 insertions(+) create mode 100644 webui/controller/policy/removeretention.php create mode 100644 webui/controller/policy/retention.php create mode 100644 webui/model/policy/retention.php create mode 100644 webui/view/theme/default/templates/policy/removeretention.tpl create mode 100644 webui/view/theme/default/templates/policy/retention.tpl diff --git a/webui/controller/policy/removeretention.php b/webui/controller/policy/removeretention.php new file mode 100644 index 00000000..dc62bf14 --- /dev/null +++ b/webui/controller/policy/removeretention.php @@ -0,0 +1,76 @@ +id = "content"; + $this->template = "policy/removeretention.tpl"; + $this->layout = "common/layout"; + + + $request = Registry::get('request'); + $db = Registry::get('db'); + + $this->load->model('policy/retention'); + + $this->document->title = $this->data['text_retention_rules']; + + + $this->data['username'] = Registry::get('username'); + + $this->data['id'] = @$this->request->get['id']; + $this->data['confirmed'] = (int)@$this->request->get['confirmed']; + + + $this->data['rule'] = $this->model_policy_retention->get_rule($this->data['id']); + + if($this->validate() == true) { + + if($this->data['confirmed'] == 1) { + $ret = $this->model_policy_retention->remove_rule($this->data['id']); + 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['id']) || $this->request->get['id'] < 1 ) { + $this->error['rule'] = $this->data['text_invalid_data']; + } + + + if (!$this->error) { + return true; + } else { + return false; + } + + } + + +} + +?> diff --git a/webui/controller/policy/retention.php b/webui/controller/policy/retention.php new file mode 100644 index 00000000..00339d40 --- /dev/null +++ b/webui/controller/policy/retention.php @@ -0,0 +1,41 @@ +id = "content"; + $this->template = "policy/retention.tpl"; + $this->layout = "common/layout"; + + + $request = Registry::get('request'); + + $db = Registry::get('db'); + + $this->load->model('policy/retention'); + + $this->document->title = $this->data['text_retention_rules']; + + $this->data['rules'] = array(); + + if(Registry::get('admin_user') == 0) { + die("go away"); + } + + if($_SERVER['REQUEST_METHOD'] == 'POST') { + $rc = $this->model_policy_retention->add_new_rule($this->request->post); + } + + $this->data['rules'] = $this->model_policy_retention->get_rules(); + + + $this->render(); + } + + +} + +?> diff --git a/webui/language/en/messages.php b/webui/language/en/messages.php index 52b9265d..55c84774 100644 --- a/webui/language/en/messages.php +++ b/webui/language/en/messages.php @@ -47,6 +47,8 @@ $_['text_database_emails'] = "email addresses in piler database"; $_['text_date'] = "Date"; $_['text_date_from'] = "Date from"; $_['text_date_to'] = "Date to"; +$_['text_days'] = "Days"; +$_['text_days_to_retain'] = "Days to retain"; $_['text_deferred_queue'] = "deferred queue"; $_['text_deferred_queue_sender'] = "deferred queue vs. sender"; $_['text_delay'] = "Delay"; diff --git a/webui/language/hu/messages.iso-8859-2.php b/webui/language/hu/messages.iso-8859-2.php index 26f17edd..08bf4d91 100644 --- a/webui/language/hu/messages.iso-8859-2.php +++ b/webui/language/hu/messages.iso-8859-2.php @@ -47,6 +47,8 @@ $_['text_database_emails'] = "email c $_['text_date'] = "Dátum"; $_['text_date_from'] = "Dátumtól"; $_['text_date_to'] = "Dátumig"; +$_['text_days'] = "Napok"; +$_['text_days_to_retain'] = "Megőrzési idő (nap)"; $_['text_deferred_queue'] = "későbbi kiküldésre váró üzenetsor"; $_['text_deferred_queue_sender'] = "későbbi kiküldésre váró üzenetsor (feladó szerint)"; $_['text_delay'] = "Késleltetés"; diff --git a/webui/language/hu/messages.php b/webui/language/hu/messages.php index ee4e29c0..1f4dfdf0 100644 --- a/webui/language/hu/messages.php +++ b/webui/language/hu/messages.php @@ -47,6 +47,8 @@ $_['text_database_emails'] = "email cĂ­m a piler adatbázisban"; $_['text_date'] = "Dátum"; $_['text_date_from'] = "DátumtĂłl"; $_['text_date_to'] = "Dátumig"; +$_['text_days'] = "Napok"; +$_['text_days_to_retain'] = "MegĹ‘rzĂ©si idĹ‘ (nap)"; $_['text_deferred_queue'] = "kĂ©sĹ‘bbi kikĂĽldĂ©sre várĂł ĂĽzenetsor"; $_['text_deferred_queue_sender'] = "kĂ©sĹ‘bbi kikĂĽldĂ©sre várĂł ĂĽzenetsor (feladĂł szerint)"; $_['text_delay'] = "KĂ©sleltetĂ©s"; diff --git a/webui/model/policy/retention.php b/webui/model/policy/retention.php new file mode 100644 index 00000000..01847670 --- /dev/null +++ b/webui/model/policy/retention.php @@ -0,0 +1,39 @@ +db->query("SELECT * FROM " . TABLE_RETENTION_RULE . " ORDER BY id"); + + if(isset($query->rows)) { return $query->rows; } + + return array(); + } + + + public function get_rule($id = 0) { + $query = $this->db->query("SELECT * FROM " . TABLE_RETENTION_RULE . " WHERE id=?", array($id)); + + if(isset($query->row)) { return $query->row; } + + return array(); + } + + + public function add_new_rule($data = array()) { + + $query = $this->db->query("INSERT INTO " . TABLE_RETENTION_RULE . " (`from`,`to`,`subject`,`_size`,`size`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`,`days`) VALUES(?,?,?,?,?,?,?,?,?,?)", array($data['from'], $data['to'], $data['subject'], $data['_size'], $data['size'], $data['attachment_type'], $data['_attachment_size'], $data['attachment_size'], $data['spam'], $data['days']) ); + return $this->db->countAffected(); + } + + + public function remove_rule($id = 0) { + $query = $this->db->query("DELETE FROM " . TABLE_RETENTION_RULE . " WHERE id=?", array($id)); + return $this->db->countAffected(); + } + + +} + +?> diff --git a/webui/view/theme/default/templates/policy/removeretention.tpl b/webui/view/theme/default/templates/policy/removeretention.tpl new file mode 100644 index 00000000..644fcbc8 --- /dev/null +++ b/webui/view/theme/default/templates/policy/removeretention.tpl @@ -0,0 +1,22 @@ + +

+ + + +. + + +: 0) { print $text_size . ': ' . $rule['_size'] . ' ' . $rule['size'] . ', '; } +if($rule['attachment_type'] > 0) { print $text_attachment_type . ': ' . $rule['attachment_type'] . ', '; } +if($rule['attachment_size'] > 0) { print $text_attachment_size . ': ' . $rule['_attachment_size'] . ' ' . $rule['attachment_size'] . ' '; } +?> + + + +

+ diff --git a/webui/view/theme/default/templates/policy/retention.tpl b/webui/view/theme/default/templates/policy/retention.tpl new file mode 100644 index 00000000..5a337791 --- /dev/null +++ b/webui/view/theme/default/templates/policy/retention.tpl @@ -0,0 +1,110 @@ + +

+ +
+ +
+ +
+
:
+
+
+
+
:
+
+
+
+
:
+
+
+
+
:
+
+ + +
+
+
+
:
+
+
+
+
:
+
+ + +
+
+
+
:
+
+ + +
+
+
+
:
+
+
+ + +
+
 
+
+
+ +
+ +
+ + +

+ + + +
+
+
+
+
+
+
+
+
+
+
 
+
+ + +
+
+
+
+
+
0) { print $rule['_size']; ?>
+
+
0) { print $rule['_attachment_size']; ?>
+
+
+
+ + +
+ + + + + +