diff --git a/blocks/recent_activity/block_latest_activities.php b/blocks/recent_activity/block_latest_activities.php new file mode 100644 index 00000000000..d9ddfa02fb8 --- /dev/null +++ b/blocks/recent_activity/block_latest_activities.php @@ -0,0 +1,62 @@ +title = get_string('blockname','block_latest_activities'); + $this->version = 2005031400; + } + + function has_config() {return true;} + + function applicable_formats() { + return (array('course-view-weeks' => true, 'course-view-topics' => true)); + } + + function get_content() { + global $CFG, $USER; + + if ($this->content !== NULL) { + return $this->content; + } + + $this->content = new stdClass; + $this->content->text = ''; + $this->content->footer = ''; + + if (empty($this->instance)) { + return $this->content; + } + + $course = get_record('course', 'id', $this->instance->pageid); + + $activitiestosee = 5; //Activities default + if (isset($CFG->block_latest_activities_number)) { + $activitiestosee = $CFG->block_latest_activities_number; + } + + $activities = get_records_sql("SELECT l.id, l.cmid, l.module, l.time + FROM {$CFG->prefix}course_modules m, + {$CFG->prefix}log l + WHERE l.cmid = m.id AND + l.userid = $USER->id AND + l.course = $course->id AND + m.visible = 1 + ORDER BY l.time DESC ". + sql_paging_limit(0,$activitiestosee)); + + $modinfo = unserialize($course->modinfo); + + if (!empty($activities) && !empty($modinfo)) { + foreach ($activities as $activity) { + $activity->name = urldecode($modinfo[$activity->cmid]->name); + $activity->timeago = format_time(time() - $activity->time); + $this->content->text .= '
'; + $this->content->text .= ''.$activity->name.''; + $this->content->text .= '
'; + } + } + return $this->content; + } +} + +?> diff --git a/blocks/recent_activity/config_global.html b/blocks/recent_activity/config_global.html new file mode 100644 index 00000000000..e887cb344f0 --- /dev/null +++ b/blocks/recent_activity/config_global.html @@ -0,0 +1,21 @@ + + + + + + + + + +
block_latest_activities_number: + + + + +
+
diff --git a/blocks/recent_activity/lang/en/block_latest_activities.php b/blocks/recent_activity/lang/en/block_latest_activities.php new file mode 100644 index 00000000000..ac5e19cda01 --- /dev/null +++ b/blocks/recent_activity/lang/en/block_latest_activities.php @@ -0,0 +1,6 @@ + diff --git a/blocks/recent_activity/lang/es/block_latest_activities.php b/blocks/recent_activity/lang/es/block_latest_activities.php new file mode 100644 index 00000000000..3593ad60ca3 --- /dev/null +++ b/blocks/recent_activity/lang/es/block_latest_activities.php @@ -0,0 +1,6 @@ +