<%doc>
###############################################################################

=head1 NAME

/workflow/manager/media/dhandler - media search result page

=head1 VERSION

$Revision: 1.12 $

=head1 DATE

$Date: 2002/06/26 19:12:50 $

=head1 SYNOPSIS

=head1 DESCRIPTION

=cut

</%doc>

<%args>
</%args>

<%once>
my $object = 'media';
my $plural = get_class_info($object)->get_plural_name;
my $w_id;

my $profile = sub {
    my $o = shift;
    my $u = $o->get_user__id;
    my $id = $o->get_id;
    my $ret;
    if (defined $u && $u == get_user_id && chk_authz($o, EDIT, 1)) {
	$ret = [['Edit', "/workflow/profile/media/$id?checkout=1&return=search", '']];
    } else {
	$ret = [['View', "/workflow/profile/media/$id?return=search", '']];
    }
    push @$ret, [ 'Log', "/workflow/events/media/$id", ''];
    return $ret;
};

my $select = sub {
    my $o = shift;
    my $u = $o->get_user__id;

    if ((not defined $u) && chk_authz($o, EDIT, 1)) {
	if ($o->get_workflow_id) {
	    return ['Checkout', 'media_prof|checkout_cb'];
	} else {
	    return ['Checkout', 'media_prof|recall_cb', $o->get_id.'|'.$w_id];
	}
    }

    return;
};

my $addition = sub {
    if (chk_authz($_[0], CREATE, 1)) {
        return ['Create', "/workflow/profile/media/new/$w_id"];
    }
    return;
};

my $exclude = sub { ! chk_authz($_[0], READ, 1) };
</%once>

<%init>;
# Get the workflow ID.
($w_id) = $r->uri =~ m!/(\d+)/?$!;

# Grab the workflow from the cache.
my $wf = $c->get('__WORKFLOWS__');
for (@$wf) { $wf = "&quot;$_->{name}&quot;" and last if $_->{id} == $w_id }
</%init>
<& '/widgets/wrappers/sharky/header.mc',
   title => "Find $plural",
   context => "Workflow | $wf | Find $plural"
 &>

<& '/widgets/search/search.mc',
   'object' => $object,
   'type'   => 'media',
&>

<form method="post" action="<% $r->uri %>" name="media_manager">

<& '/widgets/listManager/listManager.mc',
  object   => $object,
  title    => '%n Found',
  sortBy   => 'name',
  profile  => $profile,
  fields   => [ qw(id name needs_publish cover_date) ],
  addition => $addition,
  select   => $select,
  exclude  => $exclude,
  behavior => 'expand',
&>
<p></p>
<input type="image" src="/media/images/checkout_red.gif" border=0 name="Checkout" value="Checkout">
</form>
<& /widgets/wrappers/sharky/footer.mc &>



