lib/TWiki/Contrib/MailerContrib/UpData.pm
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
child 1 e2915a7cbdfa
permissions -rw-r--r--
RELEASE 4.2.0 freetown
colas@0
     1
# Module of TWiki Enterprise Collaboration Platform, http://TWiki.org/
colas@0
     2
#
colas@0
     3
# Copyright (C) 2004 Wind River Systems Inc.
colas@0
     4
# Copyright (C) 1999-2006 TWiki Contributors.
colas@0
     5
# All Rights Reserved. TWiki Contributors
colas@0
     6
# are listed in the AUTHORS file in the root of this distribution.
colas@0
     7
# NOTE: Please extend that file, not this notice.
colas@0
     8
#
colas@0
     9
# This program is free software; you can redistribute it and/or
colas@0
    10
# modify it under the terms of the GNU General Public License
colas@0
    11
# as published by the Free Software Foundation; either version 2
colas@0
    12
# of the License, or (at your option) any later version. For
colas@0
    13
# more details read LICENSE in the root of this distribution.
colas@0
    14
#
colas@0
    15
# This program is distributed in the hope that it will be useful,
colas@0
    16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
colas@0
    17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
colas@0
    18
#
colas@0
    19
# As per the GPL, removal of this notice is prohibited.
colas@0
    20
colas@0
    21
use strict;
colas@0
    22
colas@0
    23
=pod
colas@0
    24
colas@0
    25
---+ package TWiki::Contrib::MailerContrib::UpData
colas@0
    26
Object that lazy-scans topics to extract
colas@0
    27
parent relationships.
colas@0
    28
colas@0
    29
=cut
colas@0
    30
colas@0
    31
package TWiki::Contrib::MailerContrib::UpData;
colas@0
    32
colas@0
    33
=pod
colas@0
    34
colas@0
    35
---++ new($web)
colas@0
    36
   * =$web= - Web we are building parent relationships for
colas@0
    37
Constructor for a web; initially empty, will lazy-load as topics
colas@0
    38
are referenced.
colas@0
    39
colas@0
    40
=cut
colas@0
    41
colas@0
    42
sub new {
colas@0
    43
    my ( $class, $session, $web ) = @_;
colas@0
    44
    my $this = bless( {}, $class );
colas@0
    45
    $this->{web} = $web;
colas@0
    46
    $this->{session} = $session;
colas@0
    47
    return $this;
colas@0
    48
}
colas@0
    49
colas@0
    50
=pod
colas@0
    51
colas@0
    52
---++ getParent($topic) -> string
colas@0
    53
Get the name of the parent topic of the given topic
colas@0
    54
colas@0
    55
=cut
colas@0
    56
colas@0
    57
sub getParent {
colas@0
    58
    my ( $this, $topic ) = @_;
colas@0
    59
colas@0
    60
    if ( ! defined( $this->{parent}{$topic} )) {
colas@0
    61
        my( $meta, $text ) =
colas@0
    62
          $this->{session}->{store}->readTopic( undef, $this->{web}, $topic );
colas@0
    63
        my $parent = $meta->get('TOPICPARENT');
colas@0
    64
        $this->{parent}{$topic} = $parent->{name} if $parent;
colas@0
    65
        $this->{parent}{$topic} ||= '';
colas@0
    66
    }
colas@0
    67
colas@0
    68
    return $this->{parent}{$topic};
colas@0
    69
}
colas@0
    70
colas@0
    71
1;