sub delete {
my ($r) = @_;
- $r->authenticate('require_login' => 1);
+ $r->authenticate('require_login' => 1, 'require_administrator' => 1);
$r->set_title('Delete CommitFest');
my $d;
eval {
sub form {
my ($r) = @_;
- $r->authenticate('require_login' => 1);
+ $r->authenticate('require_login' => 1, 'require_administrator' => 1);
# Decide whether this is a new commitfest or an edit of an existing
# commitfest, and if editing reload data from database.
sub search {
my ($r) = @_;
+ my $aa = $r->authenticate();
$r->set_title('CommitFest Index');
- $r->add_link('/action/commitfest_form', 'New CommitFest');
+ if (defined $aa && $aa->{'is_administrator'}) {
+ $r->add_link('/action/commitfest_form', 'New CommitFest');
+ }
my $list = $r->db->select(<<EOM);
SELECT id, name, commitfest_status FROM commitfest_view ORDER BY name DESC
EOM
sub view {
my ($r) = @_;
+ my $aa = $r->authenticate();
my $id = $r->cgi_id();
my $d = $r->db->select_one(<<EOM, $id) if defined $id;
SELECT id, name, commitfest_status FROM commitfest_view WHERE id = ?
$r->add_link('/action/patch_form?commitfest=' . $id, 'New Patch');
$r->add_link('/action/commitfest_topic_search?id=' . $id,
'CommitFest Topics');
- $r->add_link('/action/commitfest_form?id=' . $id, 'Edit CommitFest');
- $r->add_link('/action/commitfest_delete?id=' . $id, 'Delete CommitFest',
- 'Are you sure you want to delete this CommitFest?');
+ if (defined $aa && $aa->{'is_administrator'}) {
+ $r->add_link('/action/commitfest_form?id=' . $id, 'Edit CommitFest');
+ $r->add_link('/action/commitfest_delete?id=' . $id,
+ 'Delete CommitFest',
+ 'Are you sure you want to delete this CommitFest?');
+ }
$r->render_template('commitfest_view', { 'd' => $d, 'patch_grouping' => [
{
'name' => 'Pending Patches',
if (!defined $self->{'authenticate'} && defined $self->cookie('session')) {
$self->{'authenticate'} =
$self->db->select_one(<<EOM, $self->cookie('session'));
-SELECT s.* FROM session s WHERE s.id = ?
+SELECT s.*, p.is_administrator FROM session s
+ LEFT JOIN user_privilege p ON s.userid = p.userid
+WHERE s.id = ?
EOM
}
if (!defined $self->{'authenticate'} && $option{'require_login'}) {
}
$self->redirect('/action/login');
}
+ if (defined $self->{'authenticate'} && $option{'require_administrator'}
+ && ! $self->{'authenticate'}{'is_administrator'}) {
+ $self->error_exit(<<EOM);
+This function is available only to administators.
+EOM
+ }
return $self->{'authenticate'};
}