source: trunk/ApprovalPlugin/lib/TWiki/Plugins/ApprovalPlugin/Approval.pm @ 1050

Revision 1050, 4.2 KB checked in by OlivierRaginel, 4 years ago (diff)

Item329: Fixed tagline

Line 
1# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
2#
3# Copyright (C) 2008 Andrew Jones, andrewjones86@googlemail.com
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License
7# as published by the Free Software Foundation; either version 2
8# of the License, or (at your option) any later version. For
9# more details read LICENSE in the root of this distribution.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14#
15# For licensing info read LICENSE file in the TWiki root.
16
17package TWiki::Plugins::ApprovalPlugin::Approval;
18
19require TWiki::Plugins::ApprovalPlugin::State;
20require TWiki::Plugins::ApprovalPlugin::Transition;
21
22use strict;
23
24use fields qw(currentWeb currentTopic definitionWeb definitionTopic history state transition preference);
25
26# stores all things about the approval (web, topic, history, etc)
27# also has pointers for state and transition objects
28
29sub new {
30    my ($class, $currentWeb, $currentTopic, $definitionWeb, $definitionTopic, $history, $state, $transition) = @_;
31   
32    my $self = {};
33   
34    # TODO
35    $self->{currentWeb} = $currentWeb;
36    $self->{currentTopic} = $currentTopic;
37    $self->{definitionWeb} = $definitionWeb;
38    $self->{definitionTopic} = $definitionTopic;
39    $self->{history} = $history;
40    $self->{state} = $state; # TWiki::Plugins::ApprovalPlugin::State Object
41    #$self->{transition} = $transition; # TWiki::Plugins::ApprovalPlugin::Transition Object
42   
43    return bless( $self, $class );
44}
45
46# empty constructor
47sub create {
48    my $class = shift;
49   
50    my $self = {};
51   
52    $self->{currentWeb};
53    $self->{currentWeb};
54    $self->{currentTopic};
55    $self->{definitionWeb};
56    $self->{definitionTopic};
57    $self->{history};
58    $self->{state} = TWiki::Plugins::ApprovalPlugin::State->create();
59    $self->{transition} = {};
60    $self->{preference} = {};
61   
62    return bless( $self, $class );
63}
64
65# resets some keys before they are re-written
66sub resetObj {
67    my $self = shift;
68    #$self->{state} = TWiki::Plugins::ApprovalPlugin::State->create();
69    $self->{transition} = {};
70   
71    # Call others
72    $self->{state}->resetObj();
73}
74
75sub currentWeb {
76    my $self = shift;
77    if (@_) { $self->{currentWeb} = shift }
78    return $self->{currentWeb};
79}
80
81sub currentTopic {
82    my $self = shift;
83    if (@_) { $self->{currentTopic} = shift }
84    return $self->{currentTopic};
85}
86
87sub definitionWeb {
88    my $self = shift;
89    if (@_) { $self->{definitionWeb} = shift }
90    return $self->{definitionWeb};
91}
92
93sub definitionTopic {
94    my $self = shift;
95    if (@_) { $self->{definitionTopic} = shift }
96    return $self->{definitionTopic};
97}
98
99sub history {
100    my $self = shift;
101    if (@_) { $self->{history} = shift }
102    return $self->{history};
103}
104
105sub historyConcat {
106    my $self = shift;
107    if (@_) { $self->{history} .= shift }
108}
109
110sub state {
111    my $self = shift;
112    if (@_) { $self->{state} = shift }
113    return $self->{state};
114}
115
116# return the transition objects in a hash by actions
117sub transitions {
118    #my $self = shift;
119    my( $self, $transition ) = @_;
120    if ( $transition ) {
121        $self->{transition} = $transition;
122    }
123    return $self->{transition};
124}
125
126# return the transition object for the action
127sub transitionByAction {
128    #my $self = shift;
129    my( $self, $action, $transition ) = @_;
130    if ( $action && $transition ) {
131        $self->{transition}->{$action} = $transition;
132    }
133    return $self->{transition}->{$action};
134}
135
136# set hash of preferences or return hash
137sub preferences {
138    my( $self, $preferences ) = @_;
139    if ( $preferences ) {
140        $self->{preference} = $preferences;
141    }
142    return $self->{preference};
143}
144
145# get or set preference by key
146sub preferenceByKey {
147    #my $self = shift;
148    my( $self, $key, $preference ) = @_;
149    if ( $key && $preference ) {
150        $self->{preference}->{$key} = $preference;
151    }
152    return $self->{preference}->{$key};
153}
154
1551;
Note: See TracBrowser for help on using the repository browser.