$this->version = 2004081200;
}
- function applicable_formats() {
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- }
-
function get_content() {
if($this->content !== NULL) {
$this->version = 2004081200;
}
- function applicable_formats() {
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- }
-
function get_content() {
global $USER, $CFG, $SESSION;
optional_variable($_GET['cal_m']);
$this->version = 2004052600;
}
- function applicable_formats() {
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- }
-
function get_content() {
global $USER, $CFG, $SESSION;
optional_variable($_GET['cal_m']);
return true;
}
- function applicable_formats() {
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- }
-
function get_content() {
global $THEME, $CFG, $USER;
$this->version = 2004052600;
}
- function applicable_formats() {
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- }
-
function get_content() {
global $CFG, $THEME;
}
function applicable_formats() {
- return COURSE_FORMAT_SITE;
+ return array('site' => true);
}
function get_content () {
$errors[] = 'version_not_set';
$correct = false;
}
- $allformats = COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- if(!($this->applicable_formats() & $allformats)) {
+
+ $formats = $this->applicable_formats();
+ if(empty($formats) || array_sum($formats) === 0) {
$errors[] = 'no_course_formats';
$correct = false;
}
+
$width = $this->preferred_width();
if(!is_int($width) || $width <= 0) {
$errors[] = 'invalid_width';
}
function applicable_formats() {
// Default case: the block can be used in all course types
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
+ return array('all' => true);
}
function preferred_width() {
// Default case: the block wants to be 180 pixels wide
$this->version = 2004052600;
}
- function applicable_formats() {
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- }
-
function get_content() {
global $CFG;
$this->version = 2004052700;
}
- function applicable_formats() {
- return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL | COURSE_FORMAT_SITE;
- }
-
function has_config() {return true;}
function print_config() {
}
function applicable_formats() {
- return (COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS);
+ return (array('weeks' => true, 'topics' => true));
}
function get_content() {
}
function applicable_formats() {
- return COURSE_FORMAT_SITE;
+ return array('site' => true);
}
function get_content() {
}
function applicable_formats() {
- return COURSE_FORMAT_SOCIAL;
+ return array('social' => true);
}
function get_content() {
$course->format = 'weeks'; // Default format is weeks
}
- // Can't avoid this... :(
- switch($course->format) {
- case 'weeks':
- $courseformat = COURSE_FORMAT_WEEKS;
- break;
- case 'topics':
- $courseformat = COURSE_FORMAT_TOPICS;
- break;
- case 'social':
- $courseformat = COURSE_FORMAT_SOCIAL;
- break;
- default:
- $courseformat = 0;
- }
-
// Doing this now so we can pass the results to block_action()
// and dodge the overhead of doing the same work twice.
// 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...
- if(block_method_result($recblock->name, 'applicable_formats') & $courseformat) {
+ $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;
}
$editing = isediting($site->id);
- $courseformat = COURSE_FORMAT_SITE;
-
// Doing this now so we can pass the results to block_action()
// and dodge the overhead of doing the same work twice.
// 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...
- if(block_method_result($recblock->name, 'applicable_formats') & $courseformat) {
+ $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;
}