コード例 #1
0
ファイル: subgroups.php プロジェクト: rijojoy/MyIceBerg
function subgroups_get_group_from_url($group_url)
{
    $matches = subgroups_group_url_matches($group_url);
    $group_guid = $matches['group_guid'];
    $group_alias = $matches['group_alias'];
    $group = get_entity($group_guid);
    if (!$group && elgg_is_active_plugin('group_alias')) {
        $group = get_group_from_group_alias($group_alias);
    }
    if ($group && $group->getURL() == $group_url) {
        return $group;
    } else {
        return false;
    }
}
コード例 #2
0
ファイル: start.php プロジェクト: mustafabicer/elggplugins
/**
 * Dispatcher for group alias.
 * URLs take the form of
 *  All groups:       g/
 *  Group profile:    g/<alias>
 *  Group Tools:      g/<alias>/<handler> => <handler>/group/<guid>
 *
 * @param array $page
 * @return bool
 */
function group_alias_page_handler($page)
{
    elgg_set_context('groups');
    if (!isset($page[0])) {
        groups_page_handler(array('all'), 'groups');
        return true;
    }
    $group = get_group_from_group_alias($page[0]);
    if ($group && !isset($page[1])) {
        groups_page_handler(array('profile', $group->guid));
    } elseif ($group && isset($page[1])) {
        forward("{$page['1']}/group/{$group->guid}");
    } else {
        groups_page_handler($page);
    }
    return true;
}
コード例 #3
0
ファイル: edit.php プロジェクト: mustafabicer/elggplugins
foreach ($CONFIG->group as $shortname => $valuetype) {
    // another work around for Elgg's encoding problems: #561, #1963
    $input[$shortname] = get_input($shortname);
    if (is_array($input[$shortname])) {
        array_walk_recursive($input[$shortname], 'profile_array_decoder');
    } else {
        $input[$shortname] = html_entity_decode($input[$shortname], ENT_COMPAT, 'UTF-8');
    }
    if ($valuetype == 'tags') {
        $input[$shortname] = string_to_tag_array($input[$shortname]);
    }
    if ($shortname == 'alias') {
        if (!get_input('group_guid')) {
            try {
                validate_username($input[$shortname]);
                if (!get_input('group_guid') && get_group_from_group_alias($input[$shortname])) {
                    throw new Exception(elgg_echo('groups:alias:already_token'));
                }
            } catch (Exception $e) {
                register_error($e->getMessage());
                forward(REFERER);
            }
        } else {
            unset($input[$shortname]);
        }
    }
}
$input['name'] = get_input('name');
$input['name'] = html_entity_decode($input['name'], ENT_COMPAT, 'UTF-8');
$user = elgg_get_logged_in_user_entity();
$group_guid = (int) get_input('group_guid');
コード例 #4
0
ファイル: start.php プロジェクト: epsylon/Hydra-dev
/**
 * Markup callback
 *
 * Generate HTML markup from linkup patterns, for a single matched
 * pattern. It is used as a regular expression callback.
 *
 * It also takes care of permissions and entity validity, so that no
 * link will be made to unauthorized or non-existing entities.
 * 
 * @return String, the resulting markup
 */
function linkup_markup($matches)
{
    $prefix = $matches[1];
    $marker = $matches[2];
    $subject = $matches[3];
    $text = "{$marker}{$subject}";
    switch ($marker) {
        case "@":
            // user
            if (preg_match("/^[a-z][\\w\\.-]+/i", $subject)) {
                $entity = get_user_by_username($subject);
                $text = linkup_markup_user($entity, $text);
                // TODO elgg_trigger_plugin_hook('mention', 'user');
            }
            break;
        case "!":
            // group
            if (preg_match("/^[0-9]+\$/", $subject)) {
                // Get group by GUID
                $entity = get_entity($subject);
                // TODO if user can access group
            } else {
                if (preg_match("/^[a-z][\\w+-]+\$/i", $subject)) {
                    // Get group by alias
                    if (!elgg_is_active_plugin('group_alias')) {
                        break;
                    }
                    $entity = get_group_from_group_alias($subject);
                }
            }
            $text = linkup_markup_group($entity, $text);
            break;
        case "#":
            // hashtag or task
            if (preg_match("/^[0-9]+\$/", $subject) && elgg_is_active_plugin('tasks')) {
                // Get task by GUID
                $entity = get_entity($subject);
                if (elgg_instanceof($entity, 'object', 'task') || elgg_instanceof($entity, 'object', 'tasklist') || elgg_instanceof($entity, 'object', 'tasklist_top')) {
                    // Linkup task
                    $text = linkup_markup_task($entity, $text);
                    break;
                }
            }
            // Linkup hashtag
            $text = linkup_link($text, "hashtag", "/tag/{$subject}");
            break;
        case "*":
            // entity
            // Check that the subject is a GUID and current user can access
            // the corresponding entity
            if (!preg_match("/^[0-9]+\$/", $subject)) {
                break;
            }
            $entity = get_entity($subject);
            if (elgg_instanceof($entity, 'user')) {
                $text = linkup_markup_user($entity);
            } else {
                if (elgg_instanceof($entity, 'group')) {
                    $text = linkup_markup_group($entity);
                } else {
                    if (elgg_instanceof($entity, 'object', 'task') || elgg_instanceof($entity, 'object', 'tasklist') || elgg_instanceof($entity, 'object', 'tasklist_top')) {
                        $text = linkup_markup_task($entity, $text);
                    } else {
                        if (elgg_instanceof($entity, 'object')) {
                            // get subtype, check permissions, linkup
                            if (!elgg_trigger_plugin_hook('linkup', "object:{$entity->getSubtype()}", array('entity' => $entity))) {
                                // Default object view
                                $text = linkup_markup_object($entity);
                            }
                        }
                    }
                }
            }
            break;
    }
    return "{$prefix}{$text}";
}
コード例 #5
0
ファイル: activate.php プロジェクト: mustafabicer/elggplugins
<?php

/**
 * Group Alias activation script
 * It sets an alias if group hasn't.
 */
foreach (elgg_get_entities(array('type' => 'group')) as $group) {
    if (!$group->alias) {
        $alias = elgg_get_friendly_title($group->name);
        $alias = preg_replace("/-/", "_", $alias);
        // If alias is token
        if (get_group_from_group_alias($alias)) {
            $alias .= $group->guid;
        }
        $group->alias = $alias;
        $group->save();
    }
}