mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 07:40:12 +01:00
added retention policy web part
This commit is contained in:
parent
020756fa1c
commit
ee9c2af1b2
76
webui/controller/policy/removeretention.php
Normal file
76
webui/controller/policy/removeretention.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerPolicyRemoveretention extends Controller {
|
||||
private $error = array();
|
||||
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
41
webui/controller/policy/retention.php
Normal file
41
webui/controller/policy/retention.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerPolicyRetention extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
39
webui/model/policy/retention.php
Normal file
39
webui/model/policy/retention.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ModelPolicyRetention extends Model {
|
||||
|
||||
public function get_rules() {
|
||||
$query = $this->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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,22 @@
|
||||
|
||||
<p>
|
||||
|
||||
<?php if($confirmed){ ?>
|
||||
|
||||
<?php print $x; ?>. <a href="index.php?route=policy/retention"><?php print $text_back; ?></a>
|
||||
|
||||
<?php } else { ?>
|
||||
<a href="index.php?route=policy/removeretention&id=<?php print $id; ?>&confirmed=1"><?php print $text_remove_rule; ?></a>: <?php
|
||||
|
||||
if($rule['from']) { print $text_from . ': ' . $rule['from'] . ', '; }
|
||||
if($rule['to']) { print $text_to . ': ' . $rule['to'] . ', '; }
|
||||
if($rule['subject']) { print $text_subject . ': ' . $rule['subject'] . ', '; }
|
||||
if($rule['size'] > 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'] . ' '; }
|
||||
?> <a href="index.php?route=policy/retention"><?php print $text_back; ?></a>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</p>
|
||||
|
110
webui/view/theme/default/templates/policy/retention.tpl
Normal file
110
webui/view/theme/default/templates/policy/retention.tpl
Normal file
@ -0,0 +1,110 @@
|
||||
|
||||
<h4><?php print $text_add_new_rule; ?></h4>
|
||||
|
||||
<form method="post" name="add1" action="index.php?route=policy/retention" style="margin-bottom: 30px;">
|
||||
|
||||
<div id="ss1" style="margin-top: 10px; width: 600px; border: 1px solid red;">
|
||||
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_from; ?>:</div>
|
||||
<div class="domaincell"><input type="text" class="text" name="from" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_to; ?>:</div>
|
||||
<div class="domaincell"><input type="text" class="text" name="to" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_subject; ?>:</div>
|
||||
<div class="domaincell"><input type="text" class="text" name="subject" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_size; ?>:</div>
|
||||
<div class="domaincell">
|
||||
<select class="ruleselect" name="_size">
|
||||
<option value=">">></option>
|
||||
<option value="=">=</option>
|
||||
<option value="<"><</option>
|
||||
</select>
|
||||
<input type="text" class="ruletext" name="size" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_attachment_type; ?>:</div>
|
||||
<div class="domaincell"><input type="text" class="text" name="attachment_type" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_attachment_size; ?>:</div>
|
||||
<div class="domaincell">
|
||||
<select class="ruleselect" name="_attachment_size">
|
||||
<option value=">">></option>
|
||||
<option value="=">=</option>
|
||||
<option value="<"><</option>
|
||||
</select>
|
||||
<input type="text" class="ruletext" name="attachment_size" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_spam; ?>:</div>
|
||||
<div class="domaincell">
|
||||
<select class="ruleselect" name="spam">
|
||||
<option value="-1">-</option>
|
||||
<option value="0"><?php print $text_not_spam; ?></option>
|
||||
<option value="1"><?php print $text_spam2; ?></option>
|
||||
</select>
|
||||
<input type="text" class="ruletext" name="attachment_size" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="domaincell"><?php print $text_days_to_retain; ?>:</div>
|
||||
<div class="domaincell"><input type="text" class="text" name="days" /></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="domaincell"> </div>
|
||||
<div class="domaincell"><input type="submit" value="<?php print $text_add; ?>" /> <input type="reset" value="<?php print $text_cancel; ?>" /></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<h4><?php print $text_existing_rules; ?></h4>
|
||||
|
||||
<?php if(isset($rules)){ ?>
|
||||
|
||||
<div id="ss1" style="margin-top: 10px; border: 1px solid red;">
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $text_from; ?></div>
|
||||
<div class="domaincell"><?php print $text_to; ?></div>
|
||||
<div class="domaincell"><?php print $text_subject; ?></div>
|
||||
<div class="domaincell"><?php print $text_spam; ?></div>
|
||||
<div class="domaincell"><?php print $text_size; ?></div>
|
||||
<div class="domaincell"><?php print $text_attachment_type; ?></div>
|
||||
<div class="domaincell"><?php print $text_attachment_size; ?></div>
|
||||
<div class="domaincell"><?php print $text_days; ?></div>
|
||||
<div class="domaincell"> </div>
|
||||
</div>
|
||||
|
||||
<?php foreach($rules as $rule) { ?>
|
||||
<div class="domainrow">
|
||||
<div class="domaincell"><?php print $rule['from']; ?></div>
|
||||
<div class="domaincell"><?php print $rule['to']; ?></div>
|
||||
<div class="domaincell"><?php print $rule['subject']; ?></div>
|
||||
<div class="domaincell"><?php if($rule['spam'] == -1) { print "-"; } else if($rule['spam'] == 0) { print $text_not_spam; } else { print $text_spam; } ?></div>
|
||||
<div class="domaincell"><?php if($rule['size'] > 0) { print $rule['_size']; ?> <?php print $rule['size']; } ?></div>
|
||||
<div class="domaincell"><?php print $rule['attachment_type']; ?></div>
|
||||
<div class="domaincell"><?php if($rule['attachment_size'] > 0) { print $rule['_attachment_size']; ?> <?php print $rule['attachment_size']; } ?></div>
|
||||
<div class="domaincell"><?php print $rule['days']; ?></div>
|
||||
<div class="domaincell"><a href="index.php?route=policy/removeretention&id=<?php print $rule['id']; ?>"><?php print $text_remove; ?></a></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } else { ?>
|
||||
<?php print $text_not_found; ?>
|
||||
<?php } ?>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user