1package Netdot::Model::AccessRight; 2 3use base 'Netdot::Model'; 4use warnings; 5use strict; 6 7my $logger = Netdot->log->get_logger('Netdot::Model'); 8 9# Classes used for access rights 10my %CLASSES = ( 11 Device => 1, 12 Ipblock => 1, 13 ContactList => 1, 14 Zone => 1, 15 ); 16 17# Make sure to return 1 181; 19 20=head1 NAME 21 22Netdot::Model::AccessRight 23 24=head1 SYNOPSIS 25 26=head1 CLASS METHODS 27=cut 28 29######################################################################## 30 31=head2 get_classes - Get a list of classes with access rights 32 33 This is useful in places like Model::delete() where we can avoid 34 searching for access rights if we know that the object being 35 deleted does not deal with rights 36 37 Arguments: 38 None 39 Returns: 40 Hash with key = class name 41 Examples: 42 my %aclasses = AccessRight->get_classes(); 43 44=cut 45 46sub get_classes{ 47 my ($self) = @_; 48 return %CLASSES; 49} 50 51 52=head1 INSTANCE METHODS 53=cut 54 55######################################################################## 56 57=head2 get_label - Get object label 58 59 Arguments: 60 None 61 Returns: 62 String 63 Examples: 64 print $accessright->get_label(); 65 66=cut 67 68sub get_label{ 69 my ($self) = @_; 70 $self->isa_object_method('get_label'); 71 if ( $self->access ){ 72 if ( $self->object_class && $self->object_id ){ 73 my $oclass = $self->object_class; 74 my $oid = $self->object_id; 75 my $obj_lbl = $oclass->retrieve($oid)->get_label; 76 return $self->object_class." ".$obj_lbl." - ".$self->access; 77 }elsif ( $self->object_class ){ 78 return $self->object_class." - ".$self->access; 79 } 80 }else{ 81 return "?"; 82 } 83} 84 85 86=head1 AUTHOR 87 88Carlos Vicente, C<< <cvicente at ns.uoregon.edu> >> 89 90=head1 COPYRIGHT & LICENSE 91 92Copyright 2012 University of Oregon, all rights reserved. 93 94This program is free software; you can redistribute it and/or modify 95it under the terms of the GNU General Public License as published by 96the Free Software Foundation; either version 2 of the License, or 97(at your option) any later version. 98 99This program is distributed in the hope that it will be useful, but 100WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY 101or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 102License for more details. 103 104You should have received a copy of the GNU General Public License 105along with this program; if not, write to the Free Software Foundation, 106Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 107 108=cut 109 110