function form_delete_file($file_id) { $file = get_entity($file_id); if ($file->canEdit()) { $thumbnail = $file->thumbnail; $smallthumb = $file->smallthumb; $largethumb = $file->largethumb; if ($thumbnail) { $delfile = new ElggFile(); $delfile->owner_guid = $file->owner_guid; $delfile->setFilename($thumbnail); $delfile->delete(); } if ($smallthumb) { $delfile = new ElggFile(); $delfile->owner_guid = $file->owner_guid; $delfile->setFilename($smallthumb); $delfile->delete(); } if ($largethumb) { $delfile = new ElggFile(); $delfile->owner_guid = $file->owner_guid; $delfile->setFilename($largethumb); $delfile->delete(); } return $file->delete(); } }
/** * Remove the icon of a blog * * @param ElggBlog $blog The blog to remove the icon from * * @return bool */ function blog_tools_remove_blog_icon(ElggBlog $blog) { $result = false; if (!empty($blog) && elgg_instanceof($blog, "object", "blog", "ElggBlog")) { if (!empty($blog->icontime)) { $icon_sizes = elgg_get_config("icon_sizes"); if (!empty($icon_sizes)) { $fh = new ElggFile(); $fh->owner_guid = $blog->getOwnerGUID(); $prefix = "blogs/" . $blog->getGUID(); foreach ($icon_sizes as $name => $info) { $fh->setFilename($prefix . $name . ".jpg"); if ($fh->exists()) { $fh->delete(); } } } unset($blog->icontime); $result = true; } else { $result = true; } } return $result; }
/** * Delete image * * @return bool */ public function delete() { $thumb_image = get_entity($this->thumb_file_guid); if ($thumb_image) { $thumb_image->delete(); } return parent::delete(); }
public function delete() { $thumbnails = array($this->thumbnail, $this->smallthumb, $this->largethumb); foreach ($thumbnails as $thumbnail) { if ($thumbnail) { $delfile = new ElggFile(); $delfile->owner_guid = $this->owner_guid; $delfile->setFilename($thumbnail); $delfile->delete(); } } return parent::delete(); }
/** * Delete item photo from diskspace * * @return boolean */ public function del_photo() { $photo_sizes = elgg_get_config('amapnews_photo_sizes'); foreach ($photo_sizes as $name => $photo_info) { $file = new ElggFile(); $file->owner_guid = $this->owner_guid; $file->setFilename("amapnews/{$this->getGUID()}{$name}.jpg"); $filepath = $file->getFilenameOnFilestore(); if (!$file->delete()) { // do nothing } } return true; }
/** * Resets all cache on the static pages * * @param string $event 'cache:flush' * @param string $type 'system' * @param mixed $entity the entity about to be removed * * @return void */ public static function resetAllCache($event, $type, $entity) { // fetch all top pages $options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => false, 'relationship' => 'subpage_of']; // ignore access $ia = elgg_set_ignore_access(true); $batch = new \ElggBatch('elgg_get_entities_from_relationship', $options); foreach ($batch as $entity) { // reset cache for the pages $file = new \ElggFile(); $file->owner_guid = $entity->guid; $file->setFilename('static_menu_item_cache'); if ($file->exists()) { $file->delete(); } } elgg_set_ignore_access($ia); }
/** * Override ElggFile::delete() * * After deleting the file delete also the directory. * * @return bool */ public function delete() { $fs = $this->getFilestore(); $dir = $this->getFileDirectory(); // Delete the file on disc if ($fs->delete($this)) { // Delete the ElggFile entity if (parent::delete()) { // Delete the directory if (is_dir($dir)) { if (rmdir($dir)) { return true; } else { elgg_add_admin_notice('video_dir_delete_failed', elgg_echo('video:dir_delete_failed', $dir)); } } } } return false; }
protected function saveThumbnail($image, $name) { try { $thumbnail = get_resized_image_from_existing_file($image->getFilenameOnFilestore(), 60, 60, true); } catch (Exception $e) { return FALSE; } $thumb = new ElggFile(); $thumb->setMimeType('image/jpeg'); $thumb->access_id = $this->access_id; $thumb->setFilename($name); $thumb->open("write"); $thumb->write($thumbnail); $thumb->save(); $image->thumbnail_guid = $thumb->getGUID(); if (!$thumb->getGUID()) { $thumb->delete(); return FALSE; } return TRUE; }
public function delete() { $icon_sizes = hj_framework_get_thumb_sizes($this->getSubtype()); $prefix_old = "hjfile/{$this->container_guid}/{$this->guid}"; $prefix_old_alt = "hjfile/{$this->guid}"; $prefix = "icons/{$this->guid}"; foreach ($icon_sizes as $size => $values) { $thumb = new ElggFile(); $thumb->owner_guid = elgg_get_logged_in_user_guid(); $thumb->setFilename("{$prefix}{$size}.jpg"); $thumb->delete(); $thumb = new ElggFile(); $thumb->owner_guid = elgg_get_logged_in_user_guid(); $thumb->setFilename("{$prefix_old}{$size}.jpg"); $thumb->delete(); $thumb = new ElggFile(); $thumb->owner_guid = elgg_get_logged_in_user_guid(); $thumb->setFilename("{$prefix_old_alt}{$size}.jpg"); $thumb->delete(); } return parent::delete(); }
/** * Remove the icon of a blog * * @param ElggBlog $blog The blog to remove the icon from * * @return bool */ function blog_tools_remove_blog_icon(ElggBlog $blog) { if (!$blog instanceof ElggBlog) { return false; } if (empty($blog->icontime)) { // no icon return true; } $icon_sizes = elgg_get_icon_sizes('object', 'blog'); if (!empty($icon_sizes)) { $fh = new ElggFile(); $fh->owner_guid = $blog->getOwnerGUID(); $prefix = "blogs/{$blog->getGUID()}"; foreach ($icon_sizes as $name => $info) { $fh->setFilename("{$prefix}{$name}.jpg"); if ($fh->exists()) { $fh->delete(); } } } unset($blog->icontime); return true; }
<?php $group_guid = get_input('group_guid'); if (!empty($group_guid) && ($group = get_entity($group_guid))) { if (elgg_instanceof($group, "group") && $group->canEdit()) { if ($layouts = $group->getEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION, false, false)) { foreach ($layouts as $layout) { if (!empty($layout->background)) { $bgf = new ElggFile(); $bgf->owner_guid = $group->getGUID(); $bgf->setFilename(GROUP_CUSTOM_LAYOUT_BACKGROUND); $bgf->delete(); } if ($layout->delete()) { system_message(elgg_echo('group_custom_layout:action:reset:success')); } else { register_error(elgg_echo('group_custom_layout:action:reset:error:remove')); } } } else { register_error(elgg_echo('group_custom_layout:action:reset:error:no_custom')); } } else { register_error(elgg_echo('group_custom_layout:action:reset:error:no_group')); } } else { register_error(elgg_echo('group_custom_layout:action:reset:error:input')); } forward(REFERER);
$videolist_item = get_entity($guid); if (!$videolist_item->guid) { register_error(elgg_echo("videolist:deletefailed")); forward('videolist/all'); } if (!$videolist_item->canEdit()) { register_error(elgg_echo("videolist:deletefailed")); forward($videolist_item->getURL()); } $container = $videolist_item->getContainerEntity(); $owner_guid = $videolist_item->getOwnerGUID(); $url = $videolist_item->getURL(); if (!$videolist_item->delete()) { register_error(elgg_echo("videolist:deletefailed")); } else { // Remove the video thumbnail $file = new ElggFile(); $file->owner_guid = $owner_guid; $file->setFilename("videolist/{$guid}.jpg"); $file->delete(); system_message(elgg_echo("videolist:deleted")); } // we can't come back to video url because it's deleted if ($url != $_SERVER['HTTP_REFERER']) { forward(REFERER); } if (elgg_instanceof($container, 'group')) { forward("videolist/group/{$container->guid}/all"); } else { forward("videolist/owner/{$container->username}"); }
/** * Update the user profile icon based on profile_sync data * * @param string $event the name of the event * @param string $type the type of the event * @param mixed $object supplied object * * @return void */ function theme_haarlem_intranet_profile_sync_profile_icon($event, $type, $object) { if (empty($object) || !is_array($object)) { return; } $user = elgg_extract('entity', $object); if (empty($user) || !elgg_instanceof($user, 'user')) { return; } // handle icons $datasource = elgg_extract('datasource', $object); $source_row = elgg_extract('source_row', $object); if (empty($datasource) || empty($source_row)) { return; } // handle custom icon $fh = new ElggFile(); $fh->owner_guid = $user->getGUID(); $icon_sizes = elgg_get_config('icon_sizes'); $icon_path = elgg_extract('profielfoto', $source_row); $icon_path = profile_sync_filter_var($icon_path); if (empty($icon_path)) { // remove icon foreach ($icon_sizes as $size => $info) { $fh->setFilename("haarlem_icon/{$size}.jpg"); if ($fh->exists()) { $fh->delete(); } } unset($user->haarlem_icontime); return; } $csv_location = $datasource->csv_location; if (empty($csv_location)) { return; } $csv_filename = basename($csv_location); $base_location = rtrim(str_ireplace($csv_filename, "", $csv_location), DIRECTORY_SEPARATOR); $icon_path = sanitise_filepath($icon_path, false); // prevent abuse (like ../../......) $icon_path = ltrim($icon_path, DIRECTORY_SEPARATOR); // remove beginning / $icon_path = $base_location . DIRECTORY_SEPARATOR . $icon_path; // concat base location and rel path // icon exists if (!file_exists($icon_path)) { return; } // was csv image updated $csv_iconsize = @filesize($icon_path); if ($csv_iconsize !== false) { $csv_iconsize = md5($csv_iconsize); $icontime = $user->haarlem_icontime; if ($csv_iconsize === $icontime) { // icons are the same return; } } // try to get the user icon $icon_contents = file_get_contents($icon_path); if (empty($icon_contents)) { return; } // make sure we have a hash to save if ($csv_iconsize === false) { $csv_iconsize = strlen($icon_contents); $csv_iconsize = md5($csv_iconsize); } // write icon to a temp location for further handling $tmp_icon = tempnam(sys_get_temp_dir(), $user->getGUID()); file_put_contents($tmp_icon, $icon_contents); // resize icon $icon_updated = false; foreach ($icon_sizes as $size => $icon_info) { $icon_contents = get_resized_image_from_existing_file($tmp_icon, $icon_info["w"], $icon_info["h"], $icon_info["square"], 0, 0, 0, 0, $icon_info["upscale"]); if (empty($icon_contents)) { continue; } $fh->setFilename("haarlem_icon/{$size}.jpg"); $fh->open("write"); $fh->write($icon_contents); $fh->close(); $icon_updated = true; } // did we have a successfull icon upload? if ($icon_updated) { $user->haarlem_icontime = $csv_iconsize; } // cleanup unlink($tmp_icon); }
/** * Deletes a video, override for the parent delete * * @return boolean */ public function delete() { // in case of an uploaded video make sure it's also deleted from queue and trash // with related media if it still remained there if ($this->videotype == 'uploaded') { $queue_object = new izapQueue(); $queue_object->delete_from_trash($this->guid, true); $queue_object->delete($this->guid, true); } $imagesrc = $this->imagesrc; $filesrc = $this->videofile; $ofilesrc = $this->orignalfile; //delete entity from elgg db and corresponding files if exist $this->setFilename($imagesrc); $image_file = $this->getFilenameOnFilestore(); file_exists($image_file) && @unlink($image_file); $this->setFilename($filesrc); $video_file = $this->getFilenameOnFilestore(); file_exists($video_file) && @unlink($video_file); $this->setFilename($ofilesrc); $orignal_file = $this->getFilenameOnFilestore(); file_exists($orignal_file) && @unlink($orignal_file); return parent::delete(); }
/** * Delete an ElggFile file * * @param int $guid ElggFile GUID * * @return bool */ function file_delete($guid) { if ($file = get_entity($guid)) { if ($file->canEdit()) { $container = get_entity($file->container_guid); $thumbnail = $file->thumbnail; $smallthumb = $file->smallthumb; $largethumb = $file->largethumb; if ($thumbnail) { $delfile = new ElggFile(); $delfile->owner_guid = $file->owner_guid; $delfile->setFilename($thumbnail); $delfile->delete(); } if ($smallthumb) { $delfile = new ElggFile(); $delfile->owner_guid = $file->owner_guid; $delfile->setFilename($smallthumb); $delfile->delete(); } if ($largethumb) { $delfile = new ElggFile(); $delfile->owner_guid = $file->owner_guid; $delfile->setFilename($largethumb); $delfile->delete(); } return $file->delete(); } } return false; }
/** * Make thumbnails of given video position. Defaults to beginning of video. * * @param Video $video The video object * @param int $position Video position */ function video_create_thumbnails($video, $position = 0) { $icon_sizes = elgg_get_config('icon_sizes'); $square = elgg_get_plugin_setting('square_icons', 'video'); // Default to square thumbnail images if (is_null($square)) { $square = true; } $square = $square == 1 ? true : false; $dir = $video->getFileDirectory(); $guid = $video->getGUID(); // Use default thumbnail as master $imagepath = "{$dir}/icon-master.jpg"; try { $thumbnailer = new VideoThumbnailer(); $thumbnailer->setInputFile($video->getFilenameOnFilestore()); $thumbnailer->setOutputFile($imagepath); $thumbnailer->setPosition($position); $thumbnailer->execute(); } catch (exception $e) { $msg = elgg_echo('VideoException:ThumbnailCreationFailed', array($video->getFilenameOnFilestore(), $e->getMessage(), $thumbnailer->getCommand())); error_log($msg); elgg_add_admin_notice('video_thumbnailing_error', $msg); return false; } $files = array(); // Create the thumbnails foreach ($icon_sizes as $name => $size_info) { // We have already created master image if ($name == 'master') { continue; } $resized = get_resized_image_from_existing_file($imagepath, $size_info['w'], $size_info['h'], $square); if ($resized) { $file = new ElggFile(); $file->owner_guid = $video->owner_guid; $file->container_guid = $guid; $file->setFilename("video/{$guid}/icon-{$name}.jpg"); $file->open('write'); $file->write($resized); $file->close(); $files[] = $file; } else { error_log("ERROR: Failed to create thumbnail '{$name}' for video {$video->getFilenameOnFilestore()}."); // Delete all images if one fails foreach ($files as $file) { $file->delete(); } return false; } } $video->icontime = time(); return true; }
/** * Delete the album directory on disk */ protected function deleteAlbumDir() { $tmpfile = new ElggFile(); $tmpfile->setFilename('image/' . $this->guid . '/._tmp_del_tidypics_album_'); $tmpfile->subtype = 'image'; $tmpfile->owner_guid = $this->owner_guid; $tmpfile->container_guid = $this->guid; $tmpfile->open("write"); $tmpfile->write(''); $tmpfile->close(); $tmpfile->save(); $albumdir = eregi_replace('/._tmp_del_tidypics_album_', '', $tmpfile->getFilenameOnFilestore()); $tmpfile->delete(); // sanity check: must be a directory if (!($handle = opendir($albumdir))) { return false; } // loop through all files that might still remain undeleted in this directory and delete them // note: this does not delete the corresponding image entities from the database while (($file = readdir($handle)) !== false) { if (in_array($file, array('.', '..'))) { continue; } $path = "{$albumdir}/{$file}"; unlink($path); } // remove empty directory closedir($handle); return rmdir($albumdir); }
/** * Removes a file based on a guid * * @param int $guid guid of the document to be deleted * * @return void */ function elasticsearch_remove_document_for_deletion($guid) { if (empty($guid)) { return; } $plugin = elgg_get_plugin_from_id('elasticsearch'); $fh = new ElggFile(); $fh->owner_guid = $plugin->getGUID(); $fh->setFilename("documents_for_deletion/{$guid}"); $fh->delete(); }
<?php /** * Avatar remove action */ $guid = get_input('guid'); $user = get_entity($guid); if ($user) { // Delete all icons from diskspace $icon_sizes = elgg_get_config('icon_sizes'); foreach ($icon_sizes as $name => $size_info) { $file = new ElggFile(); $file->owner_guid = $guid; $file->setFilename("profile/{$guid}{$name}.jpg"); $filepath = $file->getFilenameOnFilestore(); if (!$file->delete()) { elgg_log("Avatar file remove failed. Remove {$filepath} manually, please.", 'WARNING'); } } // Remove crop coords unset($user->x1); unset($user->x2); unset($user->y1); unset($user->y2); // Remove icon unset($user->icontime); system_message(elgg_echo('avatar:remove:success')); } else { register_error(elgg_echo('avatar:remove:fail')); } forward(REFERER);
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")); }
<?php $guid = (int) get_input('guid'); $filename = get_input('file'); if (!empty($guid) && !empty($filename)) { $event = false; if ($entity = get_entity($guid)) { if ($entity->getSubtype() == Event::SUBTYPE) { $event = $entity; } } if ($event && $event->canEdit()) { $files = json_decode($event->files, true); foreach ($files as $index => $file) { if (strtolower($file["file"]) == strtolower($filename)) { $prefix = "events/" . $event->getGUID() . "/files/"; $fileHandler = new ElggFile(); $fileHandler->owner_guid = $event->owner_guid; $fileHandler->setFilename($prefix . $file->file); $fileHandler->delete(); unset($files[$index]); } } $event->files = json_encode($files); } forward(REFERER); } register_error(elgg_echo('event_manager:event:file:notfound:text')); forward(REFERER);
$nfh = new ElggFile(); $nfh->owner_guid = $group->getOwnerGUID(); foreach ($sizes as $size) { // set correct file to handle $ofh->setFilename($prefix . $size . ".jpg"); $nfh->setFilename($prefix . $size . ".jpg"); // open files $ofh->open("read"); $nfh->open("write"); // copy file $nfh->write($ofh->grabFile()); // close file $ofh->close(); $nfh->close(); // cleanup old file $ofh->delete(); } $group->icontime = time(); } // move metadata of the group to the new owner $options = array("guid" => $group->getGUID(), "limit" => false); if ($metadata = elgg_get_metadata($options)) { foreach ($metadata as $md) { if ($md->owner_guid == $old_owner->getGUID()) { $md->owner_guid = $new_owner->getGUID(); $md->save(); } } } // notify new owner if ($new_owner->getGUID() != $loggedin_user->getGUID()) {
$start = true; } } if (!$manifest) { register_error(elgg_echo('plugin_installer:upload:error:nomanifest')); } elseif (!$start) { register_error(elgg_echo('plugin_installer:upload:error:nostart')); } else { if (!file_exists($CONFIG->pluginspath . $plugin_name) || $overwrite) { $extract = $zip->extractTo($CONFIG->pluginspath); $zip->close(); if ($extract === TRUE && file_exists($CONFIG->pluginspath . $plugin_name)) { disable_plugin($plugin_name); enable_plugin($plugin_name); regenerate_plugin_list(); system_message(elgg_echo('plugin_installer:upload:success')); } else { register_error(elgg_echo('plugin_installer:upload:error:unzip')); } } else { register_error(elgg_echo('plugin_installer:upload:error:pluginexists')); } } } else { register_error(elgg_echo('plugin_installer:upload:error')); } $filehandler->delete(); } else { register_error(elgg_echo('plugin_installer:upload:missing')); } forward($_SERVER['HTTP_REFERER']);
/** * Removes the thumbnail * * @return void */ public function removeThumbnail() { if (empty($this->icontime)) { return; } $fh = new \ElggFile(); $fh->owner_guid = $this->getGUID(); $prefix = 'thumb'; $icon_sizes = elgg_get_config('icon_sizes'); if (empty($icon_sizes)) { return; } foreach ($icon_sizes as $size => $info) { $fh->setFilename($prefix . $size . '.jpg'); if ($fh->exists()) { $fh->delete(); } } unset($this->icontime); }
/** * Removes the file cache for keywords * * @return void */ function search_advanced_clear_keywords_cache() { $plugin_entity = elgg_get_plugin_from_id("search_advanced"); if ($plugin_entity) { // check if cachefile exists, if exists delete it $file = new ElggFile(); $file->owner_guid = $plugin_entity->getGUID(); $file->setFilename("search_advanced_keywords_cache.json"); if ($file->exists()) { $file->delete(); } } }
/** * Deletes the previous uploaded icon * * @param string $type Icon type * @return bool */ public function deleteIcon($type = 'icon') { if ($type == 'icon') { $fh = new \ElggFile(); $fh->owner_guid = $this->guid; $icon_sizes = elgg_get_icon_sizes('object', 'event'); foreach ($icon_sizes as $name => $info) { $fh->setFilename("{$name}.jpg"); if ($fh->exists()) { $fh->delete(); } } unset($this->icontime); } return parent::deleteIcon($type); }
$guid = (int) get_input('guid'); $entity = get_entity($guid); if (!$entity->canEdit()) { register_error(elgg_echo('group:notdeleted')); forward(REFERER); } if ($entity && $entity instanceof ElggGroup) { // delete group icons $owner_guid = $entity->owner_guid; $prefix = "groups/" . $entity->guid; $imagenames = elgg_get_config('icon_sizes'); $img = new ElggFile(); $img->owner_guid = $owner_guid; foreach ($imagenames as $name => $value) { $img->setFilename("{$prefix}{$name}.jpg"); $img->delete(); } // delete original icon $img->setFilename("{$prefix}.jpg"); $img->delete(); // delete group if ($entity->delete()) { system_message(elgg_echo('group:deleted')); } else { register_error(elgg_echo('group:notdeleted')); } } else { register_error(elgg_echo('group:notdeleted')); } $url_name = elgg_get_logged_in_user_entity()->username; forward(elgg_get_site_url() . "groups/member/{$url_name}");
/** * Remove thumbnails - usually in preparation for deletion * * The thumbnails are not actually ElggObjects so we create * temporary objects to delete them. */ protected function removeThumbnails() { $thumbnail = $this->thumbnail; $smallthumb = $this->smallthumb; $largethumb = $this->largethumb; //delete standard thumbnail image if ($thumbnail) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($thumbnail); $delfile->delete(); } //delete small thumbnail image if ($smallthumb) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($smallthumb); $delfile->delete(); } //delete large thumbnail image if ($largethumb) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($largethumb); $delfile->delete(); } }
/** * Helper function to transfer the ownership of a group to a new user * * @param ElggGroup $group the group to transfer * @param ElggUser $new_owner the new owner * * @return boolean */ function group_tools_transfer_group_ownership(ElggGroup $group, ElggUser $new_owner) { $result = false; if (empty($group) || !elgg_instanceof($group, "group") || !$group->canEdit()) { return $result; } if (empty($new_owner) || !elgg_instanceof($new_owner, "user")) { return $result; } $loggedin_user = elgg_get_logged_in_user_entity(); // register plugin hook to make sure transfer can complete elgg_register_plugin_hook_handler("permissions_check", "group", "group_tools_admin_transfer_permissions_hook"); $old_owner = $group->getOwnerEntity(); // transfer ownership $group->owner_guid = $new_owner->getGUID(); $group->container_guid = $new_owner->getGUID(); // make sure user is added to the group $group->join($new_owner); if ($group->save()) { // remove existing group administrator role for new owner remove_entity_relationship($new_owner->getGUID(), "group_admin", $group->getGUID()); // check for group icon if (!empty($group->icontime)) { $prefix = "groups/" . $group->getGUID(); $sizes = array("", "tiny", "small", "medium", "large"); $ofh = new ElggFile(); $ofh->owner_guid = $old_owner->getGUID(); $nfh = new ElggFile(); $nfh->owner_guid = $group->getOwnerGUID(); foreach ($sizes as $size) { // set correct file to handle $ofh->setFilename($prefix . $size . ".jpg"); $nfh->setFilename($prefix . $size . ".jpg"); // open files $ofh->open("read"); $nfh->open("write"); // copy file $nfh->write($ofh->grabFile()); // close file $ofh->close(); $nfh->close(); // cleanup old file $ofh->delete(); } $group->icontime = time(); } // move metadata of the group to the new owner $options = array("guid" => $group->getGUID(), "limit" => false); $metadata = elgg_get_metadata($options); if (!empty($metadata)) { foreach ($metadata as $md) { if ($md->owner_guid == $old_owner->getGUID()) { $md->owner_guid = $new_owner->getGUID(); $md->save(); } } } // notify new owner if ($new_owner->getGUID() != $loggedin_user->getGUID()) { $subject = elgg_echo("group_tools:notify:transfer:subject", array($group->name)); $message = elgg_echo("group_tools:notify:transfer:message", array($new_owner->name, $loggedin_user->name, $group->name, $group->getURL())); notify_user($new_owner->getGUID(), $group->getGUID(), $subject, $message); } $result = true; } // unregister plugin hook to make sure transfer can complete elgg_unregister_plugin_hook_handler("permissions_check", "group", "group_tools_admin_transfer_permissions_hook"); return $result; }
} $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 600, 600, false); if ($thumblarge) { $thumb->setFilename($prefix . "largethumb" . $filestorename); $thumb->open("write"); $thumb->write($thumblarge); $thumb->close(); $file->largethumb = $prefix . "largethumb" . $filestorename; unset($thumblarge); } } elseif ($file->icontime) { // if it is not an image, we do not need thumbnails unset($file->icontime); $thumb = new ElggFile(); $thumb->setFilename($prefix . "thumb" . $filestorename); $thumb->delete(); unset($file->thumbnail); $thumb->setFilename($prefix . "smallthumb" . $filestorename); $thumb->delete(); unset($file->smallthumb); $thumb->setFilename($prefix . "largethumb" . $filestorename); $thumb->delete(); unset($file->largethumb); } } else { // not saving a file but still need to save the entity to push attributes to database $file->save(); } // file saved so clear sticky form elgg_clear_sticky_form('file'); // handle results differently for new files and file updates