当前位置: 首页>>代码示例>>PHP>>正文


PHP ElggGroup::addRelationship方法代码示例

本文整理汇总了PHP中ElggGroup::addRelationship方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggGroup::addRelationship方法的具体用法?PHP ElggGroup::addRelationship怎么用?PHP ElggGroup::addRelationship使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElggGroup的用法示例。


在下文中一共展示了ElggGroup::addRelationship方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ElggFile

// in the action or the visibility moves to a plugin hook
if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
    $visibility = (int) get_input('vis', '', false);
    if ($visibility != ACCESS_PUBLIC && $visibility != ACCESS_LOGGED_IN) {
        $visibility = $group->group_acl;
    }
    if ($group->access_id != $visibility) {
        $group->access_id = $visibility;
    }
}
// if a parent guid is specified, add a relationship between both groups
if ($parent_guid) {
    $parentgroup = get_entity($parent_guid);
    if ($parentgroup) {
        $parentgroup->addRelationship($group->guid, 'child');
        $group->addRelationship($parentgroup->guid, 'parent');
        $parentgroup->save();
    }
}
$group->save();
// group creator needs to be member of new group and river entry created
if ($new_group_flag) {
    elgg_set_page_owner_guid($group->guid);
    $group->join($user);
    add_to_river('river/group/create', 'create', $user->guid, $group->guid, $group->access_id);
}
// Now see if we have a file icon
if (isset($_FILES['icon']) && substr_count($_FILES['icon']['type'], 'image/')) {
    $icon_sizes = elgg_get_config('icon_sizes');
    $prefix = "groups/" . $group->guid;
    $filehandler = new ElggFile();
开发者ID:remy40,项目名称:gvrs,代码行数:31,代码来源:edit.php

示例2: create_local_groups

/**
 * Create all local groups
 */
function create_local_groups()
{
    // first, creates country groups
    $countrygroup_guid = array();
    $options["type"] = 'group';
    $options["limit"] = NULL;
    $options["metadata_name_value_pairs"][] = array("name" => 'grouptype', "value" => 'local');
    $options["metadata_name_value_pairs"][] = array("name" => 'localtype', "value" => 'national');
    $existing_countrygroups = elgg_get_entities_from_metadata($options);
    $country_data = get_country_data();
    foreach ($country_data as $country) {
        if (!is_group_name_existing($country, $existing_countrygroups)) {
            $group = new ElggGroup();
            $group->name = $country;
            $group->description = "";
            $group->grouptype = 'local';
            $group->localtype = 'national';
            $group->membership = ACCESS_PUBLIC;
            $group->access_id = ACCESS_LOGGED_IN;
            $group->save();
            $countrygroup_guid[$country] = $group->guid;
        }
    }
    // then, creates departement groups
    $depgroup_guids = array();
    $options["type"] = 'group';
    $options["limit"] = NULL;
    $options["metadata_name_value_pairs"][] = array("name" => 'grouptype', "value" => 'local');
    $options["metadata_name_value_pairs"][] = array("name" => 'localtype', "value" => 'departemental');
    $existing_depgroups = elgg_get_entities_from_metadata($options);
    $departements_data = get_departement_data();
    foreach ($departements_data as $num => $name) {
        $groupname = $num . " - " . $name;
        if (!is_group_name_existing($groupname, $existing_depgroups)) {
            $group = new ElggGroup();
            $group->name = $groupname;
            $group->description = "";
            $group->grouptype = 'local';
            $group->localtype = 'departemental';
            $group->membership = ACCESS_PUBLIC;
            $group->access_id = ACCESS_LOGGED_IN;
            $group->save();
            $depgroup_guids[$num] = $group->guid;
        }
    }
    // finally, creates region groups
    $options["metadata_name_value_pairs"] = array(array('name' => 'grouptype', 'value' => 'local', 'operand' => '=', 'case_sensitive' => TRUE), array('name' => 'localtype', 'value' => 'regional', 'operand' => '=', 'case_sensitive' => TRUE));
    $existing_region_groups = elgg_get_entities_from_metadata($options);
    $regions_data = get_region_data();
    foreach ($regions_data as $name => $dep_nums) {
        if (!is_group_name_existing($name, $existing_region_groups)) {
            $group = new ElggGroup();
            $group->name = $name;
            $group->grouptype = 'local';
            $group->localtype = 'regional';
            $group->membership = ACCESS_PUBLIC;
            $group->access_id = ACCESS_LOGGED_IN;
            $group->save();
            //add relationship with departement groups
            foreach ($dep_nums as $num) {
                $depgroup = get_entity($depgroup_guids[$num]);
                if ($depgroup) {
                    $group->addRelationship($depgroup->guid, 'child');
                    $depgroup->addRelationship($group->guid, 'parent');
                    $depgroup->save();
                }
            }
            // add relationship with country group
            $countrygroup = get_entity($countrygroup_guid['France']);
            if ($countrygroup) {
                $countrygroup->addRelationship($group->guid, 'child');
                $group->addRelationship($countrygroup->guid, 'parent');
                $countrygroup->save();
            }
            $group->save();
        }
    }
}
开发者ID:remy40,项目名称:gvrs,代码行数:81,代码来源:groups.php


注:本文中的ElggGroup::addRelationship方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。