Merge branch 'MDL-35762_fix' of git://github.com/andyjdavis/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 6 Nov 2012 15:13:47 +0000 (16:13 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 6 Nov 2012 15:13:47 +0000 (16:13 +0100)
291 files changed:
admin/cli/install.php
admin/oacleanup.php
admin/roles/check.php
admin/roles/lib.php
admin/settings/plugins.php
auth/mnet/auth.php
auth/shibboleth/index.php
backup/cc/cc_lib/cc_convert_moodle2.php
backup/moodle2/backup_stepslib.php
backup/moodle2/restore_stepslib.php
blocks/activity_modules/db/access.php [new file with mode: 0644]
blocks/activity_modules/lang/en/block_activity_modules.php
blocks/activity_modules/version.php
blocks/admin_bookmarks/db/access.php [new file with mode: 0644]
blocks/admin_bookmarks/lang/en/block_admin_bookmarks.php
blocks/admin_bookmarks/version.php
blocks/blog_menu/db/access.php [new file with mode: 0644]
blocks/blog_menu/lang/en/block_blog_menu.php
blocks/blog_menu/version.php
blocks/blog_recent/db/access.php [new file with mode: 0644]
blocks/blog_recent/lang/en/block_blog_recent.php
blocks/blog_recent/version.php
blocks/blog_tags/db/access.php [new file with mode: 0644]
blocks/blog_tags/lang/en/block_blog_tags.php
blocks/blog_tags/version.php
blocks/calendar_month/db/access.php [new file with mode: 0644]
blocks/calendar_month/lang/en/block_calendar_month.php
blocks/calendar_month/version.php
blocks/calendar_upcoming/db/access.php [new file with mode: 0644]
blocks/calendar_upcoming/lang/en/block_calendar_upcoming.php
blocks/calendar_upcoming/version.php
blocks/comments/db/access.php [new file with mode: 0644]
blocks/comments/lang/en/block_comments.php
blocks/comments/version.php
blocks/community/db/access.php [new file with mode: 0644]
blocks/community/lang/en/block_community.php
blocks/community/version.php
blocks/completionstatus/db/access.php [new file with mode: 0644]
blocks/completionstatus/lang/en/block_completionstatus.php
blocks/completionstatus/version.php
blocks/course_list/db/access.php [new file with mode: 0644]
blocks/course_list/lang/en/block_course_list.php
blocks/course_list/version.php
blocks/course_overview/db/access.php [new file with mode: 0644]
blocks/course_overview/lang/en/block_course_overview.php
blocks/course_overview/version.php
blocks/course_summary/db/access.php [new file with mode: 0644]
blocks/course_summary/lang/en/block_course_summary.php
blocks/course_summary/version.php
blocks/feedback/db/access.php [new file with mode: 0644]
blocks/feedback/lang/en/block_feedback.php
blocks/feedback/version.php
blocks/glossary_random/db/access.php [new file with mode: 0644]
blocks/glossary_random/lang/en/block_glossary_random.php
blocks/glossary_random/version.php
blocks/html/db/access.php [new file with mode: 0644]
blocks/html/lang/en/block_html.php
blocks/html/version.php
blocks/login/db/access.php [new file with mode: 0644]
blocks/login/lang/en/block_login.php
blocks/login/version.php
blocks/mentees/db/access.php [new file with mode: 0644]
blocks/mentees/lang/en/block_mentees.php
blocks/mentees/version.php
blocks/messages/db/access.php [new file with mode: 0644]
blocks/messages/lang/en/block_messages.php
blocks/messages/version.php
blocks/mnet_hosts/db/access.php [new file with mode: 0644]
blocks/mnet_hosts/lang/en/block_mnet_hosts.php
blocks/mnet_hosts/version.php
blocks/moodleblock.class.php
blocks/myprofile/db/access.php [new file with mode: 0644]
blocks/myprofile/lang/en/block_myprofile.php
blocks/myprofile/version.php
blocks/navigation/db/access.php [new file with mode: 0644]
blocks/navigation/lang/en/block_navigation.php
blocks/navigation/version.php
blocks/news_items/db/access.php [new file with mode: 0644]
blocks/news_items/lang/en/block_news_items.php
blocks/news_items/version.php
blocks/online_users/db/access.php
blocks/online_users/lang/en/block_online_users.php
blocks/online_users/version.php
blocks/participants/db/access.php [new file with mode: 0644]
blocks/participants/lang/en/block_participants.php
blocks/participants/version.php
blocks/private_files/db/access.php [new file with mode: 0644]
blocks/private_files/lang/en/block_private_files.php
blocks/private_files/version.php
blocks/quiz_results/db/access.php [new file with mode: 0644]
blocks/quiz_results/lang/en/block_quiz_results.php
blocks/quiz_results/version.php
blocks/recent_activity/db/access.php [new file with mode: 0644]
blocks/recent_activity/lang/en/block_recent_activity.php
blocks/recent_activity/version.php
blocks/rss_client/db/access.php
blocks/rss_client/lang/en/block_rss_client.php
blocks/rss_client/version.php
blocks/search_forums/db/access.php [new file with mode: 0644]
blocks/search_forums/lang/en/block_search_forums.php
blocks/search_forums/version.php
blocks/section_links/block_section_links.php
blocks/section_links/db/access.php [new file with mode: 0644]
blocks/section_links/lang/en/block_section_links.php
blocks/section_links/version.php
blocks/selfcompletion/db/access.php [new file with mode: 0644]
blocks/selfcompletion/lang/en/block_selfcompletion.php
blocks/selfcompletion/version.php
blocks/settings/db/access.php [new file with mode: 0644]
blocks/settings/lang/en/block_settings.php
blocks/settings/version.php
blocks/site_main_menu/db/access.php [new file with mode: 0644]
blocks/site_main_menu/lang/en/block_site_main_menu.php
blocks/site_main_menu/version.php
blocks/social_activities/db/access.php [new file with mode: 0644]
blocks/social_activities/lang/en/block_social_activities.php
blocks/social_activities/version.php
blocks/tag_flickr/db/access.php [new file with mode: 0644]
blocks/tag_flickr/lang/en/block_tag_flickr.php
blocks/tag_flickr/version.php
blocks/tag_youtube/db/access.php [new file with mode: 0644]
blocks/tag_youtube/lang/en/block_tag_youtube.php
blocks/tag_youtube/version.php
blocks/tags/db/access.php [new file with mode: 0644]
blocks/tags/lang/en/block_tags.php
blocks/tags/version.php
cache/README.md
cache/admin.php
cache/classes/definition.php
cache/classes/loaders.php
cache/stores/file/lib.php
calendar/renderer.php
course/changenumsections.php
course/edit.php
course/edit_form.php
course/editsection.php
course/editsection_form.php
course/externallib.php
course/format/formatlegacy.php
course/format/lib.php
course/format/renderer.php
course/format/topics/format.php
course/format/topics/styles.css
course/format/weeks/format.php
course/format/weeks/styles.css
course/lib.php
course/tests/externallib_test.php
course/yui/formatchooser/formatchooser.js [new file with mode: 0644]
enrol/database/lib.php
enrol/database/tests/sync_test.php
enrol/imsenterprise/lib.php
enrol/ldap/lib.php
index.php
lang/en/admin.php
lang/en/moodle.php
lib/adminlib.php
lib/db/caches.php
lib/db/install.php
lib/db/install.xml
lib/db/upgrade.php
lib/filelib.php
lib/modinfolib.php
lib/moodlelib.php
lib/navigationlib.php
lib/outputrenderers.php
lib/outputrequirementslib.php
lib/phpunit/classes/util.php
lib/pluginlib.php
lib/setuplib.php
lib/tests/moodlelib_test.php
lib/weblib.php
lib/yui/chooserdialogue/chooserdialogue.js
mnet/service/enrol/course.php
mod/assign/lang/en/assign.php
mod/assign/pix/icon.png [new file with mode: 0644]
mod/assign/pix/icon.svg [new file with mode: 0644]
mod/assignment/lib.php
mod/assignment/pix/icon.png [new file with mode: 0644]
mod/assignment/pix/icon.svg [new file with mode: 0644]
mod/assignment/type/upload/assignment.class.php
mod/assignment/type/uploadsingle/assignment.class.php
mod/book/pix/icon.png
mod/book/pix/icon.svg [new file with mode: 0644]
mod/chat/pix/icon.png [new file with mode: 0644]
mod/chat/pix/icon.svg [new file with mode: 0644]
mod/choice/pix/icon.png [new file with mode: 0644]
mod/choice/pix/icon.svg [new file with mode: 0644]
mod/data/pix/icon.png [new file with mode: 0644]
mod/data/pix/icon.svg [new file with mode: 0644]
mod/feedback/pix/icon.png [new file with mode: 0644]
mod/feedback/pix/icon.svg [new file with mode: 0644]
mod/folder/pix/icon.png [new file with mode: 0644]
mod/folder/pix/icon.svg [new file with mode: 0644]
mod/forum/lib.php
mod/forum/pix/icon.png [new file with mode: 0644]
mod/forum/pix/icon.svg [new file with mode: 0644]
mod/glossary/pix/icon.png [new file with mode: 0644]
mod/glossary/pix/icon.svg [new file with mode: 0644]
mod/imscp/pix/icon.png [new file with mode: 0644]
mod/imscp/pix/icon.svg [new file with mode: 0644]
mod/label/pix/icon.png [new file with mode: 0644]
mod/label/pix/icon.svg [new file with mode: 0644]
mod/lesson/pix/icon.png [new file with mode: 0644]
mod/lesson/pix/icon.svg [new file with mode: 0644]
mod/lti/pix/icon.png [new file with mode: 0644]
mod/lti/pix/icon.svg [new file with mode: 0644]
mod/page/pix/icon.png [new file with mode: 0644]
mod/page/pix/icon.svg [new file with mode: 0644]
mod/quiz/editlib.php
mod/quiz/module.js
mod/quiz/pix/icon.png
mod/quiz/pix/icon.svg [new file with mode: 0644]
mod/resource/lib.php
mod/resource/pix/icon.png [new file with mode: 0644]
mod/resource/pix/icon.svg [new file with mode: 0644]
mod/scorm/lib.php
mod/scorm/pix/icon.png [new file with mode: 0644]
mod/scorm/pix/icon.svg [new file with mode: 0644]
mod/survey/pix/icon.png [new file with mode: 0644]
mod/survey/pix/icon.svg [new file with mode: 0644]
mod/url/pix/icon.png [new file with mode: 0644]
mod/url/pix/icon.svg [new file with mode: 0644]
mod/wiki/pix/icon.png [new file with mode: 0644]
mod/wiki/pix/icon.svg [new file with mode: 0644]
mod/workshop/backup/moodle1/lib.php
mod/workshop/backup/moodle2/backup_workshop_stepslib.php
mod/workshop/backup/moodle2/restore_workshop_activity_task.class.php
mod/workshop/backup/moodle2/restore_workshop_stepslib.php
mod/workshop/db/install.xml
mod/workshop/db/upgrade.php
mod/workshop/lang/en/workshop.php
mod/workshop/lib.php
mod/workshop/locallib.php
mod/workshop/mod_form.php
mod/workshop/pix/icon.png [new file with mode: 0644]
mod/workshop/pix/icon.svg [new file with mode: 0644]
mod/workshop/version.php
mod/workshop/view.php
pix/help.png [new file with mode: 0644]
pix/help.svg [new file with mode: 0644]
pix/i/hide.png [new file with mode: 0644]
pix/i/hide.svg [new file with mode: 0644]
pix/i/marked.png [new file with mode: 0644]
pix/i/marked.svg [new file with mode: 0644]
pix/i/marker.png [new file with mode: 0644]
pix/i/marker.svg [new file with mode: 0644]
pix/i/move_2d.png [new file with mode: 0644]
pix/i/move_2d.svg [new file with mode: 0644]
pix/i/roles.png [new file with mode: 0644]
pix/i/roles.svg [new file with mode: 0644]
pix/i/show.png [new file with mode: 0644]
pix/i/show.svg [new file with mode: 0644]
pix/t/add.png [new file with mode: 0644]
pix/t/add.svg [new file with mode: 0644]
pix/t/copy.png [new file with mode: 0644]
pix/t/copy.svg [new file with mode: 0644]
pix/t/delete.png [new file with mode: 0644]
pix/t/delete.svg [new file with mode: 0644]
pix/t/down.png [new file with mode: 0644]
pix/t/down.svg [new file with mode: 0644]
pix/t/edit.png [new file with mode: 0644]
pix/t/edit.svg [new file with mode: 0644]
pix/t/editstring.png
pix/t/editstring.svg [new file with mode: 0644]
pix/t/groupn.png [new file with mode: 0644]
pix/t/groupn.svg [new file with mode: 0644]
pix/t/groups.png [new file with mode: 0644]
pix/t/groups.svg [new file with mode: 0644]
pix/t/groupv.png [new file with mode: 0644]
pix/t/groupv.svg [new file with mode: 0644]
pix/t/hide.png [new file with mode: 0644]
pix/t/hide.svg [new file with mode: 0644]
pix/t/left.png [new file with mode: 0644]
pix/t/left.svg [new file with mode: 0644]
pix/t/move.png [new file with mode: 0644]
pix/t/move.svg [new file with mode: 0644]
pix/t/right.png [new file with mode: 0644]
pix/t/right.svg [new file with mode: 0644]
pix/t/show.png [new file with mode: 0644]
pix/t/show.svg [new file with mode: 0644]
pix/t/up.png [new file with mode: 0644]
pix/t/up.svg [new file with mode: 0644]
question/editlib.php
theme/base/style/blocks.css
theme/base/style/core.css
theme/base/style/course.css
theme/standard/style/course.css
user/view.php
version.php
webservice/externallib.php
webservice/tests/externallib_test.php

index 38aa06e..858571f 100644 (file)
@@ -164,6 +164,7 @@ require_once($CFG->libdir.'/moodlelib.php');
 require_once($CFG->libdir.'/deprecatedlib.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/componentlib.class.php');
+require_once($CFG->dirroot.'/cache/lib.php');
 
 require($CFG->dirroot.'/version.php');
 $CFG->target_release = $release;
