[Bio] / WebApplication / WebMenu.pm Repository:
ViewVC logotype

Diff of /WebApplication/WebMenu.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9, Wed Jan 16 22:17:51 2008 UTC revision 1.10, Fri Jan 25 20:34:42 2008 UTC
# Line 206  Line 206 
206    
207  =pod  =pod
208    
209  =item * B<add_entry> (I<category>, I<entry>, I<url>)  =item * B<add_entry> (I<category>, I<entry>, I<url>, I<right>)
210    
211  Adds an entry and link to a existing category of the menu. I<category>, I<entry>  Adds an entry and link to a existing category of the menu. I<category>, I<entry>
212  and I<url> are mandatory. I<category> expects the name of the menu category.  and I<url> are mandatory. I<category> expects the name of the menu category.
213  I<entry> can be any string, I<url> expects a url. I<target> is optional and  I<entry> can be any string, I<url> expects a url. I<target> is optional and
214  defines a href target for that link.  defines a href target for that link.
215    The optional I<right> parameter specifies the right a user must have to
216    be able to see this category.
217    
218  =cut  =cut
219    
220  sub add_entry {  sub add_entry {
221      my ($self, $category, $entry, $url, $target) = @_;      my ($self, $category, $entry, $url, $target, $right) = @_;
222    
223      unless ($category and $entry){# and $url) {      unless ($category and $entry){# and $url) {
224          die "Missing parameter ('$category', '$entry', '$url').";          die "Missing parameter ('$category', '$entry', '$url').";
# Line 228  Line 230 
230    
231      $target = '' unless ($target);      $target = '' unless ($target);
232    
233      push @{$self->{entries}->{$category}}, [ $entry, $url, $target ];      push @{$self->{entries}->{$category}}, [ $entry, $url, $target, $right ];
234    
235      return $self;      return $self;
236  }  }
# Line 276  Line 278 
278    
279        foreach (@{$self->{entries}->{$cat}}) {        foreach (@{$self->{entries}->{$cat}}) {
280    
281          my ($entry, $e_url, $e_target) = @$_;          my ($entry, $e_url, $e_target, $e_right) = @$_;
282    
283            # check if a right is required to see this category
284            if (defined($e_right)) {
285              unless (defined($application) && ref($application) eq 'WebApplication') {
286                die "When using rights for a menu category, an application reference must be passed.";
287              }
288              next unless ($application->session->user &&
289                           $application->session->user->has_right($application, @$e_right));
290            }
291    
292          if ($e_url) {          if ($e_url) {
293            my $target = ($e_target) ? qq~target="$e_target"~ : '';            my $target = ($e_target) ? qq~target="$e_target"~ : '';
294            $html .= qq~\t\t\t<li><a href="$e_url" $target>$entry</a></li>\n~;            $html .= qq~\t\t\t<li><a href="$e_url" $target>$entry</a></li>\n~;

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3