function requireSiteAdmin()
{
    $userId = requireLogin();
    if (!isSiteAdmin()) {
        header('HTTP/1.1 403 Forbidden: Not a site administrator');
        exit;
    }
    return $userId;
}
function comber_rsvp_summary()
{
    if (is_user_logged_in()) {
        if (isSiteAdmin()) {
            $output = comber_rsvp_summary_build();
        } else {
            $output = '<p>You are not an administrator!</p>';
        }
    } else {
        // could show some logged in user info here
        $output = '<p>You need to log in!</p>';
    }
    return $output;
}
Example #3
0
function modifySiteAdminUser($userId, $siteAdmin)
{
    if (!isSiteAdmin()) {
        return FALSE;
    }
    if ($userId == $_SESSION['user']['user_id']) {
        return FALSE;
    }
    $userObj = loadUser($userId);
    if (!$userObj) {
        return FALSE;
    }
    if (!userIsActive($userId)) {
        return FALSE;
    }
    $userRoleId = getRoleId('user');
    $adminRoleId = getRoleId('admin');
    if ($userObj['role_id'] != $userRoleId && $userObj['role_id'] != $adminRoleId) {
        return FALSE;
    }
    $newRoleId = $userRoleId;
    if ($siteAdmin) {
        $newRoleId = $adminRoleId;
    }
    $updates = array('role_id' => $newRoleId);
    $conditions = array('user_id' => $userId);
    return db_update('virtual_users', $updates, $conditions);
}
function removeDomain($domainId)
{
    if (!isSiteAdmin() || !$domainId) {
        return FALSE;
    }
    $condition = array('domain_id' => $domainId);
    return db_delete('virtual_domains', $condition);
}
function modifyLocalAlias($aliasId, $name, $destination, $active)
{
    if (!$active) {
        $active = 'f';
    } else {
        $active = 't';
    }
    if (!$aliasId || !$name || !$destination || !$active) {
        return FALSE;
    }
    if (!isSiteAdmin()) {
        return FALSE;
    }
    if (!localAliasExistsById($aliasId)) {
        return FALSE;
    }
    if (!validUserName($name)) {
        return FALSE;
    }
    if (!validLocalAliasDestination($destination)) {
        return FALSE;
    }
    $updates = array('name' => $name, 'destination' => $destination, 'active' => $active);
    $conditions = array('alias_id' => $aliasId);
    return db_update('local_aliases', $updates, $conditions);
}
Example #6
0
$tree[] = array('text' => 'Your Settings', 'id' => 'your-settings', 'children' => $yourSettings);
$siteAdministration = array();
$domainAdministration = array();
$siteAdministration[] = array('text' => 'Domains', 'id' => 'manage-domains', 'leaf' => TRUE);
$domainAdministration[] = array('text' => 'Users', 'id' => 'manage-users', 'leaf' => TRUE);
$domainAdministration[] = array('text' => 'User Forwards', 'id' => 'manage-forwards', 'leaf' => TRUE);
$domainAdministration[] = array('text' => 'Aliases', 'id' => 'manage-aliases', 'leaf' => TRUE);
$domainAdministration[] = array('text' => 'Catch All Forwards', 'id' => 'catchall-addresses', 'leaf' => TRUE);
$domainAdministration[] = array('text' => 'Domain Administrators', 'id' => 'manage-domain-permissions', 'leaf' => TRUE);
$siteAdministration[] = array('text' => 'Site Administrators', 'id' => 'manage-site-administrators', 'leaf' => TRUE);
$siteAdministration[] = array('text' => 'Virtual to Local Forwards', 'id' => 'manage-local-forwards', 'leaf' => TRUE);
$siteAdministration[] = array('text' => 'Local Aliases', 'id' => 'manage-local-aliases', 'leaf' => TRUE);
if (isDomainAdmin()) {
    $tree[] = array('text' => 'Domain Administration', 'id' => 'domain-administration', 'children' => $domainAdministration);
}
if (isSiteAdmin()) {
    $tree[] = array('text' => 'Site Administration', 'id' => 'site-administration', 'children' => $siteAdministration);
    $stats = array();
    if ($config['stats']['pflogsumm']['enabled']) {
        $stats[] = array('text' => 'Log Summary', 'id' => 'log-summary', 'leaf' => TRUE);
    }
    if ($config['stats']['mailgraph']['enabled']) {
        $stats[] = array('text' => 'Graphs', 'id' => 'graphs', 'children' => array(array('text' => 'Last Day', 'id' => 'last-day-stats', 'leaf' => TRUE), array('text' => 'Last Week', 'id' => 'last-week-stats', 'leaf' => TRUE), array('text' => 'Last Month', 'id' => 'last-month-stats', 'leaf' => TRUE), array('text' => 'Last Year', 'id' => 'last-year-stats', 'leaf' => TRUE)));
    }
    if ($config['stats']['enabled']) {
        $tree[] = array('text' => 'Mail Server Stats', 'id' => 'server-stats', 'children' => $stats);
    }
    if ($config['logs']['enabled']) {
        $tree[] = array('text' => 'Mail Server Log', 'id' => 'mail-log', 'leaf' => TRUE);
    }
}
function addLocalForward($username, $domainId, $destination, $active, $printErrors = TRUE)
{
    if (!isSiteAdmin()) {
        if ($printErrors) {
            print json_encode(array('success' => false, 'errors' => array('username' => 'Permission denied')));
        }
        return FALSE;
    }
    if ($active) {
        $active = 't';
    } else {
        $active = 'f';
    }
    $errors = array();
    $foundError = FALSE;
    if (!$username) {
        $foundError = TRUE;
        $errors['username'] = '******';
    }
    if (!$domainId) {
        $foundError = TRUE;
        $errors['domain'] = 'This field is required';
    }
    if (!$destination) {
        $foundError = TRUE;
        $errors['destination'] = 'This field is required';
    }
    if (!$active) {
        $foundError = TRUE;
        $errors['active'] = 'This field is required';
    }
    if ($foundError) {
        if ($printErrors) {
            print json_encode(array('success' => false, 'errors' => $errors));
        }
        return FALSE;
    }
    $username = strtolower($username);
    if (!validUserName($username)) {
        $foundError = TRUE;
        $errors['username'] = '******';
    }
    $domain = getDomain($domainId);
    if (!$domain) {
        $foundError = TRUE;
        $errors['domain'] = 'Invalid domain';
    }
    if (!validUserName($destination)) {
        $foundError = TRUE;
        $errors['destination'] = 'Invalid destination';
    }
    if ($foundError) {
        if ($printErrors) {
            print json_encode(array('success' => false, 'errors' => $errors));
        }
        return FALSE;
    }
    $email = $username . '@' . $domain;
    if (userExists($email) || localForwardExists($email)) {
        if ($printErrors) {
            print json_encode(array('success' => false, 'errors' => array('username' => 'Username already exists')));
        }
        return FALSE;
    }
    $params = array('username' => $username, 'domain_id' => $domainId, 'destination' => $destination, 'active' => $active);
    return db_insert('virtual_aliases', $params, 'alias_id');
}
<?php

/**
 * Template Name: Admin pages
 *
 * @package WordPress
 * @subpackage comberwedding
 * @since 1.0
 */
if (!isSiteAdmin()) {
    header('Location: ' . home_url());
    die;
}
Starkers_Utilities::get_template_parts(array('parts/shared/html-header', 'parts/shared/header-admin'));
?>

    <section id="primary">
        <div class="medium-8 columns">
            <?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
                <div class="panel">
                    <?php 
        the_content();
        ?>
                </div>
            <?php 
    }
}