本文整理汇总了PHP中CUtils::getFileVersions方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtils::getFileVersions方法的具体用法?PHP CUtils::getFileVersions怎么用?PHP CUtils::getFileVersions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtils
的用法示例。
在下文中一共展示了CUtils::getFileVersions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recover
/**
* 历史版本恢复
* @param int $deviceId
* @param string $filePath
* @param string $signature
* @return bool
*/
public function recover($deviceId, $filePath, $signature)
{
$version = MiniVersion::getInstance()->getBySignature($signature);
$file = $this->getModelByPath($filePath);
if ($version["id"] == $file['version_id']) {
return true;
}
$device = MiniUserDevice::getInstance()->getById($deviceId);
$userId = $device["user_id"];
$user = MiniUser::getInstance()->getUser($userId);
$userNick = $user["nick"];
// events表 相关操作
$userDeviceName = $device["user_device_name"];
$userDeviceId = $device["id"];
$signature = $version['file_signature'];
$action = CConst::MODIFY_FILE;
$file->file_update_time = time();
$context = array('hash' => $signature, 'rev' => (int) $version["id"], 'bytes' => (int) $version['file_size'], 'update_time' => (int) $file->file_update_time, 'create_time' => (int) $file['file_create_time']);
$filePath = $file['file_path'];
$eventUuid = MiniUtil::getEventRandomString(CConst::LEN_EVENT_UUID);
MiniEvent::getInstance()->createEvent($file['user_id'], $userDeviceId, $action, $filePath, serialize($context), $eventUuid);
//create event
// files表相关操作
$file->version_id = $version["id"];
$file->event_uuid = $eventUuid;
$file->file_size = $version['file_size'];
$file->save();
// meta表相关操作
$fileMeta = FileMeta::model()->find('file_path = ?', array($filePath));
$versions = CUtils::getFileVersions($userDeviceName, $version['file_size'], $version["id"], CConst::WEB_RESTORE, $userId, $userNick, $fileMeta['meta_value']);
$fileMeta->meta_value = $versions;
$fileMeta->save();
//更新版本引用数
MiniVersion::getInstance()->updateRefCountByIds(array($version["id"]), TRUE);
return true;
}
示例2: handleFileMeta
/**
*
* 更新文件meta信息,删除时添加版本
* @param UserFile $file
*/
public function handleFileMeta($filePath, $versionId, $userId, $userNick, $deviceName, $fileSize)
{
//
// 查询之前的版本
//
$meta = new FileMeta();
$meta = $meta->getFileMeta($filePath, "version");
if ($meta) {
$value = CUtils::getFileVersions($deviceName, $fileSize, $versionId, $this->_action, $userId, $userNick, $meta["meta_value"]);
$meta["meta_value"] = $value;
} else {
$value = CUtils::getFileVersions($deviceName, $fileSize, $versionId, $this->_action, $userId, $userNick);
$meta["file_path"] = $filePath;
$meta["meta_key"] = "version";
$meta["meta_value"] = $value;
}
return $meta->save();
}
示例3: _saveFileMeta
/**
* 为更名文件创建meta版本
*/
private function _saveFileMeta($filePath, $versionId, $userId, $userNick, $action, $deviceName, $fileSize)
{
//
// 获取文件旧版本
//
$meta = FileMeta::model()->findByAttributes(array('file_path' => $filePath, 'meta_key' => 'version'));
if (!$meta) {
$meta = new FileMeta();
$value = CUtils::getFileVersions($deviceName, $fileSize, $versionId, $action, $userId, $userNick);
$meta["file_path"] = $filePath;
$meta["meta_key"] = "version";
$meta["meta_value"] = serialize(array());
}
$value = CUtils::getFileVersions($deviceName, $fileSize, $versionId, $action, $userId, $userNick, $meta["meta_value"]);
$meta["meta_value"] = $value;
$meta->save();
if ($action == MConst::CREATE_FILE || $action == MConst::MODIFY_FILE || $action == CConst::WEB_RESTORE) {
FileVersion::model()->updateRefCountByIds(array($versionId), TRUE);
}
}
示例4: handleFileMeta
/** 创建meta信息
*/
public function handleFileMeta($filePath, $versionId, $userId, $userNick, $action, $deviceName, $fileSize)
{
//
// 查询之前的版本
//
$handler = new FileMeta();
$meta = $handler->getFileMeta($filePath, "version");
if (!$meta) {
$meta = new FileMeta();
$meta["file_path"] = $filePath;
$meta["meta_key"] = "version";
$meta["meta_value"] = serialize(array());
}
$value = CUtils::getFileVersions($deviceName, $fileSize, $versionId, $action, $userId, $userNick, $meta["meta_value"]);
$meta["meta_value"] = $value;
if ($action == MConst::CREATE_FILE || $action == MConst::MODIFY_FILE || $action == CConst::WEB_RESTORE) {
FileVersion::model()->updateRefCountByIds(array($versionId), TRUE);
}
return $meta->save();
}