For staff: Media items don't show up in user's media list, when parent album is deleted

nocte

Well-known member
Affected version
XFMG 2.2.4
As stated in the title.

In my opinion this is a bug and makes moderation hard sometimes: You will find all deleted media items by a user easily, but once the parent album is deleted, you have to go to the user's album list and go through the (deleted) albums in order to find deleted media items.
 
Here's a possible solution (in a way, that can easily be used for a class extension):

class XFMG\Finder\MediaItem

Find:

PHP:
    public function visibleAlbumsOnly()
    {
        $expression = $this->expression(
            'IF(%s > 0, %s = \'visible\', 1=1)',
            'album_id', 'Album.album_state'
        );
        $this->where($expression);

        return $this;
    }

Replace:

PHP:
    public function visibleAlbumsOnly()
    {
        $visitor = \XF::visitor();

        if ($visitor->hasPermission('xfmg', 'viewDeleted'))
        {
            $expression = $this->expression(
                'IF(%s > 0, %s IN(\'visible\',\'deleted\'), 1=1)',
                'album_id', 'Album.album_state'
            );
            $this->where($expression);

            return $this;
        }

        $expression = $this->expression(
            'IF(%s > 0, %s = \'visible\', 1=1)',
            'album_id', 'Album.album_state'
        );
        $this->where($expression);

        return $this;
    }

Problem: Media items don't show up as "deleted" (but like a "visible" one), if only the parent album is deleted, but not the media item itself. This is stated in the same class in the method includePersonalAlbums():

PHP:
        // never include media in hidden albums here as it will mostly be confusing
        $this->visibleAlbumsOnly();

I'd suggest to show media items in deleted (and maybe moderated) albums as "deleted" (or "moderated"), because just hiding them is confusing as well.
 
Back
Top Bottom