Skip to content

Commit

Permalink
MDL-15117 wiki converted and other regressions fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jun 4, 2008
1 parent bae7362 commit 655b09c
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 177 deletions.
2 changes: 1 addition & 1 deletion admin/modules.php
Expand Up @@ -116,7 +116,7 @@
WHERE id IN (SELECT DISTINCT course
FROM {course_modules}
WHERE module=?)";
$DB->execute_sql($sql, array($module->id));
$DB->execute($sql, array($module->id));

// Now delete all the course module records
if (!$DB->delete_records("course_modules", array("module"=>$module->id))) {
Expand Down
2 changes: 1 addition & 1 deletion backup/backup_check.html
Expand Up @@ -36,7 +36,7 @@
notice("No backupable modules are installed!");
}

if (!execute_sql("DELETE FROM {$CFG->prefix}backup_ids WHERE backup_code = '{$backupprefs->backup_unique_code}'",false)){
if (!$DB->delete_records("backup_ids", array('backup_code'=>$backupprefs->backup_unique_code))){
print_error('cannotdeletebackupids');
}

Expand Down
2 changes: 1 addition & 1 deletion calendar/event.php
Expand Up @@ -166,7 +166,7 @@
WHERE repeatid = ?";
$params = array($form->name, $form->description, $timestartoffset, $form->timeduration, time(), $event->repeatid);

$DB->execute_sql($sql, $params);
$DB->execute($sql, $params);

/// Log the event update.
add_to_log($form->courseid, 'calendar', 'edit all', 'event.php?action=edit&id='.$form->id, $form->name);
Expand Down
2 changes: 1 addition & 1 deletion grade/export/lib.php
Expand Up @@ -344,7 +344,7 @@ public function flush($buffersize) {
$params = array_merge(array($this->export_time), $params);

$sql = "UPDATE {grade_grades} SET exported = ? WHERE id $usql";
$DB->execute_sql($sql, $params, false);
$DB->execute($sql, $params);
$this->update_list = array();
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/blocklib.php
Expand Up @@ -836,7 +836,7 @@ function blocks_move_block($page, &$instance, $destpos, $destweight=NULL, $pinne
AND pagetype = ? AND pageid = ?";
$params = array($destweight, $destpos, $instance->pagetype, $instance->pageid);
}
if (!$DB->execute_sql($opengapsql, $params)) {
if (!$DB->execute($opengapsql, $params)) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/datalib.php
Expand Up @@ -1303,9 +1303,9 @@ function fix_course_sortorder($categoryid=0, $n=0, $safe=0, $depth=0, $path='')
// will stop us -- shift things aside for a moment...
if ($safe || ($n >= $min && $n+$count+1 < $min && $CFG->dbfamily==='mysql')) {
$shift = $max + $n + 1000;
$DB->execute_sql("UPDATE {course}
SET sortorder=sortorder+?
WHERE category=?", array($shift, $categoryid));
$DB->execute("UPDATE {course}
SET sortorder=sortorder+?
WHERE category=?", array($shift, $categoryid));
}

$courses = get_courses($categoryid, 'c.sortorder ASC', 'c.id,c.sortorder');
Expand Down
2 changes: 1 addition & 1 deletion lib/statslib.php
Expand Up @@ -159,7 +159,7 @@ function stats_cron_daily($maxdays=1) {
GROUP BY stattype, timeend, courseid, userid
HAVING count(l.id) > 0";

if ($logspresent and !$DB->execute_sql($sql)) {
if ($logspresent and !$DB->execute($sql)) {
$failed = true;
break;
}
Expand Down
8 changes: 4 additions & 4 deletions mod/wiki/admin.php
Expand Up @@ -17,19 +17,19 @@
print_error("Course Module ID was incorrect");
}

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

if (! $wiki = get_record("wiki", "id", $cm->instance)) {
if (! $wiki = $DB->get_record("wiki", array("id"=>$cm->instance))) {
print_error("Course module is incorrect");
}

} else {
if (! $wiki = get_record("wiki", "id", $a)) {
if (! $wiki = $DB->get_record("wiki", array("id"=>$a))) {
print_error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $wiki->course)) {
if (! $course = $DB->get_record("course", array("id"=>$wiki->course))) {
print_error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("wiki", $wiki->id, $course->id)) {
Expand Down
25 changes: 11 additions & 14 deletions mod/wiki/backuplib.php
Expand Up @@ -24,12 +24,12 @@

//This function executes all the backup procedure about this mod
function wiki_backup_mods($bf,$preferences) {
global $CFG;
global $CFG, $DB;

$status = true;

////Iterate over wiki table
if ($wikis = get_records ("wiki","course", $preferences->backup_course,"id")) {
if ($wikis = $DB->get_records ("wiki","course", array($preferences->backup_course=>"id"))) {
foreach ($wikis as $wiki) {
if (backup_mod_selected($preferences,'wiki',$wiki->id)) {
wiki_backup_one_mod($bf,$preferences,$wiki);
Expand All @@ -41,11 +41,12 @@ function wiki_backup_mods($bf,$preferences) {
}

function wiki_backup_one_mod($bf,$preferences,$wiki) {
global $DB;

$status = true;

if (is_numeric($wiki)) {
$wiki = get_record('wiki','id',$wiki);
$wiki = $DB->get_record('wiki', array('id'=>$wiki));
}

//Start mod
Expand Down Expand Up @@ -89,6 +90,7 @@ function wiki_check_backup_mods_instances($instance,$backup_unique_code) {

////Return an array of info (name,value)
function wiki_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
global $DB;
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
Expand All @@ -98,18 +100,17 @@ function wiki_check_backup_mods($course,$user_data=false,$backup_unique_code,$in
}
//First the course data
$info[0][0] = get_string("modulenameplural","wiki");
$info[0][1] = count_records("wiki", "course", "$course");
$info[0][1] = $DB->count_records("wiki", array("course"=>$course));
return $info;
}

//Backup wiki_entries contents (executed from wiki_backup_mods)
function backup_wiki_entries ($bf,$preferences,$wiki, $userinfo) {

global $CFG;
global $CFG, $DB;

$status = true;

$wiki_entries = get_records("wiki_entries","wikiid",$wiki,"id");
$wiki_entries = $DB->get_records("wiki_entries", array("wikiid"=>$wiki), "id");
//If there are entries
if ($wiki_entries) {
//Write start tag
Expand Down Expand Up @@ -139,12 +140,11 @@ function backup_wiki_entries ($bf,$preferences,$wiki, $userinfo) {

//Write wiki_pages contents
function backup_wiki_pages ($bf,$preferences,$entryid) {

global $CFG;
global $CFG, $DB;

$status = true;

$pages = get_records("wiki_pages","wiki",$entryid);
$pages = $DB_>get_records("wiki_pages", array("wiki"=>$entryid));
if ($pages) {
//Start tag
$status =fwrite ($bf,start_tag("PAGES",6,true));
Expand Down Expand Up @@ -173,8 +173,7 @@ function backup_wiki_pages ($bf,$preferences,$entryid) {
}

function backup_wiki_files_instance($bf,$preferences,$instanceid) {

global $CFG;
global $CFG, $DB;

$status = true;

Expand All @@ -196,7 +195,6 @@ function backup_wiki_files_instance($bf,$preferences,$instanceid) {

//Backup wiki binary files
function backup_wiki_files($bf,$preferences) {

global $CFG;

$status = true;
Expand Down Expand Up @@ -227,7 +225,6 @@ function backup_wiki_files($bf,$preferences) {
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function wiki_encode_content_links ($content,$preferences) {

global $CFG;

$base = preg_quote($CFG->wwwroot,"/");
Expand Down
4 changes: 2 additions & 2 deletions mod/wiki/confirmlock.php
Expand Up @@ -22,9 +22,9 @@
exit;
}

if($lock=get_record('wiki_locks','id',$lockid)) {
if($lock=$DB->get_record('wiki_locks', array('id'=>$lockid))) {
$lock->lockedseen=time();
update_record('wiki_locks',$lock);
$DB->update_record('wiki_locks',$lock);
print 'ok';
} else {
print 'cancel'; // Tells user their lock has been cancelled.
Expand Down
12 changes: 6 additions & 6 deletions mod/wiki/ewiki/ewiki.php
Expand Up @@ -1147,7 +1147,7 @@ function ewiki_page_search($id, &$data, $action) {
function ewiki_page_info($id, &$data, $action) {

global $ewiki_plugins, $ewiki_config, $ewiki_links;
global $CFG, $course; // MOODLE HACK
global $CFG, $COURSE, $DB; // MOODLE HACK

$pnum = optional_param(EWIKI_UP_PAGENUM, 0);
$pend = optional_param(EWIKI_UP_PAGEEND, 0);
Expand Down Expand Up @@ -1267,12 +1267,12 @@ function ewiki_page_info($id, &$data, $action) {
}
elseif ($i == "userid") {
$i = 'author';
if ($user = get_record('user', 'id', $value)) {
if (!isset($course->id)) {
$course->id = 1;
if ($user = $DB->get_record('user', array('id'=>$value))) {
if (!isset($COURSE->id)) {
$COURSE->id = SITEID;
}
$picture = print_user_picture($user->id, $course->id, $user->picture, false, true, true);
$value = $picture." <a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">".fullname($user)."</a>";
$picture = print_user_picture($user->id, $COURSE->id, $user->picture, false, true, true);
$value = $picture." <a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$COURSE->id\">".fullname($user)."</a>";
} else {
continue;
//$value = @$current['author'];
Expand Down
4 changes: 2 additions & 2 deletions mod/wiki/ewiki/plugins/moodle/downloads.php
Expand Up @@ -294,7 +294,7 @@ function ewiki_page_filedownload($id, $data, $action, $def_sec="") {

function ewiki_entry_downloads($row, $show_section=0, $fullinfo=false) {

global $ewiki_binary_icons, $ewiki_upload_sections;
global $ewiki_binary_icons, $ewiki_upload_sections, $DB;

$meta = &$row["meta"];

Expand Down Expand Up @@ -345,7 +345,7 @@ function ewiki_entry_downloads($row, $show_section=0, $fullinfo=false) {
$info->comment = format_text($p_comment);

if ($fullinfo) {
if ($user = get_record('user', 'id', $row['userid'])) {
if ($user = $DB->get_record('user', array('id'=>$row['userid']))) {
if (!isset($course->id)) {
$course->id = 1;
}
Expand Down

0 comments on commit 655b09c

Please sign in to comment.