mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-15117 wiki converted and other regressions fixed
This commit is contained in:
parent
bae736241a
commit
655b09ca8a
@ -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))) {
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -344,7 +344,7 @@ class grade_export_update_buffer {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
@ -41,11 +41,12 @@
|
||||
}
|
||||
|
||||
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
|
||||
@ -89,6 +90,7 @@
|
||||
|
||||
////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) {
|
||||
@ -98,18 +100,17 @@
|
||||
}
|
||||
//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
|
||||
@ -139,12 +140,11 @@
|
||||
|
||||
//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));
|
||||
@ -173,8 +173,7 @@
|
||||
}
|
||||
|
||||
function backup_wiki_files_instance($bf,$preferences,$instanceid) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
@ -196,7 +195,6 @@
|
||||
|
||||
//Backup wiki binary files
|
||||
function backup_wiki_files($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
@ -227,7 +225,6 @@
|
||||
//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,"/");
|
||||
|
@ -22,9 +22,9 @@ if($lockid == 0) {
|
||||
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.
|
||||
|
@ -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);
|
||||
@ -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&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&course=$COURSE->id\">".fullname($user)."</a>";
|
||||
} else {
|
||||
continue;
|
||||
//$value = @$current['author'];
|
||||
|
@ -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"];
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ define("EWIKI_DB_TABLE_NAME", "wiki_pages");
|
||||
|
||||
|
||||
function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
global $wiki, $wiki_entry, $CFG;
|
||||
global $wiki, $wiki_entry, $CFG, $DB;
|
||||
#-- result array
|
||||
$r = array();
|
||||
|
||||
@ -32,8 +32,14 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
*/
|
||||
# Ugly, but we need to choose which wiki we are about to change/read
|
||||
case "GET":
|
||||
$id = "'" . anydb_escape_string($args["id"]) . "'";
|
||||
($version = 0 + @$args["version"]) and ($version = "AND (version=$version)") or ($version="");
|
||||
$params = array('id'=>$args["id"]);
|
||||
if ($version = 0 + @$args["version"]) {
|
||||
$params['version'] = $version;
|
||||
$versionsql = "AND version = :version";
|
||||
} else {
|
||||
$versionsql = "";
|
||||
|
||||
}
|
||||
|
||||
# $result = mysql_query("SELECT * FROM " . EWIKI_DB_TABLE_NAME
|
||||
# . " WHERE (pagename=$id) $version ORDER BY version DESC LIMIT 1"
|
||||
@ -46,9 +52,11 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
# $r["meta"] = @unserialize($r["meta"]);
|
||||
#}
|
||||
|
||||
$select="(pagename=$id) AND wiki=".$wiki_entry->id." $version ";
|
||||
$select="(pagename=:id) AND wiki= :weid $versionsql ";
|
||||
$params['weid'] = $wiki_entry->id;
|
||||
$sort="version DESC";
|
||||
if ($result_arr = get_records_select(EWIKI_DB_TABLE_NAME, $select,$sort,"*",0,1)) {
|
||||
|
||||
if ($result_arr = $DB->get_records_select(EWIKI_DB_TABLE_NAME, $select, $params, $sort,"*",0,1)) {
|
||||
//Iterate to get the first (and unique!)
|
||||
foreach ($result_arr as $obj) {
|
||||
$result_obj = $obj;
|
||||
@ -70,9 +78,9 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
*/
|
||||
case "HIT":
|
||||
#mysql_query("UPDATE " . EWIKI_DB_TABLE_NAME . " SET hits=(hits+1) WHERE pagename='" . anydb_escape_string($args["id"]) . "'");
|
||||
# set_field does not work because of the "hits+1" construct
|
||||
# $DB->set_field does not work because of the "hits+1" construct
|
||||
#print "DO ".anydb__escape_string($args["id"]); exit;
|
||||
execute_sql("UPDATE " .$CFG->prefix.EWIKI_DB_TABLE_NAME . " SET hits=(hits+1) WHERE pagename='" . anydb_escape_string($args["id"]) . "' and wiki=".$wiki_entry->id, 0);
|
||||
$DB->execute("UPDATE {".EWIKI_DB_TABLE_NAME."} SET hits=(hits+1) WHERE pagename=? and wiki=?", array($args["id"], $wiki_entry->id));
|
||||
break;
|
||||
/* Stores the $data array into the database, while not overwriting
|
||||
existing entries (using WRITE); returns 0 on failure and 1 if
|
||||
@ -113,13 +121,13 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
|
||||
# Check if Record exists
|
||||
if($COMMAND=="REPLACE") {
|
||||
if(count_records(EWIKI_DB_TABLE_NAME,"wiki", $wiki_entry->id,"pagename",$args["pagename"],"version",$args["version"])) {
|
||||
delete_record(EWIKI_DB_TABLE_NAME,"wiki", $wiki_entry->id,"pagename",$args["pagename"],"version",$args["version"]);
|
||||
if ($DB->count_records(EWIKI_DB_TABLE_NAME, array("wiki"=>$wiki_entry->id,"pagename"=>$args["pagename"],"version"=>$args["version"]))) {
|
||||
$DB->delete_record(EWIKI_DB_TABLE_NAME, array("wiki"=>$wiki_entry->id,"pagename"=>$args["pagename"],"version"=>$args["version"]));
|
||||
}
|
||||
}
|
||||
|
||||
# Write
|
||||
$result=insert_record(EWIKI_DB_TABLE_NAME,(object)$args,false);
|
||||
$result=$DB->insert_record(EWIKI_DB_TABLE_NAME,(object)$args,false);
|
||||
|
||||
#$result = mysql_query("$COMMAND INTO " . EWIKI_DB_TABLE_NAME .
|
||||
# " (" . $sql1 . ") VALUES (" . $sql2 . ")"
|
||||
@ -139,21 +147,22 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
*/
|
||||
case "FIND":
|
||||
$select = "";
|
||||
$params = array();
|
||||
$p=0;
|
||||
foreach (array_values($args) as $id) {
|
||||
if (strlen($id)) {
|
||||
$p++;
|
||||
$pname = "par$p";
|
||||
$r[$id] = 0;
|
||||
$select .= ($select ? " OR " : "") .
|
||||
"(pagename='" . anydb_escape_string($id) . "')";
|
||||
"(pagename= :$pname)";
|
||||
$params[$pname] = $id;
|
||||
}
|
||||
}
|
||||
if($select) {
|
||||
$select = "(".$select.") AND wiki=".$wiki_entry->id;
|
||||
$result = get_records_select(EWIKI_DB_TABLE_NAME,$select);
|
||||
#$sql = "SELECT pagename AS id, meta FROM " .
|
||||
# EWIKI_DB_TABLE_NAME . " WHERE $sql "
|
||||
#);
|
||||
#while ($result && ($row = mysql_fetch_row($result))) {
|
||||
# $r[$row[0]] = strpos($row[1], 's:5:"image"') ? $row[1] : 1;
|
||||
$select = "(".$select.") AND wiki= :weid ";
|
||||
$params['weid'] = $wiki_entry->id;
|
||||
$result = $DB->get_records_select(EWIKI_DB_TABLE_NAME,$select, $params);
|
||||
|
||||
while(list($key, $val) = @each($result)) {
|
||||
$r[$val->pagename]=strpos($val->meta, 's:5:"image"') ? $val->meta : 1;
|
||||
@ -165,12 +174,12 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
*/
|
||||
case "COUNTVERSIONS":
|
||||
$sql= "SELECT pagename AS id, count(*) as versioncount".
|
||||
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE wiki = ".$wiki_entry->id.
|
||||
" FROM {".EWIKI_DB_TABLE_NAME."}
|
||||
WHERE wiki = ?".
|
||||
" GROUP BY pagename";
|
||||
|
||||
#print "$sql";
|
||||
$result=get_records_sql($sql);
|
||||
$result=$DB->get_records_sql($sql, array($wiki_entry->id));
|
||||
while(list($key, $val) = each($result)) {
|
||||
$r[$key]=$val->versioncount;
|
||||
}
|
||||
@ -188,8 +197,8 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
// ON (pagename)
|
||||
$sql= "SELECT DISTINCT ON (pagename) pagename AS id, ".
|
||||
implode(", ", $args) .
|
||||
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE wiki = ".$wiki_entry->id.
|
||||
" FROM {".EWIKI_DB_TABLE_NAME."}".
|
||||
" WHERE wiki = ?".
|
||||
" ORDER BY pagename, version DESC";
|
||||
break;
|
||||
case 'mysql':
|
||||
@ -197,12 +206,12 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
// mysql-specific GROUP BY-semantics
|
||||
$sql= "SELECT pagename AS id, ".
|
||||
implode(", ", $args) .
|
||||
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE wiki = ".$wiki_entry->id.
|
||||
" FROM {".EWIKI_DB_TABLE_NAME."}".
|
||||
" WHERE wiki = ?".
|
||||
" GROUP BY id, version DESC " ;
|
||||
default:
|
||||
// All but the latest version are here eliminated in
|
||||
// get_records_sql, since it will return an array
|
||||
// $DB->get_records_sql, since it will return an array
|
||||
// with only one result per id-field value. Note,
|
||||
// that for this to work the query needs to order the
|
||||
// records ascending by version, so later versions
|
||||
@ -210,12 +219,12 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
// recordset_to_array. This is not pretty.
|
||||
$sql= "SELECT pagename AS id, ".
|
||||
implode(", ", $args) .
|
||||
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE wiki = ".$wiki_entry->id.
|
||||
" FROM {".EWIKI_DB_TABLE_NAME."}".
|
||||
" WHERE wiki = ?".
|
||||
" ORDER BY version";
|
||||
}
|
||||
|
||||
$result=get_records_sql($sql);
|
||||
$result = $DB->get_records_sql($sql, array($wiki_entry->id));
|
||||
$r = new ewiki_dbquery_result($args);
|
||||
|
||||
if ($result) {
|
||||
@ -239,10 +248,10 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
if ($field == "id") { $field = "pagename"; }
|
||||
$sql= "SELECT pagename AS id, version, flags" .
|
||||
(EWIKI_DBQUERY_BUFFER && ($field!="pagename") ? ", $field" : "") .
|
||||
" FROM " . $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE $field " . sql_ilike() . " '%".anydb_escape_string($content)."%' and wiki=".$wiki_entry->id .
|
||||
" FROM {".EWIKI_DB_TABLE_NAME."}".
|
||||
" WHERE $field " . $DB->sql_ilike() . " ? and wiki= ?".
|
||||
" ORDER BY id, version ASC";
|
||||
$result=get_records_sql($sql);
|
||||
$result=$DB->get_records_sql($sql, array("%$content%", $wiki_entry->id));
|
||||
|
||||
$r = new ewiki_dbquery_result(array("id","version",$field));
|
||||
$drop = "";
|
||||
@ -265,13 +274,13 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
|
||||
|
||||
case "DELETE":
|
||||
$id = anydb_escape_string($args["id"]);
|
||||
$id = $args["id"];
|
||||
$version = $args["version"];
|
||||
|
||||
#mysql_query("DELETE FROM " . EWIKI_DB_TABLE_NAME ."
|
||||
# WHERE pagename='$id' AND version=$version");
|
||||
# print "DELETING wiki:".$wiki_entry->id."Pagename: $id Version: $version <br />\n";
|
||||
delete_records(EWIKI_DB_TABLE_NAME,"wiki", $wiki_entry->id,"pagename",$id,"version",$version);
|
||||
$DB->delete_records(EWIKI_DB_TABLE_NAME, array("wiki"=>$wiki_entry->id,"pagename"=>$id,"version"=>$version));
|
||||
|
||||
break;
|
||||
|
||||
|
@ -7,8 +7,7 @@
|
||||
require_once($CFG->dirroot.'/mod/wiki/lib.php');
|
||||
|
||||
function wiki_filter($courseid, $text) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
// Trivial-cache - keyed on $cachedcourseid
|
||||
static $nothingtodo;
|
||||
@ -48,7 +47,7 @@
|
||||
|
||||
/// Walk through each entry and get the pages.
|
||||
foreach ($wiki_entries as $wiki_entry) {
|
||||
if ($wiki_pages = get_records('wiki_pages', 'wiki', $wiki_entry->id, 'pagename, version DESC')) {
|
||||
if ($wiki_pages = $DB->get_records('wiki_pages', array('wiki'=>$wiki_entry->id), 'pagename, version DESC')) {
|
||||
/// Walk through each page and filter.
|
||||
$wikientries = array();
|
||||
foreach ($wiki_pages as $wiki_page) {
|
||||
|
197
mod/wiki/lib.php
197
mod/wiki/lib.php
@ -178,15 +178,15 @@ function wiki_print_recent_activity($course, $isteacher, $timestart) {
|
||||
/// that has occurred in wiki activities and print it out.
|
||||
/// Return true if there was output, or false is there was none.
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l
|
||||
INNER JOIN {$CFG->prefix}course_modules cm ON l.cmid = cm.id
|
||||
WHERE l.time > '$timestart' AND l.course = {$course->id}
|
||||
AND l.module = 'wiki' AND action LIKE 'edit%'
|
||||
ORDER BY l.time ASC";
|
||||
$sql = "SELECT l.*, cm.instance
|
||||
FROM {log} l JOIN {course_modules} cm ON l.cmid = cm.id
|
||||
WHERE l.time > ? AND l.course = ?
|
||||
AND l.module = 'wiki' AND action LIKE 'edit%'
|
||||
ORDER BY l.time ASC";
|
||||
|
||||
if (!$logs = get_records_sql($sql)){
|
||||
if (!$logs = $DB->get_records_sql($sql, array($timestart, $course->id))){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -218,19 +218,20 @@ function wiki_print_recent_activity($course, $isteacher, $timestart) {
|
||||
}
|
||||
|
||||
function wiki_log_info($log) {
|
||||
global $CFG;
|
||||
return get_record_sql("SELECT u.firstname, u.lastname
|
||||
FROM {$CFG->prefix}user u
|
||||
WHERE u.id = '$log->userid'");
|
||||
global $CFG, $DB;
|
||||
return $DB->get_record_sql("SELECT u.firstname, u.lastname
|
||||
FROM {user} u
|
||||
WHERE u.id = ?", array($log->userid));
|
||||
}
|
||||
|
||||
function wiki_cron () {
|
||||
/// Function to be run periodically according to the moodle cron
|
||||
/// This function searches for things that need to be done, such
|
||||
/// as sending out mail, toggling flags etc ...
|
||||
global $DB;
|
||||
|
||||
// Delete expired locks
|
||||
$result=delete_records_select('wiki_locks','lockedseen < '.(time()-WIKI_LOCK_PERSISTENCE));
|
||||
$result = $DB->delete_records_select('wiki_locks','lockedseen < '.(time()-WIKI_LOCK_PERSISTENCE));
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -245,24 +246,20 @@ function wiki_grades($wikiid) {
|
||||
function wiki_get_participants($wikiid) {
|
||||
//Returns the users with data in one wiki
|
||||
//(users with records in wiki_pages and wiki_entries)
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
//Get users from wiki_pages
|
||||
$st_pages = get_records_sql("SELECT DISTINCT u.id, u.id
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}wiki_entries e,
|
||||
{$CFG->prefix}wiki_pages p
|
||||
WHERE e.wikiid = '$wikiid' and
|
||||
p.wiki = e.id and
|
||||
u.id = p.userid");
|
||||
$st_pages = $DB->get_records_sql("SELECT DISTINCT u.id, u.id
|
||||
FROM {user} u, {wiki_entries} e, {wiki_pages} p
|
||||
WHERE e.wikiid = ? and
|
||||
p.wiki = e.id and
|
||||
u.id = p.userid", array($wikiid));
|
||||
|
||||
//Get users from wiki_entries
|
||||
$st_entries = get_records_sql("SELECT DISTINCT u.id, u.id
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}wiki_entries e
|
||||
WHERE e.wikiid = '$wikiid' and
|
||||
u.id = e.userid");
|
||||
$st_entries = $DB->get_records_sql("SELECT DISTINCT u.id, u.id
|
||||
FROM {user} u, {wiki_entries} e
|
||||
WHERE e.wikiid = ? and
|
||||
u.id = e.userid", array($wikiid));
|
||||
|
||||
//Add entries to pages
|
||||
if ($st_entries) {
|
||||
@ -361,36 +358,40 @@ function wiki_content_dir(&$wiki) {
|
||||
|
||||
function wiki_get_course_wikis($courseid, $wtype='*') {
|
||||
/// Returns all wikis for the specified course and optionally of the specified type.
|
||||
global $DB;
|
||||
|
||||
$select = 'course = '.$courseid;
|
||||
$select = 'course = ?';
|
||||
$params = array($courseid);
|
||||
if ($wtype != '*') {
|
||||
$select .= ' AND wtype = \''.$wtype.'\'';
|
||||
$select .= ' AND wtype = ?';
|
||||
$params[] = $wtype;
|
||||
}
|
||||
return get_records_select('wiki', $select, 'id');
|
||||
return $DB->get_records_select('wiki', $select, $params, 'id');
|
||||
}
|
||||
|
||||
function wiki_has_entries(&$wiki) {
|
||||
/// Returns true if wiki already has wiki entries; otherwise false.
|
||||
global $DB;
|
||||
|
||||
return record_exists('wiki_entries', 'wikiid', $wiki->id);
|
||||
return $DB->record_exists('wiki_entries', array('wikiid'=>$wiki->id));
|
||||
}
|
||||
|
||||
function wiki_get_entries(&$wiki, $byindex=NULL) {
|
||||
/// Returns an array with all wiki entries indexed by entry id; false if there are none.
|
||||
/// If the optional $byindex is specified, returns the entries indexed by that field.
|
||||
/// Valid values for $byindex are 'student', 'group'.
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($byindex == 'student') {
|
||||
return get_records('wiki_entries', 'wikiid', $wiki->id, '',
|
||||
return $DB->get_records('wiki_entries', array('wikiid'=>$wiki->id), '',
|
||||
'userid,id,wikiid,course,groupid,pagename,timemodified');
|
||||
}
|
||||
else if ($byindex == 'group') {
|
||||
return get_records('wiki_entries', 'wikiid', $wiki->id, '',
|
||||
return $DB->get_records('wiki_entries', array('wikiid'=>$wiki->id), '',
|
||||
'groupid,id,wikiid,course,userid,pagename,timemodified');
|
||||
}
|
||||
else {
|
||||
return get_records('wiki_entries', 'wikiid', $wiki->id);
|
||||
return $DB->get_records('wiki_entries', array('wikiid'=>$wiki->id));
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,30 +506,32 @@ function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
}
|
||||
|
||||
function wiki_get_teacher_entry(&$wiki, $groupid=0) {
|
||||
global $DB;
|
||||
/// Returns the wiki entry for the wiki teacher type.
|
||||
return get_record('wiki_entries', 'wikiid', $wiki->id, 'course', $wiki->course, 'groupid', $groupid);
|
||||
return $DB->get_record('wiki_entries', array('wikiid'=>$wiki->id, 'course'=>$wiki->course, 'groupid'=>$groupid));
|
||||
}
|
||||
|
||||
function wiki_get_group_entry(&$wiki, $groupid=null) {
|
||||
global $DB;
|
||||
/// Returns the wiki entry for the given group.
|
||||
return get_record('wiki_entries', 'wikiid', $wiki->id, 'groupid', $groupid);
|
||||
return $DB->get_record('wiki_entries', array('wikiid'=>$wiki->id, 'groupid'=>$groupid));
|
||||
}
|
||||
|
||||
function wiki_get_student_entry(&$wiki, $userid=null) {
|
||||
/// Returns the wiki entry for the given student.
|
||||
global $USER;
|
||||
global $USER, $DB;
|
||||
|
||||
if (is_null($userid)) {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
return get_record('wiki_entries', 'wikiid', $wiki->id, 'userid', $userid);
|
||||
return $DB->get_record('wiki_entries', array('wikiid'=>$wiki->id, 'userid'=>$userid));
|
||||
}
|
||||
|
||||
function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
/// Returns a list of other wikis to display, depending on the type, group and user.
|
||||
/// Returns the key containing the currently selected entry as well.
|
||||
|
||||
global $CFG, $id;
|
||||
global $CFG, $id, $DB;
|
||||
|
||||
$wikis = false;
|
||||
|
||||
@ -555,11 +558,11 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
$wiki_entries = wiki_get_entries($wiki, 'student');
|
||||
|
||||
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
|
||||
$sql = "SELECT gm.userid FROM {$CFG->prefix}groups_members gm " .
|
||||
"INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid " .
|
||||
"WHERE gg.groupingid = $wiki->groupingid ";
|
||||
$sql = "SELECT gm.userid FROM {groups_members} gm " .
|
||||
"INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid " .
|
||||
"WHERE gg.groupingid = ? ";
|
||||
|
||||
$groupingmembers = get_records_sql($sql);
|
||||
$groupingmembers = $DB->get_records_sql($sql, array($wiki->groupingid));
|
||||
}
|
||||
|
||||
if ($isteacher and (SITEID != $course->id)) {
|
||||
@ -631,19 +634,21 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
/// Get all student wikis created, regardless of group.
|
||||
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
|
||||
$sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w '
|
||||
.' INNER JOIN '.$CFG->prefix.'user u ON w.userid = u.id '
|
||||
.' INNER JOIN '.$CFG->prefix.'groups_members gm ON gm.userid = u.id '
|
||||
.' INNER JOIN '.$CFG->prefix.'groupings_groups gg ON gm.groupid = gg.groupid '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND gg.groupingid = '.$wiki->groupingid
|
||||
.' FROM {wiki_entries} w '
|
||||
.' INNER JOIN {user} u ON w.userid = u.id '
|
||||
.' INNER JOIN {groups_members} gm ON gm.userid = u.id '
|
||||
.' INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid '
|
||||
.' WHERE w.wikiid = ? AND gg.groupingid = ?'
|
||||
.' ORDER BY w.id';
|
||||
$params = array($wiki->id, $wiki->groupingid);
|
||||
} else {
|
||||
$sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w, '.$CFG->prefix.'user u '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND u.id = w.userid '
|
||||
.' FROM {wiki_entries} w, {user} u '
|
||||
.' WHERE w.wikiid = ? AND u.id = w.userid '
|
||||
.' ORDER BY w.id';
|
||||
$params = array($wiki->id);
|
||||
}
|
||||
$wiki_entries = get_records_sql($sql);
|
||||
$wiki_entries = $DB->get_records_sql($sql, $params);
|
||||
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
|
||||
foreach ($wiki_entries as $wiki_entry) {
|
||||
$key = 'view.php?id='.$id.'&userid='.$wiki_entry->userid.'&page='.$wiki_entry->pagename;
|
||||
@ -671,19 +676,21 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
if ($viewall !== false) {
|
||||
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
|
||||
$sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w '
|
||||
.' INNER JOIN '.$CFG->prefix.'user u ON w.userid = u.id '
|
||||
.' INNER JOIN '.$CFG->prefix.'groups_members gm ON gm.userid = u.id '
|
||||
.' INNER JOIN '.$CFG->prefix.'groupings_groups gg ON gm.groupid = gg.groupid '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND gg.groupingid = '.$wiki->groupingid
|
||||
.' FROM {wiki_entries} w '
|
||||
.' INNER JOIN {user} u ON w.userid = u.id '
|
||||
.' INNER JOIN {groups_members} gm ON gm.userid = u.id '
|
||||
.' INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid '
|
||||
.' WHERE w.wikiid = ? AND gg.groupingid = ?'
|
||||
.' ORDER BY w.id';
|
||||
$params = array($wiki->id, $wiki->groupingid);
|
||||
} else {
|
||||
$sql = 'SELECT w.id, w.userid, w.pagename, u.firstname, u.lastname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w, '.$CFG->prefix.'user u '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND u.id = w.userid '
|
||||
.' FROM {wiki_entries} w, {user} u '
|
||||
.' WHERE w.wikiid = ? AND u.id = w.userid '
|
||||
.' ORDER BY w.id';
|
||||
$params = array($wiki->id);
|
||||
}
|
||||
$wiki_entries = get_records_sql($sql);
|
||||
$wiki_entries = $DB->get_records_sql($sql, $params);
|
||||
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
|
||||
foreach ($wiki_entries as $wiki_entry) {
|
||||
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid) && empty($groupingmembers[$wiki_entry->userid])) {
|
||||
@ -753,18 +760,20 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
else if ($groupmode == VISIBLEGROUPS) {
|
||||
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
|
||||
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w '
|
||||
.' INNER JOIN '.$CFG->prefix.'groups g ON g.id = w.groupid '
|
||||
.' INNER JOIN '.$CFG->prefix.'groupings_groups gg ON g.id = gg.groupid '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND gg.groupingid = '.$wiki->groupingid
|
||||
.' FROM {wiki_entries} w '
|
||||
.' INNER JOIN {groups} g ON g.id = w.groupid '
|
||||
.' INNER JOIN {groupings_groups} gg ON g.id = gg.groupid '
|
||||
.' WHERE w.wikiid = ? AND gg.groupingid = ?'
|
||||
.' ORDER BY w.groupid';
|
||||
$params = array($wiki->id, $wiki->groupingid);
|
||||
} else {
|
||||
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w, '.$CFG->prefix.'groups g '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND g.id = w.groupid '
|
||||
.' FROM {wiki_entries} w, {groups} g '
|
||||
.' WHERE w.wikiid = ? AND g.id = w.groupid '
|
||||
.' ORDER BY w.groupid';
|
||||
$params = array($wiki->id);
|
||||
}
|
||||
$wiki_entries = get_records_sql($sql);
|
||||
$wiki_entries = $DB->get_records_sql($sql, $params);
|
||||
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
|
||||
foreach ($wiki_entries as $wiki_entry) {
|
||||
$key = 'view.php?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
|
||||
@ -801,18 +810,20 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
else if ($groupmode) {
|
||||
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
|
||||
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w '
|
||||
.' INNER JOIN '.$CFG->prefix.'groups g ON g.id = w.groupid '
|
||||
.' INNER JOIN '.$CFG->prefix.'groupings_groups gg ON g.id = gg.groupid '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND gg.groupingid = '.$wiki->groupingid
|
||||
.' FROM {wiki_entries} w '
|
||||
.' INNER JOIN {groups} g ON g.id = w.groupid '
|
||||
.' INNER JOIN {groupings_groups} gg ON g.id = gg.groupid '
|
||||
.' WHERE w.wikiid = ? AND gg.groupingid = ?'
|
||||
.' ORDER BY w.groupid';
|
||||
$params = array($wiki->id, $wiki->groupingid);
|
||||
} else {
|
||||
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w, '.$CFG->prefix.'groups g '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND g.id = w.groupid '
|
||||
.' FROM {wiki_entries} w, {groups} g '
|
||||
.' WHERE w.wikiid = ? AND g.id = w.groupid '
|
||||
.' ORDER BY w.groupid';
|
||||
$params = array($wiki->id);
|
||||
}
|
||||
$wiki_entries = get_records_sql($sql);
|
||||
$wiki_entries = $DB->get_records_sql($sql, $params);
|
||||
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
|
||||
foreach ($wiki_entries as $wiki_entry) {
|
||||
$key = 'view.php?id='.$id.($wiki_entry->groupid?"&groupid=".$wiki_entry->groupid:"").'&page='.$wiki_entry->pagename;
|
||||
@ -838,18 +849,20 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
if ($viewall !== false) {
|
||||
if (!empty($CFG->enablegroupings) && !empty($wiki->groupingid)) {
|
||||
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w '
|
||||
.' INNER JOIN '.$CFG->prefix.'groups g ON g.id = w.groupid '
|
||||
.' INNER JOIN '.$CFG->prefix.'groupings_groups gg ON g.id = gg.groupid '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND gg.groupingid = '.$wiki->groupingid
|
||||
.' FROM {wiki_entries} w '
|
||||
.' INNER JOIN {groups} g ON g.id = w.groupid '
|
||||
.' INNER JOIN {groupings_groups} gg ON g.id = gg.groupid '
|
||||
.' WHERE w.wikiid = ? AND gg.groupingid = ?'
|
||||
.' ORDER BY w.groupid';
|
||||
$params = array($wiki->id, $wiki->groupingid);
|
||||
} else {
|
||||
$sql = 'SELECT w.id, w.groupid, w.pagename, g.name as gname '
|
||||
.' FROM '.$CFG->prefix.'wiki_entries w, '.$CFG->prefix.'groups g '
|
||||
.' WHERE w.wikiid = '.$wiki->id.' AND g.id = w.groupid '
|
||||
.' FROM {wiki_entries} w, {groups} g '
|
||||
.' WHERE w.wikiid = ? AND g.id = w.groupid '
|
||||
.' ORDER BY w.groupid';
|
||||
$params = array($wiki->id);
|
||||
}
|
||||
$wiki_entries = get_records_sql($sql);
|
||||
$wiki_entries = $DB->get_records_sql($sql, $params);
|
||||
$wiki_entries=is_array($wiki_entries)?$wiki_entries:array();
|
||||
|
||||
|
||||
@ -875,7 +888,7 @@ function wiki_add_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
/// No checking is done here. It is assumed that the caller has the correct
|
||||
/// privileges to add this entry.
|
||||
|
||||
global $USER;
|
||||
global $USER, $DB;
|
||||
|
||||
/// If this wiki already has a wiki_type entry, return false.
|
||||
if (wiki_get_entry($wiki, $course, $userid, $groupid) !== false) {
|
||||
@ -932,9 +945,9 @@ function wiki_add_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
$wiki_entry->timemodified = time();
|
||||
break;
|
||||
}
|
||||
$wiki_entry->pagename = addslashes($wiki_entry->pagename);
|
||||
$wiki_entry->pagename = $wiki_entry->pagename;
|
||||
|
||||
return insert_record("wiki_entries", $wiki_entry, true);
|
||||
return $DB->insert_record("wiki_entries", $wiki_entry, true);
|
||||
}
|
||||
|
||||
function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
|
||||
@ -1134,15 +1147,17 @@ function wiki_user_can_access_teacher_wiki(&$wiki, $groupid, &$course) {
|
||||
}
|
||||
|
||||
function wiki_get_owner(&$wiki_entry) {
|
||||
global $DB;
|
||||
|
||||
if ($wiki_entry->userid > 0) {
|
||||
$user = get_record('user', 'id', $wiki_entry->userid);
|
||||
$user = $DB->get_record('user', array('id'=>$wiki_entry->userid));
|
||||
$owner = fullname($user);
|
||||
}
|
||||
else if ($wiki_entry->groupid > 0) {
|
||||
$owner = groups_get_group_name($wiki_entry->groupid); //TODO:check.
|
||||
}
|
||||
else if ($wiki_entry->course > 0) {
|
||||
$course = get_record('course', 'id', $wiki_entry->course);
|
||||
$course = $DB->get_record('course', array('id'=>$wiki_entry->course));
|
||||
$owner = $course->shortname;
|
||||
}
|
||||
else {
|
||||
@ -1670,11 +1685,11 @@ function wiki_get_post_actions() {
|
||||
* held by current user then the the second element has a member ->id only.
|
||||
*/
|
||||
function wiki_obtain_lock($wikiid,$pagename) {
|
||||
global $USER;
|
||||
global $USER, $DB;
|
||||
|
||||
// Check for lock
|
||||
$alreadyownlock=false;
|
||||
if($lock=get_record('wiki_locks','pagename',$pagename,'wikiid', $wikiid)) {
|
||||
if($lock=$DB->get_record('wiki_locks', array('pagename'=>$pagename,'wikiid'=>$wikiid))) {
|
||||
// Consider the page locked if the lock has been confirmed within WIKI_LOCK_PERSISTENCE seconds
|
||||
if($lock->lockedby==$USER->id) {
|
||||
// Cool, it's our lock, do nothing except remember it in session
|
||||
@ -1684,7 +1699,7 @@ function wiki_obtain_lock($wikiid,$pagename) {
|
||||
return array(false,$lock);
|
||||
} else {
|
||||
// Not locked any more. Get rid of the old lock record.
|
||||
if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wikiid)) {
|
||||
if(!$DB->delete_records('wiki_locks', array('pagename'=>$pagename,'wikiid'=>$wikiid))) {
|
||||
print_error('Unable to delete lock record');
|
||||
}
|
||||
}
|
||||
@ -1699,7 +1714,7 @@ function wiki_obtain_lock($wikiid,$pagename) {
|
||||
$newlock->lockedseen=$newlock->lockedsince;
|
||||
$newlock->wikiid=$wikiid;
|
||||
$newlock->pagename=$pagename;
|
||||
if(!$lockid=insert_record('wiki_locks',$newlock)) {
|
||||
if(!$lockid=$DB->insert_record('wiki_locks',$newlock)) {
|
||||
print_error('Unable to insert lock record');
|
||||
}
|
||||
}
|
||||
@ -1724,6 +1739,8 @@ function wiki_obtain_lock($wikiid,$pagename) {
|
||||
* @param string $pagename Name of page.
|
||||
*/
|
||||
function wiki_release_lock($wikiid,$pagename) {
|
||||
global $DB;
|
||||
|
||||
if(!array_key_exists(SESSION_WIKI_LOCKS,$_SESSION)) {
|
||||
// No locks at all in session
|
||||
return;
|
||||
@ -1734,7 +1751,7 @@ function wiki_release_lock($wikiid,$pagename) {
|
||||
if(array_key_exists($key,$_SESSION[SESSION_WIKI_LOCKS])) {
|
||||
$lockid=$_SESSION[SESSION_WIKI_LOCKS][$key];
|
||||
unset($_SESSION[SESSION_WIKI_LOCKS][$key]);
|
||||
if(!delete_records('wiki_locks','id',$lockid)) {
|
||||
if (!$DB->delete_records('wiki_locks', array('id'=>$lockid))) {
|
||||
print_error("Unable to delete lock record.");
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ $page=required_param('page',PARAM_RAW);
|
||||
if (! $cm = get_coursemodule_from_id('wiki', $id)) {
|
||||
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");
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ $actions = explode('/', $page,2);
|
||||
if(count($actions)!=2) {
|
||||
print_error("Unsupported page value");
|
||||
}
|
||||
$pagename=addslashes($actions[1]);
|
||||
if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wiki->id)) {
|
||||
$pagename=$actions[1];
|
||||
if(!$DB->delete_records('wiki_locks', array('pagename'=>$pagename, 'wikiid'=>$wiki->id))) {
|
||||
print_error('Unable to delete lock record');
|
||||
}
|
||||
|
||||
|
@ -41,19 +41,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", $wid)) {
|
||||
if (! $wiki = $DB->get_record("wiki", array("id"=>$wid))) {
|
||||
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)) {
|
||||
@ -262,11 +262,11 @@
|
||||
/// Moodle Log
|
||||
if ($editsave != NULL) { /// We've submitted an edit and have been redirected back here
|
||||
add_to_log($course->id, "wiki", 'edit',
|
||||
addslashes("view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$ewiki_title"),
|
||||
"view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$ewiki_title",
|
||||
format_string($wiki->name,true).": ".$ewiki_title, $cm->id, $userid);
|
||||
} else if ($ewiki_action != 'edit') {
|
||||
add_to_log($course->id, "wiki", $ewiki_action,
|
||||
addslashes("view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$ewiki_title"),
|
||||
"view.php?id=$cm->id&groupid=$groupid&userid=$userid&page=$ewiki_title",
|
||||
format_string($wiki->name,true).": ".$ewiki_title, $cm->id, $userid);
|
||||
}
|
||||
|
||||
@ -417,7 +417,7 @@
|
||||
$a=new stdClass;
|
||||
$a->since=userdate($lock->lockedsince);
|
||||
$a->seen=userdate($lock->lockedseen);
|
||||
$user=get_record('user','id',$lock->lockedby);
|
||||
$user=$DB->get_record('user', array('id'=>$lock->lockedby));
|
||||
$a->name=fullname($user,
|
||||
has_capability('moodle/site:viewfullnames', $modcontext));
|
||||
|
||||
@ -443,7 +443,7 @@
|
||||
} else {
|
||||
if (ajaxenabled()) {
|
||||
// OK, the page is now locked to us. Put in the AJAX for keeping the lock
|
||||
$strlockcancelled=addslashes(get_string('lockcancelled','wiki'));
|
||||
$strlockcancelled=addslashes_js(get_string('lockcancelled','wiki'));
|
||||
$strnojslockwarning=get_string('nojslockwarning','wiki');
|
||||
$intervalms=WIKI_LOCK_RECONFIRM*1000;
|
||||
print "
|
||||
|
@ -1017,7 +1017,7 @@ function tag_unset_flag($tagids) {
|
||||
$tagids = implode(',', $tagids);
|
||||
}
|
||||
$timemodified = time();
|
||||
return $DB->execute_sql("UPDATE {tag} tg SET tg.flag = 0, tg.timemodified = ? WHERE tg.id IN ($tagids)", array($timemodified));
|
||||
return $DB->execute("UPDATE {tag} tg SET tg.flag = 0, tg.timemodified = ? WHERE tg.id IN ($tagids)", array($timemodified));
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user