当前位置: 首页>>代码示例>>PHP>>正文


PHP file_storage::get_pathname_hash方法代码示例

本文整理汇总了PHP中file_storage::get_pathname_hash方法的典型用法代码示例。如果您正苦于以下问题:PHP file_storage::get_pathname_hash方法的具体用法?PHP file_storage::get_pathname_hash怎么用?PHP file_storage::get_pathname_hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file_storage的用法示例。


在下文中一共展示了file_storage::get_pathname_hash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmldb_hvp_upgrade


//.........这里部分代码省略.........
            $dbman->add_field($table, $timecreated);
        }
        // Define field timemodified to be added to hvp.
        $timemodified = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'timecreated');
        // Conditionally launch add field timemodified.
        if (!$dbman->field_exists($table, $timemodified)) {
            $dbman->add_field($table, $timemodified);
        }
        // Hvp savepoint reached.
        upgrade_mod_savepoint(true, 2016011300, 'hvp');
    }
    if ($oldversion < 2016042500) {
        // Define table hvp_tmpfiles to be created.
        $table = new xmldb_table('hvp_tmpfiles');
        // Adding fields to table hvp_tmpfiles.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table hvp_tmpfiles.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for hvp_tmpfiles.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Hvp savepoint reached.
        upgrade_mod_savepoint(true, 2016042500, 'hvp');
    }
    if ($oldversion < 2016050600) {
        // Define table hvp_events to be created.
        $table = new xmldb_table('hvp_events');
        // Adding fields to table hvp_events.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('user_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('created_at', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('type', XMLDB_TYPE_CHAR, '63', null, XMLDB_NOTNULL, null, null);
        $table->add_field('sub_type', XMLDB_TYPE_CHAR, '63', null, XMLDB_NOTNULL, null, null);
        $table->add_field('content_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        $table->add_field('content_title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
        $table->add_field('library_name', XMLDB_TYPE_CHAR, '127', null, XMLDB_NOTNULL, null, null);
        $table->add_field('library_version', XMLDB_TYPE_CHAR, '31', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table hvp_events.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Conditionally launch create table for hvp_events.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Define table hvp_counters to be created.
        $table = new xmldb_table('hvp_counters');
        // Adding fields to table hvp_counters.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
        $table->add_field('type', XMLDB_TYPE_CHAR, '63', null, XMLDB_NOTNULL, null, null);
        $table->add_field('library_name', XMLDB_TYPE_CHAR, '127', null, XMLDB_NOTNULL, null, null);
        $table->add_field('library_version', XMLDB_TYPE_CHAR, '31', null, XMLDB_NOTNULL, null, null);
        $table->add_field('num', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
        // Adding keys to table hvp_counters.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
        // Adding indexes to table hvp_counters.
        $table->add_index('realkey', XMLDB_INDEX_NOTUNIQUE, array('type', 'library_name', 'library_version'));
        // Conditionally launch create table for hvp_counters.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }
        // Hvp savepoint reached.
        upgrade_mod_savepoint(true, 2016050600, 'hvp');
    }
    if ($oldversion < 2016051000) {
        $table = new xmldb_table('hvp');
        // Define field timecreated to be added to hvp.
        $intro = new xmldb_field('intro', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
        // Conditionally launch add field timecreated.
        if (!$dbman->field_exists($table, $intro)) {
            $dbman->add_field($table, $intro);
        }
        // Define field timemodified to be added to hvp.
        $introformat = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'intro');
        // Conditionally launch add field timemodified.
        if (!$dbman->field_exists($table, $introformat)) {
            $dbman->add_field($table, $introformat);
        }
        // Hvp savepoint reached.
        upgrade_mod_savepoint(true, 2016051000, 'hvp');
    }
    if ($oldversion < 2016110100) {
        // Change context of activity files from COURSE to MODULE.
        $filearea = 'content';
        $component = 'mod_hvp';
        // Find activity ID and correct context ID
        $hvpsresult = $DB->get_records_sql("SELECT f.id AS fileid, f.itemid, c.id, f.filepath, f.filename, f.pathnamehash\n                   FROM {files} f\n                   JOIN {course_modules} cm ON f.itemid = cm.instance\n                   JOIN {modules} md ON md.id = cm.module\n                   JOIN {context} c ON c.instanceid = cm.id\n                  WHERE md.name = 'hvp'\n                    AND f.filearea = 'content'\n                    AND c.contextlevel = " . CONTEXT_MODULE);
        foreach ($hvpsresult as $hvp) {
            // Need to re-hash pathname after changing context
            $pathnamehash = file_storage::get_pathname_hash($hvp->id, $component, $filearea, $hvp->itemid, $hvp->filepath, $hvp->filename);
            // Double check that hash doesn't exist (avoid duplicate entries)
            if (!$DB->get_field_sql("SELECT contextid FROM {files} WHERE pathnamehash = '{$pathnamehash}'")) {
                // Update context ID and pathname hash for files
                $DB->execute("UPDATE {files} SET contextid = {$hvp->id}, pathnamehash = '{$pathnamehash}' WHERE pathnamehash = '{$hvp->pathnamehash}'");
            }
        }
        // Hvp savepoint reached.
        upgrade_mod_savepoint(true, 2016110100, 'hvp');
    }
    return true;
}
开发者ID:h5p,项目名称:h5p-moodle-plugin,代码行数:101,代码来源:upgrade.php


注:本文中的file_storage::get_pathname_hash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。