示例#1
0
 public function index()
 {
     $this->id = "content";
     $this->template = "group/list.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $language = Registry::get('language');
     $this->load->model('group/group');
     $this->load->model('user/auth');
     $this->document->title = $language->get('text_group_management');
     $this->data['page'] = 0;
     $this->data['page_len'] = get_page_length();
     $this->data['total_users'] = 0;
     $users = array();
     /* get search term if there's any */
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $this->data['search'] = @$this->request->post['search'];
     } else {
         $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'];
     }
     $this->data['sort'] = 'groupname';
     $this->data['order'] = (int) @$this->request->get['order'];
     if (@$this->request->get['sort'] == "uid") {
         $this->data['sort'] = "uid";
     }
     if (@$this->request->get['sort'] == "realname") {
         $this->data['sort'] = "realname";
     }
     if (@$this->request->get['sort'] == "email") {
         $this->data['sort'] = "email";
     }
     if (@$this->request->get['sort'] == "domain") {
         $this->data['sort'] = "domain";
     }
     if (@$this->request->get['sort'] == "policy") {
         $this->data['sort'] = "policy_group";
     }
     /* check if we are admin */
     if (Registry::get('admin_user') == 1) {
         $this->data['groups'] = $this->model_group_group->get_groups($this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
         $this->data['total_groups'] = $this->model_group_group->count_groups($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_pages'] = floor($this->data['total_users'] / $this->data['page_len']);
     $this->render();
 }
示例#2
0
 public function index()
 {
     $this->id = "content";
     $this->template = "audit/helper.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('audit/audit');
     if (Registry::get('admin_user') == 0 && Registry::get('auditor_user') == 0) {
         die("go away");
     }
     $this->data['page'] = 0;
     if (isset($this->request->post['page'])) {
         $this->data['page'] = $this->request->post['page'];
     }
     $this->data['page_len'] = $this->a['page_len'] = get_page_length();
     $this->data['n'] = -1;
     if (isset($this->request->post)) {
         $this->fixup_request($this->request->post);
         list($this->data['n'], $this->data['messages']) = $this->model_audit_audit->search_audit($this->a);
     }
     $this->data['actions'][ACTION_UNKNOWN] = '??';
     $this->data['actions'][ACTION_LOGIN] = $this->data['text_login2'];
     $this->data['actions'][ACTION_LOGIN_FAILED] = $this->data['text_login_failed'];
     $this->data['actions'][ACTION_LOGOUT] = $this->data['text_logout2'];
     $this->data['actions'][ACTION_VIEW_MESSAGE] = $this->data['text_view_message2'];
     $this->data['actions'][ACTION_VIEW_HEADER] = $this->data['text_view_header'];
     $this->data['actions'][ACTION_UNAUTHORIZED_VIEW_MESSAGE] = $this->data['text_unauthorized_view_message'];
     $this->data['actions'][ACTION_RESTORE_MESSAGE] = $this->data['text_restore_message'];
     $this->data['actions'][ACTION_DOWNLOAD_MESSAGE] = $this->data['text_download_message2'];
     $this->data['actions'][ACTION_SEARCH] = $this->data['text_search2'];
     $this->data['actions'][ACTION_SAVE_SEARCH] = $this->data['text_save_search'];
     $this->data['actions'][ACTION_CHANGE_USER_SETTINGS] = $this->data['text_change_user_settings'];
     $this->data['actions'][ACTION_REMOVE_MESSAGE] = $this->data['text_remove_message2'];
     $this->data['actions'][ACTION_UNAUTHORIZED_REMOVE_MESSAGE] = $this->data['text_unauthorized_remove_message'];
     $this->data['actions'][ACTION_DOWNLOAD_ATTACHMENT] = $this->data['text_download_attachment2'];
     $this->data['actions'][ACTION_UNAUTHORIZED_DOWNLOAD_ATTACHMENT] = $this->data['text_unauthorized_download_attachment'];
     $this->data['actions'][ACTION_VIEW_JOURNAL] = $this->data['text_view_journal'];
     /* paging info */
     $this->data['prev_page'] = $this->data['page'] - 1;
     $this->data['next_page'] = $this->data['page'] + 1;
     $this->data['total_pages'] = ceil($this->data['n'] / $this->data['page_len']) - 1;
     $this->data['hits_from'] = $this->data['page'] * $this->data['page_len'] + 1;
     $this->data['hits_to'] = ($this->data['page'] + 1) * $this->data['page_len'];
     if ($this->data['hits_to'] > $this->data['n']) {
         $this->data['hits_to'] = $this->data['n'];
     }
     $this->render();
 }
示例#3
0
 public function index()
 {
     $this->id = "content";
     $this->template = "search/helper.tpl";
     $this->layout = "common/layout-empty";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $sphx = Registry::get('sphx');
     $this->load->model('search/search');
     $this->load->model('search/message');
     $this->load->model('user/user');
     $this->data['page'] = 0;
     if (isset($this->request->post['page'])) {
         $this->data['page'] = $this->request->post['page'];
     }
     $this->data['page_len'] = get_page_length();
     $this->data['n'] = -1;
     if ($this->request->post['searchtype'] == 'expert') {
         if (isset($this->request->post['search']) && preg_match("/(from|to|subject|body|direction|d|size|date1|date2|attachment|a|tag|note|id)\\:/", $this->request->post['search'])) {
             $this->a = $this->model_search_search->preprocess_post_expert_request($this->request->post);
         } else {
             $this->naive_preprocess_post_expert_request($this->request->post);
         }
         $this->fixup_post_request();
         list($this->data['n'], $this->data['total_found'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, $this->data['page']);
     } else {
         $this->fixup_post_simple_request();
         list($this->data['n'], $this->data['total_found'], $this->data['all_ids'], $this->data['messages']) = $this->model_search_search->search_messages($this->a, $this->data['page']);
     }
     if ($this->a['ref']) {
         $this->data['_ref'] = $this->a['ref'];
     }
     if (isset($this->request->post['ref']) && $this->request->post['ref']) {
         $this->data['_ref'] = $this->request->post['ref'];
     }
     /* paging info */
     $this->data['prev_page'] = $this->data['page'] - 1;
     $this->data['next_page'] = $this->data['page'] + 1;
     $this->data['total_pages'] = ceil($this->data['n'] / $this->data['page_len']) - 1;
     $this->data['hits_from'] = $this->data['page'] * $this->data['page_len'] + 1;
     $this->data['hits_to'] = ($this->data['page'] + 1) * $this->data['page_len'];
     if ($this->data['hits_to'] > $this->data['n']) {
         $this->data['hits_to'] = $this->data['n'];
     }
     $this->data['sort'] = $this->request->post['sort'];
     $this->data['order'] = $this->request->post['order'];
     $this->render();
 }
示例#4
0
 public function index()
 {
     $this->id = "content";
     $this->template = "group/email.tpl";
     $this->layout = "common/layout-email";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $language = Registry::get('language');
     $this->load->model('group/group');
     $this->load->model('user/auth');
     $this->document->title = '';
     $this->data['page'] = 0;
     $this->data['page_len'] = get_page_length();
     $this->data['total'] = 0;
     $this->data['sort'] = 'email';
     $this->data['term'] = '';
     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'];
     }
     $this->data['search'] = $this->request->get['term'];
     /* check if we are admin */
     if (Registry::get('admin_user') == 1) {
         // 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 . '" },';
             }
             $s = preg_replace("/,\$/", "", $s) . " ]";
             print $s;
         }
         // 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();
         }
     }
 }
