Exemplo n.º 1
0
        foreach ($potentialmembers as $userid) {
            $nonmembers[$userid] = groups_get_user_displayname($userid, $courseid);
            $potentialmemberscount++;
        }
        natcasesort($nonmembers);
        // Print out the HTML
        foreach ($nonmembers as $id => $name) {
            $potentialmembersoptions .= "<option value=\"{$id}\">{$name}</option>\n";
        }
    } else {
        $potentialmembersoptions .= '<option>&nbsp;</option>';
    }
    // Print the page and form
    $strgroups = get_string('groups');
    $strparticipants = get_string('participants');
    $groupname = groups_get_group_displayname($groupid);
    print_header("{$course->shortname}: {$strgroups}", $course->fullname, "<a href=\"{$CFG->wwwroot}/course/view.php?id={$courseid}\">{$course->shortname}</a> " . "-> <a href=\"{$CFG->wwwroot}/user/index.php?id={$courseid}\">{$strparticipants}</a> " . '-> <a href="' . format_string(groups_home_url($courseid, $groupid, $groupingid, false)) . "\">{$strgroups}</a>" . '-> ' . get_string('adduserstogroup', 'group'), '', '', true, '', user_login_string($course, $USER));
    ?>
<div id="addmembersform">
    <h3 class="main"><?php 
    print_string('adduserstogroup', 'group');
    echo " {$groupname}";
    ?>
</h3>

    <form id="assignform" method="post" action="">
    <div>
    <input type="hidden" name="sesskey" value="<?php 
    p(sesskey());
    ?>
" />
Exemplo n.º 2
0
/**
 * Get a sorted array of group-id/display-name objects.
 * @param array $groupids Array of group IDs
 * @param bool $justnames Return names only as values, not objects. Needed
 *   for print_group_menu in weblib
 * @return array If $justnames is set, returns an array of id=>name. Otherwise
 *   returns an array without specific keys of objects containing id, name
 */
function groups_groupids_to_group_names($groupids, $justnames = false)
{
    if (!$groupids) {
        return array();
    }
    $group_names = array();
    foreach ($groupids as $id) {
        $gname = new object();
        $gname->id = $id;
        $gname->name = groups_get_group_displayname($id);
        $group_names[] = $gname;
    }
    if (!usort($group_names, 'groups_compare_name')) {
        debug('Error usort [groups_compare_name].');
    }
    /*// Put the groups into a hash and sort them
        foreach($groupids as $id) {
            $listgroups[$id] = groups_get_group_displayname($id);
        }
        natcasesort($listgroups);
    
        $group_names = array();
        foreach ($listgroups as $id => $name) {
            $gname = new object;
            $gname->id = $id;
            $gname->name = $name;
            $group_names[] = $gname;
        }*/
    if ($justnames) {
        $namesonly = array();
        foreach ($group_names as $id => $object) {
            $namesonly[$object->id] = $object->name;
        }
        return $namesonly;
    }
    return $group_names;
}