mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-15094 towards full dml conversion
This commit is contained in:
parent
73ee9fd8f9
commit
d9cde0edeb
@ -342,13 +342,17 @@ class moodle_list{
|
||||
$this->reorder_peers($peers);
|
||||
}
|
||||
function reorder_peers($peers){
|
||||
global $DB;
|
||||
|
||||
foreach ($peers as $key => $peer) {
|
||||
if (! set_field("{$this->table}", "sortorder", $key, "id", $peer)) {
|
||||
if (! $DB->set_field($this->table, "sortorder", $key, array("id"=>$peer))) {
|
||||
print_error('listupdatefail');
|
||||
}
|
||||
}
|
||||
}
|
||||
function move_item_left($id) {
|
||||
global $DB;
|
||||
|
||||
$item = $this->find_item($id);
|
||||
if (!isset($item->parentlist->parentitem->parentlist)){
|
||||
print_error('listcantmoveleft');
|
||||
@ -359,7 +363,7 @@ class moodle_list{
|
||||
} else {
|
||||
$newparent = 0; // top level item
|
||||
}
|
||||
if (!set_field("{$this->table}", "parent", $newparent, "id", $item->id)) {
|
||||
if (!$DB->set_field($this->table, "parent", $newparent, array("id"=>$item->id))) {
|
||||
print_error('listupdatefail');
|
||||
} else {
|
||||
$oldparentkey = array_search($item->parentlist->parentitem->id, $newpeers);
|
||||
@ -374,12 +378,14 @@ class moodle_list{
|
||||
* @param integer $id
|
||||
*/
|
||||
function move_item_right($id) {
|
||||
global $DB;
|
||||
|
||||
$peers = $this->get_items_peers($id);
|
||||
$itemkey = array_search($id, $peers);
|
||||
if (!isset($peers[$itemkey-1])){
|
||||
print_error('listcantmoveright');
|
||||
} else {
|
||||
if (!set_field("{$this->table}", "parent", $peers[$itemkey-1], "id", $peers[$itemkey])) {
|
||||
if (!$DB->set_field($this->table, "parent", $peers[$itemkey-1], array("id"=>$peers[$itemkey]))) {
|
||||
print_error('listupdatefail');
|
||||
} else {
|
||||
$newparent = $this->find_item($peers[$itemkey-1]);
|
||||
@ -432,7 +438,7 @@ class moodle_list{
|
||||
}
|
||||
}
|
||||
|
||||
class list_item{
|
||||
class list_item {
|
||||
/**
|
||||
* id of record, used if list is editable
|
||||
*
|
||||
|
@ -364,35 +364,5 @@ class WikiToMarkdown {
|
||||
//return $buffer;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function update( $thing, $textfield, $formatfield, $coursesql='' ) {
|
||||
// converts the text in a particular activity (or sub-activity)
|
||||
// $thing = the database name for that 'thing' (eg, resource, choice)
|
||||
// $textfield = the name of the field that might hold the wiki-text
|
||||
// $formatfield = the name of the field that contains the format type
|
||||
// $coursesql = if supplied, the query to get the courseid, if not get from the 'course' field
|
||||
// ($id of record is tacked on right at the end, so phrase accordingly)
|
||||
// returns a count of records converted
|
||||
$count = 0;
|
||||
if ($records = get_records( $thing,$formatfield,FORMAT_WIKI )) {
|
||||
foreach( $records as $record ) {
|
||||
$text = $record->$textfield;
|
||||
$id = $record->id;
|
||||
if (!$coursesql) {
|
||||
$courseid = $record->course;
|
||||
} else {
|
||||
$r = get_record_sql( $coursesql . "$id" );
|
||||
$courseid = $r->course;
|
||||
}
|
||||
$newtext = $this->convert( $text,$courseid );
|
||||
|
||||
$record->$textfield = $newtext;
|
||||
$record->$formatfield = FORMAT_MARKDOWN;
|
||||
update_record( $thing, addslashes_object( $record ) );
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user