2012-06-25 22:14:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class ControllerGroupEmail extends Controller {
|
|
|
|
private $error = array();
|
|
|
|
|
|
|
|
public function index(){
|
|
|
|
|
|
|
|
$this->id = "content";
|
2012-06-27 11:17:23 +02:00
|
|
|
$this->template = "group/email.tpl";
|
|
|
|
$this->layout = "common/layout-email";
|
2012-06-25 22:14:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
$request = Registry::get('request');
|
|
|
|
$db = Registry::get('db');
|
|
|
|
$language = Registry::get('language');
|
|
|
|
|
|
|
|
$this->load->model('group/group');
|
|
|
|
|
2012-07-06 21:58:52 +02:00
|
|
|
$this->document->title = $language->get('text_group_management');
|
|
|
|
|
2012-06-27 11:17:23 +02:00
|
|
|
$this->data['page'] = 0;
|
|
|
|
$this->data['page_len'] = get_page_length();
|
|
|
|
|
|
|
|
$this->data['total'] = 0;
|
|
|
|
|
|
|
|
$this->data['sort'] = 'email';
|
2012-06-25 22:14:30 +02:00
|
|
|
|
|
|
|
$this->data['term'] = '';
|
|
|
|
|
2012-06-27 11:17:23 +02:00
|
|
|
if(!isset($this->request->get['term']) || strlen($this->request->get['term']) < 1) { die("no data"); }
|
|
|
|
|
|
|
|
if(isset($this->request->get['page']) && is_numeric($this->request->get['page']) && $this->request->get['page'] > 0) {
|
|
|
|
$this->data['page'] = $this->request->get['page'];
|
|
|
|
}
|
2012-06-25 22:14:30 +02:00
|
|
|
|
2012-06-27 11:17:23 +02:00
|
|
|
$this->data['search'] = $this->request->get['term'];
|
2012-06-25 22:14:30 +02:00
|
|
|
|
|
|
|
/* check if we are admin */
|
|
|
|
|
|
|
|
if(Registry::get('admin_user') == 1) {
|
|
|
|
|
2012-06-27 11:17:23 +02:00
|
|
|
// for autocomplete
|
|
|
|
|
|
|
|
if(strlen($this->request->get['term']) >= 2) {
|
|
|
|
$emails = $this->model_group_group->get_emails_by_string($this->request->get['term']);
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
$s = '[ ';
|
|
|
|
|
|
|
|
foreach($emails as $email) {
|
|
|
|
$i++;
|
|
|
|
$s .= '{ "id": "' . $i . '", "value": "' . $email['email'] . '" },';
|
|
|
|
}
|
2012-06-25 22:14:30 +02:00
|
|
|
|
2012-06-27 11:17:23 +02:00
|
|
|
$s = preg_replace("/,$/", "", $s) . " ]";
|
|
|
|
|
|
|
|
print $s;
|
2012-06-25 22:14:30 +02:00
|
|
|
}
|
|
|
|
|
2012-06-27 11:17:23 +02:00
|
|
|
// for email list
|
|
|
|
|
|
|
|
if(strlen($this->request->get['term']) == 1) {
|
|
|
|
$this->data['emails'] = $this->model_group_group->get_emails_by_string($this->request->get['term'], $this->data['page'], $this->data['page_len']);
|
|
|
|
|
|
|
|
$this->data['total'] = $this->model_group_group->count_emails($this->request->get['term']);
|
|
|
|
|
|
|
|
$this->data['prev_page'] = $this->data['page'] - 1;
|
|
|
|
$this->data['next_page'] = $this->data['page'] + 1;
|
|
|
|
|
|
|
|
$this->data['total_pages'] = floor($this->data['total'] / $this->data['page_len']);
|
|
|
|
|
|
|
|
$this->render();
|
|
|
|
}
|
2012-06-25 22:14:30 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|