Ejemplo n.º 1
0
function subsite_manager_plugins_boot()
{
    // handle run once functions
    run_function_once("subsite_manager_runonce");
    run_function_once("subsite_manager_runonce_elgg18");
    // Check if current user should be a admin of this site
    if ($user = elgg_get_logged_in_user_entity()) {
        // don't check for super admins
        if (!subsite_manager_is_superadmin($user->getGUID())) {
            // where are we
            if (subsite_manager_on_subsite()) {
                // is the user suppose to be an admin
                if (elgg_get_site_entity()->isAdmin($user->getGUID())) {
                    // is the user currently an admin
                    if (!$user->isAdmin()) {
                        $user->makeAdmin();
                    }
                } elseif ($user->isAdmin()) {
                    // user is an admin, but shouldn't be
                    $user->removeAdmin();
                }
            } elseif ($user->isAdmin()) {
                // user is an admin, but shouldn't be
                $user->removeAdmin();
            }
        }
    }
    // check the site email address
    $config_email = elgg_get_config("siteemail");
    $site = elgg_get_site_entity();
    if (empty($config_email) || $site->email != $config_email) {
        elgg_set_config("siteemail", $site->email);
    }
}
Ejemplo n.º 2
0
/**
 * Check if the given user has full access.
 *
 * @todo: Will always return full access if the user is an admin.
 *
 * @param int $user_guid The user to check
 *
 * @return bool
 * @since 1.7.1
 */
function elgg_is_admin_user($user_guid)
{
    global $CONFIG;
    // cannot use magic metadata here because of recursion
    return subsite_manager_is_superadmin($user_guid);
    // must support the old way of getting admin from metadata
    // in order to run the upgrade to move it into the users table.
    // 	$version = (int) datalist_get('version');
    // 	if ($version < 2010040201) {
    // 		$admin = get_metastring_id('admin');
    // 		$yes = get_metastring_id('yes');
    // 		$one = get_metastring_id('1');
    // 		$query = "SELECT * FROM {$CONFIG->dbprefix}users_entity as e,
    // 			{$CONFIG->dbprefix}metadata as md
    // 			WHERE (
    // 				md.name_id = '$admin'
    // 				AND md.value_id IN ('$yes', '$one')
    // 				AND e.guid = md.entity_guid
    // 				AND e.guid = {$user_guid}
    // 				AND e.banned = 'no'
    // 			)";
    // 	} else {
    // 		$query = "SELECT * FROM {$CONFIG->dbprefix}users_entity as e
    // 			WHERE (
    // 				e.guid = {$user_guid}
    // 				AND e.admin = 'yes'
    // 			)";
    // 	}
    // 	// normalizing the results from get_data()
    // 	// See #1242
    // 	$info = get_data($query);
    // 	if (!((is_array($info) && count($info) < 1) || $info === FALSE)) {
    // 		return TRUE;
    // 	}
    // 	return FALSE;
}
Ejemplo n.º 3
0
function subsite_manager_check_subsite_user()
{
    if (!elgg_is_logged_in()) {
        return;
    }
    $site = elgg_get_site_entity();
    if (!elgg_instanceof($site, "site", Subsite::SUBTYPE, "Subsite")) {
        return;
    }
    if ($site->isUser() || subsite_manager_is_superadmin()) {
        return;
    }
    if (!isset($_SESSION['msg'])) {
        $_SESSION['msg'] = array();
    }
    if (!isset($_SESSION['msg']['success'])) {
        $_SESSION['msg']['success'] = array();
    }
    if (elgg_in_context('groups')) {
        // remove message when viewing group pages
        $_SESSION['msg']['success'] = array_diff($_SESSION['msg']['success'], array(elgg_echo("subsite_manager:subsite:wanttojoin")));
    } else {
        if (!is_array($_SESSION['msg']['success'])) {
            $_SESSION['msg']['success'] = array();
        }
        // show message for non-members of subsite
        if (!in_array(elgg_echo("subsite_manager:subsite:wanttojoin"), $_SESSION['msg']['success'])) {
            array_push($_SESSION['msg']['success'], elgg_echo("subsite_manager:subsite:wanttojoin"));
        }
    }
}
Ejemplo n.º 4
0
function subsite_manager_admin_user_delete_hook($hook, $type, $returnvalue, $params)
{
    if (!subsite_manager_is_superadmin()) {
        return false;
    }
}