-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added: option to make all site users a member of an auto join group
changed: moved some functions
- Loading branch information
Showing
8 changed files
with
265 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
global $CONFIG; | ||
global $GROUP_TOOLS_ACL; | ||
|
||
set_time_limit(0); | ||
|
||
admin_gatekeeper(); | ||
|
||
$group_guid = (int) get_input("group_guid"); | ||
|
||
if(!empty($group_guid)){ | ||
if(($group = get_entity($group_guid)) && ($group instanceof ElggGroup)){ | ||
// set counters | ||
$already = 0; | ||
$new = 0; | ||
$failure = 0; | ||
|
||
$options = array( | ||
"type" => "user", | ||
"relationship" => "member_of_site", | ||
"relationship_guid" => $CONFIG->site_guid, | ||
"inverse_relationship" => true, | ||
"limit" => false, | ||
"callback" => "group_tools_guid_only_callback" | ||
); | ||
|
||
if($user_guids = elgg_get_entities_from_relationship($options)){ | ||
// make sure we can add user to group acl | ||
register_plugin_hook("access:collections:write", "user", "group_tools_add_user_acl_hook"); | ||
$GROUP_TOOLS_ACL = $group->group_acl; | ||
|
||
foreach($user_guids as $user_guid){ | ||
if(!is_group_member($group->getGUID(), $user_guid)){ | ||
if(join_group($group->getGUID(), $user_guid)){ | ||
$new++; | ||
} else { | ||
$failure++; | ||
} | ||
} else { | ||
$already++; | ||
} | ||
|
||
// cleanup cache, to be sure | ||
invalidate_cache_for_entity($user_guid); | ||
} | ||
|
||
// cleanup hook | ||
unregister_plugin_hook("access:collections:write", "user", "group_tools_add_user_acl_hook"); | ||
} | ||
|
||
system_message(sprintf(elgg_echo("group_tools:action:fix_auto_join:success"), $new, $already, $failure)); | ||
} else { | ||
register_error(elgg_echo("group_tools:action:error:entity")); | ||
} | ||
} else { | ||
register_error(elgg_echo("group_tools:action:error:input")); | ||
} | ||
|
||
forward(REFERER); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
function group_tools_add_user_acl_hook($hook, $type, $return_value, $params){ | ||
global $GROUP_TOOLS_ACL; | ||
|
||
$result = $return_value; | ||
|
||
if(!empty($GROUP_TOOLS_ACL) && is_array($result)){ | ||
if(!array_key_exists($GROUP_TOOLS_ACL, $result)){ | ||
$result[$GROUP_TOOLS_ACL] = "temp group"; | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
function group_tools_multiple_admin_can_edit_hook($hook, $type, $return_value, $params){ | ||
$result = $return_value; | ||
|
||
if(!empty($params) && is_array($params) && !$result){ | ||
if(array_key_exists("entity", $params) && array_key_exists("user", $params)){ | ||
$entity = $params["entity"]; | ||
$user = $params["user"]; | ||
|
||
if(($entity instanceof ElggGroup) && ($user instanceof ElggUser)){ | ||
if($entity->isMember($user) && check_entity_relationship($user->getGUID(), "group_admin", $entity->getGUID())){ | ||
$result = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters