Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
36b5893b
Commit
36b5893b
authored
Feb 07, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 496488: Hooks for creating, updating, and deleting groups
r=mkanat, a=mkanat (module owner)
parent
fcf51896
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
Group.pm
Bugzilla/Group.pm
+14
-0
Hook.pm
Bugzilla/Hook.pm
+46
-0
Extension.pm
extensions/Example/Extension.pm
+45
-0
No files found.
Bugzilla/Group.pm
View file @
36b5893b
...
...
@@ -195,6 +195,8 @@ sub set_icon_url { $_[0]->set('icon_url', $_[1]); }
sub
update
{
my
$self
=
shift
;
my
$dbh
=
Bugzilla
->
dbh
;
$dbh
->
bz_start_transaction
();
my
$changes
=
$self
->
SUPER::
update
(
@_
);
if
(
exists
$changes
->
{
name
})
{
...
...
@@ -214,6 +216,10 @@ sub update {
&&
$changes
->
{
isactive
}
->
[
1
]);
$self
->
_rederive_regexp
()
if
exists
$changes
->
{
userregexp
};
Bugzilla::Hook::
process
(
'group_end_of_update'
,
{
group
=>
$self
,
changes
=>
$changes
});
$dbh
->
bz_commit_transaction
();
return
$changes
;
}
...
...
@@ -269,12 +275,15 @@ sub remove_from_db {
my
$self
=
shift
;
my
$dbh
=
Bugzilla
->
dbh
;
$self
->
check_remove
(
@_
);
$dbh
->
bz_start_transaction
();
Bugzilla::Hook::
process
(
'group_before_delete'
,
{
group
=>
$self
});
$dbh
->
do
(
'DELETE FROM whine_schedules
WHERE mailto_type = ? AND mailto = ?'
,
undef
,
MAILTO_GROUP
,
$self
->
id
);
# All the other tables will be handled by foreign keys when we
# drop the main "groups" row.
$self
->
SUPER::
remove_from_db
(
@_
);
$dbh
->
bz_commit_transaction
();
}
# Add missing entries in bug_group_map for bugs created while
...
...
@@ -375,6 +384,8 @@ sub create {
print
get_text
(
'install_group_create'
,
{
name
=>
$params
->
{
name
}
})
.
"\n"
if
Bugzilla
->
usage_mode
==
USAGE_MODE_CMDLINE
;
$dbh
->
bz_start_transaction
();
my
$group
=
$class
->
SUPER::
create
(
@_
);
# Since we created a new group, give the "admin" group all privileges
...
...
@@ -392,6 +403,9 @@ sub create {
}
$group
->
_rederive_regexp
()
if
$group
->
user_regexp
;
Bugzilla::Hook::
process
(
'group_end_of_create'
,
{
group
=>
$group
});
$dbh
->
bz_commit_transaction
();
return
$group
;
}
...
...
Bugzilla/Hook.pm
View file @
36b5893b
...
...
@@ -454,6 +454,52 @@ changed flags, and search for a specific condition like C<added eq 'review-'>.
=back
=head2 group_before_delete
This happens in L<Bugzilla::Group/remove_from_db>, after we've confirmed
that the group can be deleted, but before any rows have actually
been removed from the database. This occurs inside a database
transaction.
Params:
=over
=item C<group> - The L<Bugzilla::Group> being deleted.
=back
=head2 group_end_of_create
This happens at the end of L<Bugzilla::Group/create>, after all other
changes are made to the database. This occurs inside a database transaction.
Params:
=over
=item C<group> - The changed L<Bugzilla::Group> object, with all fields set
to their updated values.
=back
=head2 group_end_of_update
This happens at the end of L<Bugzilla::Group/update>, after all other
changes are made to the database. This occurs inside a database transaction.
Params:
=over
=item C<group> - The changed L<Bugzilla::Group> object, with all fields set
to their updated values.
=item C<changes> - The hash of changed fields.
C<< $changes->{$field} = [$old, $new] >>
=back
=head2 install_before_final_checks
Allows execution of custom code before the final checks are done in
...
...
extensions/Example/Extension.pm
View file @
36b5893b
...
...
@@ -246,6 +246,51 @@ sub flag_end_of_update {
# warn $result;
}
sub
group_before_delete
{
my
(
$self
,
$args
)
=
@_
;
# This code doesn't actually *do* anything, it's just here to show you
# how to use this hook.
my
$group
=
$args
->
{
'group'
};
my
$group_id
=
$group
->
id
;
# Uncomment this line to see a line in your webserver's error log whenever
# you file a bug.
# warn "Group $group_id is about to be deleted!";
}
sub
group_end_of_create
{
my
(
$self
,
$args
)
=
@_
;
# This code doesn't actually *do* anything, it's just here to show you
# how to use this hook.
my
$group
=
$args
->
{
'group'
};
my
$group_id
=
$group
->
id
;
# Uncomment this line to see a line in your webserver's error log whenever
# you create a new group.
#warn "Group $group_id has been created!";
}
sub
group_end_of_update
{
my
(
$self
,
$args
)
=
@_
;
# This code doesn't actually *do* anything, it's just here to show you
# how to use this hook.
my
(
$group
,
$changes
)
=
@$args
{
qw(group changes)
};
foreach
my
$field
(
keys
%
$changes
)
{
my
$used_to_be
=
$changes
->
{
$field
}
->
[
0
];
my
$now_it_is
=
$changes
->
{
$field
}
->
[
1
];
}
my
$group_id
=
$group
->
id
;
my
$num_changes
=
scalar
keys
%
$changes
;
my
$result
=
"There were $num_changes changes to fields on group $group_id."
;
# Uncomment this line to see $result in your webserver's error log whenever
# you update a group.
#warn $result;
}
sub
install_before_final_checks
{
my
(
$self
,
$args
)
=
@_
;
print
"Install-before_final_checks hook\n"
unless
$args
->
{
silent
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment