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;
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;
/// 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;
$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);
}
}
+/**
+ * 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
/// 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());
$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);
$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
// 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
// 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');
}
$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);
$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));
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');
$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',
$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));
$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);
}
}
+ 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');
// 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());
}
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
-
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
-
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
* 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
*/
$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}';
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)
--- /dev/null
+<?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'
+ ),
+);
<?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';
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
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
$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)';
$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 ';
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
--- /dev/null
+<?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'
+ ),
+);
*/
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
<?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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
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');
}
--- /dev/null
+<?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'
+ ),
+);
* @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';
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
$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',
)
)
);
-
-
*/
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
* @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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
+
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)
--- /dev/null
+<?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'
+ ),
+);
$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:';
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)
--- /dev/null
+<?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'
+ ),
+);
*/
$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';
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)
$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',
$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.';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
}
$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') {
}
$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;
}
}
$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;
}
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
*/
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
*/
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
--- /dev/null
+<?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'
+ ),
+);
$string['pluginname'] = 'Youtube';
$string['scienceandtech'] = 'Science & 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 & Places';
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)
--- /dev/null
+<?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'
+ ),
+);
$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';
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)
$definitions = array(
'string' => array( // Required, unique to the component
'mode' => cache_store::MODE_APPLICATION, // Required
+ 'simpledata' => false, // Optional
'requireidentifiers' => array( // Optional
'lang'
),
* 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.
$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();
$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();
* [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
*/
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
$area = (string)$definition['area'];
// Set the defaults.
+ $simpledata = false;
$requireidentifiers = array();
$requiredataguarantee = false;
$requiremultipleidentifiers = false;
$mappingsonly = false;
$invalidationevents = array();
+ if (array_key_exists('simpledata', $definition)) {
+ $simpledata = (bool)$definition['simpledata'];
+ }
if (array_key_exists('requireidentifiers', $definition)) {
$requireidentifiers = (array)$definition['requireidentifiers'];
}
$cachedefinition->mode = $mode;
$cachedefinition->component = $component;
$cachedefinition->area = $area;
+ $cachedefinition->simpledata = $simpledata;
$cachedefinition->requireidentifiers = $requireidentifiers;
$cachedefinition->requiredataguarantee = $requiredataguarantee;
$cachedefinition->requiremultipleidentifiers = $requiremultipleidentifiers;
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
* @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.
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.
*
// Paddding (the first week may have blank days in the beginning)
for($i = $display->minwday; $i < $startwday; ++$i) {
$cell = new html_table_cell(' ');
- $cell->attributes = array('class'=>'nottoday');
+ $cell->attributes = array('class'=>'nottoday dayblank');
$row->cells[] = $cell;
}
}
// 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));
// Paddding (the last week may have blank days at the end)
for($i = $dayweek; $i <= $display->maxwday; ++$i) {
$cell = new html_table_cell(' ');
- $cell->attributes = array('class'=>'nottoday');
+ $cell->attributes = array('class'=>'nottoday dayblank');
$row->cells[] = $cell;
}
$table->data[] = $row;
$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));
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);
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);
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'];
$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');
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
}
+//--------------------------------------------------------------------------------
+ $mform->addElement('hidden', 'addcourseformatoptionshere');
+
//--------------------------------------------------------------------------------
enrol_course_edit_form($mform, $course, $context);
$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) {
$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;
}
}
// 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");
}
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() {
$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');
}
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();
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;
+ }
}
// 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) {
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);
$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;
$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
'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),
'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),
'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'
)
);
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),
'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',
'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'
)
// 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;
}
}
- // 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;
}
/**
}
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
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();
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]);
}
}
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;
}
$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;
}
);
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);
+ }
}
/**
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;
+ }
+}
*/
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;
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))) {
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.
}
// 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');
.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
// 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');
.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
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);
$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;
}
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;
}
$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);
$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) {
// 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) {
// 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));
+ }
}
/**
// 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;
$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);
// 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']);
+