~ubuntu-branches/ubuntu/oneiric/request-tracker3.8/oneiric-updates

« back to all changes in this revision

Viewing changes to lib/RT/CustomField_Overlay.pm

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves, Dominic Hargreaves, Christian Perrier
  • Date: 2009-06-16 21:46:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616214659-5ji9k1n3qyc2br3n
Tags: 3.8.4-1
[ Dominic Hargreaves ]
* Add missing comma in Depends (fixes FTBFS on etch)
* Update debconf translations: pt.po, ja.po, sv.po, it.po, cs.po, ru.po
  (Closes: #519885, #519922, #520603, #520759, #521199, #521926)
* Document preference for not using SQLite in production
  (Closes: #512750)

[ Christian Perrier ]
* Debconf templates and debian/control reviewed by the debian-l10n-
  english team as part of the Smith review project.
  (Closes: #522367, #520959)
* [Debconf translation updates]
  - Japanese. Closes: #522896
  - German. Closes: #520958
  - Portuguese. Closes: #523481
  - Galician. Closes: #524256
  - Galician. Closes: #524256
  - Spanish. Closes: #524449
  - Italian. Closes: #524715
  - Russian. Closes: #524894
  - Swedish. Closes: #525171
  - French. Closes: #525281

[ Dominic Hargreaves ]
* Don't tell dbconfig to comment out unused variables, since this
  breaks MySQL and Postgres database configuration (Closes: #523090)
* Update Standards-Version (no changes)
* Switch dependency on sysklogd to rsyslog (Closes: #526914)
* New upstream release; includes
  - Minor security fix (Closes: #533069)
  - Add missing Postgres index (Closes: #512653)
* Patch webmux.pl to provide a better error message when the wrong
  major version of RT is in @INC (for example in a mod_perl context).
  (Closes: #518692)
* Add some more example Exim 4 configuration (Closes: #238345)
* Don't apply database ACLs in databases managed by dbconfig-common.
* Remove unused ACL patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
    $RT::ACE::LOWERCASERIGHTNAMES{ lc $right } = $right;
122
122
}
123
123
 
 
124
=head2 AddRights C<RIGHT>, C<DESCRIPTION> [, ...]
 
125
 
 
126
Adds the given rights to the list of possible rights.  This method
 
127
should be called during server startup, not at runtime.
 
128
 
 
129
=cut
 
130
 
 
131
sub AddRights {
 
132
    my $self = shift;
 
133
    my %new = @_;
 
134
    $RIGHTS = { %$RIGHTS, %new };
 
135
    %RT::ACE::LOWERCASERIGHTNAMES = ( %RT::ACE::LOWERCASERIGHTNAMES,
 
136
                                      map { lc($_) => $_ } keys %new);
 
137
}
 
138
 
124
139
sub AvailableRights {
125
140
    my $self = shift;
126
141
    return $RIGHTS;
307
322
    # XXX - really naive implementation.  Slow. - not really. still just one query
308
323
 
309
324
    my $CFs = RT::CustomFields->new( $self->CurrentUser );
310
 
    $CFs->Limit( FIELD => 'Name', VALUE => $args{'Name'}, CASESENSITIVE => 0);
 
325
    $CFs->SetContextObject( $self->ContextObject );
 
326
    my $field = $args{'Name'} =~ /\D/? 'Name' : 'id';
 
327
    $CFs->Limit( FIELD => $field, VALUE => $args{'Name'}, CASESENSITIVE => 0);
311
328
    # Don't limit to queue if queue is 0.  Trying to do so breaks
312
329
    # RT::Group type CFs.
313
330
    if ( defined $args{'Queue'} ) {
314
331
        $CFs->LimitToQueue( $args{'Queue'} );
315
332
    }
316
333
 
317
 
    # When loading by name, it's ok if they're disabled. That's not a big deal.
 
334
    # When loading by name, we _can_ load disabled fields, but prefer
 
335
    # non-disabled fields.
318
336
    $CFs->{'find_disabled_rows'}=1;
 
337
    $CFs->OrderByCols(
 
338
        { FIELD => "Disabled", ORDER => 'ASC' },
 
339
    );
319
340
 
320
341
    # We only want one entry.
321
342
    $CFs->RowsPerPage(1);
332
353
# {{{ Dealing with custom field values 
333
354
 
334
355
 
335
 
=cut
336
 
 
337
356
=head2 Custom field values
338
357
 
339
358
=head3 Values FIELD
653
672
 
654
673
# }}}
655
674
 
656
 
# {{{ sub CurrentUserHasRight
657
 
 
658
675
=head2 CurrentUserHasRight RIGHT
659
676
 
660
677
Helper function to call the custom field's queue's CurrentUserHasRight with the passed in args.
671
688
    );
672
689
}
673
690
 
674
 
# }}}
675
 
 
 
691
=head2 ACLEquivalenceObjects
 
692
 
 
693
Returns list of objects via which users can get rights on this custom field. For custom fields
 
694
these objects can be set using L<ContextObject|/"ContextObject and SetContextObject">.
 
695
 
 
696
=cut
 
697
 
 
698
sub ACLEquivalenceObjects {
 
699
    my $self = shift;
 
700
 
 
701
    my $ctx = $self->ContextObject
 
702
        or return;
 
703
    return ($ctx, $ctx->ACLEquivalenceObjects);
 
704
}
 
705
 
 
706
=head2 ContextObject and SetContextObject
 
707
 
 
708
Set or get a context for this object. It can be ticket, queue or another object
 
709
this CF applies to. Used for ACL control, for example SeeCustomField can be granted on
 
710
queue level to allow people to see all fields applied to the queue.
 
711
 
 
712
=cut
 
713
 
 
714
sub SetContextObject {
 
715
    my $self = shift;
 
716
    return $self->{'context_object'} = shift;
 
717
}
 
718
  
 
719
sub ContextObject {
 
720
    my $self = shift;
 
721
    return $self->{'context_object'};
 
722
}
 
723
  
676
724
# {{{ sub _Set
677
725
 
678
726
sub _Set {