Exemplo n.º 1
0
 function test_get_user()
 {
     $this->assertTrue($user = groups_get_user(2));
     //Primary admin.
     if (isset($user)) {
         $this->userid = $user->id;
     }
     $this->assertTrue($user_2 = groups_get_user(1));
     //Guest.
     if (isset($user_2)) {
         $this->userid_2 = $user_2->id;
     }
 }
Exemplo n.º 2
0
 /**
  * setUp/tearDown: Better in a constructor/destructor, but PHP4 doesn't do destructors :(
  */
 function setUp()
 {
     parent::setUp();
     if ($course = groups_get_course_info(1)) {
         $this->courseid = $course->id;
     }
     if ($user = groups_get_user(2)) {
         //Primary admin.
         $this->userid = $user->id;
     }
     $this->groupid = groups_create_group($this->courseid);
     $groupinfo = groups_set_default_group_settings();
     $bok = groups_set_group_settings($this->groupid, $groupinfo);
     $bok = groups_add_member($this->groupid, $this->userid);
 }
Exemplo n.º 3
0
/**
 * Returns the display name of a user - the full name of the user 
 * prefixed by '#' for editing teachers and '-' for teachers.
 * @param int $userid The ID of the user.
 * @param int $courseid The ID of the related-course.
 * @return string The display name of the user.
 */
function groups_get_user_displayname($userid, $courseid)
{
    if ($courseid == false) {
        $fullname = false;
    } else {
        $user = groups_get_user($userid);
        $fullname = fullname($user, true);
        //TODO: isteacher, isteacheredit.
        if (isteacher($courseid, $userid)) {
            if (isteacheredit($courseid, $userid)) {
                $prefix = '# ';
            } else {
                $prefix = '- ';
            }
            $fullname = $prefix . $fullname;
        }
    }
    return $fullname;
}