index fe2e444..a27aff9 100644 (file)
@@ -59,11 +59,19 @@ function online_assignment_cleanup($output=false) {
         if ($output) echo $OUTPUT->heading($fullname);
 
         /// retrieve a list of sections beyond what is currently being shown
+        $courseformatoptions = course_get_format($course)->get_format_options();
+        if (!isset($courseformatoptions['numsections'])) {
+            // Course format does not use numsections
+            if ($output) {
+                echo 'No extra sections<br />';
+            }
+            continue;
+        }
         $sql = "SELECT *
                   FROM {course_sections}
                  WHERE course=? AND section>?
               ORDER BY section ASC";
-        $params = array($course->id, $course->numsections);
+        $params = array($course->id, $courseformatoptions['numsections']);
         if (!($xsections = $DB->get_records_sql($sql, $params))) {
             if ($output) echo 'No extra sections<br />';
             continue;
@@ -94,7 +102,7 @@ function online_assignment_cleanup($output=false) {
                         /// the journal update erroneously stored it in course_sections->section
                         $newsection = $xsection->section;
                         /// double check the new section
-                        if ($newsection > $course->numsections) {
+                        if ($newsection > $courseformatoptions['numsections']) {
                             /// get the record for section 0 for this course
                             if (!($zerosection = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>'0')))) {
                                 continue;
index 470159e..d3917b0 100644 (file)
@@ -59,16 +59,11 @@ $courseid = $course->id;
 $contextname = print_context_name($context);
 
 // Get the user_selector we will need.
-// Teachers within a course just get to see the same list of people they can
-// assign roles to. Admins (people with moodle/role:manage) can run this report for any user.
-$options = array('context' => $context, 'roleid' => 0);
-if (has_capability('moodle/role:manage', $context)) {
-    $userselector = new potential_assignees_course_and_above('reportuser', $options);
-} else {
-    $userselector = roles_get_potential_user_selector($context, 'reportuser', $options);
-}
-$userselector->set_multiselect(false);
-$userselector->set_rows(10);
+// Teachers within a course just get to see the same list of enrolled users.
+// Admins (people with moodle/role:manage) can run this report for any user.
+$options = array('accesscontext' => $context);
+$userselector = new role_check_users_selector('reportuser', $options);
+$userselector->set_rows(20);
 
 // Work out an appropriate page title.
 $title = get_string('checkpermissionsin', 'role', $contextname);
index 5765cf5..60acdf9 100644 (file)
@@ -1074,6 +1074,135 @@ class potential_assignees_below_course extends role_assign_user_selector_base {
     }
 }
 
+/**
+ * User selector subclass for the selection of users in the check permissions page.
+ *
+ * @copyright 2012 Petr Skoda {@link http://skodak.org}
+ */
+class role_check_users_selector extends user_selector_base {
+    const MAX_ENROLLED_PER_PAGE = 100;
+    const MAX_POTENTIAL_PER_PAGE = 100;
+
+    /** @var bool limit listing of users to enrolled only */
+    var $onlyenrolled;
+
+    /**
+     * Constructor.
+     *
+     * @param string $name the control name/id for use in the HTML.
+     * @param array $options other options needed to construct this selector.
+     * You must be able to clone a userselector by doing new get_class($us)($us->get_name(), $us->get_options());
+     */
+    public function __construct($name, $options) {
+        if (!isset($options['multiselect'])) {
+            $options['multiselect'] = false;
+        }
+        parent::__construct($name, $options);
+
+        $coursecontext = $this->accesscontext->get_course_context(false);
+        if ($coursecontext and $coursecontext->id != SITEID and !has_capability('moodle/role:manage', $coursecontext)) {
+            // Prevent normal teachers from looking up all users.
+            $this->onlyenrolled = true;
+        } else {
+            $this->onlyenrolled = false;
+        }
+    }
+
+    public function find_users($search) {
+        global $DB;
+
+        list($wherecondition, $params) = $this->search_sql($search, 'u');
+
+        $fields      = 'SELECT ' . $this->required_fields_sql('u');
+        $countfields = 'SELECT COUNT(1)';
+
+        $coursecontext = $this->accesscontext->get_course_context(false);
+
+        if ($coursecontext and $coursecontext != SITEID) {
+            $sql1 = " FROM {user} u
+                      JOIN {user_enrolments} ue ON (ue.userid = u.id)
+                      JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
+                     WHERE $wherecondition";
+            $params['courseid1'] = $coursecontext->instanceid;
+
+            if ($this->onlyenrolled) {
+                $sql2 = null;
+            } else {
+                $sql2 = " FROM {user} u
+                     LEFT JOIN ({user_enrolments} ue
+                                JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid2)) ON (ue.userid = u.id)
+                         WHERE $wherecondition
+                               AND ue.id IS NULL";
+                $params['courseid2'] = $coursecontext->instanceid;
+            }
+
+        } else {
+            if ($this->onlyenrolled) {
+                // Bad luck, current user may not view only enrolled users.
+                return array();
+            }
+            $sql1 = null;
+            $sql2 = " FROM {user} u
+                     WHERE $wherecondition";
+        }
+
+        $params['contextid'] = $this->accesscontext->id;
+
+        list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
+        $order = ' ORDER BY ' . $sort;
+
+        $result = array();
+
+        if ($search) {
+            $groupname1 = get_string('enrolledusersmatching', 'enrol', $search);
+            $groupname2 = get_string('potusersmatching', 'role', $search);
+        } else {
+            $groupname1 = get_string('enrolledusers', 'enrol');
+            $groupname2 = get_string('potusers', 'role');
+        }
+
+        if ($sql1) {
+            $enrolleduserscount = $DB->count_records_sql($countfields . $sql1, $params);
+            if (!$this->is_validating() and $enrolleduserscount > $this::MAX_ENROLLED_PER_PAGE) {
+                $result[$groupname1] = array();
+                $toomany = $this->too_many_results($search, $enrolleduserscount);
+                $result[implode(' - ', array_keys($toomany))] = array();
+
+            } else {
+                $enrolledusers = $DB->get_records_sql($fields . $sql1 . $order, array_merge($params, $sortparams));
+                if ($enrolledusers) {
+                    $result[$groupname1] = $enrolledusers;
+                }
+            }
+            if ($sql2) {
+                $result[''] = array();
+            }
+        }
+        if ($sql2) {
+            $otheruserscount = $DB->count_records_sql($countfields . $sql2, $params);
+            if (!$this->is_validating() and $otheruserscount > $this::MAX_POTENTIAL_PER_PAGE) {
+                $result[$groupname2] = array();
+                $toomany = $this->too_many_results($search, $otheruserscount);
+                $result[implode(' - ', array_keys($toomany))] = array();
+            } else {
+                $otherusers = $DB->get_records_sql($fields . $sql2 . $order, array_merge($params, $sortparams));
+                if ($otherusers) {
+                    $result[$groupname2] = $otherusers;
+                }
+            }
+        }
+
+        return $result;
+    }
+
+    protected function get_options() {
+        global $CFG;
+        $options = parent::get_options();
+        $options['file'] = $CFG->admin . '/roles/lib.php';
+        return $options;
+    }
+}
+
 /**
  * User selector subclass for the list of potential users on the assign roles page,
  * when we are assigning in a context at or above the course level. In this case we
index 29d0665..8d29028 100644 (file)
@@ -245,6 +245,15 @@ if ($hassiteconfig) {
 
 /// Web services
     $ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
+    // Mobile
+    $temp = new admin_settingpage('mobile', new lang_string('mobile','admin'), 'moodle/site:config', false);
+    $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
+    $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
+    $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
+            new lang_string('enablemobilewebservice', 'admin'),
+            new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
+    $temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'admin'), new lang_string('configmobilecssurl','admin'), '', PARAM_URL));
+    $ADMIN->add('webservicesettings', $temp);
     /// overview page
     $temp = new admin_settingpage('webservicesoverview', new lang_string('webservicesoverview', 'webservice'));
     $temp->add(new admin_setting_webservicesoverview());
@@ -253,9 +262,9 @@ if ($hassiteconfig) {
     $ADMIN->add('webservicesettings', new admin_externalpage('webservicedocumentation', new lang_string('wsdocapi', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/documentation.php", 'moodle/site:config', false));
     /// manage service
     $temp = new admin_settingpage('externalservices', new lang_string('externalservices', 'webservice'));
-    $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
-    $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
-    $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice', new lang_string('enablemobilewebservice', 'admin'), new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
+    $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
+            new lang_string('enablemobilewebservice', 'admin'),
+            new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
     $temp->add(new admin_setting_heading('manageserviceshelpexplaination', new lang_string('information', 'webservice'), new lang_string('servicehelpexplanation', 'webservice')));
     $temp->add(new admin_setting_manageexternalservices());
     $ADMIN->add('webservicesettings', $temp);
index ee103bb..203d161 100644 (file)
@@ -378,23 +378,28 @@ class auth_plugin_mnet extends auth_plugin_base {
                 $extra = $DB->get_records_sql($sql);
 
                 $keys = array_keys($courses);
-                $defaultrole = reset(get_archetype_roles('student'));
-                //$defaultrole = get_default_course_role($ccache[$shortname]); //TODO: rewrite this completely, there is no default course role any more!!!
-                foreach ($keys AS $id) {
-                    if ($courses[$id]->visible == 0) {
-                        unset($courses[$id]);
-                        continue;
+                $studentroles = get_archetype_roles('student');
+                if (!empty($studentroles)) {
+                    $defaultrole = reset($studentroles);
+                    //$defaultrole = get_default_course_role($ccache[$shortname]); //TODO: rewrite this completely, there is no default course role any more!!!
+                    foreach ($keys AS $id) {
+                        if ($courses[$id]->visible == 0) {
+                            unset($courses[$id]);
+                            continue;
+                        }
+                        $courses[$id]->cat_id          = $courses[$id]->category;
+                        $courses[$id]->defaultroleid   = $defaultrole->id;
+                        unset($courses[$id]->category);
+                        unset($courses[$id]->visible);
+
+                        $courses[$id]->cat_name        = $extra[$id]->cat_name;
+                        $courses[$id]->cat_description = $extra[$id]->cat_description;
+                        $courses[$id]->defaultrolename = $defaultrole->name;
+                        // coerce to array
+                        $courses[$id] = (array)$courses[$id];
                     }
-                    $courses[$id]->cat_id          = $courses[$id]->category;
-                    $courses[$id]->defaultroleid   = $defaultrole->id;
-                    unset($courses[$id]->category);
-                    unset($courses[$id]->visible);
-
-                    $courses[$id]->cat_name        = $extra[$id]->cat_name;
-                    $courses[$id]->cat_description = $extra[$id]->cat_description;
-                    $courses[$id]->defaultrolename = $defaultrole->name;
-                    // coerce to array
-                    $courses[$id] = (array)$courses[$id];
+                } else {
+                    throw new moodle_exception('unknownrole', 'error', '', 'student');
                 }
             } else {
                 // if the array is empty, send it anyway
index 6a760ec..88caf30 100644 (file)
@@ -28,7 +28,7 @@
 
     // Check whether Shibboleth is configured properly
     if (empty($pluginconfig->user_attribute)) {
-        print_error('shib_not_set_up_error', 'auth');
+        print_error('shib_not_set_up_error', 'auth_shibboleth');
      }
 
 /// If we can find the Shibboleth attribute, save it in session and return to main login page
@@ -95,9 +95,9 @@
     // If we can find any (user independent) Shibboleth attributes but no user
     // attributes we probably didn't receive any user attributes
     elseif (!empty($_SERVER['HTTP_SHIB_APPLICATION_ID']) || !empty($_SERVER['Shib-Application-ID'])) {
-        print_error('shib_no_attributes_error', 'auth' , '', '\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\'');
+        print_error('shib_no_attributes_error', 'auth_shibboleth' , '', '\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\'');
     } else {
-        print_error('shib_not_set_up_error', 'auth');
+        print_error('shib_not_set_up_error', 'auth_shibboleth');
     }
 
 
index 5f6d9e4..56002a0 100644 (file)
@@ -83,14 +83,15 @@ abstract class cc_convert_moodle2 {
                 $coursef = new XMLGenericDocument();
                 $course_file = $dir . DIRECTORY_SEPARATOR .'course' . DIRECTORY_SEPARATOR . 'course.xml';
                 $coursef->load($course_file);
-                $numsections = (int)$coursef->nodeValue('/course/numsections');
+                //$numsections = (int)$coursef->nodeValue('/course/numsections');
+                // TODO MDL-35781, this is commented because numsections is now optional attribute
                 $section_list = $docp->nodeList('/moodle_backup/information/contents/sections/section');
                 if (!empty($section_list)) {
                     $count = 0;
                     foreach ($section_list as $node) {
-                        if ($count > $numsections) {
-                            break;
-                        }
+                        //if ($count > $numsections) {
+                        //    break;
+                        //}
                         $sectionid    = $docp->nodeValue('sectionid', $node);
                         $sectiontitle = $docp->nodeValue('title'    , $node);
                         $sectionpath  = $docp->nodeValue('directory', $node);
index 2667e03..158b4a2 100644 (file)
@@ -394,6 +394,11 @@ class backup_section_structure_step extends backup_structure_step {
         $section->add_child($avail);
         $section->add_child($availfield);
 
+        // Add nested elements for course_format_options table
+        $formatoptions = new backup_nested_element('course_format_options', array('id'), array(
+            'format', 'name', 'value'));
+        $section->add_child($formatoptions);
+
         // Define sources
         $section->set_source_table('course_sections', array('id' => backup::VAR_SECTIONID));
         $avail->set_source_table('course_sections_availability', array('coursesectionid' => backup::VAR_SECTIONID));
@@ -402,6 +407,12 @@ class backup_section_structure_step extends backup_structure_step {
               FROM {course_sections_avail_fields} csaf
          LEFT JOIN {user_info_field} uif ON uif.id = csaf.customfieldid
              WHERE csaf.coursesectionid = ?', array(backup::VAR_SECTIONID));
+        $formatoptions->set_source_sql('SELECT cfo.id, cfo.format, cfo.name, cfo.value
+              FROM {course} c
+              JOIN {course_format_options} cfo
+              ON cfo.courseid = c.id AND cfo.format = c.format
+              WHERE c.id = ? AND cfo.sectionid = ?',
+                array(backup::VAR_COURSEID, backup::VAR_SECTIONID));
 
         // Aliases
         $section->set_source_alias('section', 'number');
@@ -428,10 +439,10 @@ class backup_course_structure_step extends backup_structure_step {
 
         $course = new backup_nested_element('course', array('id', 'contextid'), array(
             'shortname', 'fullname', 'idnumber',
-            'summary', 'summaryformat', 'format', 'coursedisplay', 'showgrades',
-            'newsitems', 'startdate', 'numsections',
+            'summary', 'summaryformat', 'format', 'showgrades',
+            'newsitems', 'startdate',
             'marker', 'maxbytes', 'legacyfiles', 'showreports',
-            'visible', 'hiddensections', 'groupmode', 'groupmodeforce',
+            'visible', 'groupmode', 'groupmodeforce',
             'defaultgroupingid', 'lang', 'theme',
             'timecreated', 'timemodified',
             'requested',
@@ -476,6 +487,12 @@ class backup_course_structure_step extends backup_structure_step {
         $courserec = $DB->get_record('course', array('id' => $this->task->get_courseid()));
         $courserec->contextid = $this->task->get_contextid();
 
+        $formatoptions = course_get_format($courserec)->get_format_options();
+        $course->add_final_elements(array_keys($formatoptions));
+        foreach ($formatoptions as $key => $value) {
+            $courserec->$key = $value;
+        }
+
         $course->set_source_array(array($courserec));
 
         $categoryrec = $DB->get_record('course_categories', array('id' => $courserec->category));
index afa6f5b..0a42f09 100644 (file)
@@ -1100,6 +1100,7 @@ class restore_section_structure_step extends restore_structure_step {
             $paths[] = new restore_path_element('availability', '/section/availability');
             $paths[] = new restore_path_element('availability_field', '/section/availability_field');
         }
+        $paths[] = new restore_path_element('course_format_options', '/section/course_format_options');
 
         // Apply for 'format' plugins optional paths at section level
         $this->add_plugin_structure('format', $section);
@@ -1233,6 +1234,17 @@ class restore_section_structure_step extends restore_structure_step {
         }
     }
 
+    public function process_course_format_options($data) {
+        global $DB;
+        $data = (object)$data;
+        $oldid = $data->id;
+        unset($data->id);
+        $data->sectionid = $this->task->get_sectionid();
+        $data->courseid = $this->get_courseid();
+        $newid = $DB->insert_record('course_format_options', $data);
+        $this->set_mapping('course_format_options', $oldid, $newid);
+    }
+
     protected function after_execute() {
         // Add section related files, with 'course_section' itemid to match
         $this->add_related_files('course', 'section', 'course_section');
@@ -1382,6 +1394,8 @@ class restore_course_structure_step extends restore_structure_step {
         // Course record ready, update it
         $DB->update_record('course', $data);
 
+        course_get_format($data)->update_course_format_options($data);
+
         // Role name aliases
         restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
     }
diff --git a/blocks/activity_modules/db/access.php b/blocks/activity_modules/db/access.php
new file mode 100644 (file)
index 0000000..de6bbb8
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Activity modules block caps.
+ *
+ * @package    block_activity_modules
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/activity_modules:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/activity_modules:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index e7fd6e4..b4d4cfe 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['activity_modules:addinstance'] = 'Add a new activities block';
+$string['activity_modules:myaddinstance'] = 'Add a new activities block to the My Moodle page';
 $string['pluginname'] = 'Activities';
index 8758d2c..3209219 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_activity_modules'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/admin_bookmarks/db/access.php b/blocks/admin_bookmarks/db/access.php
new file mode 100644 (file)
index 0000000..7c8b418
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Admin bookmarks block caps.
+ *
+ * @package    block_admin_bookmarks
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/admin_bookmarks:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/admin_bookmarks:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 8fbd9b3..6f78c0d 100644 (file)
@@ -23,5 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['admin_bookmarks:addinstance'] = 'Add a new admin bookmarks block';
+$string['admin_bookmarks:myaddinstance'] = 'Add a new admin bookmarks block to the My Moodle page';
 $string['pluginname'] = 'Admin bookmarks';
-
index 87f6ff9..691286c 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_admin_bookmarks'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/blog_menu/db/access.php b/blocks/blog_menu/db/access.php
new file mode 100644 (file)
index 0000000..059aeeb
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Blog menu block caps.
+ *
+ * @package    block_blog_menu
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/blog_menu:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/blog_menu:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 9a715dc..60f08a2 100644 (file)
@@ -23,5 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['blog_menu:addinstance'] = 'Add a new blog menu block';
+$string['blog_menu:myaddinstance'] = 'Add a new blog menu block to the My Moodle page';
 $string['pluginname'] = 'Blog menu';
-
index 3ce1988..0b58ac8 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_blog_menu'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/blog_recent/db/access.php b/blocks/blog_recent/db/access.php
new file mode 100644 (file)
index 0000000..691ef27
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Blog recent block caps.
+ *
+ * @package    block_blog_recent
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/blog_recent:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/blog_recent:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 2315c56..fa1c8b8 100644 (file)
@@ -23,6 +23,8 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['blog_recent:addinstance'] = 'Add a new recent blog entries block';
+$string['blog_recent:myaddinstance'] = 'Add a new recent blog entries block to the My Moodle page';
 $string['norecentblogentries'] = 'No recent entries';
 $string['numentriestodisplay'] = 'Number of recent entries to display';
 $string['pluginname'] = 'Recent blog entries';
index dde30e0..9758711 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_blog_recent'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/blog_tags/db/access.php b/blocks/blog_tags/db/access.php
new file mode 100644 (file)
index 0000000..ba81a71
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Blog tags block caps.
+ *
+ * @package    block_blog_tags
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/blog_tags:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/blog_tags:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index f271d37..cc3c25e 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['blog_tags:addinstance'] = 'Add a new blog tags block';
+$string['blog_tags:myaddinstance'] = 'Add a new blog tags block to the My Moodle page';
 $string['pluginname'] = 'Blog tags';
index 2152f9d..237dd3e 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_blog_tags'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/calendar_month/db/access.php b/blocks/calendar_month/db/access.php
new file mode 100644 (file)
index 0000000..71cb0bc
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Calendar month block caps.
+ *
+ * @package    block_calendar_month
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/calendar_month:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/calendar_month:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 8187b3c..887a1ef 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['calendar_month:addinstance'] = 'Add a new calendar block';
+$string['calendar_month:myaddinstance'] = 'Add a new calendar block to the My Moodle page';
 $string['pluginname'] = 'Calendar';
index 449f088..72db711 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_calendar_month'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/calendar_upcoming/db/access.php b/blocks/calendar_upcoming/db/access.php
new file mode 100644 (file)
index 0000000..673cf8b
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Calendar upcoming block caps.
+ *
+ * @package    block_calendar_upcoming
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/calendar_upcoming:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/calendar_upcoming:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 4d33bd9..130b716 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['calendar_upcoming:addinstance'] = 'Add a new upcoming events block';
+$string['calendar_upcoming:myaddinstance'] = 'Add a new upcoming events block to the My Moodle page';
 $string['pluginname'] = 'Upcoming events';
index 86d947b..e25aba6 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_calendar_upcoming'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/comments/db/access.php b/blocks/comments/db/access.php
new file mode 100644 (file)
index 0000000..1122993
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Comments block caps.
+ *
+ * @package    block_comments
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/comments:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/comments:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index ead57db..01c919a 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['comments:myaddinstance'] = 'Add a new comments block to the My Moodle page';
+$string['comments:addinstance'] = 'Add a new comments block';
 $string['pluginname'] = 'Comments';
index db0ee48..e1b7118 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_comments'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/community/db/access.php b/blocks/community/db/access.php
new file mode 100644 (file)
index 0000000..1ec36ed
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Community block caps.
+ *
+ * @package    block_community
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/community:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/community:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index ec78b5a..ef509e3 100644 (file)
@@ -19,7 +19,7 @@
  * Strings for component 'block_community', language 'en', branch 'MOODLE_20_STABLE'
  *
  * @package   block_community
- * @author     Jerome Mouneyrac <jerome@mouneyrac.com>
+ * @author    Jerome Mouneyrac <jerome@mouneyrac.com>
  * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
@@ -37,6 +37,8 @@ $string['audience_help'] = 'What kind of course are you looking for?  As well as
 $string['blocks'] = 'Blocks';
 $string['cannotselecttopsubject'] = 'Cannot select a top subject level';
 $string['comments'] = 'Comments ({$a})';
+$string['community:addinstance'] = 'Add a new community finder block';
+$string['community:myaddinstance'] = 'Add a new community finder block to the My Moodle page';
 $string['contentinfo'] = 'Subject: {$a->subject} - Audience: {$a->audience} - Educational level: {$a->educationallevel}';
 $string['continue'] = 'Continue';
 $string['contributors'] = ' - Contributors: {$a}';
index 18ca3c4..77cf608 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_community'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/completionstatus/db/access.php b/blocks/completionstatus/db/access.php
new file mode 100644 (file)
index 0000000..8220ecc
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Completion status block caps.
+ *
+ * @package    block_completionstatus
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/completionstatus:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/completionstatus:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 6658c17..3c90759 100644 (file)
@@ -1,6 +1,31 @@
 <?php
 
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for component 'block_completionstatus', language 'en', branch 'MOODLE_20_STABLE'
+ *
+ * @package   block_completionstatus
+ * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
 $string['completionprogressdetails'] = 'Completion progress details';
+$string['completionstatus:addinstance'] = 'Add a new course completion status block';
+$string['completionstatus:myaddinstance'] = 'Add a new course completion status block to the My Moodle page';
 $string['criteriagroup'] = 'Criteria group';
 $string['firstofsecond'] = '{$a->first} of {$a->second}';
 $string['pluginname'] = 'Course completion status';
index f47016c..c9fc3df 100644 (file)
@@ -26,7 +26,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version      = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version      = 2012091600; // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires     = 2012061700; // Requires this Moodle version
 $plugin->component    = 'block_completionstatus';
 $plugin->dependencies = array('report_completion' => 2012061700);
\ No newline at end of file
diff --git a/blocks/course_list/db/access.php b/blocks/course_list/db/access.php
new file mode 100644 (file)
index 0000000..5d594fe
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Course list block caps.
+ *
+ * @package    block_course_list
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/course_list:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/course_list:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 4e79fc1..4265f45 100644 (file)
@@ -27,6 +27,8 @@ $string['adminview'] = 'Admin view';
 $string['allcourses'] = 'Admin user sees all courses';
 $string['configadminview'] = 'What should the admin see in the course list block?';
 $string['confighideallcourseslink'] = 'Hide "All courses" link at the bottom of the block. Link hiding does not affects Admin\'s view';
+$string['course_list:addinstance'] = 'Add a new courses block';
+$string['course_list:myaddinstance'] = 'Add a new courses block to the My Moodle page';
 $string['hideallcourseslink'] = 'Hide All courses link';
 $string['owncourses'] = 'Admin user sees own courses';
 $string['pluginname'] = 'Courses';
index 79ab1af..d30f69b 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_course_list'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/course_overview/db/access.php b/blocks/course_overview/db/access.php
new file mode 100644 (file)
index 0000000..828135c
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Course overview block caps.
+ *
+ * @package    block_course_overview
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/course_overview:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/course_overview:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 0419efc..d7be855 100644 (file)
  * @copyright  2012 Adam Olley <adam.olley@netspot.com.au>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-$string['pluginname'] = 'Course overview';
+
 $string['activityoverview'] = 'You have {$a}s that need attention';
 $string['alwaysshowall'] = 'Always Show All';
 $string['collapseall'] = 'Collapse All Course Lists';
 $string['configotherexpanded'] = 'If enabled, Other Courses will be expanded by default unless overriden by user preferences.';
 $string['configpreservestates'] = 'If enabled, the collapsed/expanded states set by the user are stored and used on each load.';
+$string['course_overview:addinstance'] = 'Add a new course overview block';
+$string['course_overview:myaddinstance'] = 'Add a new course overview block to the My Moodle page';
 $string['defaultmaxcourses'] = 'Default maximum courses';
 $string['defaultmaxcoursesdesc'] = 'Maximum courses which should be displayed on course overview block, 0 will show all courses';
 $string['expandall'] = 'Expand All Course Lists';
@@ -39,6 +41,7 @@ $string['messages'] = 'messages';
 $string['movecoursehere'] = 'Move course here';
 $string['numtodisplay'] = 'Number of courses to display: ';
 $string['otherexpanded'] = 'Other Courses Expanded';
+$string['pluginname'] = 'Course overview';
 $string['preservestates'] = 'Preserve Expanded States';
 $string['shortnameprefix'] = 'Includes {$a}';
 $string['shortnamesufixsingular'] = ' (and {$a} other)';
@@ -50,4 +53,4 @@ $string['showwelcomeareadesc'] = 'Show the welcome area above the course list?';
 $string['view_edit_profile'] = '(View and edit your profile.)';
 $string['welcome'] = 'Welcome {$a}';
 $string['youhavemessages'] = 'You have {$a} unread ';
-$string['youhavenomessages'] = 'You have no unread ';
\ No newline at end of file
+$string['youhavenomessages'] = 'You have no unread ';
index 4208588..787f52b 100644 (file)
@@ -24,6 +24,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012062800;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_course_overview'; // Full name of the plugin (used for diagnostics)
\ No newline at end of file
diff --git a/blocks/course_summary/db/access.php b/blocks/course_summary/db/access.php
new file mode 100644 (file)
index 0000000..5613ae7
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Course summary block caps.
+ *
+ * @package    block_course_summary
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/course_summary:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/course_summary:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index ca2b53b..836cbfc 100644 (file)
@@ -24,4 +24,6 @@
  */
 
 $string['coursesummary'] = 'Course summary';
+$string['course_summary:addinstance'] = 'Add a new course/site description block';
+$string['course_summary:myaddinstance'] = 'Add a new course/site description block to the My Moodle page';
 $string['pluginname'] = 'Course/Site description';
index 482a4cb..5e9801f 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_course_summary'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/feedback/db/access.php b/blocks/feedback/db/access.php
new file mode 100644 (file)
index 0000000..759f6d7
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Feedback block caps.
+ *
+ * @package    block_feedback
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/feedback:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/feedback:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 8d1bca4..ab69613 100644 (file)
@@ -1,5 +1,30 @@
 <?php
 
-$string['pluginname'] = 'Feedback';
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for component 'block_feedback', language 'en', branch 'MOODLE_20_STABLE'
+ *
+ * @package   block_feedback
+ * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
 $string['feedback'] = 'Feedback';
+$string['feedback:addinstance'] = 'Add a new feedback block';
+$string['feedback:myaddinstance'] = 'Add a new feedback block to the My Moodle page';
 $string['missing_feedback_module'] = 'This blocks relies on the Feedback activity module, but that module is not present!';
+$string['pluginname'] = 'Feedback';
index cd36d5f..dee2421 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_feedback';  // Full name of the plugin (used for diagnostics)
diff --git a/blocks/glossary_random/db/access.php b/blocks/glossary_random/db/access.php
new file mode 100644 (file)
index 0000000..0c1acd6
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Glossary random block caps.
+ *
+ * @package    block_glossary_random
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$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,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index efcb980..ddb483d 100644 (file)
@@ -27,6 +27,8 @@ $string['addentry'] = 'Add your own favorite quotes!';
 $string['askaddentry'] = 'When users can add entries to the glossary, show a link with this text';
 $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';
index 7a4ef6e..1d70116 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_glossary_random'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/html/db/access.php b/blocks/html/db/access.php
new file mode 100644 (file)
index 0000000..84c5836
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * HTML block caps.
+ *
+ * @package    block_html
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/html:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/html:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index d331059..47ebe4a 100644 (file)
@@ -29,6 +29,8 @@ $string['configclasses'] = 'Additional CSS classes';
 $string['configclasses_help'] = 'The purpose of this configuration is to aid with theming by helping distinguish HTML blocks from each other. Any CSS classes entered here (space delimited) will be appended to the block\'s default classes.';
 $string['configcontent'] = 'Content';
 $string['configtitle'] = 'Block title';
+$string['html:addinstance'] = 'Add a new HTML block';
+$string['html:myaddinstance'] = 'Add a new HTML block to the My Moodle page';
 $string['leaveblanktohide'] = 'leave blank to hide the title';
 $string['newhtmlblock'] = '(new HTML block)';
 $string['pluginname'] = 'HTML';
index 8ebbc49..94b1efd 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_html';      // Full name of the plugin (used for diagnostics)
diff --git a/blocks/login/db/access.php b/blocks/login/db/access.php
new file mode 100644 (file)
index 0000000..109eedc
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Login block caps.
+ *
+ * @package    block_login
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/login:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/login:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 1d5f117..83dd8dc 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['login:addinstance'] = 'Add a new login block';
+$string['login:myaddinstance'] = 'Add a new login block to the My Moodle page';
 $string['pluginname'] = 'Login';
index 60fead7..78f4d67 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_login';     // Full name of the plugin (used for diagnostics)
diff --git a/blocks/mentees/db/access.php b/blocks/mentees/db/access.php
new file mode 100644 (file)
index 0000000..ba14b07
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Mentees block caps.
+ *
+ * @package    block_mentees
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$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,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 7b443bb..3a22057 100644 (file)
@@ -26,5 +26,7 @@
 $string['configtitle'] = 'Block title';
 $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';
index 1642f31..66f51a7 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_mentees';   // Full name of the plugin (used for diagnostics)
diff --git a/blocks/messages/db/access.php b/blocks/messages/db/access.php
new file mode 100644 (file)
index 0000000..4ea589d
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Messages block caps.
+ *
+ * @package    block_messages
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/messages:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/messages:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 6f91fa3..b542a7a 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['messages:addinstance'] = 'Add a new messages block';
+$string['messages:myaddinstance'] = 'Add a new messages block to the My Moodle page';
 $string['pluginname'] = 'Messages';
index 93c6a91..8482826 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_messages';  // Full name of the plugin (used for diagnostics)
diff --git a/blocks/mnet_hosts/db/access.php b/blocks/mnet_hosts/db/access.php
new file mode 100644 (file)
index 0000000..43e2c32
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Mnet hosts block caps.
+ *
+ * @package    block_mnet_hosts
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/mnet_hosts:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/mnet_hosts:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index c8e273e..1da1a2a 100644 (file)
@@ -26,5 +26,7 @@
 $string['error_authmnetneeded'] = 'MNet authentication plugin must be enabled to see the list of MNet network servers';
 $string['error_localusersonly'] = 'Remote users can not jump to other MNet network servers from this host';
 $string['error_roamcapabilityneeded'] = 'Users need the capability \'Roam to a remote application via MNet\' to see the list of MNet network servers';
+$string['mnet_hosts:addinstance'] = 'Add a new network servers block';
+$string['mnet_hosts:myaddinstance'] = 'Add a new network servers block to the My Moodle page';
 $string['pluginname'] = 'Network servers';
 $string['server'] = 'Server';
index 2548a40..8f936c5 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_mnet_hosts'; // Full name of the plugin (used for diagnostics)
index d5a20a2..b1a6bf7 100644 (file)
@@ -558,20 +558,48 @@ class block_base {
     function user_can_addto($page) {
         global $USER;
 
-        if (has_capability('moodle/block:edit', $page->context)) {
-            return true;
-        }
-
         // The blocks in My Moodle are a special case and use a different capability.
         if (!empty($USER->id)
-            && $page->context->contextlevel == CONTEXT_USER             // Page belongs to a user
-            && $page->context->instanceid == $USER->id) {               // Page belongs to this user
-            return has_capability('moodle/my:manageblocks', $page->context);
+            && $page->context->contextlevel == CONTEXT_USER // Page belongs to a user
+            && $page->context->instanceid == $USER->id) { // Page belongs to this user
+            $capability = 'block/' . $this->name() . ':myaddinstance';
+            return $this->has_add_block_capability($page, $capability)
+                    && has_capability('moodle/my:manageblocks', $page->context);
+        }
+
+        $capability = 'block/' . $this->name() . ':addinstance';
+        if ($this->has_add_block_capability($page, $capability)
+                && has_capability('moodle/block:edit', $page->context)) {
+            return true;
         }
 
         return false;
     }
 
+    /**
+     * Returns true if the user can add a block to a page.
+     *
+     * @param moodle_page $page
+     * @param string $capability the capability to check
+     * @return boolean true if user can add a block, false otherwise.
+     */
+    private function has_add_block_capability($page, $capability) {
+        // Check if the capability exists.
+        if (!get_capability_info($capability)) {
+            // Debug warning that the capability does not exist, but no more than once per page.
+            static $warned = array();
+            if (!isset($warned[$this->name()])) {
+                debugging('The block ' .$this->name() . ' does not define the standard capability ' .
+                        $capability , DEBUG_DEVELOPER);
+                $warned[$this->name()] = 1;
+            }
+            // If the capability does not exist, the block can always be added.
+            return true;
+        } else {
+            return has_capability($capability, $page->context);
+        }
+    }
+
     static function get_extra_capabilities() {
         return array('moodle/block:view', 'moodle/block:edit');
     }
diff --git a/blocks/myprofile/db/access.php b/blocks/myprofile/db/access.php
new file mode 100644 (file)
index 0000000..328a6f0
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * My profile block caps.
+ *
+ * @package    block_myprofile
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/myprofile:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/myprofile:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 74dea91..450b640 100644 (file)
@@ -24,8 +24,6 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-$string['pluginname'] = 'Logged in user';
-$string['myprofile_settings'] = 'Visible user information';
 $string['contentsettings'] = 'Display settings for content region';
 $string['display_picture'] = 'Display picture';
 $string['display_country'] = 'Display country';
@@ -45,3 +43,7 @@ $string['display_firstaccess'] = 'Display first access';
 $string['display_lastaccess'] = 'Display last access';
 $string['display_currentlogin'] = 'Display current login';
 $string['display_lastip'] = 'Display last IP';
+$string['myprofile:addinstance'] = 'Add a new logged in user block';
+$string['myprofile:myaddinstance'] = 'Add a new logged in user block to the My Moodle page';
+$string['myprofile_settings'] = 'Visible user information';
+$string['pluginname'] = 'Logged in user';
index 9e8f652..a2bbdcb 100644 (file)
@@ -26,6 +26,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_myprofile'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/navigation/db/access.php b/blocks/navigation/db/access.php
new file mode 100644 (file)
index 0000000..6754273
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Navigation block caps.
+ *
+ * @package    block_navigation
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/navigation:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/navigation:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 1fb2aa3..c00d802 100644 (file)
@@ -31,6 +31,8 @@ $string['courseactivities'] = 'Categories, courses, and course Activities';
 $string['enabledockdesc'] = 'Allow the user to dock this block';
 $string['expansionlimit'] = 'Generate navigation for the following';
 $string['linkcategoriesdesc'] = 'Display categories as links';
+$string['navigation:addinstance'] = 'Add a new navigation block';
+$string['navigation:myaddinstance'] = 'Add a new navigation block to the My Moodle page';
 $string['pluginname'] = 'Navigation';
 $string['trimmode'] = 'Trim mode';
 $string['trimmoderight'] = 'Trim characters from the right';
index b6454c7..8fa942a 100644 (file)
@@ -24,6 +24,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_navigation'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/news_items/db/access.php b/blocks/news_items/db/access.php
new file mode 100644 (file)
index 0000000..86bb1b7
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * News items block caps.
+ *
+ * @package    block_news_items
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$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,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index d13568a..d1ab3d8 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['news_items:addinstance'] = 'Add a new latest news block';
+$string['news_items:myaddinstance'] = 'Add a new navigation block to the My Moodle page';
 $string['pluginname'] = 'Latest news';
index 19f9814..1c9e875 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_news_items'; // Full name of the plugin (used for diagnostics)
index ff00c60..f238b73 100644 (file)
@@ -26,6 +26,29 @@ defined('MOODLE_INTERNAL') || die();
 
 $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,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+
     'block/online_users:viewlist' => array(
 
         'captype' => 'read',
@@ -40,5 +63,3 @@ $capabilities = array(
         )
     )
 );
-
-
index 360ef48..034fce5 100644 (file)
@@ -24,6 +24,8 @@
  */
 
 $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';
index 34e50b5..5afa7eb 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_online_users'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/participants/db/access.php b/blocks/participants/db/access.php
new file mode 100644 (file)
index 0000000..ad8a9f2
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Participants block caps.
+ *
+ * @package    block_participants
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/participants:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/participants:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 1343996..fc2ec8b 100644 (file)
@@ -23,4 +23,6 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['participants:addinstance'] = 'Add a new people block';
+$string['participants:myaddinstance'] = 'Add a new people block to the My Moodle page';
 $string['pluginname'] = 'People';
index ca8564f..eaa1859 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_participants'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/private_files/db/access.php b/blocks/private_files/db/access.php
new file mode 100644 (file)
index 0000000..707027f
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Private files block caps.
+ *
+ * @package    block_private_files
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/private_files:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/private_files:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index e3970e6..b672dde 100644 (file)
@@ -26,3 +26,6 @@
 $string['managemyfiles'] = 'Manage my files';
 $string['pluginname'] = 'My private files';
 $string['privatefiles'] = 'Private files';
+$string['private_files:addinstance'] = 'Add a new private files block';
+$string['private_files:myaddinstance'] = 'Add a new private files block to the My Moodle page';
+
index d2737bf..3f5ec71 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_private_files'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/quiz_results/db/access.php b/blocks/quiz_results/db/access.php
new file mode 100644 (file)
index 0000000..ec77308
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Quiz results block caps.
+ *
+ * @package    block_quiz_results
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/quiz_results:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/quiz_results:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index b3bda7f..a035cbc 100644 (file)
@@ -46,6 +46,8 @@ $string['error_emptyquizid'] = 'There is an error right now with this block: you
 $string['error_emptyquizrecord'] = 'There is an error right now with this block: the selected quiz does not seem to exist in the database.';
 $string['error_nogroupsexist'] = 'There is an error right now with this block: it is set to display grades in group mode, but the course has no defined groups.';
 $string['pluginname'] = 'Quiz results';
+$string['quiz_results:addinstance'] = 'Add a new quiz results block';
+$string['quiz_results:myaddinstance'] = 'Add a new quiz results block to the My Moodle page';
 $string['worstgrade'] = 'The lowest grade:';
 $string['worstgrades'] = 'The {$a} lowest grades:';
 $string['worstgroupgrade'] = 'The group with the lowest average:';
index eb8a929..22eeac7 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_quiz_results'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/recent_activity/db/access.php b/blocks/recent_activity/db/access.php
new file mode 100644 (file)
index 0000000..331dbba
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Recent activity block caps.
+ *
+ * @package    block_recent_activity
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/recent_activity:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/recent_activity:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 9284efd..6d47dce 100644 (file)
@@ -24,3 +24,5 @@
  */
 
 $string['pluginname'] = 'Recent activity';
+$string['recent_activity:addinstance'] = 'Add a new recent activity block';
+$string['recent_activity:myaddinstance'] = 'Add a new recent activity block to the My Moodle page';
index 006ae71..9eefc82 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_recent_activity'; // Full name of the plugin (used for diagnostics)
index 6eeb862..3789a58 100644 (file)
@@ -26,6 +26,29 @@ defined('MOODLE_INTERNAL') || die();
 
 $capabilities = array(
 
+    'block/rss_client:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/rss_client:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+
     'block/rss_client:manageownfeeds' => array(
 
         'captype' => 'write',
index 33ca817..77e161c 100644 (file)
@@ -62,10 +62,12 @@ $string['numentries'] = 'Entries per feed';
 $string['pickfeed'] = 'Pick a news feed';
 $string['pluginname'] = 'Remote RSS feeds';
 $string['remotenewsfeed'] = 'Remote news feed';
+$string['rss_client:addinstance'] = 'Add a new remote RSS feeds block';
 $string['rss_client:createprivatefeeds'] = 'Create private RSS feeds';
 $string['rss_client:createsharedfeeds'] = 'Create shared RSS feeds';
 $string['rss_client:manageanyfeeds'] = 'Manage any RSS feeds';
 $string['rss_client:manageownfeeds'] = 'Manage own RSS feeds';
+$string['rss_client:myaddinstance'] = 'Add a new remote RSS feeds block to the My Moodle page';
 $string['seeallfeeds'] = 'See all feeds';
 $string['sharedfeed'] = 'Shared feed';
 $string['shownumentrieslabel'] = 'Max number entries to show per block.';
index 266a8bc..c19bcff 100644 (file)
@@ -25,7 +25,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_rss_client'; // Full name of the plugin (used for diagnostics)
 $plugin->cron      = 300;               // Set min time between cron executions to 300 secs (5 mins)
diff --git a/blocks/search_forums/db/access.php b/blocks/search_forums/db/access.php
new file mode 100644 (file)
index 0000000..bd5c3a6
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Search forums block caps.
+ *
+ * @package    block_search_forums
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/search_forums:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/search_forums:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index d71a510..3b998ba 100644 (file)
@@ -25,3 +25,5 @@
 
 $string['advancedsearch'] = 'Advanced search';
 $string['pluginname'] = 'Search forums';
+$string['search_forums:addinstance'] = 'Add a new search forums block';
+$string['search_forums:myaddinstance'] = 'Add a new search forums block for the My Moodle page';
index 0203983..8a77b05 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_search_forums'; // Full name of the plugin (used for diagnostics)
index a8a0a93..2942b47 100644 (file)
@@ -72,6 +72,7 @@ class block_section_links extends block_base {
         }
 
         $course = $this->page->course;
+        $courseformatoptions = course_get_format($course)->get_format_options();
         $context = context_course::instance($course->id);
 
         if ($course->format == 'weeks' or $course->format == 'weekscss') {
@@ -86,18 +87,18 @@ class block_section_links extends block_base {
         }
         $inc = 1;
 
-        if(!empty($config->numsections1) and ($course->numsections > $config->numsections1)) {
+        if(!empty($config->numsections1) and ($courseformatoptions['numsections'] > $config->numsections1)) {
             $inc = $config->incby1;
         } else {
-            if ($course->numsections > 22) {
+            if ($courseformatoptions['numsections'] > 22) {
                 $inc = 2;
             }
         }
 
-        if(!empty($config->numsections2) and ($course->numsections > $config->numsections2)) {
+        if(!empty($config->numsections2) and ($courseformatoptions['numsections'] > $config->numsections2)) {
             $inc = $config->incby2;
         } else {
-            if ($course->numsections > 40) {
+            if ($courseformatoptions['numsections'] > 40) {
                 $inc = 5;
             }
         }
@@ -105,12 +106,12 @@ class block_section_links extends block_base {
         $sql = "SELECT section, visible
                   FROM {course_sections}
                  WHERE course = ? AND
-                       section < ".($course->numsections+1)."
+                       section < ".($courseformatoptions['numsections']+1)."
               ORDER BY section";
 
         if ($sections = $DB->get_records_sql($sql, array($course->id))) {
             $text = '<ol class="inline-list">';
-            for ($i = $inc; $i <= $course->numsections; $i += $inc) {
+            for ($i = $inc; $i <= $courseformatoptions['numsections']; $i += $inc) {
                 if (!isset($sections[$i])) {
                     continue;
                 }
diff --git a/blocks/section_links/db/access.php b/blocks/section_links/db/access.php
new file mode 100644 (file)
index 0000000..5e6a48b
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Section links block caps.
+ *
+ * @package    block_section_links
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/section_links:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/section_links:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 57e8c12..c267cd1 100644 (file)
@@ -34,5 +34,7 @@ $string['numsectionsdesc2'] = 'Once the number of sections in the course reaches
 $string['numsections1'] = 'Number of sections';
 $string['numsections2'] = 'Alternative number of sections';
 $string['pluginname'] = 'Section links';
+$string['section_links:addinstance'] = 'Add a new section links block';
+$string['section_links:myaddinstance'] = 'Add a new section links block to the My Moodle page';
 $string['topics'] = 'Topics';
 $string['weeks'] = 'Weeks';
index 1bfd4f0..9b24bfe 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_section_links'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/selfcompletion/db/access.php b/blocks/selfcompletion/db/access.php
new file mode 100644 (file)
index 0000000..489eebd
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Self completion block caps.
+ *
+ * @package    block_selfcompletion
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/selfcompletion:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/selfcompletion:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 403d0b2..e7c89d3 100644 (file)
@@ -27,3 +27,5 @@ $string['alreadyselfcompleted'] = 'You have already marked yourself as complete
 $string['completecourse'] = 'Complete course';
 $string['pluginname'] = 'Self completion';
 $string['selfcompletionnotenabled'] = 'The self completion criteria has not been enabled for this course';
+$string['selfcompletion:addinstance'] = 'Add a new self completion block';
+$string['selfcompletion:myaddinstance'] = 'Add a new self completion block to the My Moodle page';
index 92a5a56..9fc46d6 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_selfcompletion'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/settings/db/access.php b/blocks/settings/db/access.php
new file mode 100644 (file)
index 0000000..7585857
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Settings block caps.
+ *
+ * @package    block_settings
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/settings:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/settings:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 51a7d50..3563843 100644 (file)
@@ -26,3 +26,5 @@
 
 $string['enabledock'] = 'Allow the user to dock this block';
 $string['pluginname'] = 'Settings';
+$string['settings:addinstance'] = 'Add a new settings block';
+$string['settings:myaddinstance'] = 'Add a new settings block to the My Moodle page';
index 686672b..9740627 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_settings';  // Full name of the plugin (used for diagnostics)
diff --git a/blocks/site_main_menu/db/access.php b/blocks/site_main_menu/db/access.php
new file mode 100644 (file)
index 0000000..aaa71d7
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Site main menu block caps.
+ *
+ * @package    block_site_main_menu
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/site_main_menu:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/site_main_menu:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index f4c92fc..0a2f478 100644 (file)
@@ -24,4 +24,5 @@
  */
 
 $string['pluginname'] = 'Main menu';
-
+$string['site_main_menu:addinstance'] = 'Add a new main menu block';
+$string['site_main_menu:myaddinstance'] = 'Add a new main menu block to the My Moodle page';
index 0930f06..931c433 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_site_main_menu'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/social_activities/db/access.php b/blocks/social_activities/db/access.php
new file mode 100644 (file)
index 0000000..1981d02
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Social activities block caps.
+ *
+ * @package    block_social_activities
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/social_activities:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/social_activities:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 16d91ee..abb5666 100644 (file)
@@ -24,3 +24,5 @@
  */
 
 $string['pluginname'] = 'Social activities';
+$string['social_activities:addinstance'] = 'Add a new social activities block';
+$string['social_activities:myaddinstance'] = 'Add a new social activities block to the My Moodle page';
index 26002a0..beb8563 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_social_activities'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/tag_flickr/db/access.php b/blocks/tag_flickr/db/access.php
new file mode 100644 (file)
index 0000000..414b070
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Tag flickr block caps.
+ *
+ * @package    block_tag_flickr
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/tag_flickr:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/tag_flickr:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index 76f8e8a..6dc3172 100644 (file)
@@ -37,3 +37,5 @@ $string['numberofphotos'] = 'Number of photos';
 $string['pluginname'] = 'Flickr';
 $string['relevance'] = 'Relevance';
 $string['sortby'] = 'Sort by';
+$string['tag_flickr:addinstance'] = 'Add a new flickr block';
+$string['tag_flickr:myaddinstance'] = 'Add a new flickr block to the My Moodle page';
index 3288914..89a4226 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_tag_flickr'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/tag_youtube/db/access.php b/blocks/tag_youtube/db/access.php
new file mode 100644 (file)
index 0000000..0c1aac4
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Tag youtube block caps.
+ *
+ * @package    block_tag_youtube
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/tag_youtube:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/tag_youtube:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index cb1180a..0e3dc8f 100644 (file)
@@ -42,4 +42,6 @@ $string['petsanimals'] = 'Pets &amp; Animals';
 $string['pluginname'] = 'Youtube';
 $string['scienceandtech'] = 'Science &amp; Tech';
 $string['sports'] = 'Sports';
+$string['tag_youtube:addinstance'] = 'Add a new youtube block';
+$string['tag_youtube:myaddinstance'] = 'Add a new youtube block to the My Moodle page';
 $string['travel'] = 'Travel &amp; Places';
index 91bb656..7dbf882 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012061700;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_tag_youtube'; // Full name of the plugin (used for diagnostics)
diff --git a/blocks/tags/db/access.php b/blocks/tags/db/access.php
new file mode 100644 (file)
index 0000000..7ba3459
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Tags block caps.
+ *
+ * @package    block_tags
+ * @copyright  Mark Nelson <markn@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/tags:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/tags:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
index ddd340e..7f2d59f 100644 (file)
@@ -70,5 +70,7 @@ $string['showcoursetags'] = 'Show course tags';
 $string['showcoursetagsdef'] = 'Display the course tagging features in the tags block, allowing students to tag courses.';
 $string['suggestedtagthisunit'] = 'Suggested tag to this course:';
 $string['tags'] = 'tags';
+$string['tags:addinstance'] = 'Add a new tags block';
+$string['tags:myaddinstance'] = 'Add a new tags block to the My Moodle page';
 $string['tagthisunit'] = 'Tag this course:';
 $string['tagunits'] = 'to tag your favourite courses';
index d4b93d1..2c02165 100644 (file)
@@ -25,6 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2012082800;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2012091600;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2012061700;        // Requires this Moodle version
 $plugin->component = 'block_tags';      // Full name of the plugin (used for diagnostics)
index f5e5816..40a723d 100644 (file)
@@ -9,6 +9,7 @@ A definition:
      $definitions = array(
         'string' => array(                            // Required, unique to the component
             'mode' => cache_store::MODE_APPLICATION,  // Required
+            'simpledata' => false,                    // Optional
             'requireidentifiers' => array(            // Optional
                 'lang'
             ),
@@ -104,6 +105,7 @@ The following settings are required for a definition:
 * mode - Application, session or request.
 
 The following optional settings can also be defined:
+* simpledata - Set to true if you know that you will only be storing scalar values or arrays of scalar values. Avoids costly investigation of data types.
 * requireidentifiers - Any identifiers the definition requires. Must be provided when creating the loader.
 * requiredataguarantee - If set to true then only stores that support data guarantee will be used.
 * requiremultipleidentifiers - If set to true then only stores that support multiple identifiers will be used.
index ce26856..3151e1d 100644 (file)
@@ -60,7 +60,7 @@ if (!empty($action) && confirm_sesskey()) {
             $mform = cache_administration_helper::get_add_store_form($plugin);
             $title = get_string('addstore', 'cache', $plugins[$plugin]['name']);
             if ($mform->is_cancelled()) {
-                rediect($PAGE->url);
+                redirect($PAGE->url);
             } else if ($data = $mform->get_data()) {
                 $config = cache_administration_helper::get_store_configuration_from_data($data);
                 $writer = cache_config_writer::instance();
@@ -80,7 +80,7 @@ if (!empty($action) && confirm_sesskey()) {
             $mform = cache_administration_helper::get_edit_store_form($plugin, $store);
             $title = get_string('addstore', 'cache', $plugins[$plugin]['name']);
             if ($mform->is_cancelled()) {
-                rediect($PAGE->url);
+                redirect($PAGE->url);
             } else if ($data = $mform->get_data()) {
                 $config = cache_administration_helper::get_store_configuration_from_data($data);
                 $writer = cache_config_writer::instance();
index a73c947..dcc219d 100644 (file)
@@ -39,6 +39,8 @@ defined('MOODLE_INTERNAL') || die();
  *          [int] Sets the mode for the definition. Must be one of cache_store::MODE_*
  *
  * Optional settings:
+ *     + simpledata
+ *          [bool] If set to true we know that the data is scalar or array of scalar.
  *     + requireidentifiers
  *          [array] An array of identifiers that must be provided to the cache when it is created.
  *     + requiredataguarantee
@@ -127,6 +129,12 @@ class cache_definition {
      */
     protected $area;
 
+    /**
+     * Set to true if we know the data is scalar or array of scalar.
+     * @var bool
+     */
+    protected $simpledata = false;
+
     /**
      * An array of identifiers that must be provided when the definition is used to create a cache.
      * @var array
@@ -281,6 +289,7 @@ class cache_definition {
         $area = (string)$definition['area'];
 
         // Set the defaults.
+        $simpledata = false;
         $requireidentifiers = array();
         $requiredataguarantee = false;
         $requiremultipleidentifiers = false;
@@ -297,6 +306,9 @@ class cache_definition {
         $mappingsonly = false;
         $invalidationevents = array();
 
+        if (array_key_exists('simpledata', $definition)) {
+            $simpledata = (bool)$definition['simpledata'];
+        }
         if (array_key_exists('requireidentifiers', $definition)) {
             $requireidentifiers = (array)$definition['requireidentifiers'];
         }
@@ -398,6 +410,7 @@ class cache_definition {
         $cachedefinition->mode = $mode;
         $cachedefinition->component = $component;
         $cachedefinition->area = $area;
+        $cachedefinition->simpledata = $simpledata;
         $cachedefinition->requireidentifiers = $requireidentifiers;
         $cachedefinition->requiredataguarantee = $requiredataguarantee;
         $cachedefinition->requiremultipleidentifiers = $requiremultipleidentifiers;
@@ -534,6 +547,14 @@ class cache_definition {
         return $this->mappingsonly;
     }
 
+    /**
+     * Returns true if the data is known to be scalar or array of scalar.
+     * @return bool
+     */
+    public function uses_simple_data() {
+        return $this->simpledata;
+    }
+
     /**
      * Returns true if this definition requires a data guarantee from the cache stores being used.
      * @return bool
index aa6a0ed..ef7b308 100644 (file)
@@ -498,6 +498,9 @@ class cache implements cache_loader {
      * @param stdClass|array $data
      */
     protected function unref($data) {
+        if ($this->definition->uses_simple_data()) {
+            return $data;
+        }
         // Check if it requires serialisation in order to produce a reference free copy.
         if ($this->requires_serialisation($data)) {
             // Damn, its going to have to be serialise.
index 3428d92..03d2b32 100644 (file)
@@ -456,6 +456,28 @@ class cachestore_file implements cache_store, cache_is_key_aware {
         return true;
     }
 
+    /**
+     * Given the data from the add instance form this function creates a configuration array.
+     *
+     * @param stdClass $data
+     * @return array
+     */
+    public static function config_get_configuration_array($data) {
+        $config = array();
+
+        if (isset($data->path)) {
+            $config['path'] = $data->path;
+        }
+        if (isset($data->autocreate)) {
+            $config['autocreate'] = $data->autocreate;
+        }
+        if (isset($data->prescan)) {
+            $config['prescan'] = $data->prescan;
+        }
+
+        return $config;
+    }
+
     /**
      * Checks to make sure that the path for the file cache exists.
      *
index 3b3b455..842ecc4 100644 (file)
@@ -464,7 +464,7 @@ class core_calendar_renderer extends plugin_renderer_base {
         // Paddding (the first week may have blank days in the beginning)
         for($i = $display->minwday; $i < $startwday; ++$i) {
             $cell = new html_table_cell('&nbsp;');
-            $cell->attributes = array('class'=>'nottoday');
+            $cell->attributes = array('class'=>'nottoday dayblank');
             $row->cells[] = $cell;
         }
 
@@ -523,10 +523,10 @@ class core_calendar_renderer extends plugin_renderer_base {
             }
 
             // Special visual fx for today
-            if($display->thismonth && $calendar->day == $calendar->day) {
-                $cellclasses[] = 'today';
+            if ($display->thismonth && $calendar->day == $date['mday']) {
+                $cellclasses[] = 'day today';
             } else {
-                $cellclasses[] = 'nottoday';
+                $cellclasses[] = 'day nottoday';
             }
             $cell->attributes = array('class'=>join(' ',$cellclasses));
 
@@ -557,7 +557,7 @@ class core_calendar_renderer extends plugin_renderer_base {
         // Paddding (the last week may have blank days at the end)
         for($i = $dayweek; $i <= $display->maxwday; ++$i) {
             $cell = new html_table_cell('&nbsp;');
-            $cell->attributes = array('class'=>'nottoday');
+            $cell->attributes = array('class'=>'nottoday dayblank');
             $row->cells[] = $cell;
         }
         $table->data[] = $row;
index 3354f1c..deed367 100644 (file)
@@ -31,6 +31,7 @@ require_once($CFG->dirroot.'/course/lib.php');
 $courseid = required_param('courseid', PARAM_INT);
 $increase = optional_param('increase', true, PARAM_BOOL);
 $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
+$courseformatoptions = course_get_format($course)->get_format_options();
 
 $PAGE->set_url('/course/changenumsections.php', array('courseid' => $courseid));
 
@@ -39,18 +40,21 @@ require_login($course);
 require_capability('moodle/course:update', context_course::instance($course->id));
 require_sesskey();
 
-if ($increase) {
-    // Add an additional section.
-    $course->numsections++;
-} else {
-    // Remove a section.
-    $course->numsections--;
-}
-
-// Don't go less than 0, intentionally redirect silently (for the case of
-// double clicks).
-if ($course->numsections >= 0) {
-    $DB->update_record('course', $course);
+if (isset($courseformatoptions['numsections'])) {
+    if ($increase) {
+        // Add an additional section.
+        $courseformatoptions['numsections']++;
+    } else {
+        // Remove a section.
+        $courseformatoptions['numsections']--;
+    }
+
+    // Don't go less than 0, intentionally redirect silently (for the case of
+    // double clicks).
+    if ($courseformatoptions['numsections'] >= 0) {
+        course_get_format($course)->update_course_format_options(
+                array('numsections' => $courseformatoptions['numsections']));
+    }
 }
 
 $url = course_get_url($course);
index 6a5aefb..8fbb3a9 100644 (file)
@@ -41,7 +41,7 @@ if ($id) { // editing course
         print_error('cannoteditsiteform');
     }
 
-    $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
+    $course = course_get_format($id)->get_course();
     require_login($course);
     $category = $DB->get_record('course_categories', array('id'=>$course->category), '*', MUST_EXIST);
     $coursecontext = context_course::instance($course->id);
index cb1feeb..70b709a 100644 (file)
@@ -10,9 +10,11 @@ class course_edit_form extends moodleform {
     protected $context;
 
     function definition() {
-        global $USER, $CFG, $DB;
+        global $USER, $CFG, $DB, $PAGE;
 
         $mform    = $this->_form;
+        $PAGE->requires->yui_module('moodle-course-formatchooser', 'M.course.init_formatchooser',
+                array(array('formid' => $mform->getAttribute('id'))));
 
         $course        = $this->_customdata['course']; // this contains the data of this form
         $category      = $this->_customdata['category'];
@@ -120,29 +122,14 @@ class course_edit_form extends moodleform {
         $mform->addHelpButton('format', 'format');
         $mform->setDefault('format', $courseconfig->format);
 
-        $mform->addElement('select', 'coursedisplay', get_string('coursedisplay'),
-            array(COURSE_DISPLAY_SINGLEPAGE => get_string('coursedisplay_single'),
-                COURSE_DISPLAY_MULTIPAGE => get_string('coursedisplay_multi')));
-        $mform->addHelpButton('coursedisplay', 'coursedisplay');
-        $mform->setDefault('coursedisplay', $courseconfig->coursedisplay);
-
-        for ($i = 0; $i <= $courseconfig->maxsections; $i++) {
-            $sectionmenu[$i] = "$i";
-        }
-        $mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu);
-        $mform->setDefault('numsections', $courseconfig->numsections);
+        // button to update format-specific options on format change (will be hidden by JavaScript)
+        $mform->registerNoSubmitButton('updatecourseformat');
+        $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
 
         $mform->addElement('date_selector', 'startdate', get_string('startdate'));
         $mform->addHelpButton('startdate', 'startdate');
         $mform->setDefault('startdate', time() + 3600 * 24);
 
-        $choices = array();
-        $choices['0'] = get_string('hiddensectionscollapsed');
-        $choices['1'] = get_string('hiddensectionsinvisible');
-        $mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices);
-        $mform->addHelpButton('hiddensections', 'hiddensections');
-        $mform->setDefault('hiddensections', $courseconfig->hiddensections);
-
         $options = range(0, 10);
         $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
         $mform->addHelpButton('newsitems', 'newsitemsnumber');
@@ -193,6 +180,9 @@ class course_edit_form extends moodleform {
             $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
         }
 
+//--------------------------------------------------------------------------------
+        $mform->addElement('hidden', 'addcourseformatoptionshere');
+
 //--------------------------------------------------------------------------------
         enrol_course_edit_form($mform, $course, $context);
 
@@ -310,8 +300,22 @@ class course_edit_form extends moodleform {
             $gr_el =& $mform->getElement('defaultgroupingid');
             $gr_el->load($options);
         }
-    }
 
+        // add course format options
+        $formatvalue = $mform->getElementValue('format');
+        if (is_array($formatvalue) && !empty($formatvalue)) {
+            $courseformat = course_get_format((object)array('format' => $formatvalue[0]));
+            $newel = $mform->createElement('header', '', get_string('courseformatoptions', 'moodle',
+                    $courseformat->get_format_name()));
+            $mform->insertElementBefore($newel, 'addcourseformatoptionshere');
+
+            $elements = $courseformat->create_edit_form_elements($mform);
+            for ($i = 0; $i < count($elements); $i++) {
+                $mform->insertElementBefore($mform->removeElement($elements[$i]->getName(), false),
+                        'addcourseformatoptionshere');
+            }
+        }
+    }
 
 /// perform some extra moodle validation
     function validation($data, $files) {
@@ -333,6 +337,12 @@ class course_edit_form extends moodleform {
 
         $errors = array_merge($errors, enrol_course_edit_validation($data, $this->context));
 
+        $courseformat = course_get_format((object)array('format' => $data['format']));
+        $formaterrors = $courseformat->edit_form_validation($data, $files, $errors);
+        if (!empty($formaterrors) && is_array($formaterrors)) {
+            $errors = array_merge($errors, $formaterrors);
+        }
+
         return $errors;
     }
 }
index 549bd98..c75e3dc 100644 (file)
@@ -16,7 +16,7 @@
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * Edit the introduction of a section
+ * Edit the section basic information and availability
  *
  * @copyright 1999 Martin Dougiamas  http://dougiamas.com
  * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 
 require_once("../config.php");
 require_once("lib.php");
-require_once($CFG->libdir.'/filelib.php');
-require_once($CFG->libdir . '/gradelib.php');
-require_once($CFG->libdir . '/completionlib.php');
 require_once($CFG->libdir . '/conditionlib.php');
 
-require_once('editsection_form.php');
-
-$id = required_param('id',PARAM_INT);    // Week/topic ID
+$id = required_param('id', PARAM_INT);    // course_sections.id
 $sectionreturn = optional_param('sr', 0, PARAM_INT);
 
 $PAGE->set_url('/course/editsection.php', array('id'=>$id, 'sr'=> $sectionreturn));
 
 $section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
 $course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
+$sectionnum = $section->section;
 
 require_login($course);
 $context = context_course::instance($course->id);
 require_capability('moodle/course:update', $context);
 
-$editoroptions = array('context'=>$context ,'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
-$section = file_prepare_standard_editor($section, 'summary', $editoroptions, $context, 'course', 'section', $section->id);
-$section->usedefaultname = (is_null($section->name));
-
-if (!empty($CFG->enableavailability)) {
-    // Get section availability conditions from sectioncache.
-    $modinfo = get_fast_modinfo($course);
-    $sectioninfo = $modinfo->get_section_info($section->section);
-    $section->conditionsgrade = $sectioninfo->conditionsgrade;
-    $section->conditionscompletion = $sectioninfo->conditionscompletion;
-    $section->conditionsfield = $sectioninfo->conditionsfield;
-}
-
-$mform = new editsection_form($PAGE->url, array('course' => $course, 'editoroptions' => $editoroptions,
-        'cs' => $section, 'showavailability' => $section->showavailability));
-$mform->set_data($section); // set current value
+// get section_info object with all availability options
+$sectioninfo = get_fast_modinfo($course)->get_section_info($sectionnum);
 
-$returnurl = course_get_url($course, $sectionreturn);
+$editoroptions = array('context'=>$context ,'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes'=>$CFG->maxbytes, 'trusttext'=>false, 'noclean'=>true);
+$mform = course_get_format($course->id)->editsection_form($PAGE->url,
+        array('cs' => $sectioninfo, 'editoroptions' => $editoroptions));
+// set current value, make an editable copy of section_info object
+// this will retrieve all format-specific options as well
+$mform->set_data(convert_to_array($sectioninfo));
 
-/// If data submitted, then process and store.
 if ($mform->is_cancelled()){
-    redirect($returnurl);
-
+    // form cancelled, return to course
+    redirect(course_get_url($course, $section, array('sr' => $sectionreturn)));
 } else if ($data = $mform->get_data()) {
-    if (empty($data->usedefaultname)) {
-        $section->name = $data->name;
-    } else {
-        $section->name = null;
-    }
-    $data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'section', $section->id);
-    $section->summary = $data->summary;
-    $section->summaryformat = $data->summaryformat;
-    if (!empty($CFG->enableavailability)) {
-        $section->availablefrom = $data->availablefrom;
-        $section->availableuntil = $data->availableuntil;
-        if (isset($data->groupingid)) {
-            $section->groupingid = $data->groupingid;
-        }
-        $section->showavailability = $data->showavailability;
+    // data submitted and validated, update and return to course
+    $DB->update_record('course_sections', $data);
+    rebuild_course_cache($course->id, true);
+    if (isset($data->section)) {
+        // usually edit form does not change relative section number but just in case
+        $sectionnum = $data->section;
     }
-    $DB->update_record('course_sections', $section);
     if (!empty($CFG->enableavailability)) {
         // Update grade and completion conditions
-        condition_info_section::update_section_from_form($section, $data);
+        $sectioninfo = get_fast_modinfo($course)->get_section_info($sectionnum);
+        condition_info_section::update_section_from_form($sectioninfo, $data);
+        rebuild_course_cache($course->id, true);
     }
-    rebuild_course_cache($course->id);
+    course_get_format($course->id)->update_section_format_options($data);
 
-    add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
+    add_to_log($course->id, "course", "editsection", "editsection.php?id=$id", "$sectionnum");
     $PAGE->navigation->clear_cache();
-    redirect($returnurl);
+    redirect(course_get_url($course, $section, array('sr' => $sectionreturn)));
 }
 
-$sectionname  = get_section_name($course, $section);
+// the edit form is displayed for the first time or there was a validation
+// error on the previous step. Display the edit form:
+$sectionname  = get_section_name($course, $sectionnum);
 $stredit      = get_string('edita', '', " $sectionname");
 $strsummaryof = get_string('summaryof', '', " $sectionname");
 
index 73da8d3..4dffac5 100644 (file)
@@ -5,7 +5,15 @@ if (!defined('MOODLE_INTERNAL')) {
 }
 
 require_once($CFG->libdir.'/formslib.php');
-
+require_once($CFG->libdir.'/filelib.php');
+require_once($CFG->libdir.'/completionlib.php');
+require_once($CFG->libdir.'/gradelib.php');
+
+/**
+ * Default form for editing course section
+ *
+ * Course format plugins may specify different editing form to use
+ */
 class editsection_form extends moodleform {
 
     function definition() {
@@ -28,6 +36,13 @@ class editsection_form extends moodleform {
         $mform->addElement('hidden', 'id');
         $mform->setType('id', PARAM_INT);
 
+        // additional fields that course format has defined
+        $courseformat = course_get_format($course);
+        $formatoptions = $courseformat->section_format_options(true);
+        if (!empty($formatoptions)) {
+            $elements = $courseformat->create_edit_form_elements($mform, true);
+        }
+
         $mform->_registerCancelButton('cancel');
     }
 
@@ -195,8 +210,6 @@ class editsection_form extends moodleform {
                 CONDITION_STUDENTVIEW_HIDE => get_string('showavailabilitysection_hide', 'condition'));
             $mform->addElement('select', 'showavailability',
                     get_string('showavailabilitysection', 'condition'), $showhide);
-
-            $mform->setDefault('showavailability', $this->_customdata['showavailability']);
         }
 
         $this->add_action_buttons();
@@ -232,4 +245,47 @@ class editsection_form extends moodleform {
 
         return $errors;
     }
+
+    /**
+     * Load in existing data as form defaults
+     *
+     * @param stdClass|array $default_values object or array of default values
+     */
+    function set_data($default_values) {
+        if (!is_object($default_values)) {
+            // we need object for file_prepare_standard_editor
+            $default_values = (object)$default_values;
+        }
+        $editoroptions = $this->_customdata['editoroptions'];
+        $default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions,
+                $editoroptions['context'], 'course', 'section', $default_values->id);
+        $default_values->usedefaultname = (is_null($default_values->name));
+        parent::set_data($default_values);
+    }
+
+    /**
+     * Return submitted data if properly submitted or returns NULL if validation fails or
+     * if there is no submitted data.
+     *
+     * @return object submitted data; NULL if not valid or not submitted or cancelled
+     */
+    function get_data() {
+        $data = parent::get_data();
+        if ($data !== null) {
+            $editoroptions = $this->_customdata['editoroptions'];
+            if (!empty($data->usedefaultname)) {
+                $data->name = null;
+            }
+            $data = file_postupdate_standard_editor($data, 'summary', $editoroptions,
+                    $editoroptions['context'], 'course', 'section', $data->id);
+            $course = $this->_customdata['course'];
+            foreach (course_get_format($course)->section_format_options() as $option => $unused) {
+                // fix issue with unset checkboxes not being returned at all
+                if (!isset($data->$option)) {
+                    $data->$option = null;
+                }
+            }
+        }
+        return $data;
+    }
 }
index 290146a..659228c 100644 (file)
@@ -297,6 +297,7 @@ class core_course_external extends external_api {
 
             // now security checks
             $context = context_course::instance($course->id, IGNORE_MISSING);
+            $courseformatoptions = course_get_format($course)->get_format_options();
             try {
                 self::validate_context($context);
             } catch (Exception $e) {
@@ -316,7 +317,10 @@ class core_course_external extends external_api {
                 external_format_text($course->summary, $course->summaryformat, $context->id, 'course', 'summary', 0);
             $courseinfo['format'] = $course->format;
             $courseinfo['startdate'] = $course->startdate;
-            $courseinfo['numsections'] = $course->numsections;
+            if (array_key_exists('numsections', $courseformatoptions)) {
+                // For backward-compartibility
+                $courseinfo['numsections'] = $courseformatoptions['numsections'];
+            }
 
             //some field should be returned only if the user has update permission
             $courseadmin = has_capability('moodle/course:update', $context);
@@ -328,7 +332,10 @@ class core_course_external extends external_api {
                 $courseinfo['newsitems'] = $course->newsitems;
                 $courseinfo['visible'] = $course->visible;
                 $courseinfo['maxbytes'] = $course->maxbytes;
-                $courseinfo['hiddensections'] = $course->hiddensections;
+                if (array_key_exists('hiddensections', $courseformatoptions)) {
+                    // For backward-compartibility
+                    $courseinfo['hiddensections'] = $courseformatoptions['hiddensections'];
+                }
                 $courseinfo['groupmode'] = $course->groupmode;
                 $courseinfo['groupmodeforce'] = $course->groupmodeforce;
                 $courseinfo['defaultgroupingid'] = $course->defaultgroupingid;
@@ -339,6 +346,13 @@ class core_course_external extends external_api {
                 $courseinfo['enablecompletion'] = $course->enablecompletion;
                 $courseinfo['completionstartonenrol'] = $course->completionstartonenrol;
                 $courseinfo['completionnotify'] = $course->completionnotify;
+                $courseinfo['courseformatoptions'] = array();
+                foreach ($courseformatoptions as $key => $value) {
+                    $courseinfo['courseformatoptions'][] = array(
+                        'name' => $key,
+                        'value' => $value
+                    );
+                }
             }
 
             if ($courseadmin or $course->visible
@@ -377,7 +391,9 @@ class core_course_external extends external_api {
                                     'number of recent items appearing on the course page', VALUE_OPTIONAL),
                             'startdate' => new external_value(PARAM_INT,
                                     'timestamp when the course start'),
-                            'numsections' => new external_value(PARAM_INT, 'number of weeks/topics'),
+                            'numsections' => new external_value(PARAM_INT,
+                                    '(deprecated, use courseformatoptions) number of weeks/topics',
+                                    VALUE_OPTIONAL),
                             'maxbytes' => new external_value(PARAM_INT,
                                     'largest size of file that can be uploaded into the course',
                                     VALUE_OPTIONAL),
@@ -386,7 +402,7 @@ class core_course_external extends external_api {
                             'visible' => new external_value(PARAM_INT,
                                     '1: available to student, 0:not available', VALUE_OPTIONAL),
                             'hiddensections' => new external_value(PARAM_INT,
-                                    'How the hidden sections in the course are displayed to students',
+                                    '(deprecated, use courseformatoptions) How the hidden sections in the course are displayed to students',
                                     VALUE_OPTIONAL),
                             'groupmode' => new external_value(PARAM_INT, 'no group, separate, visible',
                                     VALUE_OPTIONAL),
@@ -412,6 +428,13 @@ class core_course_external extends external_api {
                                     'forced course language', VALUE_OPTIONAL),
                             'forcetheme' => new external_value(PARAM_PLUGIN,
                                     'name of the force theme', VALUE_OPTIONAL),
+                            'courseformatoptions' => new external_multiple_structure(
+                                new external_single_structure(
+                                    array('name' => new external_value(PARAM_ALPHANUMEXT, 'course format option name'),
+                                        'value' => new external_value(PARAM_RAW, 'course format option value')
+                                )),
+                                    'additional options for particular course format', VALUE_OPTIONAL
+                             ),
                         ), 'course'
                 )
         );
@@ -447,8 +470,9 @@ class core_course_external extends external_api {
                                     VALUE_DEFAULT, $courseconfig->newsitems),
                             'startdate' => new external_value(PARAM_INT,
                                     'timestamp when the course start', VALUE_OPTIONAL),
-                            'numsections' => new external_value(PARAM_INT, 'number of weeks/topics',
-                                    VALUE_DEFAULT, $courseconfig->numsections),
+                            'numsections' => new external_value(PARAM_INT,
+                                    '(deprecated, use courseformatoptions) number of weeks/topics',
+                                    VALUE_OPTIONAL),
                             'maxbytes' => new external_value(PARAM_INT,
                                     'largest size of file that can be uploaded into the course',
                                     VALUE_DEFAULT, $courseconfig->maxbytes),
@@ -458,8 +482,8 @@ class core_course_external extends external_api {
                             'visible' => new external_value(PARAM_INT,
                                     '1: available to student, 0:not available', VALUE_OPTIONAL),
                             'hiddensections' => new external_value(PARAM_INT,
-                                    'How the hidden sections in the course are displayed to students',
-                                    VALUE_DEFAULT, $courseconfig->hiddensections),
+                                    '(deprecated, use courseformatoptions) How the hidden sections in the course are displayed to students',
+                                    VALUE_OPTIONAL),
                             'groupmode' => new external_value(PARAM_INT, 'no group, separate, visible',
                                     VALUE_DEFAULT, $courseconfig->groupmode),
                             'groupmodeforce' => new external_value(PARAM_INT, '1: yes, 0: no',
@@ -480,6 +504,12 @@ class core_course_external extends external_api {
                                     'forced course language', VALUE_OPTIONAL),
                             'forcetheme' => new external_value(PARAM_PLUGIN,
                                     'name of the force theme', VALUE_OPTIONAL),
+                            'courseformatoptions' => new external_multiple_structure(
+                                new external_single_structure(
+                                    array('name' => new external_value(PARAM_ALPHANUMEXT, 'course format option name'),
+                                        'value' => new external_value(PARAM_RAW, 'course format option value')
+                                )),
+                                    'additional options for particular course format', VALUE_OPTIONAL),
                         )
                     ), 'courses to create'
                 )
@@ -562,6 +592,12 @@ class core_course_external extends external_api {
             // Summary format.
             $course['summaryformat'] = external_validate_format($course['summaryformat']);
 
+            if (!empty($course['courseformatoptions'])) {
+                foreach ($course['courseformatoptions'] as $option) {
+                    $course[$option['name']] = $option['value'];
+                }
+            }
+
             //Note: create_course() core function check shortname, idnumber, category
             $course['id'] = create_course((object) $course)->id;
 
index 516f3c5..e6141a3 100644 (file)
@@ -98,8 +98,46 @@ class format_legacy extends format_base {
             }
         }
 
-        // else, default behavior:
-        return parent::get_view_url($section, $options);
+        // if function is not defined
+        if (!$this->uses_sections() ||
+                !array_key_exists('coursedisplay', $this->course_format_options())) {
+            // default behaviour
+            return parent::get_view_url($section, $options);
+        }
+
+        $course = $this->get_course();
+        $url = new moodle_url('/course/view.php', array('id' => $course->id));
+
+        $sr = null;
+        if (array_key_exists('sr', $options)) {
+            $sr = $options['sr'];
+        }
+        if (is_object($section)) {
+            $sectionno = $section->section;
+        } else {
+            $sectionno = $section;
+        }
+        if ($sectionno !== null) {
+            if ($sr !== null) {
+                if ($sr) {
+                    $usercoursedisplay = COURSE_DISPLAY_MULTIPAGE;
+                    $sectionno = $sr;
+                } else {
+                    $usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE;
+                }
+            } else {
+                $usercoursedisplay = $course->coursedisplay;
+            }
+            if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) {
+                $url->param('section', $sectionno);
+            } else {
+                if (!empty($options['navigation'])) {
+                    return null;
+                }
+                $url->set_anchor('section-'.$sectionno);
+            }
+        }
+        return $url;
     }
 
     /**
@@ -202,4 +240,101 @@ class format_legacy extends format_base {
         }
         return parent::get_default_blocks();
     }
+
+    /**
+     * Definitions of the additional options that this course format uses for course
+     *
+     * By default course formats have the options that existed in Moodle 2.3:
+     * - coursedisplay
+     * - numsections
+     * - hiddensections
+     *
+     * @param bool $foreditform
+     * @return array of options
+     */
+    public function course_format_options($foreditform = false) {
+        static $courseformatoptions = false;
+        if ($courseformatoptions === false) {
+            $courseconfig = get_config('moodlecourse');
+            $courseformatoptions = array(
+                'numsections' => array(
+                    'default' => $courseconfig->numsections,
+                    'type' => PARAM_INT,
+                ),
+                'hiddensections' => array(
+                    'default' => $courseconfig->hiddensections,
+                    'type' => PARAM_INT,
+                ),
+                'coursedisplay' => array(
+                    'default' => $courseconfig->coursedisplay,
+                    'type' => PARAM_INT,
+                ),
+            );
+        }
+        if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
+            $courseconfig = get_config('moodlecourse');
+            $sectionmenu = array();
+            for ($i = 0; $i <= $courseconfig->maxsections; $i++) {
+                $sectionmenu[$i] = "$i";
+            }
+            $courseformatoptionsedit = array(
+                'numsections' => array(
+                    'label' => new lang_string('numberweeks'),
+                    'element_type' => 'select',
+                    'element_attributes' => array($sectionmenu),
+                ),
+                'hiddensections' => array(
+                    'label' => new lang_string('hiddensections'),
+                    'help' => 'hiddensections',
+                    'help_component' => 'moodle',
+                    'element_type' => 'select',
+                    'element_attributes' => array(
+                        array(
+                            0 => new lang_string('hiddensectionscollapsed'),
+                            1 => new lang_string('hiddensectionsinvisible')
+                        )
+                    ),
+                ),
+                'coursedisplay' => array(
+                    'label' => new lang_string('coursedisplay'),
+                    'element_type' => 'select',
+                    'element_attributes' => array(
+                        array(
+                            COURSE_DISPLAY_SINGLEPAGE => new lang_string('coursedisplay_single'),
+                            COURSE_DISPLAY_MULTIPAGE => new lang_string('coursedisplay_multi')
+                        )
+                    ),
+                    'help' => 'coursedisplay',
+                    'help_component' => 'moodle',
+                )
+            );
+            $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
+        }
+        return $courseformatoptions;
+    }
+
+    /**
+     * Updates format options for a course
+     *
+     * Legacy course formats may assume that course format options
+     * ('coursedisplay', 'numsections' and 'hiddensections') are shared between formats.
+     * Therefore we make sure to copy them from the previous format
+     *
+     * @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data
+     * @param stdClass $oldcourse if this function is called from {@link update_course()}
+     *     this object contains information about the course before update
+     * @return bool whether there were any changes to the options values
+     */
+    public function update_course_format_options($data, $oldcourse = null) {
+        if ($oldcourse !== null) {
+            $data = (array)$data;
+            $oldcourse = (array)$oldcourse;
+            foreach ($this->course_format_options() as $key => $unused) {
+                if (array_key_exists($key, $oldcourse) && !array_key_exists($key, $data)) {
+                    $data[$key] = $oldcourse[$key];
+                }
+            }
+        }
+        return $this->update_format_options($data);
+    }
 }
\ No newline at end of file
index 9496601..d0ad3d7 100644 (file)
@@ -68,6 +68,8 @@ abstract class format_base {
     protected $format;
     /** @var stdClass data for course object, please use {@link format_base::get_course()} */
     protected $course = false;
+    /** @var array caches format options, please use {@link format_base::get_format_options()} */
+    protected $formatoptions = array();
     /** @var array cached instances */
     private static $instances = array();
 
@@ -180,6 +182,7 @@ abstract class format_base {
                 foreach (self::$instances[$courseid] as $format => $object) {
                     // in case somebody keeps the reference to course format object
                     self::$instances[$courseid][$format]->course = false;
+                    self::$instances[$courseid][$format]->formatoptions = array();
                 }
                 unset(self::$instances[$courseid]);
             }
@@ -219,6 +222,16 @@ abstract class format_base {
         }
         if ($this->course === false) {
             $this->course = $DB->get_record('course', array('id' => $this->courseid));
+            $options = $this->get_format_options();
+            foreach ($options as $optionname => $optionvalue) {
+                if (!isset($this->course->$optionname)) {
+                    $this->course->$optionname = $optionvalue;
+                } else {
+                    debugging('The option name '.$optionname.' in course format '.$this->format.
+                        ' is invalid because the field with the same name exists in {course} table',
+                        DEBUG_DEVELOPER);
+                }
+            }
         }
         return $this->course;
     }
@@ -343,34 +356,19 @@ abstract class format_base {
         $course = $this->get_course();
         $url = new moodle_url('/course/view.php', array('id' => $course->id));
 
-        $sr = null;
         if (array_key_exists('sr', $options)) {
-            $sr = $options['sr'];
-        }
-        if (is_object($section)) {
+            $sectionno = $options['sr'];
+        } else if (is_object($section)) {
             $sectionno = $section->section;
         } else {
             $sectionno = $section;
         }
-        if ($sectionno !== null) {
-            if ($sr !== null) {
-                if ($sr) {
-                    $usercoursedisplay = COURSE_DISPLAY_MULTIPAGE;
-                    $sectionno = $sr;
-                } else {
-                    $usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE;
-                }
-            } else {
-                $usercoursedisplay = $course->coursedisplay;
-            }
-            if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) {
-                $url->param('section', $sectionno);
-            } else {
-                if (!empty($options['navigation'])) {
-                    return null;
-                }
-                $url->set_anchor('section-'.$sectionno);
-            }
+        if (!empty($options['navigation']) && $sectionno !== null) {
+            // by default assume that sections are never displayed on separate pages
+            return null;
+        }
+        if ($this->uses_sections() && $sectionno !== null) {
+            $url->set_anchor('section-'.$sectionno);
         }
         return $url;
     }
@@ -411,6 +409,346 @@ abstract class format_base {
         );
         return $blocknames;
     }
+
+    /**
+     * Returns the localised name of this course format plugin
+     *
+     * @return lang_string
+     */
+    public final function get_format_name() {
+        return new lang_string('pluginname', 'format_'.$this->get_format());
+    }
+
+    /**
+     * Definitions of the additional options that this course format uses for course
+     *
+     * This function may be called often, it should be as fast as possible.
+     * Avoid using get_string() method, use "new lang_string()" instead
+     * It is not recommended to use dynamic or course-dependant expressions here
+     * This function may be also called when course does not exist yet.
+     *
+     * Option names must be different from fields in the {course} talbe or any form elements on
+     * course edit form, it may even make sence to use special prefix for them.
+     *
+     * Each option must have the option name as a key and the array of properties as a value:
+     * 'default' - default value for this option (assumed null if not specified)
+     * 'type' - type of the option value (PARAM_INT, PARAM_RAW, etc.)
+     *
+     * Additional properties used by default implementation of
+     * {@link format_base::create_edit_form_elements()} (calls this method with $foreditform = true)
+     * 'label' - localised human-readable label for the edit form
+     * 'element_type' - type of the form element, default 'text'
+     * 'element_attributes' - additional attributes for the form element, these are 4th and further
+     *    arguments in the moodleform::addElement() method
+     * 'help' - string for help button. Note that if 'help' value is 'myoption' then the string with
+     *    the name 'myoption_help' must exist in the language file
+     * 'help_component' - language component to look for help string, by default this the component
+     *    for this course format
+     *
+     * This is an interface for creating simple form elements. If format plugin wants to use other
+     * methods such as disableIf, it can be done by overriding create_edit_form_elements().
+     *
+     * Course format options can be accessed as:
+     * $this->get_course()->OPTIONNAME (inside the format class)
+     * course_get_format($course)->get_course()->OPTIONNAME (outside of format class)
+     *
+     * All course options are returned by calling:
+     * $this->get_format_options();
+     *
+     * @param bool $foreditform
+     * @return array of options
+     */
+    public function course_format_options($foreditform = false) {
+        return array();
+    }
+
+    /**
+     * Definitions of the additional options that this course format uses for section
+     *
+     * See {@link format_base::course_format_options()} for return array definition.
+     *
+     * Additionally section format options may have property 'cache' set to true
+     * if this option needs to be cached in {@link get_fast_modinfo()}. The 'cache' property
+     * is recommended to be set only for fields used in {@link format_base::get_section_name()},
+     * {@link format_base::extend_course_navigation()} and {@link format_base::get_view_url()}
+     *
+     * For better performance cached options are recommended to have 'cachedefault' property
+     * Unlike 'default', 'cachedefault' should be static and not access get_config().
+     *
+     * Regardless of value of 'cache' all options are accessed in the code as
+     * $sectioninfo->OPTIONNAME
+     * where $sectioninfo is instance of section_info, returned by
+     * get_fast_modinfo($course)->get_section_info($sectionnum)
+     * or get_fast_modinfo($course)->get_section_info_all()
+     *
+     * All format options for particular section are returned by calling:
+     * $this->get_format_options($section);
+     *
+     * @param bool $foreditform
+     * @return array
+     */
+    public function section_format_options($foreditform = false) {
+        return array();
+    }
+
+    /**
+     * Returns the format options stored for this course or course section
+     *
+     * When overriding please note that this function is called from rebuild_course_cache()
+     * and section_info object, therefore using of get_fast_modinfo() and/or any function that
+     * accesses it may lead to recursion.
+     *
+     * @param null|int|stdClass|section_info $section if null the course format options will be returned
+     *     otherwise options for specified section will be returned. This can be either
+     *     section object or relative section number (field course_sections.section)
+     * @return array
+     */
+    public function get_format_options($section = null) {
+        global $DB;
+        if ($section === null) {
+            $options = $this->course_format_options();
+        } else {
+            $options = $this->section_format_options();
+        }
+        if (empty($options)) {
+            // there are no option for course/sections anyway, no need to go further
+            return array();
+        }
+        if ($section === null) {
+            // course format options will be returned
+            $sectionid = 0;
+        } else if ($this->courseid && isset($section->id)) {
+            // course section format options will be returned
+            $sectionid = $section->id;
+        } else if ($this->courseid && is_int($section) &&
+                ($sectionobj = $DB->get_record('course_sections',
+                        array('section' => $section, 'courseid' => $this->courseid), 'id'))) {
+            // course section format options will be returned
+            $sectionid = $sectionobj->id;
+        } else {
+            // non-existing (yet) section was passed as an argument
+            // default format options for course section will be returned
+            $sectionid = -1;
+        }
+        if (!array_key_exists($sectionid, $this->formatoptions)) {
+            $this->formatoptions[$sectionid] = array();
+            // first fill with default values
+            foreach ($options as $optionname => $optionparams) {
+                $this->formatoptions[$sectionid][$optionname] = null;
+                if (array_key_exists('default', $optionparams)) {
+                    $this->formatoptions[$sectionid][$optionname] = $optionparams['default'];
+                }
+            }
+            if ($this->courseid && $sectionid !== -1) {
+                // overwrite the default options values with those stored in course_format_options table
+                // nothing can be stored if we are interested in generic course ($this->courseid == 0)
+                // or generic section ($sectionid === 0)
+                $records = $DB->get_records('course_format_options',
+                        array('courseid' => $this->courseid,
+                              'format' => $this->format,
+                              'sectionid' => $sectionid
+                            ), '', 'id,name,value');
+                foreach ($records as $record) {
+                    if (array_key_exists($record->name, $this->formatoptions[$sectionid])) {
+                        $value = $record->value;
+                        if ($value !== null && isset($options[$record->name]['type'])) {
+                            // this will convert string value to number if needed
+                            $value = clean_param($value, $options[$record->name]['type']);
+                        }
+                        $this->formatoptions[$sectionid][$record->name] = $value;
+                    }
+                }
+            }
+        }
+        return $this->formatoptions[$sectionid];
+    }
+
+    /**
+     * Adds format options elements to the course/section edit form
+     *
+     * This function is called from {@link course_edit_form::definition_after_data()}
+     *
+     * @param MoodleQuickForm $mform form the elements are added to
+     * @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form
+     * @return array array of references to the added form elements
+     */
+    public function create_edit_form_elements(&$mform, $forsection = false) {
+        $elements = array();
+        if ($forsection) {
+            $options = $this->section_format_options(true);
+        } else {
+            $options = $this->course_format_options(true);
+        }
+        foreach ($options as $optionname => $option) {
+            if (!isset($option['element_type'])) {
+                $option['element_type'] = 'text';
+            }
+            $args = array($option['element_type'], $optionname, $option['label']);
+            if (!empty($option['element_attributes'])) {
+                $args = array_merge($args, $option['element_attributes']);
+            }
+            $elements[] = call_user_func_array(array($mform, 'addElement'), $args);
+            if (isset($option['help'])) {
+                $helpcomponent = 'format_'. $this->get_format();
+                if (isset($option['help_component'])) {
+                    $helpcomponent = $option['help_component'];
+                }
+                $mform->addHelpButton($optionname, $option['help'], $helpcomponent);
+            }
+            if (isset($option['type'])) {
+                $mform->setType($optionname, $option['type']);
+            }
+            if (is_null($mform->getElementValue($optionname)) && isset($option['default'])) {
+                $mform->setDefault($optionname, $option['default']);
+            }
+        }
+        return $elements;
+    }
+
+    /**
+     * Override if you need to perform some extra validation of the format options
+     *
+     * @param array $data array of ("fieldname"=>value) of submitted data
+     * @param array $files array of uploaded files "element_name"=>tmp_file_path
+     * @param array $errors errors already discovered in edit form validation
+     * @return array of "element_name"=>"error_description" if there are errors,
+     *         or an empty array if everything is OK.
+     *         Do not repeat errors from $errors param here
+     */
+    public function edit_form_validation($data, $files, $errors) {
+        return array();
+    }
+
+    /**
+     * Updates format options for a course or section
+     *
+     * If $data does not contain property with the option name, the option will not be updated
+     *
+     * @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data
+     * @param null|int null if these are options for course or section id (course_sections.id)
+     *     if these are options for section
+     * @return bool whether there were any changes to the options values
+     */
+    protected function update_format_options($data, $sectionid = null) {
+        global $DB;
+        if (!$sectionid) {
+            $allformatoptions = $this->course_format_options();
+            $sectionid = 0;
+        } else {
+            $allformatoptions = $this->section_format_options();
+        }
+        if (empty($allformatoptions)) {
+            // nothing to update anyway
+            return false;
+        }
+        $defaultoptions = array();
+        $cached = array();
+        foreach ($allformatoptions as $key => $option) {
+            $defaultoptions[$key] = null;
+            if (array_key_exists('default', $option)) {
+                $defaultoptions[$key] = $option['default'];
+            }
+            $cached[$key] = ($sectionid === 0 || !empty($option['cache']));
+        }
+        $records = $DB->get_records('course_format_options',
+                array('courseid' => $this->courseid,
+                      'format' => $this->format,
+                      'sectionid' => $sectionid
+                    ), '', 'name,id,value');
+        $changed = $needrebuild = false;
+        $data = (array)$data;
+        foreach ($defaultoptions as $key => $value) {
+            if (isset($records[$key])) {
+                if (array_key_exists($key, $data) && $records[$key]->value !== $data[$key]) {
+                    $DB->set_field('course_format_options', 'value',
+                            $data[$key], array('id' => $records[$key]->id));
+                    $changed = true;
+                    $needrebuild = $needrebuild || $cached[$key];
+                }
+            } else {
+                if (array_key_exists($key, $data) && $data[$key] !== $value) {
+                    $newvalue = $data[$key];
+                    $changed = true;
+                    $needrebuild = $needrebuild || $cached[$key];
+                } else {
+                    $newvalue = $value;
+                    // we still insert entry in DB but there are no changes from user point of
+                    // view and no need to call rebuild_course_cache()
+                }
+                $DB->insert_record('course_format_options', array(
+                    'courseid' => $this->courseid,
+                    'format' => $this->format,
+                    'sectionid' => $sectionid,
+                    'name' => $key,
+                    'value' => $newvalue
+                ));
+            }
+        }
+        if ($needrebuild) {
+            rebuild_course_cache($this->courseid, true);
+        }
+        if ($changed) {
+            // reset internal caches
+            if (!$sectionid) {
+                $this->course = false;
+            }
+            unset($this->formatoptions[$sectionid]);
+        }
+        return $changed;
+    }
+
+    /**
+     * Updates format options for a course
+     *
+     * If $data does not contain property with the option name, the option will not be updated
+     *
+     * @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data
+     * @param stdClass $oldcourse if this function is called from {@link update_course()}
+     *     this object contains information about the course before update
+     * @return bool whether there were any changes to the options values
+     */
+    public function update_course_format_options($data, $oldcourse = null) {
+        return $this->update_format_options($data);
+    }
+
+    /**
+     * Updates format options for a section
+     *
+     * Section id is expected in $data->id (or $data['id'])
+     * If $data does not contain property with the option name, the option will not be updated
+     *
+     * @param stdClass|array $data return value from {@link moodleform::get_data()} or array with data
+     * @return bool whether there were any changes to the options values
+     */
+    public function update_section_format_options($data) {
+        $data = (array)$data;
+        return $this->update_format_options($data, $data['id']);
+    }
+
+    /**
+     * Return an instance of moodleform to edit a specified section
+     *
+     * Default implementation returns instance of editsection_form that automatically adds
+     * additional fields defined in {@link format_base::section_format_options()}
+     *
+     * Format plugins may extend editsection_form if they want to have custom edit section form.
+     *
+     * @param mixed $action the action attribute for the form. If empty defaults to auto detect the
+     *              current url. If a moodle_url object then outputs params as hidden variables.
+     * @param array $customdata the array with custom data to be passed to the form
+     *     /course/editsection.php passes section_info object in 'cs' field
+     *     for filling availability fields
+     * @return moodleform
+     */
+    public function editsection_form($action, $customdata = array()) {
+        global $CFG;
+        require_once($CFG->dirroot. '/course/editsection_form.php');
+        $context = context_course::instance($this->courseid);
+        if (!array_key_exists('course', $customdata)) {
+            $customdata['course'] = $this->get_course();
+        }
+        return new editsection_form($action, $customdata);
+    }
 }
 
 /**
@@ -443,5 +781,33 @@ class format_site extends format_base {
     public function get_view_url($section, $options = array()) {
         return new moodle_url('/');
     }
-}
 
+    /**
+     * Returns the list of blocks to be automatically added on the site frontpage when moodle is installed
+     *
+     * @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT
+     *     each of values is an array of block names (for left and right side columns)
+     */
+    public function get_default_blocks() {
+        return blocks_get_default_site_course_blocks();
+    }
+
+    /**
+     * Definitions of the additional options that site uses
+     *
+     * @param bool $foreditform
+     * @return array of options
+     */
+    public function course_format_options($foreditform = false) {
+        static $courseformatoptions = false;
+        if ($courseformatoptions === false) {
+            $courseformatoptions = array(
+                'numsections' => array(
+                    'default' => 1,
+                    'type' => PARAM_INT,
+                ),
+            );
+        }
+        return $courseformatoptions;
+    }
+}
index 26f28c2..ea83ace 100644 (file)
@@ -448,6 +448,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
      */
     protected function get_nav_links($course, $sections, $sectionno) {
         // FIXME: This is really evil and should by using the navigation API.
+        $course = course_get_format($course)->get_course();
         $canviewhidden = has_capability('moodle/course:viewhiddensections', context_course::instance($course->id))
             or !$course->hiddensections;
 
@@ -542,6 +543,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
         global $PAGE;
 
         $modinfo = get_fast_modinfo($course);
+        $course = course_get_format($course)->get_course();
 
         // Can we view the section in question?
         if (!($sectioninfo = $modinfo->get_section_info($displaysection))) {
@@ -637,6 +639,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
         global $PAGE;
 
         $modinfo = get_fast_modinfo($course);
+        $course = course_get_format($course)->get_course();
 
         $context = context_course::instance($course->id);
         // Title with completion help icon.
index 5108a86..cf2c052 100644 (file)
@@ -45,6 +45,7 @@ if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context)
 }
 
 // make sure all sections are created
+$course = course_get_format($course)->get_course();
 course_create_sections_if_missing($course, range(0, $course->numsections));
 
 $renderer = $PAGE->get_renderer('format_topics');
index 5342d30..7f0426e 100644 (file)
@@ -2,5 +2,5 @@
 .course-content ul.topics li.section {list-style: none;margin:5px 0 0 0;padding:0;}
 .course-content ul.topics li.section .content {margin:0 40px;}
 .course-content ul.topics li.section .left {width:40px;float:left;text-align:center;}
-.course-content ul.topics li.section .right {width:40px;float:right;text-align:center;}
+.course-content ul.topics li.section .right {width:40px;float:right;text-align:center;padding-top: 4px;}
 .jumpmenu {text-align:center;}
\ No newline at end of file
index 86fac1e..2f98855 100644 (file)
@@ -38,6 +38,7 @@ if ($week = optional_param('week', 0, PARAM_INT)) {
 // End backwards-compatible aliasing..
 
 // make sure all sections are created
+$course = course_get_format($course)->get_course();
 course_create_sections_if_missing($course, range(0, $course->numsections));
 
 $renderer = $PAGE->get_renderer('format_weeks');
index a4c802a..fc87f3c 100644 (file)
@@ -2,5 +2,5 @@
 .course-content ul.weeks li.section {list-style: none;margin:5px 0 0 0;padding:0;}
 .course-content ul.weeks li.section .content {margin:0 40px;}
 .course-content ul.weeks li.section .left {width:40px;float:left;text-align:center;}
-.course-content ul.weeks li.section .right {width:40px;float:right;text-align:center;}
+.course-content ul.weeks li.section .right {width:40px;float:right;text-align:center;padding-top: 4px;}
 .jumpmenu {text-align:center;}
\ No newline at end of file
index 0227f97..7549889 100644 (file)
@@ -2765,7 +2765,7 @@ function course_add_cm_to_section($courseorid, $modid, $sectionnum, $beforemod =
     course_create_sections_if_missing($courseorid, $sectionnum);
     $section = get_fast_modinfo($courseorid)->get_section_info($sectionnum);
     $modarray = explode(",", trim($section->sequence));
-    if (empty($modarray)) {
+    if (empty($section->sequence)) {
         $newsequence = "$modid";
     } else if ($beforemod && ($key = array_keys($modarray, $beforemod))) {
         $insertarray = array($modid, $beforemod);
@@ -2939,7 +2939,10 @@ function move_section($course, $section, $move) {
 
     $sectiondest = $section + $move;
 
-    if ($sectiondest > $course->numsections or $sectiondest < 1) {
+    // compartibility with course formats using field 'numsections'
+    $courseformatoptions = course_get_format($course)->get_format_options();
+    if (array_key_exists('numsections', $courseformatoptions) &&
+            $sectiondest > $courseformatoptions['numsections'] or $sectiondest < 1) {
         return false;
     }
 
@@ -2965,7 +2968,10 @@ function move_section_to($course, $section, $destination) {
         return true;
     }
 
-    if (($destination > $course->numsections) || ($destination < 1)) {
+    // compartibility with course formats using field 'numsections'
+    $courseformatoptions = course_get_format($course)->get_format_options();
+    if ((array_key_exists('numsections', $courseformatoptions) &&
+            ($destination > $courseformatoptions['numsections'])) || ($destination < 1)) {
         return false;
     }
 
@@ -3775,7 +3781,10 @@ function create_course($data, $editoroptions = NULL) {
         $DB->set_field('course', 'summaryformat', $data->summary_format, array('id'=>$newcourseid));
     }
 
-    $course = $DB->get_record('course', array('id'=>$newcourseid));
+    // update course format options
+    course_get_format($newcourseid)->update_course_format_options($data);
+
+    $course = course_get_format($newcourseid)->get_course();
 
     // Setup the blocks
     blocks_add_default_course_blocks($course);
@@ -3843,7 +3852,7 @@ function update_course($data, $editoroptions = NULL) {
 
     $data->timemodified = time();
 
-    $oldcourse = $DB->get_record('course', array('id'=>$data->id), '*', MUST_EXIST);
+    $oldcourse = course_get_format($data->id)->get_course();
     $context   = context_course::instance($oldcourse->id);
 
     if ($editoroptions) {
@@ -3879,6 +3888,9 @@ function update_course($data, $editoroptions = NULL) {
     // make sure the modinfo cache is reset
     rebuild_course_cache($data->id);
 
+    // update course format options with full course data
+    course_get_format($data->id)->update_course_format_options($data, $oldcourse);
+
     $course = $DB->get_record('course', array('id'=>$data->id));
 
     if ($movecat) {
@@ -3901,6 +3913,14 @@ function update_course($data, $editoroptions = NULL) {
 
     // Trigger events
     events_trigger('course_updated', $course);
+
+    if ($oldcourse->format !== $course->format) {
+        // Remove all options stored for the previous format
+        // We assume that new course format migrated everything it needed watching trigger
+        // 'course_updated' and in method format_XXX::update_course_format_options()
+        $DB->delete_records('course_format_options',
+                array('courseid' => $course->id, 'format' => $oldcourse->format));
+    }
 }
 
 /**
@@ -4218,8 +4238,6 @@ class course_request {
 
         // Apply course default settings
         $data->format             = $courseconfig->format;
-        $data->numsections        = $courseconfig->numsections;
-        $data->hiddensections     = $courseconfig->hiddensections;
         $data->newsitems          = $courseconfig->newsitems;
         $data->showgrades         = $courseconfig->showgrades;
         $data->showreports        = $courseconfig->showreports;
index 984b9ed..82cba69 100644 (file)
@@ -339,6 +339,17 @@ class core_course_external_testcase extends externallib_advanced_testcase {
         $course2['completionnotify'] = 1;
         $course2['lang'] = 'en';
         $course2['forcetheme'] = 'base';
+        $course3['fullname'] = 'Test course 3';
+        $course3['shortname'] = 'Testcourse3';
+        $course3['categoryid'] = $category->id;
+        $course3['format'] = 'topics';
+        $course3options = array('numsections' => 8,
+            'hiddensections' => 1,
+            'coursedisplay' => 1);
+        $course3['courseformatoptions'] = array();
+        foreach ($course3options as $key => $value) {
+            $course3['courseformatoptions'][] = array('name' => $key, 'value' => $value);
+        }
         $courses = array($course1, $course2);
 
         $createdcourses = core_course_external::create_courses($courses);
@@ -348,58 +359,64 @@ class core_course_external_testcase extends externallib_advanced_testcase {
 
         // Check that the courses were correctly created.
         foreach ($createdcourses as $createdcourse) {
-            $dbcourse = $DB->get_record('course', array('id' => $createdcourse['id']));
+            $courseinfo = course_get_format($createdcourse['id'])->get_course();
 
             if ($createdcourse['shortname'] == $course2['shortname']) {
-                $this->assertEquals($dbcourse->fullname, $course2['fullname']);
-                $this->assertEquals($dbcourse->shortname, $course2['shortname']);
-                $this->assertEquals($dbcourse->category, $course2['categoryid']);
-                $this->assertEquals($dbcourse->idnumber, $course2['idnumber']);
-                $this->assertEquals($dbcourse->summary, $course2['summary']);
-                $this->assertEquals($dbcourse->summaryformat, $course2['summaryformat']);
-                $this->assertEquals($dbcourse->format, $course2['format']);
-                $this->assertEquals($dbcourse->showgrades, $course2['showgrades']);
-                $this->assertEquals($dbcourse->newsitems, $course2['newsitems']);
-                $this->assertEquals($dbcourse->startdate, $course2['startdate']);
-                $this->assertEquals($dbcourse->numsections, $course2['numsections']);
-                $this->assertEquals($dbcourse->maxbytes, $course2['maxbytes']);
-                $this->assertEquals($dbcourse->showreports, $course2['showreports']);
-                $this->assertEquals($dbcourse->visible, $course2['visible']);
-                $this->assertEquals($dbcourse->hiddensections, $course2['hiddensections']);
-                $this->assertEquals($dbcourse->groupmode, $course2['groupmode']);
-                $this->assertEquals($dbcourse->groupmodeforce, $course2['groupmodeforce']);
-                $this->assertEquals($dbcourse->defaultgroupingid, $course2['defaultgroupingid']);
-                $this->assertEquals($dbcourse->completionnotify, $course2['completionnotify']);
-                $this->assertEquals($dbcourse->lang, $course2['lang']);
+                $this->assertEquals($courseinfo->fullname, $course2['fullname']);
+                $this->assertEquals($courseinfo->shortname, $course2['shortname']);
+                $this->assertEquals($courseinfo->category, $course2['categoryid']);
+                $this->assertEquals($courseinfo->idnumber, $course2['idnumber']);
+                $this->assertEquals($courseinfo->summary, $course2['summary']);
+                $this->assertEquals($courseinfo->summaryformat, $course2['summaryformat']);
+                $this->assertEquals($courseinfo->format, $course2['format']);
+                $this->assertEquals($courseinfo->showgrades, $course2['showgrades']);
+                $this->assertEquals($courseinfo->newsitems, $course2['newsitems']);
+                $this->assertEquals($courseinfo->startdate, $course2['startdate']);
+                $this->assertEquals($courseinfo->numsections, $course2['numsections']);
+                $this->assertEquals($courseinfo->maxbytes, $course2['maxbytes']);
+