| 1 | # E2::E2Node | ||||||||||||||||||||||||||||||||
| 2 | # Jose M. Weeks <jose@joseweeks.com> | ||||||||||||||||||||||||||||||||
| 3 | # 03 July 2003 | ||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||
| 5 | # See bottom for pod documentation. | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | package E2::E2Node; | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use E2::Node; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use E2::Writeup; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 2 | our @ISA = "E2::Node"; | |||||||||||||||||||||||||||||||
| 18 | 2 | our $VERSION = "0.33"; | |||||||||||||||||||||||||||||||
| 19 | 2 | our $DEBUG; *DEBUG = *E2::Interface::DEBUG; | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | # Prototypes | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | sub new; | ||||||||||||||||||||||||||||||||
| 24 | sub clear; | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | sub has_mine; | ||||||||||||||||||||||||||||||||
| 27 | sub is_locked; | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | sub list_writeups; | ||||||||||||||||||||||||||||||||
| 30 | sub list_softlinks; | ||||||||||||||||||||||||||||||||
| 31 | sub list_firmlinks; | ||||||||||||||||||||||||||||||||
| 32 | sub list_sametitles; | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | sub get_writeup; | ||||||||||||||||||||||||||||||||
| 35 | sub get_writeup_by_author; | ||||||||||||||||||||||||||||||||
| 36 | sub get_my_writeup; | ||||||||||||||||||||||||||||||||
| 37 | sub get_writeup_number; | ||||||||||||||||||||||||||||||||
| 38 | sub get_writeup_count; | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | sub vote; | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | sub add_writeup; | ||||||||||||||||||||||||||||||||
| 43 | sub create; | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | # Private | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | sub type_as_string; | ||||||||||||||||||||||||||||||||
| 48 | sub twig_handlers; | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | # Object Methods | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 53 | 1 | my $arg = shift; | |||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | my $class = ref( $arg ) || $arg; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $arg || $arg
MC/DC0%0/2
ref $arg || $arg
ref $arg
$arg
Truth table33%1/3
A || B
A= ref $argB= $arg
| |||||||||||||||||||||||||||||||||
| 55 | 1 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | # See clear for the other members of $self | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 1 | $self->clear; | |||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 1 | return $self; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 3 | ▶ | sub clear { | ||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 65 | 3 | ▶ | my $self = shift or croak "Usage: clear E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | warn "E2::E2Node::clear\n" if $DEBUG > 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 3 | @{ $self->{writeups} } = (); # Array to hold writeups in currently | |||||||||||||||||||||||||||||||
| 70 | # loaded node. See E2::Writeup. | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 3 | $self->{locked} = undef; # soft locked | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 3 | $self->{next} = 0; # Next writeup to return | |||||||||||||||||||||||||||||||
| 75 | 3 | $self->{mine} = undef; # My writeup in this node. | |||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 3 | @{ $self->{firmlinks} } = (); # List of firmlinks | |||||||||||||||||||||||||||||||
| 78 | 3 | @{ $self->{softlinks} } = (); # List of softlinks | |||||||||||||||||||||||||||||||
| 79 | 3 | @{ $self->{sametitles}} = (); # List of sametitles | |||||||||||||||||||||||||||||||
| 80 | # The preceding three return hashrefs | ||||||||||||||||||||||||||||||||
| 81 | # with the following keys: | ||||||||||||||||||||||||||||||||
| 82 | # o title | ||||||||||||||||||||||||||||||||
| 83 | # o id | ||||||||||||||||||||||||||||||||
| 84 | # sametitles has this as well: | ||||||||||||||||||||||||||||||||
| 85 | # o type | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | # Now clear parent | ||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 3 | return $self->SUPER::clear; | |||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub has_mine { | ||||||||||||||||||||||||||||||
|
Subroutine
has_mine: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $self = shift or croak "Usage: has_mine E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if(!$self->node_id) { return undef; } # No node loaded | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if( defined( $self->{mine} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 98 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub is_locked { | ||||||||||||||||||||||||||||||
|
Subroutine
is_locked: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my $self = shift or croak "Usage: is_locked E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if( !$self->node_id ) { return undef; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if( $self->{locked} ) { return 1; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | 0 | else { return 0; } | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub list_softlinks { | ||||||||||||||||||||||||||||||
|
Subroutine
list_softlinks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $self = shift or croak "Usage: list_softlinks E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return undef if !$self->node_id; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 0 | return @{ $self->{softlinks} }; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub list_firmlinks { | ||||||||||||||||||||||||||||||
|
Subroutine
list_firmlinks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $self = shift or croak "Usage: list_firmlinks E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return undef if !$self->node_id; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 0 | return @{ $self->{firmlinks} }; | |||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | sub list_sametitles { | ||||||||||||||||||||||||||||||
|
Subroutine
list_sametitles: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | my $self = shift or croak "Usage: list_sametitles E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | return undef if !$self->node_id; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 0 | return @{ $self->{sametitles} }; | |||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | sub twig_handlers { | ||||||||||||||||||||||||||||||
|
Subroutine
twig_handlers: called CC=2 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | my $self = shift or croak "Usage: twig_handlers E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | return ( | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | 'node/nodelock' => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 143 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||
| 144 | 0 | $self->{locked} = $b->text; | |||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if( $self->{locked} eq "" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | 0 | $self->{locked} = undef; | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | }, | ||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | 'node/writeup' => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 150 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 0 | my $wu = new E2::Writeup; | |||||||||||||||||||||||||||||||
| 153 | 0 | $wu->clone( $self ); | |||||||||||||||||||||||||||||||
| 154 | 0 | $wu->parse( $b ); | |||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||
| 156 | 0 | my $name = $self->this_username; | |||||||||||||||||||||||||||||||
| 157 | 0 | my $uid = $self->this_user_id; | |||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if( $self->logged_in && | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$self->logged_in and $uid ? $uid == $wu->author_id : lc $name eq lc $wu->author
MC/DC0%0/2
$self->logged_in and $uid ? $uid == $wu->author_id : lc $name eq lc $wu->author
$self->logged_in
$uid ? $uid == $wu->author_id : lc $name eq lc $wu->author
Truth table0%0/3
A and B
A= $self->logged_inB= $uid ? $uid == $wu->author_id : lc $name eq lc $wu->author
| |||||||||||||||||||||||||||||||||
| 160 | ($uid ? $uid == $wu->author_id : | ||||||||||||||||||||||||||||||||
| 161 | lc($name) eq lc($wu->author)) ) { | ||||||||||||||||||||||||||||||||
| 162 | 0 | $self->{mine} = @{ $self->{writeups} }; | |||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | 0 | push @{ $self->{writeups} }, $wu; | |||||||||||||||||||||||||||||||
| 166 | }, | ||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | 'node/softlinks/e2link' => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 168 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||
| 169 | 0 | push @{ $self->{softlinks} }, { | |||||||||||||||||||||||||||||||
| 170 | title => $b->text, | ||||||||||||||||||||||||||||||||
| 171 | id => $b->{att}->{node_id} | ||||||||||||||||||||||||||||||||
| 172 | 0 | }; | |||||||||||||||||||||||||||||||
| 173 | }, | ||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | 'node/firmlinks/e2link' => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 175 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||
| 176 | 0 | push @{ $self->{firmlinks} }, { | |||||||||||||||||||||||||||||||
| 177 | title => $b->text, | ||||||||||||||||||||||||||||||||
| 178 | id => $b->{att}->{node_id} | ||||||||||||||||||||||||||||||||
| 179 | 0 | }; | |||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | 'node/sametitles/nodesuggest' => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 182 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||
| 183 | 0 | my $c = $b->first_child( 'e2link' ); | |||||||||||||||||||||||||||||||
| 184 | 0 | push @{ $self->{sametitles} }, { | |||||||||||||||||||||||||||||||
| 185 | title => $c->text, | ||||||||||||||||||||||||||||||||
| 186 | type => $b->{att}->{type}, | ||||||||||||||||||||||||||||||||
| 187 | id => $c->{att}->{node_id} | ||||||||||||||||||||||||||||||||
| 188 | 0 | }; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | 1 | ); | |||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | sub type_as_string { | ||||||||||||||||||||||||||||||
|
Subroutine
type_as_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 194 | 1 | return 'e2node'; | |||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub list_writeups { | ||||||||||||||||||||||||||||||
|
Subroutine
list_writeups: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | my $self = shift or croak "Usage: list_writeups E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return undef if !$self->exists; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 201 | 0 | return @{ $self->{writeups} }; | |||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub get_writeup { | ||||||||||||||||||||||||||||||
|
Subroutine
get_writeup: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my $self = shift or croak "Usage: get_writeup E2E2NODE [ , NUM ]"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 0 | my $num = shift; | |||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if( $num ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 209 | 0 | $self->{next} = $num; | |||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||
| 212 | 0 | return $self->{writeups}[ $self->{next}++ ]; | |||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub get_writeup_by_author { | ||||||||||||||||||||||||||||||
|
Subroutine
get_writeup_by_author: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | my $self = shift | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 217 | or croak "Usage: get_writeup_by_author E2E2NODE, AUTHOR"; | ||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $author = shift | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | or croak "Usage: get_writeup_by_author E2E2NODE, AUTHOR"; | ||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if( !$self->node_id ) { return undef; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | for( my $i = 0; $i < @{ $self->{writeups} }; $i++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if( lc($author) eq | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 225 | lc($self->{writeups}[$i]->author) ) { | ||||||||||||||||||||||||||||||||
| 226 | 0 | return $self->{writeups}[$i]; | |||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||
| 230 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub get_my_writeup { | ||||||||||||||||||||||||||||||
|
Subroutine
get_my_writeup: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | my $self = shift or croak "Usage: get_my_writeup E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 0 | my $i = $self->{mine}; | |||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if( ! defined $i ) { return undef; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||
| 239 | 0 | return $self->{writeups}[$i]; | |||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub get_writeup_number { | ||||||||||||||||||||||||||||||
|
Subroutine
get_writeup_number: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my $self = shift or croak "Usage: get_writeup_number E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if( !$self->node_id ) { return undef; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 246 | 0 | return $self->{next}; | |||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub get_writeup_count { | ||||||||||||||||||||||||||||||
|
Subroutine
get_writeup_count: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $self = shift or croak "Usage: get_writeup_count E2E2NODE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if( !$self->node_id ) { return undef; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||
| 254 | 0 | return $$self->{writeups}; | |||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub create { | ||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $self = shift or croak "Usage: create E2E2NODE, TITLE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my $title = shift or croak "Usage: create E2E2NODE, TITLE"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | warn "E2::E2Node::create\n" if $DEBUG > 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | # Make sure we have username & user_id | ||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if( !$self->logged_in ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | warn "Unable to create node: not logged in" if $DEBUG; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 267 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||
| 270 | return $self->thread_then( | ||||||||||||||||||||||||||||||||
| 271 | [ | ||||||||||||||||||||||||||||||||
| 272 | \&E2::Interface::process_request, | ||||||||||||||||||||||||||||||||
| 273 | $self, | ||||||||||||||||||||||||||||||||
| 274 | node => $title, | ||||||||||||||||||||||||||||||||
| 275 | op => "new", | ||||||||||||||||||||||||||||||||
| 276 | type => "e2node", | ||||||||||||||||||||||||||||||||
| 277 | displaytype => "xmltrue", | ||||||||||||||||||||||||||||||||
| 278 | e2node_createdby_user => $self->{user_id} | ||||||||||||||||||||||||||||||||
| 279 | ], | ||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | 0 | my $r = shift; | |||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if( !$r =~ /<author .*?user_id="(.*?)"/s ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 284 | 0 | croak "Invalid document"; | |||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | 0 | $self->load_from_xml( $r ); | |||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||
| 289 | 0 | return $self->exists; | |||||||||||||||||||||||||||||||
| 290 | 0 | }); | |||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||
| 293 | # FIXME: Allow multiple votes/replies/etc. in one request. | ||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | sub vote { | ||||||||||||||||||||||||||||||
|
Subroutine
vote: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my $self = shift or croak "Usage: vote E2E2NODE, NODE_ID => VOTE [ , NODE_ID2 = VOTE2 [ , ... ] ]"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | my %list = @_ or croak "Usage: vote E2E2NODE, NODE_ID => VOTE [ , NODE_ID2 = VOTE2 [ , ... ] ]"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | warn "E2::E2Node::vote\n" if $DEBUG > 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if( !$self->logged_in ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | warn "Unable to vote: not logged in" if $DEBUG; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 303 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||
| 306 | my %params = ( node_id => $self->{node_id}, | ||||||||||||||||||||||||||||||||
| 307 | 0 | op => "vote", | |||||||||||||||||||||||||||||||
| 308 | displaytype => "xmltrue"); | ||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||
| 310 | 0 | foreach( keys %list ) { | |||||||||||||||||||||||||||||||
| 311 | 0 | my $v = $list{$_}; | |||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if( $v != 1 && $v != -1 ) { next; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v != 1 and $v != -1
MC/DC0%0/2
$v != 1 and $v != -1
$v != 1
$v != -1
Truth table0%0/3
A and B
A= $v != 1B= $v != -1
| |||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 0 | $params{ "vote__$_" } = $v; | |||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | return $self->thread_then( | ||||||||||||||||||||||||||||||||
| 319 | [ | ||||||||||||||||||||||||||||||||
| 320 | \&E2::Interface::process_request, | ||||||||||||||||||||||||||||||||
| 321 | $self, | ||||||||||||||||||||||||||||||||
| 322 | %params | ||||||||||||||||||||||||||||||||
| 323 | ], | ||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 325 | 0 | my $r = shift; | |||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if( !($r =~ /<node /s ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 328 | 0 | croak 'Invalid document'; | |||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||
| 331 | 0 | return $self->load_from_xml( $r ); | |||||||||||||||||||||||||||||||
| 332 | 0 | }); | |||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub add_writeup { | ||||||||||||||||||||||||||||||
|
Subroutine
add_writeup: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | my $self = shift | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 337 | or croak "Usage: add_writeup E2E2NODE, TEXT, TYPE [ , NODISPLAY ]"; | ||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my $text = shift | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 339 | or croak "Usage: add_writeup E2E2NODE, TEXT, TYPE [ , NODISPLAY ]"; | ||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | my $type = shift | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 341 | or croak "Usage: add_writeup E2E2NODE, TEXT, TYPE [ , NODISPLAY ]"; | ||||||||||||||||||||||||||||||||
| 342 | 0 | my $nodisplay = shift; | |||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | warn "E2::E2Node::add_writeup\n" if $DEBUG > 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if( !$self->logged_in ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | warn "Unable to add writeup: not logged in" if $DEBUG; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 348 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||
| 351 | return $self->thread_then( | ||||||||||||||||||||||||||||||||
| 352 | [ | ||||||||||||||||||||||||||||||||
| 353 | \&E2::Interface::process_request, | ||||||||||||||||||||||||||||||||
| 354 | $self, | ||||||||||||||||||||||||||||||||
| 355 | node => "new writeup", | ||||||||||||||||||||||||||||||||
| 356 | op => "new", | ||||||||||||||||||||||||||||||||
| 357 | type => "writeup", | ||||||||||||||||||||||||||||||||
| 358 | node => $self->{node_id}, # Why two "node" params? | ||||||||||||||||||||||||||||||||
| 359 | writeup_notnew => $nodisplay, # dunno.... | ||||||||||||||||||||||||||||||||
| 360 | writeup_doctext => $text, | ||||||||||||||||||||||||||||||||
| 361 | writeup_parent_e2node => $self->{node_id}, | ||||||||||||||||||||||||||||||||
| 362 | writeuptype => $type | ||||||||||||||||||||||||||||||||
| 363 | ], | ||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||
| 366 | # FIXME - Add code to test for success. | ||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||
| 368 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 369 | 0 | }); | |||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | 2 | 1; | |||||||||||||||||||||||||||||||
| 373 | __END__ | ||||||||||||||||||||||||||||||||