[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/settings/ -> courses.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * This file defines settingpages and externalpages under the "courses" category
  19   *
  20   * @package core
  21   * @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com)
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  $capabilities = array(
  26      'moodle/backup:backupcourse',
  27      'moodle/category:manage',
  28      'moodle/course:create',
  29      'moodle/site:approvecourse',
  30      'moodle/restore:restorecourse'
  31  );
  32  if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
  33      // Speedup for non-admins, add all caps used on this page.
  34      $ADMIN->add('courses',
  35          new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'),
  36              $CFG->wwwroot . '/course/management.php',
  37              array('moodle/category:manage', 'moodle/course:create')
  38          )
  39      );
  40      $ADMIN->add('courses',
  41          new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
  42              new moodle_url('/course/editcategory.php', array('parent' => 0)),
  43              array('moodle/category:manage')
  44          )
  45      );
  46      $ADMIN->add('courses',
  47          new admin_externalpage('restorecourse', new lang_string('restorecourse', 'admin'),
  48              new moodle_url('/backup/restorefile.php', array('contextid' => context_system::instance()->id)),
  49              array('moodle/restore:restorecourse')
  50          )
  51      );
  52  
  53      // Course Default Settings Page.
  54      // NOTE: these settings must be applied after all other settings because they depend on them.
  55  
  56      // Main course settings.
  57      $temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
  58      require_once($CFG->dirroot.'/course/lib.php');
  59  
  60      $choices = array();
  61      $choices['0'] = new lang_string('hide');
  62      $choices['1'] = new lang_string('show');
  63      $temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
  64          1, $choices));
  65  
  66      // Course format.
  67      $temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
  68  
  69      $courseformats = get_sorted_course_formats(true);
  70      $formcourseformats = array();
  71      foreach ($courseformats as $courseformat) {
  72          $formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
  73      }
  74      $temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'),
  75          'topics', $formcourseformats));
  76  
  77      $temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'),
  78          new lang_string('maxnumberweeks_desc'), 52));
  79  
  80      $temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'),
  81          new lang_string('coursehelpnumberweeks'), 4));
  82  
  83      $choices = array();
  84      $choices['0'] = new lang_string('hiddensectionscollapsed');
  85      $choices['1'] = new lang_string('hiddensectionsinvisible');
  86      $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'),
  87          new lang_string('coursehelphiddensections'), 0, $choices));
  88  
  89      $choices = array();
  90      $choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
  91      $choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
  92      $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
  93          new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
  94  
  95      // Appearance.
  96      $temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
  97  
  98      $languages = array();
  99      $languages[''] = new lang_string('forceno');
 100      $languages += get_string_manager()->get_list_of_translations();
 101      $temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '', key($languages),
 102          $languages));
 103  
 104      $options = range(0, 10);
 105      $temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'),
 106          new lang_string('coursehelpnewsitemsnumber'), 5, $options));
 107      $temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'),
 108          new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 109      $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
 110          array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 111  
 112      // Files and uploads.
 113      $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
 114  
 115      if (!empty($CFG->legacyfilesinnewcourses)) {
 116          $choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
 117          $temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'),
 118              new lang_string('courselegacyfiles_help'), key($choices), $choices));
 119      }
 120  
 121      $currentmaxbytes = get_config('moodlecourse', 'maxbytes');
 122      if (isset($CFG->maxbytes)) {
 123          $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $currentmaxbytes);
 124      } else {
 125          $choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
 126      }
 127      $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
 128          new lang_string('coursehelpmaximumupload'), key($choices), $choices));
 129  
 130      // Completion tracking.
 131      $temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
 132      $temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
 133          new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 134  
 135      // Groups.
 136      $temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
 137      $choices = array();
 138      $choices[NOGROUPS] = new lang_string('groupsnone', 'group');
 139      $choices[SEPARATEGROUPS] = new lang_string('groupsseparate', 'group');
 140      $choices[VISIBLEGROUPS] = new lang_string('groupsvisible', 'group');
 141      $temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices));
 142      $temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', new lang_string('force'), new lang_string('coursehelpforce'), 0,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 143  
 144      $ADMIN->add('courses', $temp);
 145  
 146  
 147      // "courserequests" settingpage.
 148      $temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
 149      $temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));
 150      $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', new lang_string('defaultrequestcategory', 'admin'), new lang_string('configdefaultrequestcategory', 'admin'), 1));
 151      $temp->add(new admin_setting_configcheckbox('requestcategoryselection', new lang_string('requestcategoryselection', 'admin'), new lang_string('configrequestcategoryselection', 'admin'), 0));
 152      $temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
 153      $ADMIN->add('courses', $temp);
 154  
 155      // Pending course requests.
 156      if (!empty($CFG->enablecourserequests)) {
 157          $ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
 158                  $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
 159      }
 160  
 161      // Add a category for backups.
 162      $ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
 163  
 164      // Create a page for general backups configuration and defaults.
 165      $temp = new admin_settingpage('backupgeneralsettings', new lang_string('generalbackdefaults', 'backup'), 'moodle/backup:backupcourse');
 166  
 167      // General configuration section.
 168      $temp->add(new admin_setting_configselect('backup/loglifetime', new lang_string('loglifetime', 'backup'), new lang_string('configloglifetime', 'backup'), 30, array(
 169          1   => new lang_string('numdays', '', 1),
 170          2   => new lang_string('numdays', '', 2),
 171          3   => new lang_string('numdays', '', 3),
 172          5   => new lang_string('numdays', '', 5),
 173          7   => new lang_string('numdays', '', 7),
 174          10  => new lang_string('numdays', '', 10),
 175          14  => new lang_string('numdays', '', 14),
 176          20  => new lang_string('numdays', '', 20),
 177          30  => new lang_string('numdays', '', 30),
 178          60  => new lang_string('numdays', '', 60),
 179          90  => new lang_string('numdays', '', 90),
 180          120 => new lang_string('numdays', '', 120),
 181          180 => new lang_string('numdays', '', 180),
 182          365 => new lang_string('numdays', '', 365)
 183      )));
 184  
 185      // General defaults section.
 186      $temp->add(new admin_setting_heading('generalsettings', new lang_string('generalsettings', 'backup'), ''));
 187      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_users', new lang_string('generalusers','backup'), new lang_string('configgeneralusers','backup'), array('value'=>1, 'locked'=>0)));
 188      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_anonymize', new lang_string('generalanonymize','backup'), new lang_string('configgeneralanonymize','backup'), array('value'=>0, 'locked'=>0)));
 189      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), array('value'=>1, 'locked'=>0)));
 190      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), array('value'=>1, 'locked'=>0)));
 191      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0)));
 192      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0)));
 193      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), array('value'=>1, 'locked'=>0)));
 194      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), array('value'=>1,'locked'=>0)));
 195      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), array('value'=>1, 'locked'=>0)));
 196      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_logs', new lang_string('generallogs','backup'), new lang_string('configgenerallogs','backup'), array('value'=>0, 'locked'=>0)));
 197      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0)));
 198      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), array('value'=>1, 'locked'=>0)));
 199      $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_groups',
 200              new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'),
 201              array('value' => 1, 'locked' => 0)));
 202  
 203      $ADMIN->add('backups', $temp);
 204  
 205      // Create a page for general import configuration and defaults.
 206      $temp = new admin_settingpage('importgeneralsettings', new lang_string('importgeneralsettings', 'backup'), 'moodle/backup:backupcourse');
 207      $temp->add(new admin_setting_configtext('backup/import_general_maxresults', new lang_string('importgeneralmaxresults', 'backup'), new lang_string('importgeneralmaxresults_desc', 'backup'), 10));
 208      $temp->add(new admin_setting_configcheckbox('backup/import_general_duplicate_admin_allowed',
 209              new lang_string('importgeneralduplicateadminallowed', 'backup'),
 210              new lang_string('importgeneralduplicateadminallowed_desc', 'backup'), 0));
 211      $ADMIN->add('backups', $temp);
 212  
 213      // Create a page for automated backups configuration and defaults.
 214      $temp = new admin_settingpage('automated', new lang_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
 215  
 216      // Automated configuration section.
 217      $temp->add(new admin_setting_configselect('backup/backup_auto_active', new lang_string('active'),  new lang_string('autoactivedescription', 'backup'), 0, array(
 218          0 => new lang_string('autoactivedisabled', 'backup'),
 219          1 => new lang_string('autoactiveenabled', 'backup'),
 220          2 => new lang_string('autoactivemanual', 'backup')
 221      )));
 222      $temp->add(new admin_setting_special_backupdays());
 223      $temp->add(new admin_setting_configtime('backup/backup_auto_hour', 'backup_auto_minute', new lang_string('executeat'),
 224              new lang_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
 225      $storageoptions = array(
 226          0 => new lang_string('storagecourseonly', 'backup'),
 227          1 => new lang_string('storageexternalonly', 'backup'),
 228          2 => new lang_string('storagecourseandexternal', 'backup')
 229      );
 230      $temp->add(new admin_setting_configselect('backup/backup_auto_storage', new lang_string('automatedstorage', 'backup'), new lang_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
 231      $temp->add(new admin_setting_special_backup_auto_destination());
 232  
 233      $maxkeptoptions = array(
 234          0 => new lang_string('all'), 1 => '1',
 235          2 => '2',
 236          5 => '5',
 237          10 => '10',
 238          20 => '20',
 239          30 => '30',
 240          40 => '40',
 241          50 => '50',
 242          100 => '100',
 243          200 => '200',
 244          300 => '300',
 245          400 => '400',
 246          500 => '500');
 247      $temp->add(new admin_setting_configselect('backup/backup_auto_max_kept', new lang_string('automatedmaxkept', 'backup'),
 248              new lang_string('automatedmaxkepthelp', 'backup'), 1, $maxkeptoptions));
 249  
 250      $automateddeletedaysoptions = array(
 251          0 => new lang_string('never'),
 252          1000 => new lang_string('numdays', '', 1000),
 253          365  => new lang_string('numdays', '', 365),
 254          180  => new lang_string('numdays', '', 180),
 255          150  => new lang_string('numdays', '', 150),
 256          120  => new lang_string('numdays', '', 120),
 257          90   => new lang_string('numdays', '', 90),
 258          60   => new lang_string('numdays', '', 60),
 259          35   => new lang_string('numdays', '', 35),
 260          10   => new lang_string('numdays', '', 10),
 261          5    => new lang_string('numdays', '', 5),
 262          2    => new lang_string('numdays', '', 2)
 263      );
 264      $temp->add(new admin_setting_configselect('backup/backup_auto_delete_days', new lang_string('automateddeletedays', 'backup'),
 265              '', 0, $automateddeletedaysoptions));
 266  
 267      $minkeptoptions = array(
 268          0 => new lang_string('none'),
 269          1 => '1',
 270          2 => '2',
 271          5 => '5',
 272          10 => '10',
 273          20 => '20',
 274          30 => '30',
 275          40 => '40',
 276          50 => '50',
 277          100 => '100',
 278          200 => '200',
 279          300 => '300',
 280          400 => '400'
 281      );
 282      $temp->add(new admin_setting_configselect('backup/backup_auto_min_kept', new lang_string('automatedminkept', 'backup'),
 283              new lang_string('automatedminkepthelp', 'backup'), 0, $minkeptoptions));
 284  
 285      $temp->add(new admin_setting_configcheckbox('backup/backup_shortname', new lang_string('backup_shortname', 'admin'), new lang_string('backup_shortnamehelp', 'admin'), 0));
 286      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_hidden', new lang_string('skiphidden', 'backup'), new lang_string('skiphiddenhelp', 'backup'), 1));
 287      $temp->add(new admin_setting_configselect('backup/backup_auto_skip_modif_days', new lang_string('skipmodifdays', 'backup'), new lang_string('skipmodifdayshelp', 'backup'), 30, array(
 288          0 => new lang_string('never'),
 289          1 => new lang_string('numdays', '', 1),
 290          2 => new lang_string('numdays', '', 2),
 291          3 => new lang_string('numdays', '', 3),
 292          5 => new lang_string('numdays', '', 5),
 293          7 => new lang_string('numdays', '', 7),
 294          10 => new lang_string('numdays', '', 10),
 295          14 => new lang_string('numdays', '', 14),
 296          20 => new lang_string('numdays', '', 20),
 297          30 => new lang_string('numdays', '', 30),
 298          60 => new lang_string('numdays', '', 60),
 299          90 => new lang_string('numdays', '', 90),
 300          120 => new lang_string('numdays', '', 120),
 301          180 => new lang_string('numdays', '', 180),
 302          365 => new lang_string('numdays', '', 365)
 303      )));
 304      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_modif_prev', new lang_string('skipmodifprev', 'backup'), new lang_string('skipmodifprevhelp', 'backup'), 0));
 305  
 306      // Automated defaults section.
 307      $temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), ''));
 308      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', new lang_string('generalusers', 'backup'), new lang_string('configgeneralusers', 'backup'), 1));
 309      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), 1));
 310      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), 1));
 311      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1));
 312      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1));
 313      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), 1));
 314      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), 1));
 315      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), 1));
 316      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0));
 317      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
 318      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));
 319      $temp->add(new admin_setting_configcheckbox('backup/backup_auto_groups', new lang_string('generalgroups', 'backup'),
 320              new lang_string('configgeneralgroups', 'backup'), 1));
 321  
 322      //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
 323      //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
 324  
 325      $ADMIN->add('backups', $temp);
 326  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1