Skip to content

Commit

Permalink
MDL-14679 towards /user conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed May 31, 2008
1 parent b9a6636 commit ce8c75e
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 122 deletions.
2 changes: 2 additions & 0 deletions lib/dml/oci8po_adodb_moodle_recordset.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function next() {
}

public function rewind() {
//TODO - this does not work in Oracle :-(
error('Implement rewind in oracle by doing query again');
$this->rs->MoveFirst();
}

Expand Down
6 changes: 3 additions & 3 deletions user/addnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$users = optional_param('userid', array(), PARAM_INT); // array of user id
$contents = optional_param('contents', array(), PARAM_RAW); // array of user notes
$states = optional_param('states', array(), PARAM_ALPHA); // array of notes states
if (! $course = get_record('course', 'id', $id)) {
if (! $course = $DB->get_record('course', array('id'=>$id))) {
print_error("Course ID is incorrect");
}

Expand All @@ -25,7 +25,7 @@
$note->courseid = $id;
$note->format = FORMAT_PLAIN;
foreach ($users as $k => $v) {
if(!$user = get_record('user', 'id', $v) || empty($contents[$k])) {
if(!$user = $DB->get_record('user', array('id'=>$v)) || empty($contents[$k])) {
continue;
}
$note->id = 0;
Expand Down Expand Up @@ -74,7 +74,7 @@
}

foreach ($users as $k => $v) {
if(!$user = get_record('user', 'id', $v)) {
if(!$user = $DB->get_record('user', array('id'=>$v))) {
continue;
}
$checkbox = choose_from_menu($state_names, 'states[' . $k . ']', empty($states[$k]) ? NOTES_STATE_PUBLIC : $states[$k], '', '', '0', true);
Expand Down
17 changes: 9 additions & 8 deletions user/extendenrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$id = required_param('id', PARAM_INT); // course id
$users = optional_param('userid', array(), PARAM_INT); // array of user id

if (! $course = get_record('course', 'id', $id)) {
if (! $course = $DB->get_record('course', array('id'=>$id))) {
print_error("Course ID is incorrect");
}

Expand All @@ -22,10 +22,10 @@

foreach ($form->userid as $k => $v) {
// find all roles this student have in this course
if ($students = get_records_sql("SELECT ra.id, ra.roleid, ra.timestart, ra.timeend
FROM {$CFG->prefix}role_assignments ra
WHERE userid = $v
AND contextid = $context->id")) {
if ($students = $DB->get_records_sql("SELECT ra.id, ra.roleid, ra.timestart, ra.timeend
FROM {role_assignments} ra
WHERE userid = ?
AND contextid = ?", array($v, $context->id))) {
// enrol these users again, with time extension
// not that this is not necessarily a student role
foreach ($students as $student) {
Expand Down Expand Up @@ -124,9 +124,10 @@
foreach ($_POST as $k => $v) {
if (preg_match('/^user(\d+)$/',$k,$m)) {

if (!($user = get_record_sql("SELECT * FROM {$CFG->prefix}user u
INNER JOIN {$CFG->prefix}role_assignments ra ON u.id=ra.userid
WHERE u.id={$m[1]} AND ra.contextid = $context->id"))) {
if (!($user = $DB->get_record_sql("SELECT *
FROM {user} u
JOIN {role_assignments} ra ON u.id=ra.userid
WHERE u.id=? AND ra.contextid = ?", array($m[1], $context->id)))) {
continue;
}
$userbasemenu = $basemenu;
Expand Down
6 changes: 3 additions & 3 deletions user/groupaddnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$content = optional_param('content', '', PARAM_RAW); // note content
$state = optional_param('state', '', PARAM_ALPHA); // note publish state

if (! $course = get_record('course', 'id', $id)) {
if (! $course = $DB->get_record('course', array('id'=>$id))) {
print_error("Course ID is incorrect");
}

Expand All @@ -24,7 +24,7 @@
$note->content = $content;
$note->publishstate = $state;
foreach ($users as $k => $v) {
if(!$user = get_record('user', 'id', $v)) {
if(!$user = $DB->get_record('user', array('id'=>$v))) {
continue;
}
$note->id = 0;
Expand Down Expand Up @@ -69,7 +69,7 @@

$userlist = array();
foreach ($users as $k => $v) {
if(!$user = get_record('user', 'id', $v)) {
if (!$user = $DB->get_record('user', array('id'=>$v))) {
continue;
}
echo '<input type="hidden" name="userid['.$k.']" value="'.$v.'" />';
Expand Down
17 changes: 9 additions & 8 deletions user/groupextendenrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$id = required_param('id', PARAM_INT); // course id
$users = optional_param('userid', array(), PARAM_INT); // array of user id

if (! $course = get_record('course', 'id', $id)) {
if (! $course = $DB->get_record('course', array('id'=>$id))) {
print_error("Course ID is incorrect");
}

Expand All @@ -20,10 +20,10 @@

foreach ($form->userid as $k => $v) {
// find all roles this student have in this course
if ($students = get_records_sql("SELECT ra.id, ra.roleid, ra.timestart, ra.timeend
FROM {$CFG->prefix}role_assignments ra
WHERE userid = $v
AND contextid = $context->id")) {
if ($students = $DB->get_records_sql("SELECT ra.id, ra.roleid, ra.timestart, ra.timeend
FROM {role_assignments} ra
WHERE userid = ?
AND contextid = ?", array($v, $context->id))) {
// enrol these users again, with time extension
// not that this is not necessarily a student role
foreach ($students as $student) {
Expand Down Expand Up @@ -122,9 +122,10 @@
foreach ($_POST as $k => $v) {
if (preg_match('/^user(\d+)$/',$k,$m)) {

if (!($user = get_record_sql("SELECT * FROM {$CFG->prefix}user u
INNER JOIN {$CFG->prefix}role_assignments ra ON u.id=ra.userid
WHERE u.id={$m[1]} AND ra.contextid = $context->id"))) {
if (!($user = $DB->get_record_sql("SELECT *
FROM {user} u
JOIN {role_assignments} ra ON u.id=ra.userid
WHERE u.id=? AND ra.contextid = ?", array($m[1], $context->id)))) {
continue;
}
if ($user->timestart) {
Expand Down
Loading

0 comments on commit ce8c75e

Please sign in to comment.