### Eclipse Workspace Patch 1.0
#P moodle
Index: lib/accesslib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/accesslib.php,v
retrieving revision 1.34
diff -u -r1.34 accesslib.php
--- lib/accesslib.php	31 Aug 2006 05:06:30 -0000	1.34
+++ lib/accesslib.php	31 Aug 2006 08:02:04 -0000
@@ -1189,19 +1189,30 @@
  * @return boolean
  */
 function update_capabilities($component='moodle') {
-    
     $storedcaps = array();
-    $filecaps = array();
-    
+
+    $filecaps = load_capability_def($component);
     $cachedcaps = get_cached_capabilities($component);
     if ($cachedcaps) {
         foreach ($cachedcaps as $cachedcap) {
             array_push($storedcaps, $cachedcap->name);
+            // update risk bitmasks in existing capabilitites if needed
+            if (array_key_exists($cachedcap->name, $filecaps)) {
+                if (!array_key_exists('riskbitmask', $filecaps[$cachedcap->name])) {
+                    $filecaps[$cachedcap->name]['riskbitmask'] = 0; // no risk by default
+                }
+                if ($cachedcap->riskbitmask != $filecaps[$cachedcap->name]['riskbitmask']) {
+                    $updatecap = new object;
+                    $updatecap->id = $cachedcap->id;
+                    $updatecap->riskbitmask = $filecaps[$cachedcap->name]['riskbitmask'];
+                    if (!update_record('capabilities', $updatecap)) {
+                        return false;
+                    }
+                }
+            }
         }
     }
-    
-    $filecaps = load_capability_def($component);
-    
+
     // Are there new capabilities in the file definition?
     $newcaps = array();
     
@@ -1218,6 +1229,7 @@
         $capability->captype = $capdef['captype'];
         $capability->contextlevel = $capdef['contextlevel'];
         $capability->component = $component;
+        $capability->riskbitmask = $capdef['riskbitmask'];
         
         if (!insert_record('capabilities', $capability, false, 'id')) {
             return false;
@@ -1859,4 +1871,4 @@
     return get_records_sql($select.$from.$where);  
 
 }
-?>
+?>
\ No newline at end of file
Index: lib/db/install.xml
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/install.xml,v
retrieving revision 1.12
diff -u -r1.12 install.xml
--- lib/db/install.xml	30 Aug 2006 17:17:39 -0000	1.12
+++ lib/db/install.xml	31 Aug 2006 08:02:08 -0000
@@ -583,7 +583,8 @@
         <FIELD NAME="ajax" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="htmleditor" NEXT="autosubscribe"/>
         <FIELD NAME="autosubscribe" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="ajax" NEXT="trackforums"/>
         <FIELD NAME="trackforums" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="autosubscribe" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="trackforums"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="trackforums" NEXT="trustbitmask"/>
+        <FIELD NAME="trustbitmask" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Default comment for the field, please edit me" PREVIOUS="timemodified"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for user"/>
@@ -915,7 +916,8 @@
         <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="captype"/>
         <FIELD NAME="captype" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="contextlevel"/>
         <FIELD NAME="contextlevel" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="captype" NEXT="component"/>
-        <FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="contextlevel"/>
+        <FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="contextlevel" NEXT="riskbitmask"/>
+        <FIELD NAME="riskbitmask" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Default comment for the field, please edit me" PREVIOUS="component"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for capabilities" NEXT="name"/>
Index: lib/db/postgres7.sql
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/postgres7.sql,v
retrieving revision 1.144
diff -u -r1.144 postgres7.sql
--- lib/db/postgres7.sql	29 Aug 2006 22:45:54 -0000	1.144
+++ lib/db/postgres7.sql	31 Aug 2006 08:02:17 -0000
@@ -750,6 +750,7 @@
   captype varchar(50) NOT NULL default '',   
   contextlevel integer NOT NULL default 0,   
   component varchar(100) NOT NULL default ''     
+  riskbitmask integer NOT NULL default 0,   
 );         
 CREATE UNIQUE INDEX prefix_capabilities_name_idx ON prefix_capabilities (name);
 
Index: lib/db/postgres7.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/postgres7.php,v
retrieving revision 1.207
diff -u -r1.207 postgres7.php
--- lib/db/postgres7.php	30 Aug 2006 16:37:52 -0000	1.207
+++ lib/db/postgres7.php	31 Aug 2006 08:02:17 -0000
@@ -1759,6 +1759,10 @@
         execute_sql("
             CREATE INDEX {$CFG->prefix}sess_exp2_ix ON {$CFG->prefix}sessions2 (expireref);", true);
     }
+    
+    if ($oldversion < 2006083002) {
+        table_column('capabilities', '', 'riskbitmask', 'INTEGER', '10', 'unsigned', '0', 'not null', '');
+    }
 
     return $result;
 }
Index: lib/db/mysql.sql
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/mysql.sql,v
retrieving revision 1.170
diff -u -r1.170 mysql.sql
--- lib/db/mysql.sql	30 Aug 2006 16:37:52 -0000	1.170
+++ lib/db/mysql.sql	31 Aug 2006 08:02:14 -0000
@@ -985,6 +985,7 @@
   `captype` varchar(50) NOT NULL default '', 
   `contextlevel` int(10) unsigned NOT NULL default '0', 
   `component` varchar(100) NOT NULL default '', 
+  `riskbitmask` int(10) unsigned NOT NULL default '0', 
   UNIQUE KEY `name` (`name`),
   PRIMARY KEY (`id`) 
 ) TYPE=MYISAM COMMENT ='this defines all capabilities';
Index: lib/db/mysql.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/db/mysql.php,v
retrieving revision 1.226
diff -u -r1.226 mysql.php
--- lib/db/mysql.php	30 Aug 2006 16:37:52 -0000	1.226
+++ lib/db/mysql.php	31 Aug 2006 08:02:13 -0000
@@ -2165,6 +2165,10 @@
         table_column('sessions2', 'sessdata', 'sessdata', 'LONGTEXT', '', '', '', '', '');
     }
     
+    if ($oldversion < 2006083002) {
+        table_column('capabilities', '', 'riskbitmask', 'INTEGER', '10', 'unsigned', '0', 'not null', '');
+    }
+
     return $result;
 }
 
Index: version.php
===================================================================
RCS file: /cvsroot/moodle/moodle/version.php,v
retrieving revision 1.368
diff -u -r1.368 version.php
--- version.php	30 Aug 2006 16:37:52 -0000	1.368
+++ version.php	31 Aug 2006 08:02:03 -0000
@@ -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 = 2006083001;  // YYYYMMDD = date
+   $version = 2006083003;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.7 dev';    // Human-friendly version name
