setcookie('MoodleSessionTest'.$CFG->sessioncookie, '', time() - 3600, '/');
/// switch to site language and locale
- if (!empty($CFG->courselang)) {
+ if (!empty($CFG->courselang)) {
unset ($CFG->courselang);
- }
+ }
if (!empty($SESSION->lang)) {
unset ($SESSION->lang);
}
ob_start(); //for whitespace test
require_once('../config.php');
- // extra whitespace test - intentionally breaks cookieless mode
- $extraws = '';
+ // extra whitespace test - intentionally breaks cookieless mode
+ $extraws = '';
while (true) {
$extraws .= ob_get_contents();
if (!@ob_end_clean()) { //
print_heading($strdatabasechecking);
$db->debug=true;
if (main_upgrade($CFG->version)) {
- if (empty($CFG->rolesactive)) {
- moodle_upgrade_roles_system_17();
- }
+ if (empty($CFG->rolesactive)) {
+ moodle_upgrade_roles_system_17();
+ }
if (!update_capabilities()) {
error('Had trouble upgrading the core capabilities for Roles');
}
/// Check for valid admin user
require_login();
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
- if (!isadmin()) {
+ if (!isadmin()) {
//if (!has_capability('moodle/site:config', $context->id)) {
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
}
/// Optional stuff
if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
$miscdata .= '<div class="adminlink"><a href="'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase').
- '</a> - <span class="explanation">'.get_string('adminhelpmanagedatabase').'</span></div>';
+ '</a> - <span class="explanation">'.get_string('adminhelpmanagedatabase').'</span></div>';
}
/// Hack to show the XMLDB editor
if (file_exists("$CFG->dirroot/$CFG->admin/xmldb")) {
$miscdata .= '<div class="adminlink"><a href="xmldb/index.php">'.get_string('xmldbeditor').
- '</a> - <span class="explanation">'.get_string('adminhelpxmldbeditor').'</span></div>';
+ '</a> - <span class="explanation">'.get_string('adminhelpxmldbeditor').'</span></div>';
}
$table->data[] = array('<strong><a href="misc.php">'.get_string('miscellaneous').'</a></strong>', $miscdata);
define("MAX_USERS_PER_PAGE", 5000);
$contextid = required_param('contextid',PARAM_INT); // context id
- $roleid = optional_param('roleid', 0, PARAM_INT); // required role id
+ $roleid = optional_param('roleid', 0, PARAM_INT); // required role id
$add = optional_param('add', 0, PARAM_BOOL);
$remove = optional_param('remove', 0, PARAM_BOOL);
$showall = optional_param('showall', 0, PARAM_BOOL);
$searchtext = optional_param('searchtext', '', PARAM_RAW); // search string
$previoussearch = optional_param('previoussearch', 0, PARAM_BOOL);
- $hidden = optional_param('hidden', 0, PARAM_BOOL); // whether this assignment is hidden
+ $hidden = optional_param('hidden', 0, PARAM_BOOL); // whether this assignment is hidden
$previoussearch = ($searchtext != '') or ($previoussearch) ? 1:0;
- $timestart = optional_param('timestart', 0, PARAM_INT);
- $timeend = optional_param('timened', 0, PARAM_INT);
+ $timestart = optional_param('timestart', 0, PARAM_INT);
+ $timeend = optional_param('timened', 0, PARAM_INT);
if (! $site = get_site()) {
redirect("$CFG->wwwroot/$CFG->admin/index.php");
}
/* permission check to see whether this user can assign people to this role
- * needs to be:
+ * needs to be:
* 1) has the capability to assign
* 2) not in role_deny_grant
* end of permission checking
- */
+ */
require_login($course->id);
error("You must be an editing teacher in this course, or an admin");
}
- $strassignusers = get_string('assignusers', 'role');
- $strpotentialusers = get_string('potentialusers', 'role');
- $strexistingusers = get_string('existingusers', 'role');
- $straction = get_string('assignroles', 'role');
- $strcurrentrole = get_string('currentrole', 'role');
- $strcurrentcontext = get_string('currentcontext', 'role');
- $strsearch = get_string('search');
- $strshowall = get_string('showall');
-
- $context = get_record('context', 'id', $contextid);
-
- $currenttab = '';
- $tabsmode = 'assign';
- include_once('tabs.php');
-
+ $strassignusers = get_string('assignusers', 'role');
+ $strpotentialusers = get_string('potentialusers', 'role');
+ $strexistingusers = get_string('existingusers', 'role');
+ $straction = get_string('assignroles', 'role');
+ $strcurrentrole = get_string('currentrole', 'role');
+ $strcurrentcontext = get_string('currentcontext', 'role');
+ $strsearch = get_string('search');
+ $strshowall = get_string('showall');
+
+ $context = get_record('context', 'id', $contextid);
+
+ $currenttab = '';
+ $tabsmode = 'assign';
+ include_once('tabs.php');
+
/// Don't allow restricted teachers to even see this page (because it contains
/// a lot of email addresses and access to all student on the server
} else {
if ($add and !empty($frm->addselect) and confirm_sesskey()) {
- //$timestart = ????
- // time end = ????
- $timemodified = time();
+ //$timestart = ????
+ // time end = ????
+ $timemodified = time();
foreach ($frm->addselect as $adduser) {
$adduser = clean_param($adduser, PARAM_INT);
if (! role_assign($roleid, $adduser, 0, $contextid, $timestart, $timeend, $hidden)) {
/// Get all existing students and teachers for this course.
$existinguserarray = array();
- $SQL = "select u.* from {$CFG->prefix}role_assignments r, {$CFG->prefix}user u where contextid = $contextid and roleid = $roleid and u.id = r.userid"; // join now so that we can just use fullname() later
+ $SQL = "select u.* from {$CFG->prefix}role_assignments r, {$CFG->prefix}user u where contextid = $contextid and roleid = $roleid and u.id = r.userid"; // join now so that we can just use fullname() later
if (!$contextusers = get_records_sql($SQL)) {
- $contextusers = array();
+ $contextusers = array();
}
- foreach ($contextusers as $contextuser) {
- $existinguserarray[] = $contextuser->id;
- }
-
- $existinguserlist = implode(',', $existinguserarray);
+ foreach ($contextusers as $contextuser) {
+ $existinguserarray[] = $contextuser->id;
+ }
+
+ $existinguserlist = implode(',', $existinguserarray);
unset($existinguserarray);
/// Get search results excluding any users already in this course
}
}
-
+
// this needs to check capability too
$role = get_records('role');
foreach ($role as $rolex) {
- $options[$rolex->id] = $rolex->name;
+ $options[$rolex->id] = $rolex->name;
}
// prints a form to swap roles
print ('<div align="center">'.$strcurrentcontext.': '.print_context_name($contextid).'<br/>');
print ('<input type="hidden" name="contextid" value="'.$contextid.'">'.$strcurrentrole.': ');
choose_from_menu ($options, 'roleid', $roleid, 'choose', $script='rolesform.submit()');
- print ('</div></form>');
-
- if ($roleid) {
+ print ('</div></form>');
+
+ if ($roleid) {
- print_simple_box_start("center");
-
- include('assign.html');
+ print_simple_box_start("center");
+
+ include('assign.html');
- print_simple_box_end();
+ print_simple_box_end();
- }
+ }
print_footer($course);
?>
<?php print_textarea($CFG->htmleditor, 10, 50, 50, 10, 'description', "$role->description"); ?>
<input type="hidden" name="contextid" value="<?php echo $contextid; ?>">
-<p>
- <table>
- <tr>
- <td>Capability Name</td><td>Inherit</td><td>Allow</td><td>Prevent</td><td>Prohibit</td>
- </tr>
- <?php
-
- // init these 2
- $contextlevel = 0;
- $component = '';
-
- foreach ($capabilities as $capability) {
- // prints a breaker if component or name or context level
- if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
- echo ('<tr><td colspan="4"><b>'.get_component_string($capability->component, $capability->contextlevel).'</b></td></tr>');
- }
-
- // these 2 are used to see to group same mod/core capabilities together
- $contextlevel = $capability->contextlevel;
- $component = $capability->component;
-
- // check the capability override for this cap, this role in this context
-
- $SQL = "select * from {$CFG->prefix}role_capabilities where
- roleid = $roleid and capability = '$capability->name' and contextid = $contextid";
-
- $localoverride = get_record_sql($SQL);
-
- if (isset($r_caps[$capability->name])) {
- $isallow = $r_caps[$capability->name] > 0;
- $isprevent = $r_caps[$capability->name] < 0 && $r_caps[$capability->name] > -500;
- $isprohibit = $r_caps[$capability->name] <= -500;
- } else {
- $isallow = 0;
- $isprevent = 0;
- $isprohibit = 0;
- }
-
- ?>
-
- <tr>
- <td><?php echo get_capability_string($capability->name); ?></td>
- <td><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="0" <?php if (!isset($localoverride->permission) || $localoverride->permission==0){ echo 'checked="checked"'; }?>></td>
+<p>
+ <table>
+ <tr>
+ <td>Capability Name</td><td>Inherit</td><td>Allow</td><td>Prevent</td><td>Prohibit</td>
+ </tr>
+ <?php
+
+ // init these 2
+ $contextlevel = 0;
+ $component = '';
+
+ foreach ($capabilities as $capability) {
+ // prints a breaker if component or name or context level
+ if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
+ echo ('<tr><td colspan="4"><b>'.get_component_string($capability->component, $capability->contextlevel).'</b></td></tr>');
+ }
+
+ // these 2 are used to see to group same mod/core capabilities together
+ $contextlevel = $capability->contextlevel;
+ $component = $capability->component;
+
+ // check the capability override for this cap, this role in this context
+
+ $SQL = "select * from {$CFG->prefix}role_capabilities where
+ roleid = $roleid and capability = '$capability->name' and contextid = $contextid";
+
+ $localoverride = get_record_sql($SQL);
+
+ if (isset($r_caps[$capability->name])) {
+ $isallow = $r_caps[$capability->name] > 0;
+ $isprevent = $r_caps[$capability->name] < 0 && $r_caps[$capability->name] > -500;
+ $isprohibit = $r_caps[$capability->name] <= -500;
+ } else {
+ $isallow = 0;
+ $isprevent = 0;
+ $isprohibit = 0;
+ }
+
+ ?>
+
+ <tr>
+ <td><?php echo get_capability_string($capability->name); ?></td>
+ <td><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="0" <?php if (!isset($localoverride->permission) || $localoverride->permission==0){ echo 'checked="checked"'; }?>></td>
<td><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="1" <?php if (isset($localoverride->permission) && $localoverride->permission==1){ echo 'checked="checked"'; }?>></td>
<td ><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="-1" <?php if (isset($localoverride->permission) && $localoverride->permission==-1){ echo 'checked="checked"'; }?>></td>
<td ><INPUT TYPE=radio NAME="<?php echo $capability->name; ?>" VALUE="-1000" <?php if (isset($localoverride->permission) && $localoverride->permission==-1000){ echo 'checked="checked"'; }?>></td>
</tr>
-
- <?php } ?>
- </table>
+
+ <?php } ?>
+ </table>
</p>
<br/><input type="submit" value="<?php print_string($action);?>">
-</form>
\ No newline at end of file
+</form>
require_login();
- $roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editting a role
- $action = optional_param('action', '', PARAM_ALPHA);
- $name = optional_param('name', '', PARAM_ALPHA); // new role name
- $description = optional_param('description', '', PARAM_NOTAGS); // new role desc
- $confirm = optional_param('confirm', 0, PARAM_BOOL);
+ $roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editting a role
+ $action = optional_param('action', '', PARAM_ALPHA);
+ $name = optional_param('name', '', PARAM_ALPHA); // new role name
+ $description = optional_param('description', '', PARAM_NOTAGS); // new role desc
+ $confirm = optional_param('confirm', 0, PARAM_BOOL);
- $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
- $contextid = $sitecontext->id;
-
+ $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ $contextid = $sitecontext->id;
+
if (!isadmin()) {
error('Only admins can access this page');
}
$strmanageroles = get_string('manageroles');
if ($roleid && $action!='delete') {
- $role = get_record('role', 'id', $roleid);
+ $role = get_record('role', 'id', $roleid);
- $edittingstr = '-> '.get_string('editting', $role->name);
+ $edittingstr = '-> '.get_string('editting', $role->name);
} else {
- $edittingstr ='';
+ $edittingstr ='';
}
print_header("$site->shortname: $strmanageroles",
"$site->fullname",
"<a href=\"../index.php\">$stradministration</a> -> <a href=\"manage.php\">$strmanageroles</a>
- $edittingstr
- ");
+ $edittingstr
+ ");
- // form processing, editting a role, adding a role or deleting a role
- if ($action && confirm_sesskey()) {
-
- switch ($action) {
- case 'add':
-
- $newrole = create_role($name, $description);
-
- $ignore = array('roleid', 'sesskey', 'action', 'name', 'description', 'contextid');
-
- $data = data_submitted();
-
- foreach ($data as $capname => $value) {
- if (in_array($capname, $ignore)) {
- continue;
- }
+ // form processing, editting a role, adding a role or deleting a role
+ if ($action && confirm_sesskey()) {
+
+ switch ($action) {
+ case 'add':
+
+ $newrole = create_role($name, $description);
+
+ $ignore = array('roleid', 'sesskey', 'action', 'name', 'description', 'contextid');
+
+ $data = data_submitted();
+
+ foreach ($data as $capname => $value) {
+ if (in_array($capname, $ignore)) {
+ continue;
+ }
- assign_capability($capname, $value, $newrole, $contextid);
-
- }
-
- break;
-
- case 'edit':
-
- $ignore = array('roleid', 'sesskey', 'action', 'name', 'description', 'contextid');
-
- $data = data_submitted();
-
- foreach ($data as $capname => $value) {
- if (in_array($capname, $ignore)) {
- continue;
- }
-
- // edit default caps
- $SQL = "select * from {$CFG->prefix}role_capabilities where
- roleid = $roleid and capability = '$capname' and contextid = $contextid";
-
- $localoverride = get_record_sql($SQL);
-
- if ($localoverride) { // update current overrides
-
- if ($value == 0) { // inherit = delete
-
- unassign_capability($capname, $roleid, $contextid);
-
- } else {
-
- $localoverride->permission = $value;
- $localoverride->timemodified = time();
- $localoverride->modifierid = $USER->id;
- update_record('role_capabilities', $localoverride);
-
- }
-
- } else { // insert a record
-
- assign_capability($capname, $value, $roleid, $contextid);
+ assign_capability($capname, $value, $newrole, $contextid);
+
+ }
+
+ break;
+
+ case 'edit':
+
+ $ignore = array('roleid', 'sesskey', 'action', 'name', 'description', 'contextid');
+
+ $data = data_submitted();
+
+ foreach ($data as $capname => $value) {
+ if (in_array($capname, $ignore)) {
+ continue;
+ }
+
+ // edit default caps
+ $SQL = "select * from {$CFG->prefix}role_capabilities where
+ roleid = $roleid and capability = '$capname' and contextid = $contextid";
+
+ $localoverride = get_record_sql($SQL);
+
+ if ($localoverride) { // update current overrides
+
+ if ($value == 0) { // inherit = delete
+
+ unassign_capability($capname, $roleid, $contextid);
+
+ } else {
+
+ $localoverride->permission = $value;
+ $localoverride->timemodified = time();
+ $localoverride->modifierid = $USER->id;
+ update_record('role_capabilities', $localoverride);
+
+ }
+
+ } else { // insert a record
+
+ assign_capability($capname, $value, $roleid, $contextid);
- }
-
- }
-
- // update normal role settings
-
- $role->id = $roleid;
- $role->name = $name;
- $role->description = $description;
-
- update_record('role', $role);
-
- break;
-
- case 'delete':
- if ($confirm) { // deletes a role
- echo ('deleting...');
-
- // check for depedencies
-
- // delete all associated role-assignments?
- delete_records('role', 'id', $roleid);
-
- } else {
- echo ('<form action="manage.php" method="POST">');
- echo ('<input type="hidden" name="action" value="delete">');
- echo ('<input type="hidden" name="roleid" value="'.$roleid.'">');
- echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
- echo ('<input type="hidden" name="confirm" value="1">');
- echo ('are you sure?');
- echo ('<input type="submit" value="yes">');
- print_footer($course);
- exit;
-
- // prints confirmation form
- }
-
- break;
-
- /// add possible positioning switch here
-
- default:
- break;
-
- }
-
- }
+ }
+
+ }
+
+ // update normal role settings
+
+ $role->id = $roleid;
+ $role->name = $name;
+ $role->description = $description;
+
+ update_record('role', $role);
+
+ break;
+
+ case 'delete':
+ if ($confirm) { // deletes a role
+ echo ('deleting...');
+
+ // check for depedencies
+
+ // delete all associated role-assignments?
+ delete_records('role', 'id', $roleid);
+
+ } else {
+ echo ('<form action="manage.php" method="POST">');
+ echo ('<input type="hidden" name="action" value="delete">');
+ echo ('<input type="hidden" name="roleid" value="'.$roleid.'">');
+ echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
+ echo ('<input type="hidden" name="confirm" value="1">');
+ echo ('are you sure?');
+ echo ('<input type="submit" value="yes">');
+ print_footer($course);
+ exit;
+
+ // prints confirmation form
+ }
+
+ break;
+
+ /// add possible positioning switch here
+
+ default:
+ break;
+
+ }
+
+ }
- $roles = get_records('role');
+ $roles = get_records('role');
- if (($roleid && $action!='delete') || $action=='new') { // load the role if id is present
-
- if ($roleid) {
- $action='edit';
- $role = get_record('role', 'id', $roleid);
- } else {
- $action='add';
- $role->name='';
- $role->description='';
- }
-
- foreach ($roles as $rolex) {
- $options[$rolex->id] = $rolex->name;
- }
-
- // prints a form to swap roles
- print ('<form name="rolesform1" action="manage.php" method="post">');
- print ('<div align="center">Select a Role: ');
- choose_from_menu ($options, 'roleid', $roleid, 'choose', $script='rolesform1.submit()');
- print ('</div></form>');
-
- $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
- $contextid = $sitecontext->id;
-
- // this is the array holding capabilities of this role sorted till this context
- $r_caps = role_context_capabilities($roleid, $sitecontext->id);
-
- // this is the available capabilities assignable in this context
- $capabilities = fetch_context_capabilities($sitecontext->id);
-
- print_simple_box_start();
- include_once('manage.html');
- print_simple_box_end();
-
- } else {
-
- $table->tablealign = "center";
- $table->align = array ("middle", "left");
- $table->wrap = array ("nowrap", "nowrap");
- $table->cellpadding = 5;
- $table->cellspacing = 0;
- $table->width = '40%';
- /*************************
- * List all current roles *
- **************************/
-
- $table->data[] = array('roles', 'description', 'delete');
- foreach ($roles as $role) {
-
- $table->data[] = array('<a href="manage.php?roleid='.$role->id.'&sesskey='.sesskey().'">'.$role->name.'</a>', $role->description, '<a href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">delete</a>');
-
- }
- print_table($table);
-
- echo ('<form action="manage.php" method="POST">');
- echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
- echo ('<input type="hidden" name="action" value="new">');
- echo ('<input type="submit" value="add new role">');
- }
+ if (($roleid && $action!='delete') || $action=='new') { // load the role if id is present
+
+ if ($roleid) {
+ $action='edit';
+ $role = get_record('role', 'id', $roleid);
+ } else {
+ $action='add';
+ $role->name='';
+ $role->description='';
+ }
+
+ foreach ($roles as $rolex) {
+ $options[$rolex->id] = $rolex->name;
+ }
+
+ // prints a form to swap roles
+ print ('<form name="rolesform1" action="manage.php" method="post">');
+ print ('<div align="center">Select a Role: ');
+ choose_from_menu ($options, 'roleid', $roleid, 'choose', $script='rolesform1.submit()');
+ print ('</div></form>');
+
+ $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ $contextid = $sitecontext->id;
+
+ // this is the array holding capabilities of this role sorted till this context
+ $r_caps = role_context_capabilities($roleid, $sitecontext->id);
+
+ // this is the available capabilities assignable in this context
+ $capabilities = fetch_context_capabilities($sitecontext->id);
+
+ print_simple_box_start();
+ include_once('manage.html');
+ print_simple_box_end();
+
+ } else {
+
+ $table->tablealign = "center";
+ $table->align = array ("middle", "left");
+ $table->wrap = array ("nowrap", "nowrap");
+ $table->cellpadding = 5;
+ $table->cellspacing = 0;
+ $table->width = '40%';
+ /*************************
+ * List all current roles *
+ **************************/
+
+ $table->data[] = array('roles', 'description', 'delete');
+ foreach ($roles as $role) {
+
+ $table->data[] = array('<a href="manage.php?roleid='.$role->id.'&sesskey='.sesskey().'">'.$role->name.'</a>', $role->description, '<a href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">delete</a>');
+
+ }
+ print_table($table);
+
+ echo ('<form action="manage.php" method="POST">');
+ echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
+ echo ('<input type="hidden" name="action" value="new">');
+ echo ('<input type="submit" value="add new role">');
+ }
- use_html_editor("description");
- print_footer($course);
+ use_html_editor("description");
+ print_footer($course);
?>
<?php
- require_once("../../config.php");
-
- $contextid = required_param('contextid',PARAM_INT); // context id
- $roleid = optional_param('roleid', 0, PARAM_INT); // required role id
-
- $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
- if ($contextid == $sitecontext->id) {
- error ('can not override base role capabilities');
- }
-
- if (! $site = get_site()) {
+ require_once("../../config.php");
+
+ $contextid = required_param('contextid',PARAM_INT); // context id
+ $roleid = optional_param('roleid', 0, PARAM_INT); // required role id
+
+ $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ if ($contextid == $sitecontext->id) {
+ error ('can not override base role capabilities');
+ }
+
+ if (! $site = get_site()) {
redirect("$CFG->wwwroot/$CFG->admin/index.php");
}
- $strassignusers = get_string('assignusers', 'role');
- $strpotentialusers = get_string('potentialusers', 'role');
- $strexistingusers = get_string('existingusers', 'role');
- $straction = get_string('assignroles', 'role');
- $strcurrentrole = get_string('currentrole', 'role');
- $strcurrentcontext = get_string('currentcontext', 'role');
- $strsearch = get_string('search');
- $strshowall = get_string('showall');
+ $strassignusers = get_string('assignusers', 'role');
+ $strpotentialusers = get_string('potentialusers', 'role');
+ $strexistingusers = get_string('existingusers', 'role');
+ $straction = get_string('assignroles', 'role');
+ $strcurrentrole = get_string('currentrole', 'role');
+ $strcurrentcontext = get_string('currentcontext', 'role');
+ $strsearch = get_string('search');
+ $strshowall = get_string('showall');
- $context = get_record('context', 'id', $contextid);
+ $context = get_record('context', 'id', $contextid);
- $straction = get_string('overrideroles', 'role');
- $currenttab = '';
+ $straction = get_string('overrideroles', 'role');
+ $currenttab = '';
- $tabsmode = 'override';
- include_once('tabs.php');
+ $tabsmode = 'override';
+ include_once('tabs.php');
- /*************************
- * form processing here *
- *************************/
- if ($data = data_submitted()) {
- // add or update
- foreach ($data as $capname => $value) {
- // ignore contextid and roleid
- if ($capname == "contextid" || $capname == "roleid") {
- continue;
- }
-
- $SQL = "select * from {$CFG->prefix}role_capabilities where
- roleid = $roleid and capability = '$capname' and contextid = $contextid";
-
- $localoverride = get_record_sql($SQL);
-
- if ($localoverride) { // update current overrides
-
- if ($value == 0) { // inherit = delete
-
- delete_records('role_capabilities', 'roleid', $roleid, 'contextid', $contextid, 'capability', $capname);
-
- } else {
-
- $localoverride->permission = $value;
- $localoverride->timemodified = time();
- $localoverride->modifierid = $USER->id;
- update_record('role_capabilities', $localoverride);
-
- }
-
- } else { // insert a record
-
- $override->capability = $capname;
- $override->contextid = $contextid;
- $override->roleid = $roleid;
- $override->permission = $value;
- $override->timemodified = time();
- $override->modifierid = $USER->id;
- insert_record('role_capabilities', $override);
- }
-
- }
-
- }
-
- /*****************************************
- * drop down for swapping between roles *
- *****************************************/
-
- // this needs to check capability too
+ /*************************
+ * form processing here *
+ *************************/
+ if ($data = data_submitted()) {
+ // add or update
+ foreach ($data as $capname => $value) {
+ // ignore contextid and roleid
+ if ($capname == "contextid" || $capname == "roleid") {
+ continue;
+ }
+
+ $SQL = "select * from {$CFG->prefix}role_capabilities where
+ roleid = $roleid and capability = '$capname' and contextid = $contextid";
+
+ $localoverride = get_record_sql($SQL);
+
+ if ($localoverride) { // update current overrides
+
+ if ($value == 0) { // inherit = delete
+
+ delete_records('role_capabilities', 'roleid', $roleid, 'contextid', $contextid, 'capability', $capname);
+
+ } else {
+
+ $localoverride->permission = $value;
+ $localoverride->timemodified = time();
+ $localoverride->modifierid = $USER->id;
+ update_record('role_capabilities', $localoverride);
+
+ }
+
+ } else { // insert a record
+
+ $override->capability = $capname;
+ $override->contextid = $contextid;
+ $override->roleid = $roleid;
+ $override->permission = $value;
+ $override->timemodified = time();
+ $override->modifierid = $USER->id;
+ insert_record('role_capabilities', $override);
+ }
+
+ }
+
+ }
+
+ /*****************************************
+ * drop down for swapping between roles *
+ *****************************************/
+
+ // this needs to check capability too
$role = get_records('role');
foreach ($role as $rolex) {
- $options[$rolex->id] = $rolex->name;
+ $options[$rolex->id] = $rolex->name;
}
print ('<form name="rolesform" action="override.php" method="post">');
print ('<div align="center">'.$strcurrentcontext.': '.print_context_name($contextid).'<br/>');
print ('<input type="hidden" name="contextid" value="'.$contextid.'">'.$strcurrentrole.': ');
choose_from_menu ($options, 'roleid', $roleid, 'choose', $script='rolesform.submit()');
- print ('</div></form>');
-
- /**************************************
- * print html for editting overrides *
- **************************************/
+ print ('</div></form>');
+
+ /**************************************
+ * print html for editting overrides *
+ **************************************/
- if ($roleid) {
-
- // this is the array holding capabilities of this role sorted till this context
- $r_caps = role_context_capabilities($roleid, $contextid);
-
- // this is the available capabilities assignable in this context
- $capabilities = fetch_context_capabilities($contextid);
-
- print_simple_box_start("center");
-
- include_once('override.html');
+ if ($roleid) {
+
+ // this is the array holding capabilities of this role sorted till this context
+ $r_caps = role_context_capabilities($roleid, $contextid);
+
+ // this is the available capabilities assignable in this context
+ $capabilities = fetch_context_capabilities($contextid);
+
+ print_simple_box_start("center");
+
+ include_once('override.html');
- print_simple_box_end();
+ print_simple_box_end();
- }
+ }
- print_footer($course);
+ print_footer($course);
?>
// this deals with tabs, as well as print_headers for navigation
if ($currenttab != 'update') {
- switch ($context->level) {
-
- case CONTEXT_SYSTEM:
- $stradministration = get_string('administration');
- print_header($site->fullname, "$site->fullname","<a href=\"../index.php\">$stradministration</a> -> $straction");
- break;
-
- case CONTEXT_PERSONAL:
- break;
-
- case CONTEXT_USERID:
- break;
-
- case CONTEXT_COURSECAT:
- $category = get_record('course_categories', 'id', $context->instanceid);
- $strcategories = get_string("categories");
- $strcategory = get_string("category");
- $strcourses = get_string("courses");
- print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
- "<a href=\"$CFG->wwwroot/course/index.php\">$strcategories</a> -> <a href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a> -> $straction", "", "", true);
- break;
-
- case CONTEXT_COURSE:
- $streditcoursesettings = get_string("editcoursesettings");
-
- $course = get_record('course', 'id', $context->instanceid);
- print_header($streditcoursesettings, "$course->fullname",
- "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
- -> <a href=\"$CFG->wwwroot/course/edit.php?id=$course->id\">$streditcoursesettings</a> -> $straction");
- break;
-
- case CONTEXT_GROUP:
- break;
-
- case CONTEXT_MODULE:
- // get module type?
- $cm = get_record('course_modules','id',$context->instanceid);
- $module = get_record('modules','id',$cm->module); //$module->name;
- $course = get_record('course','id',$cm->course);
-
- if (! $form = get_record($module->name, "id", $cm->instance)) {
- error("The required instance of this module doesn't exist");
- }
-
- $strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">$form->name</a> ->";
- $fullmodulename = get_string("modulename", $module->name);
- $streditinga = get_string("editinga", "moodle", $fullmodulename);
- $strmodulenameplural = get_string("modulenameplural", $module->name);
-
- if ($module->name == "label") {
- $focuscursor = "";
- } else {
- $focuscursor = "form.name";
- }
-
- print_header_simple($streditinga, '',
- "<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
- $strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false);
-
- break;
-
- case CONTEXT_BLOCK:
- print_header();
- break;
-
- default:
- error ('This is an unknown context!');
- return false;
-
- }
+ switch ($context->level) {
+
+ case CONTEXT_SYSTEM:
+ $stradministration = get_string('administration');
+ print_header($site->fullname, "$site->fullname","<a href=\"../index.php\">$stradministration</a> -> $straction");
+ break;
+
+ case CONTEXT_PERSONAL:
+ break;
+
+ case CONTEXT_USERID:
+ break;
+
+ case CONTEXT_COURSECAT:
+ $category = get_record('course_categories', 'id', $context->instanceid);
+ $strcategories = get_string("categories");
+ $strcategory = get_string("category");
+ $strcourses = get_string("courses");
+ print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
+ "<a href=\"$CFG->wwwroot/course/index.php\">$strcategories</a> -> <a href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a> -> $straction", "", "", true);
+ break;
+
+ case CONTEXT_COURSE:
+ $streditcoursesettings = get_string("editcoursesettings");
+
+ $course = get_record('course', 'id', $context->instanceid);
+ print_header($streditcoursesettings, "$course->fullname",
+ "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
+ -> <a href=\"$CFG->wwwroot/course/edit.php?id=$course->id\">$streditcoursesettings</a> -> $straction");
+ break;
+
+ case CONTEXT_GROUP:
+ break;
+
+ case CONTEXT_MODULE:
+ // get module type?
+ $cm = get_record('course_modules','id',$context->instanceid);
+ $module = get_record('modules','id',$cm->module); //$module->name;
+ $course = get_record('course','id',$cm->course);
+
+ if (! $form = get_record($module->name, "id", $cm->instance)) {
+ error("The required instance of this module doesn't exist");
+ }
+
+ $strnav = "<a href=\"$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id\">$form->name</a> ->";
+ $fullmodulename = get_string("modulename", $module->name);
+ $streditinga = get_string("editinga", "moodle", $fullmodulename);
+ $strmodulenameplural = get_string("modulenameplural", $module->name);
+
+ if ($module->name == "label") {
+ $focuscursor = "";
+ } else {
+ $focuscursor = "form.name";
+ }
+
+ print_header_simple($streditinga, '',
+ "<a href=\"$CFG->wwwroot/mod/$module->name/index.php?id=$course->id\">$strmodulenameplural</a> ->
+ $strnav <a href=\"$CFG->wwwroot/course/mod.php?update=$cm->id&sesskey=".sesskey()."\">$streditinga</a> -> $straction", $focuscursor, "", false);
+
+ break;
+
+ case CONTEXT_BLOCK:
+ print_header();
+ break;
+
+ default:
+ error ('This is an unknown context!');
+ return false;
+
+ }
}
- // Printing the tabs
+ // Printing the tabs
if ($context->level == CONTEXT_MODULE) { // only show update button if module?
- $toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.$context->instanceid.'&return=true&sesskey='.sesskey(), get_string('update'));
-
- }
-
- $toprow[] = new tabobject('roles', $CFG->wwwroot.'/admin/roles/assign.php?contextid='.$context->id, get_string('roles'));
+ $toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.$context->instanceid.'&return=true&sesskey='.sesskey(), get_string('update'));
+
+ }
+
+ $toprow[] = new tabobject('roles', $CFG->wwwroot.'/admin/roles/assign.php?contextid='.$context->id, get_string('roles'));
- if (isset($tabsmode)) {
- $inactive[] = 'roles';
+ if (isset($tabsmode)) {
+ $inactive[] = 'roles';
- $secondrow[] = new tabobject('assign', $CFG->wwwroot.'/admin/roles/assign.php?contextid='.$context->id, get_string('assignroles', 'role'));
+ $secondrow[] = new tabobject('assign', $CFG->wwwroot.'/admin/roles/assign.php?contextid='.$context->id, get_string('assignroles', 'role'));
if ($context->level == CONTEXT_SYSTEM) {
- $secondrow[] = new tabobject('override', '', get_string('overrideroles', 'role'));
+ $secondrow[] = new tabobject('override', '', get_string('overrideroles', 'role'));
} else {
- $secondrow[] = new tabobject('override', $CFG->wwwroot.'/admin/roles/override.php?contextid='.$context->id,
- get_string('overrideroles', 'role'));
+ $secondrow[] = new tabobject('override', $CFG->wwwroot.'/admin/roles/override.php?contextid='.$context->id,
+ get_string('overrideroles', 'role'));
}
-
- if ($tabsmode == 'override') {
- $currenttab = 'override';
- } elseif ($tabsmode == 'assign') {
- $currenttab = 'assign';
- }
-
+
+ if ($tabsmode == 'override') {
+ $currenttab = 'override';
+ } elseif ($tabsmode == 'assign') {
+ $currenttab = 'assign';
+ }
+
} else {
- $inactive[] = '';
+ $inactive[] = '';
}
- if (!empty($secondrow)) {
+ if (!empty($secondrow)) {
$tabs = array($toprow, $secondrow);
} else {
$tabs = array($toprow);
}
- if ($context->level != CONTEXT_SYSTEM) { // do not show tabs otherwise
- print_tabs($tabs, $currenttab, $inactive);
- }
+ if ($context->level != CONTEXT_SYSTEM) { // do not show tabs otherwise
+ print_tabs($tabs, $currenttab, $inactive);
+ }
?>
$admin = new object();
$teacher = new object();
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
if (! record_exists("user_admins")) { // No admin user yet
if ($user->id == $USER->id or $user->username == "changeme") {
$deletebutton = "";
} else {
- if (has_capability('moodle/user:delete', $context->id)) {
- $deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>"; } else {
- $deletebutton ="";
+ if (has_capability('moodle/user:delete', $context->id)) {
+ $deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>"; } else {
+ $deletebutton ="";
}
}
if ($user->lastaccess) {
if (has_capability('moodle/user:edit', $context->id)) {
- $table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
+ $table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
"$user->email",
"$user->city",
"$user->country",
$deletebutton,
$confirmbutton);
} else {
- $table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
+ $table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
"$user->email",
"$user->city",
"$user->country",
$strlastaccess,
$deletebutton,
$confirmbutton);
-
- }
+
+ }
}
}
echo "</form>";
echo "</td></tr></table>";
- if (has_capability('moodle/user:create', $context->id)) {
- print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
- }
+ if (has_capability('moodle/user:create', $context->id)) {
+ print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
+ }
if (!empty($table)) {
print_table($table);
print_paging_bar($usercount, $page, $perpage,
"user.php?sort=$sort&dir=$dir&perpage=$perpage".
"&firstinitial=$firstinitial&lastinitial=$lastinitial&search=".urlencode(stripslashes($search))."&");
if (has_capability('moodle/user:create', $context->id)) {
- print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
+ print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
}
}
if (!$site = get_site()) {
redirect("index.php");
}
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
$stradministration = get_string("administration");
$strusers = get_string("users");
get_string("adminhelpauthentication"));
if (has_capability('moodle/user:update', $context->id)) {
- $table->data[] = array("<b><a href=\"user.php\">".get_string("edituser")."</a></b>",
+ $table->data[] = array("<b><a href=\"user.php\">".get_string("edituser")."</a></b>",
get_string("adminhelpedituser"));
- }
+ }
if (has_capability('moodle/user:create', $context->id)) {
- $table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a></b>",
+ $table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a></b>",
get_string("adminhelpaddnewuser"));
}
-
- if (has_capability('moodle/user:create', $context->id)) {
- $table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".get_string("uploadusers")."</a></b>",
+
+ if (has_capability('moodle/user:create', $context->id)) {
+ $table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".get_string("uploadusers")."</a></b>",
get_string("adminhelpuploadusers"));
}
require_once($CFG->dirroot.'/course/lib.php');
require_login();
- // decalre once
- global $enc;
-
- $customlang = array();
-
- $enc = array('af' => 'iso-8859-1', 'ar' => 'windows-1256', 'be' => 'windows-1251', 'bg' => 'windows-1251', 'bs' => 'windows-1250', 'ca' => 'iso-8859-1', 'cs' => 'iso-8859-2', 'da' => 'iso-8859-1', 'de' => 'iso-8859-1', 'de_du' => 'iso-8859-1', 'de_utf8' => 'utf-8', 'el' => 'windows-1253', 'en' => 'iso-8859-1', 'en_ja' => 'euc-jp', 'en_us' => 'iso-8859-1', 'en_utf8' => 'utf-8', 'es' => 'iso-8859-1', 'es_ar' => 'iso-8859-1', 'es_es' => 'iso-8859-1', 'es_mx' => 'iso-8859-1', 'et' => 'iso-8859-1', 'eu' => 'iso-8859-1', 'fa' => 'windows-1256', 'fa_utf8' => 'utf-8', 'fi' => 'iso-8859-1', 'fil' => 'iso-8859-15', 'fr' => 'iso-8859-1', 'fr_ca' => 'iso-8859-15', 'ga' => 'iso-8859-1', 'gl' => 'iso-8859-1', 'he' => 'ISO-8859-8-I', 'he_utf8' => 'utf-8', 'hi' => 'iso-8859-1', 'hr' => 'windows-1250', 'hr_utf8' => 'utf-8', 'hu' => 'iso-8859-2', 'id' => 'iso-8859-1', 'is' => 'iso-8859-1', 'it' => 'iso-8859-1', 'ja' => 'EUC-JP', 'ja_utf8' => 'UTF-8', 'ka_utf8' => 'UTF-8', 'km_utf8' => 'UTF-8', 'kn_utf8' => 'utf-8', 'ko' => 'EUC-KR', 'ko_utf8' => 'UTF-8', 'lt' => 'windows-1257', 'lv' => 'ISO-8859-4', 'mi_nt' => 'iso-8859-1', 'mi_tn_utf8' => 'utf-8', 'ms' => 'iso-8859-1', 'nl' => 'iso-8859-1', 'nn' => 'iso-8859-1', 'no' => 'iso-8859-1', 'no_gr' => 'iso-8859-1', 'pl' => 'iso-8859-2', 'pt' => 'iso-8859-1', 'pt_br' => 'iso-8859-1', 'ro' => 'iso-8859-2', 'ru' => 'windows-1251', 'sk' => 'iso-8859-2', 'sl' => 'iso-8859-2', 'sl_utf8' => 'utf-8', 'so' => 'iso-8859-1', 'sq' => 'iso-8859-1', 'sr_utf8' => 'utf-8', 'sv' => 'iso-8859-1', 'th' => 'TIS-620', 'th_utf8' => 'UTF-8', 'tl' => 'iso-8859-15', 'tl_utf8' => 'UTF-8', 'tr' => 'iso-8859-9', 'uk' => 'windows-1251', 'vi_utf8' => 'UTF-8', 'zh_cn' => 'GB18030', 'zh_cn_utf8' => 'UTF-8', 'zh_tw' => 'Big5', 'zh_tw_utf8' => 'UTF-8');
-
- /**************************************
- * Custom lang pack handling *
- **************************************/
-
- // scan list of langs, including customs packs
- $langs = get_list_of_languages();
-
- // foreach lang
- foreach ($langs as $lang => $lang1) {
-
- if (in_array($lang, array_keys($enc))) {
- // if already in array, ignore
- continue;
- }
-
- // if this lang has got a charset
-
- if ($result = get_string_from_file('thischarset',$CFG->dirroot.'/lang/'.$lang.'/moodle.php', "\$resultstring")) {
- eval($result);
- $enc[$lang] = $resultstring;
- } else if ($result = get_string_from_file('parentlanguage',$CFG->dirroot.'/lang/'.$lang.'/moodle.php',"\$resultstring")) {
- // else if there's a parent lang we can use
- eval($result);
- $enc[$lang] = $enc[$resultstring];
- } else {
- notify ('unknown lang pack detected '.$lang);
- }
-
- }
-
- /**************************************
- * End custom lang pack handling *
- **************************************/
+ // decalre once
+ global $enc;
+
+ $customlang = array();
+
+ $enc = array('af' => 'iso-8859-1', 'ar' => 'windows-1256', 'be' => 'windows-1251', 'bg' => 'windows-1251', 'bs' => 'windows-1250', 'ca' => 'iso-8859-1', 'cs' => 'iso-8859-2', 'da' => 'iso-8859-1', 'de' => 'iso-8859-1', 'de_du' => 'iso-8859-1', 'de_utf8' => 'utf-8', 'el' => 'windows-1253', 'en' => 'iso-8859-1', 'en_ja' => 'euc-jp', 'en_us' => 'iso-8859-1', 'en_utf8' => 'utf-8', 'es' => 'iso-8859-1', 'es_ar' => 'iso-8859-1', 'es_es' => 'iso-8859-1', 'es_mx' => 'iso-8859-1', 'et' => 'iso-8859-1', 'eu' => 'iso-8859-1', 'fa' => 'windows-1256', 'fa_utf8' => 'utf-8', 'fi' => 'iso-8859-1', 'fil' => 'iso-8859-15', 'fr' => 'iso-8859-1', 'fr_ca' => 'iso-8859-15', 'ga' => 'iso-8859-1', 'gl' => 'iso-8859-1', 'he' => 'ISO-8859-8-I', 'he_utf8' => 'utf-8', 'hi' => 'iso-8859-1', 'hr' => 'windows-1250', 'hr_utf8' => 'utf-8', 'hu' => 'iso-8859-2', 'id' => 'iso-8859-1', 'is' => 'iso-8859-1', 'it' => 'iso-8859-1', 'ja' => 'EUC-JP', 'ja_utf8' => 'UTF-8', 'ka_utf8' => 'UTF-8', 'km_utf8' => 'UTF-8', 'kn_utf8' => 'utf-8', 'ko' => 'EUC-KR', 'ko_utf8' => 'UTF-8', 'lt' => 'windows-1257', 'lv' => 'ISO-8859-4', 'mi_nt' => 'iso-8859-1', 'mi_tn_utf8' => 'utf-8', 'ms' => 'iso-8859-1', 'nl' => 'iso-8859-1', 'nn' => 'iso-8859-1', 'no' => 'iso-8859-1', 'no_gr' => 'iso-8859-1', 'pl' => 'iso-8859-2', 'pt' => 'iso-8859-1', 'pt_br' => 'iso-8859-1', 'ro' => 'iso-8859-2', 'ru' => 'windows-1251', 'sk' => 'iso-8859-2', 'sl' => 'iso-8859-2', 'sl_utf8' => 'utf-8', 'so' => 'iso-8859-1', 'sq' => 'iso-8859-1', 'sr_utf8' => 'utf-8', 'sv' => 'iso-8859-1', 'th' => 'TIS-620', 'th_utf8' => 'UTF-8', 'tl' => 'iso-8859-15', 'tl_utf8' => 'UTF-8', 'tr' => 'iso-8859-9', 'uk' => 'windows-1251', 'vi_utf8' => 'UTF-8', 'zh_cn' => 'GB18030', 'zh_cn_utf8' => 'UTF-8', 'zh_tw' => 'Big5', 'zh_tw_utf8' => 'UTF-8');
+
+ /**************************************
+ * Custom lang pack handling *
+ **************************************/
+
+ // scan list of langs, including customs packs
+ $langs = get_list_of_languages();
+
+ // foreach lang
+ foreach ($langs as $lang => $lang1) {
+
+ if (in_array($lang, array_keys($enc))) {
+ // if already in array, ignore
+ continue;
+ }
+
+ // if this lang has got a charset
+
+ if ($result = get_string_from_file('thischarset',$CFG->dirroot.'/lang/'.$lang.'/moodle.php', "\$resultstring")) {
+ eval($result);
+ $enc[$lang] = $resultstring;
+ } else if ($result = get_string_from_file('parentlanguage',$CFG->dirroot.'/lang/'.$lang.'/moodle.php',"\$resultstring")) {
+ // else if there's a parent lang we can use
+ eval($result);
+ $enc[$lang] = $enc[$resultstring];
+ } else {
+ notify ('unknown lang pack detected '.$lang);
+ }
+
+ }
+
+ /**************************************
+ * End custom lang pack handling *
+ **************************************/
if (!isadmin()) {
error('Only admins can access this page');
function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
//pointing to the num of records to process would be
- //useful. And it won't break anything, because the
- //crash system will continue the next time it was
- //executed. Also, the function could return:
- //0 = Some sort of error
- //1 = Finished completelly!
- //2 = Finished limit records
- //(using constants, of course ;-))
- //Then, all those errors, should be converted to
- //mtrace() and return 0. (showing the current
- //table/field/recordid)
+ //useful. And it won't break anything, because the
+ //crash system will continue the next time it was
+ //executed. Also, the function could return:
+ //0 = Some sort of error
+ //1 = Finished completelly!
+ //2 = Finished limit records
+ //(using constants, of course ;-))
+ //Then, all those errors, should be converted to
+ //mtrace() and return 0. (showing the current
+ //table/field/recordid)
global $db, $CFG, $dbtablename, $fieldname, $record, $processedrecords;
$debug = ($CFG->debug > 7);
notice(get_string('coursehidden'), $CFG->wwwroot .'/');
}
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
if (has_capability('moodle/course:view', $context->id)) {
if (isset($USER->realuser)) { // Make sure the REAL person can also access this course
global $USER;
static $admins, $nonadmins;
- if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) {
-
- if ($courseid == 0) {
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
- } else {
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
- }
-
- if (!$userid) {
- return has_capability('moodle/legacy:admin', $context->id);
- } else {
- return has_capability('moodle/legacy:admin', $context->id, false, $userid);
- }
-
- }
+ if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) {
+
+ if ($courseid == 0) {
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ } else {
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ }
+
+ if (!$userid) {
+ return has_capability('moodle/legacy:admin', $context->id);
+ } else {
+ return has_capability('moodle/legacy:admin', $context->id, false, $userid);
+ }
+
+ }
if (!isset($admins)) {
$admins = array();
/// Is the user able to access this course as a teacher?
global $USER, $CFG;
- if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) { // should be always
-
- if ($courseid == 0) {
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
- } else {
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
- }
-
- if (!$userid) {
- return has_capability('moodle/legacy:teacher', $context->id);
- } else {
- return has_capability('moodle/legacy:teacher', $context->id, false, $userid);
- }
- }
+ if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) { // should be always
+
+ if ($courseid == 0) {
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ } else {
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ }
+
+ if (!$userid) {
+ return has_capability('moodle/legacy:teacher', $context->id);
+ } else {
+ return has_capability('moodle/legacy:teacher', $context->id, false, $userid);
+ }
+ }
// Old code follows, will be removed before 1.7 because it shouldn't run
*/
function isteacheredit($courseid, $userid=0, $ignorestudentview=false) {
global $USER;
-
- if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) {
-
- if ($courseid == 0) {
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
- } else {
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
- }
-
- if (!$userid) {
- return has_capability('moodle/legacy:edittingteacher', $context->id);
- } else {
- return has_capability('moodle/legacy:edittingteacher', $context->id, false, $userid);
- }
-
- }
+
+ if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) {
+
+ if ($courseid == 0) {
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ } else {
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ }
+
+ if (!$userid) {
+ return has_capability('moodle/legacy:edittingteacher', $context->id);
+ } else {
+ return has_capability('moodle/legacy:edittingteacher', $context->id, false, $userid);
+ }
+
+ }
// we can't edit in studentview
if (!empty($USER->studentview) and !$ignorestudentview) {
return false;
if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) {
- if ($courseid == 0) {
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
- } else {
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
- }
-
- if (!$userid) {
- return has_capability('moodle/legacy:coursecreator', $context->id);
- } else {
- return has_capability('moodle/legacy:coursecreator', $context->id, false, $userid);
- }
-
- }
+ if ($courseid == 0) {
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ } else {
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ }
+
+ if (!$userid) {
+ return has_capability('moodle/legacy:coursecreator', $context->id);
+ } else {
+ return has_capability('moodle/legacy:coursecreator', $context->id, false, $userid);
+ }
+
+ }
if (empty($USER->id)) {
return false;
}
*/
function isstudent($courseid, $userid=0) {
global $USER, $CFG;
-
- if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) {
-
- if ($courseid == 0) {
- $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
- } else {
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
- }
-
- if (!$userid) {
- return has_capability('moodle/legacy:student', $context->id);
- } else {
- return has_capability('moodle/legacy:student', $context->id, false, $userid);
- }
-
- }
+
+ if (isset($CFG->rolesactive) && $CFG->rolesactive ===1) {
+
+ if ($courseid == 0) {
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ } else {
+ $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ }
+
+ if (!$userid) {
+ return has_capability('moodle/legacy:student', $context->id);
+ } else {
+ return has_capability('moodle/legacy:student', $context->id, false, $userid);
+ }
+
+ }
if (empty($USER->id) and !$userid) {
return false;
} else {
umask(0000);
if ($recursive) {
- // PHP 5.0 has recursive mkdir parameter, but 4.x does not :-(
+ // PHP 5.0 has recursive mkdir parameter, but 4.x does not :-(
$dir = str_replace('\\', '/', $dir); //windows compatibility
$dirs = explode('/', $dir);
$dir = array_shift($dirs).'/'; //skip root or drive letter
echo '</div></td><td class="links">';
//link to blogs
if ($CFG->bloglevel > 0) {
- echo '<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.get_string('blogs','blog').'</a><br />';
+ echo '<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.get_string('blogs','blog').'</a><br />';
}
- if ($isteacher) {
+ if ($isteacher) {
$timemidnight = usergetmidnight(time());
echo '<a href="'. $CFG->wwwroot .'/course/user.php?id='. $course->id .'&user='. $user->id .'">'. $string->activity .'</a><br />';
if (!iscreator($user->id) or ($isadmin and !isadmin($user->id))) { // Includes admins