/**
 * Create a new Blackboard Collaborate account for the supplied Moodle user ID.
 *
 * @param int $userid The Moodle user ID.
 * @return object|boolean The Blackboard Collaborate user object on success, False otherwise.
 */
function elluminate_new_user($userid, $password)
{
    if (!($user = $DB->get_record('user', array('id' => $userid)))) {
        return false;
    }
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    /// Determine what role to create this user as.
    $role = ELLUMINATELIVE_ROLE_PARTICIPANT;
    /// Admin = Application Administrator
    if (isadmin($user->id)) {
        $role = ELLUMINATELIVE_ROLE_APPADMIN;
        /// Editing Teachers = Moderator
    } else {
        if (has_capability('mod/elluminate:moderatemeeting', $context, $user->id)) {
            $role = ELLUMINATELIVE_ROLE_MODERATOR;
        }
    }
    /// Let's give it a whirl!
    $result = elluminate_create_user($user->username, $password, $user->email, $user->firstname, $user->lastname, $role);
    if (!empty($result)) {
        return $result;
    }
    debugging('Could not create ELM user account for ' . fullname($user), DEBUG_DEVELOPER);
    return false;
}
/**
 * Create a new Elluminate Live! account for the supplied Moodle user ID.
 *
 * @param int $userid The Moodle user ID.
 * @return object|boolean The Elluminate Live! user object on success, False otherwise.
 */
function elluminate_new_user($userid, $password)
{
    if (!($user = get_record('user', 'id', $userid))) {
        return false;
    }
    /// Determine what role to create this user as.
    $role = ELLUMINATELIVE_ROLE_PARTICIPANT;
    /// Admin = Application Administrator
    if (isadmin($user->id)) {
        $role = ELLUMINATELIVE_ROLE_APPADMIN;
        /// Editing Teachers = Moderator
    } else {
        if (isteacherinanycourse($user->id)) {
            $role = ELLUMINATELIVE_ROLE_MODERATOR;
        }
    }
    /// Let's give it a whirl!
    $result = elluminate_create_user($user->username, $password, $user->email, $user->firstname, $user->lastname, $role);
    if (!empty($result)) {
        return $result;
    }
    debugging('Could not create ELM user account for ' . fullname($user), DEBUG_DEVELOPER);
    return false;
}