本文整理汇总了PHP中ElggFile::canEdit方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggFile::canEdit方法的具体用法?PHP ElggFile::canEdit怎么用?PHP ElggFile::canEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggFile
的用法示例。
在下文中一共展示了ElggFile::canEdit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pleio_api_delete_file
function pleio_api_delete_file($file_id)
{
$user = elgg_get_logged_in_user_entity();
$user_id = $user !== false ? $user->guid : 0;
if ($file_id && $user_id) {
if (strlen($file_id) != 32) {
$file = new ElggFile($file_id);
if ($file && $file->guid && $file->canEdit($user_id) && $file->delete()) {
return new SuccessResult(elgg_echo("file:deleted"));
}
} else {
$url = pleio_api_swordfish_baseurl() . "delete-file?id=" . $file_id;
$swordfish_name = pleio_api_swordfish_username($user->username);
$result = pleio_api_call_swordfish_api($swordfish_name, $url, "POST");
if ($result->ok) {
return new SuccessResult(elgg_echo("file:deleted"));
}
}
}
return new ErrorResult(elgg_echo("file:deletefailed"));
}
示例2: ElggFile
elgg_load_library('odt_editor:locking');
// Get variables
$file_guid = (int) get_input('file_guid');
$lock_guid = get_input('lock_guid');
$lock_set = (int) get_input('lock_set') == 1;
$user_guid = elgg_get_logged_in_user_guid();
// load original file object
$file = new ElggFile($file_guid);
if (!$file) {
if ($lock) {
register_error(elgg_echo('odt_editor:error:file_removed'));
}
forward(REFERER);
}
// user must be able to edit file
if (!$file->canEdit()) {
register_error(elgg_echo('You do no longer have write access to the file that is edited.'));
forward(REFERER);
}
// save folder guid in parameter to make sure file_tools_object_handler does not overwrite the relationship
$relationships = get_entity_relationships($file->guid, FILE_TOOLS_RELATIONSHIP, true);
if (elgg_is_active_plugin('file_tools') && count($relationships) > 0) {
set_input('folder_guid', $relationships[0]->guid_one);
}
// recreate lock, user closed window but cancelled
if ($lock_set && !odt_editor_locking_is_locked($file)) {
trigger_error("Restored lock", E_USER_WARNING);
odt_editor_locking_create_lock($file, $user_guid, $lock_guid);
forward(REFERER);
}
// check for lost lock
示例3: forward
if (isset($params->container_guid)) {
$container = get_entity($params->container_guid);
} else {
$container = elgg_get_logged_in_user_entity();
}
}
if (!$container instanceof ElggEntity) {
register_error(elgg_echo('images:error:not_found'));
forward(REFERRER);
}
if (!$entity) {
$entity = new ElggFile();
$entity->subtype = 'file';
$entity->container_guid = $container ? $container->guid : elgg_get_logged_in_user_guid();
}
if (!$entity->canEdit() || !$container->canWriteToContainer(0, $entity->getType(), $entity->getSubtype())) {
register_error(elgg_echo('images:error:permission_denied'));
forward(REFERRER);
}
$entity = images()->createFromUpload('upload', $entity);
if (!$entity) {
register_error(elgg_echo('images:upload:error:invalid_file'));
forward(REFERRER);
}
$entity->title = $params->title;
$entity->description = $params->description;
$entity->tags = string_to_tag_array((string) $params->tags);
$entity->access_id = isset($params->access_id) ? $params->access_id : get_default_access();
if ($entity->save()) {
if (elgg_is_xhr()) {
echo json_encode($entity->toObject());