Permalink
Browse files

Поехали!

  • Loading branch information...
dketov committed Mar 29, 2012
0 parents commit 09635141b53f7bb70ea87f12ffd4962fc764958d
Showing with 77 additions and 0 deletions.
  1. +58 −0 block_mycourses.php
  2. +5 −0 lang/en/block_mycourses.php
  3. +5 −0 lang/ru/block_mycourses.php
  4. +1 −0 styles.css
  5. +8 −0 version.php
@@ -0,0 +1,58 @@
+<?php
+
+include_once($CFG->dirroot . '/course/lib.php');
+include_once($CFG->dirroot . '/lib/accesslib.php');
+
+class block_mycourses extends block_base {
+ function init() {
+ $this->title = get_string('mycourses');
+ }
+
+ function get_content() {
+ global $CFG, $USER, $DB, $OUTPUT;
+
+ if($this->content !== NULL) {
+ return $this->content;
+ }
+
+ $this->content = new stdClass;
+ $this->content->footer = '';
+
+ $icon = '<img src="' . $OUTPUT->pix_url('i/course') . '" class="icon" alt="" />&nbsp;';
+
+ $coursesbyroles = array();
+ if (isloggedin() && !isguestuser()) {
+ if ($courses = enrol_get_my_courses(NULL, 'fullname ASC')) {
+ foreach ($courses as $course) {
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
+ $roles = get_user_roles($coursecontext, $USER->id);
+ foreach($roles as $role) {
+ if(empty($coursesbyroles[$role->roleid]))
+ {
+ $coursesbyroles[$role->roleid] = new stdClass;
+ $coursesbyroles[$role->roleid]->role = $role;
+ }
+ $coursesbyroles[$role->roleid]->courses[] = $course;
+ }
+ }
+ foreach($coursesbyroles as $r) {
+ $list = array();
+ foreach($r->courses as $course) {
+ $link = new moodle_url('/course/view.php', array('id' => $course->id));
+
+ $list[] = html_writer::link($link, format_string($course->fullname));
+ }
+ $this->content->text .= html_writer::tag('div',
+ html_writer::tag('h3', $r->role->name) .
+ html_writer::tag('ul', html_writer::alist($list)));
+ }
+
+ $this->content->footer = html_writer::link(new moodle_url('/course/index.php'),
+ get_string("fulllistofcourses"));
+ }
+ }
+
+ return $this->content;
+ }
+}
@@ -0,0 +1,5 @@
+<?php
+
+$string['pluginname'] = get_string('mycourses');
+
+?>
@@ -0,0 +1,5 @@
+<?php
+
+$string['pluginname'] = get_string('mycourses');
+
+?>
@@ -0,0 +1 @@
+.block_course_list .footer {margin-top: 5px;}
@@ -0,0 +1,8 @@
+<?php
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2012032900; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->component = 'block_mycourses'; // Full name of the plugin (used for diagnostics)
+
+?>

0 comments on commit 0963514

Please sign in to comment.