コード例 #1
0
ファイル: AdminHandler.php プロジェクト: port22/mail
 protected function initStruct()
 {
     # NOTE: There are dependencies between domains and domain_count
     # NOTE: If you disable "display in list" for domain_count, the SQL query for domains might break.
     # NOTE: (Disabling both shouldn't be a problem.)
     # TODO: move to a db_group_concat() function?
     if (db_pgsql()) {
         $domains_grouped = "array_to_string(array_agg(domain), ',')";
     } else {
         # mysql
         $domains_grouped = 'group_concat(domain)';
     }
     $this->struct = array('username' => pacol($this->new, 1, 1, 'text', 'admin', 'email_address', '', '', array('linkto' => 'list.php?table=domain&username=%s')), 'password' => pacol(1, 1, 0, 'pass', 'password', ''), 'password2' => pacol(1, 1, 0, 'pass', 'password_again', '', '', '', 0, 1, 'password as password2'), 'superadmin' => pacol(1, 1, 0, 'bool', 'super_admin', 'super_admin_desc', 0), 'domains' => pacol(1, 1, 0, 'list', 'domain', '', array(), list_domains(), 0, 1, "coalesce(domains,'') as domains"), 'domain_count' => pacol(0, 0, 1, 'vnum', 'pAdminList_admin_count', '', '', '', 0, 1, 'coalesce(__domain_count,0) as domain_count', 'LEFT JOIN ( ' . ' SELECT count(*) AS __domain_count, ' . $domains_grouped . ' AS domains, username AS __domain_username ' . ' FROM ' . table_by_key('domain_admins') . " WHERE domain != 'ALL' GROUP BY username " . ' ) AS __domain on username = __domain_username'), 'active' => pacol(1, 1, 1, 'bool', 'active', '', 1), 'created' => pacol(0, 0, 0, 'ts', 'created', ''), 'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''));
 }
コード例 #2
0
ファイル: cyrus.mailboxes.php プロジェクト: BillTheBest/1.6.x
if (isset($_GET["verbose"])) {
    $GLOBALS["VERBOSE"] = true;
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    ini_set('error_prepend_string', null);
    ini_set('error_append_string', null);
}
$users = new usersMenus();
if (!$users->AsMailBoxAdministrator) {
    $tpl = new templates();
    $error = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    echo "alert('{$error}')";
    die;
}
if (isset($_GET["list-domains"])) {
    list_domains();
    exit;
}
if (isset($_GET["items-list"])) {
    items();
    exit;
}
if (isset($_POST["DeleteRealMailBox"])) {
    DeleteRealMailBox();
    exit;
}
page();
function page()
{
    $tpl = new templates();
    $sock = new sockets();
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
 * Form POST \ GET Variables:
 *
 * 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;
コード例 #5
0
            $fDomains = array('ALL');
        }
        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();