From d44862568241972641ea4288abe9d7e0d1152860 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 18 Jan 2013 14:14:40 +0800 Subject: [PATCH] MDL-37414 blocks: re-added the ability to add some blocks to the My Moodle --- .../glossary_random/block_glossary_random.php | 4 -- blocks/glossary_random/db/access.php | 10 +++ blocks/glossary_random/db/upgrade.php | 69 ------------------- .../lang/en/block_glossary_random.php | 1 + blocks/glossary_random/version.php | 2 +- blocks/mentees/block_mentees.php | 2 +- blocks/mentees/db/access.php | 10 +++ blocks/mentees/db/upgrade.php | 69 ------------------- blocks/mentees/lang/en/block_mentees.php | 1 + blocks/mentees/version.php | 2 +- blocks/news_items/block_news_items.php | 4 -- blocks/news_items/db/access.php | 10 +++ blocks/news_items/db/upgrade.php | 69 ------------------- .../news_items/lang/en/block_news_items.php | 1 + blocks/news_items/version.php | 2 +- blocks/online_users/block_online_users.php | 4 -- blocks/online_users/db/access.php | 10 +++ blocks/online_users/db/upgrade.php | 69 ------------------- .../lang/en/block_online_users.php | 1 + blocks/online_users/version.php | 2 +- 20 files changed, 49 insertions(+), 293 deletions(-) delete mode 100644 blocks/glossary_random/db/upgrade.php delete mode 100644 blocks/mentees/db/upgrade.php delete mode 100644 blocks/news_items/db/upgrade.php delete mode 100644 blocks/online_users/db/upgrade.php diff --git a/blocks/glossary_random/block_glossary_random.php b/blocks/glossary_random/block_glossary_random.php index 8dfa97f3ca47f..884c909307c64 100644 --- a/blocks/glossary_random/block_glossary_random.php +++ b/blocks/glossary_random/block_glossary_random.php @@ -11,10 +11,6 @@ function init() { $this->title = get_string('pluginname','block_glossary_random'); } - function applicable_formats() { - return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false); - } - function specialization() { global $CFG, $DB; diff --git a/blocks/glossary_random/db/access.php b/blocks/glossary_random/db/access.php index e7bb687b04e92..0c1acd6e07b31 100644 --- a/blocks/glossary_random/db/access.php +++ b/blocks/glossary_random/db/access.php @@ -26,6 +26,16 @@ $capabilities = array( + 'block/glossary_random:myaddinstance' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ), + 'block/glossary_random:addinstance' => array( 'riskbitmask' => RISK_SPAM | RISK_XSS, diff --git a/blocks/glossary_random/db/upgrade.php b/blocks/glossary_random/db/upgrade.php deleted file mode 100644 index 81aeabed12e4d..0000000000000 --- a/blocks/glossary_random/db/upgrade.php +++ /dev/null @@ -1,69 +0,0 @@ -. - -/** - * This file keeps track of upgrades to the glossary random block - * - * Sometimes, changes between versions involve alterations to database structures - * and other major things that may break installations. - * - * The upgrade function in this file will attempt to perform all the necessary - * actions to upgrade your older installation to the current version. - * - * If there's something it cannot do itself, it will tell you what you need to do. - * - * The commands in here will all be database-neutral, using the methods of - * database_manager class - * - * Please do not forget to use upgrade_set_timeout() - * before any action that may take longer time to finish. - * - * @since 2.0 - * @package blocks - * @copyright 2012 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Handles upgrading instances of this block. - * - * @param int $oldversion - * @param object $block - */ -function xmldb_block_glossary_random_upgrade($oldversion, $block) { - global $DB; - - // Moodle v2.4.0 release upgrade line - // Put any upgrade step following this. - - if ($oldversion < 2012112901) { - // Get the instances of this block. - if ($blocks = $DB->get_records('block_instances', array('blockname' => 'glossary_random', 'pagetypepattern' => 'my-index'))) { - // Loop through and remove them from the My Moodle page. - foreach ($blocks as $block) { - blocks_delete_instance($block); - } - - } - - // Savepoint reached. - upgrade_block_savepoint(true, 2012112901, 'glossary_random'); - } - - - return true; -} \ No newline at end of file diff --git a/blocks/glossary_random/lang/en/block_glossary_random.php b/blocks/glossary_random/lang/en/block_glossary_random.php index 0147f005ebe5a..6366bd428dfa4 100644 --- a/blocks/glossary_random/lang/en/block_glossary_random.php +++ b/blocks/glossary_random/lang/en/block_glossary_random.php @@ -28,6 +28,7 @@ $string['askinvisible'] = 'When users cannot edit or view the glossary, show this text (without link)'; $string['askviewglossary'] = 'When users can view the glossary but not add entries, show a link with this text'; $string['glossary_random:addinstance'] = 'Add a new random glossary entry block'; +$string['glossary_random:myaddinstance'] = 'Add a new random glossary entry block to the My Moodle page'; $string['intro'] = 'Make sure you have at least one glossary with at least one entry added to this course. Then you can adjust the following settings'; $string['invisible'] = '(to be continued)'; $string['lastmodified'] = 'Last modified entry'; diff --git a/blocks/glossary_random/version.php b/blocks/glossary_random/version.php index 061ec44e81b45..a5d21fafb264f 100644 --- a/blocks/glossary_random/version.php +++ b/blocks/glossary_random/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2012112901; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2012112902; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2012112900; // Requires this Moodle version $plugin->component = 'block_glossary_random'; // Full name of the plugin (used for diagnostics) diff --git a/blocks/mentees/block_mentees.php b/blocks/mentees/block_mentees.php index 85f48f3ebac1a..aa340af7e415b 100644 --- a/blocks/mentees/block_mentees.php +++ b/blocks/mentees/block_mentees.php @@ -7,7 +7,7 @@ function init() { } function applicable_formats() { - return array('all' => true, 'tag' => false, 'my' => false); + return array('all' => true, 'tag' => false); } function specialization() { diff --git a/blocks/mentees/db/access.php b/blocks/mentees/db/access.php index 489ceb319ac03..ba14b078d8b5a 100644 --- a/blocks/mentees/db/access.php +++ b/blocks/mentees/db/access.php @@ -26,6 +26,16 @@ $capabilities = array( + 'block/mentees:myaddinstance' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ), + 'block/mentees:addinstance' => array( 'riskbitmask' => RISK_SPAM | RISK_XSS, diff --git a/blocks/mentees/db/upgrade.php b/blocks/mentees/db/upgrade.php deleted file mode 100644 index e8aba712e8307..0000000000000 --- a/blocks/mentees/db/upgrade.php +++ /dev/null @@ -1,69 +0,0 @@ -. - -/** - * This file keeps track of upgrades to the mentees block - * - * Sometimes, changes between versions involve alterations to database structures - * and other major things that may break installations. - * - * The upgrade function in this file will attempt to perform all the necessary - * actions to upgrade your older installation to the current version. - * - * If there's something it cannot do itself, it will tell you what you need to do. - * - * The commands in here will all be database-neutral, using the methods of - * database_manager class - * - * Please do not forget to use upgrade_set_timeout() - * before any action that may take longer time to finish. - * - * @since 2.0 - * @package blocks - * @copyright 2012 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Handles upgrading instances of this block. - * - * @param int $oldversion - * @param object $block - */ -function xmldb_block_mentees_upgrade($oldversion, $block) { - global $DB; - - // Moodle v2.4.0 release upgrade line - // Put any upgrade step following this. - - if ($oldversion < 2012112901) { - // Get the instances of this block. - if ($blocks = $DB->get_records('block_instances', array('blockname' => 'mentees', 'pagetypepattern' => 'my-index'))) { - // Loop through and remove them from the My Moodle page. - foreach ($blocks as $block) { - blocks_delete_instance($block); - } - - } - - // Savepoint reached. - upgrade_block_savepoint(true, 2012112901, 'mentees'); - } - - - return true; -} \ No newline at end of file diff --git a/blocks/mentees/lang/en/block_mentees.php b/blocks/mentees/lang/en/block_mentees.php index 1c0cdabb15243..3a220578139d4 100644 --- a/blocks/mentees/lang/en/block_mentees.php +++ b/blocks/mentees/lang/en/block_mentees.php @@ -27,5 +27,6 @@ $string['configtitleblankhides'] = 'Block title (no title if blank)'; $string['leaveblanktohide'] = 'leave blank to hide the title'; $string['mentees:addinstance'] = 'Add a new mentees block'; +$string['mentees:myaddinstance'] = 'Add a new mentees block to the My Moodle page'; $string['newmenteesblock'] = '(new Mentees block)'; $string['pluginname'] = 'Mentees'; diff --git a/blocks/mentees/version.php b/blocks/mentees/version.php index c3a8db3557d9e..7f9e179f2c7a7 100644 --- a/blocks/mentees/version.php +++ b/blocks/mentees/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2012112901; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2012112902; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2012112900; // Requires this Moodle version $plugin->component = 'block_mentees'; // Full name of the plugin (used for diagnostics) diff --git a/blocks/news_items/block_news_items.php b/blocks/news_items/block_news_items.php index e803c6e603063..5ecbec283fad4 100644 --- a/blocks/news_items/block_news_items.php +++ b/blocks/news_items/block_news_items.php @@ -5,10 +5,6 @@ function init() { $this->title = get_string('pluginname', 'block_news_items'); } - function applicable_formats() { - return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false); - } - function get_content() { global $CFG, $USER; diff --git a/blocks/news_items/db/access.php b/blocks/news_items/db/access.php index 452158eb9fbb4..86bb1b7beda65 100644 --- a/blocks/news_items/db/access.php +++ b/blocks/news_items/db/access.php @@ -26,6 +26,16 @@ $capabilities = array( + 'block/news_items:myaddinstance' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ), + 'block/news_items:addinstance' => array( 'riskbitmask' => RISK_SPAM | RISK_XSS, diff --git a/blocks/news_items/db/upgrade.php b/blocks/news_items/db/upgrade.php deleted file mode 100644 index e634e57712576..0000000000000 --- a/blocks/news_items/db/upgrade.php +++ /dev/null @@ -1,69 +0,0 @@ -. - -/** - * This file keeps track of upgrades to the latest news block - * - * Sometimes, changes between versions involve alterations to database structures - * and other major things that may break installations. - * - * The upgrade function in this file will attempt to perform all the necessary - * actions to upgrade your older installation to the current version. - * - * If there's something it cannot do itself, it will tell you what you need to do. - * - * The commands in here will all be database-neutral, using the methods of - * database_manager class - * - * Please do not forget to use upgrade_set_timeout() - * before any action that may take longer time to finish. - * - * @since 2.0 - * @package blocks - * @copyright 2012 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Handles upgrading instances of this block. - * - * @param int $oldversion - * @param object $block - */ -function xmldb_block_news_items_upgrade($oldversion, $block) { - global $DB; - - // Moodle v2.4.0 release upgrade line - // Put any upgrade step following this. - - if ($oldversion < 2012112901) { - // Get the instances of this block. - if ($blocks = $DB->get_records('block_instances', array('blockname' => 'news_items', 'pagetypepattern' => 'my-index'))) { - // Loop through and remove them from the My Moodle page. - foreach ($blocks as $block) { - blocks_delete_instance($block); - } - - } - - // Savepoint reached. - upgrade_block_savepoint(true, 2012112901, 'news_items'); - } - - - return true; -} \ No newline at end of file diff --git a/blocks/news_items/lang/en/block_news_items.php b/blocks/news_items/lang/en/block_news_items.php index 1de650786d10d..7d76b9c75d7ef 100644 --- a/blocks/news_items/lang/en/block_news_items.php +++ b/blocks/news_items/lang/en/block_news_items.php @@ -24,4 +24,5 @@ */ $string['news_items:addinstance'] = 'Add a new latest news block'; +$string['news_items:myaddinstance'] = 'Add a new latest news block to the My Moodle page'; $string['pluginname'] = 'Latest news'; diff --git a/blocks/news_items/version.php b/blocks/news_items/version.php index 11d74ca9405ed..ba6e9310b62e1 100644 --- a/blocks/news_items/version.php +++ b/blocks/news_items/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2012112901; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2012112902; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2012112900; // Requires this Moodle version $plugin->component = 'block_news_items'; // Full name of the plugin (used for diagnostics) diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index 6d14ebbd1ae37..50ff41a05052b 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -10,10 +10,6 @@ function init() { $this->title = get_string('pluginname','block_online_users'); } - function applicable_formats() { - return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false); - } - function has_config() { return true; } diff --git a/blocks/online_users/db/access.php b/blocks/online_users/db/access.php index 41959c427db75..f238b7384d74b 100644 --- a/blocks/online_users/db/access.php +++ b/blocks/online_users/db/access.php @@ -26,6 +26,16 @@ $capabilities = array( + 'block/online_users:myaddinstance' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ), + 'block/online_users:addinstance' => array( 'riskbitmask' => RISK_SPAM | RISK_XSS, diff --git a/blocks/online_users/db/upgrade.php b/blocks/online_users/db/upgrade.php deleted file mode 100644 index f45a788e25097..0000000000000 --- a/blocks/online_users/db/upgrade.php +++ /dev/null @@ -1,69 +0,0 @@ -. - -/** - * This file keeps track of upgrades to the online users block - * - * Sometimes, changes between versions involve alterations to database structures - * and other major things that may break installations. - * - * The upgrade function in this file will attempt to perform all the necessary - * actions to upgrade your older installation to the current version. - * - * If there's something it cannot do itself, it will tell you what you need to do. - * - * The commands in here will all be database-neutral, using the methods of - * database_manager class - * - * Please do not forget to use upgrade_set_timeout() - * before any action that may take longer time to finish. - * - * @since 2.0 - * @package blocks - * @copyright 2012 Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Handles upgrading instances of this block. - * - * @param int $oldversion - * @param object $block - */ -function xmldb_block_online_users_upgrade($oldversion, $block) { - global $DB; - - // Moodle v2.4.0 release upgrade line - // Put any upgrade step following this. - - if ($oldversion < 2012112901) { - // Get the instances of this block. - if ($blocks = $DB->get_records('block_instances', array('blockname' => 'online_users', 'pagetypepattern' => 'my-index'))) { - // Loop through and remove them from the My Moodle page. - foreach ($blocks as $block) { - blocks_delete_instance($block); - } - - } - - // Savepoint reached. - upgrade_block_savepoint(true, 2012112901, 'online_users'); - } - - - return true; -} \ No newline at end of file diff --git a/blocks/online_users/lang/en/block_online_users.php b/blocks/online_users/lang/en/block_online_users.php index b7a008e0e558e..034fce5fc5aa9 100644 --- a/blocks/online_users/lang/en/block_online_users.php +++ b/blocks/online_users/lang/en/block_online_users.php @@ -25,6 +25,7 @@ $string['configtimetosee'] = 'Number of minutes determining the period of inactivity after which a user is no longer considered to be online.'; $string['online_users:addinstance'] = 'Add a new online users block'; +$string['online_users:myaddinstance'] = 'Add a new online users block to the My Moodle page'; $string['online_users:viewlist'] = 'View list of online users'; $string['periodnminutes'] = 'last {$a} minutes'; $string['pluginname'] = 'Online users'; diff --git a/blocks/online_users/version.php b/blocks/online_users/version.php index 4463c451214fb..9a32ef0ff56fc 100644 --- a/blocks/online_users/version.php +++ b/blocks/online_users/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2012112901; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2012112902; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2012112900; // Requires this Moodle version $plugin->component = 'block_online_users'; // Full name of the plugin (used for diagnostics)