示例#5
0
 public function index()
 {
     $this->id = "content";
     $this->template = "folder/list.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('folder/folder');
     $this->document->title = $this->data['text_folders'];
     if (isset($this->request->post['name']) && $this->request->post['name']) {
         $this->model_folder_folder->add_extra_folder($this->request->post['name']);
         Header("Location: folders.php");
         return;
     }
     if (isset($this->request->get['id']) && $this->request->get['id'] > 0) {
         $this->model_folder_folder->remove_extra_folder($this->request->get['id']);
         Header("Location: folders.php");
         return;
     }
     $this->data['page_len'] = get_page_length();
     $this->data['extra_folders'] = $this->model_folder_folder->get_extra_folders_for_user();
     $this->render();
 }
示例#6
0
 public function index()
 {
     $this->id = "content";
     $this->template = "user/settings.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $session = Registry::get('session');
     $db = Registry::get('db');
     $this->load->model('user/auth');
     $this->load->model('user/prefs');
     $this->load->model('user/user');
     $this->load->model('group/group');
     require DIR_BASE . 'system/helper/PHPGangsta_GoogleAuthenticator.php';
     $this->data['ga'] = $this->model_user_prefs->get_ga_settings($session->get('username'));
     $this->document->title = $this->data['text_settings'];
     $d = $r = '';
     $auditemails = $auditdomains = $auditgroups = $auditfolders = '';
     $auditemails = implode(", ", $session->get("emails"));
     $_auditdomains = $session->get("auditdomains");
     foreach ($_auditdomains as $d) {
         $auditdomains .= ', ' . $d;
     }
     $auditdomains = preg_replace("/^,\\s/", "", $auditdomains);
     $auditgroups = preg_replace("/\\s/", ", ", $this->model_group_group->get_groups_by_email($session->get("emails")));
     $folders = $session->get("folders");
     foreach ($folders as $r) {
         $auditfolders .= ', ' . $r;
     }
     $auditfolders = preg_replace("/^,\\s/", "", $auditfolders);
     if ($auditemails) {
         $this->data['emails'] = $auditemails;
     } else {
         $this->data['emails'] = $this->data['text_none_found'];
     }
     if ($auditdomains) {
         $this->data['domains'] = $auditdomains;
     } else {
         $this->data['domains'] = $this->data['text_none_found'];
     }
     if ($auditgroups) {
         $this->data['groups'] = $auditgroups;
     } else {
         $this->data['groups'] = $this->data['text_none_found'];
     }
     if ($auditfolders) {
         $this->data['folders'] = $auditfolders;
     } else {
         $this->data['folders'] = $this->data['text_none_found'];
     }
     if (isset($this->request->post['pagelen']) && isset($this->request->post['theme'])) {
         $this->model_user_prefs->set_user_preferences(Registry::get('username'), $this->request->post);
         AUDIT(ACTION_CHANGE_USER_SETTINGS, '', '', '', 'pagelen:' . $this->request->post['pagelen'] . ', theme:' . $this->request->post['theme'] . ', lang:' . $this->request->post['lang']);
         if (isAdminUser() == 1) {
             header("Location: " . SITE_URL . "index.php?route=health/health");
             return;
         }
         header("Location: " . SITE_URL . "search.php");
         return;
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && PASSWORD_CHANGE_ENABLED == 1 && $this->validate() == true) {
         if ($this->model_user_auth->change_password(Registry::get('username'), $this->request->post['password']) == 1) {
             $this->data['x'] = $this->data['text_password_changed'];
         } else {
             $this->data['x'] = $this->data['text_failed_to_change_password'];
         }
     }
     $this->data['page_len'] = get_page_length();
     $this->data['theme'] = $session->get("theme");
     $this->data['lang'] = $session->get("lang");
     $this->render();
 }
