本文整理汇总了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();
示例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();
}
}
}