コード例 #1
0
admin_gatekeeper();
// this could take a while ;)
set_time_limit(0);
$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" => elgg_get_site_entity()->getGUID(), "inverse_relationship" => true, "limit" => false, "callback" => "group_tools_guid_only_callback");
        if ($user_guids = elgg_get_entities_from_relationship($options)) {
            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);
            }
        }
        system_message(elgg_echo("group_tools:action:fix_auto_join:success", array($new, $already, $failure)));
    } else {
        register_error(elgg_echo("group_tools:action:error:entity"));
    }
コード例 #2
0
ファイル: move.php プロジェクト: lorea/Hydra-dev
         break;
 }
 $subgroup->save();
 //now we need to make sure that all members of the new subgroup are
 // members of the parent group
 // get all members of the subgroup - any members of subgroups have to be in this anyway
 global $AU_SUBGROUPS_ALL_MEMBERS;
 $AU_SUBGROUPS_ALL_MEMBERS = array();
 $options = array('relationship' => 'member', 'relationship_guid' => $subgroup->guid, 'inverse_relationship' => TRUE, 'type' => 'user', 'limit' => false);
 $batch = new ElggBatch('elgg_get_entities_from_relationship', $options, 'au_subgroups_get_all_members', 25);
 $AU_SUBGROUPS_ALL_MEMBERS = array_unique($AU_SUBGROUPS_ALL_MEMBERS);
 // array of user guids we need to invite back into the group
 $invite = array();
 foreach ($AU_SUBGROUPS_ALL_MEMBERS as $member_guid) {
     if (!is_group_member($parent_guid, $member_guid)) {
         join_group($parent_guid, $member_guid);
         $user = get_user($member_guid);
         if ($user) {
             // notify the user
             $url = elgg_normalize_url("groups/invitations/{$user->username}");
             notify_user($member_guid, $parent->owner_guid, elgg_echo('au_subgroups:moveto:subject', array($user->name, $subgroup->name, $parent->name, $parent->name)), elgg_echo('au_subgroups:moveto:body', array($user->name, $subgroup->name, $parent->name, $parent->name, $url)));
         }
         /*$invite[] = $member_guid;
         	// the user isn't a member of the parent group
         	// so we have to remove them from this subgroup, and all subgroups of this subgroup
         	// and send them an invitation
         	// we'll set a plugin setting on the user, which we'll monitor for when they accept the invitation
         	$groups_left = array($subgroup_guid);
         	
         	foreach ($child_groups as $child_guid) {
         	  if (is_group_member($child_guid, $member_guid)) {
コード例 #3
0
ファイル: ElggGroup.php プロジェクト: elainenaomi/labxp2014
 /**
  * Join an elgg user to this group.
  *
  * @param ElggUser $user User
  *
  * @return bool
  */
 public function join(ElggUser $user)
 {
     return join_group($this->getGUID(), $user->getGUID());
 }
コード例 #4
0
 //Fetch queued players and invite them
 $successful_invites = array();
 $number = $left - $invites_now;
 $mysql_query = mysql_query("SELECT * FROM queued_invitations WHERE groupid=\"" . $plugin_groupid[$i] . "\" LIMIT 0, " . $number);
 if (mysql_num_rows($mysql_query) > 0) {
     mysql_query("UPDATE groups SET locked=1 WHERE groupid=\"" . $plugin_groupid[$i] . "\"");
     while ($player = mysql_fetch_assoc($mysql_query)) {
         //foreach($plugin_groupid AS $comid)
         //{
         $result = invite_player($steam_communityid, $player["communityid"], $plugin_groupid[$i], $steam_cookie, $sessionid, $ip, $user_agent);
         //$log .= $result;
         if (preg_match("/\\<\\!\\[CDATA\\[OK\\]\\]\\>/", $result)) {
             mysql_query("INSERT INTO invitations_sent (communityid, accountid, groupid, serverip, time) VALUES(\"" . $player["communityid"] . "\", " . $user["id"] . ", \"" . $plugin_groupid[$i] . "\", \"" . $ip . "\", " . time() . ")");
         } else {
             if (preg_match("/permission/", $result)) {
                 join_group($plugin_groupid[$i], $steam_cookie, $sessionid, $ip, $user_agent);
                 $result = invite_player($steam_communityid, $player["communityid"], $plugin_groupid[$i], $steam_cookie, $sessionid, $ip, $user_agent);
                 if (preg_match("/\\<\\!\\[CDATA\\[OK\\]\\]\\>/", $result)) {
                     $invites_now++;
                     mysql_query("INSERT INTO invitations_sent (communityid, accountid, groupid, serverip, time) VALUES(\"" . $player["communityid"] . "\", " . $user["id"] . ", \"" . $plugin_groupid[$i] . "\", \"" . $ip . "\", " . time() . ")");
                 }
             }
         }
         //}
         $successful_invites[] = $player["communityid"];
     }
     //Delete successfully invited players from database
     $mysql_query_string = "DELETE FROM queued_invitations WHERE groupid=\"" . $plugin_groupid[$i] . "\" AND (";
     for ($a = 0; $a < count($successful_invites); ++$a) {
         $mysql_query_string .= " communityid=\"" . $successful_invites[$a] . "\"";
         if ($a + 1 != count($successful_invites)) {