NAME

Krang::Trash - data broker for TrashBin CGI


SYNOPSIS

  use Krang::ClassLoader 'Trash';
  # get a list of objects on the current user's workspace
  @objects = pkg('Trash')->find();
  # get just the first 10, sorting by url:
  @objects = pkg('Trash')->find(limit    => 10,
                                offset   => 0,
                                order_by => 'url');


DESCRIPTION

This module provides a find() method which returns all objects living in the trashbin. These are not full-fledged Story/Media/Template objects, just hashes containing what we need to fill the trashbin's pager view.


INTERFACE

ARGUMENTS

Example: A custom object class named ``Krang::Mailing''

The SQL select command forms a fassade, mapping asset fields to trash object fields. Order matters! All fields must be present, though they might contain the empty string (as the 'class' field in the example below.

Also assumed in the custom objects' database table is the presence of a boolean column named 'trashed', which is supposed to be set to true if the object currently lives in the trashbin.

 Class:   Krang::Mailing
 Table:   mailing
 BEGIN {
     pkg('Trash')->register_find_sql(object => 'mailing', user_sensitive => 0, sql => <<SQL);
 SELECT mailing_id   AS id,
        'mailing'    AS type,
        subject      AS title,
        ''           AS class,
        url          AS url,
        mailing_date AS date,
        ''           AS version,
        someperm     AS may_see,
        otherperm    AS may_edit,
        1            AS linkto      # format the URL as a link
 FROM mailing
 WHERE trashed = 1
 SQL
 }