// Disable/off/on
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter));
+ $select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
$row[] = $OUTPUT->render($select);
// Re-order
// Apply to strings.
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter));
+ $select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
$row[] = $OUTPUT->render($select);
if (!empty($formerror['username'])) {
echo '<span class="error"> * </span>';
}
-echo '<input type="text" name="username" size="20" maxlength="100" />';
+echo html_writer::label(get_string('username'), 'menuusername', false, array('class' => 'accesshide'));
+echo '<input id="menuusername" type="text" name="username" size="20" maxlength="100" />';
// choose a remote host
-echo " " . get_string('remotehost', 'mnet') . ":\n";
+echo " " . html_writer::label(get_string('remotehost', 'mnet'), 'menumnet_host_id') . ":\n";
if (!empty($formerror['mnet_host_id'])) {
echo '<span class="error"> * </span>';
}
echo html_writer::select($mnethosts, 'mnet_host_id');
// choose an access level
-echo " " . get_string('accesslevel', 'mnet') . ":\n";
+echo " " . html_writer::label(get_string('accesslevel', 'mnet'), 'menuaccessctrl') . ":\n";
if (!empty($formerror['accessctrl'])) {
echo '<span class="error"> * </span>';
}
$currentaction = 'hide';
}
$select = new single_select(portfolio_action_url($pluginid, 'pf'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . $pluginid);
+ $select->set_label(get_string('action'), array('class' => 'accesshide'));
$table->data[] = array($pluginname, $OUTPUT->render($select), $settings);
}
if (!in_array($plugin, $usedplugins)) {
$insaneplugins[] = $p;
} else {
$select = new single_select(portfolio_action_url($p, 'pf'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . $p);
+ $select->set_label(get_string('action'), array('class' => 'accesshide'));
$table->data[] = array(portfolio_static_function($p, 'get_name'), $OUTPUT->render($select), '');
}
}
}
$select = new single_select(repository_action_url($typename, 'repos'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . basename($typename));
-
+ $select->set_label(get_string('action'), array('class' => 'accesshide'));
// Display up/down link
$updown = '';
$spacer = $OUTPUT->spacer(array('height'=>15, 'width'=>15)); // should be done with CSS instead
// Check that it has not already been listed
if (!in_array($plugin, $alreadyplugins)) {
$select = new single_select(repository_action_url($plugin, 'repos'), 'action', $actionchoicesfornew, 'delete', null, 'applyto' . basename($plugin));
+ $select->set_label(get_string('action'), array('class' => 'accesshide'));
$table->data[] = array(get_string('pluginname', 'repository_'.$plugin), $OUTPUT->render($select), '', '');
}
}
$timezones = get_list_of_timezones();
echo '<center><form action="timezone.php" method="post">';
- echo "$strusers ($strall): ";
+ echo html_writer::label($strusers . ' (' . $strall . '): ', 'menuzone');
echo html_writer::select($timezones, "zone", $current, array('99'=>get_string("serverlocaltime")));
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
echo '<input type="submit" value="'.s($strsavechanges).'" />';
echo html_writer::start_tag('td', array('valign' => 'top'));
echo html_writer::start_tag('form', array('id' => 'uninstallform', 'action' => $url->out(), 'method' => 'post'));
echo html_writer::start_tag('fieldset');
-echo html_writer::label(get_string('installedlangs', 'tool_langimport'), 'uninstalllang');
+echo html_writer::label(get_string('installedlangs', 'tool_langimport'), 'menuuninstalllang');
echo html_writer::empty_tag('br');
echo html_writer::select($installedlangs, 'uninstalllang', '', false, array('size' => 15));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
$url = new moodle_url('/admin/tool/langimport/index.php', array('mode' => INSTALLATION_OF_SELECTED_LANG));
echo html_writer::start_tag('form', array('id' => 'installform', 'action' => $url->out(), 'method' => 'post'));
echo html_writer::start_tag('fieldset');
- echo html_writer::label(get_string('availablelangs','install'), 'pack');
+ echo html_writer::label(get_string('availablelangs','install'), 'menupack');
echo html_writer::empty_tag('br');
echo html_writer::select($options, 'pack[]', '', false, array('size' => 15, 'multiple' => 'multiple'));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
<form method="post" action="index.php">
<div>
+ <label class="accesshide" for="keyword_el"><?php print_string('spamkeyword', 'tool_spamcleaner') ?></label>
<input type="text" name="keyword" id="keyword_el" value="<?php p($keyword) ?>" />
<input type="hidden" name="sesskey" value="<?php echo sesskey();?>" />
<input type="submit" value="<?php echo get_string('spamsearch', 'tool_spamcleaner')?>" />
$string['spamfrommessages'] = 'From messages:';
$string['spamfromforumpost'] = 'From forum post:';
$string['spaminvalidresult'] = 'Unknown but invalid result';
+$string['spamkeyword'] = 'Keyword';
$string['spamoperation'] = 'Operation';
$string['spamresult'] = 'Results of searching user profiles containing:';
$string['spamsearch'] = 'Search for these keywords';
$o.= ' <input type="hidden" name ="postaction" value="edit_table" />';
$o.= ' <input type="hidden" name ="sesskey" value="' . sesskey() . '" />';
$o.= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
- $o.= ' <tr><td><label for="table" accesskey="t">' . $this->str['createtable'] .' </label>' . html_writer::select($selecttables, 'table') . '<label for="after" accesskey="a">' . $this->str['aftertable'] . ' </label>' .html_writer::select($aftertables, 'after') . '</td></tr>';
+ $o.= ' <tr><td><label for="menutable" accesskey="t">' . $this->str['createtable'] .' </label>' . html_writer::select($selecttables, 'table') . '<label for="menuafter" accesskey="a">' . $this->str['aftertable'] . ' </label>' .html_writer::select($aftertables, 'after') . '</td></tr>';
$o.= ' <tr><td colspan="2" align="center"><input type="submit" value="' .$this->str['create'] . '" /></td></tr>';
$o.= ' <tr><td colspan="2" align="center"><a href="index.php?action=edit_xml_file&dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a></td></tr>';
$o.= ' </table>';
$o.= ' <input type="hidden" name ="dir" value="' . str_replace($CFG->dirroot, '', $dirpath) . '" />';
$o.= ' <input type="hidden" name ="action" value="view_structure_php" />';
$o.= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
- $o.= ' <tr><td><label for="action" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="table" accesskey="t">' . $this->str['selecttable'] . ' </label>' .html_writer::select($poptables, 'table', $tableparam, false) . '</td></tr>';
+ $o.= ' <tr><td><label for="menucommand" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="menutable" accesskey="t">' . $this->str['selecttable'] . ' </label>' .html_writer::select($poptables, 'table', $tableparam, false) . '</td></tr>';
$o.= ' <tr><td colspan="2" align="center"><input type="submit" value="' .$this->str['view'] . '" /></td></tr>';
$o.= ' </table>';
$o.= '</div></form>';
$o.= ' <input type="hidden" name ="table" value="' . s($tableparam) . '" />';
$o.= ' <input type="hidden" name ="action" value="view_table_php" />';
$o.= ' <table id="formelements" class="boxaligncenter" cellpadding="5">';
- $o.= ' <tr><td><label for="action" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="fieldkeyindex" accesskey="f">' . $this->str['selectfieldkeyindex'] . ' </label>' .html_writer::select($popfields, 'fieldkeyindex', $origfieldkeyindexparam, false) . '</td></tr>';
+ $o.= ' <tr><td><label for="menucommand" accesskey="c">' . $this->str['selectaction'] .' </label>' . html_writer::select($popcommands, 'command', $commandparam, false) . ' <label for="menufieldkeyindex" accesskey="f">' . $this->str['selectfieldkeyindex'] . ' </label>' .html_writer::select($popfields, 'fieldkeyindex', $origfieldkeyindexparam, false) . '</td></tr>';
$o.= ' <tr><td colspan="2" align="center"><input type="submit" value="' .$this->str['view'] . '" /></td></tr>';
$o.= ' </table>';
$o.= '</div></form>';
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_cas_hostname_key', 'auth_cas') ?>:</td>
+ <td align="right"><label for="hostname"><?php print_string('auth_cas_hostname_key', 'auth_cas') ?>: </label></td>
<td>
- <input name="hostname" type="text" size="30" value="<?php echo $config->hostname ?>" />
+ <input name="hostname" id="hostname" type="text" size="30" value="<?php echo $config->hostname ?>" />
<?php if (isset($err['hostname'])) { echo $OUTPUT->error_text($err['hostname']); } ?>
</td>
<td>
</tr>
<tr valign="top" class="required">
<td align="right">
- <?php print_string('auth_cas_baseuri_key', 'auth_cas') ?>:
+ <label for="baseuri"><?php print_string('auth_cas_baseuri_key', 'auth_cas') ?>: </label>
</td>
<td>
- <input name="baseuri" type="text" size="30" value="<?php echo $config->baseuri ?>" />
+ <input name="baseuri" id="baseuri" type="text" size="30" value="<?php echo $config->baseuri ?>" />
<?php if (isset($err['baseuri'])) { echo $OUTPUT->error_text($err['baseuri']); } ?>
</td>
<td>
</tr>
<tr valign="top" class="required">
<td align="right">
- <?php print_string('auth_cas_port_key', 'auth_cas') ?>:
+ <label for="port"><?php print_string('auth_cas_port_key', 'auth_cas') ?>: </label>
</td>
<td>
- <input name="port" type="text" size="30" value="<?php echo $config->port ?>" />
+ <input name="port" id="port" type="text" size="30" value="<?php echo $config->port ?>" />
<?php if (isset($err['port'])) { echo $OUTPUT->error_text($err['port']); } ?>
</td>
<td>
</tr>
<tr valign="top" class="required">
<td align="right">
- <?php print_string('auth_cas_casversion', 'auth_cas') ?>:
+ <?php echo html_writer::label(get_string('auth_cas_casversion', 'auth_cas'), 'menucasversion'); ?>:
</td>
<td>
<?php
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_cas_language_key', 'auth_cas') ?>:</td>
+ <td align="right"><?php echo html_writer::label(get_string('auth_cas_language_key', 'auth_cas'), 'menulanguage'); ?>:</td>
<td>
<?php echo html_writer::select($CASLANGUAGES, 'language', $config->language, false); ?>
</td>
</tr>
<tr valign="top" class="required">
<td align="right">
- <?php print_string('auth_cas_proxycas_key', 'auth_cas') ?>:
+ <?php echo html_writer::label(get_string('auth_cas_proxycas_key', 'auth_cas'), 'menuproxycas'); ?>:
</td>
<td>
<?php echo html_writer::select($yesno, 'proxycas', $config->proxycas, false); ?>
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_cas_logoutcas_key', 'auth_cas') ?>:</td>
+ <td align="right"><?php echo html_writer::label(get_string('auth_cas_logoutcas_key', 'auth_cas'), 'menulogoutcas'); ?>:</td>
<td>
<?php echo html_writer::select($yesno, 'logoutcas', $config->logoutcas, false); ?>
</td>
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_cas_multiauth_key', 'auth_cas') ?>:</td>
+ <td align="right"><?php echo html_writer::label(get_string('auth_cas_multiauth_key', 'auth_cas'), 'menumultiauth'); ?>:</td>
<td>
<?php echo html_writer::select($yesno, 'multiauth', $config->multiauth, false); ?>
</td>
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_cas_certificate_check_key', 'auth_cas') ?>:</td>
+ <td align="right"><?php echo html_writer::label(get_string('auth_cas_certificate_check_key', 'auth_cas'), 'menucertificate_check'); ?>:</td>
<td>
<?php echo html_writer::select($yesno, 'certificate_check', $config->certificate_check, false); ?>
</td>
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_cas_certificate_path_key', 'auth_cas') ?>:</td>
+ <td align="right"><label for="certificate_path"><?php print_string('auth_cas_certificate_path_key', 'auth_cas') ?>: </label></td>
<td>
<input name="certificate_path" id="certificate_path" type="text" size="30" value="<?php echo $config->certificate_path ?>" />
<?php if (isset($err['certificate_path'])) echo $OUTPUT->error_text($err['certificate_path']); ?>
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><label for="menuversion"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label></td>
+ <td align="right"><label for="menuldap_version"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label></td>
<td>
<?php
$versions = array();
<table cellspacing="0" cellpadding="5" border="0">
<tr valign="top" class="required">
- <td align="right"><?php print_string("auth_fchost_key", "auth_fc") ?>:</td>
+ <td align="right"><label for="host"><?php print_string("auth_fchost_key", "auth_fc") ?>:</label></td>
<td>
- <input name="host" type="text" size="30" value="<?php echo $config->host?>" />
+ <input name="host" id="host" type="text" size="30" value="<?php echo $config->host?>" />
<?php if (isset($err["host"])) echo $OUTPUT->error_text($err["host"]); ?>
</td>
<td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string("auth_fcfppport_key", "auth_fc") ?>:</td>
+ <td align="right"><label for="fppport"><?php print_string("auth_fcfppport_key", "auth_fc") ?>: </label></td>
<td>
- <input name="fppport" type="text" size="30" value="<?php echo $config->fppport?>" />
+ <input name="fppport" id="fppport" type="text" size="30" value="<?php echo $config->fppport?>" />
<?php if (isset($err["fppport"])) echo $OUTPUT->error_text($err["host"]); ?>
</td>
<td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string("auth_fcuserid_key", "auth_fc") ?>:</td>
+ <td align="right"><label for="userid"><?php print_string("auth_fcuserid_key", "auth_fc") ?>:</label></td>
<td>
- <input name="userid" type="text" size="30" maxlength="15" value="<?php echo $config->userid?>" />
+ <input name="userid" id="userid" type="text" size="30" maxlength="15" value="<?php echo $config->userid?>" />
<?php if (isset($err["userid"])) echo $OUTPUT->error_text($err["userid"]); ?>
</td>
<td>
</td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string("auth_fcpasswd_key", "auth_fc") ?>:</td>
+ <td align="right"><label for="passwd"><?php print_string("auth_fcpasswd_key", "auth_fc") ?>:</label></td>
<td>
- <input name="passwd" type="password" size="30" maxlength="12" value="<?php echo $config->passwd?>" />
+ <input name="passwd" id="passwd" type="password" size="30" maxlength="12" value="<?php echo $config->passwd?>" />
<?php if (isset($err["passwd"])) echo $OUTPUT->error_text($err["passwd"]); ?>
</td>
<td>
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string("auth_fccreators_key", "auth_fc") ?>:</td>
+ <td align="right"><label for="creators"><?php print_string("auth_fccreators_key", "auth_fc") ?>: </label></td>
<td>
- <input name="creators" type="text" size="30" value="<?php echo $config->creators?>" />
+ <input name="creators" id="creators" type="text" size="30" value="<?php echo $config->creators?>" />
<?php if (isset($err["creators"])) echo $OUTPUT->error_text($err["creators"]); ?>
</td>
<td>
</tr>
<tr valign="top">
- <td align="right"><?php print_string('auth_fcchangepasswordurl', 'auth_fc') ?>: </td>
+ <td align="right"><label for="changepasswordurl"><?php print_string('auth_fcchangepasswordurl', 'auth_fc') ?>: </label></td>
<td>
- <input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
+ <input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
<?php
if (isset($err['changepasswordurl'])) {
<table cellspacing="0" cellpadding="5" border="0">
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_imaphost_key', 'auth_imap') ?>: </td>
+ <td align="right"><label for="host"><?php print_string('auth_imaphost_key', 'auth_imap') ?>: </label></td>
<td>
- <input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
+ <input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
<?php
if (isset($err['host'])) {
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_imaptype_key', 'auth_imap') ?>: </td>
+ <td align="right"><?php echo html_writer::label(get_string('auth_imaptype_key', 'auth_imap'), 'menutype'); ?>: </td>
<td>
<?php
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_imapport_key', 'auth_imap') ?>: </td>
+ <td align="right"><label for="port"><?php print_string('auth_imapport_key', 'auth_imap') ?>: </label></td>
<td>
- <input name="port" type="text" size="6" value="<?php echo $config->port ?>" />
+ <input name="port" id="port" type="text" size="6" value="<?php echo $config->port ?>" />
<?php
if (isset($err['port'])) {
</tr>
<tr valign="top">
- <td align="right"><?php print_string('auth_imapchangepasswordurl_key', 'auth_imap') ?>: </td>
+ <td align="right"><label for="changepasswordurl"><?php print_string('auth_imapchangepasswordurl_key', 'auth_imap') ?>: </label></td>
<td>
- <input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
+ <input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
<?php
if (isset($err['changepasswordurl'])) {
</tr>
<tr valign="top" class="required">
<td align="right">
- <label for="menuversion"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label>
+ <label for="menuldap_version"><?php print_string('auth_ldap_version_key', 'auth_ldap') ?></label>
</td>
<td>
<?php
<table cellspacing="0" cellpadding="5">
<tr valign="top" class="required">
- <td align="right"><?php print_string('rpc_negotiation_timeout', 'auth_mnet'); ?>: </td>
+ <td align="right"><label for="rpc_negotiation_timeout"><?php print_string('rpc_negotiation_timeout', 'auth_mnet'); ?>: </label></td>
<td>
- <input name="rpc_negotiation_timeout" type="text" size="5" value="<?php echo $config->rpc_negotiation_timeout ?>" />
+ <input name="rpc_negotiation_timeout" id="rpc_negotiation_timeout" type="text" size="5" value="<?php echo $config->rpc_negotiation_timeout ?>" />
<?php
if (isset($err['rpc_negotiation_timeout'])) {
<?php /*
See MDL-21327 for why this is commented out
<tr valign="top" class="required">
- <td align="right"><?php print_string('auto_add_remote_users', 'auth_mnet'); ?>: </td>
+ <td align="right"><?php echo html_writer::label(get_string('auto_add_remote_users', 'auth_mnet'), 'menuauto_add_remote_users'); ?>: </td>
<td>
<?php
<table cellspacing="0" cellpadding="5" border="0">
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_nntphost_key', 'auth_nntp') ?>: </td>
+ <td align="right"><label for="host"><?php print_string('auth_nntphost_key', 'auth_nntp') ?>: </label></td>
<td>
- <input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
+ <input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
<?php
if (isset($err["host"])) {
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_nntpport_key', 'auth_nntp') ?>: </td>
+ <td align="right"><label for="port"><?php print_string('auth_nntpport_key', 'auth_nntp') ?>: </label></td>
<td>
- <input name="port" type="text" size="6" value="<?php echo $config->port ?>" />
+ <input name="port" id="port" type="text" size="6" value="<?php echo $config->port ?>" />
<?php
if (isset($err["port"])) {
</tr>
<tr valign="top">
- <td align="right"><?php print_string('auth_nntpchangepasswordurl_key', 'auth_nntp') ?>: </td>
+ <td align="right"><label for="changepasswordurl"><?php print_string('auth_nntpchangepasswordurl_key', 'auth_nntp') ?>: </label></td>
<td>
- <input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
+ <input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
<?php
if (isset($err['changepasswordurl'])) {
<table cellspacing="0" cellpadding="5" border="0">
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_pop3host_key', 'auth_pop3') ?>: </td>
+ <td align="right"><label for="host"><?php print_string('auth_pop3host_key', 'auth_pop3') ?>: </label></td>
<td>
- <input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
+ <input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
<?php
if (isset($err['host'])) {
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_pop3type_key', 'auth_pop3') ?>: </td>
+ <td align="right"><?php echo html_writer::label(get_string('auth_pop3type_key', 'auth_pop3'), 'menutype'); ?>: </td>
<td>
<?php
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_pop3port_key', 'auth_pop3') ?>: </td>
+ <td align="right"><label for="port"><?php print_string('auth_pop3port_key', 'auth_pop3') ?>: </label></td>
<td>
- <input name="port" type="text" size="6" value="<?php echo $config->port ?>" />
+ <input name="port" id="port" type="text" size="6" value="<?php echo $config->port ?>" />
<?php
if (isset($err['port'])) {
</tr>
<tr valign="top" class="required">
- <td align="right"><?php print_string('auth_pop3mailbox_key', 'auth_pop3') ?>: </td>
+ <td align="right"><label for="mailbox"><?php print_string('auth_pop3mailbox_key', 'auth_pop3') ?>: </label></td>
<td>
- <input name="mailbox" type="text" size="6" value="<?php echo $config->mailbox ?>" />
+ <input name="mailbox" id="mailbox" type="text" size="6" value="<?php echo $config->mailbox ?>" />
<?php
if (isset($err['mailbox'])) {
</tr>
<tr valign="top">
- <td align="right"><?php print_string('auth_pop3changepasswordurl_key', 'auth_pop3') ?>: </td>
+ <td align="right"><label for="changepasswordurl"><?php print_string('auth_pop3changepasswordurl_key', 'auth_pop3') ?>: </label></td>
<td>
- <input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
+ <input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
<?php
if (isset($err['changepasswordurl'])) {
<table cellspacing="0" cellpadding="5" border="0">
<tr valign="top">
- <td align="right"><?php print_string('auth_radiushost_key', 'auth_radius') ?>: </td>
+ <td align="right"><label for="host"><?php print_string('auth_radiushost_key', 'auth_radius') ?>: </label></td>
<td>
- <input name="host" type="text" size="30" value="<?php echo $config->host ?>" />
+ <input name="host" id="host" type="text" size="30" value="<?php echo $config->host ?>" />
<?php
if (isset($err['host'])) {
</tr>
<tr valign="top">
- <td align="right"><?php print_string('auth_radiusnasport_key', 'auth_radius') ?>: </td>
+ <td align="right"><label for="nasport"><?php print_string('auth_radiusnasport_key', 'auth_radius') ?>: </label></td>
<td>
- <input name="nasport" type="text" size="6" value="<?php echo $config->nasport ?>" />
+ <input name="nasport" id="nasport" type="text" size="6" value="<?php echo $config->nasport ?>" />
<?php
if (isset($err['nasport'])) {
</tr>
<tr valign="top" >
- <td align="right"><?php print_string('auth_radiustype_key', 'auth_radius') ?>: </td>
+ <td align="right"><?php echo html_writer::label(get_string('auth_radiustype_key', 'auth_radius'), 'menuradiustype'); ?>: </td>
<td>
<?php
<tr valign="top" >
- <td align="right"><?php print_string('auth_radiussecret_key', 'auth_radius') ?>: </td>
+ <td align="right"><label for="secret"><?php print_string('auth_radiussecret_key', 'auth_radius') ?>: </label></td>
<td>
- <input name="secret" type="text" size="6" value="<?php echo $config->secret ?>" />
+ <input name="secret" id="secret" type="text" size="6" value="<?php echo $config->secret ?>" />
<?php
if (isset($err['secret'])) {
</tr>
<tr valign="top">
- <td align="right"><?php print_string('auth_radiuschangepasswordurl_key', 'auth_radius') ?>: </td>
+ <td align="right"><label for="changepasswordurl"><?php print_string('auth_radiuschangepasswordurl_key', 'auth_radius') ?>: </label></td>
<td>
- <input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
+ <input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
<?php
if (isset($err['changepasswordurl'])) {
<table cellspacing="0" cellpadding="5" border="0">
<tr valign="top" class="required">
- <td align="right"><?php print_string("username") ?>:</td>
+ <td align="right"><label for="user_attribute"><?php print_string("username") ?>: </label></td>
<td>
- <input name="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute ?>" />
+ <input id="user_attribute" name="user_attribute" type="text" size="30" value="<?php echo $config->user_attribute ?>" />
</td>
<td><?php print_string("auth_shib_username_description", "auth_shibboleth") ?></td>
</tr>
<tr valign="top">
- <td align="right"><?php print_string("auth_shib_convert_data", "auth_shibboleth") ?>:</td>
+ <td align="right"><label for="convert_data"><?php print_string("auth_shib_convert_data", "auth_shibboleth") ?>: </label></td>
<td>
- <input name="convert_data" type="text" size="30" value="<?php echo $config->convert_data?>" />
+ <input name="convert_data" id="convert_data" type="text" size="30" value="<?php echo $config->convert_data?>" />
<?php
if ($config->convert_data and $config->convert_data != '' and !is_readable($config->convert_data)) {
</tr>
<tr valign="top">
- <td align="right"><?php print_string("auth_shib_logout_url", "auth_shibboleth") ?>:</td>
+ <td align="right"><label for="logout_handler"><?php print_string("auth_shib_logout_url", "auth_shibboleth") ?>: </label></td>
<td>
- <input name="logout_handler" type="text" size="30" value="<?php
+ <input name="logout_handler" id="logout_handler" type="text" size="30" value="<?php
if ( isset($config->logout_handler) and !empty($config->logout_handler)){
echo $config->logout_handler;
}
</tr>
<tr valign="top">
- <td align="right"><?php print_string("auth_shib_logout_return_url", "auth_shibboleth") ?>:</td>
+ <td align="right"><label for="logout_return_url"><?php print_string("auth_shib_logout_return_url", "auth_shibboleth") ?>: </label></td>
<td>
- <input name="logout_return_url" type="text" size="30" value="<?php
+ <input name="logout_return_url" id="logout_return_url" type="text" size="30" value="<?php
if ( isset($config->logout_return_url) and !empty($config->logout_return_url)){
echo $config->logout_return_url;
}
</tr>
<tr valign="top">
- <td align="right"><?php print_string("auth_shib_auth_method", "auth_shibboleth") ?>:</td>
+ <td align="right"><label for="login_name"><?php print_string("auth_shib_auth_method", "auth_shibboleth") ?>: </label></td>
<td>
- <input name="login_name" type="text" size="30" value="<?php
+ <input name="login_name" id="login_name" type="text" size="30" value="<?php
if ( isset($config->login_name) and !empty($config->login_name)){
echo htmlentities($config->login_name);
} else {
</tr>
<tr valign="top">
- <td align="right"><?php print_string('auth_shib_changepasswordurl', 'auth_shibboleth') ?>: </td>
+ <td align="right"><label for="changepasswordurl"><?php print_string('auth_shib_changepasswordurl', 'auth_shibboleth') ?>: </label></td>
<td>
- <input name="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
+ <input name="changepasswordurl" id="changepasswordurl" type="text" value="<?php echo $config->changepasswordurl ?>" />
<?php
if (isset($err['changepasswordurl'])) {
?>
<div class="guestsub">
- <p><?php print_string("auth_shibboleth_select_organization", "auth_shibboleth"); ?></p>
+ <p><label for="idp"><?php print_string("auth_shibboleth_select_organization", "auth_shibboleth"); ?></label></p>
<form action="login.php" method="post" id="guestlogin">
- <select name="idp">
+ <select id="idp" name="idp">
<option value="-" ><?php print_string("auth_shibboleth_select_member", "auth_shibboleth"); ?></option>
<?php
print_idp_list();
switch ($type) {
case backup::TYPE_1COURSE :
- require_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_COURSE, $course->id));
+ require_capability('moodle/backup:backupcourse', context_course::instance($course->id));
$heading = get_string('backupcourse', 'backup', $course->shortname);
break;
case backup::TYPE_1SECTION :
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
require_capability('moodle/backup:backupsection', $coursecontext);
if ((string)$section->name !== '') {
$sectionname = format_string($section->name, true, array('context' => $coursecontext));
}
break;
case backup::TYPE_1ACTIVITY :
- require_capability('moodle/backup:backupactivity', get_context_instance(CONTEXT_MODULE, $cm->id));
+ require_capability('moodle/backup:backupactivity', context_module::instance($cm->id));
$heading = get_string('backupactivity', 'backup', $cm->name);
break;
default :
$returnurl = optional_param('returnurl', null, PARAM_URL);
list($context, $course, $cm) = get_context_info_array($currentcontext);
-$filecontext = get_context_instance_by_id($contextid);
+$filecontext = context::instance_by_id($contextid, IGNORE_MISSING);
$url = new moodle_url('/backup/backupfilesedit.php', array('currentcontext'=>$currentcontext, 'contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea));
$id = $dinfo[0]->id; // Id of activity/section/course (depends of type)
$courseid = $dinfo[0]->courseid; // Id of the course
- $ctxid = get_context_instance(CONTEXT_USER, $userid)->id;
+ $ctxid = context_user::instance($userid)->id;
$component = 'user';
$filearea = 'backup';
$itemid = 0;
// Load the course and context
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
-$context = get_context_instance(CONTEXT_COURSE, $courseid);
+$context = context_course::instance($courseid);
// Must pass login
require_login($course);
// Load the course +context to import from
$importcourse = $DB->get_record('course', array('id'=>$importcourseid), '*', MUST_EXIST);
-$importcontext = get_context_instance(CONTEXT_COURSE, $importcourseid);
+$importcontext = context_course::instance($importcourseid);
// Make sure the user can backup from that course
require_capability('moodle/backup:backuptargetimport', $importcontext);
require_login();
- require_capability('moodle/backup:backupcourse', get_context_instance(CONTEXT_SYSTEM));
+ require_capability('moodle/backup:backupcourse', context_system::instance());
redirect("$CFG->wwwroot/report/backups/index.php", '', 'admin', 1);
$this->sectionid = $coursemodule->section;
$this->modulename = $coursemodule->modname;
$this->activityid = $coursemodule->instance;
- $this->contextid = get_context_instance(CONTEXT_MODULE, $this->moduleid)->id;
+ $this->contextid = context_module::instance($this->moduleid)->id;
parent::__construct($name, $plan);
}
$this->blockid = $blockid;
$this->blockname = $block->blockname;
- $this->contextid = get_context_instance(CONTEXT_BLOCK, $this->blockid)->id;
+ $this->contextid = context_block::instance($this->blockid)->id;
$this->moduleid = $moduleid;
$this->modulename = null;
$this->parentcontextid = null;
$this->moduleid = $moduleid;
$this->modulename = $coursemodule->modname;
- $this->parentcontextid = get_context_instance(CONTEXT_MODULE, $this->moduleid)->id;
+ $this->parentcontextid = context_module::instance($this->moduleid)->id;
}
parent::__construct($name, $plan);
public function __construct($name, $courseid, $plan = null) {
$this->courseid = $courseid;
- $this->contextid = get_context_instance(CONTEXT_COURSE, $this->courseid)->id;
+ $this->contextid = context_course::instance($this->courseid)->id;
parent::__construct($name, $plan);
}
global $CFG;
// Set the backup::VAR_CONTEXTID setting to course context as far as next steps require that
- $coursectxid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
+ $coursectxid = context_course::instance($this->get_courseid())->id;
$this->add_setting(new backup_activity_generic_setting(backup::VAR_CONTEXTID, base_setting::IS_INTEGER, $coursectxid));
// Set the backup::VAR_COURSEID setting to course, we'll need that in some steps
public function build() {
// Set the backup::VAR_CONTEXTID setting to course context as far as next steps require that
- $coursectxid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
+ $coursectxid = context_course::instance($this->get_courseid())->id;
$this->add_setting(new backup_activity_generic_setting(backup::VAR_CONTEXTID, base_setting::IS_INTEGER, $coursectxid));
// Add some extra settings that related processors are going to need
AND bi.itemname = 'scalefinal'", array(backup::VAR_BACKUPID));
// Annotate scale files (they store files in system context, so pass it instead of default one)
- $scale->annotate_files('grade', 'scale', 'id', get_context_instance(CONTEXT_SYSTEM)->id);
+ $scale->annotate_files('grade', 'scale', 'id', context_system::instance()->id);
// Return main element (scalesdef)
return $scalesdef;
AND bi.itemname = 'outcomefinal'", array(backup::VAR_BACKUPID));
// Annotate outcome files (they store files in system context, so pass it instead of default one)
- $outcome->annotate_files('grade', 'outcome', 'id', get_context_instance(CONTEXT_SYSTEM)->id);
+ $outcome->annotate_files('grade', 'outcome', 'id', context_system::instance()->id);
// Return main element (outcomesdef)
return $outcomesdef;
$info['original_course_fullname'] = $originalcourseinfo->fullname;
$info['original_course_shortname'] = $originalcourseinfo->shortname;
$info['original_course_startdate'] = $originalcourseinfo->startdate;
- $info['original_course_contextid'] = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
- $info['original_system_contextid'] = get_context_instance(CONTEXT_SYSTEM)->id;
+ $info['original_course_contextid'] = context_course::instance($this->get_courseid())->id;
+ $info['original_system_contextid'] = context_system::instance()->id;
// Get more information from controller
list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information($this->get_backupid());
'backupid' => $this->get_backupid(), 'itemname' => 'userfinal'));
foreach ($rs as $record) {
$userid = $record->itemid;
- $userctx = get_context_instance(CONTEXT_USER, $userid);
+ $userctx = context_user::instance($userid);
if (!$userctx) {
continue; // User has not context, sure it's a deleted user, so cannot have files
}
public function build() {
// Define the task contextid (the course one)
- $this->contextid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
+ $this->contextid = context_course::instance($this->get_courseid())->id;
// Executed conditionally if restoring to new course or if overwrite_conf setting is enabled
if ($this->get_target() == backup::TARGET_NEW_COURSE || $this->get_setting_value('overwrite_conf') == true) {
public function build() {
// Define the task contextid (the course one)
- $this->contextid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
+ $this->contextid = context_course::instance($this->get_courseid())->id;
// We always try to restore as much info from sections as possible, no matter of the type
// of restore (new, existing, deleting, import...). MDL-27764
}
// Create the old-course-ctxid to new-course-ctxid mapping, we need that available since the beginning
$itemid = $this->task->get_old_contextid();
- $newitemid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
+ $newitemid = context_course::instance($this->get_courseid())->id;
restore_dbops::set_backup_ids_record($this->get_restoreid(), 'context', $itemid, $newitemid);
// Create the old-system-ctxid to new-system-ctxid mapping, we need that available since the beginning
$itemid = $this->task->get_old_system_contextid();
- $newitemid = get_context_instance(CONTEXT_SYSTEM)->id;
+ $newitemid = context_system::instance()->id;
restore_dbops::set_backup_ids_record($this->get_restoreid(), 'context', $itemid, $newitemid);
// Create the old-course-id to new-course-id mapping, we need that available since the beginning
$itemid = $this->task->get_old_courseid();
$data = (object)$data;
$oldid = $data->id;
- $data->contextid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
+ $data->contextid = context_course::instance($this->get_courseid())->id;
$newitemid = $DB->insert_record('grade_letters', $data);
$this->set_mapping('grade_letter', $oldid, $newitemid);
$data->courseid = $data->courseid ? $this->get_courseid() : 0;
// If global scale (course=0), check the user has perms to create it
// falling to course scale if not
- $systemctx = get_context_instance(CONTEXT_SYSTEM);
+ $systemctx = context_system::instance();
if ($data->courseid == 0 && !has_capability('moodle/course:managescales', $systemctx , $this->task->get_userid())) {
$data->courseid = $this->get_courseid();
}
$data->courseid = $data->courseid ? $this->get_courseid() : null;
// If global outcome (course=null), check the user has perms to create it
// falling to course outcome if not
- $systemctx = get_context_instance(CONTEXT_SYSTEM);
+ $systemctx = context_system::instance();
if (is_null($data->courseid) && !has_capability('moodle/grade:manageoutcomes', $systemctx , $this->task->get_userid())) {
$data->courseid = $this->get_courseid();
}
$data->fullname = $fullname;
$data->shortname= $shortname;
- $context = get_context_instance_by_id($this->task->get_contextid());
+ $context = context::instance_by_id($this->task->get_contextid());
if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
$data->idnumber = '';
} else {
return;
}
}
+ // Handle events with empty eventtype //MDL-32827
+ if(empty($data->eventtype)) {
+ if ($data->courseid == $SITE->id) { // Site event
+ $data->eventtype = "site";
+ } else if ($data->courseid != 0 && $data->groupid == 0 && ($data->modulename == 'assignment' || $data->modulename == 'assign')) {
+ // Course assingment event
+ $data->eventtype = "due";
+ } else if ($data->courseid != 0 && $data->groupid == 0) { // Course event
+ $data->eventtype = "course";
+ } else if ($data->groupid) { // Group event
+ $data->eventtype = "group";
+ } else if ($data->userid) { // User event
+ $data->eventtype = "user";
+ } else {
+ return;
+ }
+ }
$params = array(
'name' => $data->name,
// Save the mapping (with restorefiles support)
$this->set_mapping('block_instance', $oldid, $newitemid, true);
// Create the block context
- $newcontextid = get_context_instance(CONTEXT_BLOCK, $newitemid)->id;
+ $newcontextid = context_block::instance($newitemid)->id;
// Save the block contexts mapping and sent it to task
$this->set_mapping('context', $oldcontextid, $newcontextid);
$this->task->set_contextid($newcontextid);
// set the new course_module id in the task
$this->task->set_moduleid($newitemid);
// we can now create the context safely
- $ctxid = get_context_instance(CONTEXT_MODULE, $newitemid)->id;
+ $ctxid = context_module::instance($newitemid)->id;
// set the new context id in the task
$this->task->set_contextid($ctxid);
// update sequence field in course_section
// will be used when restore
if (!empty($filecontextid)) {
- $filecontext = get_context_instance_by_id($filecontextid);
+ $filecontext = context::instance_by_id($filecontextid);
}
$url = new moodle_url('/backup/restorefile.php', array('contextid'=>$contextid));
echo $OUTPUT->heading_with_help(get_string('choosefilefromactivitybackup', 'backup'), 'choosefilefromuserbackup', 'backup');
echo $OUTPUT->container_start();
$treeview_options = array();
- $user_context = get_context_instance(CONTEXT_USER, $USER->id);
+ $user_context = context_user::instance($USER->id);
$treeview_options['filecontext'] = $context;
$treeview_options['currentcontext'] = $context;
$treeview_options['component'] = 'backup';
echo $OUTPUT->heading_with_help(get_string('choosefilefromuserbackup', 'backup'), 'choosefilefromuserbackup', 'backup');
echo $OUTPUT->container_start();
$treeview_options = array();
-$user_context = get_context_instance(CONTEXT_USER, $USER->id);
+$user_context = context_user::instance($USER->id);
$treeview_options['filecontext'] = $user_context;
$treeview_options['currentcontext'] = $context;
$treeview_options['component'] = 'user';
echo $OUTPUT->heading_with_help(get_string('choosefilefromautomatedbackup', 'backup'), 'choosefilefromautomatedbackup', 'backup');
echo $OUTPUT->container_start();
$treeview_options = array();
- $user_context = get_context_instance(CONTEXT_USER, $USER->id);
+ $user_context = context_user::instance($USER->id);
$treeview_options['filecontext'] = $context;
$treeview_options['currentcontext'] = $context;
$treeview_options['component'] = 'backup';
$type = $backup_controller->get_type();
$mode = $backup_controller->get_mode();
$courseid = $backup_controller->get_courseid();
- $coursectx= get_context_instance(CONTEXT_COURSE, $courseid);
+ $coursectx= context_course::instance($courseid);
$userid = $backup_controller->get_userid();
$id = $backup_controller->get_id(); // courseid / sectionid / cmid
break;
case backup::TYPE_1ACTIVITY :
get_coursemodule_from_id(null, $id, $courseid, false, MUST_EXIST); // cm exists
- $modulectx = get_context_instance(CONTEXT_MODULE, $id);
+ $modulectx = context_module::instance($id);
$typecapstocheck['moodle/backup:backupactivity'] = $modulectx;
break;
default :
$type = $restore_controller->get_type();
$mode = $restore_controller->get_mode();
$courseid = $restore_controller->get_courseid();
- $coursectx= get_context_instance(CONTEXT_COURSE, $courseid);
+ $coursectx= context_course::instance($courseid);
$userid = $restore_controller->get_userid();
// Note: all the checks along the function MUST be performed for $userid, that
global $DB;
// Get the context of the module
- $contextid = get_context_instance(CONTEXT_MODULE, $moduleid)->id;
+ $contextid = context_module::instance($moduleid)->id;
// Get all the block instances which parentcontextid is the module contextid
$blockids = array();
global $DB;
// Get the context of the course
- $contextid = get_context_instance(CONTEXT_COURSE, $courseid)->id;
+ $contextid = context_course::instance($courseid)->id;
// Get all the block instances which parentcontextid is the course contextid
$blockids = array();
switch ($type) {
case backup::TYPE_1COURSE:
$shortname = $DB->get_field('course', 'shortname', array('id' => $id));
- $context = get_context_instance(CONTEXT_COURSE, $id);
+ $context = context_course::instance($id);
$shortname = format_string($shortname, true, array('context' => $context));
break;
case backup::TYPE_1SECTION:
global $CFG, $DB;
// Gather various information about roles
- $coursectx = get_context_instance(CONTEXT_COURSE, $courseid);
+ $coursectx = context_course::instance($courseid);
$assignablerolesshortname = get_assignable_roles($coursectx, ROLENAME_SHORT, false, $userid);
// Note: under 1.9 we had one function restore_samerole() that performed one complete
switch ($contextlevel) {
// For system is easy, the best context is the system context
case CONTEXT_SYSTEM:
- $targetcontext = get_context_instance(CONTEXT_SYSTEM);
+ $targetcontext = context_system::instance();
break;
// For coursecat, we are going to look for stamps in all the
}
$contexts = array();
// Build the array of contexts we are going to look
- $systemctx = get_context_instance(CONTEXT_SYSTEM);
- $coursectx = get_context_instance(CONTEXT_COURSE, $courseid);
+ $systemctx = context_system::instance();
+ $coursectx = context_course::instance($courseid);
$parentctxs= get_parent_contexts($coursectx);
foreach ($parentctxs as $parentctx) {
// Exclude system context
$matchingcontexts = $DB->get_records_sql($sql, $params);
// Only if ONE and ONLY ONE context is found, use it as valid target
if (count($matchingcontexts) == 1) {
- $targetcontext = get_context_instance_by_id(reset($matchingcontexts)->contextid);
+ $targetcontext = context::instance_by_id(reset($matchingcontexts)->contextid);
}
}
break;
// For course is easy, the best context is the course context
case CONTEXT_COURSE:
- $targetcontext = get_context_instance(CONTEXT_COURSE, $courseid);
+ $targetcontext = context_course::instance($courseid);
break;
// For module is easy, there is not best context, as far as the
// case is handled by {@link prechek_precheck_qbanks_by_level}
// in an special way
case CONTEXT_MODULE:
- $targetcontext = get_context_instance(CONTEXT_COURSE, $courseid);
+ $targetcontext = context_course::instance($courseid);
break;
}
return $targetcontext;
// but for deleted users that don't have a context anymore (MDL-30192). We are done for them
// and nothing else (custom fields, prefs, tags, files...) will be created.
if (empty($user->deleted)) {
- $newuserctxid = $user->deleted ? 0 : get_context_instance(CONTEXT_USER, $newuserid)->id;
+ $newuserctxid = $user->deleted ? 0 : context_user::instance($newuserid)->id;
self::set_backup_ids_record($restoreid, 'context', $recuser->parentitemid, $newuserctxid);
// Process custom fields
$mnethosts = $DB->get_records('mnet_host', array(), 'wwwroot', 'wwwroot, id');
// Calculate the context we are going to use for capability checking
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = context_course::instance($courseid);
// Calculate if we have perms to create users, by checking:
// to 'moodle/restore:createuser' and 'moodle/restore:userinfo'
global $DB;
// Get the course context
- $coursectx = get_context_instance(CONTEXT_COURSE, $courseid);
+ $coursectx = context_course::instance($courseid);
// Get all the mapped roles we have
$rs = $DB->get_recordset('backup_ids_temp', array('backupid' => $restoreid, 'itemname' => 'role'), '', 'itemid');
foreach ($rs as $recrole) {
//Build the message subject
$site = get_site();
- $prefix = format_string($site->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, SITEID))).": ";
+ $prefix = format_string($site->shortname, true, array('context' => context_course::instance(SITEID))).": ";
if ($haserrors) {
$prefix .= "[".strtoupper(get_string('error'))."] ";
}
// Clean up excess backups in the course backup filearea
if ($storage == 0 || $storage == 2) {
$fs = get_file_storage();
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $context = context_course::instance($course->id);
$component = 'backup';
$filearea = 'automated';
$itemid = 0;
$itemid = 0;
switch ($backuptype) {
case backup::TYPE_1ACTIVITY:
- $ctxid = get_context_instance(CONTEXT_MODULE, $id)->id;
+ $ctxid = context_module::instance($id)->id;
$component = 'backup';
$filearea = 'activity';
$itemid = 0;
break;
case backup::TYPE_1SECTION:
- $ctxid = get_context_instance(CONTEXT_COURSE, $courseid)->id;
+ $ctxid = context_course::instance($courseid)->id;
$component = 'backup';
$filearea = 'section';
$itemid = $id;
break;
case backup::TYPE_1COURSE:
- $ctxid = get_context_instance(CONTEXT_COURSE, $courseid)->id;
+ $ctxid = context_course::instance($courseid)->id;
$component = 'backup';
$filearea = 'course';
$itemid = 0;
// are sent to user's "user_tohub" file area. The upload process
// will be responsible for cleaning that filearea once finished
if ($backupmode == backup::MODE_HUB) {
- $ctxid = get_context_instance(CONTEXT_USER, $userid)->id;
+ $ctxid = context_user::instance($userid)->id;
$component = 'user';
$filearea = 'tohub';
$itemid = 0;
// file area. Maintenance of such area is responsibility of
// the user via corresponding file manager frontend
if ($backupmode == backup::MODE_GENERAL && (!$hasusers || $isannon)) {
- $ctxid = get_context_instance(CONTEXT_USER, $userid)->id;
+ $ctxid = context_user::instance($userid)->id;
$component = 'user';
$filearea = 'backup';
$itemid = 0;
// If restoring to different site and restoring users and backup has mnet users warn/error
if (!$samesite && $restoreusers && $hasmnetusers) {
// User is admin (can create users at sysctx), warn
- if (has_capability('moodle/user:create', get_context_instance(CONTEXT_SYSTEM), $controller->get_userid())) {
+ if (has_capability('moodle/user:create', context_system::instance(), $controller->get_userid())) {
$warnings[] = get_string('mnetrestore_extusers_admin', 'admin');
// User not admin
} else {
// Re-enforce 'moodle/restore:rolldates' capability for the user in the course, just in case
} else if (!has_capability('moodle/restore:rolldates',
- get_context_instance(CONTEXT_COURSE, $this->get_courseid()),
+ context_course::instance($this->get_courseid()),
$this->task->get_userid())) {
$cache[$this->get_restoreid()] = 0;
case 'activity':
$cmid = $this->get_ui()->get_controller()->get_id();
$cm = get_coursemodule_from_id(null, $cmid, $courseid);
- $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modcontext = context_module::instance($cm->id);
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$modcontext->id));
break;
case 'course':
default:
- $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
+ $coursecontext = context_course::instance($courseid);
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
}
}
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$course->id)),
- format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
- format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)))
+ format_string($course->shortname, true, array('context' => context_course::instance($course->id))),
+ format_string($course->fullname, true, array('context' => context_course::instance($course->id)))
);
$table->data[] = $row;
}
}
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'importid', 'value'=>$course->id)),
- format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
- format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)))
+ format_string($course->shortname, true, array('context' => context_course::instance($course->id))),
+ format_string($course->fullname, true, array('context' => context_course::instance($course->id)))
);
$table->data[] = $row;
}
}
$row->cells = array(
html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$category->id)),
- format_string($category->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $category->id))),
+ format_string($category->name, true, array('context' => context_coursecat::instance($category->id))),
format_text($category->description, $category->descriptionformat, array('overflowdiv'=>true))
);
$table->data[] = $row;
$resultset = $DB->get_records_sql($sql, $params, $offs, $blocksz);
foreach ($resultset as $result) {
context_instance_preload($result);
- $context = get_context_instance($contextlevel, $result->id);
+ $classname = context_helper::get_class_for_level($contextlevel);
+ $context = $classname::instance($result->id);
if (count($requiredcaps) > 0) {
if (!has_all_capabilities($requiredcaps, $context, $userid)) {
continue;
'filepath'=>$this->filepath,
'contextid'=>$this->contextid,
'stage'=>restore_ui::STAGE_DESTINATION));
- $this->coursesearch = new restore_course_search(array('url'=>$url), get_context_instance_by_id($contextid)->instanceid);
+ $this->coursesearch = new restore_course_search(array('url'=>$url), context::instance_by_id($contextid)->instanceid);
$this->categorysearch = new restore_category_search(array('url'=>$url));
}
public function process() {
'contextid' => $this->contextid,
'filepath' => $this->filepath,
'stage' => restore_ui::STAGE_SETTINGS));
- $context = get_context_instance_by_id($this->contextid);
+ $context = context::instance_by_id($this->contextid);
if ($context->contextlevel == CONTEXT_COURSE and has_capability('moodle/restore:restorecourse', $context)) {
$currentcourse = $context->instanceid;
$haserrors = (!empty($results['errors']));
$html .= $renderer->precheck_notices($results);
if (!empty($info->role_mappings->mappings)) {
- $context = get_context_instance(CONTEXT_COURSE, $this->ui->get_controller()->get_courseid());
+ $context = context_course::instance($this->ui->get_controller()->get_courseid());
$assignableroles = get_assignable_roles($context, ROLENAME_ALIAS, false);
$html .= $renderer->role_mappings($info->role_mappings->mappings, $assignableroles);
}
});
}
-}, '@VERSION@', {'requires':['base','node','node-event-simulate','moodle-enrol-notification']});
+}, '@VERSION@', {'requires':['base','node','node-event-simulate','moodle-core-notification']});
}
}, '@VERSION@', {
- requires:['base','overlay', 'moodle-enrol-notification']
-});
\ No newline at end of file
+ requires:['base','overlay', 'moodle-core-notification']
+});
}
}, '@VERSION@', {
- requires:['base','node','overlay', 'moodle-enrol-notification']
+ requires:['base','node','overlay', 'moodle-core-notification']
});
?>
<tr valign="top">
<td align="right">
- <?php print_string('numsections'.$i, 'block_section_links'); ?>:
+ <label for="menunumsections<?php echo $i; ?>"><?php print_string('numsections'.$i, 'block_section_links'); ?>:</label>
</td>
<td>
<?php choose_from_menu($numberofsections, 'numsections'.$i, $selected[$i][0]); ?>
</tr>
<tr valign="top">
<td align="right">
- <?php print_string('incby'.$i, 'block_section_links'); ?>:
+ <label for="menuincby<?php echo $i;?>"><?php print_string('incby'.$i, 'block_section_links'); ?>:</label>
</td>
<td>
<?php choose_from_menu($increments, 'incby'.$i, $selected[$i][1]); ?>
if ($officialtags) { $this->content->text .= $officialtagscontent; }
if ($coursetags) { $this->content->text .= $coursetagscontent; }
if ($commtags) { $this->content->text .= $commtagscontent; }
-
// add the input form section (allowing a user to tag the current course) and navigation, or loggin message
if ($loggedin) {
// only show the input form on course pages for those allowed (or not barred)
<div class="coursetag_form_wrapper">
<div class="coursetag_form_positioner">
<div class="coursetag_form_input1">
- <input type="text" name="coursetag_sug_keyword" class="coursetag_form_input1a" disabled="disabled" />
+ <label class="accesshide" for="coursetag_sug_keyword">$tagthisunit</label>
+ <input type="text" name="coursetag_sug_keyword" id="coursetag_sug_keyword" class="coursetag_form_input1a" disabled="disabled" />
</div>
<div class="coursetag_form_input2">
<input type="text" name="coursetag_new_tag" id="coursetag_new_tag" class="coursetag_form_input2a"
$a = new stdClass();
$a->modtype = $DB->get_field('modules', 'name', array('id' => $cm->module));
$a->modname = $DB->get_field($a->modtype, 'name', array('id' => $cm->instance));
+ $modid = $context->instanceid;
}
$mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
$event = new stdClass();
$event->action = $action;
$event->course = $courseid;
+ $event->courseid = $courseid;
$event->timeduration = 0;
if ($formoptions->eventtypes->courses) {
if (!$issite) {
- $event->courseid = $courseid;
$event->eventtype = 'course';
} else {
unset($formoptions->eventtypes->courses);
for ($i=1; $i<=12; $i++) {
$months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), '%B');
}
+ echo html_writer::label(get_string('months'), 'menu'. $name, false, array('class' => 'accesshide'));
echo html_writer::select($months, $name, $selected, false);
}
$select = new single_select(new moodle_url(CALENDAR_URL.'set.php', array('return' => base64_encode($returnurl->out(false)), 'var' => 'setcourse', 'sesskey'=>sesskey())), 'id', $courseoptions, $selected, null);
$select->class = 'cal_courses_flt';
if ($label !== null) {
- $select->label = $label;
+ $select->set_label($label);
+ } else {
+ $select->set_label(get_string('listofcourses'), array('class' => 'accesshide'));
}
return $this->output->render($select);
}
make_categories_list($movetocategories, $notused, 'moodle/category:manage');
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
echo '<tr><td colspan="3" align="right">';
+ echo html_writer::label(get_string('moveselectedcoursesto'), 'movetoid', false, array('class' => 'accesshide'));
echo html_writer::select($movetocategories, 'moveto', $category->id, null, array('id'=>'movetoid'));
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
}
$popupurl = new moodle_url("index.php?move=$category->id&sesskey=".sesskey());
$select = new single_select($popupurl, 'moveto', $tempdisplaylist, $category->parent, null, "moveform$category->id");
+ $select->set_label(get_string('frontpagecategorynames'), array('class' => 'accesshide'));
echo $OUTPUT->render($select);
}
echo '</td>';
WHERE ue.enrolid = e.id
AND e.courseid <> :siteid
AND c.id = e.courseid
- AND c.visible = 1)';
+ AND c.visible = 1) total';
$params = array('siteid' => $SITE->id);
$enrolmenttotal = $DB->count_records_sql($sql, $params);
WHERE c.id = cm.course
AND c.id <> :siteid
AND cm.visible = 1
- AND c.visible = 1)';
+ AND c.visible = 1) total';
$params = array('siteid' => $SITE->id);
$moduletotal = $DB->count_records_sql($sql, $params);
$PAGE->set_url('/course/reset.php', array('id'=>$id));
require_login($course);
-require_capability('moodle/course:update', context_course::instance($course->id));
+require_capability('moodle/course:reset', context_course::instance($course->id));
$strreset = get_string('reset');
$strresetcourse = get_string('resetcourse');
echo $OUTPUT->box_start();
echo $OUTPUT->heading($scale->name);
echo "<center>";
- echo html_writer::select($scalemenu, 'unused');
+ echo html_writer::label(get_string('scales'), 'scaleunused'. $scaleid, false, array('class' => 'accesshide'));
+ echo html_writer::select($scalemenu, 'unused', '', array('' => 'choosedots'), array('id' => 'scaleunused'.$scaleid));
echo "</center>";
echo text_to_html($scale->description);
echo $OUTPUT->box_end();
echo $OUTPUT->box_start();
echo $OUTPUT->heading($scale->name);
echo "<center>";
- echo html_writer::select($scalemenu, 'unused');
+ echo html_writer::label(get_string('scales'), 'courseunused' . $scale->id, false, array('class' => 'accesshide'));
+ echo html_writer::select($scalemenu, 'unused', '', array('' => 'choosedots'), array('id' => 'courseunused' . $scale->id));
echo "</center>";
echo text_to_html($scale->description);
echo $OUTPUT->box_end();
echo $OUTPUT->box_start();
echo $OUTPUT->heading($scale->name);
echo "<center>";
- echo html_writer::select($scalemenu, 'unused');
+ echo html_writer::label(get_string('scales'), 'sitescale' . $scale->id, false, array('class' => 'accesshide'));
+ echo html_writer::select($scalemenu, 'unused', '', array('' => 'choosedots'), array('id' => 'sitescale' . $scale->id));
echo "</center>";
echo text_to_html($scale->description);
echo $OUTPUT->box_end();
echo "<input type=\"button\" onclick=\"checkall()\" value=\"$strselectall\" />\n";
echo "<input type=\"button\" onclick=\"checknone()\" value=\"$strdeselectall\" />\n";
// Select box should only show categories in which user has min capability to move course.
+ echo html_writer::label(get_string('moveselectedcoursesto'), 'movetoid', false, array('class' => 'accesshide'));
echo html_writer::select($usercatlist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
echo "</td>\n</tr>\n";
M.course.init_section_dragdrop = function(params) {
new DRAGSECTION(params);
}
-}, '@VERSION@', {requires:['base', 'node', 'io', 'dom', 'dd', 'dd-scroll', 'moodle-core-dragdrop', 'moodle-enrol-notification', 'moodle-course-coursebase']});
+}, '@VERSION@', {requires:['base', 'node', 'io', 'dom', 'dd', 'dd-scroll', 'moodle-core-dragdrop', 'moodle-core-notification', 'moodle-course-coursebase']});
}
}
-}, '@VERSION@', {requires:['base','node', 'overlay', 'io-base', 'test', 'json-parse', 'event-delegate', 'dd-plugin', 'event-key', 'moodle-enrol-notification']});
+}, '@VERSION@', {requires:['base','node', 'overlay', 'io-base', 'test', 'json-parse', 'event-delegate', 'dd-plugin', 'event-key', 'moodle-core-notification']});
'msn' => new external_value(PARAM_NOTAGS, 'msn number', VALUE_OPTIONAL),
'department' => new external_value(PARAM_TEXT, 'department', VALUE_OPTIONAL),
'institution' => new external_value(PARAM_TEXT, 'institution', VALUE_OPTIONAL),
+ 'idnumber' => new external_value(PARAM_RAW, 'An arbitrary ID code number perhaps from the institution', VALUE_OPTIONAL),
'interests' => new external_value(PARAM_TEXT, 'user interests (separated by commas)', VALUE_OPTIONAL),
'firstaccess' => new external_value(PARAM_INT, 'first access to the site (0 if never)', VALUE_OPTIONAL),
'lastaccess' => new external_value(PARAM_INT, 'last access to the site (0 if never)', VALUE_OPTIONAL),
}
}
-}, '@VERSION@', {requires:['base','node', 'overlay', 'io-base', 'test', 'json-parse', 'event-delegate', 'dd-plugin', 'event-key', 'moodle-enrol-notification']});
+}, '@VERSION@', {requires:['base','node', 'overlay', 'io-base', 'test', 'json-parse', 'event-delegate', 'dd-plugin', 'event-key', 'moodle-core-notification']});
+/**
+ * This module provides backwards compatability and should be removed
+ * entirely in Moodle 2.5
+ */
YUI.add('moodle-enrol-notification', function(Y) {
-
-var DIALOGUE_NAME = 'Moodle dialogue',
- DIALOGUE_PREFIX = 'moodle-dialogue',
- CONFIRM_NAME = 'Moodle confirmation dialogue',
- EXCEPTION_NAME = 'Moodle exception',
- AJAXEXCEPTION_NAME = 'Moodle AJAX exception',
- ALERT_NAME = 'Moodle alert',
- C = Y.Node.create,
- BASE = 'notificationBase',
- LIGHTBOX = 'lightbox',
- NODELIGHTBOX = 'nodeLightbox',
- COUNT = 0,
- CONFIRMYES = 'yesLabel',
- CONFIRMNO = 'noLabel',
- TITLE = 'title',
- QUESTION = 'question',
- CSS = {
- BASE : 'moodle-dialogue-base',
- WRAP : 'moodle-dialogue-wrap',
- HEADER : 'moodle-dialogue-hd',
- BODY : 'moodle-dialogue-bd',
- CONTENT : 'moodle-dialogue-content',
- FOOTER : 'moodle-dialogue-fd',
- HIDDEN : 'hidden',
- LIGHTBOX : 'moodle-dialogue-lightbox'
- };
-
-var DIALOGUE = function(config) {
- COUNT++;
- var id = 'moodle-dialogue-'+COUNT;
- config.notificationBase =
- C('<div class="'+CSS.BASE+'">')
- .append(C('<div class="'+CSS.LIGHTBOX+' '+CSS.HIDDEN+'"></div>'))
- .append(C('<div id="'+id+'" class="'+CSS.WRAP+'"></div>')
- .append(C('<div class="'+CSS.HEADER+' yui3-widget-hd"></div>'))
- .append(C('<div class="'+CSS.BODY+' yui3-widget-bd"></div>'))
- .append(C('<div class="'+CSS.CONTENT+' yui3-widget-ft"></div>')));
- Y.one(document.body).append(config.notificationBase);
- config.srcNode = '#'+id;
- config.width = config.width || '400px';
- config.visible = config.visible || false;
- config.center = config.centered || true;
- config.centered = false;
- DIALOGUE.superclass.constructor.apply(this, [config]);
-};
-Y.extend(DIALOGUE, Y.Overlay, {
- initializer : function(config) {
- this.set(NODELIGHTBOX, this.get(BASE).one('.'+CSS.LIGHTBOX).setStyle('opacity', 0.5));
- this.after('visibleChange', this.visibilityChanged, this);
- this.after('headerContentChange', function(e){
- var h = (this.get('closeButton'))?this.get(BASE).one('.'+CSS.HEADER):false;
- if (h && !h.one('.closebutton')) {
- var c = C('<div class="closebutton"></div>');
- c.on('click', this.hide, this);
- h.append(c);
- }
- }, this);
- this.render();
- this.show();
- },
- visibilityChanged : function(e) {
- switch (e.attrName) {
- case 'visible':
- if (this.get(LIGHTBOX)) {
- var l = this.get(NODELIGHTBOX);
- if (!e.prevVal && e.newVal) {
- l.setStyle('height',l.get('docHeight')+'px').removeClass(CSS.HIDDEN);
- } else if (e.prevVal && !e.newVal) {
- l.addClass(CSS.HIDDEN);
- }
- }
- if (this.get('center') && !e.prevVal && e.newVal) {
- this.centerDialogue();
- }
- if (this.get('draggable')) {
- var titlebar = '#' + this.get('id') + ' .' + CSS.HEADER;
- this.plug(Y.Plugin.Drag, {handles : [titlebar]});
- this.dd.addInvalid('div.closebutton');
- Y.one(titlebar).setStyle('cursor', 'move');
- }
- break;
- }
- },
- centerDialogue : function() {
- var bb = this.get('boundingBox'), hidden = bb.hasClass(DIALOGUE_PREFIX+'-hidden');
- if (hidden) {
- bb.setStyle('top', '-1000px').removeClass(DIALOGUE_PREFIX+'-hidden');
- }
- var x = Math.max(Math.round((bb.get('winWidth') - bb.get('offsetWidth'))/2), 15);
- var y = Math.max(Math.round((bb.get('winHeight') - bb.get('offsetHeight'))/2), 15) + Y.one(window).get('scrollTop');
-
- if (hidden) {
- bb.addClass(DIALOGUE_PREFIX+'-hidden');
- }
- bb.setStyle('left', x).setStyle('top', y);
- }
-}, {
- NAME : DIALOGUE_NAME,
- CSS_PREFIX : DIALOGUE_PREFIX,
- ATTRS : {
- notificationBase : {
-
- },
- nodeLightbox : {
- value : null
- },
- lightbox : {
- validator : Y.Lang.isBoolean,
- value : true
- },
- closeButton : {
- validator : Y.Lang.isBoolean,
- value : true
- },
- center : {
- validator : Y.Lang.isBoolean,
- value : true
- },
- draggable : {
- validator : Y.Lang.isBoolean,
- value : false
- }
- }
-});
-
-var ALERT = function(config) {
- config.closeButton = false;
- ALERT.superclass.constructor.apply(this, [config]);
-};
-Y.extend(ALERT, DIALOGUE, {
- _enterKeypress : null,
- initializer : function(config) {
- this.publish('complete');
- var yes = C('<input type="button" value="'+this.get(CONFIRMYES)+'" />'),
- content = C('<div class="confirmation-dialogue"></div>')
- .append(C('<div class="confirmation-message">'+this.get('message')+'</div>'))
- .append(C('<div class="confirmation-buttons"></div>')
- .append(yes));
- this.get(BASE).addClass('moodle-dialogue-confirm');
- this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
- this.setStdModContent(Y.WidgetStdMod.HEADER, this.get(TITLE), Y.WidgetStdMod.REPLACE);
- this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
- this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this);
- yes.on('click', this.submit, this);
- },
- submit : function(e, outcome) {
- this._enterKeypress.detach();
- this.fire('complete');
- this.hide();
- this.destroy();
- }
-}, {
- NAME : ALERT_NAME,
- CSS_PREFIX : DIALOGUE_PREFIX,
- ATTRS : {
- title : {
- validator : Y.Lang.isString,
- value : 'Alert'
- },
- message : {
- validator : Y.Lang.isString,
- value : 'Confirm'
- },
- yesLabel : {
- validator : Y.Lang.isString,
- setter : function(txt) {
- if (!txt) {
- txt = 'Ok';
- }
- return txt;
- },
- value : 'Ok'
- }
- }
-});
-
-var CONFIRM = function(config) {
- CONFIRM.superclass.constructor.apply(this, [config]);
-};
-Y.extend(CONFIRM, DIALOGUE, {
- _enterKeypress : null,
- _escKeypress : null,
- initializer : function(config) {
- this.publish('complete');
- this.publish('complete-yes');
- this.publish('complete-no');
- var yes = C('<input type="button" value="'+this.get(CONFIRMYES)+'" />'),
- no = C('<input type="button" value="'+this.get(CONFIRMNO)+'" />'),
- content = C('<div class="confirmation-dialogue"></div>')
- .append(C('<div class="confirmation-message">'+this.get(QUESTION)+'</div>'))
- .append(C('<div class="confirmation-buttons"></div>')
- .append(yes)
- .append(no));
- this.get(BASE).addClass('moodle-dialogue-confirm');
- this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
- this.setStdModContent(Y.WidgetStdMod.HEADER, this.get(TITLE), Y.WidgetStdMod.REPLACE);
- this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
- this._enterKeypress = Y.on('key', this.submit, window, 'down:13', this, true);
- this._escKeypress = Y.on('key', this.submit, window, 'down:27', this, false);
- yes.on('click', this.submit, this, true);
- no.on('click', this.submit, this, false);
- },
- submit : function(e, outcome) {
- this._enterKeypress.detach();
- this._escKeypress.detach();
- this.fire('complete', outcome);
- if (outcome) {
- this.fire('complete-yes');
- } else {
- this.fire('complete-no');
- }
- this.hide();
- this.destroy();
- }
-}, {
- NAME : CONFIRM_NAME,
- CSS_PREFIX : DIALOGUE_PREFIX,
- ATTRS : {
- yesLabel : {
- validator : Y.Lang.isString,
- value : 'Yes'
- },
- noLabel : {
- validator : Y.Lang.isString,
- value : 'No'
- },
- title : {
- validator : Y.Lang.isString,
- value : 'Confirm'
- },
- question : {
- validator : Y.Lang.isString,
- value : 'Are you sure?'
- }
- }
-});
-Y.augment(CONFIRM, Y.EventTarget);
-
-var EXCEPTION = function(config) {
- config.width = config.width || (M.cfg.developerdebug)?Math.floor(Y.one(document.body).get('winWidth')/3)+'px':null;
- config.closeButton = true;
- EXCEPTION.superclass.constructor.apply(this, [config]);
-};
-Y.extend(EXCEPTION, DIALOGUE, {
- _hideTimeout : null,
- _keypress : null,
- initializer : function(config) {
- this.get(BASE).addClass('moodle-dialogue-exception');
- this.setStdModContent(Y.WidgetStdMod.HEADER, config.name, Y.WidgetStdMod.REPLACE);
- var content = C('<div class="moodle-exception"></div>')
- .append(C('<div class="moodle-exception-message">'+this.get('message')+'</div>'))
- .append(C('<div class="moodle-exception-param hidden param-filename"><label>File:</label> '+this.get('fileName')+'</div>'))
- .append(C('<div class="moodle-exception-param hidden param-linenumber"><label>Line:</label> '+this.get('lineNumber')+'</div>'))
- .append(C('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get('stack')+'</pre></div>'));
- if (M.cfg.developerdebug) {
- content.all('.moodle-exception-param').removeClass('hidden');
- }
- this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-
- var self = this;
- var delay = this.get('hideTimeoutDelay');
- if (delay) {
- this._hideTimeout = setTimeout(function(){self.hide();}, delay);
- }
- this.after('visibleChange', this.visibilityChanged, this);
- this.after('destroyedChange', function(){this.get(BASE).remove();}, this);
- this._keypress = Y.on('key', this.hide, window, 'down:13,27', this);
- this.centerDialogue();
- },
- visibilityChanged : function(e) {
- if (e.attrName == 'visible' && e.prevVal && !e.newVal) {
- if (this._keypress) this._keypress.detach();
- var self = this;
- setTimeout(function(){self.destroy();}, 1000);
- }
- }
-}, {
- NAME : EXCEPTION_NAME,
- CSS_PREFIX : DIALOGUE_PREFIX,
- ATTRS : {
- message : {
- value : ''
- },
- name : {
- value : ''
- },
- fileName : {
- value : ''
- },
- lineNumber : {
- value : ''
- },
- stack : {
- setter : function(str) {
- var lines = str.split("\n");
- var pattern = new RegExp('^(.+)@('+M.cfg.wwwroot+')?(.{0,75}).*:(\\d+)$');
- for (var i in lines) {
- lines[i] = lines[i].replace(pattern, "<div class='stacktrace-line'>ln: $4</div><div class='stacktrace-file'>$3</div><div class='stacktrace-call'>$1</div>");
- }
- return lines.join('');
- },
- value : ''
- },
- hideTimeoutDelay : {
- validator : Y.Lang.isNumber,
- value : null
- }
- }
-});
-
-var AJAXEXCEPTION = function(config) {
- config.name = config.name || 'Error';
- config.closeButton = true;
- AJAXEXCEPTION.superclass.constructor.apply(this, [config]);
-};
-Y.extend(AJAXEXCEPTION, DIALOGUE, {
- _keypress : null,
- initializer : function(config) {
- this.get(BASE).addClass('moodle-dialogue-exception');
- this.setStdModContent(Y.WidgetStdMod.HEADER, config.name, Y.WidgetStdMod.REPLACE);
- var content = C('<div class="moodle-ajaxexception"></div>')
- .append(C('<div class="moodle-exception-message">'+this.get('error')+'</div>'))
- .append(C('<div class="moodle-exception-param hidden param-debuginfo"><label>URL:</label> '+this.get('reproductionlink')+'</div>'))
- .append(C('<div class="moodle-exception-param hidden param-debuginfo"><label>Debug info:</label> '+this.get('debuginfo')+'</div>'))
- .append(C('<div class="moodle-exception-param hidden param-stacktrace"><label>Stack trace:</label> <pre>'+this.get('stacktrace')+'</pre></div>'));
- if (M.cfg.developerdebug) {
- content.all('.moodle-exception-param').removeClass('hidden');
- }
- this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-
- var self = this;
- var delay = this.get('hideTimeoutDelay');
- if (delay) {
- this._hideTimeout = setTimeout(function(){self.hide();}, delay);
- }
- this.after('visibleChange', this.visibilityChanged, this);
- this._keypress = Y.on('key', this.hide, window, 'down:13, 27', this);
- this.centerDialogue();
- },
- visibilityChanged : function(e) {
- if (e.attrName == 'visible' && e.prevVal && !e.newVal) {
- var self = this;
- this._keypress.detach();
- setTimeout(function(){self.destroy();}, 1000);
- }
- }
-}, {
- NAME : AJAXEXCEPTION_NAME,
- CSS_PREFIX : DIALOGUE_PREFIX,
- ATTRS : {
- error : {
- validator : Y.Lang.isString,
- value : 'Unknown error'
- },
- debuginfo : {
- value : null
- },
- stacktrace : {
- value : null
- },
- reproductionlink : {
- setter : function(link) {
- if (link !== null) {
- link = '<a href="'+link+'">'+link.replace(M.cfg.wwwroot, '')+'</a>';
- }
- return link;
- },
- value : null
- },
- hideTimeoutDelay : {
- validator : Y.Lang.isNumber,
- value : null
- }
- }
-});
-
-M.core = M.core || {};
-M.core.dialogue = DIALOGUE;
-M.core.alert = ALERT;
-M.core.confirm = CONFIRM;
-M.core.exception = EXCEPTION;
-M.core.ajaxException = AJAXEXCEPTION;
-
-}, '@VERSION@', {requires:['base','node','overlay','event-key', 'moodle-enrol-notification-skin', 'dd-plugin']});
+ console.log("You are using a deprecated name. Please update your YUI module to use moodle-core-notification instead of moodle-enrol-notification");
+}, '@VERSION@', {requires:['base','node','overlay','event-key', 'moodle-core-notification']});
}
}
-}, '@VERSION@', {requires:['base','node', 'overlay', 'io-base', 'test', 'json-parse', 'event-delegate', 'dd-plugin', 'event-key', 'moodle-enrol-notification']});
\ No newline at end of file
+}, '@VERSION@', {requires:['base','node', 'overlay', 'io-base', 'test', 'json-parse', 'event-delegate', 'dd-plugin', 'event-key', 'moodle-core-notification']});
}
}
-}, '@VERSION@', {requires:['base','node','io-base','json-parse','test','moodle-enrol-notification']});
\ No newline at end of file
+}, '@VERSION@', {requires:['base','node','io-base','json-parse','test','moodle-core-notification']});
return new AUTOLINKER(config);
}
-}, '@VERSION@', {requires:['base','node','io-base','json-parse','event-delegate','overlay','moodle-enrol-notification']});
+}, '@VERSION@', {requires:['base','node','io-base','json-parse','event-delegate','overlay','moodle-core-notification']});
// Set sources to populate the data
- $filling->set_source_table('gradingform_rubric_fillings',
- array('instanceid' => backup::VAR_PARENTID));
+ // Binding criterionid to ensure it's existence
+ $filling->set_source_sql('SELECT rf.*
+ FROM {gradingform_rubric_fillings} rf
+ JOIN {grading_instances} gi ON gi.id = rf.instanceid
+ JOIN {gradingform_rubric_criteria} rc ON rc.id = rf.criterionid AND gi.definitionid = rc.definitionid
+ WHERE rf.instanceid = :instanceid',
+ array('instanceid' => backup::VAR_PARENTID));
// no need to annotate ids or files yet (one day when remark field supports
// embedded fileds, they must be annotated here)
$data->criterionid = $this->get_mappingid('gradingform_rubric_criterion', $data->criterionid);
$data->levelid = $this->get_mappingid('gradingform_rubric_level', $data->levelid);
- $DB->insert_record('gradingform_rubric_fillings', $data);
+ if (!empty($data->criterionid)) {
+ $DB->insert_record('gradingform_rubric_fillings', $data);
+ }
+
}
}
return $this->get_instance($instance);
}
if ($itemid && $raterid) {
- if ($rs = $DB->get_records('grading_instances', array('raterid' => $raterid, 'itemid' => $itemid), 'timemodified DESC', '*', 0, 1)) {
+ $params = array('definitionid' => $this->definition->id, 'raterid' => $raterid, 'itemid' => $itemid);
+ if ($rs = $DB->get_records('grading_instances', $params, 'timemodified DESC', '*', 0, 1)) {
$record = reset($rs);
$currentinstance = $this->get_current_instance($raterid, $itemid);
if ($record->status == gradingform_rubric_instance::INSTANCE_STATUS_INCOMPLETE &&
$string['messagehistoryfull'] = 'All messages';
$string['messages'] = 'Messages';
$string['messaging'] = 'Messaging';
+$string['messagingblockednoncontact'] = '{$a} will not be able to reply as you have blocked non-contacts';
$string['messagingdisabled'] = 'Messaging is disabled on this site, emails will be sent instead';
$string['mycontacts'] = 'My contacts';
$string['newonlymsg'] = 'Show only new';
$string['unreadnewnotification'] = 'New notification';
$string['unreadnewnotifications'] = 'New notifications ({$a})';
$string['userisblockingyou'] = 'This user has blocked you from sending messages to them';
-$string['userisblockingyounoncontact'] = 'This user is only accepting messages from people listed as contacts, and you are not currently on the list.';
+$string['userisblockingyounoncontact'] = '{$a} only accepts messages from their contacts.';
$string['userssearchresults'] = 'Users found: {$a}';
$string['list'] = 'List';
$string['listfiles'] = 'List of files in {$a}';
$string['listofallpeople'] = 'List of all people';
+$string['listofcourses'] = 'List of courses';
$string['local'] = 'Local';
$string['localplugindeleteconfirm'] = 'You are about to completely delete the local plugin \'{$a}\'. This will completely delete everything in the database associated with this plugin. Are you SURE you want to continue?';
$string['localplugins'] = 'Local plugins';
$string['migratinggrades'] = 'Migrating grades';
$string['min'] = 'min';
$string['mins'] = 'mins';
+$string['minute'] = 'minute';
$string['minutes'] = 'minutes';
$string['miscellaneous'] = 'Miscellaneous';
$string['missingcategory'] = 'You need to choose a category';
$string['missingurl'] = 'Missing URL';
$string['missingusername'] = 'Missing username';
$string['moddoesnotsupporttype'] = 'Module {$a->modname} does not support uploads of type {$a->type}';
+$string['month'] = 'Month';
+$string['months'] = 'Months';
$string['modified'] = 'Modified';
$string['modchooserenable'] = 'Activity chooser on';
$string['modchooserdisable'] = 'Activity chooser off';
$string['olduserdirectory'] = 'This is the OLD users directory, and is no longer needed. You may safely delete it. The files it contains have been copied to the NEW user directory.';
$string['opentoguests'] = 'Guest access';
$string['optional'] = 'optional';
+$string['options'] = 'options';
$string['order'] = 'Order';
$string['originalpath'] = 'Original path';
$string['orphanedactivities'] = 'Orphaned activities';
$string['screenreaderyes'] = 'Yes';
$string['screenreaderuse_help'] = 'If set to yes, a more accessible interface is provided in various places such as chat.';
$string['screenshot'] = 'Screenshot';
-$string['search'] = 'Search'; // TODO rename to searchforums and move to mod_forum
+$string['search'] = 'Search'; // TODO MDL-34652 rename to searchforums and move to mod_forum
$string['search_help'] = 'For basic searching of one or more words anywhere in the text, just type them separated by spaces. All words longer than two characters are used.
For advanced searching, press the search button without typing anything in the search box to access the advanced search form.';
$string['seealsostats'] = 'See also: stats';
$string['select'] = 'Select';
$string['selectacountry'] = 'Select a country';
+$string['selectacourse'] = 'Select a course';
+$string['selectacoursesite'] = 'Select a course or site';
+$string['selectanaction'] = 'Select an action';
+$string['selectagroup'] = 'Select a group';
$string['selectaregion'] = 'Select a region';
+$string['selctauser'] = 'Select a user';
$string['selectall'] = 'Select all';
$string['selectamodule'] = 'Please select an activity module';
+$string['selectanoptions'] = 'Select an options';
$string['selectdefault'] = 'Select default';
$string['selectedfile'] = 'Selected file';
$string['selectednowmove'] = '{$a} files selected for moving. Now go into the destination folder and press \'Move files to here\'';
$string['serverlocaltime'] = 'Server\'s local time';
$string['setcategorytheme'] = 'Set category theme';
$string['settings'] = 'Settings';
-$string['shortname'] = 'Short name'; // @deprecated - use shortnamecourse or shortnameuser or some own context specific string
+$string['shortname'] = 'Short name'; // @deprecated MDL-34652 - use shortnamecourse or shortnameuser or some own context specific string
$string['shortnamecollisionwarning'] = '[*] = This shortname is already in use by a course and will need to be changed upon approval';
$string['shortnamecourse'] = 'Course short name';
$string['shortnamecourse_help'] = 'The short name of the course is displayed in the navigation and is used in the subject line of course email messages.';
$string['downloadcsv'] = 'a comma separated values text file';
$string['downloadexcel'] = 'a Microsoft Excel spreadsheet';
$string['downloadods'] = 'an OpenDocument Spreadsheet (ODS)';
+$string['downloadoptions'] = 'Select download options';
$string['downloadtsv'] = 'a tab separated values text file';
$string['downloadxhtml'] = 'an unpaged XHTML document';
function admin_critical_warnings_present() {
global $SESSION;
- if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+ if (!has_capability('moodle/site:config', context_system::instance())) {
return 0;
}
*/
public function check_access() {
global $CFG;
- $context = empty($this->context) ? get_context_instance(CONTEXT_SYSTEM) : $this->context;
+ $context = empty($this->context) ? context_system::instance() : $this->context;
foreach($this->req_capability as $cap) {
if (has_capability($cap, $context)) {
return true;
*/
public function check_access() {
global $CFG;
- $context = empty($this->context) ? get_context_instance(CONTEXT_SYSTEM) : $this->context;
+ $context = empty($this->context) ? context_system::instance() : $this->context;
foreach($this->req_capability as $cap) {
if (has_capability($cap, $context)) {
return true;
if (is_array($this->choices)) {
return true;
}
- $users = get_users_by_capability(get_context_instance(CONTEXT_SYSTEM),
+ $users = get_users_by_capability(context_system::instance(),
$this->capability, 'u.id,u.username,u.firstname,u.lastname', 'u.lastname,u.firstname');
$this->choices = array(
'$@NONE@$' => get_string('nobody'),
// This identifies the block instance requesting AJAX extension
$instanceid = optional_param('instance', null, PARAM_INT);
- $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
+ $PAGE->set_context(context_system::instance());
// Create a global nav object
$navigation = new global_navigation_for_ajax($PAGE, $branchtype, $branchid);
$blockinstance->id = $DB->insert_record('block_instances', $blockinstance);
// Ensure the block context is created.
- get_context_instance(CONTEXT_BLOCK, $blockinstance->id);
+ context_block::instance($blockinstance->id);
// If the new instance was created, allow it to do additional setup
if ($block = block_instance($blockname, $blockinstance)) {
$bi->subpagepattern = $data->bui_subpagepattern;
}
- $systemcontext = get_context_instance(CONTEXT_SYSTEM);
- $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
+ $systemcontext = context_system::instance();
+ $frontpagecontext = context_course::instance(SITEID);
$parentcontext = get_context_instance_by_id($data->bui_parentcontextid);
// Updating stickiness and contexts. See MDL-21375 for details.
global $DB;
$page = new moodle_page();
- $page->set_context(get_context_instance(CONTEXT_SYSTEM));
+ $page->set_context(context_system::instance());
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('navigation', 'settings')), '*', null, true);
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('admin_bookmarks')), 'admin-*', null, null, 2);
return $DB->get_records_sql($sql, $params);
} else {
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = context_course::instance($courseid);
$contextlists = get_related_contexts_string($context);
$sql = "SELECT u.id, u.firstname, u.lastname, u.email
context_instance_preload($course);
if (isset($course->visible) && $course->visible <= 0) {
// for hidden courses, require visibility check
- if (has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) {
$visiblecourses [$course->id] = $course;
}
} else {
context_instance_preload($course);
if ($course->visible <= 0) {
// for hidden courses, require visibility check
- if (has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) {
$totalcount++;
if ($totalcount > $limitfrom && (!$limitnum or count($visiblecourses) < $limitnum)) {
$visiblecourses [$course->id] = $course;
// managers efficiently later...
foreach ($courses as $k => $course) {
context_instance_preload($course);
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
$courses[$k] = $course;
$courses[$k]->managers = array();
if ($allcats === false) {
}
} else {
foreach ($courses as $k => $course) {
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
// Note that strpos() returns 0 as "matched at pos 0"
if (strpos($coursecontext->path, $ra->path.'/') === 0) {
// Only add it to subpaths
$rs = $DB->get_recordset_sql($sql, $params);
foreach($rs as $course) {
context_instance_preload($course);
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
if ($course->visible || has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
// Don't exit this loop till the end
// we need to count all the visible courses
$rs = $DB->get_recordset_sql($sql, $params);
foreach($rs as $cat) {
context_instance_preload($cat);
- $catcontext = get_context_instance(CONTEXT_COURSECAT, $cat->id);
+ $catcontext = context_coursecat::instance($cat->id);
if ($cat->visible || has_capability('moodle/category:viewhiddencategories', $catcontext)) {
$categories[$cat->id] = $cat;
}
$cat->timemodified = time();
$catid = $DB->insert_record('course_categories', $cat);
// make sure category context exists
- get_context_instance(CONTEXT_COURSECAT, $catid);
+ context_coursecat::instance($catid);
mark_context_dirty('/'.SYSCONTEXTID);
fix_course_sortorder(); // Required to build course_categories.depth and .path.
$category = $DB->get_record('course_categories', array('id'=>$catid));
$defaultcat = reset($topcats);
foreach ($frontcourses as $course) {
$DB->set_field('course', 'category', $defaultcat->id, array('id'=>$course->id));
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $context = context_course::instance($course->id);
$fixcontexts[$context->id] = $context;
}
unset($frontcourses);
$update = true;
// make sure context caches are rebuild and dirty contexts marked
- $context = get_context_instance(CONTEXT_COURSECAT, $cat->id);
+ $context = context_coursecat::instance($cat->id);
$fixcontexts[$context->id] = $context;
}
if ($cat->sortorder != $sortorder) {
if (empty($userid)) {
$userid = $USER->id;
}
- if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id), $userid)) {
+ if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', context_module::instance($cm->id), $userid)) {
return false;
}
if ($CFG->enableavailability) {
$ci=new condition_info($cm,CONDITION_MISSING_EXTRATABLE);
if(!$ci->is_available($cm->availableinfo,false,$userid) and
!has_capability('moodle/course:viewhiddenactivities',
- get_context_instance(CONTEXT_MODULE, $cm->id), $userid)) {
+ context_module::instance($cm->id), $userid)) {
return false;
}
}
global $DB;
$catsrs = $DB->get_recordset('course_categories');
foreach ($catsrs as $cat) {
- if (has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $cat->id))) {
+ if (has_capability('moodle/course:create', context_coursecat::instance($cat->id))) {
$catsrs->close();
return true;
}
* @return bool always true
*/
function xmldb_main_upgrade($oldversion) {
- global $CFG, $USER, $DB, $OUTPUT;
+ global $CFG, $USER, $DB, $OUTPUT, $SITE;
require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
upgrade_main_savepoint(true, 2012072401.00);
}
+ if ($oldversion < 2012072600.01) {
+ // Handle events with empty eventtype //MDL-32827
+
+ $DB->set_field('event', 'eventtype', 'site', array('eventtype' => '', 'courseid' => $SITE->id));
+ $DB->set_field_select('event', 'eventtype', 'due', "eventtype = '' AND courseid != 0 AND groupid = 0 AND (modulename = 'assignment' OR modulename = 'assign')");
+ $DB->set_field_select('event', 'eventtype', 'course', "eventtype = '' AND courseid != 0 AND groupid = 0");
+ $DB->set_field_select('event', 'eventtype', 'group', "eventtype = '' AND groupid != 0");
+ $DB->set_field_select('event', 'eventtype', 'user', "eventtype = '' AND userid != 0");
+
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2012072600.01);
+ }
return true;
}
$courseid = $COURSE->id;
}
- if (!$context = get_context_instance(CONTEXT_COURSE, $courseid)) {
+ if (!$context = context_course::instance($courseid, IGNORE_MISSING)) {
return $text;
}
* @return array of user
*/
function get_course_participants($courseid) {
- return get_enrolled_users(get_context_instance(CONTEXT_COURSE, $courseid));
+ return get_enrolled_users(context_course::instance($courseid));
}
/**
* @return boolean
*/
function is_course_participant($userid, $courseid) {
- return is_enrolled(get_context_instance(CONTEXT_COURSE, $courseid), $userid);
+ return is_enrolled(context_course::instance($courseid), $userid);
}
/**
function get_recent_enrolments($courseid, $timestart) {
global $DB;
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = context_course::instance($courseid);
$sql = "SELECT u.id, u.firstname, u.lastname, MAX(l.time)
FROM {user} u, {role_assignments} ra, {log} l
//NOTE: DO NOT call new output method because it needs the module name we do not have here!
- if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $cmid))) {
+ if (has_capability('moodle/course:manageactivities', context_module::instance($cmid))) {
$string = get_string('updatethis', '', $string);
$url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey()));
$lang = current_language();
$contentcss = $PAGE->theme->editor_css_url()->out(false);
- $context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
+ $context = empty($options['context']) ? context_system::instance() : $options['context'];
$config = get_config('editor_tinymce');
'theme_advanced_fonts' => $fontselectlist,
'theme_advanced_resize_horizontal' => true,
'theme_advanced_resizing' => true,
+ 'theme_advanced_resizing_min_height' => 30,
'min_height' => 30,
'theme_advanced_toolbar_location' => "top",
'theme_advanced_statusbar_location' => "bottom",
function enrol_add_course_navigation(navigation_node $coursenode, $course) {
global $CFG;
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
$instances = enrol_get_instances($course->id, true);
$plugins = enrol_get_plugins(true);
foreach ($courses as $id=>$course) {
context_instance_preload($course);
if (!$course->visible) {
- if (!$context = get_context_instance(CONTEXT_COURSE, $id)) {
+ if (!$context = context_course::instance($id, IGNORE_MISSING)) {
unset($courses[$id]);
continue;
}
$enrol = $this->get_name();
return get_string('pluginname', 'enrol_'.$enrol);
} else {
- $context = get_context_instance(CONTEXT_COURSE, $instance->courseid);
+ $context = context_course::instance($instance->courseid);
return format_string($instance->name, true, array('context'=>$context));
}
}
if ($instance->enrol !== $name) {
throw new coding_exception('invalid enrol instance!');
}
- $context = get_context_instance(CONTEXT_COURSE, $instance->courseid, MUST_EXIST);
+ $context = context_course::instance($instance->courseid, MUST_EXIST);
$inserted = false;
$updated = false;
if ($instance->enrol !== $name) {
throw new coding_exception('invalid enrol instance!');
}
- $context = get_context_instance(CONTEXT_COURSE, $instance->courseid, MUST_EXIST);
+ $context = context_course::instance($instance->courseid, MUST_EXIST);
if (!$ue = $DB->get_record('user_enrolments', array('enrolid'=>$instance->id, 'userid'=>$userid))) {
// weird, user not enrolled
return NULL;
}
- $context = get_context_instance(CONTEXT_COURSE, $instance->courseid, MUST_EXIST);
+ $context = context_course::instance($instance->courseid, MUST_EXIST);
if (!has_capability("enrol/$name:unenrolself", $context)) {
return NULL;
throw new invalid_parameter_exception('Context does not exist');
}
if (empty(self::$contextrestriction)) {
- self::$contextrestriction = get_context_instance(CONTEXT_SYSTEM);
+ self::$contextrestriction = context_system::instance();
}
$rcontext = self::$contextrestriction;
*/
public function get_file_info($context = NULL, $component = NULL, $filearea = NULL, $itemid = NULL, $filepath = NULL, $filename = NULL) {
if (!$context) {
- $context = get_context_instance(CONTEXT_SYSTEM);
+ $context = context_system::instance();
}
switch ($context->contextlevel) {
case CONTEXT_SYSTEM:
if (empty($cminfo->uservisible)) {
continue;
}
- $modcontext = get_context_instance(CONTEXT_MODULE, $cminfo->id);
+ $modcontext = context_module::instance($cminfo->id, IGNORE_MISSING);
if ($child = $this->browser->get_file_info($modcontext)) {
$children[] = $child;
}
if (empty($component)) {
// we can not list the category contents, so try parent, or top system
if ($this->category->parent and $pc = $DB->get_record('course_categories', array('id'=>$this->category->parent))) {
- $parent = get_context_instance(CONTEXT_COURSECAT, $pc->id);
+ $parent = context_coursecat::instance($pc->id, IGNORE_MISSING);
return $this->browser->get_file_info($parent);
} else {
return $this->browser->get_file_info();
$course_cats = $DB->get_records('course_categories', array('parent'=>$this->category->id), 'sortorder', 'id,visible');
foreach ($course_cats as $category) {
- $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
+ $context = context_coursecat::instance($category->id);
if (!$category->visible and !has_capability('moodle/category:viewhiddencategories', $context)) {
continue;
}
$courses = $DB->get_records('course', array('category'=>$this->category->id), 'sortorder', 'id,visible');
foreach ($courses as $course) {
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $context = context_course::instance($course->id);
if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
continue;
}
$course_cats = $DB->get_records('course_categories', array('parent'=>0), 'sortorder', 'id,visible');
foreach ($course_cats as $category) {
- $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
+ $context = context_coursecat::instance($category->id);
if (!$category->visible and !has_capability('moodle/category:viewhiddencategories', $context)) {
continue;
}
if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
continue;
}
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $context = context_course::instance($course->id);
if ($child = $this->browser->get_file_info($context)) {
$children[] = $child;
}
print_error('noguest');
}
- $contextid = get_context_instance(CONTEXT_USER, $USER->id)->id;
+ $contextid = context_user::instance($USER->id)->id;
$fs = get_file_storage();
$draftitemid = rand(1, 999999999);
$options['forcehttps'] = false;
}
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
if (empty($draftitemid)) {
function file_get_draft_area_info($draftitemid) {
global $CFG, $USER;
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$results = array();
function file_get_user_used_space() {
global $DB, $USER;
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$sql = "SELECT SUM(files1.filesize) AS totalbytes FROM {files} files1
JOIN (SELECT contenthash, filename, MAX(id) AS id
FROM {files}
function file_get_drafarea_folders($draftitemid, $filepath, &$data) {
global $USER, $OUTPUT, $CFG;
$data->children = array();
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
$fs = get_file_storage();
if ($files = $fs->get_directory_files($context->id, 'user', 'draft', $draftitemid, $filepath, false)) {
foreach ($files as $file) {
function file_get_drafarea_files($draftitemid, $filepath = '/') {
global $USER, $OUTPUT, $CFG;
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
$fs = get_file_storage();
$data = new stdClass();
function file_save_draft_area_files($draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null, $forcehttps=false) {
global $USER;
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$options = (array)$options;
function file_rewrite_urls_to_pluginfile($text, $draftitemid, $forcehttps = false) {
global $CFG, $USER;
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$wwwroot = $CFG->wwwroot;
if ($forcehttps) {
while (!$canview && count($courses) > 0) {
$course = array_shift($courses);
- if (has_capability('moodle/user:viewdetails', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (has_capability('moodle/user:viewdetails', context_course::instance($course->id))) {
$canview = true;
}
}
} else if ($filearea === 'profile' and $context->contextlevel == CONTEXT_COURSE) {
$userid = (int)array_shift($args);
- $usercontext = get_context_instance(CONTEXT_USER, $userid);
+ $usercontext = context_user::instance($userid);
if ($CFG->forcelogin) {
require_login();
foreach($archivefiles as $file) {
$this->assertArrayHasKey($file->pathname, $this->files);
}
+
+ // Test invalid files parameter.
+ $archive = "$CFG->tempdir/archive2.zip";
+ $this->assertFalse(file_exists($archive));
+
+ $this->assertFalse(file_exists(__DIR__.'/xx/yy/ee.txt'));
+ $files = array('xtest.txt'=>__DIR__.'/xx/yy/ee.txt');
+ ob_start();
+ $result = $packer->archive_to_pathname($files, $archive);
+ $d = ob_end_clean();
+ $this->assertTrue($d !== '');
+ $this->assertFalse($result);
+
+ $this->assertTrue(file_exists(__DIR__.'/fixtures/test.txt'));
+ $files = array();
+ $files['""""'] = null; // Invalid directory name.
+ $files['test.txt'] = __DIR__.'/fixtures/test.txt';
+ ob_start();
+ $result = $packer->archive_to_pathname($files, $archive);
+ $d = ob_end_clean();
+ $this->assertTrue($d !== '');
+ $this->assertTrue($result);
+
+ @unlink($archive);
}
/**
return false;
}
+ $result = false; // One processed file or dir means success here.
+
foreach ($files as $archivepath => $file) {
$archivepath = trim($archivepath, '/');
if (is_null($file)) {
// empty directories have null as content
- $ziparch->add_directory($archivepath.'/');
+ if ($ziparch->add_directory($archivepath.'/')) {
+ $result = true;
+ } else {
+ debugging("Can not zip '$archivepath' directory", DEBUG_DEVELOPER);
+ }
} else if (is_string($file)) {
- $this->archive_pathname($ziparch, $archivepath, $file);
+ if ($this->archive_pathname($ziparch, $archivepath, $file)) {
+ $result = true;
+ } else {
+ debugging("Can not zip '$archivepath' file", DEBUG_DEVELOPER);
+ }
} else if (is_array($file)) {
$content = reset($file);
- $ziparch->add_file_from_string($archivepath, $content);
+ if ($ziparch->add_file_from_string($archivepath, $content)) {
+ $result = true;
+ } else {
+ debugging("Can not zip '$archivepath' file", DEBUG_DEVELOPER);
+ }
} else {
- $this->archive_stored($ziparch, $archivepath, $file);
+ if ($this->archive_stored($ziparch, $archivepath, $file)) {
+ $result = true;
+ } else {
+ debugging("Can not zip '$archivepath' file", DEBUG_DEVELOPER);
+ }
}
}
- return $ziparch->close();
+ return ($ziparch->close() && $result);
}
/**
* @param zip_archive $ziparch zip archive instance
* @param string $archivepath file path to archive
* @param stored_file $file stored_file object
+ * @return bool success
*/
private function archive_stored($ziparch, $archivepath, $file) {
- $file->archive_file($ziparch, $archivepath);
+ $result = $file->archive_file($ziparch, $archivepath);
+ if (!$result) {
+ return false;
+ }
if (!$file->is_directory()) {
- return;
+ return true;
}
$baselength = strlen($file->get_filepath());
if (!$file->is_directory()) {
$path = $path.$file->get_filename();
}
+ // Ignore result here, partial zipping is ok for now.
$file->archive_file($ziparch, $path);
}
+
+ return true;
}
/**
* @param zip_archive $ziparch zip archive instance
* @param string $archivepath file path to archive
* @param string $file path name of the file
+ * @return bool success
*/
private function archive_pathname($ziparch, $archivepath, $file) {
if (!file_exists($file)) {
- return;
+ return false;
}
if (is_file($file)) {
if (!is_readable($file)) {
- return;
+ return false;
}
- $ziparch->add_file_from_pathname($archivepath, $file);
- return;
+ return $ziparch->add_file_from_pathname($archivepath, $file);
}
if (is_dir($file)) {
if ($archivepath !== '') {
$this->archive_pathname($ziparch, $newpath, $file->getPathname());
}
unset($files); //release file handles
- return;
+ return true;
}
}
}
// See if there is an existing record.
- $syscontext = get_context_instance(CONTEXT_SYSTEM);
+ $syscontext = context_system::instance();
$rec = $DB->get_record('filter_active', array('filter' => $filter, 'contextid' => $syscontext->id));
if (empty($rec)) {
$insert = true;
"Must be one of TEXTFILTER_ON, TEXTFILTER_OFF or TEXTFILTER_INHERIT.");
}
- if ($contextid == get_context_instance(CONTEXT_SYSTEM)->id) {
+ if ($contextid == context_system::instance()->id) {
throw new coding_exception('You cannot use filter_set_local_state ' .
'with $contextid equal to the system context id.');
}
*/
function filter_get_all_local_settings($contextid) {
global $DB;
- $context = get_context_instance(CONTEXT_SYSTEM);
+ $context = context_system::instance();
return array(
$DB->get_records('filter_active', array('contextid' => $contextid), 'filter', 'filter,active'),
$DB->get_records('filter_config', array('contextid' => $contextid), 'filter,name', 'filter,name,value'),
$cmcontexts = array();
$cmcontextids = array();
foreach ($modinfo->get_cms() as $cm) {
- $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modulecontext = context_module::instance($cm->id);
$cmcontextids[] = $modulecontext->id;
$cmcontexts[] = $modulecontext;
}
// Get course context and all other parents...
- $coursecontext = get_context_instance(CONTEXT_COURSE, $modinfo->get_course_id());
+ $coursecontext = context_course::instance($modinfo->get_course_id());
$parentcontextids = explode('/', substr($coursecontext->path, 1));
$allcontextids = array_merge($cmcontextids, $parentcontextids);
*/
function filter_get_global_states() {
global $DB;
- $context = get_context_instance(CONTEXT_SYSTEM);
+ $context = context_system::instance();
return $DB->get_records('filter_active', array('contextid' => $context->id), 'sortorder', 'filter,active,sortorder');
}
$this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
}
if (!$this->_options['context']) {
- $this->_options['context'] = get_context_instance(CONTEXT_SYSTEM);
+ $this->_options['context'] = context_system::instance();
}
$this->_options['trusted'] = trusttext_trusted($this->_options['context']);
parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
$str .= '<div>';
if (count($formats)>1) {
- $str.= html_writer::select($formats, $elname.'[format]', $format, false);
+ $str .= html_writer::label(get_string('format'), 'menu'. $elname. 'format', false, array('class' => 'accesshide'));
+ $str .= html_writer::select($formats, $elname.'[format]', $format, false, array('id' => 'menu'. $elname. 'format'));
} else {
$keys = array_keys($formats);
- $str.= html_writer::empty_tag('input',
+ $str .= html_writer::empty_tag('input',
array('name'=>$elname.'[format]', 'type'=> 'hidden', 'value' => array_pop($keys)));
}
$str .= '</div>';
$this->options = file_get_drafarea_files($options->itemid, '/');
// calculate file count
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id', false);
$filecount = count($files);
$this->options->filecount = $filecount;
}
if ($COURSE->id == SITEID) {
- $context = get_context_instance(CONTEXT_SYSTEM);
+ $context = context_system::instance();
} else {
- $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
+ $context = context_course::instance($COURSE->id);
}
$client_id = uniqid();
// make sure max one file is present and it is not too big
if (!is_null($draftitemid)) {
$fs = get_file_storage();
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) {
$file = array_shift($files);
if ($this->_options['maxbytes']
// If the user can manage official tags, give them a link to manage them.
$label = get_string('otags', 'tag');
- if (has_capability('moodle/tag:manage', get_context_instance(CONTEXT_SYSTEM))) {
+ if (has_capability('moodle/tag:manage', context_system::instance())) {
$url = $CFG->wwwroot .'/tag/manage.php';
$label .= ' (' . $OUTPUT->action_link(
$url,
$strsaved = get_string('filesaved', 'repository');
$straddlink = get_string('choosealink', 'repository');
if ($COURSE->id == SITEID) {
- $context = get_context_instance(CONTEXT_SYSTEM);
+ $context = context_system::instance();
} else {
- $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
+ $context = context_course::instance($COURSE->id);
}
$client_id = uniqid();
if ($rule['type'] == 'required') {
$draftid = (int)$mform->getSubmitValue($elementname);
$fs = get_file_storage();
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
$errors[$elementname] = $rule['message'];
}
}
$draftid = $values[$elname];
$fs = get_file_storage();
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
return false;
}
}
$draftid = $values[$elname];
$fs = get_file_storage();
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
return false;
}
}
$draftid = $values[$elname];
$fs = get_file_storage();
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
return null;
}
return false;
}
$draftid = $values[$elname];
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
if (!$files = $fs->get_area_files($context->id, 'user' ,'draft', $draftid, 'id DESC', false)) {
return false;
}
}
$draftid = $values[$elname];
$fs = get_file_storage();
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
if (!$files = $fs->get_area_files($context->id, 'user', 'draft', $draftid, 'id DESC', false)) {
return false;
}
$DB->delete_records('grade_outcomes_courses', array('outcomeid' => $this->id, 'courseid' => $this->courseid));
}
if (parent::delete($source)) {
- $context = get_context_instance(CONTEXT_SYSTEM);
+ $context = context_system::instance();
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'grade', 'outcome', $this->id);
foreach ($files as $file) {
$options = new stdClass;
$options->noclean = true;
- $systemcontext = get_context_instance(CONTEXT_SYSTEM);
+ $systemcontext = context_system::instance();
$description = file_rewrite_pluginfile_urls($this->description, 'pluginfile.php', $systemcontext->id, 'grade', 'outcome', $this->id);
return format_text($description, $this->descriptionformat, $options);
}
public function delete($source=null) {
global $DB;
if (parent::delete($source)) {
- $context = get_context_instance(CONTEXT_SYSTEM);
+ $context = context_system::instance();
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'grade', 'scale', $this->id);
foreach ($files as $file) {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
- $systemcontext = get_context_instance(CONTEXT_SYSTEM);
+ $systemcontext = context_system::instance();
$options = new stdClass;
$options->noclean = true;
$description = file_rewrite_pluginfile_urls($this->description, 'pluginfile.php', $systemcontext->id, 'grade', 'scale', $this->id);
* @return string
*/
function grade_format_gradevalue_letter($value, $grade_item) {
- $context = get_context_instance(CONTEXT_COURSE, $grade_item->courseid);
+ $context = context_course::instance($grade_item->courseid, IGNORE_MISSING);
if (!$letters = grade_get_letters($context)) {
return ''; // no letters??
}
//Check the user is enrolled in this course
//Dont bother checking if they have a gradeable role. They may get one later so recover
//whatever grades they have now just in case.
- $course_context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $course_context = context_course::instance($courseid);
if (!is_enrolled($course_context, $userid)) {
debugging('Attempting to recover the grades of a user who is deleted or not enrolled. Skipping recover.');
return false;
$course_category = grade_category::fetch_course_category($courseid);
$course_category->delete('coursedelete');
- $fs->delete_area_files(get_context_instance(CONTEXT_COURSE, $courseid)->id, 'grade', 'feedback');
+ $fs->delete_area_files(context_course::instance($courseid)->id, 'grade', 'feedback');
if ($showfeedback) {
echo $OUTPUT->notification($strdeleted.' - '.get_string('grades', 'grades').', '.get_string('items', 'grades').', '.get_string('categories', 'grades'), 'notifysuccess');
}
function grade_course_category_delete($categoryid, $newparentid, $showfeedback) {
global $DB;
- $context = get_context_instance(CONTEXT_COURSECAT, $categoryid);
+ $context = context_coursecat::instance($categoryid);
$DB->delete_records('grade_letters', array('contextid'=>$context->id));
}
}
}
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $context = context_course::instance($course->id);
$aag = has_capability('moodle/site:accessallgroups', $context);
if ($groupmode == VISIBLEGROUPS or $aag) {
}
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$aag = has_capability('moodle/site:accessallgroups', $context);
if ($groupmode == VISIBLEGROUPS or $aag) {
return false;
}
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $context = context_course::instance($course->id);
if (has_capability('moodle/site:accessallgroups', $context)) {
$groupmode = 'aag';
}
return false;
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
if (has_capability('moodle/site:accessallgroups', $context)) {
$groupmode = 'aag';
}
// If visible groups mode, or user has the accessallgroups capability,
// then they can access all groups for the activity...
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $context)) {
return groups_get_all_groups($cm->course, 0, $cm->groupingid);
} else {
if (empty($cm->groupmembersonly)) {
return true;
}
- if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id), $userid) or groups_has_membership($cm, $userid)) {
+ if (has_capability('moodle/site:accessallgroups', context_module::instance($cm->id), $userid) or groups_has_membership($cm, $userid)) {
return true;
}
return false;
function message_get_providers_for_user($userid) {
global $DB, $CFG;
- $systemcontext = get_context_instance(CONTEXT_SYSTEM);
+ $systemcontext = context_system::instance();
$providers = get_message_providers();
$this->icon = isset($mod->icon) ? $mod->icon : '';
$this->iconcomponent = isset($mod->iconcomponent) ? $mod->iconcomponent : '';
$this->customdata = isset($mod->customdata) ? $mod->customdata : '';
- $this->context = get_context_instance(CONTEXT_MODULE, $mod->cm);
+ $this->context = context_module::instance($mod->cm);
$this->showdescription = isset($mod->showdescription) ? $mod->showdescription : 0;
$this->state = self::STATE_BASIC;
*/
private function update_user_visible() {
global $CFG;
- $modcontext = get_context_instance(CONTEXT_MODULE, $this->id);
+ $modcontext = context_module::instance($this->id);
$userid = $this->modinfo->get_user_id();
$this->uservisible = true;
// Check visibility/availability conditions.
* @param string $type PARAM_ constant
* @param bool $allownull are nulls valid value?
* @param string $debuginfo optional debug information
- * @return mixed the $param value converted to PHP type or invalid_parameter_exception
+ * @return mixed the $param value converted to PHP type
+ * @throws invalid_parameter_exception if $param is not of given type
*/
function validate_param($param, $type, $allownull=NULL_NOT_ALLOWED, $debuginfo='') {
if (is_null($param)) {
}
$cleaned = clean_param($param, $type);
- if ((string)$param !== (string)$cleaned) {
+
+ if ($type == PARAM_FLOAT) {
+ // Do not detect precision loss here.
+ if (is_float($param) or is_int($param)) {
+ // These always fit.
+ } else if (!is_numeric($param) or !preg_match('/^[\+-]?[0-9]*\.?[0-9]*(e[-+]?[0-9]+)?$/i', (string)$param)) {
+ throw new invalid_parameter_exception($debuginfo);
+ }
+ } else if ((string)$param !== (string)$cleaned) {
// conversion to string is usually lossless
throw new invalid_parameter_exception($debuginfo);
}
// we have to make sure that users still have the necessary capability,
// it should be faster to fetch them all first and then test if they are present
// instead of validating them one-by-one
- $users = get_users_by_capability(get_context_instance(CONTEXT_SYSTEM), $capability);
+ $users = get_users_by_capability(context_system::instance(), $capability);
if ($includeadmins) {
$admins = get_admins();
foreach ($admins as $admin) {
}
// Fetch the system context, the course context, and prefetch its child contexts
- $sysctx = get_context_instance(CONTEXT_SYSTEM);
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
+ $sysctx = context_system::instance();
+ $coursecontext = context_course::instance($course->id, MUST_EXIST);
if ($cm) {
- $cmcontext = get_context_instance(CONTEXT_MODULE, $cm->id, MUST_EXIST);
+ $cmcontext = context_module::instance($cm->id, MUST_EXIST);
} else {
$cmcontext = null;
}
return false;
}
}
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = context_course::instance($courseid);
// frontpage course can not be deleted!!
if ($courseid == SITEID) {
require_once($CFG->dirroot.'/group/lib.php');
$data->courseid = $data->id;
- $context = get_context_instance(CONTEXT_COURSE, $data->courseid);
+ $context = context_course::instance($data->courseid);
// calculate the time shift of dates
if (!empty($data->reset_start_date)) {
$site = get_site();
$supportuser = generate_email_supportuser();
- $systemcontext = get_context_instance(CONTEXT_SYSTEM);
+ $systemcontext = context_system::instance();
$data = new stdClass();
$data->firstname = $user->firstname;
$addedcategories[$category->id] = $categoryparent->add($category->name, $url, self::TYPE_CATEGORY, $category->name, $category->id);
if (!$category->visible) {
- if (!has_capability('moodle/category:viewhiddencategories', get_context_instance(CONTEXT_COURSECAT, $category->parent))) {
+ if (!has_capability('moodle/category:viewhiddencategories', context_coursecat::instance($category->parent))) {
$addedcategories[$category->id]->display = false;
} else {
$addedcategories[$category->id]->hidden = true;
$isparent = false;
if ($this->useridtouseforparentchecks) {
if ($this->useridtouseforparentchecks != $USER->id) {
- $usercontext = get_context_instance(CONTEXT_USER, $this->useridtouseforparentchecks, MUST_EXIST);
+ $usercontext = context_user::instance($this->useridtouseforparentchecks, MUST_EXIST);
if ($DB->record_exists('role_assignments', array('userid' => $USER->id, 'contextid' => $usercontext->id))
and has_capability('moodle/user:viewdetails', $usercontext)) {
$isparent = true;
continue;
}
context_instance_preload($course);
- if (!$course->visible && !is_role_switched($course->id) && !has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (!$course->visible && !is_role_switched($course->id) && !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) {
continue;
}
$coursenodes[$course->id] = $this->add_course($course);
break;
}
context_instance_preload($course);
- if (!$course->visible && !is_role_switched($course->id) && !has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (!$course->visible && !is_role_switched($course->id) && !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) {
continue;
}
$coursenodes[$course->id] = $this->add_course($course);
continue;
}
context_instance_preload($course);
- if (!$course->visible && !is_role_switched($course->id) && !has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (!$course->visible && !is_role_switched($course->id) && !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) {
continue;
}
$coursenodes[$course->id] = $this->add_course($course);
return;
}
$url = new moodle_url('/course/category.php', array('id' => $category->id));
- $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
+ $context = context_coursecat::instance($category->id);
$categoryname = format_string($category->name, true, array('context' => $context));
$categorynode = $parent->add($categoryname, $url, self::TYPE_CATEGORY, $categoryname, $category->id);
if (empty($category->visible)) {
}
// Prepare the default name and url for the node
- $activityname = format_string($activity->name, true, array('context' => get_context_instance(CONTEXT_MODULE, $activity->id)));
+ $activityname = format_string($activity->name, true, array('context' => context_module::instance($activity->id)));
$action = new moodle_url($activity->url);
// Check if the onclick property is set (puke!)
$iscurrentuser = ($user->id == $USER->id);
- $usercontext = get_context_instance(CONTEXT_USER, $user->id);
+ $usercontext = context_user::instance($user->id);
// Get the course set against the page, by default this will be the site
$course = $this->page->course;
if ($course->id != $SITE->id && (!$iscurrentuser || $forceforcontext)) {
$coursenode = $this->load_course($course);
$baseargs['course'] = $course->id;
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
$issitecourse = false;
} else {
// Load all categories and get the context for the system
- $coursecontext = get_context_instance(CONTEXT_SYSTEM);
+ $coursecontext = context_system::instance();
$issitecourse = true;
}
// If it's the current user the information will go under the profile root node
$usernode = $this->rootnodes['myprofile'];
$course = get_site();
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
$issitecourse = true;
} else {
if (!$issitecourse) {
$usernode->add(get_string('messages', 'message'), $url, self::TYPE_SETTING, null, 'messages');
}
- $context = get_context_instance(CONTEXT_USER, $USER->id);
+ $context = context_user::instance($USER->id);
if ($iscurrentuser && has_capability('moodle/user:manageownfiles', $context)) {
$url = new moodle_url('/user/files.php');
$usernode->add(get_string('myfiles'), $url, self::TYPE_SETTING);
$userscoursesnode = $usernode->add(get_string('courses'));
foreach ($userscourses as $usercourse) {
- $usercoursecontext = get_context_instance(CONTEXT_COURSE, $usercourse->id);
+ $usercoursecontext = context_course::instance($usercourse->id);
$usercourseshortname = format_string($usercourse->shortname, true, array('context' => $usercoursecontext));
$usercoursenode = $userscoursesnode->add($usercourseshortname, new moodle_url('/user/view.php', array('id'=>$user->id, 'course'=>$usercourse->id)), self::TYPE_CONTAINER);
return $this->addedcourses[$course->id];
}
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
if ($course->id != $SITE->id && !$course->visible) {
if (is_role_switched($course->id)) {
$coursenode = $parent->add($shortname, $url, self::TYPE_COURSE, $shortname, $course->id);
$coursenode->nodetype = self::NODETYPE_BRANCH;
$coursenode->hidden = (!$course->visible);
- $coursenode->title(format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))));
+ $coursenode->title(format_string($course->fullname, true, array('context' => context_course::instance($course->id))));
if (!$forcegeneric) {
$this->addedcourses[$course->id] = $coursenode;
}
}
$filterselect = clean_param($filterselect, PARAM_INT);
if (($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser())))
- and has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
+ and has_capability('moodle/blog:view', context_system::instance())) {
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
$participants->add(get_string('blogscourse','blog'), $blogsurls->out());
}
// Blogs
if (!empty($CFG->bloglevel)
and ($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser())))
- and has_capability('moodle/blog:view', get_context_instance(CONTEXT_SYSTEM))) {
+ and has_capability('moodle/blog:view', context_system::instance())) {
$blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect));
$coursenode->add(get_string('blogssite','blog'), $blogsurls->out());
}
case self::TYPE_COURSE :
$course = $DB->get_record('course', array('id' => $this->instanceid), '*', MUST_EXIST);
require_course_login($course, true, null, false, true);
- $this->page->set_context(get_context_instance(CONTEXT_COURSE, $course->id));
+ $this->page->set_context(context_course::instance($course->id));
$coursenode = $this->add_course($course);
$this->add_course_essentials($coursenode, $course);
if ($this->format_display_course_content($course->format)) {
WHERE cs.id = ?';
$course = $DB->get_record_sql($sql, array($this->instanceid), MUST_EXIST);
require_course_login($course, true, null, false, true);
- $this->page->set_context(get_context_instance(CONTEXT_COURSE, $course->id));
+ $this->page->set_context(context_course::instance($course->id));
$coursenode = $this->add_course($course);
$this->add_course_essentials($coursenode, $course);
$sections = $this->load_course_sections($course, $coursenode);
$modinfo = get_fast_modinfo($course);
$cm = $modinfo->get_cm($this->instanceid);
require_course_login($course, true, $cm, false, true);
- $this->page->set_context(get_context_instance(CONTEXT_MODULE, $cm->id));
+ $this->page->set_context(context_module::instance($cm->id));
$coursenode = $this->load_course($course);
if ($course->id == $SITE->id) {
$modulenode = $this->load_activity($cm, $course, $coursenode->find($cm->id, self::TYPE_ACTIVITY));
global $CFG;
$course = $this->page->course;
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
// note: do not test if enrolled or viewing here because we need the enrol link in Course administration section
$course = $SITE;
}
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // Course context
+ $coursecontext = context_course::instance($course->id); // Course context
$systemcontext = get_system_context();
$currentuser = ($USER->id == $userid);
if ($currentuser) {
$user = $USER;
- $usercontext = get_context_instance(CONTEXT_USER, $user->id); // User context
+ $usercontext = context_user::instance($user->id); // User context
} else {
$select = context_helper::get_preload_record_columns_sql('ctx');
$sql = "SELECT u.*, $select
context_helper::preload_from_record($user);
// Check that the user can view the profile
- $usercontext = get_context_instance(CONTEXT_USER, $user->id); // User context
+ $usercontext = context_user::instance($user->id); // User context
$canviewuser = has_capability('moodle/user:viewdetails', $usercontext);
if ($course->id == $SITE->id) {
if ($currentuser && !empty($CFG->bloglevel)) {
$blog = $usersetting->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER, null, 'blogs');
$blog->add(get_string('preferences', 'blog'), new moodle_url('/blog/preferences.php'), navigation_node::TYPE_SETTING);
- if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 && has_capability('moodle/blog:manageexternal', get_context_instance(CONTEXT_SYSTEM))) {
+ if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 && has_capability('moodle/blog:manageexternal', context_system::instance())) {
$blog->add(get_string('externalblogs', 'blog'), new moodle_url('/blog/external_blogs.php'), navigation_node::TYPE_SETTING);
$blog->add(get_string('addnewexternalblog', 'blog'), new moodle_url('/blog/external_blog_edit.php'), navigation_node::TYPE_SETTING);
}
global $SITE, $CFG;
$course = clone($SITE);
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // Course context
+ $coursecontext = context_course::instance($course->id); // Course context
$frontpage = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
if ($forceopen) {
$options->currentfile = '';
if (!empty($options->itemid)) {
$fs = get_file_storage();
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
if (empty($options->filename)) {
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id DESC', false)) {
$file = reset($files);
*/
var $label = '';
+ /**
+ * @var array Button label's attributes
+ */
+ var $labelattributes = array();
+
/**
* @var string Form submit method post or get
*/
* Sets select's label
*
* @param string $label
+ * @param array $attributes (optional)
*/
- public function set_label($label) {
+ public function set_label($label, $attributes = array()) {
$this->label = $label;
+ $this->labelattributes = $attributes;
+
}
}
*/
var $label = '';
+ /**
+ * @var array Button label's attributes
+ */
+ var $labelattributes = array();
+
/**
* @var string Wrapping div class
*/
* Sets select's label
*
* @param string $label
+ * @param array $attributes (optional)
*/
- public function set_label($label) {
+ public function set_label($label, $attributes = array()) {
$this->label = $label;