Skip to content

Commit

Permalink
MDL-61363 tag: add change_instances_context function
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwyllie committed Mar 7, 2018
1 parent 694710d commit 8376557
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tag/classes/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -958,10 +958,28 @@ public static function change_items_context($component, $itemtype, $itemids, $ne
if ($newcontext instanceof context) {
$newcontext = $newcontext->id;
}

$DB->set_field_select('tag_instance', 'contextid', $newcontext,
'component = :component AND itemtype = :itemtype AND itemid ' . $sql, $params);
}

/**
* Moves all of the specified tag instances into a new context.
*
* @param array $taginstanceids The list of tag instance ids that should be moved
* @param context $newcontext The context to move the tag instances into
*/
public static function change_instances_context(array $taginstanceids, context $newcontext) {
global $DB;

if (empty($taginstanceids)) {
return;
}

list($sql, $params) = $DB->get_in_or_equal($taginstanceids);
$DB->set_field_select('tag_instance', 'contextid', $newcontext->id, "id {$sql}", $params);
}

/**
* Updates the information about the tag
*
Expand Down

0 comments on commit 8376557

Please sign in to comment.