Browse Source

db/upgrade.php and db/access.php fixes

MOODLE_23_STABLE
Artem Andreev 14 years ago
parent
commit
4bead3d0b0
  1. 18
      db/access.php
  2. 21
      db/upgrade.php

18
db/access.php

@ -31,13 +31,13 @@
// For the core capabilities, the variable is $moodle_capabilities. // For the core capabilities, the variable is $moodle_capabilities.
$mod_attforblock_capabilities = array( $capabilities = array(
'mod/attforblock:view' => array( 'mod/attforblock:view' => array(
'captype' => 'read', 'captype' => 'read',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'student' => CAP_ALLOW, 'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW, 'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW 'editingteacher' => CAP_ALLOW
@ -50,7 +50,7 @@ $mod_attforblock_capabilities = array(
'captype' => 'read', 'captype' => 'read',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'teacher' => CAP_ALLOW, 'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW 'editingteacher' => CAP_ALLOW
) )
@ -62,7 +62,7 @@ $mod_attforblock_capabilities = array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'teacher' => CAP_ALLOW, 'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW 'editingteacher' => CAP_ALLOW
) )
@ -74,7 +74,7 @@ $mod_attforblock_capabilities = array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'teacher' => CAP_ALLOW, 'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW 'editingteacher' => CAP_ALLOW
) )
@ -86,7 +86,7 @@ $mod_attforblock_capabilities = array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'editingteacher' => CAP_ALLOW 'editingteacher' => CAP_ALLOW
) )
), ),
@ -97,7 +97,7 @@ $mod_attforblock_capabilities = array(
'captype' => 'write', 'captype' => 'write',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'editingteacher' => CAP_ALLOW 'editingteacher' => CAP_ALLOW
) )
), ),
@ -108,7 +108,7 @@ $mod_attforblock_capabilities = array(
'captype' => 'read', 'captype' => 'read',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'editingteacher' => CAP_ALLOW 'editingteacher' => CAP_ALLOW
) )
), ),
@ -120,7 +120,7 @@ $mod_attforblock_capabilities = array(
'captype' => 'read', 'captype' => 'read',
'contextlevel' => CONTEXT_MODULE, 'contextlevel' => CONTEXT_MODULE,
'legacy' => array( 'archetypes' => array(
'student' => CAP_ALLOW 'student' => CAP_ALLOW
) )
) )

21
db/upgrade.php

@ -228,11 +228,16 @@ function xmldb_attforblock_upgrade($oldversion=0) {
$field = new xmldb_field('groupid'); $field = new xmldb_field('groupid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid'); $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field); $dbman->add_field($table, $field);
}
$index = new xmldb_index('groupid'); $index = new xmldb_index('groupid');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('groupid')); $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('groupid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index); $dbman->add_index($table, $index);
}
upgrade_mod_savepoint(true, 2010070900, 'attforblock'); upgrade_mod_savepoint(true, 2010070900, 'attforblock');
} }
@ -242,26 +247,36 @@ function xmldb_attforblock_upgrade($oldversion=0) {
$field = new xmldb_field('attendanceid'); $field = new xmldb_field('attendanceid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupid'); $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field); $dbman->add_field($table, $field);
}
$index = new xmldb_table('attendanceid'); $index = new xmldb_index('attendanceid');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index); $dbman->add_index($table, $index);
}
$sql = "UPDATE {attendance_sessions} AS ses,{attforblock} AS att SET ses.attendanceid=att.id WHERE att.course=ses.courseid"; $sql = "UPDATE {attendance_sessions} AS ses,{attforblock} AS att SET ses.attendanceid=att.id WHERE att.course=ses.courseid";
$dbman->execute($sql); $DB->execute($sql);
$table = new xmldb_table('attendance_statuses'); $table = new xmldb_table('attendance_statuses');
$field = new xmldb_field('attendanceid'); $field = new xmldb_field('attendanceid');
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid'); $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field); $dbman->add_field($table, $field);
}
$index = new xmldb_index('attendanceid'); $index = new xmldb_index('attendanceid');
$index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index); $dbman->add_index($table, $index);
}
$sql = "UPDATE {attendance_statuses} AS sta,{attforblock} AS att SET sta.attendanceid=att.id WHERE att.course=sta.courseid"; $sql = "UPDATE {attendance_statuses} AS sta,{attforblock} AS att SET sta.attendanceid=att.id WHERE att.course=sta.courseid";
execute($sql); $DB->execute($sql);
upgrade_mod_savepoint(true, 2010123003, 'attforblock');
} }
return $result; return $result;
} }

Loading…
Cancel
Save