function notify_student($user, $a, $referral = null) { if (!$referral) { $referral = $this->reason; } // Is this a praise? if ($referral->source == 3) { $suffix = '_praise'; } else { if ($referral->source == 4) { $suffix = '_recovered'; } else { $suffix = ''; } } // If the student is an athlete $athletic = ''; $athlete = is_student_athlete($user); if ($athlete) { $athletic = 'athletic_'; $mentors = lookup_athletic_mentors($user); $a->mentor = $this->format_mentors($mentors, 'names'); $a->mentor_email = $this->format_mentors($mentors, 'email'); } $a->sender = fullname($this->user); $moodle_user = get_record('user', 'id', $user->moodleid); $subject = get_string($athletic . 'referral_subject' . $suffix, 'block_student_gradeviewer', $a); $body = get_string($athletic . 'referral' . $suffix, 'block_student_gradeviewer', $a); $code = email_to_user($moodle_user, $this->user, $subject, $body); $code = $code ? 'success' : 'fail'; //mtrace(get_string($code, 'block_student_gradeviewer')); }
/** * Returns mentors for a student */ function lookup_mentors($mentee) { // First see if the user is an athlete; if they are, // then return athletic mentors if (count_records('block_courseprefs_sportusers', 'usersid', $mentee->id) >= 1) { return lookup_athletic_mentors($mentee); } global $CFG; $admin_role = get_config('', 'block_student_gradeviewer_cas_admin'); $path_perm = array("{$mentee->year}/NA/NA", "{$mentee->year}/{$mentee->college}/NA", "{$mentee->year}/{$mentee->college}/{$mentee->classification}", "{$mentee->year}/NA/{$mentee->classification}", "NA/{$mentee->college}/{$mentee->classification}", "NA/{$mentee->college}/NA", "NA/NA/{$mentee->classification}"); $sql = get_mentor_sql($admin_role, $mentee) . "\n (SELECT u.*\n FROM {$CFG->prefix}user u,\n {$CFG->prefix}block_student_academics aa\n WHERE u.id = aa.usersid\n AND aa.path IN ('" . implode("','", $path_perm) . "'))"; return get_records_sql($sql); }