]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20273 updated web services and functions description tables , includes indexes...
authorskodak <skodak>
Sun, 13 Sep 2009 19:09:16 +0000 (19:09 +0000)
committerskodak <skodak>
Sun, 13 Sep 2009 19:09:16 +0000 (19:09 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index e5d4b8767bae8c8ec1d6abc695ceeccac4ded18a..dda0aaa082a43a937ce46f98c7775e385c2ad314 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20090911" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20090913" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="external_functions" COMMENT="external functions" PREVIOUS="comments" NEXT="external_services">
+    <TABLE NAME="external_functions" COMMENT="list of all external functions" PREVIOUS="comments" NEXT="external_services">
       <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="component"/>
-        <FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="150" NOTNULL="true" SEQUENCE="false" PREVIOUS="component" NEXT="phpfile"/>
-        <FIELD NAME="phpfile" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="name" NEXT="contextrestriction"/>
-        <FIELD NAME="contextrestriction" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="phpfile"/>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="200" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="classname"/>
+        <FIELD NAME="classname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="methodname"/>
+        <FIELD NAME="methodname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="classname" NEXT="classpath"/>
+        <FIELD NAME="classpath" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="methodname" NEXT="component"/>
+        <FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="classpath"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
+      <INDEXES>
+        <INDEX NAME="name" UNIQUE="true" FIELDS="name" COMMENT="the external function names must be globally unique"/>
+      </INDEXES>
     </TABLE>
-    <TABLE NAME="external_services" COMMENT="external services" PREVIOUS="external_functions" NEXT="external_services_functions">
+    <TABLE NAME="external_services" COMMENT="built in and custom external services" PREVIOUS="external_functions" NEXT="external_services_functions">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
-        <FIELD NAME="name" TYPE="char" LENGTH="150" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="enabled"/>
-        <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="name" NEXT="custom"/>
-        <FIELD NAME="custom" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="enabled" NEXT="customname"/>
-        <FIELD NAME="customname" TYPE="char" LENGTH="150" NOTNULL="false" SEQUENCE="false" PREVIOUS="custom"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="200" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="enabled"/>
+        <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="name" NEXT="requiredcapability"/>
+        <FIELD NAME="requiredcapability" TYPE="char" LENGTH="150" NOTNULL="false" SEQUENCE="false" PREVIOUS="enabled" NEXT="restrictedusers"/>
+        <FIELD NAME="restrictedusers" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="requiredcapability" NEXT="component"/>
+        <FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" PREVIOUS="restrictedusers"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
     </TABLE>
-    <TABLE NAME="external_services_functions" COMMENT="association between external functions and external services" PREVIOUS="external_services">
+    <TABLE NAME="external_services_functions" COMMENT="lists functions available in each service group" PREVIOUS="external_services" NEXT="external_services_users">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="externalserviceid"/>
-        <FIELD NAME="externalserviceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="externalfunctionid"/>
-        <FIELD NAME="externalfunctionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="externalserviceid" NEXT="enabled"/>
-        <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="externalfunctionid"/>
+        <FIELD NAME="externalserviceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="functionname"/>
+        <FIELD NAME="functionname" TYPE="char" LENGTH="200" NOTNULL="true" SEQUENCE="false" PREVIOUS="externalserviceid"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="externalserviceid"/>
+        <KEY NAME="externalserviceid" TYPE="foreign" FIELDS="externalserviceid" REFTABLE="external_services" REFFIELDS="id" PREVIOUS="primary"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="external_services_users" COMMENT="users allowed to use services with restrictedusers flag" PREVIOUS="external_services_functions">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="externalserviceid"/>
+        <FIELD NAME="externalserviceid" 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="externalserviceid"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="externalserviceid"/>
+        <KEY NAME="externalserviceid" TYPE="foreign" FIELDS="externalserviceid" REFTABLE="external_services" REFFIELDS="id" PREVIOUS="primary" NEXT="userid"/>
+        <KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" PREVIOUS="externalserviceid"/>
       </KEYS>
     </TABLE>
   </TABLES>
index 58fecf4c2231625a2d88c249b9e82059e9b25383..b72731a2508d1f46df6f7acc89aad61f74d50216 100644 (file)
@@ -2555,93 +2555,104 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         upgrade_main_savepoint($result, 2009090800);
     }
 
