Skip to content

Commit

Permalink
Merge branch 'w30_MDL-34129_m24_enrolinfo' of git://github.com/skodak…
Browse files Browse the repository at this point in the history
…/moodle
  • Loading branch information
danpoltawski committed Jul 24, 2012
2 parents 5082d87 + cb76fec commit 1011757
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
34 changes: 2 additions & 32 deletions course/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,8 @@
echo $OUTPUT->box_end();
}

echo $OUTPUT->box_start('generalbox info');

$course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
echo format_text($course->summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);

if (!empty($CFG->coursecontact)) {
$coursecontactroles = explode(',', $CFG->coursecontact);
foreach ($coursecontactroles as $roleid) {
if ($users = get_role_users($roleid, $context, true)) {
foreach ($users as $teacher) {
$role = new stdClass();
$role->id = $teacher->roleid;
$role->name = $teacher->rolename;
$role->shortname = $teacher->roleshortname;
$role->coursealias = $teacher->rolecoursealias;
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
$namesarray[] = role_get_name($role, $context).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
$teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';
}
}
}

if (!empty($namesarray)) {
echo "<ul class=\"teachers\">\n<li>";
echo implode('</li><li>', $namesarray);
echo "</li></ul>";
}
}

// TODO: print some enrol icons

echo $OUTPUT->box_end();
$courserenderer = $PAGE->get_renderer('core', 'course');
echo $courserenderer->course_info_box($course);

echo "<br />";

Expand Down
45 changes: 45 additions & 0 deletions course/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,51 @@ public function __construct(moodle_page $page, $target) {
parent::__construct($page, $target);
}

/**
* Renders course info box.
*
* @param stdClass $course
* @return string
*/
public function course_info_box(stdClass $course) {
global $CFG;

$context = context_course::instance($course->id);

$content = '';
$content .= $this->output->box_start('generalbox info');

$summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
$content .= format_text($summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);
if (!empty($CFG->coursecontact)) {
$coursecontactroles = explode(',', $CFG->coursecontact);
foreach ($coursecontactroles as $roleid) {
if ($users = get_role_users($roleid, $context, true)) {
foreach ($users as $teacher) {
$role = new stdClass();
$role->id = $teacher->roleid;
$role->name = $teacher->rolename;
$role->shortname = $teacher->roleshortname;
$role->coursealias = $teacher->rolecoursealias;
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
$namesarray[] = role_get_name($role, $context).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
$teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';
}
}
}

if (!empty($namesarray)) {
$content .= "<ul class=\"teachers\">\n<li>";
$content .= implode('</li><li>', $namesarray);
$content .= "</li></ul>";
}
}

$content .= $this->output->box_end();

return $content;
}

/**
* Renderers a structured array of courses and categories into a nice
* XHTML tree structure.
Expand Down
3 changes: 3 additions & 0 deletions enrol/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('enrolmentoptions','enrol'));

$courserenderer = $PAGE->get_renderer('core', 'course');
echo $courserenderer->course_info_box($course);

//TODO: find if future enrolments present and display some info

foreach ($forms as $form) {
Expand Down

0 comments on commit 1011757

Please sign in to comment.