Compare commits
212 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 06ede85e1f | |||
| 8ad8b7dba8 | |||
| 36f0835e72 | |||
| 259b9d05f3 | |||
| da20cd7b43 | |||
| acb4688d29 | |||
| 471952fe82 | |||
| 0d738689bd | |||
| 7390fdde63 | |||
| 1374c61bb4 | |||
| 98d9209a34 | |||
| 8351ce1bd0 | |||
| b911ab236c | |||
| b4730465e6 | |||
| 78cc7bee62 | |||
| 5d6eafcf10 | |||
| 090e19328e | |||
| 34b5e856b0 | |||
| c44a5d5946 | |||
| b7d7679112 | |||
| 64a17788aa | |||
| 0baa1eee59 | |||
| 9f6eeb4abf | |||
| 6a48b42ae8 | |||
| 2dd90f136c | |||
| e6647397b9 | |||
| 07fa10d725 | |||
| 98032d512d | |||
| 389235fb00 | |||
| 656237dd55 | |||
| e3cc5b1a7f | |||
| 0742ea86b2 | |||
| 41f79b5c07 | |||
| ed85c0acd2 | |||
| 9c39028179 | |||
| 9fb4a6300b | |||
| 44c9dc6e7b | |||
| 4af7c9d188 | |||
| 847dee60ce | |||
| e0be8fd6a3 | |||
| 55e03d1233 | |||
| e391f907af | |||
| bef867a96c | |||
| 4207d47742 | |||
| bd7193c7ac | |||
| 77e4a16c4f | |||
| 7daba2713e | |||
| 03b1be3005 | |||
| 5c8511ecf7 | |||
| 52435228c5 | |||
| c9dc3e5564 | |||
| ffaf18a8c1 | |||
| f5fddc6081 | |||
| 9d5a4e2b7c | |||
| ba9103b2c6 | |||
| 79196c9ed5 | |||
| a572cfe5bd | |||
| 92d7776478 | |||
| 2715f96932 | |||
| 6919d9f790 | |||
| 8be0517692 | |||
| a4b65c11b9 | |||
| 64e711f04b | |||
| e6cf40de78 | |||
| 174f5a0189 | |||
| dd56fd7c64 | |||
| 436f83f8ff | |||
| d03f904759 | |||
| 15a6af91f5 | |||
| 0a23dec07a | |||
| 6f8081bef4 | |||
| c643d3ae06 | |||
| 507ccf1c4b | |||
| 60bc533ee8 | |||
| 42f2b8d0dd | |||
| 84047d1fc9 | |||
| b79ac7e0d6 | |||
| 241ceba38c | |||
| 8e49e0833c | |||
| f6bf9c932d | |||
| 1fb2369b09 | |||
| 4de0925820 | |||
| 81f2a1686a | |||
| 5f509554a5 | |||
| edd5d0693d | |||
| d59a75a841 | |||
| 9b482d1cbe | |||
| ca090f3262 | |||
| 12db898084 | |||
| c79345c0f0 | |||
| d691571218 | |||
| 4e1bb6e10c | |||
| a7e920fbfb | |||
| 7a725d6b59 | |||
| 489c6ef357 | |||
| dbb6157aa1 | |||
| 50467e50c9 | |||
| 85a91fb98e | |||
| 75454e2567 | |||
| 06c09f30e3 | |||
| 26daa23d9d | |||
| 74a2ee73ed | |||
| fca41d2589 | |||
| 6de6a45a10 | |||
| 0f1fac1f1f | |||
| 692134ecd4 | |||
| d7706bac2c | |||
| 391e054c03 | |||
| 71f2316fe6 | |||
| 16d610019a | |||
| 4f5791da64 | |||
| c5e3a242b1 | |||
| 13ad1eaf37 | |||
| 7ca448fa83 | |||
| 37efb4f1ee | |||
| 81bd2292bc | |||
| 8fa13d155d | |||
| 465846f082 | |||
| f68815ffcf | |||
| 67b5d74b2c | |||
| 3d0e3ade75 | |||
| 7d1fb2f6ec | |||
| 227e54d65a | |||
| ee6181b1e7 | |||
| 3962c89bbf | |||
| 59137c2c5b | |||
| b83e494d6f | |||
| 3b2164bdca | |||
| aa54d70440 | |||
| d2d4bccec1 | |||
| f3a3c59f48 | |||
| 3d62a46b26 | |||
| 9aacfedb22 | |||
| 12b734434b | |||
| f9068e531c | |||
| 96506c474a | |||
| 0d66e33da5 | |||
| 934fa3ed6c | |||
| 6743d6c520 | |||
| cf76e10e4a | |||
| c800e31213 | |||
| 23580ddacb | |||
| 827fcdb347 | |||
| 60aaf1dc77 | |||
| fd8fa6f9d0 | |||
| 8adf19eda8 | |||
| a6e29ac6a3 | |||
| 52e184904f | |||
| b8d80c062e | |||
| eb9d692f8b | |||
| a805d653d1 | |||
| fe4a0cfe63 | |||
| d0e3447e43 | |||
| f046221272 | |||
| 42a50a0a45 | |||
| 77335e76e9 | |||
| ddf3e875f3 | |||
| 91fa7abf3d | |||
| b060e5b0b8 | |||
| f9c8746704 | |||
| c629aeabe3 | |||
| 27614a5e5d | |||
| ba32fc0042 | |||
| 87b05ba3e0 | |||
| 728f3c9d08 | |||
| d7dd177eb4 | |||
| 507de745e3 | |||
| bf8ff4889b | |||
| f9112bda35 | |||
| ba63612bfa | |||
| 408612d111 | |||
| 60e837038a | |||
| 4cb05cea9d | |||
| 09c1e72a56 | |||
| d2455301b7 | |||
| 1be2b904ab | |||
| 337817e669 | |||
| b17a3a5591 | |||
| c44c552efa | |||
| faa297ce6f | |||
| b6225c0f2f | |||
| 50496af78b | |||
| 8fc52ccf46 | |||
| 9f9324f408 | |||
| d4dc367a5b | |||
| 3ede344b5c | |||
| 5c686792c6 | |||
| 91a4b3bd3e | |||
| 1a6a1487f4 | |||
| a5286ae4cc | |||
| 5b97bff526 | |||
| 1c4873ba1b | |||
| 9a8f8cea49 | |||
| c37f03543b | |||
| cd4ca97611 | |||
| 77bfc4ce0f | |||
| 13c53a4a2e | |||
| d3796a2c61 | |||
| 43070e6193 | |||
| d099348e32 | |||
| c4dd3bb86f | |||
| ce8b66c67f | |||
| d38f419d5c | |||
| c102060deb | |||
| 0ae36f6638 | |||
| 3c3d544700 | |||
| c4b491a417 | |||
| 112d3b4962 | |||
| 7bb8ae5911 | |||
| dbe6d9f821 | |||
| 4927443761 | |||
| ac3e0b3c8c |
@@ -94,7 +94,7 @@ $oldversion = "$CFG->release ($CFG->version)";
|
||||
$newversion = "$release ($version)";
|
||||
|
||||
// test environment first
|
||||
if (!check_moodle_environment($version, $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, false, ENV_SELECT_RELEASE)) {
|
||||
$errors = environment_get_errors($environment_results);
|
||||
cli_heading(get_string('environment', 'admin'));
|
||||
foreach ($errors as $error) {
|
||||
|
||||
@@ -328,4 +328,118 @@
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.1" requires="1.9">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.0.25">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.2" level="required">
|
||||
</PHP>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+2
-2
@@ -387,10 +387,10 @@ class generator {
|
||||
.$this->get('number_of_modules')." modules in each section, for each course...");
|
||||
|
||||
list($modules_list_sql, $modules_params) =
|
||||
$DB->get_in_or_equal($this->get('modules_list'), SQL_PARAMS_NAMED, 'param0000', true);
|
||||
$DB->get_in_or_equal($this->get('modules_list'), SQL_PARAMS_NAMED, 'mod', true);
|
||||
|
||||
list($modules_ignored_sql, $ignore_params) =
|
||||
$DB->get_in_or_equal($this->modules_to_ignore, SQL_PARAMS_NAMED, 'param2000', false);
|
||||
$DB->get_in_or_equal($this->modules_to_ignore, SQL_PARAMS_NAMED, 'ignore', false);
|
||||
|
||||
$wheresql = "name $modules_list_sql AND name $modules_ignored_sql";
|
||||
$modules = $DB->get_records_select('modules', $wheresql, array_merge($modules_params, $ignore_params));
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ if (!core_tables_exist()) {
|
||||
echo $OUTPUT->box($releasenoteslink, 'generalbox releasenoteslink');
|
||||
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
if (!check_moodle_environment($release, $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
if (!check_moodle_environment(normalize_version($release), $environment_results, true, ENV_SELECT_RELEASE)) {
|
||||
print_upgrade_reload("index.php?agreelicense=1&lang=$CFG->lang");
|
||||
} else {
|
||||
echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
|
||||
@@ -53,11 +53,6 @@ define('INSTALLATION_OF_SELECTED_LANG', 2);
|
||||
define('DELETION_OF_SELECTED_LANG', 4);
|
||||
define('UPDATE_ALL_LANG', 5);
|
||||
|
||||
//reset and diagnose lang cache permissions
|
||||
remove_dir($CFG->dataroot.'/cache/languages');
|
||||
if (file_exists($CFG->dataroot.'/cache/languages')) {
|
||||
print_error('cannotdeletelangcache', 'error');
|
||||
}
|
||||
get_string_manager()->reset_caches();
|
||||
|
||||
$notice_ok = array();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="admin/report/customlang/db" VERSION="20101115" COMMENT="XMLDB file for Moodle admin/report/customlang"
|
||||
<XMLDB PATH="admin/report/customlang/db" VERSION="20110419" COMMENT="XMLDB file for Moodle admin/report/customlang"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -30,11 +30,11 @@
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin" PREVIOUS="id" NEXT="version"/>
|
||||
<FIELD NAME="version" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The checked out version of the plugin, null of the version is unknown" PREVIOUS="name"/>
|
||||
<FIELD NAME="version" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The checked out version of the plugin, null if the version is unknown" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
@@ -57,5 +57,18 @@ function xmldb_report_customlang_upgrade($oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2010111500, 'report', 'customlang');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the version field from integer to varchar
|
||||
*/
|
||||
if ($oldversion < 2011041900) {
|
||||
$table = new xmldb_table('report_customlang_components');
|
||||
$field = new xmldb_field('version', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'name');
|
||||
|
||||
$dbman->change_field_type($table, $field);
|
||||
|
||||
upgrade_plugin_savepoint(true, 2011041900, 'report', 'customlang');
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true); // progress bar is used here
|
||||
|
||||
require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/report/customlang/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
@@ -45,8 +47,22 @@ if ($action === 'checkout') {
|
||||
if (empty($lng)) {
|
||||
print_error('missingparameter');
|
||||
}
|
||||
report_customlang_utils::checkout($lng);
|
||||
redirect(new moodle_url('/admin/report/customlang/edit.php', array('lng' => $lng)));
|
||||
|
||||
$PAGE->set_cacheable(false); // progress bar is used here
|
||||
$output = $PAGE->get_renderer('report_customlang');
|
||||
echo $output->header();
|
||||
echo $output->heading(get_string('pluginname', 'report_customlang'));
|
||||
$progressbar = new progress_bar();
|
||||
$progressbar->create(); // prints the HTML code of the progress bar
|
||||
|
||||
// we may need a bit of extra execution time and memory here
|
||||
@set_time_limit(HOURSECS);
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
report_customlang_utils::checkout($lng, $progressbar);
|
||||
|
||||
echo $output->continue_button(new moodle_url('/admin/report/customlang/edit.php', array('lng' => $lng)), 'get');
|
||||
echo $output->footer();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action === 'checkin') {
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$string['checkin'] = 'Check in strings into disk';
|
||||
$string['checkout'] = 'Check out strings into translator';
|
||||
$string['checkout'] = 'Check out strings into the translator';
|
||||
$string['checkoutdone'] = 'Strings checked out successfully into the translator';
|
||||
$string['checkoutinprogress'] = 'Checking out strings into the translator';
|
||||
$string['confirmcheckin'] = 'You are about to check in modified strings into your local language pack. This will export the customized strings from the translator into the data directory and Moodle will start using the modified strings. Press \'Continue\' button to proceed check in.';
|
||||
$string['customlang:edit'] = 'Edit local translation';
|
||||
$string['customlang:view'] = 'View local translation';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Definition of classes used by Langugae customization admin report
|
||||
* Definition of classes used by language customization admin report
|
||||
*
|
||||
* @package report
|
||||
* @subpackage customlang
|
||||
@@ -33,6 +33,12 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class report_customlang_utils {
|
||||
|
||||
/**
|
||||
* Rough number of strings that are being processed during a full checkout.
|
||||
* This is used to estimate the progress of the checkout.
|
||||
*/
|
||||
const ROUGH_NUMBER_OF_STRINGS = 16500;
|
||||
|
||||
/** @var array cache of {@link self::list_components()} results */
|
||||
protected static $components = null;
|
||||
|
||||
@@ -83,8 +89,9 @@ class report_customlang_utils {
|
||||
* This should be executed each time before going to the translation page
|
||||
*
|
||||
* @param string $lang language code to checkout
|
||||
* @param progress_bar $progressbar optionally, the given progress bar can be updated
|
||||
*/
|
||||
public static function checkout($lang) {
|
||||
public static function checkout($lang, progress_bar $progressbar = null) {
|
||||
global $DB;
|
||||
|
||||
// make sure that all components are registered
|
||||
@@ -107,6 +114,10 @@ class report_customlang_utils {
|
||||
}
|
||||
unset($current);
|
||||
|
||||
// initialize the progress counter - stores the number of processed strings
|
||||
$done = 0;
|
||||
$strinprogress = get_string('checkoutinprogress', 'report_customlang');
|
||||
|
||||
// reload components and fetch their strings
|
||||
$stringman = get_string_manager();
|
||||
$components = $DB->get_records('report_customlang_components');
|
||||
@@ -129,6 +140,12 @@ class report_customlang_utils {
|
||||
$stringlocal = isset($local[$stringid]) ? $local[$stringid] : null;
|
||||
$now = time();
|
||||
|
||||
if (!is_null($progressbar)) {
|
||||
$done++;
|
||||
$donepercent = floor(min($done, self::ROUGH_NUMBER_OF_STRINGS) / self::ROUGH_NUMBER_OF_STRINGS * 100);
|
||||
$progressbar->update_full($donepercent, $strinprogress);
|
||||
}
|
||||
|
||||
if (isset($current[$stringid])) {
|
||||
$needsupdate = false;
|
||||
$currentoriginal = $current[$stringid]->original;
|
||||
@@ -175,6 +192,10 @@ class report_customlang_utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($progressbar)) {
|
||||
$progressbar->update_full(100, get_string('checkoutdone', 'report_customlang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,3 +63,7 @@
|
||||
background-color: #f6f6f6;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
#page-admin-report-customlang-index .continuebutton {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2010120900;
|
||||
$plugin->version = 2011041900;
|
||||
$plugin->requires = 2010120700;
|
||||
|
||||
@@ -151,19 +151,21 @@ function search_spammers($keywords) {
|
||||
$params = array('userid'=>$USER->id);
|
||||
|
||||
$keywordfull = array();
|
||||
$i = 0;
|
||||
foreach ($keywords as $keyword) {
|
||||
$keywordfull[] = $DB->sql_like('description', ':descpat', false);
|
||||
$params['descpat'] = "%$keyword%";
|
||||
$keywordfull2[] = $DB->sql_like('p.summary', ':sumpat', false);
|
||||
$params['sumpat'] = "%$keyword%";
|
||||
$keywordfull[] = $DB->sql_like('description', ':descpat'.$i, false);
|
||||
$params['descpat'.$i] = "%$keyword%";
|
||||
$keywordfull2[] = $DB->sql_like('p.summary', ':sumpat'.$i, false);
|
||||
$params['sumpat'.$i] = "%$keyword%";
|
||||
$i++;
|
||||
}
|
||||
$conditions = '( '.implode(' OR ', $keywordfull).' )';
|
||||
$conditions2 = '( '.implode(' OR ', $keywordfull2).' )';
|
||||
|
||||
$sql = "SELECT * FROM {user} WHERE deleted = 0 AND id <> :userid AND $conditions"; // Exclude oneself
|
||||
$sql2 = "SELECT u.*, p.summary FROM {user} AS u, {post} AS p WHERE $conditions2 AND u.deleted = 0 AND u.id=p.userid AND u.id <> :userid";
|
||||
$spamusers_desc = $DB->get_recordset_sql($sql);
|
||||
$spamusers_blog = $DB->get_recordset_sql($sql2);
|
||||
$spamusers_desc = $DB->get_recordset_sql($sql, $params);
|
||||
$spamusers_blog = $DB->get_recordset_sql($sql2, $params);
|
||||
|
||||
$keywordlist = implode(', ', $keywords);
|
||||
echo $OUTPUT->box(get_string('spamresult', 'report_spamcleaner').s($keywordlist)).' ...';
|
||||
|
||||
+2
-3
@@ -628,7 +628,7 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
|
||||
// Legacy type.
|
||||
$archetype = optional_param('archetype', null, PARAM_RAW);
|
||||
if ($archetype) {
|
||||
if (isset($archetype)) {
|
||||
$archetypes = get_role_archetypes();
|
||||
if (isset($archetypes[$archetype])){
|
||||
$this->role->archetype = $archetype;
|
||||
@@ -716,7 +716,6 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
}
|
||||
|
||||
protected function get_archetype_field($id) {
|
||||
global $OUTPUT;
|
||||
$options = array();
|
||||
$options[''] = get_string('none');
|
||||
foreach(get_role_archetypes() as $type) {
|
||||
@@ -1143,7 +1142,7 @@ class existing_role_holders extends role_assign_user_selector_base {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params = array_merge($params, $ctxparams);
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
|
||||
@@ -52,13 +52,22 @@ if (!during_initial_install()) { //do not use during installation
|
||||
$temp->add(new admin_setting_configtext('coursesperpage', get_string('coursesperpage', 'admin'), get_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
|
||||
|
||||
// front page default role
|
||||
$roleoptions = array(0=>get_string('none')); // roles to choose from
|
||||
if ($roles = get_all_roles()) {
|
||||
foreach ($roles as $role) {
|
||||
$roleoptions[$role->id] = strip_tags(format_string($role->name, true));
|
||||
$options = array(0=>get_string('none')); // roles to choose from
|
||||
$defaultfrontpageroleid = 0;
|
||||
foreach (get_all_roles() as $role) {
|
||||
if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
|
||||
$options[$role->id] = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
|
||||
if ($role->archetype === 'frontpage') {
|
||||
$defaultfrontpageroleid = $role->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('defaultfrontpageroleid', get_string('frontpagedefaultrole', 'admin'), '', 0, $roleoptions));
|
||||
if ($defaultfrontpageroleid and (!isset($CFG->defaultfrontpageroleid) or $CFG->defaultfrontpageroleid)) {
|
||||
//frotpage role may not exist in old upgraded sites
|
||||
unset($options[0]);
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('defaultfrontpageroleid', get_string('frontpagedefaultrole', 'admin'), '', $defaultfrontpageroleid, $options));
|
||||
|
||||
|
||||
$ADMIN->add('frontpage', $temp);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ if ($hassiteconfig) {
|
||||
$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), current_language(), get_string_manager()->get_list_of_translations())); // $CFG->lang might be set in installer already, default en is in setup.php
|
||||
$temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', 'admin'), get_string('configlangmenu', 'admin'), 1));
|
||||
$temp->add(new admin_setting_langlist());
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('langcache_desc', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('langstringcache', get_string('langstringcache', 'admin'), get_string('configlangstringcache', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('locale', get_string('localetext', 'admin'), get_string('configlocale', 'admin'), '', PARAM_FILE));
|
||||
$temp->add(new admin_setting_configselect('latinexcelexport', get_string('latinexcelexport', 'admin'), get_string('configlatinexcelexport', 'admin'), '0', array('0'=>'Unicode','1'=>'Latin')));
|
||||
|
||||
@@ -241,6 +241,8 @@ $temp->add(new admin_setting_configselect('extramemorylimit', get_string('extram
|
||||
$temp->add(new admin_setting_configtext('curlcache', get_string('curlcache', 'admin'),
|
||||
get_string('configcurlcache', 'admin'), 120, PARAM_INT));
|
||||
|
||||
$temp->add(new admin_setting_configtext('curltimeoutkbitrate', get_string('curltimeoutkbitrate', 'admin'),
|
||||
get_string('curltimeoutkbitrate_help', 'admin'), 56, PARAM_INT));
|
||||
/* //TODO: we need to fix code instead of relying on slow rcache, enable this once we have some code that is actually using it
|
||||
$temp->add(new admin_setting_special_selectsetup('cachetype', get_string('cachetype', 'admin'),
|
||||
get_string('configcachetype', 'admin'), '',
|
||||
|
||||
+25
-27
@@ -38,17 +38,18 @@ if ($hassiteconfig
|
||||
if ($ADMIN->fulltree) {
|
||||
if (!during_initial_install()) {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$allroles = array();
|
||||
$generalroles = array();
|
||||
|
||||
$otherroles = array();
|
||||
$guestroles = array();
|
||||
$userroles = array();
|
||||
$studentroles = array();
|
||||
$teacherroles = array();
|
||||
$creatornewroles = array();
|
||||
|
||||
$defaultteacherid = null;
|
||||
$defaultuserid = null;
|
||||
$defaultguestid = null;
|
||||
|
||||
foreach (get_all_roles() as $role) {
|
||||
$rolename = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
|
||||
$allroles[$role->id] = $rolename;
|
||||
switch ($role->archetype) {
|
||||
case 'manager':
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
@@ -56,58 +57,55 @@ if ($hassiteconfig
|
||||
case 'coursecreator':
|
||||
break;
|
||||
case 'editingteacher':
|
||||
$teacherroles[$role->id] = $rolename;
|
||||
$defaultteacherid = isset($defaultteacherid) ? $defaultteacherid : $role->id;
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'teacher':
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'student':
|
||||
$studentroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'guest':
|
||||
$defaultguestid = isset($defaultguestid) ? $defaultguestid : $role->id;
|
||||
$guestroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'user':
|
||||
$defaultuserid = isset($defaultuserid) ? $defaultuserid : $role->id;
|
||||
$userroles[$role->id] = $rolename;
|
||||
break;
|
||||
case 'frontpage':
|
||||
break;
|
||||
default:
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
$generalroles[$role->id] = $rolename;
|
||||
$otherroles[$role->id] = $rolename;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reset($guestroles);
|
||||
$defaultguestid = key($guestroles);
|
||||
reset($studentroles);
|
||||
$defaultstudentid = key($studentroles);
|
||||
reset($teacherroles);
|
||||
$defaultteacherid = key($teacherroles);
|
||||
if (empty($guestroles)) {
|
||||
$guestroles[0] = get_string('none');
|
||||
$defaultguestid = 0;
|
||||
}
|
||||
|
||||
if ($userroles) {
|
||||
reset($userroles);
|
||||
$defaultuserid = key($userroles);
|
||||
} else {
|
||||
$userroles = array('0'=>get_string('none'));
|
||||
if (empty($userroles)) {
|
||||
$userroles[0] = get_string('none');
|
||||
$defaultuserid = 0;
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
|
||||
get_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
|
||||
get_string('confignotloggedinroleid', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
|
||||
$temp->add(new admin_setting_configselect('guestroleid', get_string('guestroleid', 'admin'),
|
||||
get_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $generalroles)));
|
||||
get_string('guestroleid_help', 'admin'), $defaultguestid, ($guestroles + $otherroles)));
|
||||
$temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
|
||||
get_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $generalroles)));
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('nodefaultuserrolelists', get_string('nodefaultuserrolelists', 'admin'), get_string('confignodefaultuserrolelists', 'admin'), 0));
|
||||
|
||||
if (!during_initial_install()) {
|
||||
get_string('configdefaultuserroleid', 'admin'), $defaultuserid, ($userroles + $otherroles)));
|
||||
$temp->add(new admin_setting_configselect('creatornewroleid', get_string('creatornewroleid', 'admin'),
|
||||
get_string('creatornewroleid_help', 'admin'), $defaultteacherid, $creatornewroles));
|
||||
|
||||
// release memory
|
||||
unset($otherroles);
|
||||
unset($guestroles);
|
||||
unset($userroles);
|
||||
unset($creatornewroles);
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
|
||||
|
||||
+18
-7
@@ -307,6 +307,9 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
// process templates
|
||||
$user->$field = uu_process_template($formdata->$field, $user);
|
||||
$formdefaults[$field] = true;
|
||||
if (in_array($field, $upt->columns)) {
|
||||
$upt->track($field, s($user->$field), 'normal');
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($PRF_FIELDS as $field) {
|
||||
@@ -614,7 +617,13 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
|
||||
$isinternalauth = $auth->is_internal();
|
||||
|
||||
if ($DB->record_exists('user', array('email'=>$user->email))) {
|
||||
if (empty($user->email)) {
|
||||
$upt->track('email', get_string('invalidemail'), 'error');
|
||||
$upt->track('status', $strusernotaddederror, 'error');
|
||||
$userserrors++;
|
||||
continue;
|
||||
|
||||
} else if ($DB->record_exists('user', array('email'=>$user->email))) {
|
||||
if ($noemailduplicates) {
|
||||
$upt->track('email', $stremailduplicate, 'error');
|
||||
$upt->track('status', $strusernotaddederror, 'error');
|
||||
@@ -765,7 +774,7 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||
}
|
||||
}
|
||||
|
||||
$manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend, true);
|
||||
$manual->enrol_user($manualcache[$courseid], $user->id, $rid, $today, $timeend);
|
||||
|
||||
$a = new stdClass();
|
||||
$a->course = $shortname;
|
||||
@@ -898,11 +907,13 @@ while ($linenum <= $previewrows and $fields = $cir->next()) {
|
||||
$rowcols['status'][] = get_string('missingusername');
|
||||
}
|
||||
|
||||
if (!validate_email($rowcols['email'])) {
|
||||
$rowcols['status'][] = get_string('invalidemail');
|
||||
}
|
||||
if ($DB->record_exists('user', array('email'=>$rowcols['email']))) {
|
||||
$rowcols['status'][] = $stremailduplicate;
|
||||
if (isset($rowcols['email'])) {
|
||||
if (!validate_email($rowcols['email'])) {
|
||||
$rowcols['status'][] = get_string('invalidemail');
|
||||
}
|
||||
if ($DB->record_exists('user', array('email'=>$rowcols['email']))) {
|
||||
$rowcols['status'][] = $stremailduplicate;
|
||||
}
|
||||
}
|
||||
$rowcols['status'] = implode('<br />', $rowcols['status']);
|
||||
$data[] = $rowcols;
|
||||
|
||||
+61
-28
@@ -157,14 +157,14 @@ class uu_progress_tracker {
|
||||
|
||||
/**
|
||||
* Validation callback function - verified the column line of csv file.
|
||||
* Converts column names to lowercase too.
|
||||
* Converts standard column names to lowercase.
|
||||
* @param csv_import_reader $cir
|
||||
* @param array standard user fields
|
||||
* @param array custom profile fields
|
||||
* @param array $stdfields standard user fields
|
||||
* @param array $profilefields custom profile fields
|
||||
* @param moodle_url $returnurl return url in case of any error
|
||||
* @return array list of fields
|
||||
*/
|
||||
function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $frofilefields, moodle_url $returnurl) {
|
||||
function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $profilefields, moodle_url $returnurl) {
|
||||
$columns = $cir->get_columns();
|
||||
|
||||
if (empty($columns)) {
|
||||
@@ -178,22 +178,40 @@ function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $fr
|
||||
print_error('csvfewcolumns', 'error', $returnurl);
|
||||
}
|
||||
|
||||
$textlib = textlib_get_instance(); // profile fields may contain unicode chars
|
||||
|
||||
// test columns
|
||||
$processed = array();
|
||||
foreach ($columns as $key=>$unused) {
|
||||
$field = strtolower($columns[$key]); // no unicode expected here, ignore case
|
||||
if (!in_array($field, $stdfields) && !in_array($field, $frofilefields) &&// if not a standard field and not an enrolment field, then we have an error
|
||||
!preg_match('/^course\d+$/', $field) && !preg_match('/^group\d+$/', $field) &&
|
||||
!preg_match('/^type\d+$/', $field) && !preg_match('/^role\d+$/', $field) &&
|
||||
!preg_match('/^enrolperiod\d+$/', $field)) {
|
||||
print_error('invalidfieldname', 'error', $returnurl, $field);
|
||||
}
|
||||
if (in_array($field, $processed)) {
|
||||
$field = $columns[$key];
|
||||
$lcfield = $textlib->strtolower($field);
|
||||
if (in_array($field, $stdfields) or in_array($lcfield, $stdfields)) {
|
||||
// standard fields are only lowercase
|
||||
$newfield = $lcfield;
|
||||
|
||||
} else if (in_array($field, $profilefields)) {
|
||||
// exact profile field name match - these are case sensitive
|
||||
$newfield = $field;
|
||||
|
||||
} else if (in_array($lcfield, $profilefields)) {
|
||||
// hack: somebody wrote uppercase in csv file, but the system knows only lowercase profile field
|
||||
$newfield = $lcfield;
|
||||
|
||||
} else if (preg_match('/^(course|group|type|role|enrolperiod)\d+$/', $lcfield)) {
|
||||
// special fields for enrolments
|
||||
$newfield = $lcfield;
|
||||
|
||||
} else {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('duplicatefieldname', 'error', $returnurl, $field);
|
||||
print_error('invalidfieldname', 'error', $returnurl, $field);
|
||||
}
|
||||
$processed[$key] = $field;
|
||||
if (in_array($newfield, $processed)) {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('duplicatefieldname', 'error', $returnurl, $newfield);
|
||||
}
|
||||
$processed[$key] = $newfield;
|
||||
}
|
||||
|
||||
return $processed;
|
||||
@@ -248,33 +266,48 @@ function uu_process_template($template, $user) {
|
||||
|
||||
if (is_null($result)) {
|
||||
return $template; //error during regex processing??
|
||||
}
|
||||
|
||||
if (is_array($template)) {
|
||||
$template['text'] = $result;
|
||||
return $t;
|
||||
} else {
|
||||
if (array($template)) {
|
||||
$template['text'] = $t;
|
||||
return $t;
|
||||
} else {
|
||||
return $t;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal callback function.
|
||||
*/
|
||||
function uu_process_template_callback($block, $username, $firstname, $lastname) {
|
||||
function uu_process_template_callback($username, $firstname, $lastname, $block) {
|
||||
$textlib = textlib_get_instance();
|
||||
$repl = $block[0];
|
||||
|
||||
switch ($block[3]) {
|
||||
case 'u': $repl = $username; break;
|
||||
case 'f': $repl = $firstname; break;
|
||||
case 'l': $repl = $lastname; break;
|
||||
case 'u':
|
||||
$repl = $username;
|
||||
break;
|
||||
case 'f':
|
||||
$repl = $firstname;
|
||||
break;
|
||||
case 'l':
|
||||
$repl = $lastname;
|
||||
break;
|
||||
default:
|
||||
return $block[0];
|
||||
}
|
||||
|
||||
switch ($block[1]) {
|
||||
case '+': $repl = $textlib->strtoupper($repl); break;
|
||||
case '-': $repl = $textlib->strtolower($repl); break;
|
||||
case '~': $repl = $textlib->strtotitle($repl); break;
|
||||
case '+':
|
||||
$repl = $textlib->strtoupper($repl);
|
||||
break;
|
||||
case '-':
|
||||
$repl = $textlib->strtolower($repl);
|
||||
break;
|
||||
case '~':
|
||||
$repl = $textlib->strtotitle($repl);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($block[2])) {
|
||||
$repl = $textlib->substr($repl, 0 , $block[2]);
|
||||
}
|
||||
|
||||
+5
-5
@@ -228,9 +228,9 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
|
||||
// find obsolete users
|
||||
if (count($userlist)) {
|
||||
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u0000', false);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.id, u.username, u.email, u.auth
|
||||
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', false);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.id, u.username, u.email, u.auth
|
||||
FROM {user} u
|
||||
WHERE u.auth=:authtype AND u.deleted=0 AND u.username $notin_sql";
|
||||
} else {
|
||||
@@ -238,7 +238,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
FROM {user} u
|
||||
WHERE u.auth=:authtype AND u.deleted=0";
|
||||
$params = array();
|
||||
$params['authtype'] = $this->authtype;
|
||||
$params['authtype'] = $this->authtype;
|
||||
}
|
||||
$remove_users = $DB->get_records_sql($sql, $params);
|
||||
|
||||
@@ -290,7 +290,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
// only go ahead if we actually
|
||||
// have fields to update locally
|
||||
if (!empty($updatekeys)) {
|
||||
list($in_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u0000', true);
|
||||
list($in_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', true);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.id, u.username
|
||||
FROM {user} u
|
||||
|
||||
@@ -53,7 +53,12 @@ abstract class backup_qtype_plugin extends backup_plugin {
|
||||
$answers->add_child($answer);
|
||||
|
||||
// Set the sources
|
||||
$answer->set_source_table('question_answers', array('question' => backup::VAR_PARENTID));
|
||||
$answer->set_source_sql('
|
||||
SELECT *
|
||||
FROM {question_answers}
|
||||
WHERE question = :question
|
||||
ORDER BY id',
|
||||
array('question' => backup::VAR_PARENTID));
|
||||
|
||||
// Aliases
|
||||
$answer->set_source_alias('answer', 'answertext');
|
||||
@@ -82,7 +87,12 @@ abstract class backup_qtype_plugin extends backup_plugin {
|
||||
$units->add_child($unit);
|
||||
|
||||
// Set the sources
|
||||
$unit->set_source_table('question_numerical_units', array('question' => backup::VAR_PARENTID));
|
||||
$unit->set_source_sql('
|
||||
SELECT *
|
||||
FROM {question_numerical_units}
|
||||
WHERE question = :question
|
||||
ORDER BY id',
|
||||
array('question' => backup::VAR_PARENTID));
|
||||
|
||||
// don't need to annotate ids nor files
|
||||
}
|
||||
|
||||
@@ -41,6 +41,6 @@ abstract class restore_plagiarism_plugin extends restore_plugin {
|
||||
if (!array_key_exists($this->pluginname, $enabledplugins)) {
|
||||
return;
|
||||
}
|
||||
parent::define_plugin_structure($connectionpoint);
|
||||
return parent::define_plugin_structure($connectionpoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2194,6 +2194,7 @@ abstract class restore_activity_structure_step extends restore_structure_step {
|
||||
/**
|
||||
* As far as activity restore steps are implementing restore_subplugin stuff, they need to
|
||||
* have the parent task available for wrapping purposes (get course/context....)
|
||||
* @return restore_task
|
||||
*/
|
||||
public function get_task() {
|
||||
return $this->task;
|
||||
|
||||
@@ -130,19 +130,7 @@ class backup_ui extends base_ui {
|
||||
}
|
||||
return $backupid;
|
||||
}
|
||||
/**
|
||||
* Cancels the current backup and redirects the user back to the relevant place
|
||||
*/
|
||||
public function cancel_backup() {
|
||||
global $PAGE;
|
||||
// Determine the approriate URL to redirect the user to
|
||||
if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm !== null) {
|
||||
$relevanturl = new moodle_url('/mod/'.$PAGE->cm->modname.'/view.php', array('id'=>$PAGE->cm->id));
|
||||
} else {
|
||||
$relevanturl = new moodle_url('/course/view.php', array('id'=>$PAGE->course->id));
|
||||
}
|
||||
redirect($relevanturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of progress bar items that can be displayed through the backup renderer.
|
||||
* @return array Array of items for the progress bar
|
||||
|
||||
@@ -81,7 +81,7 @@ class backup_ui_stage_initial extends backup_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
$data = $form->get_data();
|
||||
@@ -180,7 +180,7 @@ class backup_ui_stage_schema extends backup_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it wasn't cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
// Check it has been submit
|
||||
@@ -288,7 +288,7 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it hasn't been cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
$data = $form->get_data();
|
||||
|
||||
@@ -226,6 +226,21 @@ abstract class base_ui {
|
||||
public static function load_controller($uniqueid=false) {
|
||||
throw new coding_exception('load_controller() method needs to be overridden in each subclass of base_ui');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current backup/restore and redirects the user back to the relevant place
|
||||
*/
|
||||
public function cancel_process() {
|
||||
global $PAGE;
|
||||
// Determine the appropriate URL to redirect the user to
|
||||
if ($PAGE->context->contextlevel == CONTEXT_MODULE && $PAGE->cm !== null) {
|
||||
$relevanturl = new moodle_url('/mod/'.$PAGE->cm->modname.'/view.php', array('id'=>$PAGE->cm->id));
|
||||
} else {
|
||||
$relevanturl = new moodle_url('/course/view.php', array('id'=>$PAGE->course->id));
|
||||
}
|
||||
redirect($relevanturl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of progress bar items that can be displayed through the backup renderer.
|
||||
* @return array Array of items for the progress bar
|
||||
|
||||
@@ -392,7 +392,7 @@ class restore_ui_stage_schema extends restore_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it wasn't cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
// Check it has been submit
|
||||
@@ -500,7 +500,7 @@ class restore_ui_stage_review extends restore_ui_stage {
|
||||
$form = $this->initialise_stage_form();
|
||||
// Check it hasn't been cancelled
|
||||
if ($form->is_cancelled()) {
|
||||
$this->ui->cancel_backup();
|
||||
$this->ui->cancel_process();
|
||||
}
|
||||
|
||||
$data = $form->get_data();
|
||||
|
||||
@@ -1,15 +1,65 @@
|
||||
<?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/>.
|
||||
|
||||
// seems to work...
|
||||
// maybe I should add some pretty icons?
|
||||
// or possibly add the ability to custom-name things?
|
||||
/**
|
||||
* Admin Bookmarks Block page.
|
||||
*
|
||||
* @package block
|
||||
* @subpackage admin_bookmarks
|
||||
* @copyright 2011 Moodle
|
||||
* @author 2006 vinkmar
|
||||
* 2011 Rossiani Wijaya (updated)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The admin bookmarks block class
|
||||
*/
|
||||
class block_admin_bookmarks extends block_base {
|
||||
|
||||
/** @var string */
|
||||
public $blockname = null;
|
||||
|
||||
/** @var bool */
|
||||
protected $contentgenerated = false;
|
||||
|
||||
/** @var bool|null */
|
||||
protected $docked = null;
|
||||
|
||||
/**
|
||||
* Set the initial properties for the block
|
||||
*/
|
||||
function init() {
|
||||
$this->title = get_string('pluginname', 'block_admin_bookmarks');
|
||||
$this->blockname = get_class($this);
|
||||
$this->title = get_string('pluginname', $this->blockname);
|
||||
}
|
||||
|
||||
/**
|
||||
* All multiple instances of this block
|
||||
* @return bool Returns false
|
||||
*/
|
||||
function instance_allow_multiple() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the applicable formats for this block to all
|
||||
* @return array
|
||||
*/
|
||||
function applicable_formats() {
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
return array('all' => true);
|
||||
@@ -18,58 +68,59 @@ class block_admin_bookmarks extends block_base {
|
||||
}
|
||||
}
|
||||
|
||||
function preferred_width() {
|
||||
return 210;
|
||||
}
|
||||
|
||||
function create_item($visiblename,$link,$icon) {
|
||||
$this->tempcontent .= '<a href="' . $link . '"><img src="' . $icon . '" alt="" /> ' . $visiblename . '</a><br />' . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content for this block
|
||||
*/
|
||||
function get_content() {
|
||||
|
||||
global $CFG, $USER;
|
||||
global $CFG;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
// First check if we have already generated, don't waste cycles
|
||||
if ($this->contentgenerated === true) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = new stdClass;
|
||||
$this->content->text = '';
|
||||
if (get_user_preferences('admin_bookmarks')) {
|
||||
// this is expensive! Only require when bookmakrs exist..
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
$adminroot = admin_get_root(false, false); // settings not required - only pages
|
||||
|
||||
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
|
||||
// hmm... just a liiitle (potentially) processor-intensive
|
||||
// (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here
|
||||
|
||||
/// Accessibility: markup as a list.
|
||||
$this->content->text .= '<ol class="list">'."\n";
|
||||
|
||||
$contents = array();
|
||||
foreach($bookmarks as $bookmark) {
|
||||
$temp = $adminroot->locate($bookmark);
|
||||
if ($temp instanceof admin_settingpage) {
|
||||
$this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n";
|
||||
$contenturl = new moodle_url('/admin/settings.php', array('section'=>$bookmark));
|
||||
$contentlink = html_writer::link($contenturl, $temp->visiblename);
|
||||
$contents[] = html_writer::tag('li', $contentlink);
|
||||
} else if ($temp instanceof admin_externalpage) {
|
||||
$this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n";
|
||||
$contenturl = new moodle_url($temp->url);
|
||||
$contentlink = html_writer::link($contenturl, $temp->visiblename);
|
||||
$contents[] = html_writer::tag('li', $contentlink);
|
||||
}
|
||||
}
|
||||
$this->content->text .= "</ol>\n";
|
||||
$this->content->text = html_writer::tag('ol', implode('', $contents), array('class' => 'list'));
|
||||
} else {
|
||||
$bookmarks = array();
|
||||
}
|
||||
|
||||
if (isset($this->page->section) and $this->page->section == 'search'){
|
||||
$this->content->footer = '';
|
||||
$this->page->settingsnav->initialise();
|
||||
$node = $this->page->settingsnav->get('root', navigation_node::TYPE_SETTING);
|
||||
if (!$node || !$node->contains_active_node()) {
|
||||
return $this->content;
|
||||
}
|
||||
$section = $node->find_active_node()->key;
|
||||
|
||||
if ($section == 'search' || empty($section)){
|
||||
// the search page can't be properly bookmarked at present
|
||||
$this->content->footer = '';
|
||||
} else if (($section = (isset($this->page->section) ? $this->page->section : '')) && (in_array($section, $bookmarks))) {
|
||||
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&sesskey='.sesskey().'">' . get_string('unbookmarkthispage','admin') . '</a>';
|
||||
} else if ($section = (isset($this->page->section) ? $this->page->section : '')) {
|
||||
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&sesskey='.sesskey().'">' . get_string('bookmarkthispage','admin') . '</a>';
|
||||
} else if (in_array($section, $bookmarks)) {
|
||||
$deleteurl = new moodle_url('/blocks/admin_bookmarks/delete.php', array('section'=>$section, 'sesskey'=>sesskey()));
|
||||
$this->content->footer = html_writer::link($deleteurl, get_string('unbookmarkthispage','admin'));
|
||||
} else {
|
||||
$this->content->footer = '';
|
||||
$createurl = new moodle_url('/blocks/admin_bookmarks/create.php', array('section'=>$section, 'sesskey'=>sesskey()));
|
||||
$this->content->footer = html_writer::link($createurl, get_string('bookmarkthispage','admin'));
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
|
||||
@@ -4,6 +4,8 @@ require('../../config.php');
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_login();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$PAGE->set_context($context);
|
||||
$adminroot = admin_get_root(false, false); // settings not required - only pages
|
||||
|
||||
if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
|
||||
|
||||
@@ -5,6 +5,8 @@ require('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
require_login();
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$PAGE->set_context($context);
|
||||
$adminroot = admin_get_root(false, false); // settings not required - only pages
|
||||
|
||||
if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* The comments block
|
||||
*
|
||||
* @package block
|
||||
* @subpackage comments
|
||||
* @copyright 2009 Dongsheng Cai <dongsheng@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
// Obviously required
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
|
||||
class block_comments extends block_base {
|
||||
@@ -38,15 +64,17 @@ class block_comments extends block_base {
|
||||
$this->content->footer = '';
|
||||
$this->content->text = '';
|
||||
list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
|
||||
$args = new stdClass();
|
||||
|
||||
$args = new stdClass;
|
||||
$args->context = $PAGE->context;
|
||||
$args->course = $course;
|
||||
$args->area = 'page_comments';
|
||||
$args->itemid = 0;
|
||||
// set 'env' to tell moodle tweak ui for this block
|
||||
$args->env = 'block_comments';
|
||||
$args->component = 'block_comments';
|
||||
$args->linktext = get_string('showcomments');
|
||||
$args->notoggle = true;
|
||||
$args->autostart = true;
|
||||
$args->displaycancel = true;
|
||||
$comment = new comment($args);
|
||||
$comment->set_view_permission(true);
|
||||
|
||||
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* The comments block helper functions and callbacks
|
||||
*
|
||||
* @package block
|
||||
* @subpackage comments
|
||||
* @copyright 2011 Dongsheng Cai <dongsheng@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Validate comment parameter before perform other comments actions
|
||||
*
|
||||
* @param stdClass $comment_param {
|
||||
* context => context the context object
|
||||
* courseid => int course id
|
||||
* cm => stdClass course module object
|
||||
* commentarea => string comment area
|
||||
* itemid => int itemid
|
||||
* }
|
||||
* @return boolean
|
||||
*/
|
||||
function comments_comment_validate($comment_param) {
|
||||
if ($comment_param->commentarea != 'page_comments') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
if ($comment_param->itemid != 0) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Running addtional permission check on plugins
|
||||
*
|
||||
* @param stdClass $args
|
||||
* @return array
|
||||
*/
|
||||
function comments_comment_permissions($args) {
|
||||
return array('post'=>true, 'view'=>true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate comment data before displaying comments
|
||||
*
|
||||
* @param stdClass $comment
|
||||
* @param stdClass $args
|
||||
* @return boolean
|
||||
*/
|
||||
function comments_comment_display($comments, $args) {
|
||||
if ($args->commentarea != 'page_comments') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
if ($args->itemid != 0) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
return $comments;
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
.block_messages .content {text-align:left;padding-top:5px;}
|
||||
.block_messages .content .list li.listentry {clear:both;}
|
||||
.block_messages .content .list li.listentry div.user {float:left;position:relative;}
|
||||
.block_messages .content .list li.listentry div.message {float:right;}
|
||||
.block_messages .content .footer {clear:both;}
|
||||
.block_messages .content .list li.listentry .user {float:left;position:relative;}
|
||||
.block_messages .content .list li.listentry .message {float:right;}
|
||||
.block_messages .content .info {text-align:center;}
|
||||
.block_messages .content .footer {clear:both;}
|
||||
|
||||
.dir-rtl .block_messages .content .list li.listentry .user {float:right;}
|
||||
.dir-rtl .block_messages .content .list li.listentry .message {float:left;}
|
||||
@@ -35,16 +35,18 @@
|
||||
.ie6 .block_navigation .block_tree .tree_item {width:100%;}
|
||||
|
||||
/** Overide for RTL layout **/
|
||||
.dir-rtl .block_navigation .block_tree {padding-right:0px;}
|
||||
.dir-rtl .block_navigation .block_tree li.item_with_icon > p img {right:0;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree li ul {padding-right:0;}
|
||||
.dir-rtl .block_navigation .block_tree li.depth_2 ul {padding-right:16px;}
|
||||
.dir-rtl .block_navigation .block_tree li.depth_2 ul {padding-left:0;padding-right: 7px;}
|
||||
.dir-rtl .block_navigation .block_tree .tree_item {padding-right: 18px;text-align:right;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree .tree_item.branch {background-position: center right;}
|
||||
.dir-rtl .block_navigation .block_tree .navigation_node.tree_item.branch {padding-right:0;}
|
||||
.dir-rtl .block_navigation .block_tree .root_node.leaf {padding-right:0px;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree,
|
||||
.dir-rtl .block_navigation .block_tree li ul,
|
||||
.dir-rtl .block_navigation .block_tree .navigation_node.tree_item.branch,
|
||||
.dir-rtl .block_navigation .block_tree .root_node.leaf {padding-right:0;}
|
||||
|
||||
.dir-rtl .block_navigation .block_tree li.item_with_icon > p img,
|
||||
.dir-rtl .block_navigation .block_tree .type_activity > .tree_item.branch img {right:0;left:auto;}
|
||||
|
||||
.jsenabled.dir-rtl .block_navigation .block_tree .tree_item.emptybranch {background-image: url([[pix:t/collapsed_empty_rtl]]);background-position: center right;}
|
||||
.jsenabled.dir-rtl .block_navigation .block_tree .collapsed .tree_item.branch {background-image: url([[pix:t/collapsed_rtl]]);}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
.block_online_users .content .list li.listentry {clear:both;}
|
||||
.block_online_users .content .list li.listentry div.user {float:left;position:relative;}
|
||||
.block_online_users .content .list li.listentry div.message {float:right;}
|
||||
.block_online_users .content .list li.listentry .user {float:left;position:relative;}
|
||||
.block_online_users .content .list li.listentry .message {float:right;}
|
||||
.block_online_users .content .info {text-align:center;}
|
||||
|
||||
.dir-rtl .block_online_users .content .list li.listentry .user {float:right;}
|
||||
.dir-rtl .block_online_users .content .list li.listentry .message {float:left;}
|
||||
@@ -1,4 +1,6 @@
|
||||
.block_recent_activity .activitydate,
|
||||
.block_recent_activity .activityhead {text-align:center;}
|
||||
.block_recent_activity .unlist li {margin-bottom:1em;}
|
||||
.block_recent_activity li .head .date {float:right;}
|
||||
.block_recent_activity li .head .date {float:right;}
|
||||
|
||||
.dir-rtl .block_recent_activity .content h3 {text-align: right;}
|
||||
@@ -26,8 +26,9 @@
|
||||
|
||||
/** Overide for RTL layout **/
|
||||
.dir-rtl .block_settings .block_tree {padding-right:0px;}
|
||||
.dir-rtl .block_settings .block_tree li ul {padding-right:16px;}
|
||||
.dir-rtl .block_settings .block_tree li.item_with_icon > p img {right:0;}
|
||||
.dir-rtl .block_settings .block_tree li ul {padding-left:0;padding-right: 7px;}
|
||||
.dir-rtl .block_settings .block_tree li.item_with_icon > p img,
|
||||
.dir-rtl .block_navigation .block_tree .type_activity > .tree_item.branch img {left:auto;right:0;}
|
||||
.dir-rtl .block_settings .block_tree .tree_item {padding-right: 18px;text-align:right;}
|
||||
.dir-rtl .block_settings .block_tree .tree_item.branch {background-position: center right;}
|
||||
.dir-rtl .block_settings .block_tree .root_node.leaf {padding-right:0px;}
|
||||
|
||||
@@ -966,3 +966,65 @@ function blog_get_associated_count($courseid, $cmid=null) {
|
||||
}
|
||||
return $DB->count_records('blog_association', array('contextid' => $context->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Running addtional permission check on plugin, for example, plugins
|
||||
* may have switch to turn on/off comments option, this callback will
|
||||
* affect UI display, not like pluginname_comment_validate only throw
|
||||
* exceptions.
|
||||
* Capability check has been done in comment->check_permissions(), we
|
||||
* don't need to do it again here.
|
||||
*
|
||||
* @param stdClass $comment_param {
|
||||
* context => context the context object
|
||||
* courseid => int course id
|
||||
* cm => stdClass course module object
|
||||
* commentarea => string comment area
|
||||
* itemid => int itemid
|
||||
* }
|
||||
* @return array
|
||||
*/
|
||||
function blog_comment_permissions($comment_param) {
|
||||
return array('post'=>true, 'view'=>true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate comment parameter before perform other comments actions
|
||||
*
|
||||
* @param stdClass $comment {
|
||||
* context => context the context object
|
||||
* courseid => int course id
|
||||
* cm => stdClass course module object
|
||||
* commentarea => string comment area
|
||||
* itemid => int itemid
|
||||
* }
|
||||
* @return boolean
|
||||
*/
|
||||
function blog_comment_validate($comment_param) {
|
||||
global $DB;
|
||||
// validate comment itemid
|
||||
if (!$entry = $DB->get_record('post', array('id'=>$comment_param->itemid))) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
// validate comment area
|
||||
if ($comment_param->commentarea != 'format_blog') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
// validation for comment deletion
|
||||
if (!empty($comment_param->commentid)) {
|
||||
if ($record = $DB->get_record('comments', array('id'=>$comment_param->commentid))) {
|
||||
if ($record->commentarea != 'format_blog') {
|
||||
throw new comment_exception('invalidcommentarea');
|
||||
}
|
||||
if ($record->contextid != $comment_param->context->id) {
|
||||
throw new comment_exception('invalidcontext');
|
||||
}
|
||||
if ($record->itemid != $comment_param->itemid) {
|
||||
throw new comment_exception('invalidcommentitemid');
|
||||
}
|
||||
} else {
|
||||
throw new comment_exception('invalidcommentid');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -517,7 +517,7 @@ class blog_entry {
|
||||
|
||||
} else {
|
||||
if (in_array($type, array('image/gif', 'image/jpeg', 'image/png'))) { // Image attachments don't get printed as links
|
||||
$imagereturn .= "<br />" . $OUTPUT->pix_icon($ffurl, $filename);
|
||||
$imagereturn .= '<br /><img src="'.$ffurl.'" alt="" />';
|
||||
} else {
|
||||
$imagereturn .= html_writer::link($ffurl, $image);
|
||||
$imagereturn .= format_text(html_writer::link($ffurl, $filename), FORMAT_HTML, array('context'=>$syscontext));
|
||||
@@ -718,7 +718,7 @@ class blog_listing {
|
||||
global $DB;
|
||||
|
||||
if (empty($this->entries)) {
|
||||
if ($sqlarray = $this->get_entry_fetch_sql()) {
|
||||
if ($sqlarray = $this->get_entry_fetch_sql(false, 'created DESC')) {
|
||||
$this->entries = $DB->get_records_sql($sqlarray['sql'], $sqlarray['params'], $start, $limit);
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -149,7 +149,7 @@ if ($eventid !== 0) {
|
||||
} else {
|
||||
$title = get_string('newevent', 'calendar');
|
||||
calendar_get_allowed_types($formoptions->eventtypes, $USER->id);
|
||||
$event = new calendar_event();
|
||||
$event = new stdClass();
|
||||
$event->action = $action;
|
||||
$event->course = $courseid;
|
||||
$event->timeduration = 0;
|
||||
@@ -171,6 +171,7 @@ if ($eventid !== 0) {
|
||||
$event->timestart = make_timestamp($cal_y, $cal_m, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
$event = new calendar_event($event);
|
||||
if (!calendar_add_event_allowed($event)) {
|
||||
print_error('nopermissions');
|
||||
}
|
||||
|
||||
+67
-63
@@ -460,8 +460,11 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
|
||||
}
|
||||
}
|
||||
if ($event->modulename == 'assignment'){
|
||||
// create calendar_event to test edit_event capability
|
||||
// this new event will also prevent double creation of calendar_event object
|
||||
$checkevent = new calendar_event($event);
|
||||
// TODO: rewrite this hack somehow
|
||||
if (!calendar_edit_event_allowed($event)){ // cannot manage entries, eg. student
|
||||
if (!calendar_edit_event_allowed($checkevent)){ // cannot manage entries, eg. student
|
||||
if (!$assignment = $DB->get_record('assignment', array('id'=>$event->instance))) {
|
||||
// print_error("invalidid", 'assignment');
|
||||
continue;
|
||||
@@ -1435,16 +1438,18 @@ function calendar_edit_event_allowed($event) {
|
||||
// 2) They have managegroupentries AND are in the group
|
||||
$group = $DB->get_record('groups', array('id'=>$event->groupid));
|
||||
return $group && (
|
||||
has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $group->courseid)) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', get_context_instance(CONTEXT_COURSE, $group->courseid))
|
||||
has_capability('moodle/calendar:manageentries', $event->context) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', $event->context)
|
||||
&& groups_is_member($event->groupid)));
|
||||
} else if (!empty($event->courseid)) {
|
||||
// if groupid is not set, but course is set,
|
||||
// it's definiely a course event
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid));
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
} else if (!empty($event->userid) && $event->userid == $USER->id) {
|
||||
// if course is not set, but userid id set, it's a user event
|
||||
return (has_capability('moodle/calendar:manageownentries', $sitecontext));
|
||||
return (has_capability('moodle/calendar:manageownentries', $event->context));
|
||||
} else if (!empty($event->userid)) {
|
||||
return (has_capability('moodle/calendar:manageentries', $event->context));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1675,7 +1680,7 @@ function calendar_add_event_allowed($event) {
|
||||
|
||||
switch ($event->eventtype) {
|
||||
case 'course':
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid));
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
|
||||
case 'group':
|
||||
// Allow users to add/edit group events if:
|
||||
@@ -1683,24 +1688,21 @@ function calendar_add_event_allowed($event) {
|
||||
// 2) They have managegroupentries AND are in the group
|
||||
$group = $DB->get_record('groups', array('id'=>$event->groupid));
|
||||
return $group && (
|
||||
has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $group->courseid)) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', get_context_instance(CONTEXT_COURSE, $group->courseid))
|
||||
has_capability('moodle/calendar:manageentries', $event->context) ||
|
||||
(has_capability('moodle/calendar:managegroupentries', $event->context)
|
||||
&& groups_is_member($event->groupid)));
|
||||
|
||||
case 'user':
|
||||
if ($event->userid == $USER->id) {
|
||||
return (has_capability('moodle/calendar:manageownentries', $sitecontext));
|
||||
return (has_capability('moodle/calendar:manageownentries', $event->context));
|
||||
}
|
||||
//there is no 'break;' intentionally
|
||||
|
||||
case 'site':
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, SITEID));
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
|
||||
default:
|
||||
if (isset($event->courseid) && $event->courseid > 0) {
|
||||
return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid));
|
||||
}
|
||||
return false;
|
||||
return has_capability('moodle/calendar:manageentries', $event->context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1809,6 +1811,9 @@ class calendar_event {
|
||||
$data->format = editors_get_preferred_format();
|
||||
}
|
||||
|
||||
if (empty($data->context)) {
|
||||
$data->context = $this->calculate_context($data);
|
||||
}
|
||||
$this->properties = $data;
|
||||
}
|
||||
|
||||
@@ -1858,6 +1863,39 @@ class calendar_event {
|
||||
return !empty($this->properties->{$key});
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the context value needed for calendar_event.
|
||||
* Event's type can be determine by the available value store in $data
|
||||
* It is important to check for the existence of course/courseid to determine
|
||||
* the course event.
|
||||
* Default value is set to CONTEXT_USER
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
protected function calculate_context(stdClass $data) {
|
||||
global $USER;
|
||||
|
||||
$context = null;
|
||||
if (isset($data->courseid) && $data->courseid > 0) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $data->courseid);
|
||||
} else if (isset($data->course) && $data->course > 0) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $data->course);
|
||||
} else if (isset($data->groupid) && $data->groupid > 0) {
|
||||
$group = $DB->get_record('groups', array('id'=>$data->groupid));
|
||||
$context = get_context_instance(CONTEXT_COURSE, $group->courseid);
|
||||
} else if (isset($data->userid) && $data->userid > 0 && $data->userid == $USER->id) {
|
||||
$context = get_context_instance(CONTEXT_USER);
|
||||
} else if (isset($data->userid) && $data->userid > 0 && $data->userid != $USER->id &&
|
||||
isset($data->instance) && $data->instance > 0) {
|
||||
$cm = get_coursemodule_from_id('', $data->instance, 0, false, MUST_EXIST);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $cm->course);
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_USER);
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of editoroptions for this event: Called by __get
|
||||
* Please use $blah = $event->editoroptions;
|
||||
@@ -1874,7 +1912,7 @@ class calendar_event {
|
||||
* @return string
|
||||
*/
|
||||
protected function get_description() {
|
||||
global $USER, $CFG;
|
||||
global $CFG;
|
||||
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
@@ -1883,28 +1921,10 @@ class calendar_event {
|
||||
if ($this->editorcontext === null) {
|
||||
// Switch on the event type to decide upon the appropriate context
|
||||
// to use for this event
|
||||
switch ($this->properties->eventtype) {
|
||||
case 'course':
|
||||
case 'group':
|
||||
// Course and group event files are served from the course context
|
||||
// and there are checks in plugin.php to ensure permissions are
|
||||
// followed
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
break;
|
||||
case 'user':
|
||||
// User context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
break;
|
||||
case 'site':
|
||||
// Site context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
break;
|
||||
default:
|
||||
// Hmmmm some modules use custom eventtype strings, if that is the
|
||||
// case we are going to abandon using files. Anything that uses a
|
||||
// custom type is being added manually through code
|
||||
return clean_text($this->properties->description, $this->properties->format);
|
||||
break;
|
||||
$this->editorcontext = $this->properties->context;
|
||||
if ($this->properties->eventtype != 'user' && $this->properties->eventtype != 'course'
|
||||
&& $this->properties->eventtype != 'site' && $this->properties->eventtype != 'group') {
|
||||
return clean_text($this->properties->description, $this->properties->format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1973,24 +1993,24 @@ class calendar_event {
|
||||
if ($usingeditor) {
|
||||
switch ($this->properties->eventtype) {
|
||||
case 'user':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->courseid = 0;
|
||||
$this->properties->groupid = 0;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
case 'site':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->courseid = SITEID;
|
||||
$this->properties->groupid = 0;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
case 'course':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->groupid = 0;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
case 'group':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
$this->properties->userid = $USER->id;
|
||||
break;
|
||||
default:
|
||||
@@ -2133,7 +2153,7 @@ class calendar_event {
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($deleterepeated=false) {
|
||||
global $DB, $USER, $CFG;
|
||||
global $DB;
|
||||
|
||||
// If $this->properties->id is not set then something is wrong
|
||||
if (empty($this->properties->id)) {
|
||||
@@ -2146,23 +2166,7 @@ class calendar_event {
|
||||
|
||||
// If the editor context hasn't already been set then set it now
|
||||
if ($this->editorcontext === null) {
|
||||
switch ($this->properties->eventtype) {
|
||||
case 'course':
|
||||
case 'group':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $this->properties->courseid);
|
||||
break;
|
||||
case 'user':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
break;
|
||||
case 'site':
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
break;
|
||||
default:
|
||||
// There is a chance we can get here as some modules use there own
|
||||
// eventtype strings. In this case the event has been added by code
|
||||
// and we don't need to worry about it anyway
|
||||
break;
|
||||
}
|
||||
$this->editorcontext = $this->properties->context;
|
||||
}
|
||||
|
||||
// If the context has been set delete all associated files
|
||||
@@ -2224,10 +2228,10 @@ class calendar_event {
|
||||
|
||||
if ($properties->eventtype === 'site') {
|
||||
// Site context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
} else if ($properties->eventtype === 'user') {
|
||||
// User context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
} else if ($properties->eventtype === 'group' || $properties->eventtype === 'course') {
|
||||
// First check the course is valid
|
||||
$course = $DB->get_record('course', array('id'=>$properties->courseid));
|
||||
@@ -2235,7 +2239,7 @@ class calendar_event {
|
||||
print_error('invalidcourse');
|
||||
}
|
||||
// Course context
|
||||
$this->editorcontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$this->editorcontext = $this->properties->context;
|
||||
// We have a course and are within the course context so we had
|
||||
// better use the courses max bytes value
|
||||
$this->editoroptions['maxbytes'] = $course->maxbytes;
|
||||
@@ -2375,7 +2379,7 @@ class calendar_event {
|
||||
if (!is_object($properties)) {
|
||||
throw new coding_exception('When creating an event properties should be either an object or an assoc array');
|
||||
}
|
||||
$event = new calendar_event();
|
||||
$event = new calendar_event($properties);
|
||||
if ($event->update($properties)) {
|
||||
return $event;
|
||||
} else {
|
||||
|
||||
+3
-4
@@ -40,9 +40,9 @@ M.core_comment = {
|
||||
this.component = args.component;
|
||||
this.courseid = args.courseid;
|
||||
this.contextid = args.contextid;
|
||||
this.env = args.env;
|
||||
this.autostart = (args.autostart);
|
||||
// expand comments?
|
||||
if (args.autostart) {
|
||||
if (this.autostart) {
|
||||
this.view(args.page);
|
||||
}
|
||||
// load comments
|
||||
@@ -115,7 +115,6 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
|
||||
scope = args['scope'];
|
||||
}
|
||||
//params['page'] = args.page?args.page:'';
|
||||
params['env'] = '';
|
||||
// the form element only accept certain file types
|
||||
params['sesskey'] = M.cfg.sesskey;
|
||||
params['action'] = args.action?args.action:'';
|
||||
@@ -347,7 +346,7 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
|
||||
var d = container.getStyle('display');
|
||||
if (d=='none'||d=='') {
|
||||
// show
|
||||
if (this.env != 'block_comments') {
|
||||
if (!this.autostart) {
|
||||
this.load(page);
|
||||
} else {
|
||||
this.register_delete_buttons();
|
||||
|
||||
+64
-56
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -24,87 +23,96 @@ require_once('../config.php');
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
|
||||
$contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
if (empty($CFG->usecomments)) {
|
||||
throw new comment_exception('commentsnotenabled', 'moodle');
|
||||
}
|
||||
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_url('/comment/comment_ajax.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
// Allow anonymous user to view comments providing forcelogin now enabled
|
||||
require_course_login($course, true, $cm);
|
||||
$PAGE->set_context($context);
|
||||
if (!empty($cm)) {
|
||||
$PAGE->set_cm($cm, $course);
|
||||
} else if (!empty($course)) {
|
||||
$PAGE->set_course($course);
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
$error = array('error'=>get_string('invalidsesskey'));
|
||||
$error = array('error'=>get_string('invalidsesskey', 'error'));
|
||||
die(json_encode($error));
|
||||
}
|
||||
|
||||
if (!isloggedin()) {
|
||||
// display comments on front page without permission check
|
||||
if ($action == 'get') {
|
||||
if ($context->id == get_context_instance(CONTEXT_COURSE, SITEID)->id) {
|
||||
$ignore_permission = true;
|
||||
} else {
|
||||
// tell user to log in to view comments
|
||||
$ignore_permission = false;
|
||||
echo json_encode(array('error'=>'require_login'));
|
||||
die;
|
||||
}
|
||||
} else {
|
||||
// ignore request
|
||||
die;
|
||||
}
|
||||
} else {
|
||||
$ignore_permission = false;
|
||||
}
|
||||
|
||||
$client_id = required_param('client_id', PARAM_ALPHANUM);
|
||||
$area = optional_param('area', '', PARAM_ALPHAEXT);
|
||||
$client_id = optional_param('client_id', '', PARAM_RAW);
|
||||
$commentid = optional_param('commentid', -1, PARAM_INT);
|
||||
$content = optional_param('content', '', PARAM_RAW);
|
||||
$itemid = optional_param('itemid', '', PARAM_INT);
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
|
||||
echo $OUTPUT->header(); // send headers
|
||||
|
||||
// initilising comment object
|
||||
if (!empty($client_id)) {
|
||||
$args = new stdClass();
|
||||
$args->context = $context;
|
||||
$args->course = $course;
|
||||
$args->cm = $cm;
|
||||
$args->area = $area;
|
||||
$args->itemid = $itemid;
|
||||
$args->client_id = $client_id;
|
||||
$args->component = $component;
|
||||
// only for comments in frontpage
|
||||
$args->ignore_permission = $ignore_permission;
|
||||
$manager = new comment($args);
|
||||
} else {
|
||||
die;
|
||||
}
|
||||
$args = new stdClass;
|
||||
$args->context = $context;
|
||||
$args->course = $course;
|
||||
$args->cm = $cm;
|
||||
$args->area = $area;
|
||||
$args->itemid = $itemid;
|
||||
$args->client_id = $client_id;
|
||||
$args->component = $component;
|
||||
$manager = new comment($args);
|
||||
|
||||
echo $OUTPUT->header(); // send headers
|
||||
|
||||
// process ajax request
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
$result = $manager->add($content);
|
||||
if (!empty($result) && is_object($result)) {
|
||||
$result->count = $manager->count();
|
||||
$result->client_id = $client_id;
|
||||
echo json_encode($result);
|
||||
if ($manager->can_post()) {
|
||||
$result = $manager->add($content);
|
||||
if (!empty($result) && is_object($result)) {
|
||||
$result->count = $manager->count();
|
||||
$result->client_id = $client_id;
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
$result = $manager->delete($commentid);
|
||||
if ($result === true) {
|
||||
echo json_encode(array('client_id'=>$client_id, 'commentid'=>$commentid));
|
||||
$comment_record = $DB->get_record('comments', array('id'=>$commentid));
|
||||
if ($manager->can_delete($commentid) || $comment_record->userid == $USER->id) {
|
||||
if ($manager->delete($commentid)) {
|
||||
$result = array(
|
||||
'client_id' => $client_id,
|
||||
'commentid' => $commentid
|
||||
);
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'get':
|
||||
default:
|
||||
$result = array();
|
||||
$comments = $manager->get_comments($page);
|
||||
$result['list'] = $comments;
|
||||
$result['count'] = $manager->count();
|
||||
$result['pagination'] = $manager->get_pagination($page);
|
||||
$result['client_id'] = $client_id;
|
||||
echo json_encode($result);
|
||||
if ($manager->can_view()) {
|
||||
$comments = $manager->get_comments($page);
|
||||
$result = array(
|
||||
'list' => $comments,
|
||||
'count' => $manager->count(),
|
||||
'pagination' => $manager->get_pagination($page),
|
||||
'client_id' => $client_id
|
||||
);
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isloggedin()) {
|
||||
// tell user to log in to view comments
|
||||
echo json_encode(array('error'=>'require_login'));
|
||||
}
|
||||
// ignore request
|
||||
die;
|
||||
|
||||
+18
-14
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -21,35 +20,40 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
|
||||
if (empty($CFG->usecomments)) {
|
||||
throw new comment_exception('commentsnotenabled', 'moodle');
|
||||
}
|
||||
|
||||
$contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
|
||||
list($context, $course, $cm) = get_context_info_array($contextid);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
require_sesskey();
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$area = optional_param('area', '', PARAM_ALPHAEXT);
|
||||
$commentid = optional_param('commentid', -1, PARAM_INT);
|
||||
$content = optional_param('content', '', PARAM_RAW);
|
||||
$itemid = optional_param('itemid', '', PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', '', PARAM_URL);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$area = optional_param('area', '', PARAM_ALPHAEXT);
|
||||
$content = optional_param('content', '', PARAM_RAW);
|
||||
$itemid = optional_param('itemid', '', PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', '/', PARAM_URL);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
|
||||
$cmt = new stdClass();
|
||||
// Currently this script can only add comments
|
||||
if ($action !== 'add') {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
$cmt = new stdClass;
|
||||
$cmt->contextid = $contextid;
|
||||
$cmt->courseid = $course->id;
|
||||
$cmt->cm = $cm;
|
||||
$cmt->area = $area;
|
||||
$cmt->itemid = $itemid;
|
||||
$cmt->component = $component;
|
||||
$comment = new comment($cmt);
|
||||
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
if ($comment->can_post()) {
|
||||
$cmt = $comment->add($content);
|
||||
if (!empty($cmt) && is_object($cmt)) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
exit;
|
||||
}
|
||||
|
||||
+6
-3
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once('locallib.php');
|
||||
require_once($CFG->dirroot.'/comment/locallib.php');
|
||||
|
||||
require_login();
|
||||
admin_externalpage_setup('comments', '', null, '', array('pagelayout'=>'report'));
|
||||
@@ -81,8 +81,11 @@ if (!empty($err)) {
|
||||
}
|
||||
if (empty($action)) {
|
||||
echo '<form method="post">';
|
||||
$manager->print_comments($page);
|
||||
echo '<input type="submit" id="comments_delete" name="batchdelete" value="'.get_string('delete').'" />';
|
||||
$return = $manager->print_comments($page);
|
||||
// if no comments available, $return will be false
|
||||
if ($return) {
|
||||
echo '<input type="submit" id="comments_delete" name="batchdelete" value="'.get_string('delete').'" />';
|
||||
}
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
|
||||
+514
-213
File diff suppressed because it is too large
Load Diff
+104
-52
@@ -23,46 +23,70 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class comment_manager {
|
||||
|
||||
/**
|
||||
* The number of comments to display per page
|
||||
* @var int
|
||||
*/
|
||||
private $perpage;
|
||||
function __construct() {
|
||||
|
||||
/**
|
||||
* Constructs the comment_manage object
|
||||
*/
|
||||
public function __construct() {
|
||||
global $CFG;
|
||||
$this->perpage = $CFG->commentsperpage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return comments by pages
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param int $page
|
||||
* @return mixed
|
||||
* @return array An array of comments
|
||||
*/
|
||||
function get_comments($page) {
|
||||
global $DB, $CFG, $USER;
|
||||
$params = array();
|
||||
global $DB;
|
||||
|
||||
if ($page == 0) {
|
||||
$start = 0;
|
||||
} else {
|
||||
$start = $page*$this->perpage;
|
||||
$start = $page * $this->perpage;
|
||||
}
|
||||
$sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated
|
||||
FROM {comments} c, {user} u
|
||||
WHERE u.id=c.userid ORDER BY c.timecreated ASC";
|
||||
|
||||
$comments = array();
|
||||
|
||||
$sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated
|
||||
FROM {comments} c
|
||||
JOIN {user} u
|
||||
ON u.id=c.userid
|
||||
ORDER BY c.timecreated ASC";
|
||||
$rs = $DB->get_recordset_sql($sql, null, $start, $this->perpage);
|
||||
$formatoptions = array('overflowdiv' => true);
|
||||
if ($records = $DB->get_records_sql($sql, array(), $start, $this->perpage)) {
|
||||
foreach ($records as $item) {
|
||||
$item->fullname = fullname($item);
|
||||
$item->time = userdate($item->timecreated);
|
||||
$item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
|
||||
$comments[] = $item;
|
||||
unset($item->firstname);
|
||||
unset($item->lastname);
|
||||
unset($item->timecreated);
|
||||
}
|
||||
foreach ($rs as $item) {
|
||||
// Set calculated fields
|
||||
$item->fullname = fullname($item);
|
||||
$item->time = userdate($item->timecreated);
|
||||
$item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
|
||||
// Unset fields not related to the comment
|
||||
unset($item->firstname);
|
||||
unset($item->lastname);
|
||||
unset($item->timecreated);
|
||||
// Record the comment
|
||||
$comments[] = $item;
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the course object
|
||||
*
|
||||
* @global moodle_page $PAGE
|
||||
* @global moodle_database $DB
|
||||
* @param int $courseid
|
||||
* @return void
|
||||
*/
|
||||
private function setup_course($courseid) {
|
||||
global $PAGE, $DB;
|
||||
if (!empty($this->course)) {
|
||||
@@ -71,88 +95,116 @@ class comment_manager {
|
||||
}
|
||||
if ($courseid == $PAGE->course->id) {
|
||||
$this->course = $PAGE->course;
|
||||
} else if (!$this->course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
} else if (!$this->course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
$this->course = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the module or block information for a comment
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param stdClass $comment
|
||||
* @return bool
|
||||
*/
|
||||
private function setup_plugin($comment) {
|
||||
global $DB;
|
||||
$this->context = get_context_instance_by_id($comment->contextid);
|
||||
if (!is_object($this->context)) {
|
||||
return;
|
||||
if (!$this->context) {
|
||||
return false;
|
||||
}
|
||||
if ($this->context->contextlevel == CONTEXT_BLOCK) {
|
||||
if ($block = $DB->get_record('block_instances', array('id'=>$this->context->instanceid))) {
|
||||
$this->plugintype = 'block';
|
||||
$this->pluginname = $block->blockname;
|
||||
}
|
||||
}
|
||||
if ($this->context->contextlevel == CONTEXT_MODULE) {
|
||||
$this->plugintype = 'mod';
|
||||
$this->cm = get_coursemodule_from_id('', $this->context->instanceid);
|
||||
$this->setup_course($this->cm->course);
|
||||
$this->modinfo = get_fast_modinfo($this->course);
|
||||
$this->pluginname = $this->modinfo->cms[$this->cm->id]->modname;
|
||||
switch ($this->context->contextlevel) {
|
||||
case CONTEXT_BLOCK:
|
||||
if ($block = $DB->get_record('block_instances', array('id' => $this->context->instanceid))) {
|
||||
$this->plugintype = 'block';
|
||||
$this->pluginname = $block->blockname;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$this->plugintype = 'mod';
|
||||
$this->cm = get_coursemodule_from_id('', $this->context->instanceid);
|
||||
$this->setup_course($this->cm->course);
|
||||
$this->modinfo = get_fast_modinfo($this->course);
|
||||
$this->pluginname = $this->modinfo->cms[$this->cm->id]->modname;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print comments
|
||||
* @param int $page
|
||||
* @return boolean return false if no comments available
|
||||
*/
|
||||
function print_comments($page=0) {
|
||||
global $CFG, $OUTPUT, $DB;
|
||||
$count = $DB->count_records_sql('SELECT COUNT(*) FROM {comments} c');
|
||||
public function print_comments($page = 0) {
|
||||
global $OUTPUT, $CFG, $OUTPUT, $DB;
|
||||
|
||||
$count = $DB->count_records('comments');
|
||||
$comments = $this->get_comments($page);
|
||||
if (count($comments) == 0) {
|
||||
echo $OUTPUT->notification(get_string('nocomments', 'moodle'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = array (html_writer::checkbox('selectall', '', false, get_string('selectall'), array('id'=>'comment_select_all', 'class'=>'comment-report-selectall')), get_string('author', 'search'), get_string('content'), get_string('action'));
|
||||
$table->head = array (
|
||||
html_writer::checkbox('selectall', '', false, get_string('selectall'), array('id'=>'comment_select_all', 'class'=>'comment-report-selectall')),
|
||||
get_string('author', 'search'),
|
||||
get_string('content'),
|
||||
get_string('action')
|
||||
);
|
||||
$table->align = array ('left', 'left', 'left', 'left');
|
||||
$table->attributes = array('class'=>'generaltable commentstable');
|
||||
$table->data = array();
|
||||
$linkbase = $CFG->wwwroot.'/comment/index.php?action=delete&sesskey='.sesskey();
|
||||
|
||||
$link = new moodle_url('/comment/index.php', array('action' => 'delete', 'sesskey' => sesskey()));
|
||||
foreach ($comments as $c) {
|
||||
$link = $linkbase . '&commentid='. $c->id;
|
||||
$this->setup_plugin($c);
|
||||
if (!empty($this->plugintype)) {
|
||||
$context_url = plugin_callback($this->plugintype, $this->pluginname, FEATURE_COMMENT, 'url', array($c));
|
||||
$context_url = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'url', array($c));
|
||||
}
|
||||
$checkbox = html_writer::checkbox('comments', $c->id, false);
|
||||
$action = html_writer::link($link, get_string('delete'));
|
||||
$action = html_writer::link(new moodle_url($link, array('commentid' => $c->id)), get_string('delete'));
|
||||
if (!empty($context_url)) {
|
||||
$action .= html_writer::tag('br', null);
|
||||
$action .= html_writer::empty_tag('br');
|
||||
$action .= html_writer::link($context_url, get_string('commentincontext'), array('target'=>'_blank'));
|
||||
}
|
||||
$table->data[] = array($checkbox, $c->fullname, $c->content, $action);
|
||||
}
|
||||
echo html_writer::table($table);
|
||||
echo $OUTPUT->paging_bar($count, $page, $this->perpage, $CFG->wwwroot.'/comment/index.php');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a comment
|
||||
* Delete a comment
|
||||
*
|
||||
* @param int $commentid
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_comment($commentid) {
|
||||
global $DB;
|
||||
if ($comment = $DB->get_record('comments', array('id'=>$commentid))) {
|
||||
$DB->delete_records('comments', array('id'=>$commentid));
|
||||
if ($DB->record_exists('comments', array('id' => $commentid))) {
|
||||
$DB->delete_records('comments', array('id' => $commentid));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* delete comments
|
||||
* @param int $commentid
|
||||
* Delete comments
|
||||
*
|
||||
* @param string $list A list of comment ids separated by hyphens
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_comments($list) {
|
||||
global $DB;
|
||||
$ids = explode('-', $list);
|
||||
foreach ($ids as $id) {
|
||||
if (is_int((int)$id)) {
|
||||
if ($comment = $DB->get_record('comments', array('id'=>$id))) {
|
||||
$DB->delete_records('comments', array('id'=>$comment->id));
|
||||
}
|
||||
$id = (int)$id;
|
||||
if ($DB->record_exists('comments', array('id' => $id))) {
|
||||
$DB->delete_records('comments', array('id' => $id));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -357,6 +357,13 @@ $CFG->admin = 'admin';
|
||||
//
|
||||
// $CFG->langcacheroot = '/var/www/moodle/htdocs/altcache/lang';
|
||||
//
|
||||
// If $CFG->langcache is enabled (which should always be in production
|
||||
// environment), Moodle stores the list of available languages in a cache file.
|
||||
// By default, the file $CFG->dataroot/languages is used. You may wish to
|
||||
// specify an alternative location of this cache file.
|
||||
//
|
||||
// $CFG->langmenucachefile = '/var/www/moodle/htdocs/altcache/languages';
|
||||
//
|
||||
// Site default language can be set via standard administration interface. If you
|
||||
// want to have initial error messages for eventual database connection problems
|
||||
// localized too, you have to set your language code here.
|
||||
|
||||
+16
-53
@@ -1637,6 +1637,16 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
// Module can put text after the link (e.g. forum unread)
|
||||
echo $mod->get_after_link();
|
||||
|
||||
// If there is content but NO link (eg label), then display the
|
||||
// content here (BEFORE any icons). In this case cons must be
|
||||
// displayed after the content so that it makes more sense visually
|
||||
// and for accessibility reasons, e.g. if you have a one-line label
|
||||
// it should work similarly (at least in terms of ordering) to an
|
||||
// activity.
|
||||
if (empty($url)) {
|
||||
echo $contentpart;
|
||||
}
|
||||
|
||||
if ($isediting) {
|
||||
if ($groupbuttons and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
|
||||
if (! $mod->groupmodelink = $groupbuttonslink) {
|
||||
@@ -1707,7 +1717,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
$extraclass = '';
|
||||
}
|
||||
echo "
|
||||
<form class='togglecompletion$extraclass' method='post' action='togglecompletion.php'><div>
|
||||
<form class='togglecompletion$extraclass' method='post' action='".$CFG->wwwroot."/course/togglecompletion.php'><div>
|
||||
<input type='hidden' name='id' value='{$mod->id}' />
|
||||
<input type='hidden' name='sesskey' value='".sesskey()."' />
|
||||
<input type='hidden' name='completionstate' value='$newstate' />
|
||||
@@ -1721,8 +1731,11 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
}
|
||||
}
|
||||
|
||||
// Display the content (if any) at this part of the html
|
||||
echo $contentpart;
|
||||
// If there is content AND a link, then display the content here
|
||||
// (AFTER any icons). Otherwise it was displayed before
|
||||
if (!empty($url)) {
|
||||
echo $contentpart;
|
||||
}
|
||||
|
||||
// Show availability information (for someone who isn't allowed to
|
||||
// see the activity itself, or for staff)
|
||||
@@ -1880,56 +1893,6 @@ function get_category_or_system_context($categoryid) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the cached list of course activities stored in the database
|
||||
* @param int $courseid - id of course to rebuild, empty means all
|
||||
* @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly
|
||||
*/
|
||||
function rebuild_course_cache($courseid=0, $clearonly=false) {
|
||||
global $COURSE, $DB, $OUTPUT;
|
||||
|
||||
// Destroy navigation caches
|
||||
navigation_cache::destroy_volatile_caches();
|
||||
|
||||
if ($clearonly) {
|
||||
if (empty($courseid)) {
|
||||
$courseselect = array();
|
||||
} else {
|
||||
$courseselect = array('id'=>$courseid);
|
||||
}
|
||||
$DB->set_field('course', 'modinfo', null, $courseselect);
|
||||
// update cached global COURSE too ;-)
|
||||
if ($courseid == $COURSE->id or empty($courseid)) {
|
||||
$COURSE->modinfo = null;
|
||||
}
|
||||
// reset the fast modinfo cache
|
||||
$reset = 'reset';
|
||||
get_fast_modinfo($reset);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($courseid) {
|
||||
$select = array('id'=>$courseid);
|
||||
} else {
|
||||
$select = array();
|
||||
@set_time_limit(0); // this could take a while! MDL-10954
|
||||
}
|
||||
|
||||
$rs = $DB->get_recordset("course", $select,'','id,fullname');
|
||||
foreach ($rs as $course) {
|
||||
$modinfo = serialize(get_array_of_activities($course->id));
|
||||
$DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id));
|
||||
// update cached global COURSE too ;-)
|
||||
if ($course->id == $COURSE->id) {
|
||||
$COURSE->modinfo = $modinfo;
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
// reset the fast modinfo cache
|
||||
$reset = 'reset';
|
||||
get_fast_modinfo($reset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the child categories of a given courses category. Uses a static cache
|
||||
* to make repeat calls efficient.
|
||||
|
||||
@@ -384,7 +384,7 @@ if(!$csv) {
|
||||
// Try load a aggregation method
|
||||
$method = $completion->get_aggregation_method($current_group->criteriatype);
|
||||
|
||||
$method = $method == 1 ? 'All' : 'Any';
|
||||
$method = $method == 1 ? get_string('all') : get_string('any');
|
||||
|
||||
} else {
|
||||
$method = '-';
|
||||
@@ -406,7 +406,7 @@ if(!$csv) {
|
||||
// Get course aggregation
|
||||
$method = $completion->get_aggregation_method();
|
||||
|
||||
print $method == 1 ? 'All' : 'Any';
|
||||
print $method == 1 ? get_string('all') : get_string('any');
|
||||
print '</th>';
|
||||
|
||||
print '</tr>';
|
||||
@@ -515,7 +515,7 @@ if(!$csv) {
|
||||
|
||||
// Overall course completion status
|
||||
print '<th class="criteriaicon">';
|
||||
print '<img src="'.$OUTPUT->pix_url('i/course').'" class="icon" alt="Course" title="Course Complete" />'; //TODO: localize
|
||||
print '<img src="'.$OUTPUT->pix_url('i/course').'" class="icon" alt="'.get_string('course').'" title="'.get_string('coursecomplete', 'completion').'" />';
|
||||
print '</th>';
|
||||
|
||||
print '</tr>';
|
||||
@@ -634,7 +634,7 @@ foreach ($progress as $user) {
|
||||
print '<td class="completion-progresscell">'.
|
||||
'<a href="'.$CFG->wwwroot.'/course/togglecompletion.php?user='.$user->id.'&course='.$course->id.'&rolec='.$allow_marking_criteria.'&sesskey='.sesskey().'">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/completion-manual-'.($is_complete ? 'y' : 'n')).
|
||||
'" alt="'.$describe.'" class="icon" title="Mark as complete" /></a></td>'; //TODO: localize
|
||||
'" alt="'.$describe.'" class="icon" title="'.get_string('markcomplete', 'completion').'" /></a></td>';
|
||||
} else {
|
||||
print '<td class="completion-progresscell">'.
|
||||
'<img src="'.$OUTPUT->pix_url('i/'.$completionicon).
|
||||
|
||||
@@ -196,7 +196,7 @@
|
||||
$actions = array_merge($viewnames, $postnames);
|
||||
}
|
||||
|
||||
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action0');
|
||||
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action');
|
||||
$actionsql = "action $actionsql";
|
||||
|
||||
$relatedcontexts = get_related_contexts_string($context);
|
||||
|
||||
@@ -152,6 +152,7 @@ if ($course->id != SITEID && has_capability('moodle/course:viewparticipants', $c
|
||||
}
|
||||
|
||||
$PAGE->navigation->extend_for_user($user);
|
||||
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
|
||||
$PAGE->set_title("$course->shortname: $stractivityreport ($mode)");
|
||||
$PAGE->set_heading($course->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
@@ -154,6 +154,8 @@ switch ($action) {
|
||||
$roleid = optional_param('role', null, PARAM_INT);
|
||||
$duration = optional_param('duration', 0, PARAM_INT);
|
||||
$startdate = optional_param('startdate', 0, PARAM_INT);
|
||||
$recovergrades = optional_param('recovergrades', 0, PARAM_INT);
|
||||
|
||||
if (empty($roleid)) {
|
||||
$roleid = null;
|
||||
}
|
||||
@@ -185,6 +187,10 @@ switch ($action) {
|
||||
$plugin = $plugins[$instance->enrol];
|
||||
if ($plugin->allow_enrol($instance) && has_capability('enrol/'.$plugin->get_name().':enrol', $context)) {
|
||||
$plugin->enrol_user($instance, $user->id, $roleid, $timestart, $timeend);
|
||||
if ($recovergrades) {
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
grade_recover_history_grades($user->id, $instance->courseid);
|
||||
}
|
||||
} else {
|
||||
throw new enrol_ajax_exception('enrolnotpermitted');
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class enrol_category_handler {
|
||||
$params = array('courselevel'=>CONTEXT_COURSE, 'match'=>$parentcontext->path.'/%', 'userid'=>$ra->userid);
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
$params['userid'] = $ra->userid;
|
||||
|
||||
foreach ($rs as $instance) {
|
||||
@@ -119,7 +119,7 @@ class enrol_category_handler {
|
||||
$contextids = get_parent_contexts($coursecontext);
|
||||
array_pop($contextids); // remove system context, we are interested in categories only
|
||||
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c000');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c');
|
||||
$params = array_merge($params, $contextparams);
|
||||
|
||||
$sql = "SELECT ra.id
|
||||
@@ -168,8 +168,8 @@ function enrol_category_sync_course($course) {
|
||||
$contextids = get_parent_contexts($coursecontext);
|
||||
array_pop($contextids); // remove system context, we are interested in categories only
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c');
|
||||
$params = array_merge($params, $contextparams);
|
||||
$params['courseid'] = $course->id;
|
||||
|
||||
@@ -257,7 +257,7 @@ function enrol_category_sync_full() {
|
||||
return;
|
||||
}
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
$params['courselevel'] = CONTEXT_COURSE;
|
||||
$params['catlevel'] = CONTEXT_COURSECAT;
|
||||
|
||||
|
||||
+1
-1
@@ -449,7 +449,7 @@ class enrol_ldap_plugin extends enrol_plugin {
|
||||
WHERE u.deleted = 0 AND e.courseid = :courseid ";
|
||||
$params = array('roleid'=>$role->id, 'courseid'=>$course_obj->id);
|
||||
if (!empty($ldapmembers)) {
|
||||
list($ldapml, $params2) = $DB->get_in_or_equal($ldapmembers, SQL_PARAMS_NAMED, 'm0', false);
|
||||
list($ldapml, $params2) = $DB->get_in_or_equal($ldapmembers, SQL_PARAMS_NAMED, 'm', false);
|
||||
$sql .= "AND u.idnumber $ldapml";
|
||||
$params = array_merge($params, $params2);
|
||||
unset($params2);
|
||||
|
||||
+4
-2
@@ -141,7 +141,7 @@ class course_enrolment_manager {
|
||||
public function get_total_other_users() {
|
||||
global $DB;
|
||||
if ($this->totalotherusers === null) {
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params['courseid'] = $this->course->id;
|
||||
$sql = "SELECT COUNT(DISTINCT u.id)
|
||||
FROM {role_assignments} ra
|
||||
@@ -222,7 +222,7 @@ class course_enrolment_manager {
|
||||
}
|
||||
$key = md5("$sort-$direction-$page-$perpage");
|
||||
if (!array_key_exists($key, $this->otherusers)) {
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params['courseid'] = $this->course->id;
|
||||
$params['cid'] = $this->course->id;
|
||||
$sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, u.*, ue.lastseen
|
||||
@@ -613,6 +613,8 @@ class course_enrolment_manager {
|
||||
* @return bool
|
||||
*/
|
||||
public function edit_enrolment($userenrolment, $data) {
|
||||
//Only allow editing if the user has the appropriate capability
|
||||
//Already checked in /enrol/users.php but checking again in case this function is called from elsewhere
|
||||
list($instance, $plugin) = $this->get_user_enrolment_components($userenrolment);
|
||||
if ($instance && $plugin && $plugin->allow_manage($instance) && has_capability("enrol/$instance->enrol:manage", $this->context)) {
|
||||
if (!isset($data->status)) {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Manual plugin external functions and service definitions.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @author 2011 Jerome Mouneyrac
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$functions = array(
|
||||
|
||||
// === enrol related functions ===
|
||||
'moodle_enrol_manual_enrol_users' => array(
|
||||
'classname' => 'moodle_enrol_manual_external',
|
||||
'methodname' => 'manual_enrol_users',
|
||||
'classpath' => 'enrol/manual/externallib.php',
|
||||
'description' => 'Manual enrol users',
|
||||
'capabilities'=> 'enrol/manual:enrol',
|
||||
'type' => 'write',
|
||||
),
|
||||
|
||||
);
|
||||
@@ -0,0 +1,143 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* External course participation api.
|
||||
*
|
||||
* This api is mostly read only, the actual enrol and unenrol
|
||||
* support is in each enrol plugin.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @copyright 2011 Moodle Pty Ltd (http://moodle.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/externallib.php");
|
||||
|
||||
class moodle_enrol_manual_external extends external_api {
|
||||
|
||||
/**
|
||||
* Returns description of method parameters
|
||||
* @return external_function_parameters
|
||||
*/
|
||||
public static function manual_enrol_users_parameters() {
|
||||
return new external_function_parameters(
|
||||
array(
|
||||
'enrolments' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'roleid' => new external_value(PARAM_INT, 'Role to assign to the user'),
|
||||
'userid' => new external_value(PARAM_INT, 'The user that is going to be enrolled'),
|
||||
'courseid' => new external_value(PARAM_INT, 'The course to enrol the user role in'),
|
||||
'timestart' => new external_value(PARAM_INT, 'Timestamp when the enrolment start', VALUE_OPTIONAL),
|
||||
'timeend' => new external_value(PARAM_INT, 'Timestamp when the enrolment end', VALUE_OPTIONAL),
|
||||
'suspend' => new external_value(PARAM_INT, 'set to 1 to suspend the enrolment', VALUE_OPTIONAL)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrolment of users
|
||||
* Function throw an exception at the first error encountered.
|
||||
* @param array $enrolments An array of user enrolment
|
||||
* @return null
|
||||
*/
|
||||
public static function manual_enrol_users($enrolments) {
|
||||
global $DB, $CFG;
|
||||
|
||||
require_once($CFG->libdir . '/enrollib.php');
|
||||
|
||||
$params = self::validate_parameters(self::manual_enrol_users_parameters(),
|
||||
array('enrolments' => $enrolments));
|
||||
|
||||
$transaction = $DB->start_delegated_transaction(); //rollback all enrolment if an error occurs
|
||||
//(except if the DB doesn't support it)
|
||||
|
||||
//retrieve the manual enrolment plugin
|
||||
$enrol = enrol_get_plugin('manual');
|
||||
if (empty($enrol)) {
|
||||
throw new moodle_exception('manualpluginnotinstalled', 'enrol_manual');
|
||||
}
|
||||
|
||||
foreach ($params['enrolments'] as $enrolment) {
|
||||
// Ensure the current user is allowed to run this function in the enrolment context
|
||||
$context = get_context_instance(CONTEXT_COURSE, $enrolment['courseid']);
|
||||
self::validate_context($context);
|
||||
|
||||
//check that the user has the permission to manual enrol
|
||||
require_capability('enrol/manual:enrol', $context);
|
||||
|
||||
//throw an exception if user is not able to assign the role
|
||||
$roles = get_assignable_roles($context);
|
||||
if (!key_exists($enrolment['roleid'], $roles)) {
|
||||
$errorparams = new stdClass();
|
||||
$errorparams->roleid = $enrolment['roleid'];
|
||||
$errorparams->courseid = $enrolment['courseid'];
|
||||
$errorparams->userid = $enrolment['userid'];
|
||||
throw new moodle_exception('wsusercannotassign', 'enrol_manual', '', $errorparams);
|
||||
}
|
||||
|
||||
//check manual enrolment plugin instance is enabled/exist
|
||||
$enrolinstances = enrol_get_instances($enrolment['courseid'], true);
|
||||
foreach ($enrolinstances as $courseenrolinstance) {
|
||||
if ($courseenrolinstance->enrol == "manual") {
|
||||
$instance = $courseenrolinstance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($instance)) {
|
||||
$errorparams = new stdClass();
|
||||
$errorparams->courseid = $enrolment['courseid'];
|
||||
throw new moodle_exception('wsnoinstance', 'enrol_manual', $errorparams);
|
||||
}
|
||||
|
||||
//check that the plugin accept enrolment (it should always the case, it's hard coded in the plugin)
|
||||
if (!$enrol->allow_enrol($instance)) {
|
||||
$errorparams = new stdClass();
|
||||
$errorparams->roleid = $enrolment['roleid'];
|
||||
$errorparams->courseid = $enrolment['courseid'];
|
||||
$errorparams->userid = $enrolment['userid'];
|
||||
throw new moodle_exception('wscannotenrol', 'enrol_manual', '', $errorparams);
|
||||
}
|
||||
|
||||
//finally proceed the enrolment
|
||||
$enrolment['timestart'] = isset($enrolment['timestart']) ? $enrolment['timestart'] : 0;
|
||||
$enrolment['timeend'] = isset($enrolment['timeend']) ? $enrolment['timeend'] : 0;
|
||||
$enrolment['status'] = (isset($enrolment['suspend']) && !empty($enrolment['suspend'])) ?
|
||||
ENROL_USER_SUSPENDED : ENROL_USER_ACTIVE;
|
||||
|
||||
$enrol->enrol_user($instance, $enrolment['userid'], $enrolment['roleid'],
|
||||
$enrolment['timestart'], $enrolment['timeend'], $enrolment['status']);
|
||||
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value
|
||||
* @return external_description
|
||||
*/
|
||||
public static function manual_enrol_users_returns() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,3 +42,8 @@ $string['status_help'] = 'This setting determines whether users can be enrolled
|
||||
$string['statusenabled'] = 'Enabled';
|
||||
$string['statusdisabled'] = 'Disabled';
|
||||
$string['unenrolselfconfirm'] = 'Do you really want to unenrol yourself from course "{$a}"?';
|
||||
$string['unenroluser'] = 'Do you really want to unenrol "{$a->user}" from course "{$a->course}"?';
|
||||
$string['unenrolusers'] = 'Unenrol users';
|
||||
$string['wscannotenrol'] = 'Plugin instance cannot manually enrol a user in the course id = {$a->courseid}';
|
||||
$string['wsnoinstance'] = 'Manual enrolment plugin instance doesn\'t exist or is disabled for the course (id = {$a->courseid})';
|
||||
$string['wsusercannotassign'] = 'You don\'t have the permission to assign this role ({$a->roleid}) to this user ({$a->userid}) in this course({$a->courseid}).';
|
||||
@@ -26,4 +26,4 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2010071200;
|
||||
$plugin->version = 2010071201;
|
||||
|
||||
@@ -28,6 +28,6 @@ $string['linkedcourse'] = 'Link course';
|
||||
$string['meta:config'] = 'Configure meta enrol instances';
|
||||
$string['meta:selectaslinked'] = 'Select course as meta linked';
|
||||
$string['nosyncroleids'] = 'Roles that are not synchronised';
|
||||
$string['nosyncroleids_desc'] = 'By default all course level role assignments are synchronised from parent to child courses. Roles that are selected here will not be included in the synchronisation process. The current roles will be updated in the next cron execution.';
|
||||
$string['nosyncroleids_desc'] = 'By default all course level role assignments are synchronised from parent to child courses. Roles that are selected here will not be included in the synchronisation process. The roles available for synchronisation will be updated in the next cron execution.';
|
||||
$string['pluginname'] = 'Course meta link';
|
||||
$string['pluginname_desc'] = 'Course meta link enrolment plugin synchronises enrolments and roles in two different courses.';
|
||||
|
||||
@@ -208,7 +208,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
|
||||
// iterate through all not enrolled yet users
|
||||
if (enrol_is_enabled('meta')) {
|
||||
list($enabled, $params) = $DB->get_in_or_equal(explode(',', $CFG->enrol_plugins_enabled), SQL_PARAMS_NAMED, 'e00');
|
||||
list($enabled, $params) = $DB->get_in_or_equal(explode(',', $CFG->enrol_plugins_enabled), SQL_PARAMS_NAMED, 'e');
|
||||
$onecourse = "";
|
||||
if ($courseid) {
|
||||
$params['courseid'] = $courseid;
|
||||
@@ -267,7 +267,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
}
|
||||
$enabled[] = $DB->sql_empty(); // manual assignments are replicated too
|
||||
|
||||
list($enabled, $params) = $DB->get_in_or_equal($enabled, SQL_PARAMS_NAMED, 'e00');
|
||||
list($enabled, $params) = $DB->get_in_or_equal($enabled, SQL_PARAMS_NAMED, 'e');
|
||||
$sql = "SELECT DISTINCT pra.roleid, pra.userid, c.id AS contextid, e.id AS enrolid
|
||||
FROM {role_assignments} pra
|
||||
JOIN {user} u ON (u.id = pra.userid AND u.deleted = 0)
|
||||
@@ -281,7 +281,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
$params['courseid'] = $courseid;
|
||||
|
||||
if ($ignored = $meta->get_config('nosyncroleids')) {
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'i00', false);
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'ig', false);
|
||||
$params = array_merge($params, $xparams);
|
||||
$sql = "$sql AND pra.roleid $notignored";
|
||||
}
|
||||
@@ -296,7 +296,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
// remove unwanted roles - include ignored roles and disabled plugins too
|
||||
$params = array('coursecontext' => CONTEXT_COURSE, 'courseid' => $courseid);
|
||||
if ($ignored = $meta->get_config('nosyncroleids')) {
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'i00', false);
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'ig', false);
|
||||
$params = array_merge($params, $xparams);
|
||||
$notignored = "AND pra.roleid $notignored";
|
||||
} else {
|
||||
|
||||
+7
-2
@@ -626,6 +626,7 @@ class course_enrolment_users_table extends course_enrolment_table {
|
||||
* @return single_button|url_select
|
||||
*/
|
||||
public function get_enrolment_selector() {
|
||||
global $CFG;
|
||||
static $count = 0;
|
||||
|
||||
$instances = $this->manager->get_enrolment_instances();
|
||||
@@ -659,6 +660,7 @@ class course_enrolment_users_table extends course_enrolment_table {
|
||||
$control->class = 'singlebutton enrolusersbutton instance'.$count;
|
||||
$control->formid = 'manuallyenrol_select_'+$count;
|
||||
}
|
||||
|
||||
$course = $this->manager->get_course();
|
||||
$timeformat = get_string('strftimedatefullshort');
|
||||
$today = time();
|
||||
@@ -685,7 +687,9 @@ class course_enrolment_users_table extends course_enrolment_table {
|
||||
'unlimitedduration',
|
||||
'startdatetoday',
|
||||
'durationdays',
|
||||
'enrolperiod'), 'enrol');
|
||||
'enrolperiod',
|
||||
'finishenrollingusers',
|
||||
'recovergrades'), 'enrol');
|
||||
$this->moodlepage->requires->string_for_js('assignroles', 'role');
|
||||
$this->moodlepage->requires->string_for_js('startingfrom', 'moodle');
|
||||
|
||||
@@ -697,7 +701,8 @@ class course_enrolment_users_table extends course_enrolment_table {
|
||||
'ajaxurl'=>'/enrol/ajax.php',
|
||||
'url'=>$this->moodlepage->url->out(false),
|
||||
'optionsStartDate'=>$startdateoptions,
|
||||
'defaultRole'=>$instance->roleid);
|
||||
'defaultRole'=>$instance->roleid,
|
||||
'disableGradeHistory'=>$CFG->disablegradehistory);
|
||||
$this->moodlepage->requires->yui_module($modules, $function, array($arguments));
|
||||
}
|
||||
return $control;
|
||||
|
||||
+3
-1
@@ -62,7 +62,7 @@ if ($action) {
|
||||
|
||||
switch ($action) {
|
||||
/**
|
||||
* Unenrols a user from this course
|
||||
* Unenrols a user from this course (including removing all of their grades)
|
||||
*/
|
||||
case 'unenrol':
|
||||
$ue = $DB->get_record('user_enrolments', array('id'=>required_param('ue', PARAM_INT)), '*', MUST_EXIST);
|
||||
@@ -166,6 +166,8 @@ if ($action) {
|
||||
*/
|
||||
case 'edit':
|
||||
$ue = $DB->get_record('user_enrolments', array('id'=>required_param('ue', PARAM_INT)), '*', MUST_EXIST);
|
||||
|
||||
//Only show the edit form if the user has the appropriate capability
|
||||
list($instance, $plugin) = $manager->get_user_enrolment_components($ue);
|
||||
if ($instance && $plugin && $plugin->allow_manage($instance) && has_capability("enrol/$instance->enrol:manage", $manager->get_context())) {
|
||||
$user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST);
|
||||
|
||||
@@ -60,7 +60,7 @@ Structure of the user enroller panel
|
||||
.user-enroller-panel .uep-loading-lightbox.hidden {display:none;}
|
||||
.user-enroller-panel .uep-loading-lightbox .loading-icon {margin:auto;vertical-align:middle;margin-top:125px;}
|
||||
|
||||
.user-enroller-panel .uep-footer {padding:3px;background-color:#ddd;}
|
||||
.user-enroller-panel .uep-footer {padding:3px;background-color:#ddd;text-align:center;}
|
||||
.user-enroller-panel .uep-search {margin:3px;}
|
||||
.user-enroller-panel .uep-search label {padding-right:8px;}
|
||||
.user-enroller-panel .uep-search input {width:70%;}
|
||||
@@ -70,3 +70,7 @@ Structure of the user enroller panel
|
||||
.user-enroller-panel .collapsiblearea {border:1px solid #bbb;background-color:#f6f6f6;}
|
||||
.user-enroller-panel .collapsiblearea.hidden {display:none;}
|
||||
.user-enroller-panel .collapsiblearea .uep-enrolment-option {margin:5px 1em;}
|
||||
|
||||
.dir-rtl .user-enroller-panel .uep-header .close {right: auto;left:1em;}
|
||||
.dir-rtl .user-enroller-panel .uep-search-results .user { text-align: right;}
|
||||
.dir-rtl .user-enroller-panel .uep-content .uep-controls { text-align: right;}
|
||||
+21
-2
@@ -20,7 +20,8 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
DEFAULTROLE : 'defaultRole',
|
||||
DEFAULTSTARTDATE : 'defaultStartDate',
|
||||
DEFAULTDURATION : 'defaultDuration',
|
||||
ASSIGNABLEROLES : 'assignableRoles'
|
||||
ASSIGNABLEROLES : 'assignableRoles',
|
||||
DISABLEGRADEHISTORY : 'disableGradeHistory'
|
||||
};
|
||||
/** CSS classes for nodes in structure **/
|
||||
var CSS = {
|
||||
@@ -48,6 +49,8 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
ODD : 'odd',
|
||||
EVEN : 'even',
|
||||
HIDDEN : 'hidden',
|
||||
RECOVERGRADESCHECK : 'uep-recovergradescheck',
|
||||
RECOVERGRADESCHECKTITLE : 'uep-recovergradeschecktitle',
|
||||
SEARCHOPTIONS : 'uep-searchoptions',
|
||||
COLLAPSIBLEHEADING : 'collapsibleheading',
|
||||
COLLAPSIBLEAREA : 'collapsiblearea',
|
||||
@@ -58,7 +61,8 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
DURATION : 'duration',
|
||||
ACTIVE : 'active',
|
||||
SEARCH : 'uep-search',
|
||||
CLOSE : 'close'
|
||||
CLOSE : 'close',
|
||||
CLOSEBTN : 'close-button'
|
||||
};
|
||||
|
||||
var USERENROLLER = function(config) {
|
||||
@@ -69,6 +73,11 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
_loadingNode : null,
|
||||
_escCloseEvent : null,
|
||||
initializer : function(config) {
|
||||
recovergradescheckbox = null;
|
||||
if (this.get(UEP.DISABLEGRADEHISTORY) != true) {
|
||||
recovergradescheckbox = Y.Node.create('<div class="'+CSS.RECOVERGRADESCHECK+'"><input type="checkbox" id="recovergrades" name="recovergrades" /><span class="'+CSS.RECOVERGRADESCHECKTITLE+'"><label for="recovergrades">'+M.str.enrol.recovergrades+'</label></span></div>');
|
||||
}
|
||||
|
||||
this.set(UEP.BASE, Y.Node.create('<div class="'+CSS.PANEL+' '+CSS.HIDDEN+'"></div>')
|
||||
.append(Y.Node.create('<div class="'+CSS.WRAP+'"></div>')
|
||||
.append(Y.Node.create('<div class="'+CSS.HEADER+' header"></div>')
|
||||
@@ -79,6 +88,7 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
.append(Y.Node.create('<div class="'+CSS.SEARCHOPTION+' '+CSS.ROLE+'">'+M.str.role.assignroles+'</div>')
|
||||
.append(Y.Node.create('<select><option value="">'+M.str.enrol.none+'</option></select>'))
|
||||
)
|
||||
.append(recovergradescheckbox)
|
||||
.append(Y.Node.create('<div class="'+CSS.SEARCHOPTIONS+'"></div>')
|
||||
.append(Y.Node.create('<div class="'+CSS.COLLAPSIBLEHEADING+'"><img alt="" />'+M.str.enrol.enrolmentoptions+'</div>'))
|
||||
.append(Y.Node.create('<div class="'+CSS.COLLAPSIBLEAREA+' '+CSS.HIDDEN+'"></div>')
|
||||
@@ -98,6 +108,9 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
.append(Y.Node.create('<div class="'+CSS.SEARCH+'"><label>'+M.str.enrol.usersearch+'</label></div>')
|
||||
.append(Y.Node.create('<input type="text" id="enrolusersearch" value="" />'))
|
||||
)
|
||||
.append(Y.Node.create('<div class="'+CSS.CLOSEBTN+'"></div>')
|
||||
.append(Y.Node.create('<input type="button" value="'+M.str.enrol.finishenrollingusers+'" />'))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -109,6 +122,7 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
}
|
||||
}, this);
|
||||
this.get(UEP.BASE).one('.'+CSS.HEADER+' .'+CSS.CLOSE).on('click', this.hide, this);
|
||||
this.get(UEP.BASE).one('.'+CSS.FOOTER+' .'+CSS.CLOSEBTN+' input').on('click', this.hide, this);
|
||||
this._loadingNode = this.get(UEP.BASE).one('.'+CSS.CONTENT+' .'+CSS.LIGHTBOX);
|
||||
var params = this.get(UEP.PARAMS);
|
||||
params['id'] = this.get(UEP.COURSEID);
|
||||
@@ -362,6 +376,8 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
params['role'] = this.get(UEP.BASE).one('.'+CSS.SEARCHOPTION+'.'+CSS.ROLE+' select').get('value');
|
||||
params['startdate'] = this.get(UEP.BASE).one('.'+CSS.SEARCHOPTION+'.'+CSS.STARTDATE+' select').get('value');
|
||||
params['duration'] = this.get(UEP.BASE).one('.'+CSS.SEARCHOPTION+'.'+CSS.DURATION+' select').get('value');
|
||||
params['recovergrades'] = this.get(UEP.BASE).one('#recovergrades').get('checked')?1:0;
|
||||
|
||||
Y.io(M.cfg.wwwroot+this.get(UEP.AJAXURL), {
|
||||
method:'POST',
|
||||
data:build_querystring(params),
|
||||
@@ -482,6 +498,9 @@ YUI.add('moodle-enrol-enrolmentmanager', function(Y) {
|
||||
},
|
||||
optionsStartDate : {
|
||||
value : []
|
||||
},
|
||||
disableGradeHistory : {
|
||||
value : 0
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+2
-2
@@ -93,7 +93,7 @@ YUI.add('moodle-enrol-rolemanager', function(Y) {
|
||||
if (o.error) {
|
||||
new M.core.ajaxException(o);
|
||||
} else {
|
||||
panel.user.addRoleToDisplay(args.roleid, this.get(ASSIGNABLEROLES)[args.roleid]);
|
||||
this.users[userid].addRoleToDisplay(args.roleid, this.get(ASSIGNABLEROLES)[args.roleid]);
|
||||
}
|
||||
} catch (e) {
|
||||
new M.core.exception(e);
|
||||
@@ -391,7 +391,7 @@ YUI.add('moodle-enrol-rolemanager', function(Y) {
|
||||
}
|
||||
var node = null;
|
||||
for (var i in this.roles) {
|
||||
if (node = this.get('contentNode').one('#add_assignable_role_'+i)) {
|
||||
if (node = this.get('contentNode').one('#add_assignable_role_'+this.roles[i])) {
|
||||
node.removeAttribute('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,8 +672,7 @@ function filter_mediaplugin_youtube_callback($link) {
|
||||
$width = empty($link[5]) ? FILTER_MEDIAPLUGIN_VIDEO_WIDTH : $link[5];
|
||||
$height = empty($link[6]) ? FILTER_MEDIAPLUGIN_VIDEO_HEIGHT : $link[6];
|
||||
|
||||
if (false and empty($CFG->xmlstrictheaders)) {
|
||||
// TODO: remove this once iframe playback starts to work properly in iPads
|
||||
if (empty($CFG->xmlstrictheaders)) {
|
||||
return <<<OET
|
||||
<iframe title="$info" width="$width" height="$height" src="$site/embed/$videoid?rel=0" frameborder="0" allowfullscreen></iframe>
|
||||
OET;
|
||||
|
||||
@@ -38,20 +38,16 @@ class filter_mediaplugin_test extends UnitTestCase {
|
||||
|
||||
// we need to enable the plugins somehow
|
||||
$oldcfg = clone($CFG); // very, very ugly hack
|
||||
$CFG->filter_mediaplugin_enable_mp3 = 1;
|
||||
$CFG->filter_mediaplugin_enable_ogg = 1;
|
||||
$CFG->filter_mediaplugin_enable_ogv = 1;
|
||||
$CFG->filter_mediaplugin_enable_swf = 1;
|
||||
$CFG->filter_mediaplugin_enable_flv = 1;
|
||||
$CFG->filter_mediaplugin_enable_mov = 1;
|
||||
$CFG->filter_mediaplugin_enable_wmv = 1;
|
||||
$CFG->filter_mediaplugin_enable_mpg = 1;
|
||||
$CFG->filter_mediaplugin_enable_avi = 1;
|
||||
$CFG->filter_mediaplugin_enable_ram = 1;
|
||||
$CFG->filter_mediaplugin_enable_rpm = 1;
|
||||
$CFG->filter_mediaplugin_enable_rm = 1;
|
||||
$CFG->filter_mediaplugin_enable_youtube = 1;
|
||||
$CFG->filter_mediaplugin_enable_img = 1;
|
||||
$CFG->filter_mediaplugin_enable_youtube = 1;
|
||||
$CFG->filter_mediaplugin_enable_vimeo = 1;
|
||||
$CFG->filter_mediaplugin_enable_mp3 = 1;
|
||||
$CFG->filter_mediaplugin_enable_flv = 1;
|
||||
$CFG->filter_mediaplugin_enable_swf = 1;
|
||||
$CFG->filter_mediaplugin_enable_html5audio = 1;
|
||||
$CFG->filter_mediaplugin_enable_html5video = 1;
|
||||
$CFG->filter_mediaplugin_enable_qt = 1;
|
||||
$CFG->filter_mediaplugin_enable_wmp = 1;
|
||||
$CFG->filter_mediaplugin_enable_rm = 1;
|
||||
|
||||
|
||||
$filterplugin = new filter_mediaplugin(null, array());
|
||||
@@ -65,8 +61,6 @@ class filter_mediaplugin_test extends UnitTestCase {
|
||||
'<a class="youtube" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||
'<a class="_blanktarget" href="http://moodle.org/testfile/test.flv?d=100x100">test flv</a>',
|
||||
'<a class="hrefcss" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||
'<a href="http://www.moodle.org/logo.jpg"><img src="http://moodle.org/test.jpg" /></a>',
|
||||
'<a href="http://www.moodle.org/logo.rpm">rpm file</a>',
|
||||
'<a class="content" href="http://moodle.org/testfile/test.avi">test mp3</a>',
|
||||
'<a id="audio" href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<a href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
@@ -103,12 +97,9 @@ class filter_mediaplugin_test extends UnitTestCase {
|
||||
'<a href="http://moodle.org/testfile/test.mp3">test mp3',
|
||||
'<a href="http://moodle.org/testfile/test.mp3"test</a>',
|
||||
'<a href="http://moodle.org/testfile/">test</a>',
|
||||
'<a href="http://www.moodle.org/path/to/test.flv#param2=1?d=100x100">test</a>',
|
||||
'<href="http://moodle.org/testfile/test.avi">test</a>',
|
||||
'<a ahref="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<abbr href="http://moodle.org/testfile/test.mp3">test mp3</abbr>',
|
||||
'<ahref="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<a class="content"href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<aclass="content" href="http://moodle.org/testfile/test.mp3">test mp3</a>'
|
||||
);
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ function get_unenrolled_users_in_import($importcode, $courseid) {
|
||||
$relatedctxcondition = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
|
||||
//users with a gradeable role
|
||||
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
|
||||
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
|
||||
|
||||
//enrolled users
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
|
||||
+31
-17
@@ -85,10 +85,16 @@ class graded_users_iterator {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($gradebookroles_sql, $params) =
|
||||
$DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id);
|
||||
$relatedcontexts = get_related_contexts_string($coursecontext);
|
||||
|
||||
$relatedcontexts = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $this->course->id));
|
||||
list($gradebookroles_sql, $params) =
|
||||
$DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
|
||||
|
||||
//limit to users with an active enrolment
|
||||
list($enrolledsql, $enrolledparams) = get_enrolled_sql($coursecontext);
|
||||
|
||||
$params = array_merge($params, $enrolledparams);
|
||||
|
||||
if ($this->groupid) {
|
||||
$groupsql = "INNER JOIN {groups_members} gm ON gm.userid = u.id";
|
||||
@@ -123,31 +129,39 @@ class graded_users_iterator {
|
||||
// $params contents: gradebookroles and groupid (for $groupwheresql)
|
||||
$users_sql = "SELECT u.* $ofields
|
||||
FROM {user} u
|
||||
INNER JOIN {role_assignments} ra ON u.id = ra.userid
|
||||
JOIN ($enrolledsql) je ON je.id = u.id
|
||||
$groupsql
|
||||
WHERE u.deleted=0
|
||||
AND ra.roleid $gradebookroles_sql
|
||||
AND ra.contextid $relatedcontexts
|
||||
JOIN (
|
||||
SELECT DISTINCT ra.userid
|
||||
FROM {role_assignments} ra
|
||||
WHERE ra.roleid $gradebookroles_sql
|
||||
AND ra.contextid $relatedcontexts
|
||||
) rainner ON rainner.userid = u.id
|
||||
WHERE u.deleted = 0
|
||||
$groupwheresql
|
||||
ORDER BY $order";
|
||||
|
||||
$this->users_rs = $DB->get_recordset_sql($users_sql, $params);
|
||||
|
||||
if (!empty($this->grade_items)) {
|
||||
$itemids = array_keys($this->grade_items);
|
||||
list($itemidsql, $grades_params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED, 'items0');
|
||||
list($itemidsql, $grades_params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED, 'items');
|
||||
$params = array_merge($params, $grades_params);
|
||||
// $params contents: gradebookroles, enrolledparams, groupid (for $groupwheresql) and itemids
|
||||
|
||||
// $params contents: gradebookroles, groupid (for $groupwheresql) and itemids
|
||||
$grades_sql = "SELECT g.* $ofields
|
||||
FROM {grade_grades} g
|
||||
INNER JOIN {user} u ON g.userid = u.id
|
||||
INNER JOIN {role_assignments} ra ON u.id = ra.userid
|
||||
JOIN {user} u ON g.userid = u.id
|
||||
JOIN ($enrolledsql) je ON je.id = u.id
|
||||
$groupsql
|
||||
WHERE ra.roleid $gradebookroles_sql
|
||||
AND ra.contextid $relatedcontexts
|
||||
$groupwheresql
|
||||
AND g.itemid $itemidsql
|
||||
JOIN (
|
||||
SELECT DISTINCT ra.userid
|
||||
FROM {role_assignments} ra
|
||||
WHERE ra.roleid $gradebookroles_sql
|
||||
AND ra.contextid $relatedcontexts
|
||||
) rainner ON rainner.userid = u.id
|
||||
WHERE u.deleted = 0
|
||||
AND g.itemid $itemidsql
|
||||
$groupwheresql
|
||||
ORDER BY $order, g.itemid ASC";
|
||||
$this->grades_rs = $DB->get_recordset_sql($grades_sql, $params);
|
||||
} else {
|
||||
@@ -2231,7 +2245,7 @@ abstract class grade_helper {
|
||||
*/
|
||||
public static function get_plugins_reports($courseid) {
|
||||
global $SITE;
|
||||
|
||||
|
||||
if (self::$gradereports !== null) {
|
||||
return self::$gradereports;
|
||||
}
|
||||
|
||||
+74
-52
@@ -342,55 +342,47 @@ class grade_report_grader extends grade_report {
|
||||
//fields we need from the user table
|
||||
$userfields = user_picture::fields('u', array('idnumber'));
|
||||
|
||||
$sortjoin = $sort = $params = null;
|
||||
|
||||
//if the user has clicked one of the sort asc/desc arrows
|
||||
if (is_numeric($this->sortitemid)) {
|
||||
$params = array_merge(array('gitemid'=>$this->sortitemid), $gradebookrolesparams, $this->groupwheresql_params, $enrolledparams);
|
||||
// the MAX() magic is required in order to please PG
|
||||
$sort = "MAX(g.finalgrade) $this->sortorder";
|
||||
|
||||
$sql = "SELECT $userfields
|
||||
FROM {user} u
|
||||
JOIN ($enrolledsql) je
|
||||
ON je.id = u.id
|
||||
JOIN {role_assignments} ra
|
||||
ON ra.userid = u.id
|
||||
$this->groupsql
|
||||
LEFT JOIN {grade_grades} g
|
||||
ON (g.userid = u.id AND g.itemid = :gitemid)
|
||||
WHERE ra.roleid $gradebookrolessql
|
||||
AND u.deleted = 0
|
||||
AND ra.contextid ".get_related_contexts_string($this->context)."
|
||||
$this->groupwheresql
|
||||
GROUP BY $userfields
|
||||
ORDER BY $sort";
|
||||
$sortjoin = "LEFT JOIN {grade_grades} g ON g.userid = u.id AND g.itemid = $this->sortitemid";
|
||||
$sort = "g.finalgrade $this->sortorder";
|
||||
|
||||
} else {
|
||||
$sortjoin = '';
|
||||
switch($this->sortitemid) {
|
||||
case 'lastname':
|
||||
$sort = "u.lastname $this->sortorder, u.firstname $this->sortorder"; break;
|
||||
$sort = "u.lastname $this->sortorder, u.firstname $this->sortorder";
|
||||
break;
|
||||
case 'firstname':
|
||||
$sort = "u.firstname $this->sortorder, u.lastname $this->sortorder"; break;
|
||||
$sort = "u.firstname $this->sortorder, u.lastname $this->sortorder";
|
||||
break;
|
||||
case 'idnumber':
|
||||
default:
|
||||
$sort = "u.idnumber $this->sortorder"; break;
|
||||
$sort = "u.idnumber $this->sortorder";
|
||||
break;
|
||||
}
|
||||
|
||||
$params = array_merge($gradebookrolesparams, $this->groupwheresql_params, $enrolledparams);
|
||||
|
||||
$sql = "SELECT DISTINCT $userfields
|
||||
FROM {user} u
|
||||
JOIN ($enrolledsql) je
|
||||
ON je.id = u.id
|
||||
JOIN {role_assignments} ra
|
||||
ON u.id = ra.userid
|
||||
$this->groupsql
|
||||
WHERE ra.roleid $gradebookrolessql
|
||||
AND u.deleted = 0
|
||||
AND ra.contextid ".get_related_contexts_string($this->context)."
|
||||
$this->groupwheresql
|
||||
ORDER BY $sort";
|
||||
}
|
||||
|
||||
$sql = "SELECT $userfields
|
||||
FROM {user} u
|
||||
JOIN ($enrolledsql) je ON je.id = u.id
|
||||
$this->groupsql
|
||||
$sortjoin
|
||||
JOIN (
|
||||
SELECT DISTINCT ra.userid
|
||||
FROM {role_assignments} ra
|
||||
WHERE ra.roleid IN ($this->gradebookroles)
|
||||
AND ra.contextid " . get_related_contexts_string($this->context) . "
|
||||
) rainner ON rainner.userid = u.id
|
||||
AND u.deleted = 0
|
||||
$this->groupwheresql
|
||||
ORDER BY $sort";
|
||||
|
||||
$this->users = $DB->get_records_sql($sql, $params, $this->get_pref('studentsperpage') * $this->page, $this->get_pref('studentsperpage'));
|
||||
|
||||
@@ -399,9 +391,26 @@ class grade_report_grader extends grade_report {
|
||||
$this->users = array();
|
||||
$this->userselect_params = array();
|
||||
} else {
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid0');
|
||||
list($usql, $uparams) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid0');
|
||||
$this->userselect = "AND g.userid $usql";
|
||||
$this->userselect_params = $params;
|
||||
$this->userselect_params = $uparams;
|
||||
|
||||
//add a flag to each user indicating whether their enrolment is active
|
||||
$sql = "SELECT ue.userid
|
||||
FROM {user_enrolments} ue
|
||||
JOIN {enrol} e ON e.id = ue.enrolid
|
||||
WHERE ue.userid $usql
|
||||
AND ue.status = :uestatus
|
||||
AND e.status = :estatus
|
||||
AND e.courseid = :courseid
|
||||
GROUP BY ue.userid";
|
||||
$coursecontext = get_course_context($this->context);
|
||||
$params = array_merge($uparams, array('estatus'=>ENROL_INSTANCE_ENABLED, 'uestatus'=>ENROL_USER_ACTIVE, 'courseid'=>$coursecontext->instanceid));
|
||||
$useractiveenrolments = $DB->get_records_sql($sql, $params);
|
||||
|
||||
foreach ($this->users as $user) {
|
||||
$this->users[$user->id]->suspendedenrolment = !array_key_exists($user->id, $useractiveenrolments);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->users;
|
||||
@@ -610,6 +619,7 @@ class grade_report_grader extends grade_report {
|
||||
|
||||
$rowclasses = array('even', 'odd');
|
||||
|
||||
$suspendedstring = null;
|
||||
foreach ($this->users as $userid => $user) {
|
||||
$userrow = new html_table_row();
|
||||
$userrow->id = 'fixed_user_'.$userid;
|
||||
@@ -617,6 +627,7 @@ class grade_report_grader extends grade_report {
|
||||
|
||||
$usercell = new html_table_cell();
|
||||
$usercell->attributes['class'] = 'user';
|
||||
|
||||
$usercell->header = true;
|
||||
$usercell->scope = 'row';
|
||||
|
||||
@@ -626,6 +637,16 @@ class grade_report_grader extends grade_report {
|
||||
|
||||
$usercell->text .= html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), fullname($user));
|
||||
|
||||
if (!empty($user->suspendedenrolment)) {
|
||||
$usercell->attributes['class'] .= ' usersuspended';
|
||||
|
||||
//may be lots of suspended users so only get the string once
|
||||
if (empty($suspendedstring)) {
|
||||
$suspendedstring = get_string('userenrolmentsuspended', 'grades');
|
||||
}
|
||||
$usercell->text .= html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/enrolmentsuspended'), 'title'=>$suspendedstring, 'alt'=>$suspendedstring, 'class'=>'usersuspendedicon'));
|
||||
}
|
||||
|
||||
$userrow->cells[] = $usercell;
|
||||
|
||||
if (has_capability('gradereport/'.$CFG->grade_profilereport.':view', $this->context)) {
|
||||
@@ -1294,25 +1315,25 @@ class grade_report_grader extends grade_report {
|
||||
$params = array_merge(array('courseid'=>$this->courseid), $gradebookrolesparams, $enrolledparams, $groupwheresqlparams);
|
||||
|
||||
// find sums of all grade items in course
|
||||
$SQL = "SELECT g.itemid, SUM(g.finalgrade) AS sum
|
||||
$sql = "SELECT g.itemid, SUM(g.finalgrade) AS sum
|
||||
FROM {grade_items} gi
|
||||
JOIN {grade_grades} g
|
||||
ON g.itemid = gi.id
|
||||
JOIN {user} u
|
||||
ON u.id = g.userid
|
||||
JOIN ($enrolledsql) je
|
||||
ON je.id = u.id
|
||||
JOIN {role_assignments} ra
|
||||
ON ra.userid = u.id
|
||||
JOIN {grade_grades} g ON g.itemid = gi.id
|
||||
JOIN {user} u ON u.id = g.userid
|
||||
JOIN ($enrolledsql) je ON je.id = u.id
|
||||
JOIN (
|
||||
SELECT DISTINCT ra.userid
|
||||
FROM {role_assignments} ra
|
||||
WHERE ra.roleid $gradebookrolessql
|
||||
AND ra.contextid " . get_related_contexts_string($this->context) . "
|
||||
) rainner ON rainner.userid = u.id
|
||||
$groupsql
|
||||
WHERE gi.courseid = :courseid
|
||||
AND ra.roleid $gradebookrolessql
|
||||
AND ra.contextid ".get_related_contexts_string($this->context)."
|
||||
AND g.finalgrade IS NOT NULL
|
||||
$groupwheresql
|
||||
GROUP BY g.itemid";
|
||||
AND u.deleted = 0
|
||||
AND g.finalgrade IS NOT NULL
|
||||
$groupwheresql
|
||||
GROUP BY g.itemid";
|
||||
$sumarray = array();
|
||||
if ($sums = $DB->get_records_sql($SQL, $params)) {
|
||||
if ($sums = $DB->get_records_sql($sql, $params)) {
|
||||
foreach ($sums as $itemid => $csum) {
|
||||
$sumarray[$itemid] = $csum->sum;
|
||||
}
|
||||
@@ -1320,7 +1341,7 @@ class grade_report_grader extends grade_report {
|
||||
|
||||
// MDL-10875 Empty grades must be evaluated as grademin, NOT always 0
|
||||
// This query returns a count of ungraded grades (NULL finalgrade OR no matching record in grade_grades table)
|
||||
$SQL = "SELECT gi.id, COUNT(u.id) AS count
|
||||
$sql = "SELECT gi.id, COUNT(DISTINCT u.id) AS count
|
||||
FROM {grade_items} gi
|
||||
CROSS JOIN {user} u
|
||||
JOIN ($enrolledsql) je
|
||||
@@ -1333,11 +1354,12 @@ class grade_report_grader extends grade_report {
|
||||
WHERE gi.courseid = :courseid
|
||||
AND ra.roleid $gradebookrolessql
|
||||
AND ra.contextid ".get_related_contexts_string($this->context)."
|
||||
AND u.deleted = 0
|
||||
AND g.id IS NULL
|
||||
$groupwheresql
|
||||
GROUP BY gi.id";
|
||||
|
||||
$ungradedcounts = $DB->get_records_sql($SQL, $params);
|
||||
$ungradedcounts = $DB->get_records_sql($sql, $params);
|
||||
|
||||
$avgrow = new html_table_row();
|
||||
$avgrow->attributes['class'] = 'avg';
|
||||
|
||||
@@ -555,14 +555,23 @@ background-color:#f3ead8;
|
||||
.path-grade-report-grader div.right_scroller td,
|
||||
.path-grade-report-grader div.left_scroller th,
|
||||
.path-grade-report-grader div.right_scroller th {
|
||||
height:4.5em;
|
||||
font-size:10px;
|
||||
height:4.5em;
|
||||
font-size:10px;
|
||||
}
|
||||
|
||||
.path-grade-report-grader table th.user,
|
||||
.path-grade-report-grader table td.useridnumber {
|
||||
text-align:left;
|
||||
vertical-align:middle;
|
||||
text-align:left;
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
.path-grade-report-grader .usersuspended a:link,
|
||||
.path-grade-report-grader .usersuspended a:visited {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.path-grade-report-grader table th.usersuspended img.usersuspendedicon {
|
||||
vertical-align:middle;
|
||||
}
|
||||
|
||||
.path-grade-report-grader .yui-overlay {
|
||||
|
||||
+25
-21
@@ -618,19 +618,21 @@ class grade_report_user extends grade_report {
|
||||
// find sums of all grade items in course
|
||||
$sql = "SELECT gg.itemid, SUM(gg.finalgrade) AS sum
|
||||
FROM {grade_items} gi
|
||||
JOIN {grade_grades} gg
|
||||
ON gg.itemid = gi.id
|
||||
JOIN ($enrolledsql) je
|
||||
ON je.id = gg.userid
|
||||
JOIN {role_assignments} ra
|
||||
ON ra.userid = gg.userid
|
||||
JOIN {grade_grades} gg ON gg.itemid = gi.id
|
||||
JOIN {user} u ON u.id = gg.userid
|
||||
JOIN ($enrolledsql) je ON je.id = gg.userid
|
||||
JOIN (
|
||||
SELECT DISTINCT ra.userid
|
||||
FROM {role_assignments} ra
|
||||
WHERE ra.roleid $gradebookrolessql
|
||||
AND ra.contextid " . get_related_contexts_string($this->context) . "
|
||||
) rainner ON rainner.userid = u.id
|
||||
$groupsql
|
||||
WHERE gi.courseid = :courseid
|
||||
AND ra.roleid $gradebookrolessql
|
||||
AND ra.contextid ".get_related_contexts_string($this->context)."
|
||||
AND gg.finalgrade IS NOT NULL
|
||||
AND gg.hidden = 0
|
||||
$groupwheresql
|
||||
AND u.deleted = 0
|
||||
AND gg.finalgrade IS NOT NULL
|
||||
AND gg.hidden = 0
|
||||
$groupwheresql
|
||||
GROUP BY gg.itemid";
|
||||
|
||||
$sum_array = array();
|
||||
@@ -649,19 +651,21 @@ class grade_report_user extends grade_report {
|
||||
$sql = "SELECT gi.id, COUNT(u.id) AS count
|
||||
FROM {grade_items} gi
|
||||
JOIN {user} u
|
||||
JOIN ($enrolledsql) je
|
||||
ON je.id = u.id
|
||||
JOIN {role_assignments} ra
|
||||
ON ra.userid = u.id
|
||||
JOIN ($enrolledsql) je ON je.id = u.id
|
||||
JOIN (
|
||||
SELECT DISTINCT ra.userid
|
||||
FROM {role_assignments} ra
|
||||
WHERE ra.roleid $gradebookrolessql
|
||||
AND ra.contextid " . get_related_contexts_string($this->context) . "
|
||||
) rainner ON rainner.userid = u.id
|
||||
LEFT JOIN {grade_grades} gg
|
||||
ON (gg.itemid = gi.id AND gg.userid = u.id AND gg.finalgrade IS NOT NULL AND gg.hidden = 0)
|
||||
$groupsql
|
||||
WHERE gi.courseid = :courseid
|
||||
AND ra.roleid $gradebookrolessql
|
||||
AND ra.contextid ".get_related_contexts_string($this->context)."
|
||||
AND gg.finalgrade IS NULL
|
||||
$groupwheresql
|
||||
GROUP BY gi.id";
|
||||
WHERE gi.courseid = :courseid
|
||||
AND u.deleted = 0
|
||||
AND gg.finalgrade IS NULL
|
||||
$groupwheresql
|
||||
GROUP BY gi.id";
|
||||
|
||||
$ungraded_counts = $DB->get_records_sql($sql, $params);
|
||||
|
||||
|
||||
+4
-4
@@ -183,7 +183,7 @@ $string['configdefaultallowedmodules'] = 'For the courses which fall into the ab
|
||||
$string['configdefaulthomepage'] = 'This determines the home page for logged in users';
|
||||
$string['configdefaultrequestcategory'] = 'Courses requested by users will be automatically placed in this category.';
|
||||
$string['configdefaultrequestedcategory'] = 'Default category to put courses that were requested into, if they\'re approved.';
|
||||
$string['configdefaultuserroleid'] = 'All logged in users will be given the capabilities of the role you specify here, at the site level, in ADDITION to any other roles they may have been given. The default is the Authenticated user role (or Guest role in older versions). Note that this will not conflict with other roles they have, it just ensures that all users have capabilities that are not assignable at the course level (eg post blog entries, manage own calendar, etc).';
|
||||
$string['configdefaultuserroleid'] = 'All logged in users will be given the capabilities of the role you specify here, at the site level, in ADDITION to any other roles they may have been given. The default is the Authenticated user role. Note that this will not conflict with other roles they have unless you prohibit capabilities, it just ensures that all users have capabilities that are not assignable at the course level (eg post blog entries, manage own calendar, etc).';
|
||||
$string['configdeleteincompleteusers'] = 'After this period, old not fully setup accounts are deleted.';
|
||||
$string['configdeleteunconfirmed'] = 'If you are using email authentication, this is the period within which a response will be accepted from users. After this period, old unconfirmed accounts are deleted.';
|
||||
$string['configdenyemailaddresses'] = 'To deny email addresses from particular domains list them here in the same way. All other domains will be accepted. To deny subdomains add the domain with a preceding \'.\'. eg <strong>hotmail.com yahoo.co.uk .live.com</strong>';
|
||||
@@ -246,7 +246,6 @@ $string['configjabberpassword'] = 'The password to use when connecting to the Ja
|
||||
$string['configjabberport'] = 'The port to use when connecting to the Jabber server';
|
||||
$string['configkeeptagnamecase'] = 'Check this if you want tag names to keep the original casing as entered by users who created them';
|
||||
$string['configlang'] = 'Choose a default language for the whole site. Users can override this setting using the language menu or the setting in their personal profile.';
|
||||
$string['configlangcache'] = 'Cache the language menu. Saves a lot of memory and processing power. If you enable this, the menu takes a few minutes to update after you have added or removed languages.';
|
||||
$string['configlangstringcache'] = 'Caches all the language strings into compiled files in the data directory. If you are translating Moodle or changing strings in the Moodle source code then you may want to switch this off. Otherwise leave it on to see performance benefits.';
|
||||
$string['configlangdir'] = 'Most languages are printed left-to-right, but some, like Arabic and Hebrew, are printed right-to-left.';
|
||||
$string['configlanglist'] = 'Leave this blank to allow users to choose from any language you have in this installation of Moodle. However, you can shorten the language menu by entering a comma-separated list of language codes that you want. For example: en,es_es,fr,it';
|
||||
@@ -277,7 +276,6 @@ $string['configmypagelocked'] = 'This setting prevents the default page from bei
|
||||
$string['confignavcourselimit'] = 'Limits the number of courses shown to the user when they are either not logged in or are not enrolled in any courses.';
|
||||
$string['confignavshowallcourses'] = 'Setting this ensures that all courses on the site are shown in the navigation at all times.';
|
||||
$string['confignavshowcategories'] = 'Show course categories in the navigation bar and navigation blocks. This does not occur with courses the user is currently enrolled in, they will still be listed under mycourses without categories.';
|
||||
$string['confignodefaultuserrolelists'] = 'This setting prevents all users from being returned from the database from deprecated calls of get_course_user, etc., for the site course if the default role provides that access. Check this, if you suffer a performance hit.';
|
||||
$string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the "From" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).';
|
||||
$string['confignotifyloginfailures'] = 'If login failures have been recorded, email notifications can be sent out. Who should see these notifications?';
|
||||
$string['confignotifyloginthreshold'] = 'If notifications about failed logins are active, how many failed login attempts by one user or one IP address is it worth notifying about?';
|
||||
@@ -400,6 +398,8 @@ $string['ctyperequired'] = 'The ctype PHP extension is now required by Moodle, i
|
||||
$string['curlcache'] = 'cURL cache TTL';
|
||||
$string['curlrecommended'] = 'Installing the optional cURL library is highly recommended in order to enable Moodle Networking functionality.';
|
||||
$string['curlrequired'] = 'The cURL PHP extension is now required by Moodle, in order to communicate with Moodle repositories.';
|
||||
$string['curltimeoutkbitrate'] = 'Bitrate to use when calculating cURL timeouts (Kbps)';
|
||||
$string['curltimeoutkbitrate_help'] = 'This setting is used to calculate an appropriate timeout during large cURL requests. As part of this calculation an HTTP HEAD request is made to determine the size of the content. Setting this to 0 disables this request from being made.';
|
||||
$string['customcheck'] = 'Other checks';
|
||||
$string['custommenu'] = 'Custom menu';
|
||||
$string['custommenuitems'] = 'Custom menu items';
|
||||
@@ -632,6 +632,7 @@ $string['jabberport'] = 'Jabber port';
|
||||
$string['keeptagnamecase'] = 'Keep tag name casing';
|
||||
$string['lang'] = 'Default language';
|
||||
$string['langcache'] = 'Cache language menu';
|
||||
$string['langcache_desc'] = 'Cache the language menu. If enabled, the list of available translations is cached. The cache is automatically refreshed when you install or delete a language pack via the in-built language packs management tool. If you install a new language pack manually, you have to use Purge all caches feature to refresh the cached list.';
|
||||
$string['langedit'] = 'Language editing';
|
||||
$string['langimport'] = 'Language import utility';
|
||||
$string['langimportdisabled'] = 'Language import feature has been disabled. You have to update your language packs manually at the file-system level.';
|
||||
@@ -747,7 +748,6 @@ $string['navshowcategories'] = 'Show course categories';
|
||||
$string['neverdeleteruns'] = 'Never delete runs';
|
||||
$string['nobookmarksforuser'] = 'You do not have any bookmarks.';
|
||||
$string['nodatabase'] = 'No database';
|
||||
$string['nodefaultuserrolelists'] = 'Don\'t return all default role users';
|
||||
$string['nochanges'] = 'No changes';
|
||||
$string['nolangupdateneeded'] = 'All your language packs are up to date, no update is needed';
|
||||
$string['nomissingstrings'] = 'No missing strings';
|
||||
|
||||
@@ -60,6 +60,7 @@ $string['errajaxfailedenrol'] = 'Failed to enrol user';
|
||||
$string['errajaxsearch'] = 'Error when searching users';
|
||||
$string['errorenrolcohort'] = 'Error creating cohort sync enrolment instance in this course.';
|
||||
$string['errorenrolcohortusers'] = 'Error enrolling cohort members in this course.';
|
||||
$string['finishenrollingusers'] = 'Finish enrolling users';
|
||||
$string['invalidenrolinstance'] = 'Invalid enrolment instance';
|
||||
$string['invalidrole'] = 'Invalid role';
|
||||
$string['manageenrols'] = 'Manage enrol plugins';
|
||||
@@ -76,6 +77,7 @@ $string['participationsuspended'] = 'Suspended';
|
||||
$string['periodend'] = 'until {$a}';
|
||||
$string['periodstart'] = 'from {$a}';
|
||||
$string['periodstartend'] = 'from {$a->start} until {$a->end}';
|
||||
$string['recovergrades'] = 'Recover user\'s old grades if possible';
|
||||
$string['rolefromthiscourse'] = '{$a->role} (Assigned in this course)';
|
||||
$string['rolefrommetacourse'] = '{$a->role} (Inherited from parent course)';
|
||||
$string['rolefromcategory'] = '{$a->role} (Inherited from course category)';
|
||||
|
||||
+7
-3
@@ -32,6 +32,7 @@ $string['blockcannotread'] = 'Could not read data for blockid= {$a}';
|
||||
$string['blockdoesnotexist'] = 'This block does not exist';
|
||||
$string['blockdoesnotexistonpage'] = 'This block (id={$a->instanceid}) does not exist on this page ({$a->url}).';
|
||||
$string['blocknameconflict'] = 'Naming conflict: block {$a->name} has the same title with an existing block: {$a->conflict}!';
|
||||
$string['callbackrejectcomment'] = 'Comment callback rejected this comment.';
|
||||
$string['cannotaddcoursemodule'] = 'Could not add a new course module';
|
||||
$string['cannotaddcoursemoduletosection'] = 'Could not add the new course module to that section';
|
||||
$string['cannotaddmodule'] = '{$a} module could not be added to the module list!';
|
||||
@@ -61,7 +62,6 @@ $string['cannotdeletecourse'] = 'You do not have the permission to delete this c
|
||||
$string['cannotdeletecustomfield'] = 'Error deleting custom field data';
|
||||
$string['cannotdeletedir'] = 'Cannot delete ({$a})';
|
||||
$string['cannotdeletefile'] = 'Cannot delete this file';
|
||||
$string['cannotdeletelangcache'] = 'Language cache cannot be deleted, please fix permissions in dataroot/cache/languages!';
|
||||
$string['cannotdeleterole'] = 'It cannot be deleted, because {$a}';
|
||||
$string['cannotdeleterolewithid'] = 'Could not delete role with ID {$a}';
|
||||
$string['cannotdeletethisrole'] = 'You cannot delete this role because it is used by the system, or because it is the last role with administrator capabilities.';
|
||||
@@ -262,6 +262,11 @@ $string['invalidblockinstance'] = 'Invalid block instance for: {$a}';
|
||||
$string['invalidcategory'] = 'Incorrect category!';
|
||||
$string['invalidcategoryid'] = 'Incorrect category id!';
|
||||
$string['invalidcomment'] = 'Comment is incorrect';
|
||||
$string['invalidcommentid'] = 'Invalid comment id';
|
||||
$string['invalidcommentitemid'] = 'Invalid comment itemid';
|
||||
$string['invalidcommentarea'] = 'Invalid comment area';
|
||||
$string['invalidcommentparam'] = 'Invalid comment parameters';
|
||||
$string['invalidcomponent'] = 'Invalid component name';
|
||||
$string['invalidconfirmdata'] = 'Invalid confirmation data';
|
||||
$string['invalidcontext'] = 'Invalid context';
|
||||
$string['invalidcourse'] = 'Invalid course';
|
||||
@@ -344,7 +349,6 @@ $string['moduledisable'] = 'This module ({$a}) has been disabled for this partic
|
||||
$string['moduledoesnotexist'] = 'This module does not exist';
|
||||
$string['moduleinstancedoesnotexist'] = 'The instance of this module does not exist';
|
||||
$string['modulemissingcode'] = 'Module {$a} is missing the code needed to perform this function';
|
||||
$string['modulerejectcomment'] = 'Module rejects to add this comment';
|
||||
$string['multiplerecordsfound'] = 'Multiple records found, only one record expected.';
|
||||
$string['multiplerestorenotallow'] = 'Multiple restore execution not allowed!';
|
||||
$string['mustbeloggedin'] = 'You must be logged in to do this';
|
||||
@@ -515,5 +519,5 @@ $string['wscouldnotcreateecoursenopermission'] = 'WS - Could not create course -
|
||||
$string['wwwrootmismatch'] = 'Incorrect access detected, this server may be accessed only through "{$a}" address, sorry.<br />Please notify server administrator.';
|
||||
$string['wwwrootslash'] = 'Detected incorrect $CFG->wwwroot in config.php, it must not contain trailing slash.<br />Please notify server administrator.';
|
||||
$string['xmldberror'] = 'XMLDB error!';
|
||||
$string['alreadyloggedin'] = 'You are already logged in as {$a}, you need to log out before logging is as different user.';
|
||||
$string['alreadyloggedin'] = 'You are already logged in as {$a}, you need to log out before logging in as different user.';
|
||||
$string['youcannotdeletecategory'] = 'You cannot delete category \'{$a}\' because you can neither delete the contents, nor move them elsewhere.';
|
||||
|
||||
@@ -634,6 +634,7 @@ $string['usepercent'] = 'Use percent';
|
||||
$string['user'] = 'User';
|
||||
$string['usergrade'] = 'User {$a->fullname} ({$a->useridnumber}) on item {$a->gradeidnumber}';
|
||||
$string['userpreferences'] = 'User preferences';
|
||||
$string['userenrolmentsuspended'] = 'User enrolment suspended';
|
||||
$string['useweighted'] = 'Use weighted';
|
||||
$string['verbosescales'] = 'Verbose scales';
|
||||
$string['viewbygroup'] = 'Group';
|
||||
|
||||
@@ -242,6 +242,7 @@ $string['closewindow'] = 'Close this window';
|
||||
$string['collapseall'] = 'Collapse all';
|
||||
$string['commentincontext'] = 'Find this comment in context';
|
||||
$string['comments'] = 'Comments';
|
||||
$string['commentsnotenabled'] = 'Comments feature is not enabled';
|
||||
$string['commentsrequirelogin'] = 'You need to login to view the comments';
|
||||
$string['comparelanguage'] = 'Compare and edit current language';
|
||||
$string['complete'] = 'Complete';
|
||||
@@ -1134,6 +1135,7 @@ $string['nobody'] = 'Nobody';
|
||||
$string['nocourses'] = 'No courses';
|
||||
$string['nocoursesfound'] = 'No courses were found with the words \'{$a}\'';
|
||||
$string['nocoursesyet'] = 'No courses in this category';
|
||||
$string['nocomments'] = 'No comments';
|
||||
$string['nodstpresets'] = 'The administrator has not enabled Daylight Savings Time support.';
|
||||
$string['nofilesselected'] = 'No files have been selected to restore';
|
||||
$string['nofilesyet'] = 'No files have been uploaded to your course yet';
|
||||
|
||||
@@ -50,6 +50,7 @@ $string['noviewrate'] = 'You do not have the capability to view item ratings';
|
||||
$string['rate'] = 'Rate';
|
||||
$string['ratepermissiondenied'] = 'You do not have permission to rate this item';
|
||||
$string['rating'] = 'Rating';
|
||||
$string['ratinginvalid'] = 'Rating is invalid';
|
||||
$string['ratingtime'] = 'Restrict ratings to items with dates in this range:';
|
||||
$string['ratings'] = 'Ratings';
|
||||
$string['rolewarning'] = 'Roles with permission to rate';
|
||||
|
||||
@@ -94,6 +94,9 @@ $string['errorpostmaxsize'] = 'The uploaded file may exceed max_post_size direct
|
||||
$string['existingrepository'] = 'This repository already exists';
|
||||
$string['federatedsearch'] = 'Federated search';
|
||||
$string['fileexists'] = 'File name already being used, please use another name';
|
||||
$string['fileexistsdialog_editor'] = 'A file with that name has already been attached to the text you are editing.';
|
||||
$string['fileexistsdialog_filemanager'] = 'A file with that name has already been attached';
|
||||
$string['fileexistsdialogheader'] = 'File exists';
|
||||
$string['filename'] = 'Filename';
|
||||
$string['filenotnull'] = 'You must select a file to upload.';
|
||||
$string['filesaved'] = 'The file has been saved';
|
||||
@@ -123,6 +126,7 @@ $string['logout'] = 'Logout';
|
||||
$string['manage'] = 'Manage repositories';
|
||||
$string['manageurl'] = 'Manage';
|
||||
$string['manageuserrepository'] = 'Manage individual repository';
|
||||
$string['moving'] = 'Moving';
|
||||
$string['noenter'] = 'Nothing entered';
|
||||
$string['nofilesattached'] = 'No files attached';
|
||||
$string['nofilesavailable'] = 'No files available';
|
||||
@@ -137,6 +141,7 @@ $string['off'] = 'Enabled but hidden';
|
||||
$string['openpicker'] = 'Choose a file...';
|
||||
$string['operation'] = 'Operation';
|
||||
$string['on'] = 'Enabled and visible';
|
||||
$string['overwrite'] = 'Overwrite';
|
||||
$string['personalrepositories'] = 'Available repository instances';
|
||||
$string['plugin'] = 'Repository plug-ins';
|
||||
$string['pluginerror'] = 'Errors in repository plugin.';
|
||||
@@ -147,9 +152,11 @@ $string['readonlyinstance'] = 'You cannot edit/delete a read-only instance';
|
||||
$string['refresh'] = 'Refresh';
|
||||
$string['refreshnonjsfilepicker'] = 'Please close this window and refresh non-javascript file picker';
|
||||
$string['removed'] = 'Repository removed';
|
||||
$string['renameto'] = 'Rename to';
|
||||
$string['repositories'] = 'Repositories';
|
||||
$string['repository'] = 'Repository';
|
||||
$string['repositorycourse'] = 'Course repositories';
|
||||
$string['repositoryerror'] = 'Remote repository returned error: {$a}';
|
||||
$string['save'] = 'Save';
|
||||
$string['saveas'] = 'Save as';
|
||||
$string['saved'] = 'Saved';
|
||||
|
||||
+13
-13
@@ -2540,7 +2540,7 @@ function get_roles_with_capability($capability, $permission = null, $context = n
|
||||
|
||||
if ($context) {
|
||||
$contexts = get_parent_contexts($context, true);
|
||||
list($insql, $params) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED, 'ctx000');
|
||||
list($insql, $params) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED, 'ctx');
|
||||
$contextsql = "AND rc.contextid $insql";
|
||||
} else {
|
||||
$params = array();
|
||||
@@ -3097,7 +3097,7 @@ function get_enrolled_sql($context, $withcapability = '', $groupid = 0, $onlyact
|
||||
|
||||
// get all relevant capability info for all roles
|
||||
if ($withcapability) {
|
||||
list($incontexts, $cparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($incontexts, $cparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'ctx');
|
||||
$cparams['cap'] = $withcapability;
|
||||
|
||||
$defs = array();
|
||||
@@ -3142,8 +3142,8 @@ function get_enrolled_sql($context, $withcapability = '', $groupid = 0, $onlyact
|
||||
}
|
||||
}
|
||||
|
||||
$defaultuserroleid = isset($CFG->defaultuserroleid) ? $CFG->defaultuserroleid : null;
|
||||
$defaultfrontpageroleid = isset($CFG->defaultfrontpageroleid) ? $CFG->defaultfrontpageroleid : null;
|
||||
$defaultuserroleid = isset($CFG->defaultuserroleid) ? $CFG->defaultuserroleid : 0;
|
||||
$defaultfrontpageroleid = isset($CFG->defaultfrontpageroleid) ? $CFG->defaultfrontpageroleid : 0;
|
||||
|
||||
$nobody = false;
|
||||
|
||||
@@ -3741,7 +3741,7 @@ function fetch_context_capabilities($context) {
|
||||
|
||||
case CONTEXT_USER:
|
||||
$extracaps = array('moodle/grade:viewall');
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap');
|
||||
$SQL = "SELECT *
|
||||
FROM {capabilities}
|
||||
WHERE contextlevel = ".CONTEXT_USER."
|
||||
@@ -3814,7 +3814,7 @@ function fetch_context_capabilities($context) {
|
||||
$extra = '';
|
||||
$extracaps = block_method_result($bi->blockname, 'get_extra_capabilities');
|
||||
if ($extracaps) {
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap');
|
||||
$extra = "OR name $extra";
|
||||
}
|
||||
|
||||
@@ -4851,8 +4851,8 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
|
||||
throw new coding_exception('Invalid context specified');
|
||||
}
|
||||
|
||||
$defaultuserroleid = isset($CFG->defaultuserroleid) ? $CFG->defaultuserroleid : null;
|
||||
$defaultfrontpageroleid = isset($CFG->defaultfrontpageroleid) ? $CFG->defaultfrontpageroleid : null;
|
||||
$defaultuserroleid = isset($CFG->defaultuserroleid) ? $CFG->defaultuserroleid : 0;
|
||||
$defaultfrontpageroleid = isset($CFG->defaultfrontpageroleid) ? $CFG->defaultfrontpageroleid : 0;
|
||||
|
||||
$ctxids = trim($context->path, '/');
|
||||
$ctxids = str_replace('/', ',', $ctxids);
|
||||
@@ -4876,8 +4876,8 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
|
||||
|
||||
// we need to find out all roles that have these capabilities either in definition or in overrides
|
||||
$defs = array();
|
||||
list($incontexts, $params) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'con000');
|
||||
list($incaps, $params2) = $DB->get_in_or_equal($caps, SQL_PARAMS_NAMED, 'cap000');
|
||||
list($incontexts, $params) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'con');
|
||||
list($incaps, $params2) = $DB->get_in_or_equal($caps, SQL_PARAMS_NAMED, 'cap');
|
||||
$params = array_merge($params, $params2);
|
||||
$sql = "SELECT rc.id, rc.roleid, rc.permission, rc.capability, ctx.path
|
||||
FROM {role_capabilities} rc
|
||||
@@ -5001,7 +5001,7 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
|
||||
/// Groups
|
||||
if ($groups) {
|
||||
$groups = (array)$groups;
|
||||
list($grouptest, $grpparams) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED, 'grp000');
|
||||
list($grouptest, $grpparams) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED, 'grp');
|
||||
$grouptest = "u.id IN (SELECT userid FROM {groups_members} gm WHERE gm.groupid $grouptest)";
|
||||
$params = array_merge($params, $grpparams);
|
||||
|
||||
@@ -5016,7 +5016,7 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
|
||||
/// User exceptions
|
||||
if (!empty($exceptions)) {
|
||||
$exceptions = (array)$exceptions;
|
||||
list($exsql, $exparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'exc000', false);
|
||||
list($exsql, $exparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'exc', false);
|
||||
$params = array_merge($params, $exparams);
|
||||
$wherecond[] = "u.id $exsql";
|
||||
}
|
||||
@@ -5538,7 +5538,7 @@ function user_has_role_assignment($userid, $roleid, $contextid = 0) {
|
||||
return false;
|
||||
}
|
||||
$parents = get_parent_contexts($context, true);
|
||||
list($contexts, $params) = $DB->get_in_or_equal($parents, SQL_PARAMS_NAMED, 'r0000');
|
||||
list($contexts, $params) = $DB->get_in_or_equal($parents, SQL_PARAMS_NAMED, 'r');
|
||||
$params['userid'] = $userid;
|
||||
$params['roleid'] = $roleid;
|
||||
|
||||
|
||||
+1
-1
@@ -5400,7 +5400,7 @@ class admin_setting_manageeditors extends admin_setting {
|
||||
|
||||
// settings link
|
||||
if (file_exists($CFG->dirroot.'/lib/editor/'.$editor.'/settings.php')) {
|
||||
$eurl = new moodle_url('/admin/settings.php', array('section'=>'editorsettingstinymce'));
|
||||
$eurl = new moodle_url('/admin/settings.php', array('section'=>'editorsettings'.$editor));
|
||||
$settings = "<a href='$eurl'>{$txt->settings}</a>";
|
||||
} else {
|
||||
$settings = '';
|
||||
|
||||
+2
-2
@@ -533,13 +533,13 @@ class block_manager {
|
||||
$parentcontextids = get_parent_contexts($context);
|
||||
if ($parentcontextids) {
|
||||
list($parentcontexttest, $parentcontextparams) =
|
||||
$DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext0000');
|
||||
$DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext');
|
||||
$contexttest = "($contexttest OR (bi.showinsubcontexts = 1 AND bi.parentcontextid $parentcontexttest))";
|
||||
}
|
||||
|
||||
$pagetypepatterns = matching_page_type_patterns($this->page->pagetype);
|
||||
list($pagetypepatterntest, $pagetypepatternparams) =
|
||||
$DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest0000');
|
||||
$DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest');
|
||||
|
||||
list($ccselect, $ccjoin) = context_instance_preload_sql('b.id', CONTEXT_BLOCK, 'ctx');
|
||||
|
||||
|
||||
@@ -193,7 +193,6 @@ class completion_criteria_activity extends completion_criteria {
|
||||
$sql = '
|
||||
SELECT DISTINCT
|
||||
c.id AS course,
|
||||
cr.timeend AS date,
|
||||
cr.id AS criteriaid,
|
||||
ra.userid AS userid,
|
||||
mc.timemodified AS timecompleted
|
||||
|
||||
@@ -181,7 +181,6 @@ class completion_criteria_duration extends completion_criteria {
|
||||
$sql = '
|
||||
SELECT
|
||||
c.id AS course,
|
||||
cr.timeend AS date,
|
||||
cr.id AS criteriaid,
|
||||
u.id AS userid,
|
||||
ue.timestart AS otimestart,
|
||||
|
||||
@@ -177,7 +177,6 @@ class completion_criteria_grade extends completion_criteria {
|
||||
$sql = '
|
||||
SELECT DISTINCT
|
||||
c.id AS course,
|
||||
cr.timeend AS date,
|
||||
cr.id AS criteriaid,
|
||||
ra.userid AS userid,
|
||||
gg.finalgrade AS gradefinal,
|
||||
|
||||
@@ -592,6 +592,9 @@ class completion_info {
|
||||
* Should be called whenever a module is 'viewed' (it is up to the module how to
|
||||
* determine that). Has no effect if viewing is not set as a completion condition.
|
||||
*
|
||||
* Note that this function must be called before you print the page header because
|
||||
* it is possible that the navigation block may depend on it. If you call it after
|
||||
* printing the header, it shows a developer debug warning.
|
||||
* @uses COMPLETION_VIEW_NOT_REQUIRED
|
||||
* @uses COMPLETION_VIEWED
|
||||
* @uses COMPLETION_COMPLETE
|
||||
@@ -600,6 +603,11 @@ class completion_info {
|
||||
* @return void
|
||||
*/
|
||||
public function set_module_viewed($cm, $userid=0) {
|
||||
global $PAGE;
|
||||
if ($PAGE->headerprinted) {
|
||||
debugging('set_module_viewed must be called before header is printed',
|
||||
DEBUG_DEVELOPER);
|
||||
}
|
||||
// Don't do anything if view condition is not turned on
|
||||
if ($cm->completionview == COMPLETION_VIEW_NOT_REQUIRED || !$this->is_enabled($cm)) {
|
||||
return;
|
||||
@@ -932,6 +940,8 @@ class completion_info {
|
||||
|
||||
if ($data->userid == $USER->id) {
|
||||
$SESSION->completioncache[$cm->course][$cm->id] = $data;
|
||||
$reset = 'reset';
|
||||
get_fast_modinfo($reset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', array $excepti
|
||||
$fullname = $DB->sql_fullname('u.firstname', 'u.lastname');
|
||||
|
||||
if (!empty($exceptions)) {
|
||||
list($exceptions, $params) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex0000', false);
|
||||
list($exceptions, $params) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex', false);
|
||||
$except = "AND u.id $exceptions";
|
||||
} else {
|
||||
$except = "";
|
||||
@@ -210,7 +210,7 @@ function get_users($get=true, $search='', $confirmed=false, array $exceptions=nu
|
||||
}
|
||||
|
||||
if ($exceptions) {
|
||||
list($exceptions, $eparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex0000', false);
|
||||
list($exceptions, $eparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex', false);
|
||||
$params = $params + $eparams;
|
||||
$except = " AND id $exceptions";
|
||||
}
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ function xmldb_main_install() {
|
||||
$newsite->numsections = 0;
|
||||
$newsite->category = 0;
|
||||
$newsite->format = 'site'; // Only for this course
|
||||
$newsite->timemodified = time();
|
||||
$newsite->timecreated = time();
|
||||
$newsite->timemodified = $newsite->timecreated;
|
||||
|
||||
$newsite->id = $DB->insert_record('course', $newsite);
|
||||
$SITE = get_site();
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ $functions = array(
|
||||
'classpath' => 'user/externallib.php',
|
||||
'description' => 'Get users by id.',
|
||||
'type' => 'read',
|
||||
'capabilities'=> 'moodle/user:viewdetails',
|
||||
'capabilities'=> 'moodle/user:viewalldetails',
|
||||
),
|
||||
|
||||
'moodle_user_delete_users' => array(
|
||||
|
||||
+16
-5
@@ -3037,7 +3037,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
|
||||
// add roles without archetypes, it may contain weird things, but we can not fix them
|
||||
list($narsql, $params) = $DB->get_in_or_equal(array_keys($defaults), SQL_PARAMS_NAMED, 'ar000', false);
|
||||
list($narsql, $params) = $DB->get_in_or_equal(array_keys($defaults), SQL_PARAMS_NAMED, 'ar', false);
|
||||
$sql = "SELECT DISTINCT ra.roleid, con.contextlevel
|
||||
FROM {role_assignments} ra
|
||||
JOIN {context} con ON ra.contextid = con.id
|
||||
@@ -4030,7 +4030,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
|
||||
// enabled
|
||||
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
|
||||
list($sqlenabled, $params) = $DB->get_in_or_equal($enabledplugins, SQL_PARAMS_NAMED, 'ena00');
|
||||
list($sqlenabled, $params) = $DB->get_in_or_equal($enabledplugins, SQL_PARAMS_NAMED, 'ena');
|
||||
$params['siteid'] = SITEID;
|
||||
$sql = "INSERT INTO {enrol} (enrol, status, courseid, sortorder, enrolperiod, enrolstartdate, enrolenddate, expirynotify, expirythreshold,
|
||||
notifyall, password, cost, currency, roleid, timecreated, timemodified)
|
||||
@@ -4042,7 +4042,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
WHERE c.id <> :siteid AND ra.enrol $sqlenabled";
|
||||
$processed = $DB->get_fieldset_sql("SELECT DISTINCT enrol FROM {enrol}");
|
||||
if ($processed) {
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np00', false);
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np', false);
|
||||
$params = array_merge($params, $params2);
|
||||
$sql = "$sql AND ra.enrol $sqlnotprocessed";
|
||||
}
|
||||
@@ -4060,7 +4060,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
WHERE c.id <> :siteid";
|
||||
$processed = $DB->get_fieldset_sql("SELECT DISTINCT enrol FROM {enrol}");
|
||||
if ($processed) {
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np00', false);
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np', false);
|
||||
$params = array_merge($params, $params2);
|
||||
$sql = "$sql AND ra.enrol $sqlnotprocessed";
|
||||
}
|
||||
@@ -4073,6 +4073,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
// unfortunately there may be still some leftovers
|
||||
// after reconfigured, uninstalled or borked enrol plugins,
|
||||
// unfortunately this may be a bit slow - but there should not be many of these
|
||||
upgrade_set_timeout();
|
||||
$sqlempty = $DB->sql_empty();
|
||||
$sql = "SELECT DISTINCT c.id AS courseid, ra.enrol, c.timecreated, c.timemodified
|
||||
FROM {course} c
|
||||
@@ -4083,6 +4084,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
$params = array('siteid'=>SITEID);
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($rs as $enrol) {
|
||||
upgrade_set_timeout();
|
||||
$enrol->status = 1; // better disable them
|
||||
$DB->insert_record('enrol', $enrol);
|
||||
}
|
||||
@@ -4275,6 +4277,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
WHERE c.visible = 1";
|
||||
while ($categories = $DB->get_records_sql($sql)) {
|
||||
foreach ($categories as $cat) {
|
||||
upgrade_set_timeout();
|
||||
$DB->set_field('course_categories', 'visible', 0, array('id'=>$cat->id));
|
||||
}
|
||||
}
|
||||
@@ -4310,7 +4313,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
$params = array('syscontext'=>$syscontext->id, 'participate'=>'moodle/course:participate');
|
||||
$roles = $DB->get_fieldset_sql("SELECT DISTINCT roleid FROM {role_capabilities} WHERE contextid = :syscontext AND capability = :participate AND permission = 1", $params);
|
||||
if ($roles) {
|
||||
list($sqlroles, $params) = $DB->get_in_or_equal($roles, SQL_PARAMS_NAMED, 'r00');
|
||||
list($sqlroles, $params) = $DB->get_in_or_equal($roles, SQL_PARAMS_NAMED, 'r');
|
||||
|
||||
$sql = "INSERT INTO {user_enrolments} (status, enrolid, userid, timestart, timeend, modifierid, timecreated, timemodified)
|
||||
|
||||
@@ -4568,6 +4571,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
// Update all hashes
|
||||
$rs = $DB->get_recordset('files', array());
|
||||
foreach ($rs as $file) {
|
||||
upgrade_set_timeout();
|
||||
$pathnamehash = sha1("/$file->contextid/$file->component/$file->filearea/$file->itemid".$file->filepath.$file->filename);
|
||||
$DB->set_field('files', 'pathnamehash', $pathnamehash, array('id'=>$file->id));
|
||||
}
|
||||
@@ -4894,6 +4898,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
if ($oldversion < 2010080303) {
|
||||
$rs = $DB->get_recordset_sql('SELECT i.id, i.name, r.type FROM {repository_instances} i, {repository} r WHERE i.typeid = r.id');
|
||||
foreach ($rs as $record) {
|
||||
upgrade_set_timeout();
|
||||
if ($record->name == $record->type) {
|
||||
// repository_instances was saving type name as in name field
|
||||
// which should be empty, the repository api will try to find
|
||||
@@ -5000,6 +5005,8 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
$textlib = textlib_get_instance();
|
||||
|
||||
foreach ($rs as $question) {
|
||||
// may take awhile
|
||||
upgrade_set_timeout();
|
||||
if (empty($question->image)) {
|
||||
continue;
|
||||
}
|
||||
@@ -5078,6 +5085,8 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
FROM {question_answers} qa
|
||||
JOIN {question} q ON qa.question = q.id');
|
||||
foreach ($rs as $record) {
|
||||
// may take awhile
|
||||
upgrade_set_timeout();
|
||||
// Convert question_answers.answer
|
||||
if ($record->qtype !== 'multichoice') {
|
||||
$record->answerformat = FORMAT_PLAIN;
|
||||
@@ -5116,6 +5125,8 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
if ($CFG->texteditors !== 'textarea') {
|
||||
$rs = $DB->get_recordset('question', array('questiontextformat'=>FORMAT_MOODLE));
|
||||
foreach ($rs as $record) {
|
||||
// may take awhile
|
||||
upgrade_set_timeout();
|
||||
$record->questiontext = text_to_html($record->questiontext, false, false, true);
|
||||
$record->questiontextformat = FORMAT_HTML;
|
||||
$record->generalfeedback = text_to_html($record->generalfeedback, false, false, true);
|
||||
|
||||
@@ -567,11 +567,13 @@ abstract class moodle_database {
|
||||
* Constructs IN() or = sql fragment
|
||||
* @param mixed $items single or array of values
|
||||
* @param int $type bound param type SQL_PARAMS_QM or SQL_PARAMS_NAMED
|
||||
* @param string named param placeholder start
|
||||
* @param bool true means equal, false not equal
|
||||
* @param string $prefix named parameter placeholder prefix (unique counter value is appended to each parameter name)
|
||||
* @param bool $equal true means equal, false not equal
|
||||
* @return array - $sql and $params
|
||||
*/
|
||||
public function get_in_or_equal($items, $type=SQL_PARAMS_QM, $start='param0000', $equal=true) {
|
||||
public function get_in_or_equal($items, $type=SQL_PARAMS_QM, $prefix='param', $equal=true) {
|
||||
static $counter = 1; // guarantees unique parameters in each request
|
||||
|
||||
if (is_array($items) and empty($items)) {
|
||||
throw new coding_exception('moodle_database::get_in_or_equal() does not accept empty arrays');
|
||||
}
|
||||
@@ -590,19 +592,26 @@ abstract class moodle_database {
|
||||
}
|
||||
|
||||
} else if ($type == SQL_PARAMS_NAMED) {
|
||||
if (empty($prefix)) {
|
||||
$prefix = 'param';
|
||||
}
|
||||
|
||||
if (!is_array($items)){
|
||||
$sql = $equal ? "= :$start" : "<> :$start";
|
||||
$params = array($start=>$items);
|
||||
$param = $prefix.$counter++;
|
||||
$sql = $equal ? "= :$param" : "<> :$param";
|
||||
$params = array($param=>$items);
|
||||
} else if (count($items) == 1) {
|
||||
$sql = $equal ? "= :$start" : "<> :$start";
|
||||
$param = $prefix.$counter++;
|
||||
$sql = $equal ? "= :$param" : "<> :$param";
|
||||
$item = reset($items);
|
||||
$params = array($start=>$item);
|
||||
$params = array($param=>$item);
|
||||
} else {
|
||||
$params = array();
|
||||
$sql = array();
|
||||
foreach ($items as $item) {
|
||||
$params[$start] = $item;
|
||||
$sql[] = ':'.$start++;
|
||||
$param = $prefix.$counter++;
|
||||
$params[$param] = $item;
|
||||
$sql[] = ':'.$param;
|
||||
}
|
||||
if ($equal) {
|
||||
$sql = 'IN ('.implode(',', $sql).')';
|
||||
|
||||
@@ -178,56 +178,75 @@ class dml_test extends UnitTestCase {
|
||||
|
||||
// Correct usage of multiple values
|
||||
$in_values = array('value1', 'value2', 'value3', 'value4');
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param01', true);
|
||||
$this->assertEqual("IN (:param01,:param02,:param03,:param04)", $usql);
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param', true);
|
||||
$this->assertEqual(4, count($params));
|
||||
reset($in_values);
|
||||
$ps = array();
|
||||
foreach ($params as $key => $value) {
|
||||
$this->assertEqual(current($in_values), $value);
|
||||
next($in_values);
|
||||
$ps[] = ':'.$key;
|
||||
}
|
||||
$this->assertEqual("IN (".implode(',', $ps).")", $usql);
|
||||
|
||||
// Correct usage of single values (in array)
|
||||
$in_values = array('value1');
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param01', true);
|
||||
$this->assertEqual("= :param01", $usql);
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param', true);
|
||||
$this->assertEqual(1, count($params));
|
||||
$this->assertEqual($in_values[0], $params['param01']);
|
||||
$value = reset($params);
|
||||
$key = key($params);
|
||||
$this->assertEqual("= :$key", $usql);
|
||||
$this->assertEqual($in_value, $value);
|
||||
|
||||
// Correct usage of single value
|
||||
$in_value = 'value1';
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param01', true);
|
||||
$this->assertEqual("= :param01", $usql);
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param', true);
|
||||
$this->assertEqual(1, count($params));
|
||||
$this->assertEqual($in_value, $params['param01']);
|
||||
$value = reset($params);
|
||||
$key = key($params);
|
||||
$this->assertEqual("= :$key", $usql);
|
||||
$this->assertEqual($in_value, $value);
|
||||
|
||||
// SQL_PARAMS_NAMED - NOT IN or <>
|
||||
|
||||
// Correct usage of multiple values
|
||||
$in_values = array('value1', 'value2', 'value3', 'value4');
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param01', false);
|
||||
$this->assertEqual("NOT IN (:param01,:param02,:param03,:param04)", $usql);
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param', false);
|
||||
$this->assertEqual(4, count($params));
|
||||
reset($in_values);
|
||||
$ps = array();
|
||||
foreach ($params as $key => $value) {
|
||||
$this->assertEqual(current($in_values), $value);
|
||||
next($in_values);
|
||||
$ps[] = ':'.$key;
|
||||
}
|
||||
$this->assertEqual("NOT IN (".implode(',', $ps).")", $usql);
|
||||
|
||||
// Correct usage of single values (in array)
|
||||
$in_values = array('value1');
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param01', false);
|
||||
$this->assertEqual("<> :param01", $usql);
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param', false);
|
||||
$this->assertEqual(1, count($params));
|
||||
$this->assertEqual($in_values[0], $params['param01']);
|
||||
$value = reset($params);
|
||||
$key = key($params);
|
||||
$this->assertEqual("<> :$key", $usql);
|
||||
$this->assertEqual($in_value, $value);
|
||||
|
||||
// Correct usage of single value
|
||||
$in_value = 'value1';
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param01', false);
|
||||
$this->assertEqual("<> :param01", $usql);
|
||||
list($usql, $params) = $DB->get_in_or_equal($in_values, SQL_PARAMS_NAMED, 'param', false);
|
||||
$this->assertEqual(1, count($params));
|
||||
$this->assertEqual($in_value, $params['param01']);
|
||||
$value = reset($params);
|
||||
$key = key($params);
|
||||
$this->assertEqual("<> :$key", $usql);
|
||||
$this->assertEqual($in_value, $value);
|
||||
|
||||
// make sure the param names are unique
|
||||
list($usql1, $params1) = $DB->get_in_or_equal(array(1,2,3), SQL_PARAMS_NAMED, 'param');
|
||||
list($usql2, $params2) = $DB->get_in_or_equal(array(1,2,3), SQL_PARAMS_NAMED, 'param');
|
||||
$params1 = array_keys($params1);
|
||||
$params2 = array_keys($params2);
|
||||
$common = array_intersect($params1, $params2);
|
||||
$this->assertEqual(count($common), 0);
|
||||
}
|
||||
|
||||
public function test_fix_table_names() {
|
||||
|
||||
+1
-1
@@ -244,7 +244,7 @@ function enrol_sharing_course($user1, $user2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($plugins, $params) = $DB->get_in_or_equal($plugins, SQL_PARAMS_NAMED, 'ee00');
|
||||
list($plugins, $params) = $DB->get_in_or_equal($plugins, SQL_PARAMS_NAMED, 'ee');
|
||||
$params['enabled'] = ENROL_INSTANCE_ENABLED;
|
||||
$params['active1'] = ENROL_USER_ACTIVE;
|
||||
$params['active2'] = ENROL_USER_ACTIVE;
|
||||
|
||||
+39
-7
@@ -904,7 +904,6 @@ function format_postdata_for_curlcall($postdata) {
|
||||
* Fetches content of file from Internet (using proxy if defined). Uses cURL extension if present.
|
||||
* Due to security concerns only downloads from http(s) sources are supported.
|
||||
*
|
||||
* @global object
|
||||
* @param string $url file url starting with http(s)://
|
||||
* @param array $headers http headers, null if none. If set, should be an
|
||||
* associative array of header name => value pairs.
|
||||
@@ -916,11 +915,14 @@ function format_postdata_for_curlcall($postdata) {
|
||||
* @param int $connecttimeout timeout for connection to server; this is the timeout that
|
||||
* usually happens if the remote server is completely down (default 20 seconds);
|
||||
* may not work when using proxy
|
||||
* @param bool $skipcertverify If true, the peer's SSL certificate will not be checked. Only use this when already in a trusted location.
|
||||
* @param string $tofile store the downloaded content to file instead of returning it
|
||||
* @return mixed false if request failed or content of the file as string if ok. true if file downloaded into $tofile successfully.
|
||||
* @param bool $skipcertverify If true, the peer's SSL certificate will not be checked.
|
||||
* Only use this when already in a trusted location.
|
||||
* @param string $tofile store the downloaded content to file instead of returning it.
|
||||
* @param bool $calctimeout false by default, true enables an extra head request to try and determine
|
||||
* filesize and appropriately larger timeout based on $CFG->curltimeoutkbitrate
|
||||
* @return mixed false if request failed or content of the file as string if ok. True if file downloaded into $tofile successfully.
|
||||
*/
|
||||
function download_file_content($url, $headers=null, $postdata=null, $fullresponse=false, $timeout=300, $connecttimeout=20, $skipcertverify=false, $tofile=NULL) {
|
||||
function download_file_content($url, $headers=null, $postdata=null, $fullresponse=false, $timeout=300, $connecttimeout=20, $skipcertverify=false, $tofile=NULL, $calctimeout=false) {
|
||||
global $CFG;
|
||||
|
||||
// some extra security
|
||||
@@ -962,7 +964,6 @@ function download_file_content($url, $headers=null, $postdata=null, $fullrespons
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers2);
|
||||
}
|
||||
|
||||
|
||||
if ($skipcertverify) {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
}
|
||||
@@ -977,7 +978,7 @@ function download_file_content($url, $headers=null, $postdata=null, $fullrespons
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connecttimeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
|
||||
if (!ini_get('open_basedir') and !ini_get('safe_mode')) {
|
||||
// TODO: add version test for '7.10.5'
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
@@ -1033,6 +1034,37 @@ function download_file_content($url, $headers=null, $postdata=null, $fullrespons
|
||||
curl_setopt($ch, CURLOPT_WRITEFUNCTION, partial('download_file_content_write_handler', $received));
|
||||
}
|
||||
|
||||
if (!isset($CFG->curltimeoutkbitrate)) {
|
||||
//use very slow rate of 56kbps as a timeout speed when not set
|
||||
$bitrate = 56;
|
||||
} else {
|
||||
$bitrate = $CFG->curltimeoutkbitrate;
|
||||
}
|
||||
|
||||
// try to calculate the proper amount for timeout from remote file size.
|
||||
// if disabled or zero, we won't do any checks nor head requests.
|
||||
if ($calctimeout && $bitrate > 0) {
|
||||
//setup header request only options
|
||||
curl_setopt_array ($ch, array(
|
||||
CURLOPT_RETURNTRANSFER => false,
|
||||
CURLOPT_NOBODY => true)
|
||||
);
|
||||
|
||||
curl_exec($ch);
|
||||
$info = curl_getinfo($ch);
|
||||
$err = curl_error($ch);
|
||||
|
||||
if ($err === '' && $info['download_content_length'] > 0) { //no curl errors
|
||||
$timeout = max($timeout, ceil($info['download_content_length'] * 8 / ($bitrate * 1024))); //adjust for large files only - take max timeout.
|
||||
}
|
||||
//reinstate affected curl options
|
||||
curl_setopt_array ($ch, array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_NOBODY => false)
|
||||
);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
// try to detect encoding problems
|
||||
|
||||
@@ -702,6 +702,7 @@ class file_storage {
|
||||
$timeout = isset($options['timeout']) ? $options['timeout'] : 300;
|
||||
$connecttimeout = isset($options['connecttimeout']) ? $options['connecttimeout'] : 20;
|
||||
$skipcertverify = isset($options['skipcertverify']) ? $options['skipcertverify'] : false;
|
||||
$calctimeout = isset($options['calctimeout']) ? $options['calctimeout'] : false;
|
||||
|
||||
if (!isset($file_record->filename)) {
|
||||
$parts = explode('/', $url);
|
||||
@@ -714,7 +715,7 @@ class file_storage {
|
||||
if ($usetempfile) {
|
||||
check_dir_exists($this->tempdir);
|
||||
$tmpfile = tempnam($this->tempdir, 'newfromurl');
|
||||
$content = download_file_content($url, $headers, $postdata, $fullresponse, $timeout, $connecttimeout, $skipcertverify, $tmpfile);
|
||||
$content = download_file_content($url, $headers, $postdata, $fullresponse, $timeout, $connecttimeout, $skipcertverify, $tmpfile, $calctimeout);
|
||||
if ($content === false) {
|
||||
throw new file_exception('storedfileproblem', 'Can not fetch file form URL');
|
||||
}
|
||||
@@ -728,7 +729,7 @@ class file_storage {
|
||||
}
|
||||
|
||||
} else {
|
||||
$content = download_file_content($url, $headers, $postdata, $fullresponse, $timeout, $connecttimeout, $skipcertverify);
|
||||
$content = download_file_content($url, $headers, $postdata, $fullresponse, $timeout, $connecttimeout, $skipcertverify, NULL, $calctimeout);
|
||||
if ($content === false) {
|
||||
throw new file_exception('storedfileproblem', 'Can not fetch file form URL');
|
||||
}
|
||||
|
||||
@@ -166,7 +166,9 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group
|
||||
}
|
||||
break;
|
||||
case 'createElement':
|
||||
if($arg[2]['optional']) {
|
||||
// Optional is an optional param, if its set we need to add a disabledIf rule.
|
||||
// If its empty or not specified then its not an optional dateselector.
|
||||
if (!empty($arg[2]['optional']) && !empty($arg[0])) {
|
||||
$caller->disabledIf($arg[0], $arg[0].'[enabled]');
|
||||
}
|
||||
return parent::onQuickFormEvent($event, $arg, $caller);
|
||||
|
||||
@@ -595,7 +595,11 @@ M.form_filemanager.init = function(Y, options) {
|
||||
scope: scope,
|
||||
params: params,
|
||||
callback: function(id, obj, args) {
|
||||
scope.refresh(obj.filepath);
|
||||
if (obj == false) {
|
||||
alert(M.str.repository.fileexists);
|
||||
} else {
|
||||
scope.refresh(obj.filepath);
|
||||
}
|
||||
Y.one('#fm-rename-input').set('value', '');
|
||||
scope.rename_dialog.hide();
|
||||
}
|
||||
@@ -636,7 +640,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
dialog = Y.one('#fm-move-dlg');
|
||||
}
|
||||
|
||||
dialog.set('innerHTML', '<div class="hd">Moving</div><div class="bd"><div id="fm-move-div">'+M.str.repository.nopathselected+'</div><div id="fm-tree"></div></div>');
|
||||
dialog.set('innerHTML', '<div class="hd">'+M.str.repository.moving+'</div><div class="bd"><div id="fm-move-div">'+M.str.repository.nopathselected+'</div><div id="fm-tree"></div></div>');
|
||||
|
||||
this.movefile_dialog = new YAHOO.widget.Dialog("fm-move-dlg", {
|
||||
width : "600px",
|
||||
@@ -717,7 +721,7 @@ M.form_filemanager.init = function(Y, options) {
|
||||
var rootNode = treeview.getRoot();
|
||||
treeview.setDynamicLoad(loadDataForNode);
|
||||
treeview.removeChildren(rootNode);
|
||||
var textnode = {label: "Files", path: '/'};
|
||||
var textnode = {label: M.str.moodle.files, path: '/'};
|
||||
var tmpNode = new YAHOO.widget.TextNode(textnode, rootNode, true);
|
||||
treeview.draw();
|
||||
}, this, true);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user