-    if ($result && $oldversion < 2009090803) {
-
-    /// Define table external_functions to be dropped
-        $table = new xmldb_table('external_functions');
-
-    /// Conditionally launch drop table for external_functions
-        if ($dbman->table_exists($table)) {
-            $dbman->drop_table($table);
-        }
-
-    
-
-    /// Define table external_services to be dropped
-        $table = new xmldb_table('external_services');
-
-    /// Conditionally launch drop table for external_services
-        if ($dbman->table_exists($table)) {
-            $dbman->drop_table($table);
-        }
-  
-
-    /// Define table external_services_functions to be dropped
-        $table = new xmldb_table('external_services_functions');
-
-    /// Conditionally launch drop table for external_services_functions
-        if ($dbman->table_exists($table)) {
-            $dbman->drop_table($table);
+    if ($result && $oldversion < 2009091300) {
+        // drop all previous tables defined during the dev phase
+        $dropold = array('external_services_functions', 'external_services', 'external_functions');
+        foreach ($dropold as $tablename) {
+            $table = new xmldb_table($tablename);
+            if ($dbman->table_exists($table)) {
+                $dbman->drop_table($table);
+            }
         }
-   
+        upgrade_main_savepoint($result, 2009091300);
+    }
 
+    if ($result && $oldversion < 2009091301) {
     /// Define table external_functions to be created
         $table = new xmldb_table('external_functions');
 
     /// Adding fields to table external_functions
         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table->add_field('name', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('classname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('methodname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('classpath', XMLDB_TYPE_CHAR, '255', null, null, null, null);
         $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
-        $table->add_field('name', XMLDB_TYPE_CHAR, '150', null, XMLDB_NOTNULL, null, null);
-        $table->add_field('phpfile', XMLDB_TYPE_CHAR, '255', null, null, null, null);
-        $table->add_field('contextrestriction', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null);
 
     /// Adding keys to table external_functions
         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
 
-    /// Conditionally launch create table for external_functions
-        if (!$dbman->table_exists($table)) {
-            $dbman->create_table($table);
-        }
+    /// Adding indexes to table external_functions
+        $table->add_index('name', XMLDB_INDEX_UNIQUE, array('name'));
+
+    /// Launch create table for external_functions
+        $dbman->create_table($table);
 
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009091301);
+    }
 
+    if ($result && $oldversion < 2009091302) {
     /// Define table external_services to be created
         $table = new xmldb_table('external_services');
 
     /// Adding fields to table external_services
         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
-        $table->add_field('name', XMLDB_TYPE_CHAR, '150', null, XMLDB_NOTNULL, null, null);
-        $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
-        $table->add_field('custom', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
-        $table->add_field('customname', XMLDB_TYPE_CHAR, '150', null, null, null, null);
+        $table->add_field('name', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
+        $table->add_field('requiredcapability', XMLDB_TYPE_CHAR, '150', null, null, null, null);
+        $table->add_field('restrictedusers', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
+        $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, null, null, null);
 
     /// Adding keys to table external_services
         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
 
-    /// Conditionally launch create table for external_services
-        if (!$dbman->table_exists($table)) {
-            $dbman->create_table($table);
-        }
+    /// Launch create table for external_services
+        $dbman->create_table($table);
 
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009091302);
+    }
 
+    if ($result && $oldversion < 2009091303) {
     /// Define table external_services_functions to be created
         $table = new xmldb_table('external_services_functions');
 
     /// Adding fields to table external_services_functions
         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
         $table->add_field('externalserviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
-        $table->add_field('externalfunctionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
-        $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null);
+        $table->add_field('functionname', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null);
 
     /// Adding keys to table external_services_functions
         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->add_key('externalserviceid', XMLDB_KEY_FOREIGN, array('externalserviceid'), 'external_services', array('id'));
 
-    /// Conditionally launch create table for external_services_functions
-        if (!$dbman->table_exists($table)) {
-            $dbman->create_table($table);
-        }
+    /// Launch create table for external_services_functions
+        $dbman->create_table($table);
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2009091303);
+    }
+
+    if ($result && $oldversion < 2009091304) {
+    /// Define table external_services_users to be created
+        $table = new xmldb_table('external_services_users');
+
+    /// Adding fields to table external_services_users
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table->add_field('externalserviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
+        $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
+
+    /// Adding keys to table external_services_users
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+        $table->add_key('externalserviceid', XMLDB_KEY_FOREIGN, array('externalserviceid'), 'external_services', array('id'));
+        $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
+
+    /// Launch create table for external_services_users
+        $dbman->create_table($table);
 
     /// Main savepoint reached
-        upgrade_main_savepoint($result, 2009090803);
+        upgrade_main_savepoint($result, 2009091304);
     }
 
     return $result;
index 2e01e0dfcfc70120dc9efb06dc851250ad6a5e31..0688bd00d09d1a3fe4d144d2d362240ef64cd01a 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2009090803;  // YYYYMMDD   = date of the last version bump
+    $version = 2009091305;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20090913)';  // Human-friendly version name