// 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();
/** * 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(); } } }