%doc> ############################################################################### =head1 NAME /workflow/active/dhandler - Show active assets. =head1 VERSION $LastChangedRevision$ =head1 DATE $LastChangedDate$ =head1 SYNOPSIS =head1 DESCRIPTION =cut %doc> <%init>; my ($type, $work_id) = split('/', $m->dhandler_arg); my ($fields, $obj_type, $previewer); if ($type eq 'template') { $fields = [qw(file_name version priority desk)]; $obj_type = 'template'; } else { if (USE_THUMBNAILS && $type eq 'media') { $fields = [qw(thumb title version priority desk)]; } else { $fields = [qw(title version priority desk)]; } $obj_type = $type; $previewer = sub { my ($title, $media) = @_; $m->comp('/widgets/profile/preview_link.mc', type => $type, value => qq{$title}, doc => $media) }; } # Grab the workflow and start desk permissions. my $wf = Bric::Biz::Workflow->lookup({ id => $work_id }); my $desk_chk = { map { $_->[0] => [chk_authz(0, READ, 1, @{$_->[1]}), chk_authz(0, EDIT, 1, @{$_->[1]}) ] } map { [$_->get_id => [$_->get_asset_grp, $_->get_grp_ids ]] } $wf->allowed_desks }; $wf = $wf->get_name; %init> <& '/widgets/wrappers/sharky/header.mc', title => "Active $pl_name->{$obj_type}", no_hist => 1, context => "Workflow | "$wf" | Active $pl_name->{$obj_type}" &>
<& /widgets/wrappers/sharky/footer.mc &> <%cleanup>; # Clear out the cache of user names. %users = (); %cleanup> <%once> my $pl_name = { map { $_ => get_class_info($_)->get_plural_name } qw(story media template) }; my @pri = ('High', 'Medium High', 'Normal', 'Medium Low', 'Low'); my %users; my $profile = sub { my ($type) = @_; # Return an anonymous sub with closure on $type return sub { my $o = shift; my $u = $o->get_user__id; my $id = $o->get_id; if (defined $u && $u == get_user_id && chk_authz($o, EDIT, 1)) { return ['Edit', "/workflow/profile/$type/$id?checkout=1&return=active", '']; } else { return ['View', "/workflow/profile/$type/$id?return=active", '']; } } }; my $select = sub { my ($type, $work_id, $desk_chk) = @_; my $widget = $type eq 'template' ? 'tmpl_prof' : $type.'_prof'; # Return an anonymous sub with closure on $type return sub { my $o = shift; my $u = $o->get_user__id; if (defined $u) { # Show the name of the person who has the asset checked out. return $users{$u} ||= Bric::Biz::Person::User->lookup({ id => $u })->format_name; } elsif ($desk_chk->{$o->get_desk_id}[0] && chk_authz($o, EDIT, 1)) { # Allow access if they have permission and have READ access to the # desk the asset is on. return ['Checkout', $widget.'|checkout_cb']; } return; } }; my $exclude = sub { my $desk_chk = shift; return sub { my $o = shift; return 1 unless $desk_chk->{$o->get_desk_id}[0]; return ! chk_authz($o, READ, 1); }; }; my $values = sub { my ($o, $f) = @_; if ($f eq 'desk') { my $d = $o->get_current_desk; my $w_id = $o->get_workflow_id; my $d_id = $d->get_id; my $name = $d->get_name; return qq{$name}; } elsif ($f eq 'thumb') { # If we get a thumbnail URI, we have an image. Otherwise, simply # return a space to fill the column properly because we aren't an # image object but USE_THUMBNAILS is on. my $thumb_uri = $o->thumbnail_uri or return ' '; return qq{