MDL-15262 Added 3 new capabilities without changing defaults, as suggested by Matt...
authornicolasconnault <nicolasconnault>
Wed, 8 Oct 2008 13:23:35 +0000 (13:23 +0000)
committernicolasconnault <nicolasconnault>
Wed, 8 Oct 2008 13:23:35 +0000 (13:23 +0000)
course/edit_form.php
lang/en_utf8/role.php
lib/db/access.php
version.php

index ff8c39a7d657e2b5134369ca224f90d87b1186cf..3275c12519b1c8e2089d86b5a4c3bcccf8883f2f 100644 (file)
@@ -75,16 +75,6 @@ class course_edit_form extends moodleform {
         $mform->setDefault('category', $courseconfig->category);
         $mform->setType('category', PARAM_INT);
 
-        $mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"');
-        $mform->setHelpButton('fullname', array('coursefullname', get_string('fullnamecourse')), true);
-        $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
-        $mform->setType('fullname', PARAM_MULTILANG);
-
-        $mform->addElement('text','shortname', get_string('shortnamecourse'),'maxlength="100" size="20"');
-        $mform->setHelpButton('shortname', array('courseshortname', get_string('shortnamecourse')), true);
-        $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
-        $mform->setType('shortname', PARAM_MULTILANG);
-
         $fullname  = get_string('defaultcoursefullname');
         $shortname = get_string('defaultcourseshortname');
         while ($DB->record_exists('course', array('fullname'=>$fullname))
@@ -92,13 +82,28 @@ class course_edit_form extends moodleform {
             $fullname++;
             $shortname++;
         }
-        $mform->setDefault('fullname', $fullname);
-        $mform->setDefault('shortname', $shortname);
 
+        if (has_capability('moodle/course:changefullname', $coursecontext)) {
+            $mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"');
+            $mform->setHelpButton('fullname', array('coursefullname', get_string('fullnamecourse')), true);
+            $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
+            $mform->setType('fullname', PARAM_MULTILANG);
+            $mform->setDefault('fullname', $fullname);
+        }
 
-        $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100"  size="10"');
-        $mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
-        $mform->setType('idnumber', PARAM_RAW);
+        if (has_capability('moodle/course:changeshortname', $coursecontext)) {
+            $mform->addElement('text','shortname', get_string('shortnamecourse'),'maxlength="100" size="20"');
+            $mform->setHelpButton('shortname', array('courseshortname', get_string('shortnamecourse')), true);
+            $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
+            $mform->setType('shortname', PARAM_MULTILANG);
+            $mform->setDefault('shortname', $shortname);
+        }
+
+        if (has_capability('moodle/course:changeidnumber', $coursecontext)) {
+            $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100"  size="10"');
+            $mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
+            $mform->setType('idnumber', PARAM_RAW);
+        }
 
         $mform->addElement('htmleditor','summary', get_string('summary'), array('rows'=> '10', 'cols'=>'65'));
         $mform->setHelpButton('summary', array('text2', get_string('helptext')), true);
@@ -321,7 +326,7 @@ class course_edit_form extends moodleform {
         $mform->addElement('select', 'guest', get_string('opentoguests'), $choices);
         $mform->setHelpButton('guest', array('guestaccess', get_string('opentoguests')), true);
         $mform->setDefault('guest', $courseconfig->guest);
-        
+
         // If we are creating a course, its enrol method isn't yet chosen, BUT the site has a default enrol method which we can use here
         $enrol_object = $CFG;
         if (!empty($course)) {
@@ -359,7 +364,7 @@ class course_edit_form extends moodleform {
         require_once($CFG->libdir.'/completionlib.php');
         if(completion_info::is_enabled_for_site()) {
             $mform->addElement('header','', get_string('progress','completion'));
-            $mform->addElement('select', 'enablecompletion', get_string('completion','completion'), 
+            $mform->addElement('select', 'enablecompletion', get_string('completion','completion'),
                 array(0=>get_string('completiondisabled','completion'), 1=>get_string('completionenabled','completion')));
             $mform->setDefault('enablecompletion', $courseconfig->enablecompletion);
         } else {
@@ -403,8 +408,8 @@ class course_edit_form extends moodleform {
                 $mform->addElement('text', 'role_'.$role->id, $role->name);
                 if ($coursecontext) {
                     if ($rolename = $DB->get_record('role_names', array('roleid'=>$role->id, 'contextid'=>$coursecontext->id))) {
-                        $mform->setDefault('role_'.$role->id, $rolename->name); 
-                    }  
+                        $mform->setDefault('role_'.$role->id, $rolename->name);
+                    }
                 }
             }
         }
@@ -439,7 +444,7 @@ class course_edit_form extends moodleform {
             $gr_el->load($options);
         }
     }
-        
+
 
 /// perform some extra moodle validation
     function validation($data, $files) {
index 5bf339a5f915b3092bd901cbc1be83d2a780cfbf..930ab1f4a35f54d76e55a54944852e86d52f8e95 100644 (file)
@@ -28,6 +28,9 @@ $string['category:visibility'] = 'See hidden categories';
 $string['context'] = 'Context';
 $string['course:activityvisibility'] = 'Hide/show activities';
 $string['course:bulkmessaging'] = 'Send a message to many people';
+$string['course:changefullname'] = 'Change course full name';
+$string['course:changeshortname'] = 'Change course short name';
+$string['course:changeidnumber'] = 'Change course ID number';
 $string['course:create'] = 'Create courses';
 $string['course:delete'] = 'Delete courses';
 $string['course:manageactivities'] = 'Manage activities';
index 5a9ccfc415a48590db9bb0ef80cb7e401b345425..afda0b4b77e87231772397aa3b43bf288167cada 100644 (file)
@@ -120,7 +120,7 @@ $moodle_capabilities = array(
             'editingteacher' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:sendmessage' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -131,7 +131,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW,
             'user' => CAP_ALLOW
         )
-    ),   
+    ),
 
     'moodle/site:approvecourse' => array(
 
@@ -669,7 +669,38 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
+    'moodle/course:changefullname' => array(
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_COURSE,
+        'legacy' => array(
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+    'moodle/course:changeshortname' => array(
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_COURSE,
+        'legacy' => array(
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+    'moodle/course:changeidnumber' => array(
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_COURSE,
+        'legacy' => array(
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+
     'moodle/site:viewparticipants' => array(
 
         'captype' => 'read',
@@ -874,25 +905,25 @@ $moodle_capabilities = array(
 
     //capabilities designed for the new message system configuration
     'moodle/user:editmessageprofile' => array(
+
          'riskbitmask' => RISK_SPAM,
+
          'captype' => 'write',
          'contextlevel' => CONTEXT_USER,
          'legacy' => array(
              'admin' => CAP_ALLOW
          )
      ),
-     'moodle/user:editownmessageprofile' => array(      
-         'captype' => 'write',     
-         'contextlevel' => CONTEXT_SYSTEM,      
-         'legacy' => array(   
+
+     'moodle/user:editownmessageprofile' => array(
+
+         'captype' => 'write',
+         'contextlevel' => CONTEXT_SYSTEM,
+         'legacy' => array(
              'guest' => CAP_PROHIBIT,
              'user' => CAP_ALLOW,
              'admin' => CAP_ALLOW
-         )    
+         )
      ),
 
     'moodle/question:managecategory' => array(
index ec1481fe99f3bbe11d654aac267b93e2e178d78a..eb1c078c0ccb4f2603ede56f2a50c90a45b7549a 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 = 2008092400;  // YYYYMMDD   = date of the last version bump
+    $version = 2008100800;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20081008)';  // Human-friendly version name