/** * Constructor: fill $struct etc. * @param integer - 0 is edit mode, set to 1 to switch to create mode * @param string - if an admin_username is specified, permissions will be restricted to the domains this admin may manage * @param integer - 0 if logged in as user, 1 if logged in as admin or superadmin */ public function __construct($new = 0, $username = "", $is_admin = 1) { # set label_field if not explicitely set if (empty($this->label_field)) { $this->label_field = $this->id_field; } # set order_by if not explicitely set if (empty($this->order_by)) { $this->order_by = $this->id_field; } if ($new) { $this->new = 1; } if ($is_admin) { $this->admin_username = $username; } else { $this->username = $username; $this->is_admin = 0; $this->is_superadmin = 0; } if ($username != "" && !authentication_has_role('global-admin')) { $this->is_superadmin = 0; } if ($this->domain_field == "") { $this->no_domain_field(); } else { if ($this->admin_username != "") { $this->allowed_domains = list_domains_for_admin($username); } else { $this->allowed_domains = list_domains(); } } if ($this->user_field == '') { $this->no_user_field(); } $this->initStruct(); if (!isset($this->struct['_can_edit'])) { $this->struct['_can_edit'] = pacol(0, 0, 1, 'vnum', '', '', '', '', 0, 1, '1 as _can_edit'); } if (!isset($this->struct['_can_delete'])) { $this->struct['_can_delete'] = pacol(0, 0, 1, 'vnum', '', '', '', '', 0, 1, '1 as _can_delete'); } $struct_hook = Config::read($this->db_table . '_struct_hook'); if ($struct_hook != 'NO' && function_exists($struct_hook)) { $this->struct = $struct_hook($this->struct); } $this->initMsg(); $this->msg['id_field'] = $this->id_field; $this->msg['show_simple_search'] = count($this->searchfields) > 0; }
* fUsername * fPassword * fPassword2 * fName * fQuota * fDomain * fActive * fMail */ require_once 'common.php'; authentication_require_role('admin'); $SESSID_USERNAME = authentication_get_username(); if (authentication_has_role('global-admin')) { $list_domains = list_domains(); } else { $list_domains = list_domains_for_admin($SESSID_USERNAME); } $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text']; $pCreate_mailbox_name_text = $PALANG['pCreate_mailbox_name_text']; $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text']; if ($_SERVER['REQUEST_METHOD'] == "GET") { $fDomain = $list_domains[0]; if (isset($_GET['domain'])) { $fDomain = escape_string($_GET['domain']); } if (!in_array($fDomain, $list_domains)) { die("Invalid domain name selected, or you tried to select a domain you are not an admin for"); } $tDomain = $fDomain; $result = db_query("SELECT * FROM {$table_domain} WHERE domain='{$fDomain}'"); if ($result['rows'] == 1) {
$admin_properties = get_admin_properties($fUsername); } } else { $list_admins = array(authentication_get_username()); $is_superadmin = 0; $fUsername = ""; } if (isset($admin_properties) && $admin_properties['domain_count'] == 'ALL') { # list all domains for superadmins $list_domains = list_domains(); } elseif (!empty($fUsername)) { $list_domains = list_domains_for_admin($fUsername); } elseif ($is_superadmin) { $list_domains = list_domains(); } else { $list_domains = list_domains_for_admin(authentication_get_username()); } if (!empty($list_domains)) { for ($i = 0; $i < sizeof($list_domains); $i++) { $domain_properties[$i] = get_domain_properties($list_domains[$i]); } } #} include "templates/header.php"; include "templates/menu.php"; if ($is_superadmin) { include "templates/admin_list-domain.php"; } else { include "templates/overview-get.php"; } include "templates/footer.php";
* * File: list-virtual.php * List virtual users for a domain. * * Template File: list-virtual.php * * Form POST \ GET Variables: * * fDomain * fDisplay * search */ require_once 'common.php'; authentication_require_role('admin'); $admin_username = authentication_get_username(); $list_domains = list_domains_for_admin($admin_username); $page_size = $CONF['page_size']; $fDomain = safepost('fDomain', safeget('domain', safesession('list-virtual:domain'))); if (safesession('list-virtual:domain') != $fDomain) { unset($_SESSION['list-virtual:limit']); } $fDisplay = (int) safepost('limit', safeget('limit', safesession('list-virtual:limit'))); $search = safepost('search', safeget('search', array())); # not remembered in the session if (!is_array($search)) { die(Config::Lang('invalid_parameter')); } if (count($list_domains) == 0) { if (authentication_has_role('global-admin')) { flash_error($PALANG['no_domains_exist']); } else {
} foreach ($fDomains as $domain) { $result = db_query("INSERT INTO {$table_domain_admins} (username,domain,created) VALUES ('{$username}','{$domain}',NOW())"); } flash_info($PALANG['pAdminEdit_admin_result_success']); header("Location: list-admin.php"); exit(0); } else { flash_error($PALANG['pAdminEdit_admin_result_error']); } } if (isset($_GET['username'])) { $username = escape_string($_GET['username']); } $tAllDomains = list_domains(); $tDomains = list_domains_for_admin($username); $tActive = ''; $tPassword = $admin_details['password']; if ($admin_details['active'] == 't' || $admin_details['active'] == 1) { $tActive = $admin_details['active']; } $tSadmin = '0'; $result = db_query("SELECT * FROM {$table_domain_admins} WHERE username='******'"); // could/should be multiple matches to query; if ($result['rows'] >= 1) { $result = $result['result']; while ($row = db_array($result)) { if ($row['domain'] == 'ALL') { $tSadmin = '1'; $tDomains = array(); /* empty the list, they're an admin */