Da monster-commit of blocks version 2!
Code based on the work of Daryl Hawes for the blog module. Thanks, Daryl! Please test the hell out of it as it's sure to have issues that need to be ironed out.
This commit is contained in:
+3
-3
@@ -20,12 +20,12 @@
|
||||
|
||||
require_variable($_REQUEST['block']);
|
||||
$blockid = intval($_REQUEST['block']);
|
||||
|
||||
if(($blockrecord = get_record('blocks', 'id', $blockid)) === false) {
|
||||
|
||||
if(($blockrecord = blocks_get_record($blockid)) === false) {
|
||||
error('This block does not exist');
|
||||
}
|
||||
|
||||
$block = block_instance($blockrecord->name, NULL);
|
||||
$block = block_instance($blockrecord->name);
|
||||
if($block === false) {
|
||||
error('Problem in instantiating block object');
|
||||
}
|
||||
|
||||
+58
-25
@@ -5,11 +5,11 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/blocklib.php');
|
||||
|
||||
optional_variable($_GET['hide']);
|
||||
optional_variable($_GET['show']);
|
||||
optional_variable($_GET['delete']);
|
||||
optional_variable($_GET['confirm'], 0);
|
||||
$delete = $_GET['delete']; // Dependency remover
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_INT);
|
||||
$multiple = optional_param('multiple', 0, PARAM_INT);
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -32,8 +32,9 @@
|
||||
$strhide = get_string('hide');
|
||||
$strshow = get_string('show');
|
||||
$strsettings = get_string('settings');
|
||||
$strcourses = get_string('courses');
|
||||
$strcourses = get_string('blockinstances', 'admin');
|
||||
$strname = get_string('name');
|
||||
$strmultiple = get_string('blockmultiple', 'admin');
|
||||
|
||||
print_header("$site->shortname: $strmanageblocks", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
@@ -44,27 +45,35 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($_GET['hide']) and confirm_sesskey()) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['hide'])) {
|
||||
if (!empty($hide) && confirm_sesskey()) {
|
||||
if (!$block = get_record('block', 'id', $hide)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('blocks', 'visible', '0', 'id', $block->id); // Hide block
|
||||
set_field('block', 'visible', '0', 'id', $block->id); // Hide block
|
||||
}
|
||||
|
||||
if (!empty($_GET['show']) and confirm_sesskey() ) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['show'])) {
|
||||
if (!empty($show) && confirm_sesskey() ) {
|
||||
if (!$block = get_record('block', 'id', $show)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('blocks', 'visible', '1', 'id', $block->id); // Show block
|
||||
set_field('block', 'visible', '1', 'id', $block->id); // Show block
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
if (!empty($multiple) && confirm_sesskey()) {
|
||||
if (!$block = blocks_get_record($multiple)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
$block->multiple = !$block->multiple;
|
||||
update_record('block', $block);
|
||||
}
|
||||
|
||||
if (!$block = get_record('blocks', 'id', $delete)) {
|
||||
if (!empty($delete) && confirm_sesskey()) {
|
||||
|
||||
if (!$block = blocks_get_record($delete)) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
|
||||
$blockobject = block_instance($block->name, $site);
|
||||
$blockobject = block_instance($block->name);
|
||||
$strblockname = $blockobject->get_title();
|
||||
|
||||
if (!$_GET['confirm']) {
|
||||
@@ -76,11 +85,16 @@
|
||||
|
||||
} else {
|
||||
// Delete block
|
||||
if (!delete_records('blocks', 'id', $block->id)) {
|
||||
if (!delete_records('block', 'id', $block->id)) {
|
||||
notify("Error occurred while deleting the $strblockname record from blocks table");
|
||||
}
|
||||
|
||||
blocks_update_every_block_by_id($block->id, 'delete'); // Delete blocks in all courses by id
|
||||
$instances = get_records('block_instance', 'blockid', $block->id);
|
||||
if(!empty($instances)) {
|
||||
foreach($instances as $instance) {
|
||||
blocks_delete_instance($instance);
|
||||
}
|
||||
}
|
||||
|
||||
// Then the tables themselves
|
||||
|
||||
@@ -105,12 +119,12 @@
|
||||
|
||||
/// Get and sort the existing blocks
|
||||
|
||||
if (false === ($blocks = get_records('blocks'))) {
|
||||
if (false === ($blocks = get_records('block'))) {
|
||||
error('No blocks found!'); // Should never happen
|
||||
}
|
||||
|
||||
foreach ($blocks as $block) {
|
||||
if(($blockobject = block_instance($block->name, NULL)) === false) {
|
||||
if(($blockobject = block_instance($block->name)) === false) {
|
||||
// Failed to load
|
||||
continue;
|
||||
}
|
||||
@@ -136,11 +150,11 @@
|
||||
//$modpixpath = '../theme/'.$CFG->theme.'/pix/mod';
|
||||
}
|
||||
|
||||
$table->head = array ($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings);
|
||||
$table->align = array ('LEFT', 'RIGHT', 'LEFT', 'CENTER', 'CENTER', 'CENTER');
|
||||
$table->wrap = array ("NOWRAP", "", "", "", "","");
|
||||
$table->size = array ("100%", "10", "10", "10", "10","12");
|
||||
$table->width = "100";
|
||||
$table->head = array ($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings);
|
||||
$table->align = array ('LEFT', 'RIGHT', 'LEFT', 'CENTER', 'CENTER', 'CENTER', 'CENTER');
|
||||
$table->wrap = array ('NOWRAP', '', '', '', '', '', '');
|
||||
$table->size = array ('100%', '10', '10', '10', '10','12');
|
||||
$table->width = '100';
|
||||
|
||||
foreach ($blockbyname as $blockname => $blockid) {
|
||||
|
||||
@@ -155,7 +169,7 @@
|
||||
$settings = '<a href="block.php?block='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strsettings.'</a>';
|
||||
}
|
||||
|
||||
$count = blocks_get_courses_using_block_by_id($blockid);
|
||||
$count = count_records('block_instance', 'blockid', $blockid);
|
||||
$class = ''; // Nothing fancy, by default
|
||||
|
||||
if ($blocks[$blockid]->visible) {
|
||||
@@ -166,8 +180,27 @@
|
||||
'<img src="'.$pixpath.'/i/show.gif" style="height: 16px; width: 16px;" alt=\"\" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
if ($blockobject->instance_allow_multiple()) {
|
||||
if($blocks[$blockid]->multiple) {
|
||||
$multiple = '<nobr>'.get_string('yes').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</nobr>';
|
||||
}
|
||||
else {
|
||||
$multiple = '<nobr>'.get_string('no').' (<a href="blocks.php?multiple='.$blockid.'&sesskey='.$USER->sesskey.'">'.get_string('change', 'admin').'</a>)</nobr>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$multiple = '';
|
||||
}
|
||||
|
||||
$table->data[] = array ('<p'.$class.'>'.$blockobject->get_title().'</p>', $count, $blockobject->get_version(), $visible, $delete, $settings);
|
||||
$table->data[] = array(
|
||||
'<p'.$class.'>'.$blockobject->get_title().'</p>',
|
||||
$count,
|
||||
$blockobject->get_version(),
|
||||
$visible,
|
||||
$multiple,
|
||||
$delete,
|
||||
$settings
|
||||
);
|
||||
}
|
||||
echo '<p>';
|
||||
print_table($table);
|
||||
|
||||
+7
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
if (!empty($USER->id)) { // Additional identity check
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
//error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,14 @@
|
||||
// [pj] We are about to create the site, so let's add some blocks...
|
||||
// calendar_month is included as a Moodle feature advertisement ;-)
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
$form->blockinfo = blocks_get_default_blocks(NULL, blocks_get_config_default('site'));
|
||||
|
||||
if ($newid = insert_record("course", $form)) {
|
||||
// Site created, add blocks for it
|
||||
$page = new stdClass;
|
||||
$page->type = MOODLE_PAGE_COURSE;
|
||||
$page->id = $newid;
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
|
||||
$cat->name = get_string("miscellaneous");
|
||||
if (insert_record("course_categories", $cat)) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php", get_string("changessaved"), 1);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_activity_modules extends MoodleBlock {
|
||||
function CourseBlock_activity_modules($course) {
|
||||
function init() {
|
||||
$this->title = get_string('activities');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004041000;
|
||||
}
|
||||
|
||||
@@ -18,7 +17,7 @@ class CourseBlock_activity_modules extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
@@ -26,7 +25,7 @@ class CourseBlock_activity_modules extends MoodleBlock {
|
||||
if ($modnamesused) {
|
||||
foreach ($modnamesused as $modname => $modfullname) {
|
||||
if ($modname != 'label') {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$this->course->id.'">'.$modnamesplural[$modname].'</a>';
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$this->instance->pageid.'">'.$modnamesplural[$modname].'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$modname.'/icon.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php //$Id$
|
||||
|
||||
class CourseBlock_admin extends MoodleBlock {
|
||||
function CourseBlock_admin($course) {
|
||||
function init() {
|
||||
$this->title = get_string('administration');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081200;
|
||||
}
|
||||
|
||||
@@ -14,14 +13,14 @@ class CourseBlock_admin extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->course)) {
|
||||
if (empty($this->instance)) {
|
||||
$this->content = '';
|
||||
} else if ($this->course->id == SITEID) {
|
||||
} else if ($this->instance->pageid == SITEID) {
|
||||
$this->load_content_for_site();
|
||||
} else {
|
||||
$this->load_content_for_course();
|
||||
@@ -77,81 +76,83 @@ class CourseBlock_admin extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (isteacher($this->course->id)) {
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$isteacheredit = isteacheredit($this->course->id);
|
||||
if (isteacher($this->instance->pageid)) {
|
||||
|
||||
$isteacheredit = isteacheredit($this->instance->pageid);
|
||||
|
||||
if ($isteacheredit) {
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" />';
|
||||
if (isediting($this->course->id)) {
|
||||
$this->content->items[]='<a href="view.php?id='.$this->course->id.'&edit=off">'.get_string('turneditingoff').'</a>';
|
||||
if (isediting($this->instance->pageid)) {
|
||||
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=off">'.get_string('turneditingoff').'</a>';
|
||||
} else {
|
||||
$this->content->items[]='<a href="view.php?id='.$this->course->id.'&edit=on">'.get_string('turneditingon').'</a>';
|
||||
$this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=on">'.get_string('turneditingon').'</a>';
|
||||
}
|
||||
$this->content->items[]='<a href="edit.php?id='.$this->course->id.'">'.get_string('settings').'...</a>';
|
||||
$this->content->items[]='<a href="edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" height="16" width="16" alt="" />';
|
||||
|
||||
if (iscreator() or !empty($CFG->teacherassignteachers)) {
|
||||
if (!$this->course->teachers) {
|
||||
$this->course->teachers = get_string('defaultcourseteachers');
|
||||
if (iscreator() || !empty($CFG->teacherassignteachers)) {
|
||||
if (!$course->teachers) {
|
||||
$course->teachers = get_string('defaultcourseteachers');
|
||||
}
|
||||
$this->content->items[]='<a href="teacher.php?id='.$this->course->id.'">'.$this->course->teachers.'...</a>';
|
||||
$this->content->items[]='<a href="teacher.php?id='.$this->instance->pageid.'">'.$course->teachers.'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
|
||||
if (!$this->course->students) {
|
||||
$this->course->students = get_string('defaultcoursestudents');
|
||||
if (!$course->students) {
|
||||
$course->students = get_string('defaultcoursestudents');
|
||||
}
|
||||
$this->content->items[]='<a href="student.php?id='.$this->course->id.'">'.$this->course->students.'...</a>';
|
||||
$this->content->items[]='<a href="student.php?id='.$this->instance->pageid.'">'.$course->students.'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->course->id.'">'.get_string('backup').'...</a>';
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->instance->pageid.'">'.get_string('backup').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->course->id.'&wdir=/backupdata">'.get_string('restore').'...</a>';
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&wdir=/backupdata">'.get_string('restore').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="" />';
|
||||
$this->content->items[]='<a href="scales.php?id='.$this->course->id.'">'.get_string('scales').'...</a>';
|
||||
$this->content->items[]='<a href="scales.php?id='.$this->instance->pageid.'">'.get_string('scales').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/scales.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
|
||||
$this->content->items[]='<a href="grades.php?id='.$this->course->id.'">'.get_string('grades').'...</a>';
|
||||
$this->content->items[]='<a href="grades.php?id='.$this->instance->pageid.'">'.get_string('grades').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[]='<a href="log.php?id='.$this->course->id.'">'.get_string('logs').'...</a>';
|
||||
$this->content->items[]='<a href="log.php?id='.$this->instance->pageid.'">'.get_string('logs').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
|
||||
|
||||
if ($isteacheredit) {
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->course->id.'">'.get_string('files').'...</a>';
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'">'.get_string('files').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->course->id.'&file=teacher.html">'.get_string('help').'...</a>';
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->instance->pageid.'&file=teacher.html">'.get_string('help').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" height="16" width="16" alt="" />';
|
||||
|
||||
if ($teacherforum = forum_get_course_forum($this->course->id, 'teacher')) {
|
||||
if ($teacherforum = forum_get_course_forum($this->instance->pageid, 'teacher')) {
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/mod/forum/view.php?f='.$teacherforum->id.'">'.get_string('nameteacher', 'forum').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->modpixpath.'/forum/icon.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
|
||||
} else if (!isguest()) { // Students menu
|
||||
|
||||
if ($this->course->showgrades) {
|
||||
$this->content->items[]='<a href="grade.php?id='.$this->course->id.'">'.get_string('grades').'...</a>';
|
||||
if ($course->showgrades) {
|
||||
$this->content->items[]='<a href="grade.php?id='.$this->instance->pageid.'">'.get_string('grades').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
if ($this->course->showreports) {
|
||||
$this->content->items[]='<a href="user.php?id='.$this->course->id.'&user='.$USER->id.'">'.get_string('activityreport').'...</a>';
|
||||
if ($course->showreports) {
|
||||
$this->content->items[]='<a href="user.php?id='.$this->instance->pageid.'&user='.$USER->id.'">'.get_string('activityreport').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/report.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
if (is_internal_auth()) {
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->course->id.'">'.get_string('changepassword').'...</a>';
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
||||
} else if ($CFG->changepassword) {
|
||||
$this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
if ($CFG->allowunenroll) {
|
||||
$this->content->items[]='<a href="unenrol.php?id='.$this->course->id.'">'.get_string('unenrolme', '', $this->course->shortname).'...</a>';
|
||||
$this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_calendar_month extends MoodleBlock {
|
||||
function CourseBlock_calendar_month($course) {
|
||||
function init() {
|
||||
$this->title = get_string('calendar', 'calendar');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081200;
|
||||
}
|
||||
|
||||
@@ -19,20 +18,20 @@ class CourseBlock_calendar_month extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->course)) { // Overrides: use no course at all
|
||||
if (empty($this->instance)) { // Overrides: use no course at all
|
||||
|
||||
$courseshown = false;
|
||||
$filtercourse = array();
|
||||
|
||||
} else {
|
||||
|
||||
$courseshown = $this->course->id;
|
||||
$courseshown = $this->instance->pageid;
|
||||
|
||||
if($this->course->id == SITEID) {
|
||||
if($courseshown == SITEID) {
|
||||
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
||||
// the list of courses it will be grabbing events from.
|
||||
$filtercourse = NULL;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_calendar_upcoming extends MoodleBlock {
|
||||
function CourseBlock_calendar_upcoming ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('upcomingevents', 'calendar');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
}
|
||||
|
||||
@@ -19,10 +18,10 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
|
||||
if (empty($this->course)) { // Overrides: use no course at all
|
||||
if (empty($this->instance)) { // Overrides: use no course at all
|
||||
|
||||
$courseshown = false;
|
||||
$filtercourse = array();
|
||||
@@ -30,15 +29,15 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
|
||||
|
||||
} else {
|
||||
|
||||
$courseshown = $this->course->id;
|
||||
$courseshown = $this->instance->pageid;
|
||||
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.
|
||||
'/calendar/view.php?view=upcoming&course='.$this->course->id.'">'.
|
||||
'/calendar/view.php?view=upcoming&course='.$courseshown.'">'.
|
||||
get_string('gotocalendar', 'calendar').'</a>...';
|
||||
$this->content->footer .= '<br /><a href="'.$CFG->wwwroot.
|
||||
'/calendar/event.php?action=new&course='.$this->course->id.'">'.
|
||||
'/calendar/event.php?action=new&course='.$courseshown.'">'.
|
||||
get_string('newevent', 'calendar').'</a>...';
|
||||
|
||||
if ($this->course->id == SITEID) {
|
||||
if ($courseshown == SITEID) {
|
||||
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
||||
// the list of courses it will be grabbing events from.
|
||||
$filtercourse = NULL;
|
||||
@@ -59,9 +58,9 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
|
||||
get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS),
|
||||
get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
|
||||
|
||||
if (!empty($this->course)) {
|
||||
if (!empty($this->instance)) {
|
||||
$this->content->text = calendar_get_sideblock_upcoming($events,
|
||||
'view.php?view=day&course='.$this->course->id.'&');
|
||||
'view.php?view=day&course='.$courseshown.'&');
|
||||
}
|
||||
|
||||
if (empty($this->content->text)) {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_course_list extends MoodleBlock {
|
||||
function CourseBlock_course_list ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('courses');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081200;
|
||||
}
|
||||
|
||||
@@ -20,13 +19,6 @@ class CourseBlock_course_list extends MoodleBlock {
|
||||
return true;
|
||||
}
|
||||
|
||||
function handle_config($config) {
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, $value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $THEME, $CFG, $USER;
|
||||
|
||||
@@ -34,7 +26,7 @@ class CourseBlock_course_list extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_course_summary extends MoodleBlock {
|
||||
function CourseBlock_course_summary ($course) {
|
||||
if(!empty($course) && $course->id == SITEID) { // Site level
|
||||
$this->title = get_string('frontpagedescription');
|
||||
} else {
|
||||
$this->title = get_string('blockname','block_course_summary');
|
||||
}
|
||||
function init() {
|
||||
$this->title = get_string('pagedescription', 'block_course_summary');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
}
|
||||
|
||||
function specialization() {
|
||||
if($this->instance->pagetype == MOODLE_PAGE_COURSE && $this->instance->pageid != SITEID) {
|
||||
$this->title = get_string('coursesummary', 'block_course_summary');
|
||||
}
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $THEME;
|
||||
|
||||
@@ -19,18 +20,20 @@ class CourseBlock_course_summary extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
if (empty($this->instance)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$this->content = New stdClass;
|
||||
$options->noclean = true; // Don't clean Javascripts etc
|
||||
$this->content->text = format_text($this->course->summary, FORMAT_HTML, $options);
|
||||
if(isediting($this->course->id)) {
|
||||
if($this->course->id == SITEID) {
|
||||
$this->content->text = format_text($course->summary, FORMAT_HTML, $options);
|
||||
if(isediting($this->instance->pageid)) {
|
||||
if($this->instance->pageid == SITEID) {
|
||||
$editpage = $CFG->wwwroot.'/admin/site.php';
|
||||
} else {
|
||||
$editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->course->id;
|
||||
$editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->instance->pageid;
|
||||
}
|
||||
$this->content->text .= "<div align=\"right\"><a href=\"$editpage\"><img src=\"$CFG->pixpath/t/edit.gif\" alt=\"\" /></a></div>";
|
||||
}
|
||||
|
||||
+84
-1
@@ -24,7 +24,7 @@ global $CFG;
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($oldversion < 2004041000 and $result) {
|
||||
if ($oldversion < 2004041000 && $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}blocks` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(40) NOT NULL default '',
|
||||
@@ -37,6 +37,89 @@ global $CFG;
|
||||
COMMENT = 'To register and update all the available blocks'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004101900 && $result) {
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}block` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(40) NOT NULL default '',
|
||||
`version` int(10) NOT NULL default '0',
|
||||
`cron` int(10) unsigned NOT NULL default '0',
|
||||
`lastcron` int(10) unsigned NOT NULL default '0',
|
||||
`visible` tinyint(1) NOT NULL default '1',
|
||||
`multiple` tinyint(1) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
COMMENT = 'To register and update all the available blocks'");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('blocks');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
$block->multiple = 0;
|
||||
insert_record('block', $block);
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("DROP TABLE `{$CFG->prefix}blocks`");
|
||||
|
||||
$result = execute_sql("CREATE TABLE `{$CFG->prefix}block_instance` (
|
||||
`id` int(10) not null auto_increment,
|
||||
`blockid` int(10) not null default '0',
|
||||
`pageid` int(10) not null default '0',
|
||||
`pagetype` enum('course') not null,
|
||||
`position` enum('l', 'r') not null,
|
||||
`weight` tinyint(3) not null default '0',
|
||||
`visible` tinyint(1) not null default '0',
|
||||
`configdata` text not null default '',
|
||||
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX pageid(`pageid`)
|
||||
)");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('course');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $thiscourse) {
|
||||
// The @ suppresses a notice emitted if there is no : in the string
|
||||
@list($left, $right) = split(':', $thiscourse->blockinfo);
|
||||
if(!empty($left)) {
|
||||
$arr = explode(',', $left);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = MOODLE_PAGE_COURSE;
|
||||
$instance->position = BLOCK_POS_LEFT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
if(!empty($right)) {
|
||||
$arr = explode(',', $right);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = MOODLE_PAGE_COURSE;
|
||||
$instance->position = BLOCK_POS_RIGHT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}course` DROP COLUMN blockinfo");
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
|
||||
+15
-1
@@ -3,13 +3,27 @@
|
||||
# Table structure for table `blocks`
|
||||
#
|
||||
|
||||
CREATE TABLE `prefix_blocks` (
|
||||
CREATE TABLE `prefix_block` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(40) NOT NULL default '',
|
||||
`version` int(10) NOT NULL default '0',
|
||||
`cron` int(10) unsigned NOT NULL default '0',
|
||||
`lastcron` int(10) unsigned NOT NULL default '0',
|
||||
`visible` tinyint(1) NOT NULL default '1',
|
||||
`multiple` tinyint(1) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
CREATE TABLE `prefix_block_instance` (
|
||||
`id` int(10) not null auto_increment,
|
||||
`blockid` int(10) not null default '0',
|
||||
`pageid` int(10) not null default '0',
|
||||
`pagetype` enum('course') not null,
|
||||
`position` enum('l', 'r') not null,
|
||||
`weight` tinyint(3) not null default '0',
|
||||
`visible` tinyint(1) not null default '0',
|
||||
`configdata` text not null default '',
|
||||
PRIMARY KEY(`id`),
|
||||
INDEX pageid(`pageid`)
|
||||
) TYPE=MyISAM;
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -39,6 +39,85 @@ global $CFG;
|
||||
|
||||
}
|
||||
|
||||
if ($oldversion < 2004101900 && $result) {
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}block (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
name varchar(40) NOT NULL default '',
|
||||
version INT8 NOT NULL default '0',
|
||||
cron INT8 unsigned NOT NULL default '0',
|
||||
lastcron INT8 unsigned NOT NULL default '0',
|
||||
visible int NOT NULL default '1',
|
||||
multiple int NOT NULL default '0'
|
||||
)
|
||||
");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('blocks');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $block) {
|
||||
$block->multiple = 0;
|
||||
insert_record('block', $block);
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("DROP TABLE {$CFG->prefix}blocks");
|
||||
|
||||
$result = execute_sql("CREATE TABLE {$CFG->prefix}block_instance (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
blockid INT8 not null default '0',
|
||||
pageid INT8 not null default '0',
|
||||
pagetype enum('course') not null,
|
||||
position enum('l', 'r') not null,
|
||||
weight int not null default '0',
|
||||
visible int not null default '0',
|
||||
configdata text not null default ''
|
||||
)");
|
||||
|
||||
if(!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$records = get_records('course');
|
||||
if(!empty($records)) {
|
||||
foreach($records as $thiscourse) {
|
||||
// The @ suppresses a notice emitted if there is no : in the string
|
||||
@list($left, $right) = split(':', $thiscourse->blockinfo);
|
||||
if(!empty($left)) {
|
||||
$arr = explode(',', $left);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = MOODLE_PAGE_COURSE;
|
||||
$instance->position = BLOCK_POS_LEFT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
if(!empty($right)) {
|
||||
$arr = explode(',', $right);
|
||||
foreach($arr as $weight => $blk) {
|
||||
$instance = new stdClass;
|
||||
$instance->blockid = abs($blk);
|
||||
$instance->pageid = $thiscourse->id;
|
||||
$instance->pagetype = MOODLE_PAGE_COURSE;
|
||||
$instance->position = BLOCK_POS_RIGHT;
|
||||
$instance->weight = $weight;
|
||||
$instance->visible = ($blk > 0) ? 1 : 0;
|
||||
$instance->configdata = '';
|
||||
insert_record('block_instance', $instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
execute_sql("ALTER TABLE {$CFG->prefix}course DROP COLUMN blockinfo");
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
|
||||
+14
-1
@@ -9,6 +9,19 @@ CREATE TABLE prefix_blocks (
|
||||
version INT8 NOT NULL default '0',
|
||||
cron INT8 NOT NULL default '0',
|
||||
lastcron INT8 NOT NULL default '0',
|
||||
visible int NOT NULL default '1'
|
||||
visible int NOT NULL default '1',
|
||||
multiple int NOT NULL default '1'
|
||||
) ;
|
||||
|
||||
CREATE TABLE prefix_block_instance (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
blockid INT8 not null default '0',
|
||||
pageid INT8 not null default '0',
|
||||
pagetype enum('course') not null,
|
||||
position enum('l', 'r') not null,
|
||||
weight int not null default '0',
|
||||
visible int not null default '0',
|
||||
configdata text not null default ''
|
||||
) ;
|
||||
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_login extends MoodleBlock {
|
||||
function CourseBlock_login ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('login');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081600;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,18 @@ define('BLOCK_TYPE_NUKE', 3);
|
||||
|
||||
class MoodleBlock {
|
||||
var $str;
|
||||
var $title = NULL;
|
||||
var $course = NULL;
|
||||
var $content_type = NULL;
|
||||
var $content = NULL;
|
||||
var $title = NULL;
|
||||
var $course = NULL;
|
||||
var $content_type = NULL;
|
||||
var $content = NULL;
|
||||
var $edit_controls = NULL;
|
||||
var $version = NULL;
|
||||
var $version = NULL;
|
||||
var $instance = NULL;
|
||||
var $config = NULL;
|
||||
|
||||
function MoodleBlock() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
function name() {
|
||||
// Returns the block name, as present in the class name,
|
||||
@@ -118,14 +124,9 @@ class MoodleBlock {
|
||||
print_side_block($title, ' ', NULL, NULL, '');
|
||||
}
|
||||
|
||||
function add_edit_controls($options, $blockid) {
|
||||
function add_edit_controls($options) {
|
||||
global $CFG, $THEME, $USER;
|
||||
|
||||
// The block may be disabled
|
||||
$blockid = intval($blockid);
|
||||
$enabled = $blockid > 0;
|
||||
$blockid = abs($blockid);
|
||||
|
||||
if (!isset($this->str)) {
|
||||
$this->str->delete = get_string('delete');
|
||||
$this->str->moveup = get_string('moveup');
|
||||
@@ -134,6 +135,7 @@ class MoodleBlock {
|
||||
$this->str->moveleft = get_string('moveleft');
|
||||
$this->str->hide = get_string('hide');
|
||||
$this->str->show = get_string('show');
|
||||
$this->str->configure = get_string('configuration');
|
||||
}
|
||||
|
||||
$path = $CFG->wwwroot.'/course';
|
||||
@@ -148,7 +150,7 @@ class MoodleBlock {
|
||||
|
||||
$movebuttons = '<div style="float: right;">';
|
||||
|
||||
if($enabled) {
|
||||
if($this->instance->visible) {
|
||||
$icon = '/t/hide.gif';
|
||||
$title = $this->str->hide;
|
||||
}
|
||||
@@ -157,27 +159,37 @@ class MoodleBlock {
|
||||
$title = $this->str->show;
|
||||
}
|
||||
|
||||
$movebuttons .= '<a style="margin-right: 6px; margin-left: 3px;" title="'.$title.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=toggle&blockid='.$blockid.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.$icon.'" alt="" /></a>';
|
||||
$page = new stdClass;
|
||||
$page->id = $this->instance->pageid;
|
||||
$page->type = $this->instance->pagetype;
|
||||
$script = page_source_script($page);
|
||||
|
||||
$movebuttons .= '<a style="margin-right: 6px; margin-left: 2px;" title="'.$title.'" href="'.$script.'&blockaction=toggle&instanceid='.$this->instance->id.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.$icon.'" alt=\"\" /></a>';
|
||||
|
||||
$movebuttons .= '<a title="'.$this->str->delete.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=delete&blockid='.$blockid.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/delete.gif" alt="" /></a> ';
|
||||
if($options & BLOCK_CONFIGURE) {
|
||||
$movebuttons .= '<a style="margin-right: 6px; margin-left: 2px;" title="'.$this->str->configure.'" href="'.$script.'&blockaction=config&instanceid='.$this->instance->id.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/edit.gif" alt=\"\" /></a>';
|
||||
}
|
||||
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->delete.'" href="'.$script.'&blockaction=delete&instanceid='.$this->instance->id.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/delete.gif" alt=\"\" /></a> ';
|
||||
|
||||
if ($options & BLOCK_MOVE_LEFT) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveleft.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveside&blockid='.$blockid.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/left.gif" alt="" /></a>';
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveleft.'" href="'.$script.'&blockaction=moveleft&instanceid='.$this->instance->id.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/left.gif" alt=\"\" /></a>';
|
||||
}
|
||||
if ($options & BLOCK_MOVE_UP) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveup.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveup&blockid='.$blockid.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/up.gif" alt="" /></a>';
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveup.'" href="'.$script.'&blockaction=moveup&instanceid='.$this->instance->id.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/up.gif" alt=\"\" /></a>';
|
||||
}
|
||||
if ($options & BLOCK_MOVE_DOWN) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->movedown.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=movedown&blockid='.$blockid.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/down.gif" alt="" /></a>';
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->movedown.'" href="'.$script.'&blockaction=movedown&instanceid='.$this->instance->id.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/down.gif" alt=\"\" /></a>';
|
||||
}
|
||||
if ($options & BLOCK_MOVE_RIGHT) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveright.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveside&blockid='.$blockid.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/right.gif" alt="" /></a>';
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveright.'" href="'.$script.'&blockaction=moveright&instanceid='.$this->instance->id.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/right.gif" alt=\"\" /></a>';
|
||||
}
|
||||
|
||||
$movebuttons .= '</div>';
|
||||
@@ -225,12 +237,27 @@ class MoodleBlock {
|
||||
return false;
|
||||
}
|
||||
function print_config() {
|
||||
// This does nothing, it's here to prevent errors from
|
||||
// derived classes if they implement has_config() but not print_config()
|
||||
// Default behavior: print the config_global.html file
|
||||
// You don't need to override this if you 're satisfied with the above
|
||||
if(!$this->has_config()) {
|
||||
return false;
|
||||
}
|
||||
global $CFG, $USER, $THEME;
|
||||
print_simple_box_start('center', '', $THEME->cellheading);
|
||||
include($CFG->dirroot.'/blocks/'.$this->name().'/config_global.html');
|
||||
print_simple_box_end();
|
||||
return true;
|
||||
}
|
||||
function handle_config() {
|
||||
// This does nothing, it's here to prevent errors from
|
||||
// derived classes if they implement has_config() but not handle_config()
|
||||
function handle_config($config) {
|
||||
// Default behavior: save all variables as $CFG properties
|
||||
// You don't need to override this if you 're satisfied with the above
|
||||
if(!$this->has_config()) {
|
||||
return false;
|
||||
}
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, $value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function applicable_formats() {
|
||||
// Default case: the block can be used in all course types
|
||||
@@ -248,6 +275,49 @@ class MoodleBlock {
|
||||
// Default case: just an id for the block, with our name in it
|
||||
return array('id' => 'block_'.$this->name());
|
||||
}
|
||||
function load_instance($instance) {
|
||||
if(!empty($instance->configdata)) {
|
||||
$this->config = unserialize(base64_decode($instance->configdata));
|
||||
}
|
||||
unset($instance->configdata);
|
||||
$this->instance = $instance;
|
||||
$this->specialization();
|
||||
}
|
||||
function specialization() {
|
||||
// Just to make sure that this method exists.
|
||||
return;
|
||||
}
|
||||
|
||||
function instance_allow_multiple() {
|
||||
// Are you going to allow multiple instances of each block?
|
||||
// If yes, then it is assumed that the block WILL USE per-instance configuration
|
||||
return false;
|
||||
}
|
||||
function instance_config_print() {
|
||||
// Default behavior: print the config_instance.html file
|
||||
// You don't need to override this if you 're satisfied with the above
|
||||
if(!$this->instance_allow_multiple()) {
|
||||
return false;
|
||||
}
|
||||
global $CFG, $USER, $THEME;
|
||||
|
||||
if(is_file($CFG->dirroot.'/blocks/'.$this->name().'/config_instance.html')) {
|
||||
print_simple_box_start('center', '', $THEME->cellheading);
|
||||
include($CFG->dirroot.'/blocks/'.$this->name().'/config_instance.html');
|
||||
print_simple_box_end();
|
||||
}
|
||||
else {
|
||||
notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
function instance_config_save($data) {
|
||||
$data = stripslashes_recursive($data);
|
||||
$this->config = $data;
|
||||
return set_field('block_instance', 'configdata', base64_encode(serialize($data)), 'id', $this->instance->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MoodleBlock_Nuke extends MoodleBlock {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_news_items extends MoodleBlock {
|
||||
function CourseBlock_news_items ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('latestnews');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
}
|
||||
|
||||
@@ -15,23 +14,24 @@ class CourseBlock_news_items extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->instance)) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
if ($this->course->newsitems) {
|
||||
$news = forum_get_course_forum($this->course->id, 'news');
|
||||
if ($course->newsitems) {
|
||||
$news = forum_get_course_forum($this->instance->pageid, 'news');
|
||||
// Slightly hacky way to do it but...
|
||||
ob_start();
|
||||
forum_print_latest_discussions($news->id, $this->course->newsitems, "minimal", "", get_current_group($this->course->id));
|
||||
forum_print_latest_discussions($news->id, $course->newsitems, "minimal", "", get_current_group($this->instance->pageid));
|
||||
$this->content->text = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_online_users extends MoodleBlock {
|
||||
function CourseBlock_online_users ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('blockname','block_online_users');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052700;
|
||||
}
|
||||
|
||||
@@ -31,14 +30,16 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New stdClass;
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->course)) {
|
||||
if (empty($this->instance)) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$timetoshowusers = 300; //Seconds default
|
||||
if (isset($CFG->block_online_users_timetosee)) {
|
||||
$timetoshowusers = $CFG->block_online_users_timetosee * 60;
|
||||
@@ -46,11 +47,10 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
$timefrom = time()-$timetoshowusers;
|
||||
|
||||
//Calculate if we are in separate groups
|
||||
$isseparategroups = ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce and
|
||||
!isteacheredit($this->course->id));
|
||||
$isseparategroups = ($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce && !isteacheredit($this->instance->pageid));
|
||||
|
||||
//Get the user current group
|
||||
$currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL;
|
||||
$currentgroup = $isseparategroups ? get_current_group($this->instance->pageid) : NULL;
|
||||
|
||||
$groupmembers = "";
|
||||
$groupselect = "";
|
||||
@@ -61,11 +61,11 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
$groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
||||
}
|
||||
|
||||
if (empty($this->course->category)) { // Site-level
|
||||
if ($this->instance->pageid == SITEID) { // Site-level
|
||||
$courseselect = '';
|
||||
$timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)";
|
||||
} else {
|
||||
$courseselect = "AND s.course = '".$this->course->id."'";
|
||||
$courseselect = "AND s.course = '".$this->instance->pageid."'";
|
||||
$timeselect = "AND s.timeaccess > $timefrom";
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->course->category and $CFG->allusersaresitestudents) {
|
||||
if ($this->instance->pageid == SITEID && $CFG->allusersaresitestudents) {
|
||||
if ($siteusers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess
|
||||
FROM {$CFG->prefix}user u
|
||||
WHERE u.lastaccess > $timefrom AND u.username <> 'guest'
|
||||
@@ -130,7 +130,7 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
}
|
||||
$this->content->text .= $imgtag;
|
||||
}
|
||||
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->course->id.'" title="'.$timeago.'">'.$user->fullname.'</a></div>';
|
||||
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->instance->pageid.'" title="'.$timeago.'">'.$user->fullname.'</a></div>';
|
||||
}
|
||||
/*
|
||||
$table->align = array("right","left");
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_participants extends MoodleBlock {
|
||||
function CourseBlock_participants ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('people');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
}
|
||||
|
||||
@@ -14,12 +13,12 @@ class CourseBlock_participants extends MoodleBlock {
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
if (empty($this->course)) {
|
||||
if (empty($this->instance)) {
|
||||
$this->content = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
@@ -27,26 +26,28 @@ class CourseBlock_participants extends MoodleBlock {
|
||||
$strgroups = get_string('groups');
|
||||
$strgroupmy = get_string('groupmy');
|
||||
|
||||
if ($this->course->category or $CFG->showsiteparticipantslist > 1 or ($CFG->showsiteparticipantslist == 1 and isteacher()) or isteacher(SITEID)) {
|
||||
$this->content->items[]='<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?id='.$this->course->id.'">'.get_string('participants').'</a>';
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
if ($this->instance->pageid != SITEID || $CFG->showsiteparticipantslist > 1 || ($CFG->showsiteparticipantslist == 1 && isteacher()) || isteacher(SITEID)) {
|
||||
$this->content->items[]='<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?id='.$this->instance->pageid.'">'.get_string('participants').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
|
||||
if ($this->course->groupmode or !$this->course->groupmodeforce) {
|
||||
if ($this->course->groupmode == VISIBLEGROUPS or isteacheredit($this->course->id)) {
|
||||
$this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/course/groups.php?id='.$this->course->id.'">'.$strgroups.'</a>';
|
||||
if ($course->groupmode || !$course->groupmodeforce) {
|
||||
if ($course->groupmode == VISIBLEGROUPS or isteacheredit($this->instance->pageid)) {
|
||||
$this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/course/groups.php?id='.$this->instance->pageid.'">'.$strgroups.'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" height="16" width="16" alt="" />';
|
||||
} else if ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce) {
|
||||
} else if ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce) {
|
||||
// Show nothing
|
||||
} else if ($currentgroup = get_current_group($this->course->id)) {
|
||||
$this->content->items[]='<a title="'.$strgroupmy.'" href="'.$CFG->wwwroot.'/course/group.php?id='.$this->course->id.'">'.$strgroupmy.'</a>';
|
||||
} else if ($currentgroup = get_current_group($this->instance->pageid)) {
|
||||
$this->content->items[]='<a title="'.$strgroupmy.'" href="'.$CFG->wwwroot.'/course/group.php?id='.$this->instance->pageid.'">'.$strgroupmy.'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($USER->id)) {
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.$this->course->id.'">'.get_string('editmyprofile').'</a>';
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
|
||||
if ($USER->description) {
|
||||
$this->content->items[]= $editmyprofile;
|
||||
} else {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_recent_activity extends MoodleBlock {
|
||||
function CourseBlock_recent_activity ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('recentactivity');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004042900;
|
||||
}
|
||||
|
||||
@@ -14,18 +13,20 @@ class CourseBlock_recent_activity extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
if (empty($this->instance)) {
|
||||
$this->content = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
// Slightly hacky way to do it but...
|
||||
ob_start();
|
||||
print_recent_activity($this->course);
|
||||
print_recent_activity($course);
|
||||
$this->content->text = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_search_forums extends MoodleBlock {
|
||||
function CourseBlock_search_forums ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('search', 'forum');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004041000;
|
||||
}
|
||||
|
||||
@@ -17,16 +16,18 @@ class CourseBlock_search_forums extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
if (empty($this->instance)) {
|
||||
$this->content = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
$form = forum_print_search_form($this->course, '', true);
|
||||
$form = forum_print_search_form($course, '', true);
|
||||
$this->content->text = '<div align="center">'.$form.'</div>';
|
||||
|
||||
return $this->content;
|
||||
|
||||
@@ -2,7 +2,15 @@
|
||||
|
||||
class CourseBlock_section_links extends MoodleBlock {
|
||||
|
||||
function CourseBlock_section_links ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('blockname', 'block_section_links');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->version = 2004052800;
|
||||
}
|
||||
|
||||
function instance_config($instance) {
|
||||
parent::instance_config($instance);
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
if (isset($course->format)) {
|
||||
if ($course->format == 'topics') {
|
||||
$this->title = get_string('topics', 'block_section_links');
|
||||
@@ -11,12 +19,7 @@ class CourseBlock_section_links extends MoodleBlock {
|
||||
} else {
|
||||
$this->title = get_string('blockname', 'block_section_links');
|
||||
}
|
||||
} else {
|
||||
$this->title = get_string('blockname', 'block_section_links');
|
||||
}
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052800;
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
@@ -32,41 +35,46 @@ class CourseBlock_section_links extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
$this->content = New stdClass;
|
||||
$this->content->footer = '';
|
||||
$this->content->text = '';
|
||||
|
||||
if (empty($this->instance)) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if ($this->course->format == 'weeks') {
|
||||
$highlight = ceil((time()-$this->course->startdate)/604800);
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
if ($course->format == 'weeks') {
|
||||
$highlight = ceil((time()-$course->startdate)/604800);
|
||||
$linktext = get_string('jumptocurrentweek', 'block_section_links');
|
||||
$sectionname = 'week';
|
||||
}
|
||||
else if ($this->course->format == 'topics') {
|
||||
$highlight = $this->course->marker;
|
||||
else if ($course->format == 'topics') {
|
||||
$highlight = $course->marker;
|
||||
$linktext = get_string('jumptocurrenttopic', 'block_section_links');
|
||||
$sectionname = 'topic';
|
||||
}
|
||||
$inc = 1;
|
||||
if ($this->course->numsections > 22) {
|
||||
if ($course->numsections > 22) {
|
||||
$inc = 2;
|
||||
}
|
||||
if ($this->course->numsections > 40) {
|
||||
if ($course->numsections > 40) {
|
||||
$inc = 5;
|
||||
}
|
||||
$courseid = $this->course->id;
|
||||
|
||||
if (!empty($USER->id)) {
|
||||
$display = get_field('course_display', 'display', 'course', $courseid, 'userid', $USER->id);
|
||||
$display = get_field('course_display', 'display', 'course', $this->instance->pageid, 'userid', $USER->id);
|
||||
}
|
||||
if (!empty($display)) {
|
||||
$link = "$CFG->wwwroot/course/view.php?id=$courseid&$sectionname=";
|
||||
$link = "$CFG->wwwroot/course/view.php?id=$this->instance->pageid&$sectionname=";
|
||||
} else {
|
||||
$link = '#';
|
||||
}
|
||||
$text = '<font size="-1">';
|
||||
for ($i = $inc; $i <= $this->course->numsections; $i += $inc) {
|
||||
$isvisible = get_field('course_sections', 'visible', 'course', $this->course->id, 'section', $i);
|
||||
if (!$isvisible and !isteacher($this->course->id)) {
|
||||
for ($i = $inc; $i <= $course->numsections; $i += $inc) {
|
||||
$isvisible = get_field('course_sections', 'visible', 'course', $this->instance->pageid, 'section', $i);
|
||||
if (!$isvisible and !isteacher($this->instance->pageid)) {
|
||||
continue;
|
||||
}
|
||||
$style = ($isvisible) ? '' : ' class="dimmed"';
|
||||
@@ -77,8 +85,8 @@ class CourseBlock_section_links extends MoodleBlock {
|
||||
}
|
||||
}
|
||||
if ($highlight) {
|
||||
$isvisible = get_field('course_sections', 'visible', 'course', $this->course->id, 'section', $highlight);
|
||||
if ($isvisible or isteacher($this->course->id)) {
|
||||
$isvisible = get_field('course_sections', 'visible', 'course', $this->instance->pageid, 'section', $highlight);
|
||||
if ($isvisible or isteacher($this->instance->pageid)) {
|
||||
$style = ($isvisible) ? '' : ' class="dimmed"';
|
||||
$text .= "<br /><a href=\"$link$highlight\"$style>$linktext</a>";
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php //$Id$
|
||||
|
||||
class CourseBlock_site_main_menu extends MoodleBlock {
|
||||
function CourseBlock_site_main_menu ($course) {
|
||||
function init() {
|
||||
$this->title = get_string('mainmenu');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052700;
|
||||
}
|
||||
|
||||
@@ -19,28 +18,30 @@ class CourseBlock_site_main_menu extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->content = New stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
$isteacher = isteacher($this->course->id);
|
||||
$isediting = isediting($this->course->id);
|
||||
$ismoving = ismoving($this->course->id);
|
||||
if (empty($this->instance)) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$sections = get_all_sections($this->course->id);
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$isteacher = isteacher($this->instance->pageid);
|
||||
$isediting = isediting($this->instance->pageid);
|
||||
$ismoving = ismoving($this->instance->pageid);
|
||||
|
||||
$sections = get_all_sections($this->instance->pageid);
|
||||
$section = $sections[0];
|
||||
|
||||
if($section->sequence || $isediting) {
|
||||
get_all_mods($this->course->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
}
|
||||
|
||||
$groupbuttons = $this->course->groupmode;
|
||||
$groupbuttonslink = (!$this->course->groupmodeforce);
|
||||
$groupbuttons = $course->groupmode;
|
||||
$groupbuttonslink = (!$course->groupmodeforce);
|
||||
|
||||
if ($ismoving) {
|
||||
$strmovehere = get_string('movehere');
|
||||
@@ -49,7 +50,7 @@ class CourseBlock_site_main_menu extends MoodleBlock {
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
|
||||
$modinfo = unserialize($this->course->modinfo);
|
||||
$modinfo = unserialize($course->modinfo);
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
@@ -67,7 +68,7 @@ class CourseBlock_site_main_menu extends MoodleBlock {
|
||||
if ($isediting && !$ismoving) {
|
||||
if ($groupbuttons) {
|
||||
if (! $mod->groupmodelink = $groupbuttonslink) {
|
||||
$mod->groupmode = $this->course->groupmode;
|
||||
$mod->groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -88,7 +89,7 @@ class CourseBlock_site_main_menu extends MoodleBlock {
|
||||
}
|
||||
$instancename = urldecode($modinfo[$modnumber]->name);
|
||||
if (!empty($CFG->filterall)) {
|
||||
$instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->course->id);
|
||||
$instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->instance->pageid);
|
||||
}
|
||||
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
||||
if (!empty($modinfo[$modnumber]->extra)) {
|
||||
@@ -122,7 +123,7 @@ class CourseBlock_site_main_menu extends MoodleBlock {
|
||||
|
||||
if ($isediting && $modnames) {
|
||||
$this->content->footer = '<div style="text-align: right;">'.
|
||||
print_section_add_menus($this->course, 0, $modnames, true, true).'</div>';
|
||||
print_section_add_menus($course, 0, $modnames, true, true).'</div>';
|
||||
} else {
|
||||
$this->content->footer = '';
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php //$Id$
|
||||
|
||||
class CourseBlock_social_activities extends MoodleBlock {
|
||||
function CourseBlock_social_activities ($course) {
|
||||
function init(){
|
||||
$this->title = get_string('blockname','block_social_activities');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004041800;
|
||||
}
|
||||
|
||||
@@ -18,26 +17,29 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
if (empty($this->course)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content = new stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->instance)) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
// To make our day, we start with an ugly hack
|
||||
global $sections, $mods, $modnames;
|
||||
|
||||
$section = $sections[0];
|
||||
// That wasn't so bad, was it?
|
||||
|
||||
$groupbuttons = $this->course->groupmode;
|
||||
$groupbuttonslink = (!$this->course->groupmodeforce);
|
||||
$isteacher = isteacher($this->course->id);
|
||||
$isediting = isediting($this->course->id);
|
||||
$ismoving = ismoving($this->course->id);
|
||||
$groupbuttons = $course->groupmode;
|
||||
$groupbuttonslink = (!$course->groupmodeforce);
|
||||
$isteacher = isteacher($this->instance->pageid);
|
||||
$isediting = isediting($this->instance->pageid);
|
||||
$ismoving = ismoving($this->instance->pageid);
|
||||
if ($ismoving) {
|
||||
$strmovehere = get_string('movehere');
|
||||
$strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
|
||||
@@ -45,7 +47,7 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
|
||||
$modinfo = unserialize($this->course->modinfo);
|
||||
$modinfo = unserialize($course->modinfo);
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
@@ -63,7 +65,7 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
if ($isediting && !$ismoving) {
|
||||
if ($groupbuttons) {
|
||||
if (! $mod->groupmodelink = $groupbuttonslink) {
|
||||
$mod->groupmode = $this->course->groupmode;
|
||||
$mod->groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -84,7 +86,7 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
}
|
||||
$instancename = urldecode($modinfo[$modnumber]->name);
|
||||
if (!empty($CFG->filterall)) {
|
||||
$instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->course->id);
|
||||
$instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->instance->pageid);
|
||||
}
|
||||
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
||||
if (!empty($modinfo[$modnumber]->extra)) {
|
||||
@@ -118,7 +120,7 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
|
||||
if ($isediting && $modnames) {
|
||||
$this->content->footer = '<div style="text-align: right;">'.
|
||||
print_section_add_menus($this->course, 0, $modnames, true, true).'</div>';
|
||||
print_section_add_menus($course, 0, $modnames, true, true).'</div>';
|
||||
} else {
|
||||
$this->content->footer = '';
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@
|
||||
// database (blocks_version) to determine whether upgrades should
|
||||
// be performed (see db/backup_*.php)
|
||||
|
||||
$blocks_version = 2004052700; // The current version is a date (YYYYMMDDXX)
|
||||
$blocks_version = 2004101900; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
+12
-5
@@ -54,8 +54,11 @@
|
||||
|
||||
if (!empty($course)) {
|
||||
// Test for and remove blocks which aren't appropriate anymore
|
||||
$form->blockinfo = $course->blockinfo;
|
||||
block_remove_inappropriate_from_course($form);
|
||||
$page = new stdClass;
|
||||
$page->id = $course->id;
|
||||
$page->type = MOODLE_PAGE_COURSE;
|
||||
|
||||
blocks_remove_inappropriate($page);
|
||||
|
||||
// Update with the new data
|
||||
if (update_record("course", $form)) {
|
||||
@@ -68,10 +71,14 @@
|
||||
} else {
|
||||
$form->timecreated = time();
|
||||
|
||||
//Create blockinfo default content
|
||||
$form->blockinfo = blocks_get_default_blocks(null, blocks_get_config_default($form->format));
|
||||
|
||||
if ($newcourseid = insert_record("course", $form)) { // Set up new course
|
||||
|
||||
// Setup the blocks
|
||||
$page = new stdClass;
|
||||
$page->type = MOODLE_PAGE_COURSE;
|
||||
$page->id = $newcourseid;
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
|
||||
$section = NULL;
|
||||
$section->course = $newcourseid; // Create a default section.
|
||||
$section->section = 0;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
define('BLOCK_R_MIN_WIDTH', 100);
|
||||
define('BLOCK_R_MAX_WIDTH', 210);
|
||||
|
||||
optional_variable($preferred_width_left, 0);
|
||||
optional_variable($preferred_width_right, 0);
|
||||
optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]));
|
||||
optional_variable($preferred_width_right, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]));
|
||||
$preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH);
|
||||
$preferred_width_right = min($preferred_width_right, BLOCK_R_MAX_WIDTH);
|
||||
@@ -25,9 +25,9 @@
|
||||
echo '<table width="100%" border="0" cellspacing="5" cellpadding="5">';
|
||||
echo '<tr>';
|
||||
|
||||
if(block_have_active($leftblocks) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;">';
|
||||
print_course_blocks($course, $leftblocks, BLOCK_LEFT);
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_LEFT]);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -53,14 +53,14 @@
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
if(block_have_active($rightblocks) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
print_course_blocks($course, $rightblocks, BLOCK_RIGHT);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
block_print_blocks_admin($course, $missingblocks);
|
||||
}
|
||||
print_spacer(1, 120, true);
|
||||
echo '</td>';
|
||||
// The right column
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_RIGHT]);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
blocks_print_adminblock($page, $missingblocks);
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
echo '</tr>';
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
define('BLOCK_R_MIN_WIDTH', 100);
|
||||
define('BLOCK_R_MAX_WIDTH', 210);
|
||||
|
||||
optional_variable($preferred_width_left, 0);
|
||||
optional_variable($preferred_width_right, 0);
|
||||
optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]));
|
||||
optional_variable($preferred_width_right, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]));
|
||||
$preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH);
|
||||
$preferred_width_right = min($preferred_width_right, BLOCK_R_MAX_WIDTH);
|
||||
@@ -63,14 +63,14 @@
|
||||
|
||||
/// The left column ...
|
||||
|
||||
if(block_have_active($leftblocks) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;">';
|
||||
print_course_blocks($course, $leftblocks, BLOCK_LEFT);
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_LEFT]);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
/// Start main column
|
||||
echo "<td width=\"*\">";
|
||||
echo '<td valign="top">';
|
||||
|
||||
print_heading_block(get_string("topicoutline"), "100%", "outlineheadingblock");
|
||||
print_spacer(8, 1, true);
|
||||
@@ -270,13 +270,12 @@
|
||||
echo "</td>";
|
||||
|
||||
// The right column
|
||||
if(block_have_active($rightblocks) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
print_course_blocks($course, $rightblocks, BLOCK_RIGHT);
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_RIGHT]);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
block_print_blocks_admin($course, $missingblocks);
|
||||
blocks_print_adminblock($page, $missingblocks);
|
||||
}
|
||||
print_spacer(1, 120, true);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
define('BLOCK_R_MIN_WIDTH', 100);
|
||||
define('BLOCK_R_MAX_WIDTH', 210);
|
||||
|
||||
optional_variable($preferred_width_left, 0);
|
||||
optional_variable($preferred_width_right, 0);
|
||||
optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]));
|
||||
optional_variable($preferred_width_right, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]));
|
||||
$preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH);
|
||||
$preferred_width_right = min($preferred_width_right, BLOCK_R_MAX_WIDTH);
|
||||
@@ -54,14 +54,14 @@
|
||||
|
||||
/// The left column ...
|
||||
|
||||
if(block_have_active($leftblocks) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;">';
|
||||
print_course_blocks($course, $leftblocks, BLOCK_LEFT);
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_LEFT]);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
/// Start main column
|
||||
echo "</td><td width=\"*\">";
|
||||
echo '<td valign="top">';
|
||||
print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock");
|
||||
print_spacer(8, 1, true);
|
||||
|
||||
@@ -256,14 +256,13 @@
|
||||
echo "</td>";
|
||||
|
||||
// The right column
|
||||
if(block_have_active($rightblocks) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
print_course_blocks($course, $rightblocks, BLOCK_RIGHT);
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_RIGHT]);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
block_print_blocks_admin($course, $missingblocks);
|
||||
blocks_print_adminblock($page, $missingblocks);
|
||||
}
|
||||
print_spacer(1, 120, true);
|
||||
echo '</td>';
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
echo "</tr>\n";
|
||||
|
||||
+23
-81
@@ -9,6 +9,10 @@
|
||||
optional_variable($id);
|
||||
optional_variable($name);
|
||||
|
||||
optional_param('blockaction');
|
||||
optional_param('instanceid', 0, PARAM_INT);
|
||||
optional_param('blockid', 0, PARAM_INT);
|
||||
|
||||
if (!$id and !$name) {
|
||||
error("Must specify course id or short name");
|
||||
}
|
||||
@@ -33,31 +37,12 @@
|
||||
$course->format = 'weeks'; // Default format is weeks
|
||||
}
|
||||
|
||||
// Doing this now so we can pass the results to block_action()
|
||||
// and dodge the overhead of doing the same work twice.
|
||||
|
||||
$blocks = $course->blockinfo;
|
||||
$delimpos = strpos($blocks, ':');
|
||||
|
||||
if($delimpos === false) {
|
||||
// No ':' found, we have all left blocks
|
||||
$leftblocks = explode(',', $blocks);
|
||||
$rightblocks = array();
|
||||
}
|
||||
else if($delimpos === 0) {
|
||||
// ':' at start of string, we have all right blocks
|
||||
$blocks = substr($blocks, 1);
|
||||
$leftblocks = array();
|
||||
$rightblocks = explode(',', $blocks);
|
||||
}
|
||||
else {
|
||||
// Both left and right blocks
|
||||
$leftpart = substr($blocks, 0, $delimpos);
|
||||
$rightpart = substr($blocks, $delimpos + 1);
|
||||
$leftblocks = explode(',', $leftpart);
|
||||
$rightblocks = explode(',', $rightpart);
|
||||
}
|
||||
$page = new stdClass;
|
||||
$page->id = $course->id;
|
||||
$page->type = MOODLE_PAGE_COURSE;
|
||||
|
||||
$pageblocks = blocks_get_by_page($page);
|
||||
|
||||
if (!isset($USER->editing)) {
|
||||
$USER->editing = false;
|
||||
}
|
||||
@@ -75,47 +60,29 @@
|
||||
|
||||
$editing = $USER->editing;
|
||||
|
||||
if (isset($hide) and confirm_sesskey()) {
|
||||
if (isset($hide) && confirm_sesskey()) {
|
||||
set_section_visible($course->id, $hide, '0');
|
||||
}
|
||||
|
||||
if (isset($show) and confirm_sesskey()) {
|
||||
if (isset($show) && confirm_sesskey()) {
|
||||
set_section_visible($course->id, $show, '1');
|
||||
}
|
||||
|
||||
if (isset($_GET['blockaction']) and confirm_sesskey()) {
|
||||
if (isset($_GET['blockid'])) {
|
||||
block_action($course, $leftblocks, $rightblocks, strtolower($_GET['blockaction']), intval($_GET['blockid']));
|
||||
if (!empty($blockaction) && confirm_sesskey()) {
|
||||
if (!empty($blockid)) {
|
||||
blocks_execute_action($page, $pageblocks, strtolower($blockaction), intval($blockid));
|
||||
|
||||
}
|
||||
else if (!empty($instanceid)) {
|
||||
$instance = blocks_find_instance($instanceid, $pageblocks);
|
||||
blocks_execute_action($page, $pageblocks, strtolower($blockaction), $instance);
|
||||
}
|
||||
// This re-query could be eliminated by judicious programming in blocks_execute_action(),
|
||||
// but I 'm not sure if it's worth the complexity increase...
|
||||
$pageblocks = blocks_get_by_page($page);
|
||||
}
|
||||
|
||||
// This has to happen after block_action() has possibly updated the two arrays
|
||||
$allblocks = array_merge($leftblocks, $rightblocks);
|
||||
|
||||
$missingblocks = array();
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
|
||||
// Note down which blocks are going to get displayed
|
||||
blocks_used($allblocks, $recblocks);
|
||||
|
||||
if($editing && $recblocks) {
|
||||
foreach($recblocks as $recblock) {
|
||||
// If it's not hidden or displayed right now...
|
||||
if(!in_array($recblock->id, $allblocks) && !in_array(-($recblock->id), $allblocks)) {
|
||||
// And if it's applicable for display in this format...
|
||||
$formats = block_method_result($recblock->name, 'applicable_formats');
|
||||
|
||||
if( isset($formats[$course->format]) ? $formats[$course->format] : !empty($formats['all'])) {
|
||||
// Translation: if the course format is explicitly accepted/rejected, use
|
||||
// that setting. Otherwise, fallback to the 'all' format. The empty() test
|
||||
// uses the trick that empty() fails if 'all' is either !isset() or false.
|
||||
|
||||
// Add it to the missing blocks
|
||||
$missingblocks[] = $recblock->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$missingblocks = blocks_get_missing($page, $pageblocks);
|
||||
|
||||
if (!empty($section)) {
|
||||
if (!empty($move) and confirm_sesskey()) {
|
||||
@@ -126,11 +93,6 @@
|
||||
}
|
||||
} else {
|
||||
$USER->editing = false;
|
||||
|
||||
// Note down which blocks are going to get displayed
|
||||
$allblocks = array_merge($leftblocks, $rightblocks);
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
blocks_used($allblocks, $recblocks);
|
||||
}
|
||||
|
||||
$SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
|
||||
@@ -168,26 +130,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// If the block width cache is not set, set it
|
||||
if(!isset($SESSION->blockcache->width->{$course->id}) || $editing) {
|
||||
|
||||
// This query might be optimized away if we 're in editing mode
|
||||
if(!isset($recblocks)) {
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
}
|
||||
$preferred_width_left = blocks_preferred_width($leftblocks, $recblocks);
|
||||
$preferred_width_right = blocks_preferred_width($rightblocks, $recblocks);
|
||||
|
||||
// This may be kind of organizational overkill, granted...
|
||||
// But is there any real need to simplify the structure?
|
||||
$SESSION->blockcache->width->{$course->id}->left = $preferred_width_left;
|
||||
$SESSION->blockcache->width->{$course->id}->right = $preferred_width_right;
|
||||
}
|
||||
else {
|
||||
$preferred_width_left = $SESSION->blockcache->width->{$course->id}->left;
|
||||
$preferred_width_right = $SESSION->blockcache->width->{$course->id}->right;
|
||||
}
|
||||
|
||||
require("$CFG->dirroot/course/format/$course->format/format.php"); // Include the actual course format
|
||||
|
||||
print_footer(NULL, $course);
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
optional_param('blockaction');
|
||||
optional_param('instanceid', 0, PARAM_INT);
|
||||
optional_param('blockid', 0, PARAM_INT);
|
||||
|
||||
if (! $site = get_site()) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/index.php");
|
||||
}
|
||||
@@ -57,92 +61,32 @@
|
||||
|
||||
$editing = isediting($site->id);
|
||||
|
||||
// Doing this now so we can pass the results to block_action()
|
||||
// and dodge the overhead of doing the same work twice.
|
||||
$page = new stdClass;
|
||||
$page->id = SITEID;
|
||||
$page->type = MOODLE_PAGE_COURSE;
|
||||
|
||||
$blocks = $site->blockinfo;
|
||||
$delimpos = strpos($blocks, ':');
|
||||
|
||||
if($delimpos === false) {
|
||||
// No ':' found, we have all left blocks
|
||||
$leftblocks = explode(',', $blocks);
|
||||
$rightblocks = array();
|
||||
}
|
||||
else if($delimpos === 0) {
|
||||
// ':' at start of string, we have all right blocks
|
||||
$blocks = substr($blocks, 1);
|
||||
$leftblocks = array();
|
||||
$rightblocks = explode(',', $blocks);
|
||||
}
|
||||
else {
|
||||
// Both left and right blocks
|
||||
$leftpart = substr($blocks, 0, $delimpos);
|
||||
$rightpart = substr($blocks, $delimpos + 1);
|
||||
$leftblocks = explode(',', $leftpart);
|
||||
$rightblocks = explode(',', $rightpart);
|
||||
}
|
||||
$pageblocks = blocks_get_by_page($page);
|
||||
|
||||
if($editing) {
|
||||
if (isset($_GET['blockaction'])) {
|
||||
if (isset($_GET['blockid'])) {
|
||||
block_action($site, $leftblocks, $rightblocks, strtolower($_GET['blockaction']), intval($_GET['blockid']));
|
||||
if (!empty($blockaction) && confirm_sesskey()) {
|
||||
if (!empty($blockid)) {
|
||||
blocks_execute_action($page, $pageblocks, strtolower($blockaction), intval($blockid));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// This has to happen after block_action() has possibly updated the two arrays
|
||||
$allblocks = array_merge($leftblocks, $rightblocks);
|
||||
|
||||
$missingblocks = array();
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
|
||||
// Note down which blocks are going to get displayed
|
||||
blocks_used($allblocks, $recblocks);
|
||||
|
||||
if($editing && $recblocks) {
|
||||
foreach($recblocks as $recblock) {
|
||||
// If it's not hidden or displayed right now...
|
||||
if(!in_array($recblock->id, $allblocks) && !in_array(-($recblock->id), $allblocks)) {
|
||||
// And if it's applicable for display in this format...
|
||||
$formats = block_method_result($recblock->name, 'applicable_formats');
|
||||
|
||||
if( isset($formats['site']) ? $formats['site'] : !empty($formats['all'])) {
|
||||
// Translation: if the 'site' format is explicitly accepted/rejected, use
|
||||
// that setting. Otherwise, fallback to the 'all' format. The empty() test
|
||||
// uses the trick that empty() fails if 'all' is either !isset() or false.
|
||||
|
||||
// Add it to the missing blocks
|
||||
$missingblocks[] = $recblock->id;
|
||||
}
|
||||
}
|
||||
else if (!empty($instanceid)) {
|
||||
$instance = blocks_find_instance($instanceid, $pageblocks);
|
||||
blocks_execute_action($page, $pageblocks, strtolower($blockaction), $instance);
|
||||
}
|
||||
// This re-query could be eliminated by judicious programming in blocks_execute_action(),
|
||||
// but I 'm not sure if it's worth the complexity increase...
|
||||
$pageblocks = blocks_get_by_page($page);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Note down which blocks are going to get displayed
|
||||
$allblocks = array_merge($leftblocks, $rightblocks);
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
blocks_used($allblocks, $recblocks);
|
||||
}
|
||||
|
||||
// If the block width cache is not set, set it
|
||||
if(!isset($SESSION) or !isset($SESSION->blockcache) or
|
||||
!isset($SESSION->blockcache->width->{$site->id}) or $editing) {
|
||||
// This query might be optimized away if we 're in editing mode
|
||||
if(!isset($recblocks)) {
|
||||
$recblocks = get_records('blocks','visible','1');
|
||||
}
|
||||
$preferred_width_left = blocks_preferred_width($leftblocks, $recblocks);
|
||||
$preferred_width_right = blocks_preferred_width($rightblocks, $recblocks);
|
||||
|
||||
// This may be kind of organizational overkill, granted...
|
||||
// But is there any real need to simplify the structure?
|
||||
$SESSION->blockcache->width->{$site->id}->left = $preferred_width_left;
|
||||
$SESSION->blockcache->width->{$site->id}->right = $preferred_width_right;
|
||||
} else {
|
||||
$preferred_width_left = $SESSION->blockcache->width->{$site->id}->left;
|
||||
$preferred_width_right = $SESSION->blockcache->width->{$site->id}->right;
|
||||
$missingblocks = blocks_get_missing($page, $pageblocks);
|
||||
}
|
||||
|
||||
optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]));
|
||||
optional_variable($preferred_width_right, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]));
|
||||
$preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH);
|
||||
$preferred_width_right = min($preferred_width_right, BLOCK_R_MAX_WIDTH);
|
||||
@@ -155,9 +99,9 @@
|
||||
<tr>
|
||||
<?PHP
|
||||
|
||||
if(block_have_active($leftblocks) || $editing) {
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_LEFT]) || $editing) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_left.'px;">';
|
||||
print_course_blocks($site, $leftblocks, BLOCK_LEFT);
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_LEFT]);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -260,15 +204,18 @@
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
if(block_have_active($rightblocks) || $editing || isadmin()) {
|
||||
|
||||
|
||||
// The right column
|
||||
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing || isadmin()) {
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
if (isadmin()) {
|
||||
echo '<div align="center">'.update_course_icon($site->id).'</div>';
|
||||
echo '<br />';
|
||||
}
|
||||
print_course_blocks($site, $rightblocks, BLOCK_RIGHT);
|
||||
blocks_print_group($page, $pageblocks[BLOCK_POS_RIGHT]);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
block_print_blocks_admin($site, $missingblocks);
|
||||
blocks_print_adminblock($page, $missingblocks);
|
||||
}
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// admin.php - created with Moodle 1.2 development (2003111400)
|
||||
|
||||
|
||||
$string['blockinstances'] = 'Instances';
|
||||
$string['blockmultiple'] = 'Multiple';
|
||||
$string['change'] = 'change';
|
||||
$string['cachetext'] = 'Text cache lifetime';
|
||||
$string['filteruploadedfiles'] = 'Filter uploaded files';
|
||||
$string['upgradelogs'] = 'For full functionality, your old logs need to be upgraded. <a href=\"$a\">More information</a>';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php // $Id$
|
||||
|
||||
$string['blockname'] = 'Course Summary';
|
||||
$string['siteinfo'] = 'Site Information';
|
||||
$string['coursesummary'] = 'Course Summary';
|
||||
$string['pagedescription'] = 'Course/Site Description';
|
||||
|
||||
?>
|
||||
|
||||
@@ -116,6 +116,9 @@ $string['backuptakealook'] = 'Please take a look to your backup logs in:
|
||||
$string['backupuserfileshelp'] = 'Choose whether user files (eg profile images) should be included in automated backups';
|
||||
$string['backupusershelp'] = 'Select whether you want to include all the users in the server or only the needed users for each course';
|
||||
$string['backupversion'] = 'Backup Version';
|
||||
$string['blockconfiga'] = 'Configuring a $a block';
|
||||
$string['blockconfigin'] = 'Course: Configuring a block in $a';
|
||||
$string['blockconfigbad'] = 'This block has not been implemented correctly and thus cannot provide a configuration interface.';
|
||||
$string['blockdeleteconfirm'] = 'You are about to completely delete the block \'$a\'. This will completely delete everything in the database associated with this block. Are you SURE you want to continue?';
|
||||
$string['blockdeletefiles'] = 'All data associated with the block \'$a->block\' has been deleted from the database. To complete the deletion (and prevent the block re-installing itself), you should now delete this directory from your server: $a->directory';
|
||||
$string['blocks'] = 'Blocks';
|
||||
|
||||
+539
-533
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,6 @@ CREATE TABLE `prefix_course` (
|
||||
`format` varchar(10) NOT NULL default 'topics',
|
||||
`showgrades` smallint(2) unsigned NOT NULL default '1',
|
||||
`modinfo` longtext NOT NULL,
|
||||
`blockinfo` varchar(255) NOT NULL default '',
|
||||
`newsitems` smallint(5) unsigned NOT NULL default '1',
|
||||
`teacher` varchar(100) NOT NULL default 'Teacher',
|
||||
`teachers` varchar(100) NOT NULL default 'Teachers',
|
||||
|
||||
@@ -17,7 +17,6 @@ CREATE TABLE prefix_course (
|
||||
format varchar(10) NOT NULL default 'topics',
|
||||
showgrades integer NOT NULL default '1',
|
||||
modinfo text NOT NULL default '',
|
||||
blockinfo varchar(255) NOT NULL default '',
|
||||
newsitems integer NOT NULL default '1',
|
||||
teacher varchar(100) NOT NULL default 'Teacher',
|
||||
teachers varchar(100) NOT NULL default 'Teachers',
|
||||
|
||||
@@ -317,6 +317,35 @@ function stripslashes_safe($string) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive implementation of stripslashes()
|
||||
*
|
||||
* This function will allow you to strip the slashes from a variable.
|
||||
* If the variable is an array or object, slashes will be stripped
|
||||
* from the items (or properties) it contains, even if they are arrays
|
||||
* or objects themselves.
|
||||
*
|
||||
* @param mixed the variable to remove slashes from
|
||||
* @return mixed
|
||||
*/
|
||||
function stripslashes_recursive($var) {
|
||||
if(is_object($var)) {
|
||||
$properties = get_object_vars($var);
|
||||
foreach($properties as $property => $value) {
|
||||
$var->$property = stripslashes_recursive($value);
|
||||
}
|
||||
}
|
||||
else if(is_array($var)) {
|
||||
foreach($var as $property => $value) {
|
||||
$var[$property] = stripslashes_recursive($value);
|
||||
}
|
||||
}
|
||||
else if(is_string($var)) {
|
||||
$var = stripslashes($var);
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given some normal text this function will break up any
|
||||
* long words to a given size by inserting the given character
|
||||
@@ -3423,5 +3452,16 @@ function print_speller_code ($usehtmleditor=false) {
|
||||
function print_speller_button () {
|
||||
echo '<input type="button" value="Check spelling" onclick="openSpellChecker();" />'."\n";
|
||||
}
|
||||
|
||||
function page_source_script($page) {
|
||||
global $CFG;
|
||||
|
||||
switch($page->type) {
|
||||
case MOODLE_PAGE_COURSE:
|
||||
return $CFG->wwwroot.'/course/view.php?id='.$page->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
|
||||
?>
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2004100800; // YYYYMMDD = date of first major branch release 1.4
|
||||
$version = 2004101900; // YYYYMMDD = date of first major branch release 1.4
|
||||
// XY = increments within a single day
|
||||
|
||||
$release = '1.5 UNSTABLE DEVELOPMENT'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user