diff --git a/admin/blocks.php b/admin/blocks.php
index 1200244bda8a3..be7738e14ae10 100644
--- a/admin/blocks.php
+++ b/admin/blocks.php
@@ -126,7 +126,16 @@
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
$blockobject = false;
$strblockname = ''.$blockname.' ('.get_string('missingfromdisk').')';
+ $plugin = new object();
+ $plugin->version = $block->version;
+
} else {
+ $plugin = new object();
+ $plugin->version = '???';
+ if (file_exists("$CFG->dirroot/blocks/$blockname/version.php")) {
+ include("$CFG->dirroot/blocks/$blockname/version.php");
+ }
+
if (!$blockobject = block_instance($block->name)) {
$incompatible[] = $block;
continue;
@@ -172,14 +181,17 @@
$class = ' class="dimmed_text"'; // Leading space required!
}
-
- if ($blockobject) {
- $blockobject->get_version();
+ if ($block->version == $plugin->version) {
+ $version = $block->version;
+ } else {
+ $version = "$block->version ($plugin->version)";
}
+
+
$table->add_data(array(
''.$strblockname.'',
$blocklist,
- ''.$block->version.'',
+ ''.$version.'',
$visible,
$delete,
$settings
diff --git a/blocks/activity_modules/block_activity_modules.php b/blocks/activity_modules/block_activity_modules.php
index cc798181ff07b..75cfe1afeef6c 100644
--- a/blocks/activity_modules/block_activity_modules.php
+++ b/blocks/activity_modules/block_activity_modules.php
@@ -3,7 +3,6 @@
class block_activity_modules extends block_list {
function init() {
$this->title = get_string('pluginname', 'block_activity_modules');
- $this->version = 2007101509;
}
function get_content() {
diff --git a/blocks/activity_modules/version.php b/blocks/activity_modules/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/activity_modules/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/admin_bookmarks/block_admin_bookmarks.php b/blocks/admin_bookmarks/block_admin_bookmarks.php
index 4c7c365609586..0b3b039ec25cd 100644
--- a/blocks/admin_bookmarks/block_admin_bookmarks.php
+++ b/blocks/admin_bookmarks/block_admin_bookmarks.php
@@ -8,7 +8,6 @@ class block_admin_bookmarks extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_admin_bookmarks');
- $this->version = 2007101509;
}
function applicable_formats() {
diff --git a/blocks/admin_bookmarks/version.php b/blocks/admin_bookmarks/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/admin_bookmarks/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/blog_menu/block_blog_menu.php b/blocks/blog_menu/block_blog_menu.php
index a6ca221666799..b431a39e702e1 100755
--- a/blocks/blog_menu/block_blog_menu.php
+++ b/blocks/blog_menu/block_blog_menu.php
@@ -37,7 +37,6 @@ class block_blog_menu extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_blog_menu');
- $this->version = 2009071700;
}
function instance_allow_multiple() {
@@ -57,7 +56,7 @@ function instance_allow_config() {
}
function get_content() {
-
+
// Check if we've already generated content
if (!empty($this->content)) {
return $this->content;
@@ -79,7 +78,7 @@ function get_content() {
}
return $this->content;
}
-
+
// Iterate the option types
$menulist = array();
foreach ($options as $types) {
diff --git a/blocks/blog_menu/version.php b/blocks/blog_menu/version.php
new file mode 100644
index 0000000000000..80440b61034f6
--- /dev/null
+++ b/blocks/blog_menu/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009071700;
diff --git a/blocks/blog_recent/block_blog_recent.php b/blocks/blog_recent/block_blog_recent.php
index 70c87d6bd0d42..e9dc80ce601b1 100644
--- a/blocks/blog_recent/block_blog_recent.php
+++ b/blocks/blog_recent/block_blog_recent.php
@@ -37,7 +37,6 @@ class block_blog_recent extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_blog_recent');
$this->content_type = BLOCK_TYPE_TEXT;
- $this->version = 2009070900;
}
function applicable_formats() {
diff --git a/blocks/blog_recent/version.php b/blocks/blog_recent/version.php
new file mode 100644
index 0000000000000..3cae55d31cb8f
--- /dev/null
+++ b/blocks/blog_recent/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009070900;
diff --git a/blocks/blog_tags/block_blog_tags.php b/blocks/blog_tags/block_blog_tags.php
index 7bbca1d93a6c5..a5d8250754998 100644
--- a/blocks/blog_tags/block_blog_tags.php
+++ b/blocks/blog_tags/block_blog_tags.php
@@ -1,5 +1,7 @@
version = 2007101509;
$this->title = get_string('pluginname', 'block_blog_tags');
}
diff --git a/blocks/blog_tags/version.php b/blocks/blog_tags/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/blog_tags/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/calendar_month/block_calendar_month.php b/blocks/calendar_month/block_calendar_month.php
index 72037401e7aaa..67488c493cdfd 100644
--- a/blocks/calendar_month/block_calendar_month.php
+++ b/blocks/calendar_month/block_calendar_month.php
@@ -3,7 +3,6 @@
class block_calendar_month extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_calendar_month');
- $this->version = 2007101509;
}
function preferred_width() {
diff --git a/blocks/calendar_month/version.php b/blocks/calendar_month/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/calendar_month/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/calendar_upcoming/block_calendar_upcoming.php b/blocks/calendar_upcoming/block_calendar_upcoming.php
index 9716b080e779f..21d63b4509482 100644
--- a/blocks/calendar_upcoming/block_calendar_upcoming.php
+++ b/blocks/calendar_upcoming/block_calendar_upcoming.php
@@ -3,7 +3,6 @@
class block_calendar_upcoming extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_calendar_upcoming');
- $this->version = 2007101509;
}
function get_content() {
diff --git a/blocks/calendar_upcoming/version.php b/blocks/calendar_upcoming/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/calendar_upcoming/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/comments/block_comments.php b/blocks/comments/block_comments.php
index a90fcab1b8a40..f855ad3814b07 100644
--- a/blocks/comments/block_comments.php
+++ b/blocks/comments/block_comments.php
@@ -6,7 +6,6 @@ class block_comments extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_comments');
- $this->version = 2009072000;
}
function specialization() {
diff --git a/blocks/comments/version.php b/blocks/comments/version.php
new file mode 100644
index 0000000000000..643149d022f16
--- /dev/null
+++ b/blocks/comments/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009072000;
diff --git a/blocks/community/block_community.php b/blocks/community/block_community.php
index 2eb8dc6f6b305..d26670d1fc954 100644
--- a/blocks/community/block_community.php
+++ b/blocks/community/block_community.php
@@ -27,7 +27,6 @@
class block_community extends block_list {
function init() {
$this->title = get_string('pluginname', 'block_community');
- $this->version = 2010042701;
}
function user_can_addto($page) {
@@ -80,8 +79,8 @@ function get_content() {
$this->content->icons[] = '';
foreach ($courses as $course) {
//delete link
- $deleteicon = html_writer::empty_tag('img',
- array('src' => $OUTPUT->pix_url('i/cross_red_small'),
+ $deleteicon = html_writer::empty_tag('img',
+ array('src' => $OUTPUT->pix_url('i/cross_red_small'),
'alt' => get_string('removecommunitycourse', 'block_community')));
$deleteurl = new moodle_url($CFG->wwwroot.'/blocks/community/communitycourse.php',
array('remove'=>true, 'communityid'=> $course->id, 'sesskey' => sesskey()));
diff --git a/blocks/community/version.php b/blocks/community/version.php
new file mode 100644
index 0000000000000..7f14cbf276ebf
--- /dev/null
+++ b/blocks/community/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2010042701;
diff --git a/blocks/completionstatus/block_completionstatus.php b/blocks/completionstatus/block_completionstatus.php
index 90fd9010d41f7..083debf058c29 100644
--- a/blocks/completionstatus/block_completionstatus.php
+++ b/blocks/completionstatus/block_completionstatus.php
@@ -34,7 +34,6 @@ class block_completionstatus extends block_base {
public function init() {
$this->title = get_string('completionstatus', 'block_completionstatus');
- $this->version = 2009072800;
}
public function get_content() {
diff --git a/blocks/completionstatus/version.php b/blocks/completionstatus/version.php
new file mode 100644
index 0000000000000..279b0014f3586
--- /dev/null
+++ b/blocks/completionstatus/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009072800;
diff --git a/blocks/course_list/block_course_list.php b/blocks/course_list/block_course_list.php
index 0d52ebd7db140..a658c74ec63ca 100644
--- a/blocks/course_list/block_course_list.php
+++ b/blocks/course_list/block_course_list.php
@@ -5,7 +5,6 @@
class block_course_list extends block_list {
function init() {
$this->title = get_string('courses');
- $this->version = 2007101509;
}
function has_config() {
diff --git a/blocks/course_list/version.php b/blocks/course_list/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/course_list/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/course_overview/block_course_overview.php b/blocks/course_overview/block_course_overview.php
index c9f1d1e5d38ae..a183ee20a6eb5 100644
--- a/blocks/course_overview/block_course_overview.php
+++ b/blocks/course_overview/block_course_overview.php
@@ -33,7 +33,6 @@ class block_course_overview extends block_base {
*/
public function init() {
$this->title = get_string('pluginname', 'block_course_overview');
- $this->version = 2010021100;
}
/**
diff --git a/blocks/course_overview/version.php b/blocks/course_overview/version.php
new file mode 100644
index 0000000000000..2e54a20f5042d
--- /dev/null
+++ b/blocks/course_overview/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2010021100;
diff --git a/blocks/course_summary/block_course_summary.php b/blocks/course_summary/block_course_summary.php
index e223ca2c84d10..790a5e6228a23 100644
--- a/blocks/course_summary/block_course_summary.php
+++ b/blocks/course_summary/block_course_summary.php
@@ -3,7 +3,6 @@
class block_course_summary extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_course_summary');
- $this->version = 2007101509;
}
function specialization() {
diff --git a/blocks/course_summary/version.php b/blocks/course_summary/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/course_summary/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/feedback/block_feedback.php b/blocks/feedback/block_feedback.php
index 9d82dbfa54c46..825f67859db52 100644
--- a/blocks/feedback/block_feedback.php
+++ b/blocks/feedback/block_feedback.php
@@ -8,36 +8,35 @@ class block_feedback extends block_base {
function init() {
$this->title = get_string('feedback', 'block_feedback');
- $this->version = 2010050200;
}
-
+
function applicable_formats() {
return array('site' => true, 'course' => true);
}
function get_content() {
global $CFG, $OUTPUT;
-
+
if ($this->content !== NULL) {
return $this->content;
}
-
+
if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) {
$this->content = new stdClass;
$this->content->text = get_string('missing_feedback_module', 'block_feedback');
$this->content->footer = '';
return $this->content;
}
-
+
$courseid = $this->page->course->id;
if ($courseid <= 0) {
$courseid = SITEID;
}
-
+
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
-
+
if (empty($this->instance->pageid)) {
$this->instance->pageid = SITEID;
diff --git a/blocks/feedback/version.php b/blocks/feedback/version.php
new file mode 100644
index 0000000000000..59d59fcac151f
--- /dev/null
+++ b/blocks/feedback/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2010050200;
diff --git a/blocks/glossary_random/block_glossary_random.php b/blocks/glossary_random/block_glossary_random.php
index da3688ca62b50..bff459c05177f 100644
--- a/blocks/glossary_random/block_glossary_random.php
+++ b/blocks/glossary_random/block_glossary_random.php
@@ -6,10 +6,7 @@
class block_glossary_random extends block_base {
function init() {
-
$this->title = get_string('pluginname','block_glossary_random');
- $this->version = 2007101509;
-
}
function specialization() {
diff --git a/blocks/glossary_random/version.php b/blocks/glossary_random/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/glossary_random/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/html/block_html.php b/blocks/html/block_html.php
index 91910a0cbb146..44eec676beb58 100755
--- a/blocks/html/block_html.php
+++ b/blocks/html/block_html.php
@@ -27,7 +27,6 @@ class block_html extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_html');
- $this->version = 2007101509;
}
function applicable_formats() {
diff --git a/blocks/html/version.php b/blocks/html/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/html/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/login/block_login.php b/blocks/login/block_login.php
index 0981dd44b4dfe..da53e5a977d84 100644
--- a/blocks/login/block_login.php
+++ b/blocks/login/block_login.php
@@ -3,7 +3,6 @@
class block_login extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_login');
- $this->version = 2007101509;
}
function applicable_formats() {
diff --git a/blocks/login/version.php b/blocks/login/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/login/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/mentees/block_mentees.php b/blocks/mentees/block_mentees.php
index 9650862b30299..45d9463cf7bae 100755
--- a/blocks/mentees/block_mentees.php
+++ b/blocks/mentees/block_mentees.php
@@ -4,7 +4,6 @@ class block_mentees extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_mentees');
- $this->version = 2007101509;
}
function applicable_formats() {
diff --git a/blocks/mentees/version.php b/blocks/mentees/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/mentees/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/messages/block_messages.php b/blocks/messages/block_messages.php
index 7524fc6c1b371..32e50e5ef077b 100644
--- a/blocks/messages/block_messages.php
+++ b/blocks/messages/block_messages.php
@@ -3,7 +3,6 @@
class block_messages extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_messages');
- $this->version = 2007101509;
}
function get_content() {
@@ -52,7 +51,7 @@ function get_content() {
$link = '/message/discussion.php?id='.$user->id;
$anchortagcontents = '
'.$user->count;
-
+
$action = new popup_action('click', $link, 'message_'.$user->id);
$anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);
diff --git a/blocks/messages/version.php b/blocks/messages/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/messages/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/mnet_hosts/block_mnet_hosts.php b/blocks/mnet_hosts/block_mnet_hosts.php
index c53741fe7f249..98cf00dc72de2 100644
--- a/blocks/mnet_hosts/block_mnet_hosts.php
+++ b/blocks/mnet_hosts/block_mnet_hosts.php
@@ -3,7 +3,6 @@
class block_mnet_hosts extends block_list {
function init() {
$this->title = get_string('pluginname','block_mnet_hosts') ;
- $this->version = 2007101509;
}
function has_config() {
diff --git a/blocks/mnet_hosts/version.php b/blocks/mnet_hosts/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/mnet_hosts/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php
index 4c2806f489885..a285ac2e6d94c 100644
--- a/blocks/moodleblock.class.php
+++ b/blocks/moodleblock.class.php
@@ -76,12 +76,6 @@ class block_base {
*/
var $edit_controls = NULL;
- /**
- * The current version that the block type defines.
- * @var string $version
- */
- var $version = NULL;
-
/**
* The initialized instance of this block object.
* @var block $instance
@@ -115,20 +109,12 @@ class block_base {
/// Class Functions
- /**
- * The class constructor
- *
- */
- function block_base() {
- $this->init();
- }
-
/**
* Fake constructor to keep PHP5 happy
*
*/
function __construct() {
- $this->block_base();
+ $this->init();
}
/**
@@ -300,19 +286,6 @@ function get_content_type() {
return $this->content_type;
}
- /**
- * Returns the class $version var value.
- *
- * Intentionally doesn't check if a version is set.
- * This is already done in {@link _self_test()}
- *
- * @return string $this->version
- */
- function get_version() {
- // Intentionally doesn't check if a version is set. This is already done in _self_test()
- return $this->version;
- }
-
/**
* Returns true or false, depending on whether this block has any content to display
* and whether the user has permission to view the block
@@ -444,11 +417,6 @@ function _self_test() {
$errors[] = 'content_not_set';
$correct = false;
}*/
- if ($this->get_version() === NULL) {
- $errors[] = 'version_not_set';
- $correct = false;
- }
-
$formats = $this->applicable_formats();
if (empty($formats) || array_sum($formats) === 0) {
$errors[] = 'no_formats';
diff --git a/blocks/myprofile/block_myprofile.php b/blocks/myprofile/block_myprofile.php
index a130f1168b98d..676e33d80c20c 100644
--- a/blocks/myprofile/block_myprofile.php
+++ b/blocks/myprofile/block_myprofile.php
@@ -37,7 +37,6 @@ class block_myprofile extends block_base {
*/
public function init() {
$this->title = get_string('pluginname', 'block_myprofile');
- $this->version = 2009123100;
}
/**
diff --git a/blocks/myprofile/version.php b/blocks/myprofile/version.php
new file mode 100644
index 0000000000000..fa4218c7fc1c5
--- /dev/null
+++ b/blocks/myprofile/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009123100;
diff --git a/blocks/navigation/block_navigation.php b/blocks/navigation/block_navigation.php
index 36a4e6b794e8d..9c612f61ea53c 100644
--- a/blocks/navigation/block_navigation.php
+++ b/blocks/navigation/block_navigation.php
@@ -59,7 +59,6 @@ function init() {
global $CFG;
$this->blockname = get_class($this);
$this->title = get_string('pluginname', $this->blockname);
- $this->version = 2009082800;
}
/**
diff --git a/blocks/navigation/version.php b/blocks/navigation/version.php
new file mode 100644
index 0000000000000..ed16d20e4b2dd
--- /dev/null
+++ b/blocks/navigation/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009082800;
diff --git a/blocks/news_items/block_news_items.php b/blocks/news_items/block_news_items.php
index 8ff1041714aa0..d28f380a54d95 100644
--- a/blocks/news_items/block_news_items.php
+++ b/blocks/news_items/block_news_items.php
@@ -3,7 +3,6 @@
class block_news_items extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_news_items');
- $this->version = 2007101509;
}
function get_content() {
diff --git a/blocks/news_items/version.php b/blocks/news_items/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/news_items/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php
index 9cc727f08d544..c817394240520 100644
--- a/blocks/online_users/block_online_users.php
+++ b/blocks/online_users/block_online_users.php
@@ -8,7 +8,6 @@
class block_online_users extends block_base {
function init() {
$this->title = get_string('pluginname','block_online_users');
- $this->version = 2007101510;
}
function has_config() {return true;}
@@ -80,7 +79,7 @@ function get_content() {
$sql = "SELECT $userfields, MAX(ul.timeaccess) AS lastaccess
FROM {user_lastaccess} ul, {user} u $groupmembers $rafrom
- JOIN ($esqljoin) euj ON euj.id = u.id
+ JOIN ($esqljoin) euj ON euj.id = u.id
WHERE ul.timeaccess > $timefrom
AND u.id = ul.userid
AND ul.courseid = :courseid
diff --git a/blocks/online_users/version.php b/blocks/online_users/version.php
new file mode 100644
index 0000000000000..d343c63caacc0
--- /dev/null
+++ b/blocks/online_users/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101510;
diff --git a/blocks/participants/block_participants.php b/blocks/participants/block_participants.php
index 277ab7e369a7f..7a056ca2f84e1 100644
--- a/blocks/participants/block_participants.php
+++ b/blocks/participants/block_participants.php
@@ -3,7 +3,6 @@
class block_participants extends block_list {
function init() {
$this->title = get_string('pluginname', 'block_participants');
- $this->version = 2007101509;
}
function get_content() {
diff --git a/blocks/participants/version.php b/blocks/participants/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/participants/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/private_files/block_private_files.php b/blocks/private_files/block_private_files.php
index 7f69be0d8f05e..cc8432efca369 100755
--- a/blocks/private_files/block_private_files.php
+++ b/blocks/private_files/block_private_files.php
@@ -31,7 +31,6 @@ class block_private_files extends block_base {
function init() {
$this->title = get_string('areauserpersonal', 'repository');
- $this->version = 2010030100;
}
function specialization() {
diff --git a/blocks/private_files/version.php b/blocks/private_files/version.php
new file mode 100644
index 0000000000000..c9d9cb357762c
--- /dev/null
+++ b/blocks/private_files/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2010030100;
diff --git a/blocks/quiz_results/block_quiz_results.php b/blocks/quiz_results/block_quiz_results.php
index 08ee2eae7f2f4..a6bb6027ceb26 100644
--- a/blocks/quiz_results/block_quiz_results.php
+++ b/blocks/quiz_results/block_quiz_results.php
@@ -10,7 +10,6 @@
class block_quiz_results extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_quiz_results');
- $this->version = 2007101509;
}
function applicable_formats() {
diff --git a/blocks/quiz_results/version.php b/blocks/quiz_results/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/quiz_results/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/recent_activity/block_recent_activity.php b/blocks/recent_activity/block_recent_activity.php
index 8653a094a6956..c4d2f555ecb2f 100644
--- a/blocks/recent_activity/block_recent_activity.php
+++ b/blocks/recent_activity/block_recent_activity.php
@@ -3,7 +3,6 @@
class block_recent_activity extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_recent_activity');
- $this->version = 2007101509;
}
function get_content() {
diff --git a/blocks/recent_activity/version.php b/blocks/recent_activity/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/recent_activity/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/rss_client/block_rss_client.php b/blocks/rss_client/block_rss_client.php
index 8a4d507c1737b..ff844b6a37af3 100644
--- a/blocks/rss_client/block_rss_client.php
+++ b/blocks/rss_client/block_rss_client.php
@@ -27,8 +27,6 @@ class block_rss_client extends block_base {
function init() {
$this->title = get_string('feedstitle', 'block_rss_client');
- $this->version = 2009072901;
- $this->cron = 300; /// Set min time between cron executions to 300 secs (5 mins)
}
function preferred_width() {
diff --git a/blocks/rss_client/version.php b/blocks/rss_client/version.php
new file mode 100644
index 0000000000000..edc9f2fb60cd5
--- /dev/null
+++ b/blocks/rss_client/version.php
@@ -0,0 +1,19 @@
+.
+
+$plugin->version = 2009072901;
+$plugin->cron = 300; /// Set min time between cron executions to 300 secs (5 mins)
diff --git a/blocks/search/block_search.php b/blocks/search/block_search.php
index 79be3f1719e9f..ea8b7820edcad 100644
--- a/blocks/search/block_search.php
+++ b/blocks/search/block_search.php
@@ -15,8 +15,6 @@ class block_search extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_search');
- $this->cron = 1;
- $this->version = 2008031500;
} //init
// only one instance of this block is required
diff --git a/blocks/search/version.php b/blocks/search/version.php
new file mode 100644
index 0000000000000..93d21828aa7de
--- /dev/null
+++ b/blocks/search/version.php
@@ -0,0 +1,19 @@
+.
+
+$plugin->version = 2008031500;
+$plugin->cron = 1;
diff --git a/blocks/search_forums/block_search_forums.php b/blocks/search_forums/block_search_forums.php
index 98220ef47606d..02eef48001ddd 100644
--- a/blocks/search_forums/block_search_forums.php
+++ b/blocks/search_forums/block_search_forums.php
@@ -3,7 +3,6 @@
class block_search_forums extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_search_forums');
- $this->version = 2007101509;
}
function get_content() {
diff --git a/blocks/search_forums/version.php b/blocks/search_forums/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/search_forums/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/section_links/block_section_links.php b/blocks/section_links/block_section_links.php
index 209ddb0e7ccf0..1e80286bdec62 100644
--- a/blocks/section_links/block_section_links.php
+++ b/blocks/section_links/block_section_links.php
@@ -26,7 +26,6 @@ class block_section_links extends block_base {
function init() {
$this->title = get_string('pluginname', 'block_section_links');
- $this->version = 2007101511;
}
function instance_config($instance) {
diff --git a/blocks/section_links/version.php b/blocks/section_links/version.php
new file mode 100644
index 0000000000000..7314aac2f7bfb
--- /dev/null
+++ b/blocks/section_links/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101511;
diff --git a/blocks/selfcompletion/block_selfcompletion.php b/blocks/selfcompletion/block_selfcompletion.php
index e19af5f9a3662..50567bfdda4ae 100644
--- a/blocks/selfcompletion/block_selfcompletion.php
+++ b/blocks/selfcompletion/block_selfcompletion.php
@@ -37,7 +37,6 @@ class block_selfcompletion extends block_base {
public function init() {
$this->title = get_string('selfcompletion', 'block_selfcompletion');
- $this->version = 2009072800;
}
public function get_content() {
diff --git a/blocks/selfcompletion/version.php b/blocks/selfcompletion/version.php
new file mode 100644
index 0000000000000..279b0014f3586
--- /dev/null
+++ b/blocks/selfcompletion/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009072800;
diff --git a/blocks/settings/block_settings.php b/blocks/settings/block_settings.php
index 8be053c30e2ca..c338cfaf773d1 100644
--- a/blocks/settings/block_settings.php
+++ b/blocks/settings/block_settings.php
@@ -50,7 +50,6 @@ class block_settings extends block_base {
function init() {
$this->blockname = get_class($this);
$this->title = get_string('pluginname', $this->blockname);
- $this->version = 2009082800;
}
/**
diff --git a/blocks/settings/version.php b/blocks/settings/version.php
new file mode 100644
index 0000000000000..ed16d20e4b2dd
--- /dev/null
+++ b/blocks/settings/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2009082800;
diff --git a/blocks/site_main_menu/block_site_main_menu.php b/blocks/site_main_menu/block_site_main_menu.php
index 02595c289bc0c..5f8891bcc0237 100644
--- a/blocks/site_main_menu/block_site_main_menu.php
+++ b/blocks/site_main_menu/block_site_main_menu.php
@@ -3,9 +3,8 @@
class block_site_main_menu extends block_list {
function init() {
$this->title = get_string('pluginname', 'block_site_main_menu');
- $this->version = 2007101509;
}
-
+
function applicable_formats() {
return array('site' => true);
}
diff --git a/blocks/site_main_menu/version.php b/blocks/site_main_menu/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/site_main_menu/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/social_activities/block_social_activities.php b/blocks/social_activities/block_social_activities.php
index 1e99653c1be8b..af533f8b34954 100644
--- a/blocks/social_activities/block_social_activities.php
+++ b/blocks/social_activities/block_social_activities.php
@@ -3,7 +3,6 @@
class block_social_activities extends block_list {
function init(){
$this->title = get_string('pluginname', 'block_social_activities');
- $this->version = 2007101509;
}
function applicable_formats() {
diff --git a/blocks/social_activities/version.php b/blocks/social_activities/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/social_activities/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/tag_flickr/block_tag_flickr.php b/blocks/tag_flickr/block_tag_flickr.php
index 6dc97ceef4786..93ca5462f334b 100644
--- a/blocks/tag_flickr/block_tag_flickr.php
+++ b/blocks/tag_flickr/block_tag_flickr.php
@@ -1,8 +1,5 @@
dirroot.'/tag/lib.php');
-require_once($CFG->libdir . '/filelib.php');
-
define('FLICKR_DEV_KEY', '4fddbdd7ff2376beec54d7f6afad425e');
define('DEFAULT_NUMBER_OF_PHOTOS', 6);
@@ -10,7 +7,6 @@ class block_tag_flickr extends block_base {
function init() {
$this->title = get_string('pluginname','block_tag_flickr');
- $this->version = 2007101509;
}
function applicable_formats() {
@@ -30,9 +26,12 @@ function preferred_width() {
}
function get_content() {
-
global $CFG, $USER;
+ //note: do NOT include files at the top of this file
+ require_once($CFG->dirroot.'/tag/lib.php');
+ require_once($CFG->libdir . '/filelib.php');
+
if ($this->content !== NULL) {
return $this->content;
}
diff --git a/blocks/tag_flickr/version.php b/blocks/tag_flickr/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/tag_flickr/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/tag_youtube/block_tag_youtube.php b/blocks/tag_youtube/block_tag_youtube.php
index 982f5790503b2..139298bafe076 100644
--- a/blocks/tag_youtube/block_tag_youtube.php
+++ b/blocks/tag_youtube/block_tag_youtube.php
@@ -1,15 +1,11 @@
dirroot.'/tag/lib.php');
-require_once($CFG->libdir . '/filelib.php');
-
define('DEFAULT_NUMBER_OF_VIDEOS', 5);
class block_tag_youtube extends block_base {
function init() {
$this->title = get_string('pluginname','block_tag_youtube');
- $this->version = 2007101509;
}
function applicable_formats() {
@@ -32,6 +28,11 @@ function preferred_width() {
}
function get_content() {
+ global $CFG;
+
+ //note: do NOT include files at the top of this file
+ require_once($CFG->dirroot.'/tag/lib.php');
+ require_once($CFG->libdir . '/filelib.php');
if ($this->content !== NULL) {
return $this->content;
diff --git a/blocks/tag_youtube/version.php b/blocks/tag_youtube/version.php
new file mode 100644
index 0000000000000..c9abcfeb82034
--- /dev/null
+++ b/blocks/tag_youtube/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2007101509;
diff --git a/blocks/tags/block_tags.php b/blocks/tags/block_tags.php
index c10c9e8a4d22a..3cd2ba2887016 100644
--- a/blocks/tags/block_tags.php
+++ b/blocks/tags/block_tags.php
@@ -2,7 +2,6 @@
class block_tags extends block_base {
function init() {
- $this->version = 2008063001;
$this->title = get_string('pluginname', 'block_tags');
// the cron function goes through all users, so only do daily
// (this creates rss feeds for personal course tags)
diff --git a/blocks/tags/version.php b/blocks/tags/version.php
new file mode 100644
index 0000000000000..26eef2756e1df
--- /dev/null
+++ b/blocks/tags/version.php
@@ -0,0 +1,18 @@
+.
+
+$plugin->version = 2008063001;
diff --git a/blocks/upgrade.txt b/blocks/upgrade.txt
index 51e99501b7e59..6d3f42a35e891 100644
--- a/blocks/upgrade.txt
+++ b/blocks/upgrade.txt
@@ -16,6 +16,7 @@ required changes in code:
old global $THEME is fully replaced by $OUTPUT
* remove '_utf8' from language pack names, use new {$a} syntax in language packs
* use 'pluginname' lang pack identifier instead of 'blockname'
+* move cron and version number into standard version.php
optional - no changes needed in older code:
*
diff --git a/lang/en/error.php b/lang/en/error.php
index 29f308476ee15..10010ae8f916d 100755
--- a/lang/en/error.php
+++ b/lang/en/error.php
@@ -185,7 +185,7 @@
$string['dbsessionhandlerproblem'] = 'Setting up of database session failed.
Please notify server administrator.';
$string['dbsessionmysqlpacketsize'] = 'Serious session error detected.
Please notify administrator, this problem is most probably caused by small value in max_allowed_packet MySQL setting.';
$string['dbupdatefailed'] = 'Database update failed';
-$string['ddldependencyerror'] = '{$a->targettype} "{$a->targetname}" cannot be modifed. Dependency found with {$a->offendingtype} "{$a->offendingname}"';
+$string['ddldependencyerror'] = '{$a->targettype} "{$a->targetname}" cannot be modified. Dependency found with {$a->offendingtype} "{$a->offendingname}"';
$string['ddlexecuteerror'] = 'DDL sql execution error';
$string['ddlfieldalreadyexists'] = 'Field "{$a}" already exists';
$string['ddlfieldnotexist'] = 'Field "{$a->fieldname}" does not exist in table "{$a->tablename}"';
@@ -194,7 +194,7 @@
$string['ddlunknownerror'] = 'Unknown DDL library error';
$string['ddlxmlfileerror'] = 'XML database file errors found';
$string['destinationcmnotexit'] = 'The destination course module does not exist';
-$string['detectedbrokenplugin'] = 'Plugin "{$a}" is defective, can not continue, sorry.';
+$string['detectedbrokenplugin'] = 'Plugin "{$a}" is defective or outdated, can not continue, sorry.';
$string['dmlreadexception'] = 'Error reading from database';
$string['dmltransactionexception'] = 'Database transaction error';
$string['dmlwriteexception'] = 'Error writing to database';
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 602ffe6422085..70a293351d771 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -7553,18 +7553,15 @@ function moodle_needs_upgrading() {
if ($blockname === 'NEWBLOCK') { // Someone has unzipped the template, ignore it
continue;
}
- if (!is_readable($fullblock.'/block_'.$blockname.'.php')) {
+ if (!is_readable($fullblock.'/version.php')) {
continue;
}
- include_once($fullblock.'/block_'.$blockname.'.php');
- $classname = 'block_'.$blockname;
- if (!class_exists($classname)) {
- continue;
- }
- $blockobj = new $classname;
+ $plugin = new object();
+ $plugin->version = NULL;
+ include($fullblock.'/version.php');
if (empty($installed[$blockname])) {
return true;
- } else if ($blockobj->get_version() > $installed[$blockname]->version) {
+ } else if ($plugin->version > $installed[$blockname]->version) {
return true;
}
}
diff --git a/lib/upgradelib.php b/lib/upgradelib.php
index d388203ab195c..fa917e83544fd 100644
--- a/lib/upgradelib.php
+++ b/lib/upgradelib.php
@@ -568,10 +568,19 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
$component = 'block_'.$blockname;
+ if (!is_readable($fullblock.'/version.php')) {
+ throw new plugin_defective_exception('block/'.$blockname, 'Missing version.php file.');
+ }
+ $plugin = new object();
+ $plugin->version = NULL;
+ $plugin->cron = 0;
+ include($fullblock.'/version.php');
+ $block = $plugin;
+
if (!is_readable($fullblock.'/block_'.$blockname.'.php')) {
throw new plugin_defective_exception('block/'.$blockname, 'Missing main block class file.');
}
- require_once($fullblock.'/block_'.$blockname.'.php');
+ include_once($fullblock.'/block_'.$blockname.'.php');
$classname = 'block_'.$blockname;
@@ -587,10 +596,7 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
throw new plugin_defective_exception($component, 'Self test failed.');
}
- $block = new object(); // This may be used to update the db below
$block->name = $blockname; // The name MUST match the directory
- $block->version = $blockobj->get_version();
- $block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
$block->multiple = $blockobj->instance_allow_multiple() ? 1 : 0;
if (empty($block->version)) {