Compare commits
381 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 560c1c8ea3 | |||
| 7922f118db | |||
| f8872ff3e8 | |||
| d4edd6c99f | |||
| 301e79acae | |||
| baad460c91 | |||
| c3cf690cee | |||
| 6cc4b72fb9 | |||
| d311f9cc75 | |||
| bc6f61fe9f | |||
| b1455d0d74 | |||
| 01a2722f32 | |||
| 711f77e4ca | |||
| 615e2caf67 | |||
| cad44b4778 | |||
| c3cefce21c | |||
| 393133707a | |||
| 0fb12db343 | |||
| b1e4d7afc8 | |||
| eca84ae277 | |||
| c578a134fa | |||
| 53661a6767 | |||
| 3d115053d2 | |||
| 27db0b4376 | |||
| 45c79022ac | |||
| e15c728434 | |||
| 2c1fc0e086 | |||
| 35662296e5 | |||
| f5c99c5144 | |||
| 82efa6c9f2 | |||
| e02256507c | |||
| 794f42d81d | |||
| add479a88e | |||
| 429d0d711b | |||
| 47b2416012 | |||
| a01bd41865 | |||
| 555ad195a0 | |||
| 1ba20f5594 | |||
| d0890a7791 | |||
| b7a1f71911 | |||
| 7fd34aa0e6 | |||
| a78bb0cc83 | |||
| 2acdf0af6b | |||
| ba5ecbc72a | |||
| 4bb2eaa7d0 | |||
| 55e3c2cd82 | |||
| d320d0b285 | |||
| 9424bcb66e | |||
| 08a8eb917e | |||
| df78a7902b | |||
| 43fa28331e | |||
| c512b7cc65 | |||
| 8a7078b28b | |||
| dcb6e4169b | |||
| 8cd148efe0 | |||
| e2fb6ffa24 | |||
| 71a5c487ce | |||
| 23ea3287ea | |||
| a3e6f40dbe | |||
| 42cc95c245 | |||
| 9ea075bb32 | |||
| 08839bbcb8 | |||
| abfdce235b | |||
| 70427c648e | |||
| 5287178537 | |||
| abaaa8cdae | |||
| 9312fbe16e | |||
| d120a7baf2 | |||
| fb494ae9c8 | |||
| 09f2963373 | |||
| 6917b452bf | |||
| 919efdf632 | |||
| b3e58b7d0b | |||
| 4844fc124c | |||
| d98f1751e8 | |||
| 9ab44b3f99 | |||
| 6c32a2f003 | |||
| f23a63b545 | |||
| 6758c0fa99 | |||
| eef875e0c1 | |||
| 150735fbdb | |||
| accfa102fe | |||
| e5663dfd70 | |||
| 91d309074f | |||
| 9a3f511056 | |||
| de4d45ce8e | |||
| 2d22a9d474 | |||
| c64eea0a51 | |||
| 0e099cc444 | |||
| fda6ef7a1f | |||
| 7b8dba0b52 | |||
| c3673c5531 | |||
| 1efa930202 | |||
| 87c3a9fd9f | |||
| 1f26c7053a | |||
| fff86d45c1 | |||
| 54a0a16b53 | |||
| 8cb63784e5 | |||
| 9ac938636f | |||
| 3bdbe1b08b | |||
| eaccd0d486 | |||
| 0bc9604212 | |||
| 17a0f7350f | |||
| 0ed5fa3b88 | |||
| 34b3aa4d49 | |||
| 5f22097114 | |||
| 43fed596e5 | |||
| acb1bf6fac | |||
| 6a748d5e8b | |||
| d0a9524463 | |||
| 42e7fb5e49 | |||
| 5c550aaafc | |||
| ea6e1851e9 | |||
| bd0d739550 | |||
| 75d8d06ffb | |||
| 8c92e24434 | |||
| cbd0157d66 | |||
| c9bcb47d54 | |||
| c58f3ed7ff | |||
| 3b34d79d36 | |||
| 8f19a957e2 | |||
| 94cc2c769c | |||
| 4f718dc60c | |||
| d1b0786a51 | |||
| 1cdd43b12b | |||
| b807cc6334 | |||
| 8cbfc9614a | |||
| 9de894db2d | |||
| 7a2db63954 | |||
| 8a3894de89 | |||
| 60ca7d5b07 | |||
| 697ecc6db1 | |||
| e2536570a3 | |||
| af90211efd | |||
| 78855a6c7b | |||
| 1640389bcf | |||
| a70c9434d7 | |||
| 441b8d6e69 | |||
| de61d99ad1 | |||
| f311ba2714 | |||
| 06032cd928 | |||
| d05a5b126c | |||
| 45e4351ade | |||
| 2811b3d262 | |||
| 0cb2846998 | |||
| 4db1863687 | |||
| 4a256d6e8e | |||
| 44666a2d31 | |||
| a122d95343 | |||
| af11bd26b6 | |||
| b8aa36a063 | |||
| a10d621fc5 | |||
| a322a0ab53 | |||
| 969d8f0e3f | |||
| 36cfbfe841 | |||
| 314cc22a28 | |||
| bd1fae5fc0 | |||
| ac23be5d24 | |||
| 6e72e0a6aa | |||
| 57bafe6ebc | |||
| 4ae00d74bc | |||
| 60293b276a | |||
| 4673a6a8fc | |||
| ce5a85c354 | |||
| ff952aa064 | |||
| 675fa4b813 | |||
| 73b0524202 | |||
| 58c57f94d6 | |||
| b6ced2f7e4 | |||
| 6123c76bc7 | |||
| 8beb495df4 | |||
| 90b46f39a4 | |||
| 1f3a85aa54 | |||
| 98e4f24ff6 | |||
| 48763c4d21 | |||
| d91225aae4 | |||
| a5436ae8ce | |||
| 7a9000b1ff | |||
| 85d47590cc | |||
| 8789750cc5 | |||
| b15478526a | |||
| 8786deb033 | |||
| 59e8879130 | |||
| e81aa9e8e6 | |||
| 8a2e491ee7 | |||
| 3a6857090e | |||
| d2ff78d173 | |||
| ef37c13e29 | |||
| a8d816982a | |||
| ac7f6f4b96 | |||
| 6da08c0e2c | |||
| f72e3fbbf2 | |||
| 8afe4de645 | |||
| 1fc88334a6 | |||
| 7643bd4ca9 | |||
| 1b9f0beaf3 | |||
| 993612b00e | |||
| 4eb084f1a2 | |||
| 34b3d144fe | |||
| c61decc816 | |||
| 5864eb6017 | |||
| d9131593c7 | |||
| 16e566b99f | |||
| bd010f8854 | |||
| a364f61121 | |||
| cf2fb7579b | |||
| 945aa97617 | |||
| ca4349c1ce | |||
| 267b45e0a1 | |||
| 4c53ec3355 | |||
| 7bd19d562d | |||
| 49e3cda704 | |||
| e8ec840f3c | |||
| 0c018318c6 | |||
| 3bd02768df | |||
| 39adfbde72 | |||
| a42e313460 | |||
| d6b99cf123 | |||
| 77eb24f886 | |||
| d4609de200 | |||
| 6c2d9137b3 | |||
| 5dc182dd6e | |||
| 88e2d12038 | |||
| b6a84b6fdd | |||
| 3e2821e6f5 | |||
| d93610d4b0 | |||
| 34d55059cb | |||
| 6257097a3f | |||
| cd35f43eac | |||
| 788105dd3d | |||
| 80cee53996 | |||
| dd94734d9a | |||
| 786538f74f | |||
| 925ec67b22 | |||
| b159b57207 | |||
| c01c608fdc | |||
| ca887bc9bc | |||
| 2ff9ac5608 | |||
| f63fc5c41a | |||
| d276541169 | |||
| 72b266d54e | |||
| 8f3702ee1a | |||
| 54b951fb5f | |||
| 9844660858 | |||
| d0012b72ad | |||
| 623b678c3e | |||
| 75f6d03855 | |||
| 236a2fca9b | |||
| a7c5e2d24d | |||
| 4ae75c1847 | |||
| d7788d69f6 | |||
| a033a6b4c1 | |||
| 0626a71686 | |||
| 756fbd91fd | |||
| 3b5c7727f2 | |||
| e5b13b7fc0 | |||
| 49c29a3f46 | |||
| 92fdea041d | |||
| a7fd949571 | |||
| 32d77062b4 | |||
| 92416730d1 | |||
| 4b95721a26 | |||
| 29d526b495 | |||
| 227d3fcbd3 | |||
| 05c3b5dd2f | |||
| cf55843d07 | |||
| c7c613b45b | |||
| 06450ed398 | |||
| 3d986cf8cd | |||
| 6e3013be7c | |||
| 63b66cf276 | |||
| aaf95d0161 | |||
| 473aab4ffb | |||
| 2504a9d2ec | |||
| a24c22cd12 | |||
| 2ccad8f967 | |||
| b152769f44 | |||
| 77b4970559 | |||
| 8492c192af | |||
| f621e8e3d8 | |||
| 5a804c0f54 | |||
| bfff058cc8 | |||
| 9e72a16e14 | |||
| 90317c258b | |||
| fcb5548c38 | |||
| 654f0c0cf7 | |||
| 402469ce8b | |||
| fb092979bf | |||
| 768779972e | |||
| b0124c9703 | |||
| d2674929ba | |||
| 47ba8d481e | |||
| 814054616f | |||
| 7bc37de925 | |||
| 0f00c5c594 | |||
| 4b8ed14f54 | |||
| 9840da227e | |||
| 4948ac2e0c | |||
| 954b1b5504 | |||
| 9e81532432 | |||
| 6726f0073e | |||
| 5011fb91ff | |||
| 657beb8924 | |||
| 1d5c188798 | |||
| ac7cbc012e | |||
| 05f1cccc37 | |||
| 1081b8ec84 | |||
| af0a06b521 | |||
| 9963b0b6a6 | |||
| d7b20f1650 | |||
| 694cb9b053 | |||
| 14dcbdb0f4 | |||
| 38753adc60 | |||
| da7c844c30 | |||
| 0f6d896e43 | |||
| 0137a13d55 | |||
| 254bf485f1 | |||
| e81fce929a | |||
| c1536ff1ef | |||
| 43e1ed2cf3 | |||
| 46f15f03d2 | |||
| 0cddce2c56 | |||
| 18cbf0db95 | |||
| 3b2c61fdb8 | |||
| d64a0e9173 | |||
| c88b113c1f | |||
| aa6699f4db | |||
| 1e557db89d | |||
| 5e99c1f9a1 | |||
| 84197f41ca | |||
| b604cb81e4 | |||
| 05f853e2db | |||
| a77864208e | |||
| 4b3521ec69 | |||
| 294673628e | |||
| 081e303415 | |||
| b14d0e4713 | |||
| d2dc75fb4e | |||
| 7c95cf02af | |||
| a7f3f08722 | |||
| 5db72d63c5 | |||
| d58d0239db | |||
| e9ea8e9b63 | |||
| e523503fb8 | |||
| 4da2fefa4d | |||
| 0f85e6ba0b | |||
| 8baa0cab98 | |||
| 5a730d0a80 | |||
| 5a36d6292d | |||
| b7a4701d1f | |||
| 6cb665f18c | |||
| eae5890112 | |||
| fd9ecb595f | |||
| 1fdc20cbdb | |||
| 1830fc428c | |||
| c53069c60a | |||
| 97a0c05d46 | |||
| 700e92b8d4 | |||
| eb57e9e60b | |||
| 5f8e23c1a9 | |||
| 7ed78289b5 | |||
| 77458d700b | |||
| 52b617673c | |||
| efcbed9b73 | |||
| 2dd8a44c20 | |||
| 3b8005fae7 | |||
| 097abcc59c | |||
| f257805573 | |||
| 2e5d19ddfc | |||
| 708a1cec00 | |||
| 53165cbc05 | |||
| 557b8de4cf | |||
| f68ebb8282 | |||
| 30d3f1d220 | |||
| a7f94caa2e | |||
| aadac9873b | |||
| 4a3728ee50 | |||
| c959f27415 | |||
| e727d2aa2a | |||
| 5f11ce035d | |||
| 004f868825 |
@@ -288,9 +288,9 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
|
||||
// Get list of used plug-ins
|
||||
$instances = repository::get_types();
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
if (!empty($instances)) {
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
$totalinstances = count($instances);
|
||||
$updowncount = 1;
|
||||
foreach ($instances as $i) {
|
||||
|
||||
@@ -38,7 +38,7 @@ $string['nolangupdateneeded'] = 'All your language packs are up to date, no upda
|
||||
$string['pluginname'] = 'Language packs';
|
||||
$string['purgestringcaches'] = 'Purge string caches';
|
||||
$string['remotelangnotavailable'] = 'Because Moodle cannot connect to download.moodle.org, it is not possible for language packs to be installed automatically. Please download the appropriate ZIP file(s) from <a href="http://download.moodle.org/langpack/">download.moodle.org/langpack</a>, copy them to your {$a} directory and unzip them manually.';
|
||||
$string['uninstall'] = 'Uninstall selected language pack(s)';
|
||||
$string['uninstall'] = 'Uninstall selected language pack';
|
||||
$string['uninstallconfirm'] = 'You are about to completely uninstall language pack {$a}, are you sure?';
|
||||
$string['updatelangs'] = 'Update all installed language packs';
|
||||
|
||||
|
||||
@@ -98,12 +98,16 @@ $STD_FIELDS = array('id', 'firstname', 'lastname', 'username', 'email',
|
||||
|
||||
$PRF_FIELDS = array();
|
||||
|
||||
if ($prof_fields = $DB->get_records('user_info_field')) {
|
||||
foreach ($prof_fields as $prof_field) {
|
||||
$PRF_FIELDS[] = 'profile_field_'.$prof_field->shortname;
|
||||
if ($proffields = $DB->get_records('user_info_field')) {
|
||||
foreach ($proffields as $key => $proffield) {
|
||||
$profilefieldname = 'profile_field_'.$proffield->shortname;
|
||||
$PRF_FIELDS[] = $profilefieldname;
|
||||
// Re-index $proffields with key as shortname. This will be
|
||||
// used while checking if profile data is key and needs to be converted (eg. menu profile field)
|
||||
$proffields[$profilefieldname] = $proffield;
|
||||
unset($proffields[$key]);
|
||||
}
|
||||
}
|
||||
unset($prof_fields);
|
||||
|
||||
if (empty($iid)) {
|
||||
$mform1 = new admin_uploaduser_form1();
|
||||
@@ -331,6 +335,16 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
if (isset($formdata->$field)) {
|
||||
// process templates
|
||||
$user->$field = uu_process_template($formdata->$field, $user);
|
||||
|
||||
// Form contains key and later code expects value.
|
||||
// Convert key to value for required profile fields.
|
||||
require_once($CFG->dirroot.'/user/profile/field/'.$proffields[$field]->datatype.'/field.class.php');
|
||||
$profilefieldclass = 'profile_field_'.$proffields[$field]->datatype;
|
||||
$profilefield = new $profilefieldclass($proffields[$field]->id);
|
||||
if (method_exists($profilefield, 'convert_external_data')) {
|
||||
$user->$field = $profilefield->edit_save_data_preprocess($user->$field, null);
|
||||
}
|
||||
|
||||
$formdefaults[$field] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +376,9 @@
|
||||
echo $OUTPUT->heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
|
||||
}
|
||||
if (!empty($table)) {
|
||||
echo html_writer::start_tag('div', array('class'=>'no-overflow'));
|
||||
echo html_writer::table($table);
|
||||
echo html_writer::end_tag('div');
|
||||
echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl);
|
||||
if (has_capability('moodle/user:create', $sitecontext)) {
|
||||
echo $OUTPUT->heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
|
||||
|
||||
@@ -1370,7 +1370,7 @@ class CASClient
|
||||
|
||||
/**
|
||||
* This method is used to validate a ST; halt on failure, and sets $validate_url,
|
||||
* $text_reponse and $tree_response on success. These parameters are used later
|
||||
* $text_response and $tree_response on success. These parameters are used later
|
||||
* by CASClient::validatePGT() for CAS proxies.
|
||||
* Used for all CAS 1.0 validations
|
||||
* @param $validate_url the URL of the request to the CAS server.
|
||||
@@ -1500,7 +1500,7 @@ class CASClient
|
||||
|
||||
/**
|
||||
* This method is used to validate a SAML TICKET; halt on failure, and sets $validate_url,
|
||||
* $text_reponse and $tree_response on success. These parameters are used later
|
||||
* $text_response and $tree_response on success. These parameters are used later
|
||||
* by CASClient::validatePGT() for CAS proxies.
|
||||
*
|
||||
* @param $validate_url the URL of the request to the CAS server.
|
||||
@@ -2160,7 +2160,7 @@ class CASClient
|
||||
if ($this->_cas_server_cert != '' && $this->_cas_server_ca_cert != '') {
|
||||
// This branch added by IDMS. Seems phpCAS implementor got a bit confused about the curl options CURLOPT_SSLCERT and CURLOPT_CAINFO
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
curl_setopt($ch, CURLOPT_SSLCERT, $this->_cas_server_cert);
|
||||
curl_setopt($ch, CURLOPT_CAINFO, $this->_cas_server_ca_cert);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, '1');
|
||||
@@ -2172,7 +2172,7 @@ class CASClient
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
|
||||
curl_setopt($ch, CURLOPT_CAINFO, $this->_cas_server_ca_cert);
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ class auth_plugin_cas extends auth_plugin_ldap {
|
||||
// test pgtIou parameter for proxy mode (https connection
|
||||
// in background from CAS server to the php server)
|
||||
if ($authCAS != 'CAS' && !isset($_GET['pgtIou'])) {
|
||||
$PAGE->set_url('/auth/cas/auth.php');
|
||||
$PAGE->set_url('/login/index.php');
|
||||
$PAGE->navbar->add($CASform);
|
||||
$PAGE->set_title("$site->fullname: $CASform");
|
||||
$PAGE->set_heading($site->fullname);
|
||||
|
||||
@@ -307,7 +307,7 @@ if (!ldap_paged_results_supported($config->ldap_version)) {
|
||||
<label for="bind_pw"><?php print_string('auth_ldap_bind_pw_key', 'auth_ldap') ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="bind_pw" id="bind_pw" type="password" size="30" value="<?php echo $config->bind_pw?>" />
|
||||
<input name="bind_pw" id="bind_pw" type="password" size="30" value="<?php echo $config->bind_pw?>" autocomplete="off"/>
|
||||
<?php if (isset($err['bind_pw'])) { echo $OUTPUT->error_text($err['bind_pw']); } ?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="pass"><?php print_string("auth_dbpass_key", "auth_db") ?></label></td>
|
||||
<td>
|
||||
<input id="pass" name="pass" type="text" size="30" value="<?php echo $config->pass?>" />
|
||||
<input id="pass" name="pass" type="password" size="30" value="<?php p($config->pass)?>" autocomplete="off"/>
|
||||
<?php
|
||||
|
||||
if (isset($err["pass"])) {
|
||||
|
||||
@@ -36,13 +36,13 @@ $string['auth_dbfieldpass'] = 'Name of the field containing passwords';
|
||||
$string['auth_dbfieldpass_key'] = 'Password field';
|
||||
$string['auth_dbfielduser'] = 'Name of the field containing usernames';
|
||||
$string['auth_dbfielduser_key'] = 'Username field';
|
||||
$string['auth_dbhost'] = 'The computer hosting the database server.';
|
||||
$string['auth_dbhost'] = 'The computer hosting the database server. Use a system DSN entry if using ODBC.';
|
||||
$string['auth_dbhost_key'] = 'Host';
|
||||
$string['auth_dbchangepasswordurl_key'] = 'Password-change URL';
|
||||
$string['auth_dbinsertuser'] = 'Inserted user {$a->name} id {$a->id}';
|
||||
$string['auth_dbinsertuserduplicate'] = 'Error inserting user {$a->username} - user with this username was already created through \'{$a->auth}\' plugin.';
|
||||
$string['auth_dbinsertusererror'] = 'Error inserting user {$a}';
|
||||
$string['auth_dbname'] = 'Name of the database itself';
|
||||
$string['auth_dbname'] = 'Name of the database itself. Leave empty if using an ODBC DSN.';
|
||||
$string['auth_dbname_key'] = 'DB name';
|
||||
$string['auth_dbpass'] = 'Password matching the above username';
|
||||
$string['auth_dbpass_key'] = 'Password';
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><label for="passwd"><?php print_string("auth_fcpasswd_key", "auth_fc") ?>:</label></td>
|
||||
<td>
|
||||
<input name="passwd" id="passwd" type="password" size="30" maxlength="12" value="<?php echo $config->passwd?>" />
|
||||
<input name="passwd" id="passwd" type="password" size="30" maxlength="12" value="<?php echo $config->passwd?>" autocomplete="off"/>
|
||||
<?php if (isset($err["passwd"])) echo $OUTPUT->error_text($err["passwd"]); ?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -209,7 +209,7 @@ if (!ldap_paged_results_supported($config->ldap_version)) {
|
||||
<label for="bind_pw"><?php print_string('auth_ldap_bind_pw_key', 'auth_ldap') ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input name="bind_pw" id="bind_pw" type="password" size="30" value="<?php echo $config->bind_pw?>" />
|
||||
<input name="bind_pw" id="bind_pw" type="password" size="30" value="<?php echo $config->bind_pw?>" autocomplete="off"/>
|
||||
<?php if (isset($err['bind_pw'])) { echo $OUTPUT->error_text($err['bind_pw']); } ?>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
This files describes API changes in /auth/* - plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 2.4.6 ===
|
||||
|
||||
* can_be_manually_set() - This function was introduced in the base class and returns false by default. If overriden by
|
||||
an authentication plugin to return true, the authentication plugin will be able to be manually set for users. For example,
|
||||
when bulk uploading users you will be able to select it as the authentication method they use.
|
||||
|
||||
=== 2.4 ===
|
||||
|
||||
required changes in code:
|
||||
|
||||
@@ -335,6 +335,9 @@ class restore_controller extends backup implements loggable {
|
||||
if ($this->status != backup::STATUS_NEED_PRECHECK) {
|
||||
throw new restore_controller_exception('cannot_precheck_wrong_status', $this->status);
|
||||
}
|
||||
// Basic/initial prevention against time/memory limits
|
||||
set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
$this->precheck = restore_prechecks_helper::execute_prechecks($this, $droptemptablesafter);
|
||||
if (!array_key_exists('errors', $this->precheck)) { // No errors, can be executed
|
||||
$this->set_status(backup::STATUS_AWAITING);
|
||||
|
||||
@@ -139,7 +139,7 @@ class imscc11_backup_convert extends backup_execution_step {
|
||||
|
||||
require_once($CFG->dirroot . '/backup/cc/cc_includes.php');
|
||||
|
||||
$tempdir = $CFG->dataroot . '/temp/backup/' . uniqid('', true);
|
||||
$tempdir = $CFG->tempdir . '/backup/' . uniqid('', true);
|
||||
|
||||
if (mkdir($tempdir, 0777, true)) {
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class create_and_clean_temp_stuff extends backup_execution_step {
|
||||
backup_helper::check_and_create_backup_dir($this->get_backupid());// Create backup temp dir
|
||||
backup_helper::clear_backup_dir($this->get_backupid()); // Empty temp dir, just in case
|
||||
backup_helper::delete_old_backup_dirs(time() - (4 * 60 * 60)); // Delete > 4 hours temp dirs
|
||||
backup_controller_dbops::drop_backup_ids_temp_table($this->get_backupid()); // Drop ids temp table
|
||||
backup_controller_dbops::create_backup_ids_temp_table($this->get_backupid()); // Create ids temp table
|
||||
}
|
||||
}
|
||||
@@ -1626,7 +1627,20 @@ class backup_zip_contents extends backup_execution_step {
|
||||
$zippacker = get_file_packer('application/zip');
|
||||
|
||||
// Zip files
|
||||
$zippacker->archive_to_pathname($files, $zipfile);
|
||||
$result = $zippacker->archive_to_pathname($files, $zipfile, true, $this);
|
||||
|
||||
// Something went wrong.
|
||||
if ($result === false) {
|
||||
@unlink($zipfile);
|
||||
throw new backup_step_exception('error_zip_packing', '', 'An error was encountered while trying to generate backup zip');
|
||||
}
|
||||
// Read to make sure it is a valid backup. Refer MDL-37877 . Delete it, if found not to be valid.
|
||||
try {
|
||||
backup_general_helper::get_backup_information_from_mbz($zipfile);
|
||||
} catch (backup_helper_exception $e) {
|
||||
@unlink($zipfile);
|
||||
throw new backup_step_exception('error_zip_packing', '', $e->debuginfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ global $LINKS_ENCODERS_CACHE;
|
||||
$LINKS_ENCODERS_CACHE = array();
|
||||
|
||||
/**
|
||||
* Class implementing the @xml_contenttrasnformed logic to be applied in moodle2 backups
|
||||
* Class implementing the @xml_contenttransformed logic to be applied in moodle2 backups
|
||||
*
|
||||
* TODO: Finish phpdocs
|
||||
*/
|
||||
@@ -61,13 +61,13 @@ class backup_xml_transformer extends xml_contenttransformer {
|
||||
|
||||
// Array or object, debug and try our best recursively, shouldn't happen but...
|
||||
if (is_array($content)) {
|
||||
debugging('Backup XML transformer should process arrays but plain content always', DEBUG_DEVELOPER);
|
||||
debugging('Backup XML transformer should not process arrays but plain content only', DEBUG_DEVELOPER);
|
||||
foreach($content as $key => $plaincontent) {
|
||||
$content[$key] = $this->process($plaincontent);
|
||||
}
|
||||
return $content;
|
||||
} else if (is_object($content)) {
|
||||
debugging('Backup XML transformer should not process objects but plain content always', DEBUG_DEVELOPER);
|
||||
debugging('Backup XML transformer should not process objects but plain content only', DEBUG_DEVELOPER);
|
||||
foreach((array)$content as $key => $plaincontent) {
|
||||
$content[$key] = $this->process($plaincontent);
|
||||
}
|
||||
|
||||
@@ -161,6 +161,9 @@ class restore_section_task extends restore_task {
|
||||
$section_included = new restore_section_included_setting($settingname, base_setting::IS_BOOLEAN, true);
|
||||
if (is_number($this->info->title)) {
|
||||
$label = get_string('includesection', 'backup', $this->info->title);
|
||||
} elseif (empty($this->info->title)) { // Don't throw error if title is empty, gracefully continue restore.
|
||||
$this->log('Section title missing in backup for section id '.$this->info->sectionid, backup::LOG_WARNING, $this->name);
|
||||
$label = get_string('unnamedsection', 'backup');
|
||||
} else {
|
||||
$label = $this->info->title;
|
||||
}
|
||||
|
||||
@@ -164,8 +164,10 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
$dbman = $DB->get_manager(); // We are going to use database_manager services
|
||||
|
||||
$targettablename = 'backup_ids_temp';
|
||||
$table = new xmldb_table($targettablename);
|
||||
$dbman->drop_table($table); // And drop it
|
||||
if ($dbman->table_exists($targettablename)) {
|
||||
$table = new xmldb_table($targettablename);
|
||||
$dbman->drop_table($table); // And drop it
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -908,6 +908,15 @@ abstract class restore_dbops {
|
||||
}
|
||||
|
||||
if (empty($file->repositoryid)) {
|
||||
// If contenthash is empty then gracefully skip adding file.
|
||||
if (empty($file->contenthash)) {
|
||||
$result = new stdClass();
|
||||
$result->code = 'file_missing_in_backup';
|
||||
$result->message = sprintf('missing file (%s) contenthash in backup for component %s', $file->filename, $component);
|
||||
$result->level = backup::LOG_WARNING;
|
||||
$results[] = $result;
|
||||
continue;
|
||||
}
|
||||
// this is a regular file, it must be present in the backup pool
|
||||
$backuppath = $basepath . backup_file_manager::get_backup_content_file_location($file->contenthash);
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
abstract class backup_cron_automated_helper {
|
||||
|
||||
/** automated backups are active and ready to run */
|
||||
/** Automated backups are active and ready to run */
|
||||
const STATE_OK = 0;
|
||||
/** automated backups are disabled and will not be run */
|
||||
/** Automated backups are disabled and will not be run */
|
||||
const STATE_DISABLED = 1;
|
||||
/** automated backups are all ready running! */
|
||||
/** Automated backups are all ready running! */
|
||||
const STATE_RUNNING = 2;
|
||||
|
||||
/** Course automated backup completed successfully */
|
||||
@@ -49,6 +49,8 @@ abstract class backup_cron_automated_helper {
|
||||
const BACKUP_STATUS_SKIPPED = 3;
|
||||
/** Course automated backup had warnings */
|
||||
const BACKUP_STATUS_WARNING = 4;
|
||||
/** Course automated backup has yet to be run */
|
||||
const BACKUP_STATUS_NOTYETRUN = 5;
|
||||
|
||||
/** Run if required by the schedule set in config. Default. **/
|
||||
const RUN_ON_SCHEDULE = 0;
|
||||
@@ -119,12 +121,13 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$rs = $DB->get_recordset('course');
|
||||
foreach ($rs as $course) {
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid'=>$course->id));
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid' => $course->id));
|
||||
if (!$backupcourse) {
|
||||
$backupcourse = new stdClass;
|
||||
$backupcourse->courseid = $course->id;
|
||||
$DB->insert_record('backup_courses',$backupcourse);
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid'=>$course->id));
|
||||
$backupcourse->laststatus = self::BACKUP_STATUS_NOTYETRUN;
|
||||
$DB->insert_record('backup_courses', $backupcourse);
|
||||
$backupcourse = $DB->get_record('backup_courses', array('courseid' => $course->id));
|
||||
}
|
||||
|
||||
// The last backup is considered as successful when OK or SKIPPED.
|
||||
@@ -132,19 +135,23 @@ abstract class backup_cron_automated_helper {
|
||||
$backupcourse->laststatus == self::BACKUP_STATUS_OK) && (
|
||||
$backupcourse->laststarttime > 0 && $backupcourse->lastendtime > 0);
|
||||
|
||||
// Skip courses that do not yet need backup.
|
||||
$skipped = !(($backupcourse->nextstarttime > 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATELY);
|
||||
$skippedmessage = 'Does not require backup';
|
||||
// Assume that we are not skipping anything.
|
||||
$skipped = false;
|
||||
$skippedmessage = '';
|
||||
|
||||
// Check if we are going to be running the backup now.
|
||||
$shouldrunnow = (($backupcourse->nextstarttime > 0 && $backupcourse->nextstarttime < $now)
|
||||
|| $rundirective == self::RUN_IMMEDIATELY);
|
||||
|
||||
// If config backup_auto_skip_hidden is set to true, skip courses that are not visible.
|
||||
if (!$skipped && $config->backup_auto_skip_hidden) {
|
||||
if ($shouldrunnow && $config->backup_auto_skip_hidden) {
|
||||
$skipped = ($config->backup_auto_skip_hidden && !$course->visible);
|
||||
$skippedmessage = 'Not visible';
|
||||
}
|
||||
|
||||
// If config backup_auto_skip_modif_days is set to true, skip courses
|
||||
// that have not been modified since the number of days defined.
|
||||
if (!$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_days) {
|
||||
if ($shouldrunnow && !$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_days) {
|
||||
$sqlwhere = "course=:courseid AND time>:time AND ".$DB->sql_like('action', ':action', false, true, true);
|
||||
$timenotmodifsincedays = $now - ($config->backup_auto_skip_modif_days * DAYSECS);
|
||||
// Check log if there were any modifications to the course content.
|
||||
@@ -159,8 +166,9 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
// If config backup_auto_skip_modif_prev is set to true, skip courses
|
||||
// that have not been modified since previous backup.
|
||||
if (!$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_prev) {
|
||||
if ($shouldrunnow && !$skipped && $lastbackupwassuccessful && $config->backup_auto_skip_modif_prev) {
|
||||
// Check log if there were any modifications to the course content.
|
||||
$sqlwhere = "course=:courseid AND time>:time AND ".$DB->sql_like('action', ':action', false, true, true);
|
||||
$params = array('courseid' => $course->id,
|
||||
'time' => $backupcourse->laststarttime,
|
||||
'action' => '%view%');
|
||||
@@ -170,16 +178,17 @@ abstract class backup_cron_automated_helper {
|
||||
$skippedmessage = 'Not modified since previous backup';
|
||||
}
|
||||
|
||||
// Skip courses not needed for backup.
|
||||
if ($skipped) {
|
||||
// Output the next execution time when it has been updated.
|
||||
if ($backupcourse->nextstarttime != $nextstarttime) {
|
||||
mtrace('Backup of \'' . $course->fullname . '\' is scheduled on ' . $showtime);
|
||||
}
|
||||
// Check if the course is not scheduled to run right now.
|
||||
if (!$shouldrunnow) {
|
||||
$backupcourse->nextstarttime = $nextstarttime;
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
mtrace('Skipping ' . $course->fullname . ' (Not scheduled for backup until ' . $showtime . ')');
|
||||
} else if ($skipped) { // Must have been skipped for a reason.
|
||||
$backupcourse->laststatus = self::BACKUP_STATUS_SKIPPED;
|
||||
$backupcourse->nextstarttime = $nextstarttime;
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
mtrace('Skipping '.$course->fullname.' ('.$skippedmessage.')');
|
||||
mtrace('Skipping ' . $course->fullname . ' (' . $skippedmessage . ')');
|
||||
mtrace('Backup of \'' . $course->fullname . '\' is scheduled on ' . $showtime);
|
||||
} else {
|
||||
// Backup every non-skipped courses.
|
||||
mtrace('Backing up '.$course->fullname.'...');
|
||||
@@ -223,16 +232,17 @@ abstract class backup_cron_automated_helper {
|
||||
$count = backup_cron_automated_helper::get_backup_status_array();
|
||||
$haserrors = ($count[self::BACKUP_STATUS_ERROR] != 0 || $count[self::BACKUP_STATUS_UNFINISHED] != 0);
|
||||
|
||||
//Build the message text
|
||||
//Summary
|
||||
$message .= get_string('summary')."\n";
|
||||
// Build the message text.
|
||||
// Summary.
|
||||
$message .= get_string('summary') . "\n";
|
||||
$message .= "==================================================\n";
|
||||
$message .= " ".get_string('courses').": ".array_sum($count)."\n";
|
||||
$message .= " ".get_string('ok').": ".$count[self::BACKUP_STATUS_OK]."\n";
|
||||
$message .= " ".get_string('skipped').": ".$count[self::BACKUP_STATUS_SKIPPED]."\n";
|
||||
$message .= " ".get_string('error').": ".$count[self::BACKUP_STATUS_ERROR]."\n";
|
||||
$message .= " ".get_string('unfinished').": ".$count[self::BACKUP_STATUS_UNFINISHED]."\n";
|
||||
$message .= " ".get_string('warning').": ".$count[self::BACKUP_STATUS_WARNING]."\n\n";
|
||||
$message .= ' ' . get_string('courses') . '; ' . array_sum($count) . "\n";
|
||||
$message .= ' ' . get_string('ok') . '; ' . $count[self::BACKUP_STATUS_OK] . "\n";
|
||||
$message .= ' ' . get_string('skipped') . '; ' . $count[self::BACKUP_STATUS_SKIPPED] . "\n";
|
||||
$message .= ' ' . get_string('error') . '; ' . $count[self::BACKUP_STATUS_ERROR] . "\n";
|
||||
$message .= ' ' . get_string('unfinished') . '; ' . $count[self::BACKUP_STATUS_UNFINISHED] . "\n";
|
||||
$message .= ' ' . get_string('warning') . '; ' . $count[self::BACKUP_STATUS_WARNING] . "\n";
|
||||
$message .= ' ' . get_string('backupnotyetrun') . '; ' . $count[self::BACKUP_STATUS_NOTYETRUN]."\n\n";
|
||||
|
||||
//Reference
|
||||
if ($haserrors) {
|
||||
@@ -295,7 +305,8 @@ abstract class backup_cron_automated_helper {
|
||||
self::BACKUP_STATUS_OK => 0,
|
||||
self::BACKUP_STATUS_UNFINISHED => 0,
|
||||
self::BACKUP_STATUS_SKIPPED => 0,
|
||||
self::BACKUP_STATUS_WARNING => 0
|
||||
self::BACKUP_STATUS_WARNING => 0,
|
||||
self::BACKUP_STATUS_NOTYETRUN => 0
|
||||
);
|
||||
|
||||
$statuses = $DB->get_records_sql('SELECT DISTINCT bc.laststatus, COUNT(bc.courseid) AS statuscount FROM {backup_courses} bc GROUP BY bc.laststatus');
|
||||
@@ -371,7 +382,11 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
$outcome = self::BACKUP_STATUS_OK;
|
||||
$config = get_config('backup');
|
||||
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_AUTOMATED, $userid);
|
||||
$dir = $config->backup_auto_destination;
|
||||
$storage = (int)$config->backup_auto_storage;
|
||||
|
||||
$bc = new backup_controller(backup::TYPE_1COURSE, $course->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO,
|
||||
backup::MODE_AUTOMATED, $userid);
|
||||
|
||||
try {
|
||||
|
||||
@@ -392,27 +407,28 @@ abstract class backup_cron_automated_helper {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the default filename
|
||||
// Set the default filename.
|
||||
$format = $bc->get_format();
|
||||
$type = $bc->get_type();
|
||||
$id = $bc->get_id();
|
||||
$users = $bc->get_plan()->get_setting('users')->get_value();
|
||||
$anonymised = $bc->get_plan()->get_setting('anonymize')->get_value();
|
||||
$bc->get_plan()->get_setting('filename')->set_value(backup_plan_dbops::get_default_backup_filename($format, $type, $id, $users, $anonymised));
|
||||
$bc->get_plan()->get_setting('filename')->set_value(backup_plan_dbops::get_default_backup_filename($format, $type,
|
||||
$id, $users, $anonymised));
|
||||
|
||||
$bc->set_status(backup::STATUS_AWAITING);
|
||||
|
||||
$bc->execute_plan();
|
||||
$results = $bc->get_results();
|
||||
$outcome = self::outcome_from_results($results);
|
||||
$file = $results['backup_destination']; // may be empty if file already moved to target location
|
||||
$dir = $config->backup_auto_destination;
|
||||
$storage = (int)$config->backup_auto_storage;
|
||||
$file = $results['backup_destination']; // May be empty if file already moved to target location.
|
||||
if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
|
||||
$dir = null;
|
||||
}
|
||||
if ($file && !empty($dir) && $storage !== 0) {
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised, !$config->backup_shortname);
|
||||
// Copy file only if there was no error.
|
||||
if ($file && !empty($dir) && $storage !== 0 && $outcome != self::BACKUP_STATUS_ERROR) {
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised,
|
||||
!$config->backup_shortname);
|
||||
if (!$file->copy_content_to($dir.'/'.$filename)) {
|
||||
$outcome = self::BACKUP_STATUS_ERROR;
|
||||
}
|
||||
@@ -428,6 +444,20 @@ abstract class backup_cron_automated_helper {
|
||||
$outcome = self::BACKUP_STATUS_ERROR;
|
||||
}
|
||||
|
||||
// Delete the backup file immediately if something went wrong.
|
||||
if ($outcome === self::BACKUP_STATUS_ERROR) {
|
||||
|
||||
// Delete the file from file area if exists.
|
||||
if (!empty($file)) {
|
||||
$file->delete();
|
||||
}
|
||||
|
||||
// Delete file from external storage if exists.
|
||||
if ($storage !== 0 && !empty($filename) && file_exists($dir.'/'.$filename)) {
|
||||
@unlink($dir.'/'.$filename);
|
||||
}
|
||||
}
|
||||
|
||||
$bc->destroy();
|
||||
unset($bc);
|
||||
|
||||
@@ -524,7 +554,7 @@ abstract class backup_cron_automated_helper {
|
||||
public static function set_state_running($running = true) {
|
||||
if ($running === true) {
|
||||
if (self::get_automated_backup_state() === self::STATE_RUNNING) {
|
||||
throw new backup_exception('backup_automated_already_running');
|
||||
throw new backup_helper_exception('backup_automated_already_running');
|
||||
}
|
||||
set_config('backup_auto_running', '1', 'backup');
|
||||
} else {
|
||||
|
||||
@@ -60,13 +60,17 @@ abstract class base_plan implements checksumable, executable {
|
||||
$task->set_plan($this);
|
||||
// Append task settings to plan array, if not present, for comodity
|
||||
foreach ($task->get_settings() as $key => $setting) {
|
||||
if (!in_array($setting, $this->settings)) {
|
||||
$name = $setting->get_name();
|
||||
if (!isset($this->settings[$name])) {
|
||||
$this->settings[$name] = $setting;
|
||||
} else {
|
||||
throw new base_plan_exception('multiple_settings_by_name_found', $name);
|
||||
}
|
||||
// Check if there is already a setting for this name.
|
||||
$name = $setting->get_name();
|
||||
if (!isset($this->settings[$name])) {
|
||||
// There is no setting, so add it.
|
||||
$this->settings[$name] = $setting;
|
||||
} else if ($this->settings[$name] != $setting) {
|
||||
// If the setting already exists AND it is not the same setting,
|
||||
// then throw an error. (I.e. you're allowed to add the same
|
||||
// setting twice, but cannot add two different ones with same
|
||||
// name.)
|
||||
throw new base_plan_exception('multiple_settings_by_name_found', $name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
public function backup_details($details, $nextstageurl) {
|
||||
$yestick = $this->output->pix_icon('i/valid', get_string('yes'));
|
||||
$notick = $this->output->pix_icon('i/valid', get_string('no'));
|
||||
$notick = $this->output->pix_icon('i/invalid', get_string('no'));
|
||||
|
||||
$html = html_writer::start_tag('div', array('class'=>'backup-restore'));
|
||||
|
||||
|
||||
@@ -475,8 +475,9 @@ class restore_ui_stage_schema extends restore_ui_stage {
|
||||
if ($this->stageform === null) {
|
||||
$form = new restore_schema_form($this, $PAGE->url);
|
||||
$tasks = $this->ui->get_tasks();
|
||||
$content = '';
|
||||
$courseheading = false;
|
||||
|
||||
$allsettings = array();
|
||||
foreach ($tasks as $task) {
|
||||
if (!($task instanceof restore_root_task)) {
|
||||
if (!$courseheading) {
|
||||
@@ -484,13 +485,11 @@ class restore_ui_stage_schema extends restore_ui_stage {
|
||||
$form->add_heading('coursesettings', get_string('coursesettings', 'backup'));
|
||||
$courseheading = true;
|
||||
}
|
||||
// First add each setting
|
||||
// Put each setting into an array of settings to add. Adding
|
||||
// a setting individually is a very slow operation, so we add
|
||||
// them all in a batch later on.
|
||||
foreach ($task->get_settings() as $setting) {
|
||||
$form->add_setting($setting, $task);
|
||||
}
|
||||
// The add all the dependencies
|
||||
foreach ($task->get_settings() as $setting) {
|
||||
$form->add_dependencies($setting);
|
||||
$allsettings[] = array($setting, $task);
|
||||
}
|
||||
} else if ($this->ui->enforce_changed_dependencies()) {
|
||||
// Only show these settings if dependencies changed them.
|
||||
@@ -505,6 +504,15 @@ class restore_ui_stage_schema extends restore_ui_stage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actually add all the settings that we put in the array.
|
||||
$form->add_settings($allsettings);
|
||||
|
||||
// Add the dependencies for all the settings.
|
||||
foreach ($allsettings as $settingtask) {
|
||||
$form->add_dependencies($settingtask[0]);
|
||||
}
|
||||
|
||||
$this->stageform = $form;
|
||||
}
|
||||
return $this->stageform;
|
||||
|
||||
@@ -130,7 +130,7 @@ $communityid = optional_param('communityid', '', PARAM_INT);
|
||||
if ($remove != -1 and !empty($communityid) and confirm_sesskey()) {
|
||||
$communitymanager->block_community_remove_course($communityid, $USER->id);
|
||||
echo $OUTPUT->header();
|
||||
echo $renderer->remove_success(new moodle_url(get_referer(false)));
|
||||
echo $renderer->remove_success(new moodle_url('/course/view.php', array('id' => $courseid)));
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class block_community_manager {
|
||||
$community = $this->block_community_get_course($course->url, $userid);
|
||||
|
||||
if (empty($community)) {
|
||||
$community = new stdClass();
|
||||
$community->userid = $userid;
|
||||
$community->coursename = $course->name;
|
||||
$community->coursedescription = $course->description;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/* RSS Feeds
|
||||
-------------------------*/
|
||||
.block_rss_client .list li:first-child {
|
||||
border-top-width: 0;
|
||||
}
|
||||
.block_rss_client .list li {
|
||||
border-top: 1px solid;
|
||||
padding: 5px;
|
||||
}
|
||||
@@ -110,12 +110,12 @@ class block_tags extends block_base {
|
||||
$content = '';
|
||||
$moretags = new moodle_url('/tag/coursetags_more.php', array('show'=>$tagtype));
|
||||
if ($tagtype == 'all') {
|
||||
$tags = coursetag_get_tags(0, 0, $this->config->tagtype, $this->config->numberoftags, 'name');
|
||||
$tags = coursetag_get_tags(0, 0, $this->config->tagtype, $this->config->numberoftags);
|
||||
} else if ($tagtype == 'course') {
|
||||
$tags = coursetag_get_tags($this->page->course->id, 0, $this->config->tagtype, $this->config->numberoftags, 'name');
|
||||
$tags = coursetag_get_tags($this->page->course->id, 0, $this->config->tagtype, $this->config->numberoftags);
|
||||
$moretags->param('courseid', $this->page->course->id);
|
||||
} else if ($tagtype == 'my') {
|
||||
$tags = coursetag_get_tags(0, $USER->id, $this->config->tagtype, $this->config->numberoftags, 'name');
|
||||
$tags = coursetag_get_tags(0, $USER->id, $this->config->tagtype, $this->config->numberoftags);
|
||||
}
|
||||
$tagcloud = tag_print_cloud($tags, 150, true);
|
||||
if (!$tagcloud) {
|
||||
|
||||
@@ -120,6 +120,7 @@ if ($action === 'delete'){
|
||||
print_error('nopermissionstodeleteentry', 'blog');
|
||||
} else {
|
||||
$entry->delete();
|
||||
blog_rss_delete_file($userid);
|
||||
redirect($returnurl);
|
||||
}
|
||||
} else if (blog_user_can_edit_entry($entry)) {
|
||||
|
||||
@@ -330,3 +330,17 @@ function blog_rss_save_file($type, $id, $tagid=0, $contents='') {
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the supplied user's cached blog post RSS feed.
|
||||
* Only user blogs are available by RSS.
|
||||
* This doesn't call rss_delete_file() as blog RSS caching uses it's own file structure.
|
||||
*
|
||||
* @param int $userid
|
||||
*/
|
||||
function blog_rss_delete_file($userid) {
|
||||
$filename = blog_rss_file_name('user', $userid);
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+7
-8
@@ -24,8 +24,8 @@ A definition:
|
||||
'overrideclassfile' => null, // Optional
|
||||
'datasource' => null, // Optional
|
||||
'datasourcefile' => null, // Optional
|
||||
'persistent' => false, // Optional
|
||||
'persistentmaxsize' => false, // Optional
|
||||
'staticacceleration' => false, // Optional
|
||||
'staticaccelerationsize' => false, // Optional
|
||||
'ttl' => 0, // Optional
|
||||
'mappingsonly' => false // Optional
|
||||
'invalidationevents' => array( // Optional
|
||||
@@ -142,19 +142,18 @@ The following optional settings can also be defined:
|
||||
* overrideclassfile - Included if required when using the overrideclass param.
|
||||
* datasource - If provided this class will be used as a data source for the definition. It must implement the cache_data_source interface.
|
||||
* datasourcefile - Included if required when using the datasource param.
|
||||
* persistent - If set to true the loader will be stored when first created and provided to subsequent requests. More on this later.
|
||||
* persistentmaxsize - If set to an int this will be the maximum number of items stored in the persistent cache.
|
||||
* staticacceleration - Any data passing through the cache will be held onto to make subsequent requests for it faster.
|
||||
* staticaccelerationsize - If set to an int this will be the maximum number of items stored in the static acceleration array.
|
||||
* ttl - Can be used to set a ttl value for data being set for this cache.
|
||||
* mappingsonly - This definition can only be used if there is a store mapping for it. More on this later.
|
||||
* invalidationevents - An array of events that should trigger this cache to invalidate.
|
||||
|
||||
It's important to note that internally the definition is also aware of the component. This is picked up when the definition is read, based upon the location of the caches.php file.
|
||||
|
||||
The persist option.
|
||||
As noted the persist option causes the loader generated for this definition to be stored when first created. Subsequent requests for this definition will be given the original loader instance.
|
||||
The staticacceleration option.
|
||||
Data passed to or retrieved from the loader and its chained loaders gets cached by the instance.
|
||||
This option should be used when you know you will require the loader several times and perhaps in different areas of code.
|
||||
Because it caches key=>value data it avoids the need to re-fetch things from stores after the first request. Its good for performance, bad for memory.
|
||||
Memory use can be controlled by setting the staticaccelerationsize option.
|
||||
It should be used sparingly.
|
||||
|
||||
The mappingsonly option.
|
||||
@@ -227,4 +226,4 @@ Cache information can be invalidated in two ways.
|
||||
The first method is designed to be used when you have a single known definition you want to invalidate entries within.
|
||||
The second method is a lot more intensive for the system. There are defined invalidation events that definitions can "subscribe" to (through the definitions invalidationevents option).
|
||||
When you invalidate by event the cache API finds all of the definitions that subscribe to the event, it then loads the stores for each of those definitions and purges the keys from each store.
|
||||
This is obviously a recursive, and therefore, intense process.
|
||||
This is obviously a recursive, and therefore, intense process.
|
||||
|
||||
Vendored
+74
-28
@@ -75,19 +75,14 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* [string] A class to use as the data loader for this definition.
|
||||
* Any class used here must inherit the cache_data_loader interface.
|
||||
* + datasourcefile
|
||||
* [string] Suplements the above setting indicated the file containing the class to be used. This file is included when
|
||||
* [string] Supplements the above setting indicating the file containing the class to be used. This file is included when
|
||||
* required.
|
||||
* + persistent
|
||||
* [bool] This setting does two important things. First it tells the cache API to only instantiate the cache structure for
|
||||
* this definition once, further requests will be given the original instance.
|
||||
* Second the cache loader will keep an array of the items set and retrieved to the cache during the request.
|
||||
* This has several advantages including better performance without needing to start passing the cache instance between
|
||||
* function calls, the downside is that the cache instance + the items used stay within memory.
|
||||
* Consider using this setting when you know that there are going to be many calls to the cache for the same information
|
||||
* or when you are converting existing code to the cache and need to access the cache within functions but don't want
|
||||
* to add it as an argument to the function.
|
||||
* + persistentmaxsize
|
||||
* [int] This supplements the above setting by limiting the number of items in the caches persistent array of items.
|
||||
* + staticacceleration
|
||||
* The cache loader will keep an array of the items set and retrieved to the cache during the request.
|
||||
* Consider using this setting when you know that there are going to be many calls to the cache for the same information.
|
||||
* Requests for data in this array will be ultra fast, but it will cost memory.
|
||||
* + staticaccelerationsize
|
||||
* [int] This supplements the above setting by limiting the number of items in the static acceleration array.
|
||||
* Tweaking this setting lower will allow you to minimise the memory implications above while hopefully still managing to
|
||||
* offset calls to the cache store.
|
||||
* + ttl
|
||||
@@ -228,16 +223,16 @@ class cache_definition {
|
||||
protected $datasourceaggregate = null;
|
||||
|
||||
/**
|
||||
* Set to true if the definitions cache should be persistent
|
||||
* Set to true if the cache should hold onto items passing through it to speed up subsequent requests.
|
||||
* @var bool
|
||||
*/
|
||||
protected $persistent = false;
|
||||
protected $staticacceleration = false;
|
||||
|
||||
/**
|
||||
* The persistent item array max size.
|
||||
* The maximum number of items that static acceleration cache should hold onto.
|
||||
* @var int
|
||||
*/
|
||||
protected $persistentmaxsize = false;
|
||||
protected $staticaccelerationsize = false;
|
||||
|
||||
/**
|
||||
* The TTL for data in this cache. Please don't use this, instead use event driven invalidation.
|
||||
@@ -320,8 +315,8 @@ class cache_definition {
|
||||
$overrideclassfile = null;
|
||||
$datasource = null;
|
||||
$datasourcefile = null;
|
||||
$persistent = false;
|
||||
$persistentmaxsize = false;
|
||||
$staticacceleration = false;
|
||||
$staticaccelerationsize = false;
|
||||
$ttl = 0;
|
||||
$mappingsonly = false;
|
||||
$invalidationevents = array();
|
||||
@@ -373,10 +368,18 @@ class cache_definition {
|
||||
}
|
||||
|
||||
if (array_key_exists('persistent', $definition)) {
|
||||
$persistent = (bool)$definition['persistent'];
|
||||
// Ahhh this is the legacy persistent option.
|
||||
$staticacceleration = (bool)$definition['persistent'];
|
||||
}
|
||||
if (array_key_exists('staticacceleration', $definition)) {
|
||||
$staticacceleration = (bool)$definition['staticacceleration'];
|
||||
}
|
||||
if (array_key_exists('persistentmaxsize', $definition)) {
|
||||
$persistentmaxsize = (int)$definition['persistentmaxsize'];
|
||||
// Ahhh this is the legacy persistentmaxsize option.
|
||||
$staticaccelerationsize = (int)$definition['persistentmaxsize'];
|
||||
}
|
||||
if (array_key_exists('staticaccelerationsize', $definition)) {
|
||||
$staticaccelerationsize = (int)$definition['staticaccelerationsize'];
|
||||
}
|
||||
if (array_key_exists('ttl', $definition)) {
|
||||
$ttl = (int)$definition['ttl'];
|
||||
@@ -452,8 +455,8 @@ class cache_definition {
|
||||
$cachedefinition->datasource = $datasource;
|
||||
$cachedefinition->datasourcefile = $datasourcefile;
|
||||
$cachedefinition->datasourceaggregate = $datasourceaggregate;
|
||||
$cachedefinition->persistent = $persistent;
|
||||
$cachedefinition->persistentmaxsize = $persistentmaxsize;
|
||||
$cachedefinition->staticacceleration = $staticacceleration;
|
||||
$cachedefinition->staticaccelerationsize = $staticaccelerationsize;
|
||||
$cachedefinition->ttl = $ttl;
|
||||
$cachedefinition->mappingsonly = $mappingsonly;
|
||||
$cachedefinition->invalidationevents = $invalidationevents;
|
||||
@@ -474,7 +477,8 @@ class cache_definition {
|
||||
* - simplekeys : Set to true if the keys you will use are a-zA-Z0-9_
|
||||
* - simpledata : Set to true if the type of the data you are going to store is scalar, or an array of scalar vars
|
||||
* - overrideclass : The class to use as the loader.
|
||||
* - persistent : If set to true the cache will persist construction requests.
|
||||
* - staticacceleration : If set to true the cache will hold onto data passing through it.
|
||||
* - staticaccelerationsize : Set it to an int to limit the size of the staticacceleration cache.
|
||||
* @return cache_application|cache_session|cache_request
|
||||
*/
|
||||
public static function load_adhoc($mode, $component, $area, array $options = array()) {
|
||||
@@ -491,7 +495,14 @@ class cache_definition {
|
||||
$definition['simpledata'] = $options['simpledata'];
|
||||
}
|
||||
if (!empty($options['persistent'])) {
|
||||
$definition['persistent'] = $options['persistent'];
|
||||
// Ahhh this is the legacy persistent option.
|
||||
$definition['staticacceleration'] = (bool)$options['persistent'];
|
||||
}
|
||||
if (!empty($options['staticacceleration'])) {
|
||||
$definition['staticacceleration'] = (bool)$options['staticacceleration'];
|
||||
}
|
||||
if (!empty($options['staticaccelerationsize'])) {
|
||||
$definition['staticaccelerationsize'] = (int)$options['staticaccelerationsize'];
|
||||
}
|
||||
if (!empty($options['overrideclass'])) {
|
||||
$definition['overrideclass'] = $options['overrideclass'];
|
||||
@@ -716,18 +727,53 @@ class cache_definition {
|
||||
|
||||
/**
|
||||
* Returns true if this definitions cache should be made persistent.
|
||||
*
|
||||
* Please call {@link cache_definition::use_static_acceleration()} instead.
|
||||
*
|
||||
* @deprecated since 2.4.7
|
||||
* @return bool
|
||||
*/
|
||||
public function should_be_persistent() {
|
||||
return $this->persistent || $this->mode === cache_store::MODE_SESSION;
|
||||
debugging('Please upgrade your code to use cache_definition::use_static_acceleration', DEBUG_DEVELOPER);
|
||||
return $this->use_static_acceleration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max size for the persistent item array in the cache.
|
||||
* Returns true if we should hold onto the data flowing through the cache.
|
||||
*
|
||||
* If set to true data flowing through the cache will be stored in a static variable
|
||||
* to make subsequent requests for the data much faster.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function use_static_acceleration() {
|
||||
if ($this->mode === cache_store::MODE_REQUEST) {
|
||||
// Request caches should never use static acceleration - it just doesn't make sense.
|
||||
return false;
|
||||
}
|
||||
return $this->staticacceleration || $this->mode === cache_store::MODE_SESSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max size for the static acceleration array.
|
||||
*
|
||||
* Please call {@link cache_definition::get_static_acceleration_size()} instead.
|
||||
*
|
||||
* @see cache_definition::get_static_acceleration_size()
|
||||
* @deprecated since 2.4.7
|
||||
* @return int
|
||||
*/
|
||||
public function get_persistent_max_size() {
|
||||
return $this->persistentmaxsize;
|
||||
debugging('Please upgrade your code to call cache_definition::get_static_acceleration_size', DEBUG_DEVELOPER);
|
||||
return $this->get_static_acceleration_size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max size for the static acceleration array.
|
||||
* @return int
|
||||
*/
|
||||
public function get_static_acceleration_size() {
|
||||
return $this->staticaccelerationsize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -821,4 +867,4 @@ class cache_definition {
|
||||
protected function get_cache_identifier() {
|
||||
return cache_helper::get_site_identifier();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+9
-8
@@ -46,14 +46,15 @@ class cachestore_dummy extends cache_store {
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Gets set to true if this store is going to persist data.
|
||||
* This happens when the definition doesn't require it as the loader will not be persisting information and something has to.
|
||||
* Gets set to true if this store is going to store data.
|
||||
* This happens when the definition doesn't require static acceleration as the loader will not be storing information and
|
||||
* something has to.
|
||||
* @var bool
|
||||
*/
|
||||
protected $persist = false;
|
||||
|
||||
/**
|
||||
* The persistent store array
|
||||
* The stored data array
|
||||
* @var array
|
||||
*/
|
||||
protected $store = array();
|
||||
@@ -106,13 +107,13 @@ class cachestore_dummy extends cache_store {
|
||||
* @param cache_definition $definition
|
||||
*/
|
||||
public function initialise(cache_definition $definition) {
|
||||
// If the definition isn't persistent then we need to be persistent here.
|
||||
// If the definition isn't using static acceleration then we need to be store data here.
|
||||
// The reasoning behind this is that:
|
||||
// - If the definition is persistent then the cache loader is going to
|
||||
// store things in its persistent cache.
|
||||
// - If the definition is not persistent then the cache loader won't try to store anything
|
||||
// - If the definition is using static acceleration then the cache loader is going to
|
||||
// store things in its static array.
|
||||
// - If the definition is not using static acceleration then the cache loader won't try to store anything
|
||||
// and we will need to store it here in order to make sure it is accessible.
|
||||
$this->persist = !$definition->should_be_persistent();
|
||||
$this->persist = !$definition->use_static_acceleration();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+29
-10
@@ -150,9 +150,7 @@ class cache_factory {
|
||||
*/
|
||||
public static function reset() {
|
||||
$factory = self::instance();
|
||||
$factory->cachesfromdefinitions = array();
|
||||
$factory->cachesfromparams = array();
|
||||
$factory->stores = array();
|
||||
$factory->reset_cache_instances();
|
||||
$factory->configs = array();
|
||||
$factory->definitions = array();
|
||||
$factory->lockplugins = array(); // MUST be null in order to force its regeneration.
|
||||
@@ -160,6 +158,18 @@ class cache_factory {
|
||||
$factory->state = self::STATE_UNINITIALISED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the stores, clearing the array of created stores.
|
||||
*
|
||||
* Cache objects still held onto by the code that initialised them will remain as is
|
||||
* however all future requests for a cache/store will lead to a new instance being re-initialised.
|
||||
*/
|
||||
public function reset_cache_instances() {
|
||||
$this->cachesfromdefinitions = array();
|
||||
$this->cachesfromparams = array();
|
||||
$this->stores = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cache object given the parameters for a definition.
|
||||
*
|
||||
@@ -181,9 +191,8 @@ class cache_factory {
|
||||
$definition = $this->create_definition($component, $area, $aggregate);
|
||||
$definition->set_identifiers($identifiers);
|
||||
$cache = $this->create_cache($definition, $identifiers);
|
||||
if ($definition->should_be_persistent()) {
|
||||
$this->cachesfromdefinitions[$definitionname] = $cache;
|
||||
}
|
||||
// Loaders are always held onto to speed up subsequent requests.
|
||||
$this->cachesfromdefinitions[$definitionname] = $cache;
|
||||
return $cache;
|
||||
}
|
||||
|
||||
@@ -199,7 +208,8 @@ class cache_factory {
|
||||
* @param array $options An array of options, available options are:
|
||||
* - simplekeys : Set to true if the keys you will use are a-zA-Z0-9_
|
||||
* - simpledata : Set to true if the type of the data you are going to store is scalar, or an array of scalar vars
|
||||
* - persistent : If set to true the cache will persist construction requests.
|
||||
* - staticacceleration : If set to true the cache will hold onto data passing through it.
|
||||
* - staticaccelerationsize : The maximum number of items to hold onto for acceleration purposes.
|
||||
* @return cache_application|cache_session|cache_request
|
||||
*/
|
||||
public function create_cache_from_params($mode, $component, $area, array $identifiers = array(), array $options = array()) {
|
||||
@@ -210,9 +220,7 @@ class cache_factory {
|
||||
$definition = cache_definition::load_adhoc($mode, $component, $area, $options);
|
||||
$definition->set_identifiers($identifiers);
|
||||
$cache = $this->create_cache($definition, $identifiers);
|
||||
if ($definition->should_be_persistent()) {
|
||||
$this->cachesfromparams[$key] = $cache;
|
||||
}
|
||||
$this->cachesfromparams[$key] = $cache;
|
||||
return $cache;
|
||||
}
|
||||
|
||||
@@ -297,6 +305,15 @@ class cache_factory {
|
||||
return $this->definitionstores[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cache instances that have been used within this request.
|
||||
* @since 2.4.7
|
||||
* @return array
|
||||
*/
|
||||
public function get_caches_in_use() {
|
||||
return $this->cachesfromdefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cache config instance with the ability to write if required.
|
||||
*
|
||||
@@ -585,7 +602,9 @@ class cache_factory {
|
||||
* </code>
|
||||
*/
|
||||
public static function disable_stores() {
|
||||
// First reset to clear any static acceleration array.
|
||||
$factory = self::instance();
|
||||
$factory->reset_cache_instances();
|
||||
$factory->set_state(self::STATE_STORES_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+27
-20
@@ -238,19 +238,24 @@ class cache_helper {
|
||||
$instance = cache_config::instance();
|
||||
$invalidationeventset = false;
|
||||
$factory = cache_factory::instance();
|
||||
$inuse = $factory->get_caches_in_use();
|
||||
foreach ($instance->get_definitions() as $name => $definitionarr) {
|
||||
$definition = cache_definition::load($name, $definitionarr);
|
||||
if ($definition->invalidates_on_event($event)) {
|
||||
// OK at this point we know that the definition has information to invalidate on the event.
|
||||
// There are two routes, either its an application cache in which case we can invalidate it now.
|
||||
// or it is a persistent cache that also needs to be invalidated now.
|
||||
if ($definition->get_mode() === cache_store::MODE_APPLICATION || $definition->should_be_persistent()) {
|
||||
$cache = $factory->create_cache_from_definition($definition->get_component(), $definition->get_area());
|
||||
$cache->delete_many($keys);
|
||||
// First up check if there is a cache loader for this definition already.
|
||||
// If there is we need to invalidate the keys from there.
|
||||
$definitionkey = $definition->get_component().'/'.$definition->get_area();
|
||||
if (isset($inuse[$definitionkey])) {
|
||||
$inuse[$definitionkey]->delete_many($keys);
|
||||
}
|
||||
|
||||
// We need to flag the event in the "Event invalidation" cache if it hasn't already happened.
|
||||
if ($invalidationeventset === false) {
|
||||
// We should only log events for application and session caches.
|
||||
// Request caches shouldn't have events as all data is lost at the end of the request.
|
||||
// Events should only be logged once of course and likely several definitions are watching so we
|
||||
// track its logging with $invalidationeventset.
|
||||
$logevent = ($invalidationeventset === false && $definition->get_mode() !== cache_store::MODE_REQUEST);
|
||||
|
||||
if ($logevent) {
|
||||
// Get the event invalidation cache.
|
||||
$cache = cache::make('core', 'eventinvalidation');
|
||||
// Get any existing invalidated keys for this cache.
|
||||
@@ -307,23 +312,25 @@ class cache_helper {
|
||||
$instance = cache_config::instance();
|
||||
$invalidationeventset = false;
|
||||
$factory = cache_factory::instance();
|
||||
$inuse = $factory->get_caches_in_use();
|
||||
foreach ($instance->get_definitions() as $name => $definitionarr) {
|
||||
$definition = cache_definition::load($name, $definitionarr);
|
||||
if ($definition->invalidates_on_event($event)) {
|
||||
// Check if this definition would result in a persistent loader being in use.
|
||||
if ($definition->should_be_persistent()) {
|
||||
// There may be a persistent cache loader. Lets purge that first so that any persistent data is removed.
|
||||
$cache = $factory->create_cache_from_definition($definition->get_component(), $definition->get_area());
|
||||
$cache->purge();
|
||||
}
|
||||
// Get all of the store instances that are in use for this store.
|
||||
$stores = $factory->get_store_instances_in_use($definition);
|
||||
foreach ($stores as $store) {
|
||||
// Purge each store individually.
|
||||
$store->purge();
|
||||
// First up check if there is a cache loader for this definition already.
|
||||
// If there is we need to invalidate the keys from there.
|
||||
$definitionkey = $definition->get_component().'/'.$definition->get_area();
|
||||
if (isset($inuse[$definitionkey])) {
|
||||
$inuse[$definitionkey]->purge();
|
||||
}
|
||||
|
||||
// We should only log events for application and session caches.
|
||||
// Request caches shouldn't have events as all data is lost at the end of the request.
|
||||
// Events should only be logged once of course and likely several definitions are watching so we
|
||||
// track its logging with $invalidationeventset.
|
||||
$logevent = ($invalidationeventset === false && $definition->get_mode() !== cache_store::MODE_REQUEST);
|
||||
|
||||
// We need to flag the event in the "Event invalidation" cache if it hasn't already happened.
|
||||
if ($invalidationeventset === false) {
|
||||
if ($logevent && $invalidationeventset === false) {
|
||||
// Get the event invalidation cache.
|
||||
$cache = cache::make('core', 'eventinvalidation');
|
||||
// Create a key to invalidate all.
|
||||
|
||||
Vendored
+83
-68
@@ -93,43 +93,46 @@ class cache implements cache_loader {
|
||||
private $supportsnativettl = null;
|
||||
|
||||
/**
|
||||
* Gets set to true if the cache is going to be using the build in static "persist" cache.
|
||||
* The persist cache statically caches items used during the lifetime of the request. This greatly speeds up interaction
|
||||
* Gets set to true if the cache is going to be using a static array for acceleration.
|
||||
* The array statically caches items used during the lifetime of the request. This greatly speeds up interaction
|
||||
* with the cache in areas where it will be repetitively hit for the same information such as with strings.
|
||||
* There are several other variables to control how this persist cache works.
|
||||
* There are several other variables to control how this static acceleration array works.
|
||||
* @var bool
|
||||
*/
|
||||
private $persist = false;
|
||||
private $staticacceleration = false;
|
||||
|
||||
/**
|
||||
* The persist cache itself.
|
||||
* The static acceleration array.
|
||||
* Items will be stored in this cache as they were provided. This ensure there is no unnecessary processing taking place.
|
||||
* @var array
|
||||
*/
|
||||
private $persistcache = array();
|
||||
private $staticaccelerationarray = array();
|
||||
|
||||
/**
|
||||
* The number of items in the persist cache. Avoids count calls like you wouldn't believe.
|
||||
* The number of items in the static acceleration array. Avoids count calls like you wouldn't believe.
|
||||
* @var int
|
||||
*/
|
||||
private $persistcount = 0;
|
||||
private $staticaccelerationcount = 0;
|
||||
|
||||
/**
|
||||
* An array containing just the keys being used in the persist cache.
|
||||
* This seems redundant perhaps but is used when managing the size of the persist cache.
|
||||
* An array containing just the keys being used in the static acceleration array.
|
||||
* This seems redundant perhaps but is used when managing the size of the static acceleration array.
|
||||
* Items are added to the end of the array and the when we need to reduce the size of the cache we use the
|
||||
* key that is first on this array.
|
||||
* @var array
|
||||
*/
|
||||
private $persistkeys = array();
|
||||
private $staticaccelerationkeys = array();
|
||||
|
||||
/**
|
||||
* The maximum size of the persist cache. If set to false there is no max size.
|
||||
* Caches that make use of the persist cache should seriously consider setting this to something reasonably small, but
|
||||
* The maximum size of the static acceleration array.
|
||||
*
|
||||
* If set to false there is no max size.
|
||||
* Caches that make use of static acceleration should seriously consider setting this to something reasonably small, but
|
||||
* still large enough to offset repetitive calls.
|
||||
*
|
||||
* @var int|false
|
||||
*/
|
||||
private $persistmaxsize = false;
|
||||
private $staticaccelerationsize = false;
|
||||
|
||||
/**
|
||||
* Gets set to true during initialisation if the definition is making use of a ttl.
|
||||
@@ -181,7 +184,8 @@ class cache implements cache_loader {
|
||||
* @param array $options An array of options, available options are:
|
||||
* - simplekeys : Set to true if the keys you will use are a-zA-Z0-9_
|
||||
* - simpledata : Set to true if the type of the data you are going to store is scalar, or an array of scalar vars
|
||||
* - persistent : If set to true the cache will persist construction requests.
|
||||
* - staticacceleration : If set to true the cache will hold onto data passing through it.
|
||||
* - staticaccelerationsize : The max size for the static acceleration array.
|
||||
* @return cache_application|cache_session|cache_store
|
||||
*/
|
||||
public static function make_from_params($mode, $component, $area, array $identifiers = array(), array $options = array()) {
|
||||
@@ -218,9 +222,9 @@ class cache implements cache_loader {
|
||||
$this->datasource = $loader;
|
||||
}
|
||||
$this->definition->generate_definition_hash();
|
||||
$this->persist = $this->definition->should_be_persistent();
|
||||
if ($this->persist) {
|
||||
$this->persistmaxsize = $this->definition->get_persistent_max_size();
|
||||
$this->staticacceleration = $this->definition->use_static_acceleration();
|
||||
if ($this->staticacceleration) {
|
||||
$this->staticaccelerationsize = $this->definition->get_static_acceleration_size();
|
||||
}
|
||||
$this->hasattl = ($this->definition->get_ttl() > 0);
|
||||
}
|
||||
@@ -228,7 +232,7 @@ class cache implements cache_loader {
|
||||
/**
|
||||
* Used to inform the loader of its state as a sub loader, or as the top of the chain.
|
||||
*
|
||||
* This is important as it ensures that we do not have more than one loader keeping persistent data.
|
||||
* This is important as it ensures that we do not have more than one loader keeping static acceleration data.
|
||||
* Subloaders need to be "pure" loaders in the sense that they are used to store and retrieve information from stores or the
|
||||
* next loader/data source in the chain.
|
||||
* Nothing fancy, nothing flash.
|
||||
@@ -238,14 +242,14 @@ class cache implements cache_loader {
|
||||
protected function set_is_sub_loader($setting = true) {
|
||||
if ($setting) {
|
||||
$this->subloader = true;
|
||||
// Subloaders should not keep persistent data.
|
||||
$this->persist = false;
|
||||
$this->persistmaxsize = false;
|
||||
// Subloaders should not keep static acceleration data.
|
||||
$this->staticacceleration = false;
|
||||
$this->staticaccelerationsize = false;
|
||||
} else {
|
||||
$this->subloader = true;
|
||||
$this->persist = $this->definition->should_be_persistent();
|
||||
if ($this->persist) {
|
||||
$this->persistmaxsize = $this->definition->get_persistent_max_size();
|
||||
$this->staticacceleration = $this->definition->use_static_acceleration();
|
||||
if ($this->staticacceleration) {
|
||||
$this->staticaccelerationsize = $this->definition->get_static_acceleration_size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +280,7 @@ class cache implements cache_loader {
|
||||
public function get($key, $strictness = IGNORE_MISSING) {
|
||||
// 1. Parse the key.
|
||||
$parsedkey = $this->parse_key($key);
|
||||
// 2. Get it from the persist cache if we can (only when persist is enabled and it has already been requested/set).
|
||||
// 2. Get it from the static acceleration array if we can (only when it is enabled and it has already been requested/set).
|
||||
$result = false;
|
||||
if ($this->is_using_persist_cache()) {
|
||||
$result = $this->get_from_persist_cache($parsedkey);
|
||||
@@ -291,7 +295,7 @@ class cache implements cache_loader {
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 3. Get it from the store. Obviously wasn't in the persist cache.
|
||||
// 3. Get it from the store. Obviously wasn't in the static acceleration array.
|
||||
$result = $this->store->get($parsedkey);
|
||||
if ($result !== false) {
|
||||
if ($result instanceof cache_ttl_wrapper) {
|
||||
@@ -404,6 +408,9 @@ class cache implements cache_loader {
|
||||
if ($value instanceof cache_cached_object) {
|
||||
$value = $value->restore_object();
|
||||
}
|
||||
if ($value !== false && $this->is_using_persist_cache()) {
|
||||
$this->set_in_persist_cache($key, $value);
|
||||
}
|
||||
$resultstore[$key] = $value;
|
||||
}
|
||||
}
|
||||
@@ -604,7 +611,7 @@ class cache implements cache_loader {
|
||||
}
|
||||
$data = array();
|
||||
$simulatettl = $this->has_a_ttl() && !$this->store_supports_native_ttl();
|
||||
$usepersistcache = $this->is_using_persist_cache();
|
||||
$usestaticaccelerationarray = $this->is_using_persist_cache();
|
||||
foreach ($keyvaluearray as $key => $value) {
|
||||
if (is_object($value) && $value instanceof cacheable_object) {
|
||||
$value = new cache_cached_object($value);
|
||||
@@ -622,7 +629,7 @@ class cache implements cache_loader {
|
||||
'key' => $this->parse_key($key),
|
||||
'value' => $value
|
||||
);
|
||||
if ($usepersistcache) {
|
||||
if ($usestaticaccelerationarray) {
|
||||
$this->set_in_persist_cache($data[$key]['key'], $value);
|
||||
}
|
||||
}
|
||||
@@ -656,7 +663,7 @@ class cache implements cache_loader {
|
||||
public function has($key, $tryloadifpossible = false) {
|
||||
$parsedkey = $this->parse_key($key);
|
||||
if ($this->is_in_persist_cache($parsedkey)) {
|
||||
// Hoorah, that was easy. It exists in the persist cache so we definitely have it.
|
||||
// Hoorah, that was easy. It exists in the static acceleration array so we definitely have it.
|
||||
return true;
|
||||
}
|
||||
if ($this->has_a_ttl() && !$this->store_supports_native_ttl()) {
|
||||
@@ -798,8 +805,12 @@ class cache implements cache_loader {
|
||||
* @return bool True on success, false otherwise
|
||||
*/
|
||||
public function purge() {
|
||||
// 1. Purge the persist cache.
|
||||
$this->persistcache = array();
|
||||
// 1. Purge the static acceleration array.
|
||||
$this->staticaccelerationarray = array();
|
||||
if ($this->staticaccelerationsize !== false) {
|
||||
$this->staticaccelerationkeys = array();
|
||||
$this->staticaccelerationcount = 0;
|
||||
}
|
||||
// 2. Purge the store.
|
||||
$this->store->purge();
|
||||
// 3. Optionally pruge any stacked loaders.
|
||||
@@ -908,16 +919,16 @@ class cache implements cache_loader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this cache is making use of the persist cache.
|
||||
* Returns true if this cache is making use of the static acceleration array.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_using_persist_cache() {
|
||||
return $this->persist;
|
||||
return $this->staticacceleration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the requested key exists within the persist cache.
|
||||
* Returns true if the requested key exists within the static acceleration array.
|
||||
*
|
||||
* @param string $key The parsed key
|
||||
* @return bool
|
||||
@@ -929,20 +940,21 @@ class cache implements cache_loader {
|
||||
}
|
||||
// This could be written as a single line, however it has been split because the ttl check is faster than the instanceof
|
||||
// and has_expired calls.
|
||||
if (!$this->persist || !array_key_exists($key, $this->persistcache)) {
|
||||
if (!$this->staticacceleration || !array_key_exists($key, $this->staticaccelerationarray)) {
|
||||
return false;
|
||||
}
|
||||
if ($this->has_a_ttl() && $this->store_supports_native_ttl()) {
|
||||
return !($this->persistcache[$key] instanceof cache_ttl_wrapper && $this->persistcache[$key]->has_expired());
|
||||
return !($this->staticaccelerationarray[$key] instanceof cache_ttl_wrapper &&
|
||||
$this->staticaccelerationarray[$key]->has_expired());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the item from the persist cache if it exists there.
|
||||
* Returns the item from the static acceleration array if it exists there.
|
||||
*
|
||||
* @param string $key The parsed key
|
||||
* @return mixed|false The data from the persist cache or false if it wasn't there.
|
||||
* @return mixed|false The data from the static acceleration array or false if it wasn't there.
|
||||
*/
|
||||
protected function get_from_persist_cache($key) {
|
||||
// This method of checking if an array was supplied is faster than is_array.
|
||||
@@ -951,12 +963,12 @@ class cache implements cache_loader {
|
||||
}
|
||||
// This isset check is faster than array_key_exists but will return false
|
||||
// for null values, meaning null values will come from backing store not
|
||||
// the persist cache. We think this okay because null usage should be
|
||||
// the static acceleration array. We think this okay because null usage should be
|
||||
// very rare (see comment in MDL-39472).
|
||||
if (!$this->persist || !isset($this->persistcache[$key])) {
|
||||
if (!$this->staticacceleration || !isset($this->staticaccelerationarray[$key])) {
|
||||
$result = false;
|
||||
} else {
|
||||
$data = $this->persistcache[$key];
|
||||
$data = $this->staticaccelerationarray[$key];
|
||||
if (!$this->has_a_ttl() || !$data instanceof cache_ttl_wrapper) {
|
||||
if ($data instanceof cache_cached_object) {
|
||||
$data = $data->restore_object();
|
||||
@@ -974,28 +986,28 @@ class cache implements cache_loader {
|
||||
}
|
||||
if ($result) {
|
||||
if ($this->perfdebug) {
|
||||
cache_helper::record_cache_hit('** static persist **', $this->definition->get_id());
|
||||
cache_helper::record_cache_hit('** static acceleration **', $this->definition->get_id());
|
||||
}
|
||||
if ($this->persistmaxsize > 1 && $this->persistcount > 1) {
|
||||
// Check to see if this is the last item on the persist keys array.
|
||||
if (end($this->persistkeys) !== $key) {
|
||||
if ($this->staticaccelerationsize > 1 && $this->staticaccelerationcount > 1) {
|
||||
// Check to see if this is the last item on the static acceleration keys array.
|
||||
if (end($this->staticaccelerationkeys) !== $key) {
|
||||
// It isn't the last item.
|
||||
// Move the item to the end of the array so that it is last to be removed.
|
||||
unset($this->persistkeys[$key]);
|
||||
$this->persistkeys[$key] = $key;
|
||||
unset($this->staticaccelerationkeys[$key]);
|
||||
$this->staticaccelerationkeys[$key] = $key;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} else {
|
||||
if ($this->perfdebug) {
|
||||
cache_helper::record_cache_miss('** static persist **', $this->definition->get_id());
|
||||
cache_helper::record_cache_miss('** static acceleration **', $this->definition->get_id());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a key value pair into the persist cache.
|
||||
* Sets a key value pair into the static acceleration array.
|
||||
*
|
||||
* @param string $key The parsed key
|
||||
* @param mixed $data
|
||||
@@ -1006,32 +1018,36 @@ class cache implements cache_loader {
|
||||
if ($key === (array)$key) {
|
||||
$key = $key['key'];
|
||||
}
|
||||
$this->persistcache[$key] = $data;
|
||||
if ($this->persistmaxsize !== false) {
|
||||
$this->persistcount++;
|
||||
$this->persistkeys[$key] = $key;
|
||||
if ($this->persistcount > $this->persistmaxsize) {
|
||||
$dropkey = array_shift($this->persistkeys);
|
||||
unset($this->persistcache[$dropkey]);
|
||||
$this->persistcount--;
|
||||
if ($this->staticaccelerationsize !== false && isset($this->staticaccelerationkeys[$key])) {
|
||||
$this->staticaccelerationcount--;
|
||||
unset($this->staticaccelerationkeys[$key]);
|
||||
}
|
||||
$this->staticaccelerationarray[$key] = $data;
|
||||
if ($this->staticaccelerationsize !== false) {
|
||||
$this->staticaccelerationcount++;
|
||||
$this->staticaccelerationkeys[$key] = $key;
|
||||
if ($this->staticaccelerationcount > $this->staticaccelerationsize) {
|
||||
$dropkey = array_shift($this->staticaccelerationkeys);
|
||||
unset($this->staticaccelerationarray[$dropkey]);
|
||||
$this->staticaccelerationcount--;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an item from the persist cache.
|
||||
* Deletes an item from the static acceleration array.
|
||||
*
|
||||
* @param string|int $key As given to get|set|delete
|
||||
* @return bool True on success, false otherwise.
|
||||
*/
|
||||
protected function delete_from_persist_cache($key) {
|
||||
unset($this->persistcache[$key]);
|
||||
if ($this->persistmaxsize !== false) {
|
||||
$dropkey = array_search($key, $this->persistkeys);
|
||||
unset($this->staticaccelerationarray[$key]);
|
||||
if ($this->staticaccelerationsize !== false) {
|
||||
$dropkey = array_search($key, $this->staticaccelerationkeys);
|
||||
if ($dropkey) {
|
||||
unset($this->persistkeys[$dropkey]);
|
||||
$this->persistcount--;
|
||||
unset($this->staticaccelerationkeys[$dropkey]);
|
||||
$this->staticaccelerationcount--;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -1448,9 +1464,8 @@ class cache_application extends cache implements cache_loader_with_locking {
|
||||
* This class is used for session caches returned by the cache::make methods.
|
||||
*
|
||||
* It differs from the application loader in a couple of noteable ways:
|
||||
* 1. Sessions are always expected to be persistent.
|
||||
* Because of this we don't ever use the persist cache and instead a session array
|
||||
* containing all of the data is maintained by this object.
|
||||
* 1. Sessions are always expected to exist.
|
||||
* Because of this we don't ever use the static acceleration array.
|
||||
* 2. Session data for a loader instance (store + definition) is consolidate into a
|
||||
* single array for storage within the store.
|
||||
* Along with this we embed a lastaccessed time with the data. This way we can
|
||||
@@ -2063,7 +2078,7 @@ class cache_session extends cache {
|
||||
}
|
||||
|
||||
/**
|
||||
* The session loader never uses the persist cache.
|
||||
* The session loader never uses static acceleration.
|
||||
* Instead it stores things in the static $session variable. Shared between all session loaders.
|
||||
*
|
||||
* @return bool
|
||||
|
||||
Vendored
+3
-3
@@ -49,8 +49,7 @@ class cache_disabled extends cache {
|
||||
* @param null $loader Unused.
|
||||
*/
|
||||
public function __construct(cache_definition $definition, cache_store $store, $loader = null) {
|
||||
$this->definition = $definition;
|
||||
$this->store = $store;
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +227,8 @@ class cache_factory_disabled extends cache_factory {
|
||||
* @param array $options An array of options, available options are:
|
||||
* - simplekeys : Set to true if the keys you will use are a-zA-Z0-9_
|
||||
* - simpledata : Set to true if the type of the data you are going to store is scalar, or an array of scalar vars
|
||||
* - persistent : If set to true the cache will persist construction requests.
|
||||
* - staticacceleration : If set to true the cache will hold onto all data passing through it.
|
||||
* - staticaccelerationsize : Sets the max size of the static acceleration array.
|
||||
* @return cache_application|cache_session|cache_request
|
||||
*/
|
||||
public function create_cache_from_params($mode, $component, $area, array $identifiers = array(), array $options = array()) {
|
||||
|
||||
Vendored
+173
-15
@@ -149,8 +149,8 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'test_default_application_cache',
|
||||
'persistent' => true,
|
||||
'persistentmaxsize' => 1
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 1
|
||||
));
|
||||
$cache = cache::make('phpunit', 'test_default_application_cache');
|
||||
$this->assertInstanceOf('cache_application', $cache);
|
||||
@@ -189,7 +189,7 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'nostoretest2',
|
||||
'persistent' => true
|
||||
'staticacceleration' => true
|
||||
));
|
||||
$instance->phpunit_remove_stores();
|
||||
|
||||
@@ -907,11 +907,11 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
'crazyevent'
|
||||
)
|
||||
));
|
||||
$instance->phpunit_add_definition('phpunit/eventpurgetestpersistent', array(
|
||||
$instance->phpunit_add_definition('phpunit/eventpurgetestaccelerated', array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'eventpurgetestpersistent',
|
||||
'persistent' => true,
|
||||
'area' => 'eventpurgetestaccelerated',
|
||||
'staticacceleration' => true,
|
||||
'invalidationevents' => array(
|
||||
'crazyevent'
|
||||
)
|
||||
@@ -930,8 +930,8 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
$this->assertFalse($cache->get('testkey1'));
|
||||
$this->assertFalse($cache->get('testkey2'));
|
||||
|
||||
// Now test the persistent cache.
|
||||
$cache = cache::make('phpunit', 'eventpurgetestpersistent');
|
||||
// Now test the static acceleration array.
|
||||
$cache = cache::make('phpunit', 'eventpurgetestaccelerated');
|
||||
$this->assertTrue($cache->set('testkey1', 'test data 1'));
|
||||
$this->assertEquals('test data 1', $cache->get('testkey1'));
|
||||
$this->assertTrue($cache->set('testkey2', 'test data 2'));
|
||||
@@ -958,11 +958,11 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
'crazyevent'
|
||||
)
|
||||
));
|
||||
$instance->phpunit_add_definition('phpunit/eventpurgetestpersistent', array(
|
||||
$instance->phpunit_add_definition('phpunit/eventpurgetestaccelerated', array(
|
||||
'mode' => cache_store::MODE_SESSION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'eventpurgetestpersistent',
|
||||
'persistent' => true,
|
||||
'area' => 'eventpurgetestaccelerated',
|
||||
'staticacceleration' => true,
|
||||
'invalidationevents' => array(
|
||||
'crazyevent'
|
||||
)
|
||||
@@ -981,8 +981,8 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
$this->assertFalse($cache->get('testkey1'));
|
||||
$this->assertFalse($cache->get('testkey2'));
|
||||
|
||||
// Now test the persistent cache.
|
||||
$cache = cache::make('phpunit', 'eventpurgetestpersistent');
|
||||
// Now test the static acceleration array.
|
||||
$cache = cache::make('phpunit', 'eventpurgetestaccelerated');
|
||||
$this->assertTrue($cache->set('testkey1', 'test data 1'));
|
||||
$this->assertEquals('test data 1', $cache->get('testkey1'));
|
||||
$this->assertTrue($cache->set('testkey2', 'test data 2'));
|
||||
@@ -1383,8 +1383,8 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'test_application_locking',
|
||||
'persistent' => true,
|
||||
'persistentmaxsize' => 1,
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 1,
|
||||
'requirelockingread' => true,
|
||||
'requirelockingwrite' => true
|
||||
));
|
||||
@@ -1449,4 +1449,162 @@ class cache_phpunit_tests extends advanced_testcase {
|
||||
$this->assertInstanceOf('cache_request', $cache);
|
||||
$this->assertArrayHasKey('cache_is_searchable', $cache->phpunit_get_store_implements());
|
||||
}
|
||||
|
||||
public function test_static_acceleration() {
|
||||
$instance = cache_config_phpunittest::instance();
|
||||
$instance->phpunit_add_definition('phpunit/accelerated', array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'accelerated',
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 3,
|
||||
));
|
||||
$instance->phpunit_add_definition('phpunit/accelerated2', array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'accelerated2',
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 3,
|
||||
));
|
||||
$instance->phpunit_add_definition('phpunit/accelerated3', array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'accelerated3',
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 3,
|
||||
));
|
||||
$instance->phpunit_add_definition('phpunit/accelerated4', array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'component' => 'phpunit',
|
||||
'area' => 'accelerated4',
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 4,
|
||||
));
|
||||
$cache = cache::make('phpunit', 'accelerated');
|
||||
$this->assertInstanceOf('cache_phpunit_application', $cache);
|
||||
|
||||
// Set and get three elements.
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('b', 'B'));
|
||||
$this->assertTrue($cache->set('c', 'C'));
|
||||
$this->assertEquals('A', $cache->get('a'));
|
||||
$this->assertEquals(array('b' => 'B', 'c' => 'C'), $cache->get_many(array('b', 'c')));
|
||||
|
||||
// Make sure all items are in static acceleration array.
|
||||
$this->assertEquals('A', $cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertEquals('B', $cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertEquals('C', $cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
|
||||
// Add new value and make sure it is in cache and it is in array.
|
||||
$this->assertTrue($cache->set('d', 'D'));
|
||||
$this->assertEquals('D', $cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertEquals('D', $cache->get('d'));
|
||||
|
||||
// Now the least recent accessed item (a) is no longer in acceleration array.
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertEquals('B', $cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertEquals('C', $cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
|
||||
// Adding and deleting element.
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->delete('a'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertFalse($cache->has('a'));
|
||||
|
||||
// Make sure "purge" deletes from the array as well.
|
||||
$cache->purge();
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
|
||||
// Check that the array holds the last accessed items by get/set.
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('b', 'B'));
|
||||
$this->assertTrue($cache->set('c', 'C'));
|
||||
$this->assertTrue($cache->set('d', 'D'));
|
||||
$this->assertTrue($cache->set('e', 'E'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertEquals('C', $cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
$this->assertEquals('D', $cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertEquals('E', $cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
|
||||
/** @var cache_phpunit_application $cache */
|
||||
$cache = cache::make('phpunit', 'accelerated2');
|
||||
$this->assertInstanceOf('cache_phpunit_application', $cache);
|
||||
|
||||
// Check that the array holds the last accessed items by get/set.
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('b', 'B'));
|
||||
$this->assertTrue($cache->set('c', 'C'));
|
||||
$this->assertTrue($cache->set('d', 'D'));
|
||||
$this->assertTrue($cache->set('e', 'E'));
|
||||
// Current keys in the array: c, d, e.
|
||||
$this->assertEquals('C', $cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
$this->assertEquals('D', $cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertEquals('E', $cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
|
||||
$this->assertEquals('A', $cache->get('a'));
|
||||
// Current keys in the array: d, e, a.
|
||||
$this->assertEquals('D', $cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertEquals('E', $cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
$this->assertEquals('A', $cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
|
||||
// Current keys in the array: d, e, a.
|
||||
$this->assertEquals(array('c' => 'C'), $cache->get_many(array('c')));
|
||||
// Current keys in the array: e, a, c.
|
||||
$this->assertEquals('E', $cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
$this->assertEquals('A', $cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertEquals('C', $cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
|
||||
|
||||
$cache = cache::make('phpunit', 'accelerated3');
|
||||
$this->assertInstanceOf('cache_phpunit_application', $cache);
|
||||
|
||||
// Check that the array holds the last accessed items by get/set.
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('b', 'B'));
|
||||
$this->assertTrue($cache->set('c', 'C'));
|
||||
$this->assertTrue($cache->set('d', 'D'));
|
||||
$this->assertTrue($cache->set('e', 'E'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertEquals('C', $cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
$this->assertEquals('D', $cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertEquals('E', $cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
|
||||
$this->assertTrue($cache->set('b', 'B2'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertEquals('B2', $cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
$this->assertEquals('D', $cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertEquals('E', $cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
|
||||
$this->assertEquals(2, $cache->set_many(array('b' => 'B3', 'c' => 'C3')));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertEquals('B3', $cache->phpunit_get_directly_from_staticaccelerationarray('b'));
|
||||
$this->assertEquals('C3', $cache->phpunit_get_directly_from_staticaccelerationarray('c'));
|
||||
$this->assertFalse($cache->phpunit_get_directly_from_staticaccelerationarray('d'));
|
||||
$this->assertEquals('E', $cache->phpunit_get_directly_from_staticaccelerationarray('e'));
|
||||
|
||||
$cache = cache::make('phpunit', 'accelerated4');
|
||||
$this->assertInstanceOf('cache_phpunit_application', $cache);
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertTrue($cache->set('a', 'A'));
|
||||
$this->assertEquals('A', $cache->phpunit_get_directly_from_staticaccelerationarray('a'));
|
||||
$this->assertEquals('A', $cache->get('a'));
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -243,6 +243,17 @@ class cache_phpunit_application extends cache_application {
|
||||
public function phpunit_get_store_implements() {
|
||||
return class_implements($this->get_store());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the given key directly from the static acceleration array.
|
||||
*
|
||||
* @param string $key
|
||||
* @return false|mixed
|
||||
*/
|
||||
public function phpunit_get_directly_from_staticaccelerationarray($key) {
|
||||
$key = $this->parse_key($key);
|
||||
return $this->get_from_persist_cache($key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+10
-2
@@ -1,8 +1,16 @@
|
||||
This files describes API changes in /cache/stores/* - cache store plugins.
|
||||
Information provided here is intended especially for developers.
|
||||
|
||||
=== 2.5 ===
|
||||
=== 2.4.7 ===
|
||||
* All cache instances are recorded and subsequent requests are given a reference to the original instance.
|
||||
* The persistent option for the cache definition has been deprecated. Please use the staticacceleration option instead.
|
||||
* There is a new static acceleration option. If enabled data passing through the cache is held onto.
|
||||
* The persistentmaxsize option has been renamed to staticaccelerationsize. It does the same thing.
|
||||
* cache_definition::should_be_persistent has been deprecated. Please call cache_definition::use_static_acceleration instead.
|
||||
* cache_definition::get_persistent_max_size has been deprecated. Please call cache_definition::get_static_acceleration_size instead.
|
||||
|
||||
=== 2.4.2 ===
|
||||
* cleanup method renamed to instance_deleted.
|
||||
It is now called when the store is deleted as all comments suggested anyway.
|
||||
* instance_created method added.
|
||||
It is called when the store is created for the very first time.
|
||||
It is called when the store is created for the very first time.
|
||||
|
||||
+2
-2
@@ -106,8 +106,8 @@ $PAGE->navbar->add($pagetitle);
|
||||
|
||||
$PAGE->set_title($course->shortname.': '.get_string('calendar', 'calendar').': '.$pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_button(calendar_preferences_button($course));
|
||||
$PAGE->set_pagelayout('standard');
|
||||
$PAGE->set_button(calendar_preferences_button($course));
|
||||
|
||||
$renderer = $PAGE->get_renderer('core_calendar');
|
||||
$calendar->add_sidecalendar_blocks($renderer);
|
||||
@@ -125,7 +125,7 @@ switch($action) {
|
||||
$weekend = intval($CFG->calendar_weekend);
|
||||
}
|
||||
|
||||
$authtoken = sha1($USER->id . $USER->password . $CFG->calendar_exportsalt);
|
||||
$authtoken = sha1($USER->id . $DB->get_field('user', 'password', array('id'=>$USER->id)). $CFG->calendar_exportsalt);
|
||||
// Let's populate some vars to let "common tasks" be somewhat smart...
|
||||
// If today it's weekend, give the "next week" option
|
||||
$allownextweek = $weekend & (1 << $now['wday']);
|
||||
|
||||
+2
-2
@@ -366,7 +366,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
} else if(isset($typesbyday[$day]['startuser'])) {
|
||||
$class .= ' calendar_event_user';
|
||||
}
|
||||
$cell = html_writer::link($dayhref, $day, array('aria-controls' => $popupid.'_panel', 'id' => $popupid));
|
||||
$cell = html_writer::link($dayhref, $day, array('id' => $popupid));
|
||||
} else {
|
||||
$cell = $day;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
if(! isset($eventsbyday[$day])) {
|
||||
$class .= ' eventnone';
|
||||
$popupid = calendar_get_popup(true, false);
|
||||
$cell = html_writer::link('#', $day, array('aria-controls' => $popupid.'_panel', 'id' => $popupid));
|
||||
$cell = html_writer::link('#', $day, array('id' => $popupid));
|
||||
}
|
||||
$cell = get_accesshide($today.' ').$cell;
|
||||
}
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ if (!empty($CFG->enablecalendarexport)) {
|
||||
echo $OUTPUT->single_button(new moodle_url('/calendar/managesubscriptions.php', array('course'=>$courseid)), get_string('managesubscriptions', 'calendar'));
|
||||
}
|
||||
if (isloggedin()) {
|
||||
$authtoken = sha1($USER->id . $USER->password . $CFG->calendar_exportsalt);
|
||||
$authtoken = sha1($USER->id . $DB->get_field('user', 'password', array('id'=>$USER->id)) . $CFG->calendar_exportsalt);
|
||||
$link = new moodle_url('/calendar/export_execute.php', array('preset_what'=>'all', 'preset_time'=>'recentupcoming', 'userid' => $USER->id, 'authtoken'=>$authtoken));
|
||||
$icon = html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/ical'), 'height'=>'14', 'width'=>'36', 'alt'=>get_string('ical', 'calendar'), 'title'=>get_string('quickdownloadcalendar', 'calendar')));
|
||||
echo html_writer::tag('a', $icon, array('href'=>$link));
|
||||
|
||||
+1
@@ -48,6 +48,7 @@ YUI.add('moodle-calendar-eventmanager', function(Y) {
|
||||
width : Math.floor(constraint.get('offsetWidth')*0.9)+"px"
|
||||
});
|
||||
panel.render(td);
|
||||
node.setAttribute('aria-controls', panel.get('id'));
|
||||
panel.get('boundingBox').addClass('calendar-event-panel');
|
||||
panel.get('boundingBox').setAttribute('aria-live', 'off');
|
||||
this.on('showevent', panel.show, panel);
|
||||
|
||||
+13
-9
@@ -328,19 +328,23 @@ class course_edit_form extends moodleform {
|
||||
|
||||
/// perform some extra moodle validation
|
||||
function validation($data, $files) {
|
||||
global $DB, $CFG;
|
||||
global $DB;
|
||||
|
||||
$errors = parent::validation($data, $files);
|
||||
if ($foundcourses = $DB->get_records('course', array('shortname'=>$data['shortname']))) {
|
||||
if (!empty($data['id'])) {
|
||||
unset($foundcourses[$data['id']]);
|
||||
|
||||
// Add field validation check for duplicate shortname.
|
||||
if ($course = $DB->get_record('course', array('shortname' => $data['shortname']), '*', IGNORE_MULTIPLE)) {
|
||||
if (empty($data['id']) || $course->id != $data['id']) {
|
||||
$errors['shortname'] = get_string('shortnametaken', '', $course->fullname);
|
||||
}
|
||||
if (!empty($foundcourses)) {
|
||||
foreach ($foundcourses as $foundcourse) {
|
||||
$foundcoursenames[] = $foundcourse->fullname;
|
||||
}
|
||||
|
||||
// Add field validation check for duplicate idnumber.
|
||||
if (!empty($data['idnumber']) && (empty($data['id']) || $this->course->idnumber != $data['idnumber'])) {
|
||||
if ($course = $DB->get_record('course', array('idnumber' => $data['idnumber']), '*', IGNORE_MULTIPLE)) {
|
||||
if (empty($data['id']) || $course->id != $data['id']) {
|
||||
$errors['idnumber'] = get_string('idnumbertaken', 'error');
|
||||
}
|
||||
$foundcoursenamestring = implode(',', $foundcoursenames);
|
||||
$errors['shortname']= get_string('shortnametaken', '', $foundcoursenamestring);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ class editsection_form extends moodleform {
|
||||
$course = $this->_customdata['course'];
|
||||
|
||||
$elementgroup = array();
|
||||
$elementgroup[] = $mform->createElement('text', 'name', '', array('size' => '30'));
|
||||
$elementgroup[] = $mform->createElement('text', 'name', '', array('size' => '30', 'maxlength' => '255'));
|
||||
$elementgroup[] = $mform->createElement('checkbox', 'usedefaultname', '', get_string('sectionusedefaultname'));
|
||||
$mform->addGroup($elementgroup, 'name_group', get_string('sectionname'), ' ', false);
|
||||
$mform->addGroupRule('name_group', array('name' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255))));
|
||||
|
||||
$mform->setDefault('usedefaultname', true);
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
|
||||
@@ -515,7 +515,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
|
||||
$o.= html_writer::tag('div', '', array('class' => 'left side'));
|
||||
$o.= html_writer::tag('div', '', array('class' => 'right side'));
|
||||
$o.= html_writer::start_tag('div', array('class' => 'content'));
|
||||
$o.= $this->output->heading(get_string('orphanedactivities'), 3, 'sectionname');
|
||||
$o.= $this->output->heading(get_string('orphanedactivitiesinsectionno', '', $sectionno), 3, 'sectionname');
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
+17
-1
@@ -3962,6 +3962,20 @@ function update_course($data, $editoroptions = NULL) {
|
||||
$data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'summary', 0);
|
||||
}
|
||||
|
||||
// Check we don't have a duplicate shortname.
|
||||
if (!empty($data->shortname) && $oldcourse->shortname != $data->shortname) {
|
||||
if ($DB->record_exists('course', array('shortname' => $data->shortname))) {
|
||||
throw new moodle_exception('shortnametaken', '', '', $data->shortname);
|
||||
}
|
||||
}
|
||||
|
||||
// Check we don't have a duplicate idnumber.
|
||||
if (!empty($data->idnumber) && $oldcourse->idnumber != $data->idnumber) {
|
||||
if ($DB->record_exists('course', array('idnumber' => $data->idnumber))) {
|
||||
throw new moodle_exception('idnumbertaken', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($data->category) or empty($data->category)) {
|
||||
// prevent nulls and 0 in category field
|
||||
unset($data->category);
|
||||
@@ -4001,7 +4015,9 @@ function update_course($data, $editoroptions = NULL) {
|
||||
context_moved($context, $newparent);
|
||||
}
|
||||
|
||||
fix_course_sortorder();
|
||||
if ($movecat || (isset($data->sortorder) && $oldcourse->sortorder != $data->sortorder)) {
|
||||
fix_course_sortorder();
|
||||
}
|
||||
|
||||
// Test for and remove blocks which aren't appropriate anymore
|
||||
blocks_remove_inappropriate($course);
|
||||
|
||||
@@ -59,6 +59,11 @@ if (!empty($add)) {
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:manageactivities', $context);
|
||||
|
||||
// There is no page for this in the navigation. The closest we'll have is the course section.
|
||||
// If the course section isn't displayed on the navigation this will fall back to the course which
|
||||
// will be the closest match we have.
|
||||
navigation_node::override_active_url(course_get_url($course, $section));
|
||||
|
||||
course_create_sections_if_missing($course, $section);
|
||||
$cw = get_fast_modinfo($course)->get_section_info($section);
|
||||
|
||||
@@ -122,6 +127,7 @@ if (!empty($add)) {
|
||||
} else {
|
||||
$pageheading = get_string('addinganew', 'moodle', $fullmodulename);
|
||||
}
|
||||
$navbaraddition = $pageheading;
|
||||
|
||||
} else if (!empty($update)) {
|
||||
|
||||
@@ -228,6 +234,7 @@ if (!empty($add)) {
|
||||
} else {
|
||||
$pageheading = get_string('updatinga', 'moodle', $fullmodulename);
|
||||
}
|
||||
$navbaraddition = null;
|
||||
|
||||
} else {
|
||||
require_login();
|
||||
@@ -651,6 +658,11 @@ if ($mform->is_cancelled()) {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_title($streditinga);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
if (isset($navbaraddition)) {
|
||||
$PAGE->navbar->add($navbaraddition);
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (get_string_manager()->string_exists('modulename_help', $module->name)) {
|
||||
|
||||
@@ -97,6 +97,53 @@ class courselib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(range(0, $course->numsections + 1), $sectionscreated);
|
||||
}
|
||||
|
||||
public function test_update_course() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$defaultcategory = $DB->get_field_select('course_categories', 'MIN(id)', 'parent = 0');
|
||||
|
||||
$course = new stdClass();
|
||||
$course->fullname = 'Apu loves Unit Təsts';
|
||||
$course->shortname = 'test1';
|
||||
$course->idnumber = '1';
|
||||
$course->summary = 'Awesome!';
|
||||
$course->summaryformat = FORMAT_PLAIN;
|
||||
$course->format = 'topics';
|
||||
$course->newsitems = 0;
|
||||
$course->numsections = 5;
|
||||
$course->category = $defaultcategory;
|
||||
|
||||
$created = create_course($course);
|
||||
// Ensure the checks only work on idnumber/shortname that are not already ours.
|
||||
update_course($created);
|
||||
|
||||
$course->shortname = 'test2';
|
||||
$course->idnumber = '2';
|
||||
|
||||
$created2 = create_course($course);
|
||||
|
||||
// Test duplicate idnumber.
|
||||
$created2->idnumber = '1';
|
||||
try {
|
||||
update_course($created2);
|
||||
$this->fail('Expected exception when trying to update a course with duplicate idnumber');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals(get_string('idnumbertaken', 'error'), $e->getMessage());
|
||||
}
|
||||
|
||||
// Test duplicate shortname.
|
||||
$created2->idnumber = '2';
|
||||
$created2->shortname = 'test1';
|
||||
try {
|
||||
update_course($created2);
|
||||
$this->fail('Expected exception when trying to update a course with a duplicate shortname');
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertEquals(get_string('shortnametaken', 'error', $created2->shortname), $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_course_add_cm_to_section() {
|
||||
global $DB;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
Vendored
+59
-27
@@ -17,7 +17,8 @@ YUI.add('moodle-course-dragdrop', function(Y) {
|
||||
SECTION : 'section',
|
||||
SECTIONADDMENUS : 'section_add_menus',
|
||||
SECTIONHANDLE : 'section-handle',
|
||||
SUMMARY : 'summary'
|
||||
SUMMARY : 'summary',
|
||||
SECTIONDRAGGABLE: 'sectiondraggable'
|
||||
};
|
||||
|
||||
var DRAGSECTION = function() {
|
||||
@@ -28,7 +29,7 @@ YUI.add('moodle-course-dragdrop', function(Y) {
|
||||
|
||||
initializer : function(params) {
|
||||
// Set group for parent class
|
||||
this.groups = ['section'];
|
||||
this.groups = [ CSS.SECTIONDRAGGABLE ];
|
||||
this.samenodeclass = M.course.format.get_sectionwrapperclass();
|
||||
this.parentnodeclass = M.course.format.get_containerclass();
|
||||
|
||||
@@ -39,14 +40,16 @@ YUI.add('moodle-course-dragdrop', function(Y) {
|
||||
// Initialise sections dragging
|
||||
this.sectionlistselector = M.course.format.get_section_wrapper(Y);
|
||||
if (this.sectionlistselector) {
|
||||
// We need both the list of all sections, and just those which are moveable.
|
||||
// When updating titles and orders, the immoveable sections may need to be updated too.
|
||||
this.sectionlistselector = '.'+CSS.COURSECONTENT+' '+this.sectionlistselector;
|
||||
|
||||
this.setup_for_section(this.sectionlistselector);
|
||||
|
||||
// Make each li element in the lists of sections draggable
|
||||
var nodeselector = this.sectionlistselector.slice(CSS.COURSECONTENT.length+2);
|
||||
var del = new Y.DD.Delegate({
|
||||
container: '.'+CSS.COURSECONTENT,
|
||||
nodes: nodeselector,
|
||||
nodes: '.' + CSS.SECTIONDRAGGABLE,
|
||||
target: true,
|
||||
handles: ['.'+CSS.LEFT],
|
||||
dragConfig: {groups: this.groups}
|
||||
@@ -95,6 +98,9 @@ YUI.add('moodle-course-dragdrop', function(Y) {
|
||||
if (movedown) {
|
||||
movedown.remove();
|
||||
}
|
||||
|
||||
// This section can be moved - add the class to indicate this to Y.DD.
|
||||
sectionnode.addClass(CSS.SECTIONDRAGGABLE);
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
@@ -129,20 +135,37 @@ YUI.add('moodle-course-dragdrop', function(Y) {
|
||||
this.drop_hit(e);
|
||||
},
|
||||
|
||||
get_section_index: function(node) {
|
||||
var sectionlistselector = '.' + CSS.COURSECONTENT + ' ' + M.course.format.get_section_selector(Y),
|
||||
sectionList = Y.all(sectionlistselector),
|
||||
nodeIndex = sectionList.indexOf(node),
|
||||
zeroIndex = sectionList.indexOf(Y.one('#section-0'));
|
||||
|
||||
return (nodeIndex - zeroIndex);
|
||||
},
|
||||
|
||||
drop_hit : function(e) {
|
||||
var drag = e.drag;
|
||||
// Get a reference to our drag node
|
||||
var dragnode = drag.get('node');
|
||||
var dropnode = e.drop.get('node');
|
||||
// Prepare some variables
|
||||
var dragnodeid = Number(this.get_section_id(dragnode));
|
||||
var dropnodeid = Number(this.get_section_id(dropnode));
|
||||
|
||||
var loopstart = dragnodeid;
|
||||
var loopend = dropnodeid;
|
||||
// Get references to our nodes and their IDs.
|
||||
var dragnode = drag.get('node'),
|
||||
dragnodeid = this.get_section_id(dragnode),
|
||||
loopstart = dragnodeid,
|
||||
|
||||
if (this.goingup) {
|
||||
loopstart = dropnodeid;
|
||||
dropnodeindex = this.get_section_index(dragnode),
|
||||
loopend = dropnodeindex;
|
||||
|
||||
if (dragnodeid === dropnodeindex) {
|
||||
Y.log("Skipping move - same location moving " + dragnodeid + " to " + dropnodeindex, 'debug', 'moodle-course-dragdrop');
|
||||
return;
|
||||
}
|
||||
|
||||
Y.log("Moving from position " + dragnodeid + " to position " + dropnodeindex, 'debug', 'moodle-course-dragdrop');
|
||||
|
||||
if (loopstart > loopend) {
|
||||
// If we're going up, we need to swap the loop order
|
||||
// because loops can't go backwards.
|
||||
loopstart = dropnodeindex;
|
||||
loopend = dragnodeid;
|
||||
}
|
||||
|
||||
@@ -167,7 +190,7 @@ YUI.add('moodle-course-dragdrop', function(Y) {
|
||||
params['class'] = 'section';
|
||||
params.field = 'move';
|
||||
params.id = dragnodeid;
|
||||
params.value = dropnodeid;
|
||||
params.value = dropnodeindex;
|
||||
|
||||
// Do AJAX request
|
||||
var uri = M.cfg.wwwroot + this.get('ajaxurl');
|
||||
@@ -190,27 +213,36 @@ YUI.add('moodle-course-dragdrop', function(Y) {
|
||||
M.course.format.process_sections(Y, sectionlist, responsetext, loopstart, loopend);
|
||||
} catch (e) {}
|
||||
|
||||
// Update all of the section IDs - first unset them, then set them
|
||||
// to avoid duplicates in the DOM.
|
||||
var index;
|
||||
|
||||
// Classic bubble sort algorithm is applied to the section
|
||||
// nodes between original drag node location and the new one.
|
||||
var swapped = false;
|
||||
do {
|
||||
var swapped = false;
|
||||
for (var i = loopstart; i <= loopend; i++) {
|
||||
if (this.get_section_id(sectionlist.item(i-1)) > this.get_section_id(sectionlist.item(i))) {
|
||||
// Swap section id
|
||||
var sectionid = sectionlist.item(i-1).get('id');
|
||||
sectionlist.item(i-1).set('id', sectionlist.item(i).get('id'));
|
||||
sectionlist.item(i).set('id', sectionid);
|
||||
// See what format needs to swap
|
||||
M.course.format.swap_sections(Y, i-1, i);
|
||||
// Update flag
|
||||
swapped = false;
|
||||
for (index = loopstart; index <= loopend; index++) {
|
||||
if (this.get_section_id(sectionlist.item(index - 1)) >
|
||||
this.get_section_id(sectionlist.item(index))) {
|
||||
Y.log("Swapping " + this.get_section_id(sectionlist.item(index - 1)) +
|
||||
" with " + this.get_section_id(sectionlist.item(index)));
|
||||
// Swap section id.
|
||||
var sectionid = sectionlist.item(index - 1).get('id');
|
||||
sectionlist.item(index - 1).set('id', sectionlist.item(index).get('id'));
|
||||
sectionlist.item(index).set('id', sectionid);
|
||||
|
||||
// See what format needs to swap.
|
||||
M.course.format.swap_sections(Y, index - 1, index);
|
||||
|
||||
// Update flag.
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
loopend = loopend - 1;
|
||||
} while (swapped);
|
||||
|
||||
// Finally, hide the lightbox
|
||||
window.setTimeout(function(e) {
|
||||
window.setTimeout(function() {
|
||||
lightbox.hide();
|
||||
}, 250);
|
||||
},
|
||||
|
||||
@@ -46,6 +46,9 @@ class enrol_cohort_plugin extends enrol_plugin {
|
||||
} else if (empty($instance->name)) {
|
||||
$enrol = $this->get_name();
|
||||
$cohort = $DB->get_record('cohort', array('id'=>$instance->customint1));
|
||||
if (!$cohort) {
|
||||
return get_string('pluginname', 'enrol_'.$enrol);
|
||||
}
|
||||
$cohortname = format_string($cohort->name, true, array('context'=>context::instance_by_id($cohort->contextid)));
|
||||
if ($role = $DB->get_record('role', array('id'=>$instance->roleid))) {
|
||||
$role = role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING));
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
$string['database:unenrol'] = 'Unenrol suspended users';
|
||||
$string['dbencoding'] = 'Database encoding';
|
||||
$string['dbhost'] = 'Database host';
|
||||
$string['dbhost_desc'] = 'Type database server IP address or host name';
|
||||
$string['dbhost_desc'] = 'Type database server IP address or host name. Use a system DSN name if using ODBC.';
|
||||
$string['dbname'] = 'Database name';
|
||||
$string['dbname_desc'] = 'Leave empty if using a DSN name in database host.';
|
||||
$string['dbpass'] = 'Database password';
|
||||
$string['dbsetupsql'] = 'Database setup command';
|
||||
$string['dbsetupsql_desc'] = 'SQL command for special database setup, often used to setup communication encoding - example for MySQL and PostgreSQL: <em>SET NAMES \'utf8\'</em>';
|
||||
|
||||
@@ -41,7 +41,7 @@ if ($ADMIN->fulltree) {
|
||||
|
||||
$settings->add(new admin_setting_configpasswordunmask('enrol_database/dbpass', get_string('dbpass', 'enrol_database'), '', ''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_database/dbname', get_string('dbname', 'enrol_database'), '', ''));
|
||||
$settings->add(new admin_setting_configtext('enrol_database/dbname', get_string('dbname', 'enrol_database'), get_string('dbname_desc', 'enrol_database'), ''));
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_database/dbencoding', get_string('dbencoding', 'enrol_database'), '', 'utf-8'));
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ function cron() {
|
||||
$this->logfp = fopen($logtolocation, 'a');
|
||||
}
|
||||
|
||||
$fileisnew = false;
|
||||
if ( file_exists($filename) ) {
|
||||
@set_time_limit(0);
|
||||
$starttime = time();
|
||||
@@ -106,10 +107,8 @@ function cron() {
|
||||
if(empty($prev_path) || ($filename != $prev_path)) {
|
||||
$fileisnew = true;
|
||||
} elseif(isset($prev_time) && ($filemtime <= $prev_time)) {
|
||||
$fileisnew = false;
|
||||
$this->log_line('File modification time is not more recent than last update - skipping processing.');
|
||||
} elseif(isset($prev_md5) && ($md5 == $prev_md5)) {
|
||||
$fileisnew = false;
|
||||
$this->log_line('File MD5 hash is same as on last update - skipping processing.');
|
||||
} else {
|
||||
$fileisnew = true; // Let's process it!
|
||||
@@ -216,7 +215,7 @@ function cron() {
|
||||
$this->log_line('File not found: '.$filename);
|
||||
}
|
||||
|
||||
if (!empty($mailadmins)) {
|
||||
if (!empty($mailadmins) && $fileisnew) {
|
||||
$msg = "An IMS enrolment has been carried out within Moodle.\nTime taken: $timeelapsed seconds.\n\n";
|
||||
if(!empty($logtolocation)){
|
||||
if($this->logfp){
|
||||
@@ -233,7 +232,7 @@ function cron() {
|
||||
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'moodle';
|
||||
$eventdata->component = 'imsenterprise';
|
||||
$eventdata->component = 'enrol_imsenterprise';
|
||||
$eventdata->name = 'imsenterprise_enrolment';
|
||||
$eventdata->userfrom = get_admin();
|
||||
$eventdata->userto = get_admin();
|
||||
@@ -397,7 +396,7 @@ function process_group_tag($tagcontents) {
|
||||
// Insert default names for teachers/students, from the current language
|
||||
|
||||
// Handle course categorisation (taken from the group.org.orgunit field if present)
|
||||
if (strlen($group->category)>0) {
|
||||
if (!empty($group->category)) {
|
||||
// If the category is defined and exists in Moodle, we want to store it in that one
|
||||
if ($catid = $DB->get_field('course_categories', 'id', array('name'=>$group->category))) {
|
||||
$course->category = $catid;
|
||||
@@ -412,10 +411,10 @@ function process_group_tag($tagcontents) {
|
||||
} else {
|
||||
// If not found and not allowed to create, stick with default
|
||||
$this->log_line('Category '.$group->category.' not found in Moodle database, so using default category instead.');
|
||||
$course->category = 1;
|
||||
$course->category = $this->get_default_category_id();
|
||||
}
|
||||
} else {
|
||||
$course->category = 1;
|
||||
$course->category = $this->get_default_category_id();
|
||||
}
|
||||
$course->timecreated = time();
|
||||
$course->startdate = time();
|
||||
@@ -810,6 +809,24 @@ function load_role_mappings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default category id (often known as 'Miscellaneous'),
|
||||
* statically cached to avoid multiple DB lookups on big imports.
|
||||
*
|
||||
* @return int id of default category.
|
||||
*/
|
||||
private function get_default_category_id() {
|
||||
static $defaultcategoryid = null;
|
||||
|
||||
if ($defaultcategoryid === null) {
|
||||
$category = get_course_category();
|
||||
$defaultcategoryid = $category->id;
|
||||
}
|
||||
|
||||
return $defaultcategoryid;
|
||||
}
|
||||
|
||||
|
||||
} // end of class
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -950,7 +950,7 @@ class enrol_ldap_plugin extends enrol_plugin {
|
||||
$template->groupmodeforce = $courseconfig->groupmodeforce;
|
||||
$template->visible = $courseconfig->visible;
|
||||
$template->lang = $courseconfig->lang;
|
||||
$template->groupmodeforce = $courseconfig->groupmodeforce;
|
||||
$template->enablecompletion = $courseconfig->enablecompletion;
|
||||
}
|
||||
$course = $template;
|
||||
|
||||
|
||||
+6
-1
@@ -47,7 +47,12 @@ class enrol_meta_plugin extends enrol_plugin {
|
||||
} else if (empty($instance->name)) {
|
||||
$enrol = $this->get_name();
|
||||
$course = $DB->get_record('course', array('id'=>$instance->customint1));
|
||||
$coursename = format_string(get_course_display_name_for_list($course));
|
||||
if ($course) {
|
||||
$coursename = format_string(get_course_display_name_for_list($course));
|
||||
} else {
|
||||
// Use course id, if course is deleted.
|
||||
$coursename = $instance->customint1;
|
||||
}
|
||||
return get_string('pluginname', 'enrol_' . $enrol) . ' (' . $coursename . ')';
|
||||
} else {
|
||||
return format_string($instance->name);
|
||||
|
||||
+2
-2
@@ -399,7 +399,7 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
<button class="{!}fp-file-cancel">'.get_string('cancel').'</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="fp-info">
|
||||
<div class="fp-info clearfix">
|
||||
<div class="fp-hr"></div>
|
||||
<p class="{!}fp-thumbnail"></p>
|
||||
<div class="fp-fileinfo">
|
||||
@@ -698,7 +698,7 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
<button class="{!}fp-select-cancel">'.get_string('cancel').'</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="fp-info">
|
||||
<div class="fp-info clearfix">
|
||||
<div class="fp-hr"></div>
|
||||
<p class="{!}fp-thumbnail"></p>
|
||||
<div class="fp-fileinfo">
|
||||
|
||||
@@ -131,6 +131,11 @@ class filter_glossary extends moodle_text_filter {
|
||||
foreach ($concepts as $key => $concept) {
|
||||
// Trim empty or unlinkable concepts
|
||||
$currentconcept = trim(strip_tags($concept->concept));
|
||||
|
||||
// Concept must be HTML-escaped, so do the same as print_string
|
||||
// to turn ampersands into &.
|
||||
$currentconcept = replace_ampersands_not_followed_by_entity($currentconcept);
|
||||
|
||||
if (empty($currentconcept)) {
|
||||
unset($concepts[$key]);
|
||||
continue;
|
||||
@@ -168,10 +173,14 @@ class filter_glossary extends moodle_text_filter {
|
||||
'&mode=cat&hook='.$concept->id.'">';
|
||||
} else { // Link to entry or alias
|
||||
if (!empty($concept->originalconcept)) { // We are dealing with an alias (so show and point to original)
|
||||
$title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->originalconcept));
|
||||
$title = str_replace('"', "'", html_entity_decode(
|
||||
strip_tags($glossaryname.': '.$concept->originalconcept)));
|
||||
$concept->id = $concept->entryid;
|
||||
} else { // This is an entry
|
||||
$title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->concept));
|
||||
// We need to remove entities from the content here because it
|
||||
// will be escaped by html_writer below.
|
||||
$title = str_replace('"', "'", html_entity_decode(
|
||||
strip_tags($glossaryname.': '.$concept->concept)));
|
||||
}
|
||||
// hardcoding dictionary format in the URL rather than defaulting
|
||||
// to the current glossary format which may not work in a popup.
|
||||
|
||||
@@ -33,6 +33,7 @@ $action = optional_param('action', '', PARAM_ALPHA);
|
||||
$scope = optional_param('scope', 'custom', PARAM_ALPHA);
|
||||
|
||||
$PAGE->set_url('/grade/edit/outcome/import.php', array('courseid' => $courseid));
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
/// Make sure they can even access this course
|
||||
if ($courseid) {
|
||||
|
||||
@@ -38,7 +38,7 @@ class import_outcomes_form extends moodleform {
|
||||
$mform->addElement('hidden', 'action', 'upload');
|
||||
$mform->setType('action', PARAM_ALPHANUMEXT);
|
||||
$mform->addElement('hidden', 'courseid', $PAGE->course->id);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->setType('courseid', PARAM_INT);
|
||||
|
||||
$scope = array();
|
||||
if (($PAGE->course->id > 1) && has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
|
||||
@@ -793,9 +793,12 @@ class grade_edit_tree_column_range extends grade_edit_tree_column {
|
||||
public function get_item_cell($item, $params) {
|
||||
global $DB, $OUTPUT;
|
||||
|
||||
// If the parent aggregation is Sum of Grades, this cannot be changed
|
||||
// If the parent aggregation is Sum of Grades, we should show the number, even for scales, as that value is used...
|
||||
// ...in the computation. For text grades, the grademax is not used, so we can still show the no value string.
|
||||
$parent_cat = $item->get_parent_category();
|
||||
if ($parent_cat->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
if ($item->gradetype == GRADE_TYPE_TEXT) {
|
||||
$grademax = ' - ';
|
||||
} else if ($parent_cat->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
$grademax = format_float($item->grademax, $item->get_decimals());
|
||||
} elseif ($item->gradetype == GRADE_TYPE_SCALE) {
|
||||
$scale = $DB->get_record('scale', array('id' => $item->scaleid));
|
||||
|
||||
@@ -63,7 +63,8 @@ if ($id) {
|
||||
|
||||
$displaystring = null;
|
||||
if (!empty($grade_item->itemmodule)) {
|
||||
$displaystring = get_string('modulename', $grade_item->itemmodule).': '.$grade_item->get_name();
|
||||
$displaystring = get_string('modulename', $grade_item->itemmodule).get_string('labelsep', 'langconfig')
|
||||
.$grade_item->get_name();
|
||||
} else {
|
||||
$displaystring = $grade_item->get_name();
|
||||
}
|
||||
|
||||
@@ -86,17 +86,22 @@ class grade_import_mapping_form extends moodleform {
|
||||
}
|
||||
$mform->addElement('select', 'mapfrom', get_string('mapfrom', 'grades'), $mapfromoptions);
|
||||
|
||||
$maptooptions = array('userid'=>'userid', 'username'=>'username', 'useridnumber'=>'useridnumber', 'useremail'=>'useremail', '0'=>'ignore');
|
||||
$maptooptions = array(
|
||||
'userid' => get_string('userid', 'grades'),
|
||||
'username' => get_string('username'),
|
||||
'useridnumber' => get_string('idnumber'),
|
||||
'useremail' => get_string('email'),
|
||||
'0' => get_string('ignore', 'grades')
|
||||
);
|
||||
$mform->addElement('select', 'mapto', get_string('mapto', 'grades'), $maptooptions);
|
||||
|
||||
$mform->addElement('header', 'general', get_string('mappings', 'grades'));
|
||||
|
||||
// add a comment option
|
||||
|
||||
$comments = array();
|
||||
// Add a feedback option.
|
||||
$feedbacks = array();
|
||||
if ($gradeitems = $this->_customdata['gradeitems']) {
|
||||
foreach ($gradeitems as $itemid => $itemname) {
|
||||
$comments['feedback_'.$itemid] = 'comments for '.$itemname;
|
||||
$feedbacks['feedback_'.$itemid] = get_string('feedbackforgradeitems', 'grades', $itemname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,11 +109,16 @@ class grade_import_mapping_form extends moodleform {
|
||||
$i = 0; // index
|
||||
foreach ($header as $h) {
|
||||
$h = trim($h);
|
||||
// this is what each header maps to
|
||||
$mform->addElement('selectgroups', 'mapping_'.$i, s($h),
|
||||
array('others'=>array('0'=>'ignore', 'new'=>'new gradeitem'),
|
||||
'gradeitems'=>$gradeitems,
|
||||
'comments'=>$comments));
|
||||
// This is what each header maps to.
|
||||
$headermapsto = array(
|
||||
get_string('others', 'grades') => array(
|
||||
'0' => get_string('ignore', 'grades'),
|
||||
'new' => get_string('newitem', 'grades')
|
||||
),
|
||||
get_string('gradeitems', 'grades') => $gradeitems,
|
||||
get_string('feedbacks', 'grades') => $feedbacks
|
||||
);
|
||||
$mform->addElement('selectgroups', 'mapping_'.$i, s($h), $headermapsto);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ class graded_users_iterator {
|
||||
LEFT JOIN (SELECT * FROM {user_info_data}
|
||||
WHERE fieldid = :cf$customfieldscount) cf$customfieldscount
|
||||
ON u.id = cf$customfieldscount.userid";
|
||||
$userfields .= ", cf$customfieldscount.data AS 'customfield_{$field->shortname}'";
|
||||
$userfields .= ", cf$customfieldscount.data AS customfield_{$field->shortname}";
|
||||
$params['cf'.$customfieldscount] = $field->customid;
|
||||
$customfieldscount++;
|
||||
}
|
||||
|
||||
@@ -32,21 +32,113 @@ require_once($CFG->dirroot.'/grade/edit/tree/lib.php');
|
||||
/**
|
||||
* Tests grade_edit_tree (deals with the data on the categories and items page in the gradebook)
|
||||
*/
|
||||
class gradeedittreelib_testcase extends basic_testcase {
|
||||
var $courseid = 1;
|
||||
var $context = null;
|
||||
var $grade_edit_tree = null;
|
||||
|
||||
class gradeedittreelib_testcase extends advanced_testcase {
|
||||
public function test_format_number() {
|
||||
$numinput = array( 0, 1, 1.01, '1.010', 1.2345);
|
||||
$numinput = array(0, 1, 1.01, '1.010', 1.2345);
|
||||
$numoutput = array(0.0, 1.0, 1.01, 1.01, 1.2345);
|
||||
|
||||
for ($i=0; $i<sizeof($numinput); $i++) {
|
||||
for ($i = 0; $i < count($numinput); $i++) {
|
||||
$msg = 'format_number() testing '.$numinput[$i].' %s';
|
||||
$this->assertEquals(grade_edit_tree::format_number($numinput[$i]),$numoutput[$i],$msg);
|
||||
$this->assertEquals(grade_edit_tree::format_number($numinput[$i]), $numoutput[$i], $msg);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_grade_edit_tree_column_range_get_item_cell() {
|
||||
global $DB, $CFG;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Make some things we need.
|
||||
$scale = $this->getDataGenerator()->create_scale();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$assign = $this->getDataGenerator()->create_module('assign', array('course' => $course->id));
|
||||
$modulecontext = context_module::instance($assign->id);
|
||||
// The generator returns a dummy object, lets get the real assign object.
|
||||
$assign = new assign($modulecontext, false, false);
|
||||
$cm = $assign->get_course_module();
|
||||
|
||||
$subplugins = $assign->get_submission_plugins();
|
||||
$feedplugins = $assign->get_feedback_plugins();
|
||||
|
||||
// Get range column.
|
||||
$column = grade_edit_tree_column::factory('range');
|
||||
|
||||
$gradeitemparams = array(
|
||||
'itemtype' => 'mod',
|
||||
'itemmodule' => $cm->modname,
|
||||
'iteminstance' => $cm->instance,
|
||||
'courseid' => $cm->course,
|
||||
'itemnumber' => 0
|
||||
);
|
||||
|
||||
// Lets set the grade to something we know.
|
||||
$instance = $assign->get_instance();
|
||||
foreach ($subplugins as $plugin) {
|
||||
$enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
|
||||
$instance->$enabledname = 0;
|
||||
}
|
||||
foreach ($feedplugins as $plugin) {
|
||||
$enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
|
||||
$instance->$enabledname = 0;
|
||||
}
|
||||
$instance->grade = 70;
|
||||
$instance->instance = $instance->id;
|
||||
$assign->update_instance($instance);
|
||||
|
||||
$gradeitem = grade_item::fetch($gradeitemparams);
|
||||
$cell = $column->get_item_cell($gradeitem, array());
|
||||
|
||||
$this->assertEquals(GRADE_TYPE_VALUE, $gradeitem->gradetype);
|
||||
$this->assertEquals(null, $gradeitem->scaleid);
|
||||
$this->assertEquals(70.0, (float) $cell->text, "Grade text is 70", 0.01);
|
||||
|
||||
// Now change it to a scale.
|
||||
$instance = $assign->get_instance();
|
||||
foreach ($subplugins as $plugin) {
|
||||
$enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
|
||||
$instance->$enabledname = 0;
|
||||
}
|
||||
foreach ($feedplugins as $plugin) {
|
||||
$enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
|
||||
$instance->$enabledname = 0;
|
||||
}
|
||||
$instance->grade = -($scale->id);
|
||||
$instance->instance = $instance->id;
|
||||
$assign->update_instance($instance);
|
||||
|
||||
$gradeitem = grade_item::fetch($gradeitemparams);
|
||||
$cell = $column->get_item_cell($gradeitem, array());
|
||||
|
||||
// Make the expected scale text.
|
||||
$scaleitems = null;
|
||||
$scaleitems = explode(',', $scale->scale);
|
||||
$scalestring = end($scaleitems) . ' (' . count($scaleitems) . ')';
|
||||
|
||||
$this->assertEquals(GRADE_TYPE_SCALE, $gradeitem->gradetype);
|
||||
$this->assertEquals($scale->id, $gradeitem->scaleid);
|
||||
$this->assertEquals($scalestring, $cell->text, "Grade text matches scale");
|
||||
|
||||
// Now change it to no grade.
|
||||
$instance = $assign->get_instance();
|
||||
foreach ($subplugins as $plugin) {
|
||||
$enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
|
||||
$instance->$enabledname = 0;
|
||||
}
|
||||
foreach ($feedplugins as $plugin) {
|
||||
$enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
|
||||
$instance->$enabledname = 0;
|
||||
}
|
||||
$instance->grade = 0;
|
||||
$instance->instance = $instance->id;
|
||||
$assign->update_instance($instance);
|
||||
|
||||
$gradeitem = grade_item::fetch($gradeitemparams);
|
||||
$cell = $column->get_item_cell($gradeitem, array());
|
||||
|
||||
$this->assertEquals(GRADE_TYPE_TEXT, $gradeitem->gradetype);
|
||||
$this->assertEquals(null, $gradeitem->scaleid);
|
||||
$this->assertEquals(' - ', $cell->text, 'Grade text matches empty value of " - "');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+32
-17
@@ -99,25 +99,40 @@ $PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('adduserstogroup', 'group').": $groupname", 3);
|
||||
|
||||
/// Print group info - TODO: remove tables for layout here
|
||||
$groupinfotable = new html_table();
|
||||
$groupinfotable->attributes['class'] = 'groupinfobox';
|
||||
$picturecell = new html_table_cell();
|
||||
$picturecell->attributes['class'] = 'left side picture';
|
||||
$picturecell->text = print_group_picture($group, $course->id, true, true, false);
|
||||
// Store the rows we want to display in the group info.
|
||||
$groupinforow = array();
|
||||
|
||||
$contentcell = new html_table_cell();
|
||||
$contentcell->attributes['class'] = 'content';
|
||||
|
||||
$group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'group', 'description', $group->id);
|
||||
if (!isset($group->descriptionformat)) {
|
||||
$group->descriptionformat = FORMAT_MOODLE;
|
||||
// Check if there is a picture to display.
|
||||
if (!empty($group->picture)) {
|
||||
$picturecell = new html_table_cell();
|
||||
$picturecell->attributes['class'] = 'left side picture';
|
||||
$picturecell->text = print_group_picture($group, $course->id, true, true, false);
|
||||
$groupinforow[] = $picturecell;
|
||||
}
|
||||
|
||||
// Check if there is a description to display.
|
||||
$group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'group', 'description', $group->id);
|
||||
if (!empty($group->description)) {
|
||||
if (!isset($group->descriptionformat)) {
|
||||
$group->descriptionformat = FORMAT_MOODLE;
|
||||
}
|
||||
|
||||
$options = new stdClass;
|
||||
$options->overflowdiv = true;
|
||||
|
||||
$contentcell = new html_table_cell();
|
||||
$contentcell->attributes['class'] = 'content';
|
||||
$contentcell->text = format_text($group->description, $group->descriptionformat, $options);
|
||||
$groupinforow[] = $contentcell;
|
||||
}
|
||||
|
||||
// Check if we have something to show.
|
||||
if (!empty($groupinforow)) {
|
||||
$groupinfotable = new html_table();
|
||||
$groupinfotable->attributes['class'] = 'groupinfobox';
|
||||
$groupinfotable->data[] = new html_table_row($groupinforow);
|
||||
echo html_writer::table($groupinfotable);
|
||||
}
|
||||
$options = new stdClass;
|
||||
$options->overflowdiv = true;
|
||||
$contentcell->text = format_text($group->description, $group->descriptionformat, $options);
|
||||
$groupinfotable->data[] = new html_table_row(array($picturecell, $contentcell));
|
||||
echo html_writer::table($groupinfotable);
|
||||
|
||||
/// Print the editing form
|
||||
?>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['availablelangs'] = 'Списък на наличните езици';
|
||||
$string['availablelangs'] = 'Налични езикови пакети';
|
||||
$string['chooselanguagehead'] = 'Изберете език';
|
||||
$string['chooselanguagesub'] = 'Моля, изберете език за инсталацията. Този език ще бъде, също така, език по подразбиране на сайта, но може да бъде променен и по-късно след инсталирането.';
|
||||
$string['databasehost'] = 'Хост на базата данни';
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['language'] = 'زمان';
|
||||
$string['reload'] = 'بارکردنەوە';
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Admin directory';
|
||||
$string['availablelangs'] = 'List of available languages';
|
||||
$string['availablelangs'] = 'Available language packs';
|
||||
$string['chooselanguagehead'] = 'Choose a language';
|
||||
$string['chooselanguagesub'] = 'Please choose a language for the installation. This language will also be used as the default language for the site, though it may be changed later.';
|
||||
$string['clialreadyconfigured'] = 'File config.php already exists, please use admin/cli/install_database.php if you want to install this site.';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['environmentrequireversion'] = 'version {$a->needed} is required and ye are running {$a->current}';
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['remotedownloaderror'] = 'Download of component to yer server failed, please verify proxy settings, PHP cURL extension is highly recommended.<br /><br />Ye must download the <a href="{$a->url}">{$a->url}</a> file manually, copy it to "{$a->dest}" in yer server and unzip it there.';
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['clialreadyconfigured'] = 'File config.php already exists, please use admin/cli/install_database.php if ye want to install this site.';
|
||||
$string['clialreadyinstalled'] = 'File config.php already exists, please use admin/cli/upgrade.php if ye want to upgrade this site.';
|
||||
$string['environmenthead'] = 'Checking yer environment ...';
|
||||
$string['environmentsub2'] = 'Each Moodle release has some minimum PHP version requirement and a number of mandatory PHP extensions.
|
||||
Full environment check is done before each install and upgrade. Please contact server administrator if ye do not know how to install new version or enable PHP extensions.';
|
||||
$string['memorylimithelp'] = '<p>The PHP memory limit for yer server is currently set to {$a}.</p>
|
||||
|
||||
<p>This may cause Moodle to have memory problems later on, especially
|
||||
if ye have a lot of modules enabled and/or a lot of users.</p>
|
||||
|
||||
<p>We recommend that ye configure PHP with a higher limit if possible, like 40M.
|
||||
There are several ways of doing this that ye can try:</p>
|
||||
<ol>
|
||||
<li>If ye are able to, recompile PHP with <i>--enable-memory-limit</i>.
|
||||
This will allow Moodle to set the memory limit itself.</li>
|
||||
<li>If ye have access to yer php.ini file, ye can change the <b>memory_limit</b>
|
||||
setting in there to something like 40M. If ye don\'t have access ye might
|
||||
be able to ask yer administrator to do this for you.</li>
|
||||
<li>On some PHP servers ye can create a .htaccess file in the Moodle directory
|
||||
containing this line:
|
||||
<blockquote><div>php_value memory_limit 40M</div></blockquote>
|
||||
<p>However, on some servers this will prevent <b>all</b> PHP pages from working
|
||||
(you will see errors when ye look at pages) so you\'ll have to remove the .htaccess file.</p></li>
|
||||
</ol>';
|
||||
$string['pathssubadmindir'] = 'A very few webhosts use /admin as a special URL for ye to access a
|
||||
control panel or something. Unfortunately this conflicts with the standard location for the Moodle admin pages. Ye can fix this by
|
||||
renaming the admin directory in yer installation, and putting that new name here. For example: <em>moodleadmin</em>. This will fix admin links in Moodle.';
|
||||
$string['pathssubdataroot'] = 'Ye need a place where Moodle can save uploaded files. This directory should be readable AND WRITEABLE by the web server user
|
||||
(usually \'nobody\' or \'apache\'), but it must not be accessible directly via the web. The installer will try to create it if doesn\'t exist.';
|
||||
$string['pathssubwwwroot'] = 'Full web address where Moodle will be accessed.
|
||||
It\'s not possible to access Moodle using multiple addresses.
|
||||
If yer site has multiple public addresses ye must set up permanent redirects on all of them except this one.
|
||||
If yer site is accessible both from Intranet and Internet use the public address here and set up DNS so that the Intranet users may use the public address too.
|
||||
If the address is not correct please change the URL in yer browser to restart installation with a different value.';
|
||||
$string['phpversionhelp'] = '<p>Moodle requires a PHP version of at least 4.3.0 or 5.1.0 (5.0.x has a number of known problems).</p>
|
||||
<p>Ye are currently running version {$a}</p>
|
||||
<p>Ye must upgrade PHP or move to a host with a newer version of PHP!<br />
|
||||
(In case of 5.0.x ye could also downgrade to 4.4.x version)</p>';
|
||||
$string['welcomep20'] = 'Ye are seeing this page because ye have successfully installed and
|
||||
launched the <strong>{$a->packname} {$a->packversion}</strong> package in yer computer. Congratulations!';
|
||||
$string['welcomep60'] = 'The following pages will lead ye through some easy to follow steps to
|
||||
configure and set up <strong>Moodle</strong> on yer computer. Ye may accept the default
|
||||
settings or, optionally, amend them to suit yer own needs.';
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Directorio Admin';
|
||||
$string['availablelangs'] = 'Lista de idiomas disponibles';
|
||||
$string['availablelangs'] = 'Paquetes de idiomas disponibles';
|
||||
$string['chooselanguagehead'] = 'Seleccionar idioma';
|
||||
$string['chooselanguagesub'] = 'Por favor, seleccione un idioma para el proceso de instalación. Este idioma se usará también como idioma por defecto del sitio, si bien puede cambiarse más adelante.';
|
||||
$string['clialreadyconfigured'] = 'El archivo config.php ya existe, por favor use admin/cli/install_database.php si desea instalar este sitio';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Admin direktorioa';
|
||||
$string['availablelangs'] = 'Hizkuntza eskuragarrien zerrenda';
|
||||
$string['availablelangs'] = 'Hizkuntza-pakete eskuragarriak';
|
||||
$string['chooselanguagehead'] = 'Aukeratu hizkuntza bat';
|
||||
$string['chooselanguagesub'] = 'Mesedez, aukeratu instalaziorako hizkuntza bat. Hizkuntza hori erabiliko da gunearen berezko hizkuntza gisa, baina aurrerago alda daiteke.';
|
||||
$string['clialreadyconfigured'] = 'File config.php fitxategia badago, mesedez erabili admin/cli/install_database.php gune hau instalatu nahi baduzu.';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Dossier administration';
|
||||
$string['availablelangs'] = 'Liste des langues disponibles';
|
||||
$string['availablelangs'] = 'Paquetages de langue disponibles';
|
||||
$string['chooselanguagehead'] = 'Choisissez une langue';
|
||||
$string['chooselanguagesub'] = 'Veuillez choisir la langue d\'installation. Cette langue sera utilisée comme langue par défaut du site, que vous pourrez modifier ultérieurement.';
|
||||
$string['clialreadyconfigured'] = 'Le fichier config.php existe déjà. Veuillez utiliser admin/cli/install_database.php si vous désirez mettre à jour ce site.';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['thislanguage'] = 'Kreyòl Ayisyen';
|
||||
@@ -42,7 +42,7 @@ $string['componentisuptodate'] = 'Il componente è aggiornato.';
|
||||
$string['downloadedfilecheckfailed'] = 'Il controllo del file scaricato non è andato a buon fine.';
|
||||
$string['invalidmd5'] = 'La variabile di controllo era errata - prova di nuovo';
|
||||
$string['missingrequiredfield'] = 'Mancano alcuni campi richiesti';
|
||||
$string['remotedownloaderror'] = 'Lo scaricamento delle componenti non è andato a buon fine. Verificate le impostazioni del proxy. L\'estensione PHP cURL è fortemente consigliata.<br /><br />Dovete scaricare manualmente il file <a href="{$a->url}">{$a->url}</a>, copiarlo in "{$a->dest}" e decomprimerlo.';
|
||||
$string['remotedownloaderror'] = 'Lo scaricamento delle componenti non è andato a buon fine. Verificare le impostazioni del proxy. L\'estensione PHP cURL è fortemente consigliata.<br /><br />Devi scaricare manualmente il file <a href="{$a->url}">{$a->url}</a>, copiarlo in "{$a->dest}" e decomprimerlo.';
|
||||
$string['wrongdestpath'] = 'Percorso di destinazione errato';
|
||||
$string['wrongsourcebase'] = 'Indirizzo (URL) sorgente errato.';
|
||||
$string['wrongzipfilename'] = 'Il nome del file ZIP è errato.';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Cartella Admin';
|
||||
$string['availablelangs'] = 'Elenco delle lingue disponibili:';
|
||||
$string['availablelangs'] = 'Elenco delle lingue disponibili';
|
||||
$string['chooselanguagehead'] = 'Scegli la lingua';
|
||||
$string['chooselanguagesub'] = 'Scegli la lingua da usare durante l\'installazione. La lingua usata nel sito e dagli utenti potrà essere modificata in seguito.';
|
||||
$string['clialreadyconfigured'] = 'Il file config.php esiste già, per favore utilizza admin/cli/install_database.php se desideri installare questo sito.';
|
||||
@@ -53,8 +53,7 @@ $string['memorylimithelp'] = '<p>Il limite di memoria assegnata al PHP attualmen
|
||||
|
||||
<p>Tale limite potrà causare problemi nel funzionamento di Moodle, specialmente se usi molti moduli di attività con molti utenti.</p>
|
||||
|
||||
<p>Ti raccomandiamo di impostare il PHP con un limite più alto se possibile, ad esempio 40M.
|
||||
Ci sono diversi modi che puoi provare:
|
||||
<p>Ti raccomandiamo di impostare il PHP con un limite più alto, ad esempio 40M, usando uno dei modi seguenti:
|
||||
<ol>
|
||||
<li>Se possibile, ricompila il PHP con l\'opzione <i>--enable-memory-limit</i>.
|
||||
Questo consentirà a Moodle di impostare in autonomia il limite di memoria.</li>
|
||||
@@ -78,10 +77,10 @@ $string['pathsunsecuredataroot'] = 'La posizione della Cartella dati non è sicu
|
||||
$string['pathswrongadmindir'] = 'La cartella Admin non esiste';
|
||||
$string['phpextension'] = '{$a} estensioni PHP';
|
||||
$string['phpversion'] = 'Versione PHP';
|
||||
$string['phpversionhelp'] = '<p>Moodle necessita come minimo della versione 4.3.0 o 5.1.0 del PHP. (La versione 5.0.x soffre di problemi ben conosciuti)</p>
|
||||
<p>La versione installata nel vostro sistema è la {$a}</p>
|
||||
<p>Dovete aggiornare la versione del PHP oppure spostarsi su un host che abbia una versione più aggiornata del PHP!<br>
|
||||
(Se avete la 5.0.x, potete fare il downgrade alla versione 4.4.x)</p>';
|
||||
$string['phpversionhelp'] = '<p>Moodle necessita come minimo della versione 4.3.0 o 5.1.0 del PHP. (La versione 5.0.x soffre di problemi noti)</p>
|
||||
<p>La versione installata nel sistema è la {$a}</p>
|
||||
<p>E\' necessario aggiornare la versione del PHP oppure spostarsi su un host che abbia una versione più aggiornata del PHP!<br>
|
||||
(Dalla 5.0.x, è possibile eseguire il downgrade alla versione 4.4.x)</p>';
|
||||
$string['welcomep10'] = '{$a->installername} ({$a->installerversion})';
|
||||
$string['welcomep20'] = 'Se vedi questa pagina hai installato correttamente e lanciato il pacchetto <strong>{$a->packname} {$a->packversion}</strong>. Complimenti!';
|
||||
$string['welcomep30'] = 'La release di <strong>{$a->installername}</strong> include l\'applicazione per creare l\'ambiente necessario a far girare <strong>Moodle</strong>:';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Adminディレクトリ';
|
||||
$string['availablelangs'] = '利用可能な言語一覧';
|
||||
$string['availablelangs'] = '利用可能な言語パック';
|
||||
$string['chooselanguagehead'] = '言語を選択してください。';
|
||||
$string['chooselanguagesub'] = 'インストールのみに使用する言語を選択してください。この言語は、サイトのデフォルト言語としても使用されます。サイト言語は、後で変更することが可能です。';
|
||||
$string['clialreadyconfigured'] = 'ファイルconfig.phpは、すでに登録されています。このサイトをインストールしたい場合、admin/cli/install_database.phpを使用してください。';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Automatically generated strings for Moodle installer
|
||||
*
|
||||
* Do not edit this file manually! It contains just a subset of strings
|
||||
* needed during the very first steps of installation. This file was
|
||||
* generated automatically by export-installer.php (which is part of AMOS
|
||||
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
|
||||
* list of strings defined in /install/stringnames.txt.
|
||||
*
|
||||
* @package installer
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['thislanguage'] = 'Кыргызча';
|
||||
@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
$string['admindirname'] = 'Direktori admin';
|
||||
$string['availablelangs'] = 'Senarai bahasa yang tersedia';
|
||||
$string['chooselanguagehead'] = 'Pilih bahasa';
|
||||
$string['chooselanguagesub'] = 'Sila pilih bahasa untuk pemasangan. Bahasa ini juga akan digunakan sebagai bahasa lalai untuk laman, ia boleh diubah kemudian.';
|
||||
$string['chooselanguagesub'] = 'Sila pilih bahasa untuk pemasangan. Bahasa dipilih akan digunakan sebagai bahasa lalai untuk laman, walau bagaimanapun ia boleh diubah kemudian.';
|
||||
$string['clialreadyinstalled'] = 'config.php fail sudah wujud, sila gunakan admin/cli/upgrade.php jika anda mahu menaik taraf laman web anda.';
|
||||
$string['cliinstallheader'] = 'Baris arahan pemasangan program Moodle {$a}';
|
||||
$string['databasehost'] = 'Hos pangkalan data';
|
||||
@@ -46,7 +46,7 @@ $string['environmenthead'] = 'Memeriksa persekitaran anda ...';
|
||||
$string['environmentsub2'] = 'Setiap pelepasan Moodle mempunyai keperluan minimum versi PHP dan beberapa sambungan mandatori PHP. Persekitaran penuh disemak sebelum setiap pemasangan dan naik taraf. Sila hubungi pentadbir pelayan jika anda tidak tahu bagaimana untuk memasang versi baru atau membolehkan sambungan PHP.';
|
||||
$string['errorsinenvironment'] = 'Semakan persekitaran gagal!';
|
||||
$string['installation'] = 'Pemasangan';
|
||||
$string['langdownloaderror'] = 'Malangnya bahasa "{$a}" tidak boleh dimuat turun. Proses pemasangan akan diteruskan dalam bahasa Bahasa Inggeris.';
|
||||
$string['langdownloaderror'] = 'Malangnya fail bahasa "{$a}" tidak dapat dimuat turun. Proses pemasangan akan diteruskan dalam Bahasa Inggeris.';
|
||||
$string['memorylimithelp'] = '<p> Had memori PHP untuk pelayan anda ditetapkan kepada {$a}. </p>
|
||||
|
||||
<p> Hal ini akan menyebabkan Moodle untuk mendapat masalah memori di kemudian hari, terutama jika anda mempunyai banyak modul yang diaktifkan dan/atau ramai pengguna. </p>
|
||||
@@ -63,9 +63,9 @@ $string['pathsrodataroot'] = 'Direktori dataroot tidak dapat ditulis.';
|
||||
$string['pathsroparentdataroot'] = 'Direktori induk ({$a->parent}) tidak boleh tulis. Direktori data ({$a->dataroot}) tidak boleh diwujudkan oleh pemasang.';
|
||||
$string['pathssubadmindir'] = 'Beberapa webhos menggunakan /admin sebagai URL khas untuk anda akses panel kawalan atau sesuatu yang lain. Malangnya, ini bertentangan dengan lokasi standard untuk halaman pentadbiran Moodle. Anda boleh memperbaiki ini dengan menamakan semula direktori admin dalam pemasangan anda, dan meletakkan nama baru di sini. Sebagai contoh: <br /> <br /> <b> moodleadmin </ b> <br /> <br />
|
||||
Ini akan memulihkan pautan admin dalam Moodle.';
|
||||
$string['pathssubdataroot'] = 'Anda perlukan lokasi di mana Moodle boleh menyimpan fail yang dimuat naik. Direktori ini sepatutnya boleh dibaca DAN BOLEH DITULIS oleh pengguna web server (biasanya \'nobody\' atau \'apache\'), tetapi ia mestilah tidak boleh diakses secara langsung melalui laman web. Pemasang akan cuba untuk mewujudkannya jika belum ada.';
|
||||
$string['pathssubdirroot'] = 'Direktori laluan penuh untuk pemasangan Moodle.';
|
||||
$string['pathssubwwwroot'] = 'Alamat penuh web di mana Moodle akan dicapai. Adalah tidak mungkin untuk mengakses Moodle menggunakan pelbagai alamat. Jika laman anda mempunyai beberapa alamat awam, anda mesti menubuhkan pelencongan kekal kepada semua mereka kecuali yang satu ini. Jika laman web anda boleh diakses kedua-duanya dari Intranet dan Internet menggunakan alamat awam di sini dan menubuhkan DNS supaya pengguna Intranet boleh menggunakan alamat awam juga. Jika alamat itu tidak betul, sila ubah URL di pelayar anda untuk memulakan semula pemasangan dengan nilai yang berbeza.';
|
||||
$string['pathssubdataroot'] = 'Anda perlukan lokasi di mana Moodle boleh menyimpan fail yang dimuat naik. Direktori ini sepatutnya boleh dibaca DAN DITULIS oleh pengguna web server (biasanya \'nobody\' atau \'apache\'), tetapi ia mestilah tidak boleh diakses secara langsung melalui laman web. Pemasang akan cuba untuk wujudkannya jika belum ada.';
|
||||
$string['pathssubdirroot'] = 'Laluan penuh direktori untuk pemasangan Moodle.';
|
||||
$string['pathssubwwwroot'] = 'Alamat penuh web di mana Moodle akan dicapai. Ia tidak mungkin untuk mengakses Moodle menggunakan berbilang alamat. Jika laman anda mempunyai pelbagai alamat awam, anda mesti menubuhkan pelencongan kekal kepada yang lain kecuali yang satu ini. Jika laman web anda boleh diakses kedua-dua Intranet dan Internet, gunakan alamat awam di sini dan tubuhkan DNS supaya pengguna Intranet boleh gunakan alamat awam juga. Jika alamat sekarang tidak betul, sila ubah URL di pelayar anda untuk memulakan semula pemasangan dengan nilai yang berbeza.';
|
||||
$string['pathsunsecuredataroot'] = 'Lokasi dataroot tidak selamat';
|
||||
$string['pathswrongadmindir'] = 'Direktori admin tidak wujud';
|
||||
$string['phpextension'] = 'Sambungan PHP {$a}';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Admin-map';
|
||||
$string['availablelangs'] = 'Lijst met beschikbare talen';
|
||||
$string['availablelangs'] = 'Beschikbare taalpakketten';
|
||||
$string['chooselanguagehead'] = 'Kies een taal';
|
||||
$string['chooselanguagesub'] = 'Kies een taal voor de installatie. Deze taal zal ook als standaardtaal voor de site gebruikt worden, maar die instelling kun je later nog wijzigen.';
|
||||
$string['clialreadyconfigured'] = 'Bestand config.php bestaat al, maak aub gebruik van admin/cli/install_database.php indien je deze site wenst te installeren.';
|
||||
|
||||
@@ -42,7 +42,7 @@ $string['componentisuptodate'] = 'O componente está atualizado.';
|
||||
$string['downloadedfilecheckfailed'] = 'A verificação do ficheiro descarregado falhou.';
|
||||
$string['invalidmd5'] = 'A variável de verificação está errada - tente novamente.';
|
||||
$string['missingrequiredfield'] = 'Um dos campos obrigatórios está em falta';
|
||||
$string['remotedownloaderror'] = 'A descarga do componente para o servidor falhou. Verifique as configurações do proxy. A instalação da extensão cURL do PHP é muito recomendada.<br /><br />Terá que descarregar o ficheiro <a href="{$a->url}">{$a->url}</a> manualmente, copiá-lo para a pasta "{$a->dest}" no seu servidor e descompactá-lo.';
|
||||
$string['remotedownloaderror'] = 'O download do componente para o servidor falhou. Verifique as configurações do proxy. A instalação da extensão cURL do PHP é muito recomendada.<br /><br />Terá que descarregar o ficheiro <a href="{$a->url}">{$a->url}</a> manualmente, copiá-lo para a pasta "{$a->dest}" no seu servidor e descompactá-lo.';
|
||||
$string['wrongdestpath'] = 'Caminho de destino errado.';
|
||||
$string['wrongsourcebase'] = 'Base do URL de origem errada';
|
||||
$string['wrongzipfilename'] = 'Nome de ficheiro ZIP errado.';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['admindirname'] = 'Pasta de administração';
|
||||
$string['availablelangs'] = 'Idiomas disponíveis';
|
||||
$string['availablelangs'] = 'Pacotes de idiomas disponíveis';
|
||||
$string['chooselanguagehead'] = 'Selecione um idioma';
|
||||
$string['chooselanguagesub'] = 'Selecione o idioma a utilizar durante a instalação. Poderá depois selecionar um outro idioma para o site e para os utilizadores.';
|
||||
$string['clialreadyconfigured'] = 'O ficheiro config.php já existe, use admin/cli/install_database.php se desejar instalar este site.';
|
||||
@@ -48,7 +48,7 @@ $string['environmenthead'] = 'A verificar sistema...';
|
||||
$string['environmentsub2'] = 'Cada nova versão do Moodle tem pré-requisitos mínimos relativamente à versão do PHP e extensões necessárias para o seu correto funcionamento. Estes pré-requisitos são verificados sempre que o Moodle é instalado ou atualizado. Contacte o administrador do servidor caso seja necessário atualizar a versão do PHP ou instalar novas extensões.';
|
||||
$string['errorsinenvironment'] = 'A verificação do sistema falhou!';
|
||||
$string['installation'] = 'Instalação';
|
||||
$string['langdownloaderror'] = 'Não foi possível instalar o idioma <b>{$a}</b> por falha na descarga. O processo de instalação continuará em Inglês.';
|
||||
$string['langdownloaderror'] = 'Não foi possível instalar o idioma <b>{$a}</b> por falha no download. O processo de instalação continuará em Inglês.';
|
||||
$string['memorylimithelp'] = '<p>O limite de memória para o PHP definido atualmente no servidor é <b>{$a}</b>.</p><p>Um número elevado de módulos em utilização ou de utilizadores registados pode fazer com que o Moodle apresente problemas de falta de memória.</p><p>É recomendado que o PHP seja configurado com um limite de memória de pelo menos 40MB. Esta configuração pode ser definida de diversas formas:</p><ol><li>Compilação do PHP com o parâmetro <b>--enable-memory-limit</b>. Esta definição permitirá ao próprio Moodle definir o valor a utilizar.</li><li>Alteração do parâmetro <b>memory_limit</b> no ficheiro de configuração do PHP para um valor igual ou superior a 40MB.</li><li>Criação de um ficheiro <b>.htaccess</b> na raiz da pasta do Moodle com a linha <b>php_value memory_limit 40M</b><p>ATENÇÃO: Em alguns servidores esta configuração impedirá o funcionamento de <b>todas</b> as páginas PHP. Nestes casos, não poderá ser utilizado o ficheiro <b>.htaccess</b>.</p></li></ol>';
|
||||
$string['paths'] = 'Caminhos';
|
||||
$string['pathserrcreatedataroot'] = 'O programa de instalação não conseguiu criar a pasta de dados <b>{$a->dataroot}</b>.';
|
||||
|
||||
+6
-9
@@ -161,15 +161,12 @@ $string['configcronremotepassword'] = 'This means that the cron.php script canno
|
||||
$string['configcurlcache'] = 'Time-to-live for cURL cache, in seconds.';
|
||||
$string['configcustommenuitems'] = 'You can configure a custom menu here to be shown by themes. Each line consists of some menu text, a link URL (optional), a tooltip title (optional) and a language code or comma-separated list of codes (optional, for displaying the line to users of the specified language only), separated by pipe characters. You can specify a structure using hyphens. For example:
|
||||
<pre>
|
||||
Moodle community|http://moodle.org
|
||||
-Moodle free support|http://moodle.org/support
|
||||
-Moodle development|http://moodle.org/development
|
||||
--Moodle Tracker|http://tracker.moodle.org
|
||||
--Moodle Docs|http://docs.moodle.org|Moodle Docs in German
|
||||
Moodle community|https://moodle.org
|
||||
-Moodle free support|https://moodle.org/support
|
||||
-Moodle development|https://moodle.org/development
|
||||
--Moodle Docs|http://docs.moodle.org|Moodle Docs
|
||||
--German Moodle Docs|http://docs.moodle.org/de|Documentation in German|de
|
||||
-Moodle News|http://moodle.org/news Moodle company
|
||||
-Moodle commercial hosting|http://moodle.com/hosting
|
||||
-Moodle commercial support|http://moodle.com/support
|
||||
Moodle.com|http://moodle.com/
|
||||
</pre>';
|
||||
$string['configdbsessions'] = 'If enabled, this setting will use the database to store information about current sessions. This is especially useful for large/busy sites or sites built on cluster of servers. For most sites this should probably be left disabled so that the server disk is used instead. Note that changing this setting now will log out all current users (including you). If you are using MySQL please make sure that \'max_allowed_packet\' in my.cnf (or my.ini) is at least 4M.';
|
||||
$string['configdebug'] = 'If you turn this on, then PHP\'s error_reporting will be increased so that more warnings are printed. This is only useful for developers.';
|
||||
@@ -527,7 +524,7 @@ $string['forcelogin'] = 'Force users to log in';
|
||||
$string['forceloginforprofileimage'] = 'Force users to log in to view user pictures';
|
||||
$string['forceloginforprofileimage_help'] = 'If enabled, users must login in order to view user profile pictures and the default user picture will be used in all notification emails.';
|
||||
$string['forceloginforprofiles'] = 'Force users to log in for profiles';
|
||||
$string['forcetimezone'] = 'Force default timezone';
|
||||
$string['forcetimezone'] = 'Force timezone';
|
||||
$string['formatuninstallwithcourses'] = 'There are {$a->count} courses using {$a->format}. Their format will be changed to {$a->defaultformat} (default format for this site). Some format-specific data may be lost. Are you sure you want to proceed?';
|
||||
$string['formatuninstallconfirm'] = '{$a} will be uninstalled. No courses currently use it. Continue?';
|
||||
$string['formatuninstalled'] = 'All data associated with the format plugin \'{$a->plugin}\' has been deleted from the database. To complete the deletion (and prevent the plugin re-installing itself), you should now delete this directory from your server: {$a->directory}';
|
||||
|
||||
@@ -248,6 +248,7 @@ $string['skipmodifprevhelp'] = 'Choose whether or not to skip courses that have
|
||||
$string['title'] = 'Title';
|
||||
$string['totalcategorysearchresults'] = 'Total categories: {$a}';
|
||||
$string['totalcoursesearchresults'] = 'Total courses: {$a}';
|
||||
$string['unnamedsection'] = 'Unnamed section';
|
||||
$string['userinfo'] = 'Userinfo';
|
||||
$string['module'] = 'Module';
|
||||
$string['morecoursesearchresults'] = 'More than {$a} courses found, showing first {$a} results';
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['addfields'] = 'Add {$a} fields to form';
|
||||
$string['addfields'] = 'Add {$a} field(s) to form';
|
||||
$string['advancedelement'] = 'Advanced element';
|
||||
$string['close'] = 'Close';
|
||||
$string['day'] = 'Day';
|
||||
|
||||
@@ -202,6 +202,8 @@ $string['feedback'] = 'Feedback';
|
||||
$string['feedback_help'] = 'This box enables any comments about the grade to be added.';
|
||||
$string['feedbackadd'] = 'Add feedback';
|
||||
$string['feedbackedit'] = 'Edit feedback';
|
||||
$string['feedbackforgradeitems'] = 'Feedback for {$a}';
|
||||
$string['feedbacks'] = 'Feedbacks';
|
||||
$string['feedbacksaved'] = 'Feedback saved';
|
||||
$string['feedbackview'] = 'View feedback';
|
||||
$string['finalgrade'] = 'Final grade';
|
||||
@@ -335,6 +337,7 @@ $string['chooseaction'] = 'Choose an action ...';
|
||||
$string['choosecategory'] = 'Select category';
|
||||
$string['identifier'] = 'Identify user by';
|
||||
$string['idnumbers'] = 'ID numbers';
|
||||
$string['ignore'] = 'Ignore';
|
||||
$string['import'] = 'Import';
|
||||
$string['importcsv'] = 'Import CSV';
|
||||
$string['importcustom'] = 'Import as custom outcomes (only this course)';
|
||||
@@ -446,6 +449,7 @@ $string['numberofgrades'] = 'Number of grades';
|
||||
$string['onascaleof'] = 'on a scale of {$a->grademin} to {$a->grademax}';
|
||||
$string['operations'] = 'Operations';
|
||||
$string['options'] = 'Options';
|
||||
$string['others'] = 'Others';
|
||||
$string['outcome'] = 'Outcome';
|
||||
$string['outcome_help'] = 'This setting determines the outcome which this grade item will represent in the gradebook.';
|
||||
$string['outcomeassigntocourse'] = 'Assign another outcome to this course';
|
||||
@@ -652,6 +656,7 @@ $string['usenoscale'] = 'Use no scale';
|
||||
$string['usepercent'] = 'Use percent';
|
||||
$string['user'] = 'User';
|
||||
$string['usergrade'] = 'User {$a->fullname} ({$a->useridnumber}) on item {$a->gradeidnumber}';
|
||||
$string['userid'] = 'User ID';
|
||||
$string['userpreferences'] = 'User preferences';
|
||||
$string['userenrolmentsuspended'] = 'User enrolment suspended';
|
||||
$string['useweighted'] = 'Use weighted';
|
||||
|
||||
+4
-2
@@ -71,7 +71,7 @@ $string['addresourceoractivity'] = 'Add an activity or resource';
|
||||
$string['addresourcetosection'] = 'Add a resource to section \'{$a}\'';
|
||||
$string['address'] = 'Address';
|
||||
$string['addstudent'] = 'Add student';
|
||||
$string['addsubcategory'] = 'Add a sub-category';
|
||||
$string['addsubcategory'] = 'Add a subcategory';
|
||||
$string['addteacher'] = 'Add teacher';
|
||||
$string['admin'] = 'Admin';
|
||||
$string['adminhelpaddnewuser'] = 'To manually create a new user account';
|
||||
@@ -185,6 +185,7 @@ $string['backuploglaststatus'] = 'Last execution log';
|
||||
$string['backupmissinguserinfoperms'] = 'Note: This backup contains no user data. Exercise and Workshop activities will not be included in the backup, since these modules are not compatible with this type of backup.';
|
||||
$string['backupnext'] = 'Next backup';
|
||||
$string['backupnonisowarning'] = 'Warning: this backup is from a non-Unicode version of Moodle (pre 1.6). If this backup contains any non-ISO-8859-1 texts then they may be CORRUPTED if you try to restore them to this Unicode version of Moodle. See the <a href="http://docs.moodle.org/en/Backup_FAQ">Backup FAQ</a> for more information about how to recover this backup correctly.';
|
||||
$string['backupnotyetrun'] = 'Automated backup pending';
|
||||
$string['backuporiginalname'] = 'Backup name';
|
||||
$string['backuproleassignments'] = 'Backup role assignments for these roles';
|
||||
$string['backupsavetohelp'] = 'Full path to the directory where you want to save the backup files<br />(leave blank to save in its course default dir)';
|
||||
@@ -1246,6 +1247,7 @@ $string['options'] = 'options';
|
||||
$string['order'] = 'Order';
|
||||
$string['originalpath'] = 'Original path';
|
||||
$string['orphanedactivities'] = 'Orphaned activities';
|
||||
$string['orphanedactivitiesinsectionno'] = 'Orphaned activities (section {$a})';
|
||||
$string['other'] = 'Other';
|
||||
$string['outline'] = 'Outline';
|
||||
$string['outlinereport'] = 'Outline report';
|
||||
@@ -1631,7 +1633,7 @@ $string['stringsnotset'] = 'The following strings are not defined in {$a}';
|
||||
$string['studentnotallowed'] = 'Sorry, but you can not enter this course as \'{$a}\'';
|
||||
$string['students'] = 'Students';
|
||||
$string['studentsandteachers'] = 'Students and teachers';
|
||||
$string['subcategories'] = 'Sub-categories';
|
||||
$string['subcategories'] = 'Subcategories';
|
||||
$string['submit'] = 'Submit';
|
||||
$string['success'] = 'Success';
|
||||
$string['summary'] = 'Summary';
|
||||
|
||||
@@ -344,7 +344,7 @@ Alternatively, you may wish for students to submit each question as they go alon
|
||||
Those are probably the two most commonly used modes of behaviour. ';
|
||||
$string['importfromcoursefiles'] = '... or choose a course file to import.';
|
||||
$string['importfromupload'] = 'Select a file to upload ...';
|
||||
$string['includesubcategories'] = 'Also show questions from sub-categories';
|
||||
$string['includesubcategories'] = 'Also show questions from subcategories';
|
||||
$string['incorrect'] = 'Incorrect';
|
||||
$string['incorrectfeedback'] = 'For any incorrect response';
|
||||
$string['information'] = 'Information';
|
||||
@@ -370,7 +370,7 @@ $string['parent'] = 'Parent';
|
||||
$string['partiallycorrect'] = 'Partially correct';
|
||||
$string['partiallycorrectfeedback'] = 'For any partially correct response';
|
||||
$string['penaltyforeachincorrecttry'] = 'Penalty for each incorrect try';
|
||||
$string['penaltyforeachincorrecttry_help'] = 'When you run your questions using the \'Interactive with multiple tries\' or \'Adaptive mode\' behaviour, so that the the student will have several tries to get the question right, then this option controls how much they are penalised for each incorrect try.
|
||||
$string['penaltyforeachincorrecttry_help'] = 'When questions are run using the \'Interactive with multiple tries\' or \'Adaptive mode\' behaviour, so that the student will have several tries to get the question right, then this option controls how much they are penalised for each incorrect try.
|
||||
|
||||
The penalty is a proportion of the total question grade, so if the question is worth three marks, and the penalty is 0.3333333, then the student will score 3 if they get the question right first time, 2 if they get it right second try, and 1 of they get it right on the third try.';
|
||||
$string['previewquestion'] = 'Preview question: {$a}';
|
||||
|
||||
+244
-4
@@ -15,10 +15,9 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Box REST Client Library for PHP5 Developers
|
||||
* Box.net client.
|
||||
*
|
||||
*
|
||||
* @package moodlecore
|
||||
* @package core
|
||||
* @author James Levy <james@box.net>
|
||||
* @link http://enabled.box.net
|
||||
* @access public
|
||||
@@ -27,10 +26,251 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
require_once($CFG->libdir . '/oauthlib.php');
|
||||
|
||||
/**
|
||||
* @package moodlecore
|
||||
* Box.net client class.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class boxnet_client extends oauth2_client {
|
||||
|
||||
/** @const API URL */
|
||||
const API = 'https://api.box.com/2.0';
|
||||
|
||||
/** @const UPLOAD_API URL */
|
||||
const UPLOAD_API = 'https://upload.box.com/api/2.0';
|
||||
|
||||
/**
|
||||
* Return authorize URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function auth_url() {
|
||||
return 'https://www.box.com/api/oauth2/authorize';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a folder.
|
||||
*
|
||||
* @param string $foldername The folder name.
|
||||
* @param int $parentid The ID of the parent folder.
|
||||
* @return array Information about the new folder.
|
||||
*/
|
||||
public function create_folder($foldername, $parentid = 0) {
|
||||
$params = array('name' => $foldername, 'parent' => array('id' => (string) $parentid));
|
||||
$this->reset_state();
|
||||
$result = $this->post($this->make_url("/folders"), json_encode($params));
|
||||
$result = json_decode($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the file.
|
||||
*
|
||||
* @param int $fileid File ID.
|
||||
* @param string $path Path to download the file to.
|
||||
* @return bool Success or not.
|
||||
*/
|
||||
public function download_file($fileid, $path) {
|
||||
$this->reset_state();
|
||||
$result = $this->download_one($this->make_url("/files/$fileid/content"), array(),
|
||||
array('filepath' => $path, 'CURLOPT_FOLLOWLOCATION' => true));
|
||||
return ($result === true && $this->info['http_code'] === 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info of a file.
|
||||
*
|
||||
* @param int $fileid File ID.
|
||||
* @return object
|
||||
*/
|
||||
public function get_file_info($fileid) {
|
||||
$this->reset_state();
|
||||
$result = $this->request($this->make_url("/files/$fileid"));
|
||||
return json_decode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a folder content.
|
||||
*
|
||||
* @param int $folderid Folder ID.
|
||||
* @return object
|
||||
*/
|
||||
public function get_folder_items($folderid = 0) {
|
||||
$this->reset_state();
|
||||
$result = $this->request($this->make_url("/folders/$folderid/items",
|
||||
array('fields' => 'id,name,type,modified_at,size,owned_by')));
|
||||
return json_decode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log_out() {
|
||||
if ($accesstoken = $this->get_accesstoken()) {
|
||||
$params = array(
|
||||
'client_id' => $this->get_clientid(),
|
||||
'client_secret' => $this->get_clientsecret(),
|
||||
'token' => $accesstoken->token
|
||||
);
|
||||
$this->reset_state();
|
||||
$this->post($this->revoke_url(), $params);
|
||||
}
|
||||
parent::log_out();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a request URL.
|
||||
*
|
||||
* @param string $uri The URI to request.
|
||||
* @param array $params Query string parameters.
|
||||
* @param bool $uploadapi Whether this works with the upload API or not.
|
||||
* @return string
|
||||
*/
|
||||
protected function make_url($uri, $params = array(), $uploadapi = false) {
|
||||
$api = $uploadapi ? self::UPLOAD_API : self::API;
|
||||
$url = new moodle_url($api . '/' . ltrim($uri, '/'), $params);
|
||||
return $url->out(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a file.
|
||||
*
|
||||
* @param int $fileid The file ID.
|
||||
* @param string $newname The new file name.
|
||||
* @return object Box.net file object.
|
||||
*/
|
||||
public function rename_file($fileid, $newname) {
|
||||
// This requires a PUT request with data within it. We cannot use
|
||||
// the standard PUT request 'CURLOPT_PUT' because it expects a file.
|
||||
$data = array('name' => $newname);
|
||||
$options = array(
|
||||
'CURLOPT_CUSTOMREQUEST' => 'PUT',
|
||||
'CURLOPT_POSTFIELDS' => json_encode($data)
|
||||
);
|
||||
$url = $this->make_url("/files/$fileid");
|
||||
$this->reset_state();
|
||||
$result = $this->request($url, $options);
|
||||
$result = json_decode($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets curl for multiple requests.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reset_state() {
|
||||
$this->cleanopt();
|
||||
$this->resetHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the revoke URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function revoke_url() {
|
||||
return 'https://www.box.com/api/oauth2/revoke';
|
||||
}
|
||||
|
||||
/**
|
||||
* Share a file and return the link to it.
|
||||
*
|
||||
* @param string $fileid The file ID.
|
||||
* @param bool $businesscheck Whether or not to check if the user can share files, has a business account.
|
||||
* @return object
|
||||
*/
|
||||
public function share_file($fileid, $businesscheck = true) {
|
||||
// Sharing the file, this requires a PUT request with data within it. We cannot use
|
||||
// the standard PUT request 'CURLOPT_PUT' because it expects a file.
|
||||
$data = array('shared_link' => array('access' => 'open', 'permissions' =>
|
||||
array('can_download' => true, 'can_preview' => true)));
|
||||
$options = array(
|
||||
'CURLOPT_CUSTOMREQUEST' => 'PUT',
|
||||
'CURLOPT_POSTFIELDS' => json_encode($data)
|
||||
);
|
||||
$this->reset_state();
|
||||
$result = $this->request($this->make_url("/files/$fileid"), $options);
|
||||
$result = json_decode($result);
|
||||
|
||||
if ($businesscheck) {
|
||||
// Checks that the user has the right to share the file. If not, throw an exception.
|
||||
$this->reset_state();
|
||||
$this->head($result->shared_link->download_url);
|
||||
$info = $this->get_info();
|
||||
if ($info['http_code'] == 403) {
|
||||
throw new moodle_exception('No permission to share the file');
|
||||
}
|
||||
}
|
||||
|
||||
return $result->shared_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function search($query) {
|
||||
$this->reset_state();
|
||||
$result = $this->request($this->make_url('/search', array('query' => $query, 'limit' => 50, 'offset' => 0)));
|
||||
return json_decode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function token_url() {
|
||||
return 'https://www.box.com/api/oauth2/token';
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file.
|
||||
*
|
||||
* Please note that the file is named on Box.net using the path we are providing, and so
|
||||
* the file has the name of the stored_file hash.
|
||||
*
|
||||
* @param stored_file $storedfile A stored_file.
|
||||
* @param integer $parentid The ID of the parent folder.
|
||||
* @return object Box.net file object.
|
||||
*/
|
||||
public function upload_file(stored_file $storedfile, $parentid = 0) {
|
||||
$url = $this->make_url('/files/content', array(), true);
|
||||
$options = array(
|
||||
'filename' => $storedfile,
|
||||
'parent_id' => $parentid
|
||||
);
|
||||
$this->reset_state();
|
||||
$result = $this->post($url, $options);
|
||||
$result = json_decode($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Box REST Client Library for PHP5 Developers.
|
||||
*
|
||||
* Deprecation note: As of the 14th of December 2013 Box.net APIv1, used by this class,
|
||||
* is reaching its end of life. Please use boxnet_client() instead.
|
||||
*
|
||||
* @package core
|
||||
* @author James Levy <james@box.net>
|
||||
* @link http://enabled.box.net
|
||||
* @access public
|
||||
* @version 1.0
|
||||
* @copyright copyright Box.net 2007
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @deprecated since 2.6, 2.5.3, 2.4.7
|
||||
*/
|
||||
class boxclient {
|
||||
/** @var string */
|
||||
|
||||
+13
-3
@@ -825,6 +825,7 @@ abstract class condition_info_base {
|
||||
$a = new stdclass;
|
||||
// Display the fieldname into current lang.
|
||||
if (is_numeric($field)) {
|
||||
// Is a custom profile field (will use multilang).
|
||||
$translatedfieldname = $details->fieldname;
|
||||
} else {
|
||||
$translatedfieldname = get_user_field_name($details->fieldname);
|
||||
@@ -1035,8 +1036,15 @@ abstract class condition_info_base {
|
||||
if (!$this->is_field_condition_met($details->operator, $uservalue, $details->value)) {
|
||||
// Set available to false
|
||||
$available = false;
|
||||
// Display the fieldname into current lang.
|
||||
if (is_numeric($field)) {
|
||||
// Is a custom profile field (will use multilang).
|
||||
$translatedfieldname = $details->fieldname;
|
||||
} else {
|
||||
$translatedfieldname = get_user_field_name($details->fieldname);
|
||||
}
|
||||
$a = new stdClass();
|
||||
$a->field = format_string($details->fieldname, true, array('context' => $context));
|
||||
$a->field = format_string($translatedfieldname, true, array('context' => $context));
|
||||
$a->value = s($details->value);
|
||||
$information .= get_string('requires_user_field_'.$details->operator, 'condition', $a) . ' ';
|
||||
}
|
||||
@@ -1139,10 +1147,12 @@ abstract class condition_info_base {
|
||||
private function get_cached_grade_score($gradeitemid, $grabthelot=false, $userid=0) {
|
||||
global $USER, $DB, $SESSION;
|
||||
if ($userid==0 || $userid==$USER->id) {
|
||||
// For current user, go via cache in session
|
||||
if (empty($SESSION->gradescorecache) || $SESSION->gradescorecacheuserid!=$USER->id) {
|
||||
// For current user, go via cache in session. Force reset it every 10 minutes.
|
||||
if (empty($SESSION->gradescorecache) || $SESSION->gradescorecacheuserid!=$USER->id
|
||||
|| !isset($SESSION->gradescorecachereset) || $SESSION->gradescorecachereset+600<time()) {
|
||||
$SESSION->gradescorecache = array();
|
||||
$SESSION->gradescorecacheuserid = $USER->id;
|
||||
$SESSION->gradescorecachereset = time();
|
||||
}
|
||||
if (!array_key_exists($gradeitemid, $SESSION->gradescorecache)) {
|
||||
if ($grabthelot) {
|
||||
|
||||
+5
-5
@@ -35,8 +35,8 @@ $definitions = array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'simplekeys' => true,
|
||||
'simpledata' => true,
|
||||
'persistent' => true,
|
||||
'persistentmaxsize' => 30
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 30
|
||||
),
|
||||
|
||||
// Used to store database meta information.
|
||||
@@ -48,8 +48,8 @@ $definitions = array(
|
||||
'requireidentifiers' => array(
|
||||
'dbfamily'
|
||||
),
|
||||
'persistent' => true,
|
||||
'persistentmaxsize' => 15
|
||||
'staticacceleration' => true,
|
||||
'staticaccelerationsize' => 15
|
||||
),
|
||||
|
||||
// Event invalidation cache.
|
||||
@@ -61,7 +61,7 @@ $definitions = array(
|
||||
// cache will likely be used either lots or never.
|
||||
'eventinvalidation' => array(
|
||||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'persistent' => true,
|
||||
'staticacceleration' => true,
|
||||
'requiredataguarantee' => true,
|
||||
'simpledata' => true,
|
||||
),
|
||||
|
||||
+2
-1
@@ -43,9 +43,10 @@ $handlers = array(
|
||||
* (it is just abusing cron to do very time consuming things which is wrong any way)
|
||||
*
|
||||
* TODO: this has to be moved into separate queueing framework....
|
||||
* TODO: MDL-25508, MDL-41541
|
||||
*/
|
||||
'portfolio_send' => array (
|
||||
'handlerfile' => '/lib/portfolio.php',
|
||||
'handlerfile' => '/lib/portfoliolib.php',
|
||||
'handlerfunction' => 'portfolio_handle_event', // argument to call_user_func(), could be an array
|
||||
'schedule' => 'cron',
|
||||
'internal' => 0,
|
||||
|
||||
@@ -1552,6 +1552,8 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2012120301.11) {
|
||||
// This upgrade step is re-written under MDL-38228 (see below).
|
||||
/*
|
||||
// Retrieve the list of course_sections as a recordset to save memory
|
||||
$coursesections = $DB->get_recordset('course_sections', null, 'course, id', 'id, course, sequence');
|
||||
foreach ($coursesections as $coursesection) {
|
||||
@@ -1595,6 +1597,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
}
|
||||
$coursesections->close();
|
||||
*/
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2012120301.11);
|
||||
@@ -1611,6 +1614,22 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2012120302.01) {
|
||||
// MDL-38228. Single script to upgrade course_modules instead of 2012120301.11.
|
||||
// It replaces two scripts (now commented out) introduced in MDL-37939 and MDL-38173.
|
||||
|
||||
// This upgrade script fixes the mismatches between DB fields course_modules.section
|
||||
// and course_sections.sequence. It makes sure that each module is included
|
||||
// in the sequence of only one section and that course_modules.section points back to it.
|
||||
|
||||
// This script in included in each major version upgrade process so make sure we don't run it twice.
|
||||
if (empty($CFG->movingmoduleupgradescriptwasrun)) {
|
||||
upgrade_course_modules_sequences();
|
||||
|
||||
// To skip running the same script on the upgrade to the next major release.
|
||||
set_config('movingmoduleupgradescriptwasrun', 1);
|
||||
}
|
||||
|
||||
/*
|
||||
// Retrieve the list of course_sections as a recordset to save memory.
|
||||
// This is to fix a regression caused by MDL-37939.
|
||||
// In this case the upgrade step is fixing records where:
|
||||
@@ -1667,6 +1686,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
}
|
||||
}
|
||||
$coursesections->close();
|
||||
*/
|
||||
|
||||
upgrade_main_savepoint(true, 2012120302.01);
|
||||
}
|
||||
@@ -1779,5 +1799,55 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2012120305.08);
|
||||
}
|
||||
|
||||
if ($oldversion < 2012120306.05) {
|
||||
// Fixing possible wrong MIME type for Java Network Launch Protocol (JNLP) files.
|
||||
$select = $DB->sql_like('filename', '?', false);
|
||||
$DB->set_field_select(
|
||||
'files',
|
||||
'mimetype',
|
||||
'application/x-java-jnlp-file',
|
||||
$select,
|
||||
array('%.jnlp')
|
||||
);
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2012120306.05);
|
||||
}
|
||||
|
||||
if ($oldversion < 2012120306.09) {
|
||||
// Find all fileareas that have missing root folder entry and add the root folder entry.
|
||||
if (empty($CFG->filesrootrecordsfixed)) {
|
||||
$sql = "SELECT distinct f1.contextid, f1.component, f1.filearea, f1.itemid
|
||||
FROM {files} f1 left JOIN {files} f2
|
||||
ON f1.contextid = f2.contextid
|
||||
AND f1.component = f2.component
|
||||
AND f1.filearea = f2.filearea
|
||||
AND f1.itemid = f2.itemid
|
||||
AND f2.filename = '.'
|
||||
AND f2.filepath = '/'
|
||||
WHERE (f1.component <> 'user' or f1.filearea <> 'draft')
|
||||
and f2.id is null";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$defaults = array('filepath' => '/',
|
||||
'filename' => '.',
|
||||
'userid' => $USER->id,
|
||||
'filesize' => 0,
|
||||
'timecreated' => time(),
|
||||
'timemodified' => time(),
|
||||
'contenthash' => sha1(''));
|
||||
foreach ($rs as $r) {
|
||||
$pathhash = sha1("/$r->contextid/$r->component/$r->filearea/$r->itemid".'/.');
|
||||
$DB->insert_record('files', (array)$r + $defaults +
|
||||
array('pathnamehash' => $pathhash));
|
||||
}
|
||||
$rs->close();
|
||||
// To skip running the same script on the upgrade to the next major release.
|
||||
set_config('filesrootrecordsfixed', 1);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2012120306.09);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -164,3 +164,147 @@ function upgrade_mysql_fix_unsigned_and_lob_columns() {
|
||||
$pbar->update($i, $tablecount, "Converted unsigned/lob columns in MySQL database - $i/$tablecount.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This upgrade script fixes the mismatches between DB fields course_modules.section
|
||||
* and course_sections.sequence. It makes sure that each module is included
|
||||
* in the sequence of only one section and that course_modules.section points back to it.
|
||||
*
|
||||
* Orphaned modules (modules that were not included in any section sequence in this course)
|
||||
* will be added to their sections (or 0-section if their section is not found) and
|
||||
* made invisible since they were not accessible at all before this upgrade script.
|
||||
*
|
||||
* Note that this script does not remove non-existing modules from section sequences since
|
||||
* such operation would require much more time.
|
||||
*/
|
||||
function upgrade_course_modules_sequences() {
|
||||
global $DB;
|
||||
|
||||
$affectedcourses = array();
|
||||
// Step 1. Find all modules that point to the section which does not point back to this module.
|
||||
$sequenceconcat = $DB->sql_concat("','", "s.sequence", "','");
|
||||
$moduleconcat = $DB->sql_concat("'%,'", "m.id", "',%'");
|
||||
$sql = "SELECT m.id, m.course, m.section, s.sequence
|
||||
FROM {course_modules} m LEFT OUTER JOIN {course_sections} s
|
||||
ON m.course = s.course and m.section = s.id
|
||||
WHERE s.sequence IS NULL OR ($sequenceconcat NOT LIKE $moduleconcat)
|
||||
ORDER BY m.course";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$sections = null;
|
||||
foreach ($rs as $cm) {
|
||||
if (!isset($sections[$cm->course])) {
|
||||
// Retrieve all sections for the course (only once for each corrupt course).
|
||||
$sections = array($cm->course =>
|
||||
$DB->get_records('course_sections', array('course' => $cm->course),
|
||||
'section', 'id, section, sequence, visible'));
|
||||
if (empty($sections[$cm->course])) {
|
||||
// Very odd - the course has a module in it but has no sections. Create 0-section.
|
||||
$newsection = array('sequence' => '', 'section' => 0, 'visible' => 1);
|
||||
$newsection['id'] = $DB->insert_record('course_sections',
|
||||
$newsection + array('course' => $cm->course, 'summary' => '', 'summaryformat' => FORMAT_HTML));
|
||||
$sections[$cm->course] = array($newsection['id'] => (object)$newsection);
|
||||
}
|
||||
$affectedcourses[$cm->course] = true;
|
||||
}
|
||||
// Attempt to find the section that has this module in it's sequence.
|
||||
// If there are several of them, pick the last because this is what get_fast_modinfo() does.
|
||||
$sectionid = null;
|
||||
foreach ($sections[$cm->course] as $section) {
|
||||
if (!empty($section->sequence) && in_array($cm->id, preg_split('/,/', $section->sequence))) {
|
||||
$sectionid = $section->id;
|
||||
}
|
||||
}
|
||||
if ($sectionid) {
|
||||
// Found the section. Update course_module to point to the correct section.
|
||||
$params = array('id' => $cm->id, 'section' => $sectionid);
|
||||
if (!$sections[$cm->course][$sectionid]->visible) {
|
||||
$params['visible'] = 0;
|
||||
}
|
||||
$DB->update_record('course_modules', $params);
|
||||
} else {
|
||||
// No section in the course has this module in it's sequence.
|
||||
if (isset($sections[$cm->course][$cm->section])) {
|
||||
// Try to add module to the section it points to (if it is valid).
|
||||
$sectionid = $cm->section;
|
||||
} else {
|
||||
// Section not found. Just add to the first available section.
|
||||
reset($sections[$cm->course]);
|
||||
$sectionid = key($sections[$cm->course]);
|
||||
}
|
||||
$newsequence = ltrim($sections[$cm->course][$sectionid]->sequence . ',' . $cm->id, ',');
|
||||
$sections[$cm->course][$sectionid]->sequence = $newsequence;
|
||||
$DB->update_record('course_sections', array('id' => $sectionid, 'sequence' => $newsequence));
|
||||
// Make module invisible because it was not displayed at all before this upgrade script.
|
||||
$DB->update_record('course_modules', array('id' => $cm->id, 'section' => $sectionid, 'visible' => 0, 'visibleold' => 0));
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
unset($sections);
|
||||
|
||||
// Step 2. Find all modules that are listed in sequence of another section or listed in sequence of their section twice.
|
||||
$sequenceconcat = $DB->sql_concat("','", "s.sequence", "','");
|
||||
$moduleconcat = $DB->sql_concat("'%,'", "m.id", "',%'");
|
||||
$moduleconcatdup1 = $DB->sql_concat("'%,'", "m.id", "','", "m.id", "',%'");
|
||||
$moduleconcatdup2 = $DB->sql_concat("'%,'", "m.id", "',%,'", "m.id", "',%'");
|
||||
$sql = "SELECT m.id, m.course, m.section AS modulesectionid,
|
||||
s.id AS sectionid, s.sequence AS sectionsequence, s.section AS sectionsectionnum,
|
||||
ms.section AS modulesectionnum, ms.sequence AS modulesectionsequence
|
||||
FROM {course_modules} m JOIN {course_sections} s
|
||||
ON m.course = s.course AND
|
||||
(
|
||||
(m.section <> s.id AND $sequenceconcat LIKE $moduleconcat)
|
||||
OR
|
||||
(m.section = s.id AND $sequenceconcat LIKE $moduleconcatdup1)
|
||||
OR
|
||||
(m.section = s.id AND $sequenceconcat LIKE $moduleconcatdup2)
|
||||
)
|
||||
JOIN {course_sections} ms ON ms.id = m.section
|
||||
ORDER BY m.course, m.id, m.section DESC";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
$updatedsequences = array();
|
||||
$correctmodulesections = array();
|
||||
foreach ($rs as $cm) {
|
||||
$incorrectsectionid = $cm->sectionid;
|
||||
$incorrectsequence = $cm->sectionsequence;
|
||||
if (!isset($correctmodulesections[$cm->id])) {
|
||||
// Function get_fast_modinfo() believes that the section with the biggest sectionnum is the correct one.
|
||||
// Let's correct everything else to match with how course is displayed to the students.
|
||||
if ($cm->modulesectionnum > $cm->sectionsectionnum) {
|
||||
$correctmodulesections[$cm->id] = $cm->modulesectionid;
|
||||
} else {
|
||||
$correctmodulesections[$cm->id] = $cm->sectionid;
|
||||
// oops our module points to the wrong section.
|
||||
$DB->update_record('course_modules', array('id' => $cm->id,
|
||||
'section' => $correctmodulesections[$cm->id]));
|
||||
$incorrectsectionid = $cm->modulesectionid;
|
||||
$incorrectsequence = $cm->modulesectionsequence;
|
||||
}
|
||||
}
|
||||
if (isset($updatedsequences[$incorrectsectionid])) {
|
||||
$sequence = $updatedsequences[$incorrectsectionid];
|
||||
} else {
|
||||
$sequence = preg_split('/,/', $incorrectsequence);
|
||||
}
|
||||
if ($correctmodulesections[$cm->id] <> $incorrectsectionid) {
|
||||
// Remove all occurences of module id from section sequence.
|
||||
$sequence = array_diff($sequence, array($cm->id));
|
||||
} else {
|
||||
// Remove all occurences of module id from section sequence except for the first one.
|
||||
if (($idx = array_search($cm->id, $sequence)) !== false) {
|
||||
$firstchunk = array_splice($sequence, 0, $idx+1);
|
||||
$sequence = array_merge($firstchunk, array_diff($sequence, array($cm->id)));
|
||||
}
|
||||
}
|
||||
$updatedsequences[$incorrectsectionid] = array_values($sequence);
|
||||
$DB->update_record('course_sections', array('id' => $incorrectsectionid,
|
||||
'sequence' => join(',', $sequence)));
|
||||
$affectedcourses[$cm->course] = true;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
// Reset course cache for affected courses.
|
||||
if (!empty($affectedcourses)) {
|
||||
list($sql, $params) = $DB->get_in_or_equal(array_keys($affectedcourses));
|
||||
$DB->execute("UPDATE {course} SET modinfo = null WHERE id ".$sql, $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ header('Content-Type: text/html; charset=utf-8');
|
||||
header('X-UA-Compatible: IE=edge');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html <?php echo $htmllang ?>
|
||||
<html <?php echo $htmllang ?>>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<title><?php print_string('title', 'tinymce_dragmath')?></title>
|
||||
@@ -78,8 +78,8 @@ header('X-UA-Compatible: IE=edge');
|
||||
</object>
|
||||
<form name="form" action="#">
|
||||
<div class="mceActionPanel">
|
||||
<input type="submit" id="insert" name="insert" value="{#insert}" onclick="return DragMathDialog.insert();" />
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="return tinyMCEPopup.close();" />
|
||||
<input type="submit" id="insert" name="insert" value="<?php print_string('common:insert', 'editor_tinymce'); ?>" onclick="return DragMathDialog.insert();" />
|
||||
<input type="button" id="cancel" name="cancel" value="<?php print_string('cancel'); ?>" onclick="return tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
+3
-1
@@ -363,6 +363,8 @@ function events_process_queued_handler($qhandler) {
|
||||
$qh->status = $qhandler->status + 1;
|
||||
$DB->update_record('events_queue_handlers', $qh);
|
||||
|
||||
debugging($errormessage);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -615,4 +617,4 @@ function events_pending_count($eventname) {
|
||||
WHERE h.eventname = ?";
|
||||
|
||||
return $DB->count_records_sql($sql, array($eventname));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ class file_info_context_course extends file_info {
|
||||
* @return string
|
||||
*/
|
||||
public function get_visible_name() {
|
||||
return ($this->course->id == SITEID) ? get_string('frontpage', 'admin') : format_string($this->course->fullname, true, array('context'=>$this->context));
|
||||
return ($this->course->id == SITEID) ? get_string('frontpage', 'admin') : format_string(get_course_display_name_for_list($this->course), true, array('context'=>$this->context));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+54
-8
@@ -794,7 +794,7 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
|
||||
$newhashes = array();
|
||||
$filecount = 0;
|
||||
foreach ($draftfiles as $file) {
|
||||
if (!$options['subdirs'] && ($file->get_filepath() !== '/' or $file->is_directory())) {
|
||||
if (!$options['subdirs'] && $file->get_filepath() !== '/') {
|
||||
continue;
|
||||
}
|
||||
if (!$allowreferences && $file->is_external_file()) {
|
||||
@@ -1478,6 +1478,7 @@ function &get_mimetypes_array() {
|
||||
'jcw' => array ('type'=>'text/xml', 'icon'=>'markup'),
|
||||
'jmt' => array ('type'=>'text/xml', 'icon'=>'markup'),
|
||||
'jmx' => array ('type'=>'text/xml', 'icon'=>'markup'),
|
||||
'jnlp' => array ('type'=>'application/x-java-jnlp-file', 'icon'=>'markup'),
|
||||
'jpe' => array ('type'=>'image/jpeg', 'icon'=>'jpeg', 'groups'=>array('image', 'web_image'), 'string'=>'image'),
|
||||
'jpeg' => array ('type'=>'image/jpeg', 'icon'=>'jpeg', 'groups'=>array('image', 'web_image'), 'string'=>'image'),
|
||||
'jpg' => array ('type'=>'image/jpeg', 'icon'=>'jpeg', 'groups'=>array('image', 'web_image'), 'string'=>'image'),
|
||||
@@ -1983,6 +1984,43 @@ function send_header_404() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The readfile function can fail when files are larger than 2GB (even on 64-bit
|
||||
* platforms). This wrapper uses readfile for small files and custom code for
|
||||
* large ones.
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @param int $filesize Size of file (if left out, will get it automatically)
|
||||
* @return int|bool Size read (will always be $filesize) or false if failed
|
||||
*/
|
||||
function readfile_allow_large($path, $filesize = -1) {
|
||||
// Automatically get size if not specified.
|
||||
if ($filesize === -1) {
|
||||
$filesize = filesize($path);
|
||||
}
|
||||
if ($filesize <= 2147483647) {
|
||||
// If the file is up to 2^31 - 1, send it normally using readfile.
|
||||
return readfile($path);
|
||||
} else {
|
||||
// For large files, read and output in 64KB chunks.
|
||||
$handle = fopen($path, 'r');
|
||||
if ($handle === false) {
|
||||
return false;
|
||||
}
|
||||
$left = $filesize;
|
||||
while ($left > 0) {
|
||||
$size = min($left, 65536);
|
||||
$buffer = fread($handle, $size);
|
||||
if ($buffer === false) {
|
||||
return false;
|
||||
}
|
||||
echo $buffer;
|
||||
$left -= $size;
|
||||
}
|
||||
return $filesize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enhanced readfile() with optional acceleration.
|
||||
* @param string|stored_file $file
|
||||
@@ -2005,7 +2043,7 @@ function readfile_accel($file, $mimetype, $accelerate) {
|
||||
|
||||
if (is_object($file)) {
|
||||
header('Etag: "' . $file->get_contenthash() . '"');
|
||||
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) and $_SERVER['HTTP_IF_NONE_MATCH'] === $file->get_contenthash()) {
|
||||
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) and trim($_SERVER['HTTP_IF_NONE_MATCH'], '"') === $file->get_contenthash()) {
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
return;
|
||||
}
|
||||
@@ -2105,7 +2143,7 @@ function readfile_accel($file, $mimetype, $accelerate) {
|
||||
if (is_object($file)) {
|
||||
$file->readfile();
|
||||
} else {
|
||||
readfile($file);
|
||||
readfile_allow_large($file, $filesize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2176,7 +2214,7 @@ function send_temp_file($path, $filename, $pathisstring=false) {
|
||||
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
|
||||
header('Cache-Control: max-age=10');
|
||||
header('Cache-Control: private, max-age=10');
|
||||
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
|
||||
header('Pragma: ');
|
||||
} else { //normal http - prevent caching at all cost
|
||||
@@ -2262,15 +2300,19 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
|
||||
}
|
||||
|
||||
if ($lifetime > 0) {
|
||||
$private = '';
|
||||
if (isloggedin() and !isguestuser()) {
|
||||
$private = ' private,';
|
||||
}
|
||||
$nobyteserving = false;
|
||||
header('Cache-Control: max-age='.$lifetime);
|
||||
header('Cache-Control:'.$private.' max-age='.$lifetime);
|
||||
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
|
||||
header('Pragma: ');
|
||||
|
||||
} else { // Do not cache files in proxies and browsers
|
||||
$nobyteserving = true;
|
||||
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
|
||||
header('Cache-Control: max-age=10');
|
||||
header('Cache-Control: private, max-age=10');
|
||||
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
|
||||
header('Pragma: ');
|
||||
} else { //normal http - prevent caching at all cost
|
||||
@@ -2426,13 +2468,17 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
|
||||
}
|
||||
|
||||
if ($lifetime > 0) {
|
||||
header('Cache-Control: max-age='.$lifetime);
|
||||
$private = '';
|
||||
if (isloggedin() and !isguestuser()) {
|
||||
$private = ' private,';
|
||||
}
|
||||
header('Cache-Control:'.$private.' max-age='.$lifetime);
|
||||
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
|
||||
header('Pragma: ');
|
||||
|
||||
} else { // Do not cache files in proxies and browsers
|
||||
if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
|
||||
header('Cache-Control: max-age=10');
|
||||
header('Cache-Control: private, max-age=10');
|
||||
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
|
||||
header('Pragma: ');
|
||||
} else { //normal http - prevent caching at all cost
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user