示例#7
0
 public function index()
 {
     $this->id = "content";
     $this->template = "customer/list.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('saas/customer');
     $this->load->model('domain/domain');
     $this->document->title = $this->data['text_customers'];
     $this->data['username'] = Registry::get('username');
     $this->data['page'] = 0;
     $this->data['page_len'] = get_page_length();
     $this->data['total'] = 0;
     $this->data['entries'] = array();
     $this->data['id'] = -1;
     if (isset($this->request->get['id'])) {
         $this->data['id'] = $this->request->get['id'];
     }
     $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'];
         }
     }
     /* check if we are admin */
     if (Registry::get('admin_user') == 1) {
         if ($this->request->server['REQUEST_METHOD'] == 'POST') {
             if ($this->validate() == true) {
                 if (isset($this->request->post['id'])) {
                     if ($this->model_saas_customer->update($this->request->post) == 1) {
                         $this->data['x'] = $this->data['text_successfully_modified'];
                     } else {
                         $this->data['errorstring'] = $this->data['text_failed_to_modify'];
                         // set customer ID to be the submitted id
                         if (isset($this->request->post['id'])) {
                             $this->data['id'] = $this->request->post['id'];
                         }
                     }
                 } else {
                     if ($this->model_saas_customer->add($this->request->post) == 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;
                 // set customer ID to be the submitted id
                 if (isset($this->request->post['id'])) {
                     $this->data['id'] = $this->request->post['id'];
                     print_r($this->data['id']);
                 }
             }
         }
         $this->data['domains'] = $this->model_domain_domain->get_mapped_domains();
         if ($this->data['id'] != -1) {
             $this->data['a'] = $this->model_saas_customer->get($this->data['id']);
         } else {
             $this->data['entries'] = $this->model_saas_customer->search($this->data['search']);
         }
         if (isset($this->data['errorstring'])) {
             // use posted values if they differ from database values (ie - form was submitted but failed validation)
             if (isset($this->request->post['domain'])) {
                 $this->data['a']['domain'] = $this->request->post['domain'];
             }
             if (isset($this->request->post['branding_text'])) {
                 $this->data['a']['branding_text'] = $this->request->post['branding_text'];
             }
             if (isset($this->request->post['branding_url'])) {
                 $this->data['a']['branding_url'] = $this->request->post['branding_url'];
             }
             if (isset($this->request->post['branding_logo'])) {
                 $this->data['a']['branding_logo'] = $this->request->post['branding_logo'];
             }
             if (isset($this->request->post['support_link'])) {
                 $this->data['a']['support_link'] = $this->request->post['support_link'];
             }
             if (isset($this->request->post['text_colour'])) {
                 $this->data['a']['text_colour'] = $this->request->post['text_colour'];
             }
             if (isset($this->request->post['background_colour'])) {
                 $this->data['a']['background_colour'] = $this->request->post['background_colour'];
             }
         }
     } else {
         $this->template = "common/error.tpl";
         $this->data['errorstring'] = $this->data['text_you_are_not_admin'];
     }
     $this->render();
 }
示例#8
0
 public function index()
 {
     $this->id = "content";
     $this->template = "import/list.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('saas/import');
     $this->document->title = $this->data['text_import'];
     $this->data['username'] = Registry::get('username');
     $this->data['page'] = 0;
     $this->data['page_len'] = get_page_length();
     $this->data['total'] = 0;
     $this->data['entries'] = array();
     $this->data['id'] = -1;
     if (isset($this->request->get['id'])) {
         $this->data['id'] = $this->request->get['id'];
     }
     /* check if we are admin */
     if (Registry::get('admin_user') == 1) {
         if ($this->request->server['REQUEST_METHOD'] == 'POST') {
             if ($this->validate() == true) {
                 if (isset($this->request->post['id'])) {
                     if ($this->model_saas_import->update($this->request->post) == 1) {
                         $this->data['x'] = $this->data['text_successfully_modified'];
                     } else {
                         $this->data['errorstring'] = $this->data['text_failed_to_modify'];
                         // set ID to be the submitted id
                         if (isset($this->request->post['id'])) {
                             $this->data['id'] = $this->request->post['id'];
                         }
                     }
                 } else {
                     if ($this->model_saas_import->add($this->request->post) == 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;
                 // set ID to be the submitted id
                 if (isset($this->request->post['id'])) {
                     $this->data['id'] = $this->request->post['id'];
                 }
             }
         }
         if (isset($this->request->get['id'])) {
             $this->data['a'] = $this->model_saas_import->get($this->data['id']);
         } else {
             $this->data['entries'] = $this->model_saas_import->get();
         }
         if (isset($this->data['errorstring'])) {
             // use posted values if they differ from database values (ie - form was submitted but failed validation)
             if (isset($this->request->post['server'])) {
                 $this->data['a']['server'] = $this->request->post['server'];
             }
             if (isset($this->request->post['username'])) {
                 $this->data['a']['username'] = $this->request->post['username'];
             }
             if (isset($this->request->post['type'])) {
                 $this->data['a']['type'] = $this->request->post['type'];
             }
         }
     } else {
         $this->template = "common/error.tpl";
         $this->data['errorstring'] = $this->data['text_you_are_not_admin'];
     }
     $this->render();
 }
示例#9
0
 public function index()
 {
     $this->id = "content";
     $this->template = "accounting/accounting.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $this->load->model('user/user');
     $this->load->model('group/group');
     $this->load->model('domain/domain');
     $this->load->model('accounting/accounting');
     if (ENABLE_SAAS == 1) {
         $this->load->model('saas/ldap');
     }
     $this->data['page'] = 0;
     $this->data['page_len'] = get_page_length();
     $this->data['sort'] = 'item';
     $this->data['sorttype'] = 0;
     $this->data['order'] = 0;
     $this->data['search'] = '';
     /* get search term if there's any */
     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'];
     }
     // get sort field
     if (isset($this->request->get['sort'])) {
         if (@$this->request->get['sort'] == "item") {
             $this->data['sort'] = 'item';
         }
         if (@$this->request->get['sort'] == "oldest") {
             $this->data['sort'] = 'oldest';
             $this->data['sorttype'] = 1;
         }
         if (@$this->request->get['sort'] == "newest") {
             $this->data['sort'] = 'newest';
             $this->data['sorttype'] = 1;
         }
         if (@$this->request->get['sort'] == "sent") {
             $this->data['sort'] = 'sent';
         }
         if (@$this->request->get['sort'] == "sentsize") {
             $this->data['sort'] = 'sentsize';
             $this->data['sorttype'] = 2;
         }
         if (@$this->request->get['sort'] == "sentavg") {
             $this->data['sort'] = 'sentavg';
             $this->data['sorttype'] = 2;
         }
         if (@$this->request->get['sort'] == "recd") {
             $this->data['sort'] = 'recd';
         }
         if (@$this->request->get['sort'] == "recdsize") {
             $this->data['sort'] = 'recdsize';
             $this->data['sorttype'] = 2;
         }
         if (@$this->request->get['sort'] == "recdavg") {
             $this->data['sort'] = 'recdavg';
             $this->data['sorttype'] = 2;
         }
     }
     // get sort order
     if (isset($this->request->get['order']) && is_numeric($this->request->get['order'])) {
         $this->data['order'] = $this->request->get['order'];
     }
     // get type of accounting view
     if (@$this->request->get['view'] == "email") {
         $this->data['view'] = 'email';
         $this->data['viewname'] = $this->data['text_email'];
         $this->data['accounting'] = $this->model_accounting_accounting->get_accounting('email', $this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
         $this->data['total_records'] = $this->model_accounting_accounting->count_accounting('email', $this->data['search']);
     }
     if (@$this->request->get['view'] == "domain") {
         $this->data['view'] = 'domain';
         $this->data['viewname'] = $this->data['text_domain'];
         $this->data['accounting'] = $this->model_accounting_accounting->get_accounting('domain', $this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
         $this->data['total_records'] = $this->model_accounting_accounting->count_accounting('domain', $this->data['search']);
         $this->data['mydomain_count'] = $this->model_domain_domain->count_mydomains();
         $this->data['user_count'] = 0;
         if (ENABLE_SAAS == 1) {
             $this->data['accounts'] = array();
             foreach ($this->data['accounting'] as $a) {
                 $this->data['accounts'][$a['item']] = $this->model_saas_ldap->get_accounts_in_domain($a['item']);
                 $this->data['user_count'] += count($this->data['accounts'][$a['item']]);
             }
         }
     }
     if (@$this->request->get['view'] == "accounts" && isset($this->request->get['domain'])) {
         $this->template = "accounting/accounts.tpl";
         $this->data['domain'] = $this->request->get['domain'];
         $this->data['accounts'] = $this->model_saas_ldap->get_accounts_in_domain($this->request->get['domain']);
     }
     if ($this->data['accounting']) {
         foreach ($this->data['accounting'] as $id => $row) {
             if ($this->data['sorttype'] == 0) {
                 $this->data['accounting'][$id]['display'] = $row[$this->data['sort']];
             }
             if ($this->data['sorttype'] == 1) {
                 $this->data['accounting'][$id]['display'] = date(DATE_TEMPLATE, $row[$this->data['sort']]);
             }
             if ($this->data['sorttype'] == 2) {
                 $this->data['accounting'][$id]['display'] = nice_size($row[$this->data['sort']]);
             }
         }
     }
     $this->document->title = $this->data['text_accounting'];
     $this->data['today'] = time() - time() % 86400;
     $this->data['days'] = 15;
     $this->data['timespan'] = @$this->request->get['timespan'];
     $this->data['uid'] = @$this->request->get['uid'];
     $this->data['admin_user'] = Registry::get('admin_user');
     $this->data['readonly_admin'] = Registry::get('readonly_admin');
     $this->data['prev_page'] = $this->data['page'] - 1;
     $this->data['next_page'] = $this->data['page'] + 1;
     $this->data['total_pages'] = floor($this->data['total_records'] / $this->data['page_len']);
     $this->render();
 }
示例#10
0
 public function index()
 {
     $this->id = "content";
     $this->template = "domain/list.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $ldap_id = 0;
     $this->load->model('domain/domain');
     if (ENABLE_SAAS == 1) {
         $this->load->model('saas/ldap');
         $this->data['ldap'] = $this->model_saas_ldap->search();
         if (isset($this->request->post['ldap_id'])) {
             $ldap_id = $this->request->post['ldap_id'];
         } else {
             $ldap_id = 0;
         }
     }
     $this->document->title = $this->data['text_domain'];
     $this->data['username'] = Registry::get('username');
     $this->data['page'] = 0;
     $this->data['page_len'] = get_page_length();
     $this->data['total'] = 0;
     $this->data['domains'] = 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_domain_domain->addDomain($this->request->post['domain'], $this->request->post['mapped'], $ldap_id) == 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 domains */
         $this->data['domains'] = $this->model_domain_domain->getDomains($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['domains']) / $this->data['page_len']);
     $this->render();
 }
示例#11
0
 public function search_messages($data = array(), $page = 0)
 {
     $one_page_of_ids = array();
     $total_hits = 0;
     $total_found = 0;
     $sort = "sent";
     $order = "DESC";
     $sortorder = "ORDER BY sent DESC";
     $cache_key = "";
     $q = "";
     $s = "";
     $all_ids_csv = "";
     $session = Registry::get('session');
     while (list($k, $v) = each($data)) {
         if ($v) {
             if (is_array($v)) {
                 $v = implode(" ", $v);
             }
             $s .= '&' . $k . '=' . $v;
         }
     }
     if ($s) {
         $s = substr($s, 1, strlen($s));
     }
     AUDIT(ACTION_SEARCH, '', '', 0, $s);
     if ($data['sort'] == "sent") {
         $sort = "sent";
     }
     if ($data['sort'] == "size") {
         $sort = "size";
     }
     if ($data['sort'] == "from") {
         $sort = "from";
     }
     if ($data['sort'] == "subj") {
         $sort = "subject";
     }
     if ($data['order'] == 1) {
         $order = "ASC";
     }
     $sortorder = "ORDER BY `{$sort}` {$order}";
     $m = array();
     if (MEMCACHED_ENABLED) {
         $cache_key = $this->make_cache_file_name($data, $sortorder);
         $memcache = Registry::get('memcache');
         $m = $memcache->get($cache_key);
     }
     if (isset($m['ids'])) {
         $all_ids = $m['ids'];
         $total_found = $m['total_found'];
     } else {
         if (isset($data['ref']) && $data['ref']) {
             list($total_found, $all_ids) = $this->query_all_possible_IDs_by_reference($data['ref'], $cache_key);
         } else {
             list($total_found, $all_ids) = $this->query_all_possible_IDs($data, $sort, $order, $sortorder, $cache_key);
         }
     }
     $total_hits = count($all_ids);
     if ($total_hits > 0) {
         $session->set('last_search', serialize($all_ids));
     } else {
         $session->set('last_search', '');
     }
     $data['page_len'] = get_page_length();
     if ($total_hits > 0) {
         $i = 0;
         foreach ($all_ids as $id) {
             if ($i >= $data['page_len'] * $page && $i < $data['page_len'] * ($page + 1)) {
                 array_push($one_page_of_ids, $id);
                 $all_ids_csv .= ",{$id}";
                 if ($q) {
                     $q .= ",?";
                 } else {
                     $q = "?";
                 }
             }
             $i++;
         }
     }
     $all_ids_csv = substr($all_ids_csv, 1, strlen($all_ids_csv));
     return array($total_hits, $total_found, $all_ids_csv, $this->get_meta_data($one_page_of_ids, $q, $sortorder));
 }
示例#12
0
 public function index()
 {
     $this->id = "content";
     $this->template = "user/list.tpl";
     $this->layout = "common/layout";
     $request = Registry::get('request');
     $db = Registry::get('db');
     $language = Registry::get('language');
     $this->load->model('user/user');
     $this->document->title = $language->get('text_user_management');
     $this->data['page'] = 0;
     $this->data['page_len'] = get_page_length();
     $this->data['total_users'] = 0;
     $users = array();
     /* get search term if there's any */
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $this->data['search'] = @$this->request->post['search'];
     } else {
         $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'];
     }
     $this->data['sort'] = 'username';
     $this->data['order'] = (int) @$this->request->get['order'];
     if (@$this->request->get['sort'] == "uid") {
         $this->data['sort'] = "uid";
     }
     if (@$this->request->get['sort'] == "realname") {
         $this->data['sort'] = "realname";
     }
     if (@$this->request->get['sort'] == "email") {
         $this->data['sort'] = "email";
     }
     if (@$this->request->get['sort'] == "domain") {
         $this->data['sort'] = "domain";
     }
     if (@$this->request->get['sort'] == "policy") {
         $this->data['sort'] = "policy_group";
     }
     /* check if we are admin */
     if (Registry::get('admin_user') == 1) {
         $users = $this->model_user_user->get_users($this->data['search'], $this->data['page'], $this->data['page_len'], $this->data['sort'], $this->data['order']);
         $this->data['total_users'] = $this->model_user_user->count_users($this->data['search']);
         foreach ($users as $user) {
             $policy_group = DEFAULT_POLICY;
             $this->data['users'][] = array('uid' => $user['uid'], 'username' => $user['username'], 'realname' => $user['realname'], 'email' => $user['email'], 'shortemail' => short_email($user['email']), 'domain' => $user['domain'], 'policy_group' => $policy_group, 'isadmin' => $user['isadmin']);
         }
     } 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_pages'] = floor($this->data['total_users'] / $this->data['page_len']);
     $this->data['querystring'] = '';
     if ($this->data['page'] != 1) {
         $this->data['querystring'] .= "&amp;page=" . $this->data['page'];
     }
     if (strlen($this->data['search']) > 0) {
         $this->data['querystring'] .= "&amp;search=" . $this->data['search'];
     }
     $this->render();
 }