Revision: 540
Author: geof.glass
Date: Wed May 30 15:29:42 2012
Log: Forgot to update db directory to match Marginalia M 2.0 beta 3
Also including patch from Mawuli:
1. blocks/marginalia/lang/en/block_marginalia.php
Defined some language strings
2. blocks/marginalia/db/upgrade.php
Fixed the SQL to make it work with Postgres DB and any DB
3. blocks/marginalia/help.php
Fix the4 first line of the file. Needs to be <?php and not <?.
Missing the 'php'
http://code.google.com/p/marginalia/source/detail?r=540
Modified:
/moodle/trunk/moodle/blocks/marginalia/db/install.xml
/moodle/trunk/moodle/blocks/marginalia/db/upgrade.php
/moodle/trunk/moodle/blocks/marginalia/help.php
/moodle/trunk/moodle/blocks/marginalia/lang/en/block_marginalia.php
=======================================
--- /moodle/trunk/moodle/blocks/marginalia/db/install.xml Wed May 30
14:29:48 2012
+++ /moodle/trunk/moodle/blocks/marginalia/db/install.xml Wed May 30
15:29:42 2012
@@ -1,36 +1,40 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="blocks/marginalia/db" VERSION="20071010" COMMENT="XMLDB file
for Marginalia annotation for Moodle"
+<XMLDB PATH="blocks/marginalia/db" VERSION="20100211" COMMENT="XMLDB file
for Marginalia annotation for Moodle"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
- <TABLE NAME="marginalia" COMMENT="All annotations are stored here">
+ <TABLE NAME="marginalia" COMMENT="All annotations are stored here"
NEXT="marginalia_read">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="userid"/>
- <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id"
NEXT="access_perms"/>
- <FIELD NAME="access_perms" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid"
NEXT="url"/>
- <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true"
SEQUENCE="false" ENUM="false" PREVIOUS="access_perms" NEXT="start_block"/>
- <FIELD NAME="start_block" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="start_xpath"/>
- <FIELD NAME="start_xpath" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="start_block" NEXT="start_line"/>
- <FIELD NAME="start_line" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="start_xpath" NEXT="start_word"/>
- <FIELD NAME="start_word" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="start_line" NEXT="start_char"/>
- <FIELD NAME="start_char" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="start_word" NEXT="end_block"/>
- <FIELD NAME="end_block" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="start_char" NEXT="end_xpath"/>
- <FIELD NAME="end_xpath" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="end_block" NEXT="end_line"/>
- <FIELD NAME="end_line" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="end_xpath" NEXT="end_word"/>
- <FIELD NAME="end_word" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="end_line" NEXT="end_char"/>
- <FIELD NAME="end_char" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="end_word" NEXT="note"/>
- <FIELD NAME="note" TYPE="text" LENGTH="small" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="end_char" NEXT="quote"/>
- <FIELD NAME="quote" TYPE="text" LENGTH="small" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="note" NEXT="quote_title"/>
- <FIELD NAME="quote_title" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="quote" NEXT="quote_author_id"/>
- <FIELD NAME="quote_author_id" TYPE="int" LENGTH="10"
NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="quote_title" NEXT="action"/>
- <FIELD NAME="action" TYPE="char" LENGTH="30" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="quote_author_id" NEXT="link"/>
- <FIELD NAME="link" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="action" NEXT="link_title"/>
- <FIELD NAME="link_title" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" ENUM="false" PREVIOUS="link" NEXT="created"/>
- <FIELD NAME="created" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="link_title" NEXT="modified"/>
- <FIELD NAME="modified" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="created" NEXT="object_type"/>
- <FIELD NAME="object_type" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="modified" NEXT="object_id"/>
- <FIELD NAME="object_id" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false"
PREVIOUS="object_type"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="true" NEXT="course"/>
+ <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="false" NEXT="userid" PREVIOUS="id"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="course"
NEXT="sheet_type"/>
+ <FIELD NAME="sheet_type" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="url"/>
+ <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true"
SEQUENCE="false" PREVIOUS="sheet_type" NEXT="start_block"/>
+
+ <FIELD NAME="start_block" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" PREVIOUS="url" NEXT="start_xpath"/>
+ <FIELD NAME="start_xpath" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" PREVIOUS="start_block" NEXT="start_line"/>
+ <FIELD NAME="start_line" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="start_xpath"
NEXT="start_word"/>
+ <FIELD NAME="start_word" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="start_line"
NEXT="start_char"/>
+ <FIELD NAME="start_char" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="start_word"
NEXT="end_block"/>
+ <FIELD NAME="end_block" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" PREVIOUS="start_char" NEXT="end_xpath"/>
+ <FIELD NAME="end_xpath" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" PREVIOUS="end_block" NEXT="end_line"/>
+ <FIELD NAME="end_line" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="end_xpath"
NEXT="end_word"/>
+ <FIELD NAME="end_word" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="end_line"
NEXT="end_char"/>
+
+ <FIELD NAME="end_char" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="end_word"
NEXT="note"/>
+ <FIELD NAME="note" TYPE="text" LENGTH="small" NOTNULL="false"
SEQUENCE="false" PREVIOUS="end_char" NEXT="quote"/>
+ <FIELD NAME="quote" TYPE="text" LENGTH="small" NOTNULL="false"
SEQUENCE="false" PREVIOUS="note" NEXT="quote_title"/>
+ <FIELD NAME="quote_title" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" PREVIOUS="quote" NEXT="quote_author_id"/>
+ <FIELD NAME="quote_author_id" TYPE="int" LENGTH="10"
NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false"
PREVIOUS="quote_title" NEXT="action"/>
+ <FIELD NAME="action" TYPE="char" LENGTH="30" NOTNULL="false"
SEQUENCE="false" PREVIOUS="quote_author_id" NEXT="link"/>
+ <FIELD NAME="link" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" PREVIOUS="action" NEXT="link_title"/>
+ <FIELD NAME="link_title" TYPE="char" LENGTH="255" NOTNULL="false"
SEQUENCE="false" PREVIOUS="link" NEXT="created"/>
+ <FIELD NAME="created" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="link_title"
NEXT="modified"/>
+
+ <FIELD NAME="modified" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="created"
NEXT="object_type"/>
+ <FIELD NAME="object_type" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="modified"
NEXT="object_id"/>
+ <FIELD NAME="object_id" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="object_type"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
@@ -39,5 +43,20 @@
<INDEX NAME="object" UNIQUE="false" FIELDS="object_type,
object_id"/>
</INDEXES>
</TABLE>
+ <TABLE NAME="marginalia_read" COMMENT="Tracks when a user last read a
given annotation." PREVIOUS="marginalia">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="true" NEXT="annotationid"/>
+ <FIELD NAME="annotationid" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="userid"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="false" PREVIOUS="annotationid" NEXT="firstread"/>
+ <FIELD NAME="firstread" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="false" PREVIOUS="userid" NEXT="lastread"/>
+ <FIELD NAME="lastread" TYPE="int" LENGTH="10" NOTNULL="true"
UNSIGNED="true" SEQUENCE="false" PREVIOUS="firstread"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+ </KEYS>
+ <INDEXES>
+ <INDEX NAME="lastread" UNIQUE="true" FIELDS="annotationid,
userid"/>
+ </INDEXES>
+ </TABLE>
</TABLES>
</XMLDB>
=======================================
--- /moodle/trunk/moodle/blocks/marginalia/db/upgrade.php Wed May 30
14:29:48 2012
+++ /moodle/trunk/moodle/blocks/marginalia/db/upgrade.php Wed May 30
15:29:42 2012
@@ -1,9 +1,37 @@
<?php
+/*
+ * blocks/marginalia/upgrade.php
+ *
+ * Marginalia has been developed with funding and support from
+ * BC Campus, Simon Fraser University, and the Government of
+ * Canada, the UNDESA Africa i-Parliaments Action Plan, and
+ * units and individuals within those organizations. Many
+ * thanks to all of them. See CREDITS.html for details.
+ * Copyright (C) 2005-2011 Geoffrey Glass; the United Nations
+ *
http://www.geof.net/code/annotation
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
+ *
+ * $Id$
+ */
+
global $CFG;
require_once( $CFG->dirroot.'/blocks/marginalia/config.php' );
-require_once( ANNOTATION_DIR.'/annotation_globals.php' );
+require_once( ANNOTATION_DIR.'/lib.php' );
require_once( ANNOTATION_DIR.'/marginalia-php/Annotation.php' );
require_once( ANNOTATION_DIR.'/marginalia-php/MarginaliaHelper.php' );
require_once( ANNOTATION_DIR.'/marginalia-php/SequenceRange.php' );
@@ -11,119 +39,190 @@
function xmldb_block_marginalia_upgrade( $oldversion )
{
- global $CFG;
-
- $result = true;
-
- if ( $result && $oldversion < 2008121000 ) {
+ global $CFG, $DB;
+
+ $dbman = $DB->get_manager( );
+
+ if ( $oldversion < 2008121000 ) {
/// Define table annotation to be created
- $table = new XMLDBTable('marginalia');
-
- /// Adding fields to table annotation
- $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
- // $table->addFieldInfo('userid', XMLDB_TYPE_CHAR, '255', null,
XMLDB_NOTNULL, null, null, null, null);
- $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, null, null, '0');
- // $table->addFieldInfo('access', XMLDB_TYPE_CHAR, '32', null, null,
null, null, null, null);
- $table->addFieldInfo('access_perms', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('url', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL,
null, null, null, null);
- $table->addFieldInfo('start_block', XMLDB_TYPE_CHAR, '255', null, null,
null, null, null, null);
- $table->addFieldInfo('start_xpath', XMLDB_TYPE_CHAR, '255', null, null,
null, null, null, null);
- $table->addFieldInfo('start_line', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('start_word', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('start_char', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('end_block', XMLDB_TYPE_CHAR, '255', null, null,
null, null, null, null);
- $table->addFieldInfo('end_xpath', XMLDB_TYPE_CHAR, '255', null, null,
null, null, null, null);
- $table->addFieldInfo('end_line', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('end_word', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('end_char', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('note', XMLDB_TYPE_TEXT, 'small', null, null, null,
null, null, null);
- $table->addFieldInfo('quote', XMLDB_TYPE_TEXT, 'small', null, null,
null, null, null, null);
- $table->addFieldInfo('quote_title', XMLDB_TYPE_CHAR, '255', null, null,
null, null, null, null);
- // $table->addFieldInfo('quote_author', XMLDB_TYPE_CHAR, '255', null,
null, null, null, null, null);
- $table->addFieldInfo('quote_author_id', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('action', XMLDB_TYPE_CHAR, '30', null, null, null,
null, null, null);
- $table->addFieldInfo('link', XMLDB_TYPE_CHAR, '255', null, null, null,
null, null, null);
- $table->addFieldInfo('link_title', XMLDB_TYPE_CHAR, '255', null, null,
null, null, null, null);
- $table->addFieldInfo('created', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('modified', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('object_type', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
- $table->addFieldInfo('object_id', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-
- /// Adding keys to table annotation
- $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-
- /// Adding indexes to table annotation
- $table->addIndexInfo('object', XMLDB_INDEX_NOTUNIQUE,
array('object_type', 'object_id'));
-
- /// Launch create table for annotation
- $result = $result && create_table($table);
+ $table = new xmldb_table('marginalia');
+
+ /// Adding fields to table marginalia
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('access_perms', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_field('url', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL,
null, null);
+ $table->add_field('start_block', XMLDB_TYPE_CHAR, '255', null, null,
null, null);
+ $table->add_field('start_xpath', XMLDB_TYPE_CHAR, '255', null, null,
null, null);
+ $table->add_field('start_line', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_field('start_word', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_field('start_char', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_field('end_block', XMLDB_TYPE_CHAR, '255', null, null, null,
null);
+ $table->add_field('end_xpath', XMLDB_TYPE_CHAR, '255', null, null, null,
null);
+ $table->add_field('end_line', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('end_word', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('end_char', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('note', XMLDB_TYPE_TEXT, 'small', null, null, null,
null);
+ $table->add_field('quote', XMLDB_TYPE_TEXT, 'small', null, null, null,
null);
+ $table->add_field('quote_title', XMLDB_TYPE_CHAR, '255', null, null,
null, null);
+ $table->add_field('quote_author_id', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_field('action', XMLDB_TYPE_CHAR, '30', null, null, null,
null);
+ $table->add_field('link', XMLDB_TYPE_CHAR, '255', null, null, null,
null);
+ $table->add_field('link_title', XMLDB_TYPE_CHAR, '255', null, null,
null, null);
+ $table->add_field('created', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('modified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('object_type', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_field('object_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+
+ /// Adding keys to table marginalia
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+
+ /// Adding indexes to table marginalia
+ $table->add_index('object', XMLDB_INDEX_NOTUNIQUE,
array('object_type', 'object_id'));
+
+ /// Launch create table for marginalia
+ $dbman->create_table($table);
// Check for old annotation table and convert its data over
if ( $result ) {
$query = "SELECT a.*,
u.id AS uid,
qa.id as aid "
- ." FROM {$CFG->prefix}annotation a"
- ." JOIN {$CFG->prefix}user u ON u.username=a.userid"
- ." LEFT JOIN {$CFG->prefix}user qa ON qa.username=a.quote_author";
- $data = get_records_sql( $query );
- if ( $data ) {
- foreach ( $data as $r ) {
+ ." FROM {annotation} a"
+ ." JOIN {user} u ON u.username=a.userid"
+ ." LEFT JOIN {user} qa ON qa.username=a.quote_author";
+ $data = $DB->get_recordset_sql( $query );
+ foreach ( $data as $r ) {
/* // This method and the range classes are clever enough to handle
- // ranges in the old format.
- if ( array_key_exists( 'start_block', $r ) && $r->start_block !==
null ) {
- $r->start_block = preg_replace( '/^\//', '', $r->start_block );
- $r->start_block = preg_replace( '/\//', '\.', $r->start_block );
- }
- if ( array_key_exists( 'end_block', $r ) && $r->end_block !== null )
{
- $r->end_block = preg_replace( '/^\//', '', $r->end_block );
- $r->end_block = preg_replace( '/\//', '\.', $r->end_block );
- }
+ // ranges in the old format.
+ if ( array_key_exists( 'start_block', $r ) && $r->start_block !== null
) {
+ $r->start_block = preg_replace( '/^\//', '', $r->start_block );
+ $r->start_block = preg_replace( '/\//', '\.', $r->start_block );
+ }
+ if ( array_key_exists( 'end_block', $r ) && $r->end_block !== null ) {
+ $r->end_block = preg_replace( '/^\//', '', $r->end_block );
+ $r->end_block = preg_replace( '/\//', '\.', $r->end_block );
+ }
*/
- $r->username = $r->userid;
- $r->userid = 0;
- $r->quote_author_username = $r->quote_author;
-
- $annotation = annotation_globals::record_to_annotation( $r );
-
- // Will handle 'public' or 'private'
- if ( array_key_exists( 'access', $r) )
- $annotation->setAccess( $r->access );
-
- // Fix backslashes (\' and \") in annotation and note
- if ( AN_DBFIXBACKSLASHES )
- {
- $quote = $annotation->getQuote( );
- $quote = preg_replace( '/\\\\\'/', "'", $quote );
- $quote = preg_replace( '/\\\\"/', '"', $quote );
- $annotation->setQuote( $quote );
-
- $note = $annotation->getNote( );
- $note = preg_replace( '/\\\\\'/', "'", $note );
- $note = preg_replace( '/\\\\"/', '"', $note );
- $annotation->setNote( $note );
- }
-
- $record = annotation_globals::annotation_to_record( $annotation );
-
- // Make sure start_line and end_line are not null
- if ( ! array_key_exists( 'start_line', $r ) )
- $record->start_line = 0;
- if ( ! array_key_exists( 'end_line', $r ) )
- $record->end_line = 0;
-
- $record->userid = $r->uid;
- $record->quote_author_id = $r->aid;
- $record->object_type = AN_OTYPE_POST;
- $record->object_id = $r->object_id;
-
- $x = insert_record( AN_DBTABLE, $record, true );
- $result = $result && 0 != $x;
- }
- }
- }
+ $r->username = $r->userid;
+ $r->userid = 0;
+ $r->quote_author_username = $r->quote_author;
+
+ $annotation = annotation_globals::record_to_annotation( $r );
+
+ // Will handle 'public' or 'private'
+ if ( array_key_exists( 'access', $r) )
+ $annotation->setAccess( $r->access );
+
+ // Fix backslashes (\' and \") in annotation and note
+ if ( AN_DBFIXBACKSLASHES )
+ {
+ $quote = $annotation->getQuote( );
+ $quote = preg_replace( '/\\\\\'/', "'", $quote );
+ $quote = preg_replace( '/\\\\"/', '"', $quote );
+ $annotation->setQuote( $quote );
+
+ $note = $annotation->getNote( );
+ $note = preg_replace( '/\\\\\'/', "'", $note );
+ $note = preg_replace( '/\\\\"/', '"', $note );
+ $annotation->setNote( $note );
+ }
+
+ $record = annotation_globals::annotation_to_record( $annotation );
+
+ // Make sure start_line and end_line are not null
+ if ( ! array_key_exists( 'start_line', $r ) )
+ $record->start_line = 0;
+ if ( ! array_key_exists( 'end_line', $r ) )
+ $record->end_line = 0;
+
+ $record->userid = $r->uid;
+ $record->quote_author_id = $r->aid;
+ $record->object_type = AN_OTYPE_POST;
+ $record->object_id = $r->object_id;
+
+ $DB->insert_record( AN_DBTABLE, $record, true );
+ }
+ $data->close( );
+ }
+ upgrade_mod_savepoint(true, 2008121000, 'marginalia');
// Should perhaps delete old annotation table?
}
+
+ if ( $oldversion < 2010012800 ) {
+ $table = new xmldb_table( 'marginalia' );
+
+ /* ---- course ---- */
+ // Give in to Moodle's architecture and associate each annotation with a
course
+ // (I don't like that Moodle is course-centric: I think it should be
user-centric instead.
+ // I see annotations as belonging to the people who create them, not the
things they
+ // annotate or the courses they were created in. A student over the
course of his or her
+ // career accumulates knowledge and content, synthesizing it into new
knowledge and practice.
+ // In contrast, a course-oriented system is rooted in administrative
structure.)
+ $field = new xmldb_field( 'course', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id' );
+ if (!$dbman->field_exists($table,$field)) {
+ $dbman->add_field( $table, $field );
+ }
+ /*
+ $query = "UPDATE {marginalia} a, {forum_posts} p, {forum_discussions} d"
+ ." SET a.course=d.course"
+ ." WHERE a.object_id=
p.id AND
d.id=p.discussion";
+ */
+ $query = "UPDATE {marginalia}
+ SET course =
+ (SELECT d.course
+ FROM {forum_posts} p,
{forum_discussions} d
+ WHERE
d.id=p.discussion
+ AND {marginalia}.object_id=
p.id
+ )
+ WHERE EXISTS (SELECT
fd.id
+ FROM {forum_posts} fp,
{forum_discussions} fd
+ WHERE
fd.id=fp.discussion
+ AND {marginalia}.object_id=
fp.id
+ )";
+ $DB->execute( $query );
+
+ // Cannot have entries where cousrse = 0
+ $deletequery = "DELETE FROM {marginalia} WHERE course=0";
+ $DB->execute($deletequery);
+
+ /* ---- sheet_type ---- */
+ // Replace access_perms with sheet_type
+ // private used to have access bits 0x0; now has access 0x1
+ $field = new xmldb_field( 'access_perms', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ if ($dbman->field_exists($table, $field)) {
+ $dbman->rename_field( $table, $field, 'sheet_type');
+ }
+ $query = "UPDATE {marginalia} SET sheet_type=1 WHERE sheet_type=0";
+ $result = $DB->execute( $query );
+
+ /* ---- marginalia_read.* ---- */
+ /// Define marginalia_read table, which tracks which annotations have
been read by which users
+ $table = new xmldb_table('marginalia_read');
+
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('annotationid', XMLDB_TYPE_INTEGER, '10',
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('firstread', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+ $table->add_field('lastread', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, '0');
+
+ /// Adding keys to table marginalia_read
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+
+ /// Adding indexes to table marginalia_read
+ $table->add_index('object', XMLDB_INDEX_UNIQUE,
array('annotationid', 'userid'));
+
+ if (!$dbman->table_exists($table)) {
+ $dbman->create_table( $table );
+ }
+
+ /* ---- user_preferences.* ---- */
+ // Delete obsolete preferences
+ $DB->delete_records('user_preferences', array( 'name'
=> 'annotations.user'));
+ $DB->delete_records('user_preferences', array( 'name'
=> 'smartcopy'));
+
+ upgrade_block_savepoint(true, 2010121800, 'marginalia' );
+ }
return $result;
}
=======================================
--- /moodle/trunk/moodle/blocks/marginalia/help.php Wed May 30 15:12:10 2012
+++ /moodle/trunk/moodle/blocks/marginalia/help.php Wed May 30 15:29:42 2012
@@ -1,4 +1,4 @@
-<?
+<?php
/**
* Load up a help page.
=======================================
--- /moodle/trunk/moodle/blocks/marginalia/lang/en/block_marginalia.php Wed
May 30 15:12:10 2012
+++ /moodle/trunk/moodle/blocks/marginalia/lang/en/block_marginalia.php Wed
May 30 15:29:42 2012
@@ -125,3 +125,5 @@
$string['js_quote_not_found'] = 'The highlighted passage could not be
found';
$string['js_create_overlapping_edits'] = 'You may not create overlapping
edits';
+$string['marginalia:view_all'] = 'View all';
+$string['marginalia:fix_notes'] = 'Fix notes';