Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
/**
 * Handle an object being deleted
 *
 * @param string     $event Event name
 * @param string     $type  Event type
 * @param ElggObject $file  The object deleted
 * @return void
 */
function file_handle_object_delete($event, $type, ElggObject $file)
{
    if (!$file instanceof ElggFile) {
        return;
    }
    if (!$file->guid) {
        // this is an ElggFile used as temporary API
        return;
    }
    $file->deleteIcon();
}