本文整理汇总了PHP中repository::sync_external_file方法的典型用法代码示例。如果您正苦于以下问题:PHP repository::sync_external_file方法的具体用法?PHP repository::sync_external_file怎么用?PHP repository::sync_external_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repository
的用法示例。
在下文中一共展示了repository::sync_external_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_external_file
/**
* Convert file alias to local file
*
* @param stored_file $storedfile a stored_file instances
* @return stored_file stored_file
*/
public function import_external_file(stored_file $storedfile)
{
global $CFG;
require_once $CFG->dirroot . '/repository/lib.php';
// sync external file
repository::sync_external_file($storedfile);
// Remove file references
$storedfile->delete_reference();
return $storedfile;
}
示例2: sync_external_file
/**
* Synchronize file if it is a reference and needs synchronizing
*
* Updates contenthash and filesize
*/
public function sync_external_file()
{
global $CFG;
if (!empty($this->file_record->referencefileid)) {
require_once $CFG->dirroot . '/repository/lib.php';
repository::sync_external_file($this);
}
}
示例3: sync_external_file
/**
* Sync external files
*
* @return bool true if file content changed, false if not
*/
public function sync_external_file()
{
global $CFG, $DB;
if (empty($this->file_record->referencefileid)) {
return false;
}
if (empty($this->file_record->referencelastsync) or $this->file_record->referencelastsync + $this->file_record->referencelifetime < time()) {
require_once $CFG->dirroot . '/repository/lib.php';
if (repository::sync_external_file($this)) {
$prevcontent = $this->file_record->contenthash;
$sql = "SELECT f.*, r.repositoryid, r.reference\n FROM {files} f\n LEFT JOIN {files_reference} r\n ON f.referencefileid = r.id\n WHERE f.id = ?";
$this->file_record = $DB->get_record_sql($sql, array($this->file_record->id), MUST_EXIST);
return $prevcontent !== $this->file_record->contenthash;
}
}
return false;
}