From a3c3abffe5a964685d596a82261fde79b416107a Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Thu, 4 Nov 2010 18:00:58 +0100 Subject: Bug 485418: Code and template hooks for userprefs.cgi to be able to add additional tabs r=mkanat a=LpSolit --- extensions/Example/Extension.pm | 20 +++++++++++++++ .../en/default/account/prefs/my_tab.html.tmpl | 30 ++++++++++++++++++++++ .../hook/account/prefs/prefs-tabs.html.tmpl | 23 +++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 extensions/Example/template/en/default/account/prefs/my_tab.html.tmpl create mode 100644 extensions/Example/template/en/default/hook/account/prefs/prefs-tabs.html.tmpl (limited to 'extensions/Example') diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm index 5c6865362..f16ddf725 100644 --- a/extensions/Example/Extension.pm +++ b/extensions/Example/Extension.pm @@ -682,6 +682,26 @@ sub bug_check_can_change_field { } } +sub user_preferences { + my ($self, $args) = @_; + my $tab = $args->{current_tab}; + my $save = $args->{save_changes}; + my $handled = $args->{handled}; + + return unless $tab eq 'my_tab'; + + my $value = Bugzilla->input_params->{'example_pref'}; + if ($save) { + # Validate your data and update the DB accordingly. + $value =~ s/\s+/:/g; + } + $args->{'vars'}->{example_pref} = $value; + + # Set the 'handled' scalar reference to true so that the caller + # knows the panel name is valid and that an extension took care of it. + $$handled = 1; +} + sub webservice { my ($self, $args) = @_; diff --git a/extensions/Example/template/en/default/account/prefs/my_tab.html.tmpl b/extensions/Example/template/en/default/account/prefs/my_tab.html.tmpl new file mode 100644 index 000000000..ca7a3bd13 --- /dev/null +++ b/extensions/Example/template/en/default/account/prefs/my_tab.html.tmpl @@ -0,0 +1,30 @@ +[%# + # The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Example Plugin. + # + # The Initial Developer of the Original Code is Frédéric Buclin. + # Portions created by the Initial Developer are Copyright (C) 2010 + # the Initial Developer. All Rights Reserved. + # + # Contributor(s): Frédéric Buclin + #%] + +

+ Type some short text in the field below. Whitespaces will be replaced + by colons. +

+ +

+ + +

diff --git a/extensions/Example/template/en/default/hook/account/prefs/prefs-tabs.html.tmpl b/extensions/Example/template/en/default/hook/account/prefs/prefs-tabs.html.tmpl new file mode 100644 index 000000000..83801540a --- /dev/null +++ b/extensions/Example/template/en/default/hook/account/prefs/prefs-tabs.html.tmpl @@ -0,0 +1,23 @@ +[%# + # The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Example Plugin. + # + # The Initial Developer of the Original Code is Frédéric Buclin. + # Portions created by the Initial Developer are Copyright (C) 2010 + # the Initial Developer. All Rights Reserved. + # + # Contributor(s): Frédéric Buclin + #%] + +[% tabs = tabs.import([{ name => "my_tab", label => "Example Custom Preferences", + link => "userprefs.cgi?tab=my_tab", saveable => 1 } + ]) %] -- cgit v1.2.3-24-g4f1b