]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from MOODLE_19_STABLE:
authormjollnir_ <mjollnir_>
Tue, 15 Jan 2008 04:20:12 +0000 (04:20 +0000)
committermjollnir_ <mjollnir_>
Tue, 15 Jan 2008 04:20:12 +0000 (04:20 +0000)
MDL-13000 Adding support for developers to add their own capabilities to local/db/access.php
This relies on a local/ language pack as well for the capability names.
Notes on implementation are in lib/locallib.php

lang/en_utf8/moodle.php
lib/accesslib.php
lib/locallib.php

index 918bea3f83ca2f9c879fd156f5d140ff323b2f90..c193a6183c456d232a6e5c2a2ec17522a76db412 100644 (file)
@@ -830,6 +830,7 @@ $string['list'] = 'List';
 $string['listfiles'] = 'List of files in $a';
 $string['listofallpeople'] = 'List of all people';
 $string['livelogs'] = 'Live logs from the past hour';
+$string['local'] = 'Local';
 $string['locale'] = 'en_AU.UTF-8';
 $string['location'] = 'Location';
 $string['log_excel_date_format'] = 'yyyy mmmm d h:mm';
index 3de14bee8c4e5f86f08ae2d72fbf5f7b3cded0d6..7dec6b4c039d768ddfa43c55f64caa504fefc6b2 100755 (executable)
@@ -3146,6 +3146,9 @@ function get_cached_capabilities($component='moodle') {
     if ($component == 'moodle') {
         $storedcaps = get_records_select('capabilities',
                         "name LIKE 'moodle/%:%'");
+    } else if ($component == 'local') {
+        $storedcaps = get_records_select('capabilities', 
+                        "name LIKE 'moodle/local:%'");
     } else {
         $storedcaps = get_records_select('capabilities',
                         "name LIKE '$component:%'");
@@ -3792,7 +3795,11 @@ function get_capability_string($capabilityname) {
         break;
 
         case 'moodle':
-            $string = get_string($stringname, 'role');
+            if ($componentname == 'local') {
+                $string = get_string($stringname, 'local');
+            } else {
+                $string = get_string($stringname, 'role');
+            }
         break;
 
         case 'enrol':
@@ -3840,6 +3847,9 @@ function get_component_string($component, $contextlevel) {
             } else if (preg_match('|^block/|', $component)) {
                 $langname = str_replace('/', '_', $component);
                 $string = get_string('blockname', $langname);
+            } else if (preg_match('|^local|', $component)) {
+                $langname = str_replace('/', '_', $component);
+                $string = get_string('local');
             } else {
                 $string = get_string('coresystem');
             }
index a1db1ed24e16d43ae71001b9db37e20284862590..f300072a9b12f065d02ca8bb6c468983840946a8 100644 (file)
  * when your moodle instance is first installed, xmldb_local_upgrade() will be called
  * with $oldversion set to 0, so that all the updates run.
  *
+ * Local capabilities
+ * ------------------
+ *
+ * If your local customisations require their own capabilities, use
+ * 
+ * local/db/access.php
+ *
+ * You should create an array called $local_capabilities, which looks like:
+ * 
+ * $local_capabilities = array(
+ *         'moodle/local:capability' => array(
+ *         'captype' => 'read',
+ *         'contextlevel' => CONTEXT_SYSTEM,
+ *      ),
+ * );
+ *
+ * Note that for all local capabilities you add, you'll need to add language strings.
+ * Moodle will expect to find them in local/lang/en_utf8/local.php (eg for English)
+ * with a key (following the above example) of local:capability
+ * See the next section for local language support.
+ *
  *
  * Local language support
  * ----------------------