AxKit-App-TABOO

 view release on metacpan or  search on metacpan

lib/AxKit/App/TABOO/Provider/Article.pm  view on Meta::CPAN

  $self->{metadata} = AxKit::App::TABOO::Data::Article->new();
  $self->{metadata}->load(limit => { filename => $self->{filename},
				     primcat  => $self->{primcat}});
  return $self;
}

sub get_strref {
  my $self = shift;
  unless (defined($self->{metadata})) {
    throw Apache::AxKit::Exception::Retval(
					   return_code => 404,
					   -text => "Article does not exist");
  }
  my $doc = XML::LibXML::Document->new();
  my $rootel = $doc->createElement('taboo');
#  $rootel->setAttribute('type', 'article');
#  $rootel->setAttribute('origin', 'Article');
  $doc->setDocumentElement($rootel);
  $self->{metadata}->write_xml($doc, $rootel);
  return $doc->toString(1);
}

lib/AxKit/App/TABOO/Provider/Classification.pm  view on Meta::CPAN

sub get_fh {
  throw Apache::AxKit::Exception::IO(
	      -text => "No fh for Classification Provider");
}

sub get_dom {
  my $self = shift;
  unless ($self->{dom}) {
    unless ($self->{exists}) {
      throw Apache::AxKit::Exception::Retval(
					     return_code => 404,
					     -text => "Category " . $self->{catnotfound} . " was not found");
    }
#    warn "ANT: " . Dumper($self);
    my $authlevel = AxKit::App::TABOO::authlevel($self->{session});
    if (scalar(@{$self->{cats}}) == 1) {
      my %limit;
      if (! defined($authlevel)
	  || ($authlevel < 4)) {
	$limit{'editorok'} = 1;
      } elsif ($self->{editor}) {

lib/AxKit/App/TABOO/Provider/News.pm  view on Meta::CPAN

  return $self;
}


# sub: process
sub process {
    my $self = shift;
    if($self->{getcomments} && ($self->{commentpath} ne '/') && ($self->{uri} =~ m|/$|)) {
	# URIs should never end with / if they have a bunch of comments
	throw Apache::AxKit::Exception::Retval(
					       return_code => 404,
					       -text => "URIs should not end with /");
    }

    $self->{exists} = 0;
    if ($self->{storytimestamp}) { # This exists iff the story is OK
      $self->{exists} = 1;
    }
    if($self->{getcomments}) {
      $self->{exists} = ($self->{commenttimestamp}) ?1:0;
    }

lib/AxKit/App/TABOO/Provider/News.pm  view on Meta::CPAN

    # creating a tree of replies.  If we run it twice, the tree
    # algorithm will be confused. So, we simply check if we've been
    # run before.
    # This is addressed in AxKit CVS, but is not due to be released any time soon.
    AxKit::Debug(5, "[News] Output allready created in earlier run, reusing");
  } else {
    # This has to go here due to a quirk in AxKit, se bug report in rt.cpan.org
    my $authlevel = AxKit::App::TABOO::authlevel($self->{session});
      unless ($self->{exists}) {
	throw Apache::AxKit::Exception::Retval(
					       return_code => 404,
					       -text => "Not found by News Provider.");
      }
      $self->{editorok} = $self->{story}->editorok();
      # No point in going any further if the user isn't authorized:
      unless ($self->{editorok}) {
	if ($authlevel < 4) {
	  throw Apache::AxKit::Exception::Retval(
						 return_code => 401,
						 -text => "Authentication and higher priviliges required");
	}

lib/AxKit/App/TABOO/Provider/NewsList.pm  view on Meta::CPAN

  AxKit::Debug(9, "[NewsList] Data parsed in init: " . Dumper($self));

  return $self;
}

sub process {
  my $self = shift;
  if ($self->{uri} =~ m|/news/.*/$|) {
    # URIs should never end with / unless it is just /news/
    throw Apache::AxKit::Exception::Retval(
					   return_code => 404,
					   -text => "URIs should not end with /");  
  }
  if ((AxKit::App::TABOO::authlevel($self->{session}) < 4) && ($self->{editor})) {
    throw Apache::AxKit::Exception::Retval(
					   return_code => 401,
					   -text => "You're not allowed to see editor-only stories without being authenticated as one.");
  }
  if (($self->{unpriv}) && ($self->{editor})) {
    throw Apache::AxKit::Exception::Retval(
					   return_code => 404,
					   -text => "Editor and Unpriviliged are mutually exclusive.");
  }
  if ($self->{number} > $self->{maxrecords}) {
    throw Apache::AxKit::Exception::Retval(
					   return_code => 403,
					   -text => "The server limit for number of records is " . $self->{maxrecords});
    }
  
  if ($self->{sectionid}) {
    # Iff a resource doesn't exist, it means that the section doesn't
    # exist, so we just check the list of sections
    $self->{section} = AxKit::App::TABOO::Data::Category->new();  
    unless ($self->{section}->load(what => '*', 
				   limit => {type => 'stsec',
					     catname => $self->{sectionid}})) {
      throw Apache::AxKit::Exception::Retval(
					     return_code => 404,
					     -text => "Not found by NewsList Provider.");
    }
  }
  # No exceptions thrown means that we go ahead here:
  $self->{exists} = 1;
  return 1;
}

sub exists {
  my $self = shift;

lib/AxKit/App/TABOO/XSP/Article.pm  view on Meta::CPAN


=cut


sub get_article : struct attribOrChild(filename,primcat) {
    return << 'EOC'
    AxKit::Debug(8, "We look for article with filename: '" . $attr_filename . "'");
    my $article = AxKit::App::TABOO::Data::Article->new();
    unless ($article->load(limit => { filename => $attr_filename })) {
	throw Apache::AxKit::Exception::Retval(
					       return_code => 404,
					       -text => "Article with identifier $attr_filename not found");
    }	
    unless ($article->editorok && $article->authorok) {
        my $session = AxKit::App::TABOO::session($r);
	my $authlevel = AxKit::App::TABOO::authlevel($session);
	if (!$authlevel) {
	    throw Apache::AxKit::Exception::Retval(
						   return_code => 401,
						   -text => "Not authorised with an authlevel");
	}

lib/AxKit/App/TABOO/XSP/Article.pm  view on Meta::CPAN

	warn $r->document_root . $lookupfile;
	if (-r $r->document_root . $lookupfile) {
	    $lookupurl = 'http://' . $r->get_server_name . ':' . $r->get_server_port . $lookupfile;
	}
	last if $lookupurl;
    }
    AxKit::Debug(8, "Content really at: " . $lookupurl);

    unless ($lookupurl) {
	throw Apache::AxKit::Exception::Retval(
					       return_code => 404,
					       -text => "Content $lookupurl not found");
    }

    my $doc = XML::LibXML::Document->new();
    my $rootel = $doc->createElement('taboo');
    $rootel->setAttribute('contenturl', $lookupurl);
    #  $rootel->setAttribute('type', 'article');
    #  $rootel->setAttribute('origin', 'Article');
    $doc->setDocumentElement($rootel);
    $article->write_xml($doc, $rootel);

lib/AxKit/App/TABOO/XSP/Comment.pm  view on Meta::CPAN

=cut


sub get_comment : struct attribOrChild(storyname,sectionid,commentpath) {
    return << 'EOC'
    my $comment = AxKit::App::TABOO::Data::Comment->new();
    unless ($comment->load(what => '*', limit => {sectionid => $attr_sectionid,
						  storyname=> $attr_storyname,
						  commentpath=> $attr_commentpath})) {
      throw Apache::AxKit::Exception::Retval(
					     return_code => 404,
					     -text => "Requested comment $attr_commentpath not found.");
    }
    $comment->adduserinfo();
    my $doc = XML::LibXML::Document->new();
    my $root = $doc->createElementNS('http://www.kjetil.kjernsmo.net/software/TABOO/NS/Comment/Output', 'comm:comment-loaded');
    $doc->setDocumentElement($root);
    $comment->write_xml($doc, $root); # Return an XML representation
EOC
}

lib/AxKit/App/TABOO/XSP/Story.pm  view on Meta::CPAN

    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");
      }
    }



( run in 1.668 second using v1.01-cache-2.11-cpan-39bf76dae61 )