AxKit-App-TABOO
view release on metacpan or search on metacpan
lib/AxKit/App/TABOO/XSP/Story.pm view on Meta::CPAN
=cut
sub this_story : struct {
return << 'EOC'
my %args = map { $_ => $cgi->param($_) } $cgi->param;
$args{'username'} = AxKit::App::TABOO::loggedin(AxKit::App::TABOO::session($r));
unless ($args{'submitterid'}) {
# If the submitterid is not set, we set it to the current username
$args{'submitterid'} = $args{'username'}
}
my $timestamp = localtime;
unless ($args{'timestamp'}) {
$args{'timestamp'} = $timestamp->datetime;
}
unless ($args{'lasttimestamp'}) {
$args{'lasttimestamp'} = $timestamp->datetime;
}
my $story = AxKit::App::TABOO::Data::Story->new();
$story->populate(\%args);
$story->adduserinfo();
$story->addcatinfo();
my $doc = XML::LibXML::Document->new();
my $root = $doc->createElementNS('http://www.kjetil.kjernsmo.net/software/TABOO/NS/Story/Output', 'story:story-submission');
$doc->setDocumentElement($root);
$story->write_xml($doc, $root); # Return an XML representation
EOC
}
=head2 C<E<lt>get-story/E<gt>>
Will return an XML representation of the data for a previously saved
story, enclosed in a C<story-loaded> element. It needs to get the
story identified by C<storyname> and C<sectionid> attributes or child
elements.
=cut
sub get_story : struct attribOrChild(storyname,sectionid) {
return << 'EOC'
my %args;
foreach my $name ($cgi->param) {
$args{$name} = $cgi->param($name);
}
my $session = AxKit::App::TABOO::session($r);
unless ($args{'username'}) {
$args{'username'} = AxKit::App::TABOO::loggedin($session);
}
my $story = AxKit::App::TABOO::Data::Story->new();
unless ($story->load(limit => {sectionid => $attr_sectionid, storyname=> $attr_storyname})) {
throw Apache::AxKit::Exception::Retval(
return_code => 404,
-text => "Requested story $attr_storyname not found.");
}
$story->adduserinfo();
unless ($story->editorok) {
if (AxKit::App::TABOO::authlevel($session) < 4) {
throw Apache::AxKit::Exception::Retval(
return_code => 401,
-text => "Authentication and higher priviliges required to load story");
}
}
my $doc = XML::LibXML::Document->new();
my $root = $doc->createElementNS('http://www.kjetil.kjernsmo.net/software/TABOO/NS/Story/Output', 'story:story-loaded');
$doc->setDocumentElement($root);
$story->write_xml($doc, $root); # Return an XML representation
EOC
}
=head2 C<E<lt>number-of-unapproved sectionid="subqueue"/E<gt>>
Will return the number of articles in a given section that has not
been approved by an editor. Especially useful for giving the editors a
heads-up as to new articles in the submission queue, like in the
example.
=cut
sub number_of_unapproved : expr attribOrChild(sectionid) {
return << 'EOC'
my $stories = AxKit::App::TABOO::Data::Plurals::Stories->new();
$stories->exists(sectionid => $attr_sectionid,
editorok => 0);
EOC
}
1;
=head1 FORMALITIES
See L<AxKit::App::TABOO>.
=cut
( run in 2.494 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )