add: Ability to specify which group can use individual admin console items
This commit is contained in:
parent
f6cab15bd0
commit
58ac54b81d
29 changed files with 1227 additions and 488 deletions
|
|
@ -45,19 +45,34 @@ is looked up in the i18n table in the WebGUI namespace.
|
|||
=cut
|
||||
|
||||
sub _submenu {
|
||||
my $session = shift;
|
||||
my $workarea = shift;
|
||||
my $title = shift;
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
$title = $i18n->get($title) if ($title);
|
||||
my $ac = WebGUI::AdminConsole->new($session,"cache");
|
||||
if ($session->setting->get("trackPageStatistics")) {
|
||||
$ac->addSubmenuItem( $session->url->page('op=manageCache'), $i18n->get('manage cache'));
|
||||
}
|
||||
return $ac->render($workarea, $title);
|
||||
my $session = shift;
|
||||
my $workarea = shift;
|
||||
my $title = shift;
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
$title = $i18n->get($title) if ($title);
|
||||
my $ac = WebGUI::AdminConsole->new($session,"cache");
|
||||
if ($session->setting->get("trackPageStatistics")) {
|
||||
$ac->addSubmenuItem( $session->url->page('op=manageCache'), $i18n->get('manage cache'));
|
||||
}
|
||||
return $ac->render($workarea, $title);
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canView ( session [, user] )
|
||||
|
||||
Returns true if the user can use this Operation. user defaults to the current
|
||||
user.
|
||||
|
||||
=cut
|
||||
|
||||
sub canView {
|
||||
my $session = shift;
|
||||
my $user = shift || $session->user;
|
||||
return $user->isInGroup( $session->setting->get("groupIdAdminCache") );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_flushCache ( duration )
|
||||
|
|
@ -74,11 +89,13 @@ Text description of how long the subscription lasts.
|
|||
=cut
|
||||
|
||||
sub www_flushCache {
|
||||
my $session = shift;
|
||||
return $session->privilege->adminOnly() unless ($session->user->isInGroup(3));
|
||||
my $cache = WebGUI::Cache->new($session,);
|
||||
$cache->flush;
|
||||
return www_manageCache($session);
|
||||
my $session = shift;
|
||||
return $session->privilege->adminOnly unless canView($session);
|
||||
|
||||
# Flush the cache
|
||||
WebGUI::Cache->new($session)->flush;
|
||||
|
||||
return www_manageCache($session);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -91,24 +108,25 @@ provides an option to clear the cache.
|
|||
=cut
|
||||
|
||||
sub www_manageCache {
|
||||
my $session = shift;
|
||||
return $session->privilege->adminOnly() unless ($session->user->isInGroup(3));
|
||||
my ($output, $data);
|
||||
my $cache = WebGUI::Cache->new($session);
|
||||
my $flushURL = $session->url->page('op=flushCache');
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.$i18n->get('cache type').':</td><td class="tableData">'.ref($cache).'</td></tr>';
|
||||
$output .= '<tr><td align="right" valign="top" class="tableHeader">'.$i18n->get('cache statistics').':</td><td class="tableData"><pre>'.$cache->stats.'</pre></td></tr>';
|
||||
$output .= '<tr><td align="right" valign="top" class="tableHeader"> </td><td class="tableData">'.
|
||||
WebGUI::Form::button($session,{
|
||||
value=>$i18n->get("clear cache"),
|
||||
extras=>qq{onclick="document.location.href='$flushURL';"},
|
||||
}).
|
||||
'</td></tr>';
|
||||
my $session = shift;
|
||||
return $session->privilege->adminOnly unless canView($session);
|
||||
my $cache = WebGUI::Cache->new($session);
|
||||
my $flushURL = $session->url->page('op=flushCache');
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
my $output
|
||||
= '<table>'
|
||||
. '<tr><td align="right" class="tableHeader">'.$i18n->get('cache type').':</td><td class="tableData">'.ref($cache).'</td></tr>'
|
||||
. '<tr><td align="right" valign="top" class="tableHeader">'.$i18n->get('cache statistics').':</td><td class="tableData"><pre>'.$cache->stats.'</pre></td></tr>'
|
||||
. '<tr><td align="right" valign="top" class="tableHeader"> </td><td class="tableData">'
|
||||
. WebGUI::Form::button($session, {
|
||||
value => $i18n->get("clear cache"),
|
||||
extras => qq{onclick="document.location.href='$flushURL';"},
|
||||
})
|
||||
. '</td></tr>'
|
||||
. '</table>'
|
||||
;
|
||||
|
||||
$output .= "</table>";
|
||||
return _submenu($session,$output);
|
||||
return _submenu($session,$output);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue