本文整理汇总了PHP中assign::can_upgrade_assignment方法的典型用法代码示例。如果您正苦于以下问题:PHP assign::can_upgrade_assignment方法的具体用法?PHP assign::can_upgrade_assignment怎么用?PHP assign::can_upgrade_assignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assign
的用法示例。
在下文中一共展示了assign::can_upgrade_assignment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_mod_assign
/**
* This function will attempt to upgrade the newly restored assignment to an instance of mod_assign if
* mod_assignment is currently disabled and mod_assign is enabled and mod_assign says it can upgrade this assignment.
*
* @return none
*/
private function upgrade_mod_assign()
{
global $DB, $CFG;
// The current module must exist.
$pluginmanager = core_plugin_manager::instance();
$plugininfo = $pluginmanager->get_plugin_info('mod_assign');
// Check that the assignment module is installed.
if ($plugininfo && $plugininfo->is_installed_and_upgraded()) {
// Include the required mod assign upgrade code.
require_once $CFG->dirroot . '/mod/assign/upgradelib.php';
require_once $CFG->dirroot . '/mod/assign/locallib.php';
// Get the id and type of this assignment.
$newinstance = $this->task->get_activityid();
$record = $DB->get_record('assignment', array('id' => $newinstance), 'assignmenttype', MUST_EXIST);
$type = $record->assignmenttype;
$subplugininfo = $pluginmanager->get_plugin_info('assignment_' . $type);
// See if it is possible to upgrade.
if (assign::can_upgrade_assignment($type, $subplugininfo->versiondb)) {
$assignment_upgrader = new assign_upgrade_manager();
$log = '';
$success = $assignment_upgrader->upgrade_assignment($newinstance, $log);
if (!$success) {
throw new restore_step_exception('mod_assign_upgrade_failed', $log);
}
}
}
}
示例2: tool_assignmentupgrade_load_all_upgradable_assignmentids
/**
* Load a list of all the assignmentids that can be upgraded
* @return array of assignment ids
*/
function tool_assignmentupgrade_load_all_upgradable_assignmentids()
{
global $DB, $CFG;
require_once $CFG->dirroot . '/mod/assign/locallib.php';
// first find all the unique assignment types
$types = $DB->get_records_sql('SELECT plugin AS assignmenttype, value AS version FROM {config_plugins} WHERE name = ? AND plugin LIKE ?', array('version', 'assignment_%'));
$upgradabletypes = array();
foreach ($types as $assignment) {
$shorttype = substr($assignment->assignmenttype, strlen('assignment_'));
if (assign::can_upgrade_assignment($shorttype, $assignment->version)) {
$upgradabletypes[] = $shorttype;
}
}
list($sql, $params) = $DB->get_in_or_equal($upgradabletypes);
$records = $DB->get_records_sql('SELECT id from {assignment} where assignmenttype ' . $sql, $params);
$ids = array();
foreach ($records as $record) {
$ids[] = $record->id;
}
return $ids;
}