~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/If/OP_isempty.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for copyright and license details
 
2
 
 
3
=begin TML
 
4
 
 
5
---+ package Foswiki::If::OP_isempty
 
6
 
 
7
=cut
 
8
 
 
9
package Foswiki::If::OP_isempty;
 
10
use base 'Foswiki::Query::UnaryOP';
 
11
 
 
12
use strict;
 
13
 
 
14
sub new {
 
15
    my $class = shift;
 
16
    return $class->SUPER::new( name => 'isempty', prec => 600 );
 
17
}
 
18
 
 
19
sub evaluate {
 
20
    my $this    = shift;
 
21
    my $node    = shift;
 
22
    my $a       = $node->{params}->[0];
 
23
    my %domain  = @_;
 
24
    my $session = $domain{tom}->session;
 
25
    throw Error::Simple(
 
26
        'No context in which to evaluate "' . $a->stringify() . '"' )
 
27
      unless $session;
 
28
    my $eval = $a->_evaluate(@_);
 
29
    return 1 unless $eval;
 
30
    return 0 if ( $session->{request}->param($eval) );
 
31
    return 0 if ( $session->{prefs}->getPreferencesValue($eval) );
 
32
    return 0 if ( $session->{SESSION_TAGS}{$eval} );
 
33
    return 1;
 
34
}
 
35
 
 
36
1;
 
37
 
 
38
__DATA__
 
39
 
 
40
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
 
41
 
 
42
Copyright (C) 2005-2009 Foswiki Contributors. All Rights Reserved.
 
43
Foswiki Contributors are listed in the AUTHORS file in the root of
 
44
this distribution. NOTE: Please extend that file, not this notice.
 
45
 
 
46
This program is free software; you can redistribute it and/or
 
47
modify it under the terms of the GNU General Public License
 
48
as published by the Free Software Foundation; either version 2
 
49
of the License, or (at your option) any later version. For
 
50
more details read LICENSE in the root of this distribution.
 
51
 
 
52
This program is distributed in the hope that it will be useful,
 
53
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
54
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
55
 
 
56
As per the GPL, removal of this notice is prohibited.
 
57
 
 
58
Author: Rafael Alvarez (http://www.soronthar.com)