本文整理汇总了PHP中upgrade_mimetypes函数的典型用法代码示例。如果您正苦于以下问题:PHP upgrade_mimetypes函数的具体用法?PHP upgrade_mimetypes怎么用?PHP upgrade_mimetypes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upgrade_mimetypes函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmldb_main_upgrade
//.........这里部分代码省略.........
$table = new xmldb_table('log');
$columns = $DB->get_columns('log');
if ($columns['action']->max_length < 40) {
$index1 = new xmldb_index('course-module-action', XMLDB_INDEX_NOTUNIQUE, array('course', 'module', 'action'));
if ($dbman->index_exists($table, $index1)) {
$dbman->drop_index($table, $index1);
}
$index2 = new xmldb_index('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
if ($dbman->index_exists($table, $index2)) {
$dbman->drop_index($table, $index2);
}
$field = new xmldb_field('action', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, 'cmid');
$dbman->change_field_precision($table, $field);
$dbman->add_index($table, $index1);
$dbman->add_index($table, $index2);
}
if ($columns['url']->max_length < 100) {
$field = new xmldb_field('url', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'action');
$dbman->change_field_precision($table, $field);
}
upgrade_main_savepoint(true, 2014051200.02);
}
if ($oldversion < 2014060300.0) {
$gspath = get_config('assignfeedback_editpdf', 'gspath');
if ($gspath !== false) {
set_config('pathtogs', $gspath);
unset_config('gspath', 'assignfeedback_editpdf');
}
upgrade_main_savepoint(true, 2014060300.0);
}
if ($oldversion < 2014061000.0) {
// Fixing possible wrong MIME type for Publisher files.
$filetypes = array('%.pub' => 'application/x-mspublisher');
upgrade_mimetypes($filetypes);
upgrade_main_savepoint(true, 2014061000.0);
}
if ($oldversion < 2014062600.01) {
// We only want to delete DragMath if the directory no longer exists. If the directory
// is present then it means it has been restored, so do not perform the uninstall.
if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) {
// Purge DragMath plugin which is incompatible with GNU GPL license.
unset_all_config_for_plugin('tinymce_dragmath');
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2014062600.01);
}
// Switch the order of the fields in the files_reference index, to improve the performance of search_references.
if ($oldversion < 2014070100.0) {
$table = new xmldb_table('files_reference');
$index = new xmldb_index('uq_external_file', XMLDB_INDEX_UNIQUE, array('repositoryid', 'referencehash'));
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
upgrade_main_savepoint(true, 2014070100.0);
}
if ($oldversion < 2014070101.0) {
$table = new xmldb_table('files_reference');
$index = new xmldb_index('uq_external_file', XMLDB_INDEX_UNIQUE, array('referencehash', 'repositoryid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
upgrade_main_savepoint(true, 2014070101.0);
}
if ($oldversion < 2014072400.01) {
$table = new xmldb_table('user_devices');
$oldindex = new xmldb_index('pushid-platform', XMLDB_KEY_UNIQUE, array('pushid', 'platform'));
示例2: xmldb_main_upgrade
/**
* Main upgrade tasks to be executed on Moodle version bump
*
* This function is automatically executed after one bump in the Moodle core
* version is detected. It's in charge of performing the required tasks
* to raise core from the previous version to the next one.
*
* It's a collection of ordered blocks of code, named "upgrade steps",
* each one performing one isolated (from the rest of steps) task. Usually
* tasks involve creating new DB objects or performing manipulation of the
* information for cleanup/fixup purposes.
*
* Each upgrade step has a fixed structure, that can be summarised as follows:
*
* if ($oldversion < XXXXXXXXXX.XX) {
* // Explanation of the update step, linking to issue in the Tracker if necessary
* upgrade_set_timeout(XX); // Optional for big tasks
* // Code to execute goes here, usually the XMLDB Editor will
* // help you here. See {@link http://docs.moodle.org/dev/XMLDB_editor}.
* upgrade_main_savepoint(true, XXXXXXXXXX.XX);
* }
*
* All plugins within Moodle (modules, blocks, reports...) support the existence of
* their own upgrade.php file, using the "Frankenstyle" component name as
* defined at {@link http://docs.moodle.org/dev/Frankenstyle}, for example:
* - {@link xmldb_page_upgrade($oldversion)}. (modules don't require the plugintype ("mod_") to be used.
* - {@link xmldb_auth_manual_upgrade($oldversion)}.
* - {@link xmldb_workshopform_accumulative_upgrade($oldversion)}.
* - ....
*
* In order to keep the contents of this file reduced, it's allowed to create some helper
* functions to be used here in the {@link upgradelib.php} file at the same directory. Note
* that such a file must be manually included from upgrade.php, and there are some restrictions
* about what can be used within it.
*
* For more information, take a look to the documentation available:
* - Data definition API: {@link http://docs.moodle.org/dev/Data_definition_API}
* - Upgrade API: {@link http://docs.moodle.org/dev/Upgrade_API}
*
* @param int $oldversion
* @return bool always true
*/
function xmldb_main_upgrade($oldversion)
{
global $CFG, $DB;
require_once $CFG->libdir . '/db/upgradelib.php';
// Core Upgrade-related functions.
$dbman = $DB->get_manager();
// Loads ddl manager and xmldb classes.
// Always keep this upgrade step with version being the minimum
// allowed version to upgrade from (v2.7.0 right now).
if ($oldversion < 2014051200) {
// Just in case somebody hacks upgrade scripts or env, we really can not continue.
echo "You need to upgrade to 2.7.x or higher first!\n";
exit(1);
// Note this savepoint is 100% unreachable, but needed to pass the upgrade checks.
upgrade_main_savepoint(true, 2014051200);
}
// MDL-32543 Make sure that the log table has correct length for action and url fields.
if ($oldversion < 2014051200.02) {
$table = new xmldb_table('log');
$columns = $DB->get_columns('log');
if ($columns['action']->max_length < 40) {
$index1 = new xmldb_index('course-module-action', XMLDB_INDEX_NOTUNIQUE, array('course', 'module', 'action'));
if ($dbman->index_exists($table, $index1)) {
$dbman->drop_index($table, $index1);
}
$index2 = new xmldb_index('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
if ($dbman->index_exists($table, $index2)) {
$dbman->drop_index($table, $index2);
}
$field = new xmldb_field('action', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, 'cmid');
$dbman->change_field_precision($table, $field);
$dbman->add_index($table, $index1);
$dbman->add_index($table, $index2);
}
if ($columns['url']->max_length < 100) {
$field = new xmldb_field('url', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'action');
$dbman->change_field_precision($table, $field);
}
upgrade_main_savepoint(true, 2014051200.02);
}
if ($oldversion < 2014060300.0) {
$gspath = get_config('assignfeedback_editpdf', 'gspath');
if ($gspath !== false) {
set_config('pathtogs', $gspath);
unset_config('gspath', 'assignfeedback_editpdf');
}
upgrade_main_savepoint(true, 2014060300.0);
}
if ($oldversion < 2014061000.0) {
// Fixing possible wrong MIME type for Publisher files.
$filetypes = array('%.pub' => 'application/x-mspublisher');
upgrade_mimetypes($filetypes);
upgrade_main_savepoint(true, 2014061000.0);
}
if ($oldversion < 2014062600.01) {
// We only want to delete DragMath if the directory no longer exists. If the directory
// is present then it means it has been restored, so do not perform the uninstall.
if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) {
//.........这里部分代码省略.........
示例3: xmldb_main_upgrade
/**
* Main upgrade tasks to be executed on Moodle version bump
*
* This function is automatically executed after one bump in the Moodle core
* version is detected. It's in charge of performing the required tasks
* to raise core from the previous version to the next one.
*
* It's a collection of ordered blocks of code, named "upgrade steps",
* each one performing one isolated (from the rest of steps) task. Usually
* tasks involve creating new DB objects or performing manipulation of the
* information for cleanup/fixup purposes.
*
* Each upgrade step has a fixed structure, that can be summarised as follows:
*
* if ($oldversion < XXXXXXXXXX.XX) {
* // Explanation of the update step, linking to issue in the Tracker if necessary
* upgrade_set_timeout(XX); // Optional for big tasks
* // Code to execute goes here, usually the XMLDB Editor will
* // help you here. See {@link http://docs.moodle.org/dev/XMLDB_editor}.
* upgrade_main_savepoint(true, XXXXXXXXXX.XX);
* }
*
* All plugins within Moodle (modules, blocks, reports...) support the existence of
* their own upgrade.php file, using the "Frankenstyle" component name as
* defined at {@link http://docs.moodle.org/dev/Frankenstyle}, for example:
* - {@link xmldb_page_upgrade($oldversion)}. (modules don't require the plugintype ("mod_") to be used.
* - {@link xmldb_auth_manual_upgrade($oldversion)}.
* - {@link xmldb_workshopform_accumulative_upgrade($oldversion)}.
* - ....
*
* In order to keep the contents of this file reduced, it's allowed to create some helper
* functions to be used here in the {@link upgradelib.php} file at the same directory. Note
* that such a file must be manually included from upgrade.php, and there are some restrictions
* about what can be used within it.
*
* For more information, take a look to the documentation available:
* - Data definition API: {@link http://docs.moodle.org/dev/Data_definition_API}
* - Upgrade API: {@link http://docs.moodle.org/dev/Upgrade_API}
*
* @param int $oldversion
* @return bool always true
*/
function xmldb_main_upgrade($oldversion)
{
global $CFG, $DB;
require_once $CFG->libdir . '/db/upgradelib.php';
// Core Upgrade-related functions.
$dbman = $DB->get_manager();
// Loads ddl manager and xmldb classes.
// Always keep this upgrade step with version being the minimum
// allowed version to upgrade from (v2.7.0 right now).
if ($oldversion < 2014051200) {
// Just in case somebody hacks upgrade scripts or env, we really can not continue.
echo "You need to upgrade to 2.7.x or higher first!\n";
exit(1);
// Note this savepoint is 100% unreachable, but needed to pass the upgrade checks.
upgrade_main_savepoint(true, 2014051200);
}
// MDL-32543 Make sure that the log table has correct length for action and url fields.
if ($oldversion < 2014051200.02) {
$table = new xmldb_table('log');
$columns = $DB->get_columns('log');
if ($columns['action']->max_length < 40) {
$index1 = new xmldb_index('course-module-action', XMLDB_INDEX_NOTUNIQUE, array('course', 'module', 'action'));
if ($dbman->index_exists($table, $index1)) {
$dbman->drop_index($table, $index1);
}
$index2 = new xmldb_index('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
if ($dbman->index_exists($table, $index2)) {
$dbman->drop_index($table, $index2);
}
$field = new xmldb_field('action', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, null, 'cmid');
$dbman->change_field_precision($table, $field);
$dbman->add_index($table, $index1);
$dbman->add_index($table, $index2);
}
if ($columns['url']->max_length < 100) {
$field = new xmldb_field('url', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'action');
$dbman->change_field_precision($table, $field);
}
upgrade_main_savepoint(true, 2014051200.02);
}
if ($oldversion < 2014060300.0) {
$gspath = get_config('assignfeedback_editpdf', 'gspath');
if ($gspath !== false) {
set_config('pathtogs', $gspath);
unset_config('gspath', 'assignfeedback_editpdf');
}
upgrade_main_savepoint(true, 2014060300.0);
}
if ($oldversion < 2014061000.0) {
// Fixing possible wrong MIME type for Publisher files.
$filetypes = array('%.pub' => 'application/x-mspublisher');
upgrade_mimetypes($filetypes);
upgrade_main_savepoint(true, 2014061000.0);
}
if ($oldversion < 2014062600.01) {
// We only want to delete DragMath if the directory no longer exists. If the directory
// is present then it means it has been restored, so do not perform the uninstall.
if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) {
//.........这里部分代码省略.........