From 2b5efb7fee5e0702d461ec5761abb5a4e2a856a9 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Fri, 4 Nov 2011 00:46:33 +0100 Subject: [PATCH] Allow the fine-grained configuration of notification settings for each section and reword the help texts quite a bit. This will later be used to collect the correct set of email addresses to notify a particular audience about changes in a particular section. Notice that a project admin will have to explicitely opt-in for "Others" notifications, i.e. unless the checkbox is checked, existing email addresses won't be notified anymore. This is surely debatable for existing setups, but makes much more sense for new setups. Eventually we'll write a small migration script to add the specific enabled setting for those (existing) projects that have a non-empty mail list configured. This commit has been sponsored by SciLab. --- NEWS.mdtext | 2 + src/IDF/Form/TabsConf.php | 50 ++++++++++---- src/IDF/Views/Project.php | 21 +++--- src/IDF/templates/idf/admin/tabs.html | 97 +++++++++++++++++++-------- www/media/idf/css/style.css | 22 +++++- 5 files changed, 141 insertions(+), 51 deletions(-) diff --git a/NEWS.mdtext b/NEWS.mdtext index fb43272..a558b7a 100644 --- a/NEWS.mdtext +++ b/NEWS.mdtext @@ -12,6 +12,8 @@ by the friendly folks from Scilab ! implementations of this web hook as this setting is likely to be removed in future versions of Indefero. - Indefero now needs PHP's zip module which is not enabled by default. +- Existing email notifications now have to be explicitely activated in the + project's administrative area. ## New Features diff --git a/src/IDF/Form/TabsConf.php b/src/IDF/Form/TabsConf.php index 8ba3c2a..d41863b 100644 --- a/src/IDF/Form/TabsConf.php +++ b/src/IDF/Form/TabsConf.php @@ -57,20 +57,44 @@ class IDF_Form_TabsConf extends Pluf_Form 'widget' => 'Pluf_Form_Widget_SelectInput', )); } - $ak = array('downloads_notification_email', - 'review_notification_email', - 'wiki_notification_email', - 'source_notification_email', - 'issues_notification_email',); - foreach ($ak as $key) { - $this->fields[$key] = new IDF_Form_Field_EmailList( - array('required' => false, - 'label' => $key, - 'initial' => $this->conf->getVal($key, ''), - 'widget_attrs' => array('size' => 40), - )); - } + $sections = array( + 'downloads_notification', + 'review_notification', + 'wiki_notification', + 'source_notification', + 'issues_notification', + ); + + foreach ($sections as $section) { + $this->fields[$section.'_owners_enabled'] = new Pluf_Form_Field_Boolean( + array('required' => false, + 'label' => __('Project owners'), + 'initial' => $this->conf->getVal($section.'_owners_enabled', false), + 'widget' => 'Pluf_Form_Widget_CheckboxInput', + )); + $this->fields[$section.'_members_enabled'] = new Pluf_Form_Field_Boolean( + array('required' => false, + 'label' => __('Project members'), + 'initial' => $this->conf->getVal($section.'_members_enabled', false), + 'widget' => 'Pluf_Form_Widget_CheckboxInput', + )); + $this->fields[$section.'_email_enabled'] = new Pluf_Form_Field_Boolean( + array('required' => false, + 'label' => __('Others'), + 'initial' => $this->conf->getVal($section.'_email_enabled', false), + 'widget' => 'Pluf_Form_Widget_CheckboxInput', + )); + if ($this->conf->getVal($section.'_email_enabled', false)) { + $attrs['readonly'] = 'readonly'; + } + $this->fields[$section.'_email'] = new IDF_Form_Field_EmailList( + array('required' => false, + 'label' => null, + 'initial' => $this->conf->getVal($section.'_email', ''), + 'widget_attrs' => array('size' => 20), + )); + } $this->fields['private_project'] = new Pluf_Form_Field_Boolean( array('required' => false, diff --git a/src/IDF/Views/Project.php b/src/IDF/Views/Project.php index 5ed03e2..1ea7718 100644 --- a/src/IDF/Views/Project.php +++ b/src/IDF/Views/Project.php @@ -508,21 +508,24 @@ class IDF_Views_Project } } $form->save(); // Save the authorized users. - $request->user->setMessage(__('The project tabs access rights have been saved.')); + $request->user->setMessage(__('The project tabs access rights and notification settings have been saved.')); $url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminTabs', array($prj->shortname)); return new Pluf_HTTP_Response_Redirect($url); } } else { $params = array(); - $keys = array('downloads_access_rights', 'source_access_rights', - 'issues_access_rights', 'review_access_rights', - 'wiki_access_rights', - 'downloads_notification_email', - 'review_notification_email', - 'wiki_notification_email', - 'source_notification_email', - 'issues_notification_email'); + $sections = array('downloads', 'wiki', 'source', 'issues', 'review'); + $keys = array(); + + foreach ($sections as $section) { + $keys[] = $section.'_access_rights'; + $keys[] = $section.'_notification_owners_enabled'; + $keys[] = $section.'_notification_members_enabled'; + $keys[] = $section.'_notification_email_enabled'; + $keys[] = $section.'_notification_email'; + } + foreach ($keys as $key) { $_val = $request->conf->getVal($key, false); if ($_val !== false) { diff --git a/src/IDF/templates/idf/admin/tabs.html b/src/IDF/templates/idf/admin/tabs.html index f221d61..10ae8dc 100644 --- a/src/IDF/templates/idf/admin/tabs.html +++ b/src/IDF/templates/idf/admin/tabs.html @@ -10,11 +10,11 @@ {/if}
- +
- - + + @@ -22,6 +22,12 @@ {$form.f.downloads_access_rights|unsafe} @@ -31,6 +37,12 @@ {$form.f.wiki_access_rights|unsafe} @@ -40,6 +52,12 @@ {$form.f.issues_access_rights|unsafe} @@ -49,32 +67,37 @@ {$form.f.source_access_rights|unsafe} - - - - + +{$form.f.private_project.labelTag} + @@ -94,27 +117,45 @@ password or SSH key.{/blocktrans} {/block} {block context}
-

{trans 'Instructions:'}

-

{blocktrans}You can configure here the project tabs access rights and notification emails.{/blocktrans}

-

{blocktrans}Notification emails will be sent from the {$from_email} address, if you send the email to a mailing list, you may need to register this email address. Multiple email addresses must be separated through commas (','). If you do not want to send emails for a given type of changes, simply leave the corresponding field empty.{/blocktrans}

-

{blocktrans}If you mark a project as private, only the project members and administrators, together with the extra authorized users you provide will have access to the project. You will still be able to define further access rights for the different tabs but the "Open to all" and "Signed in users" will default to authorized users only.{/blocktrans}

-

{blocktrans}Specify each person by its login. Each person must have already registered with the given login. Separate the logins with commas and/or new lines.{/blocktrans}

+

{blocktrans}This section allows you to configure project tabs access rights and notifications.{/blocktrans}

+

{trans 'Access Rights'}

+

{blocktrans}Tab access controls whether a single user can navigate into a particular section of your project via the main menu or automatically generated object links.{/blocktrans}

+

{blocktrans}If you mark a project as private, only the project members and administrators, together with the extra authorized users you provide will have access to the project as a whole. You will still be able to define further access rights for the different tabs but the "Open to all" and "Signed in users" will default to authorized users only.{/blocktrans}

+

{blocktrans}For the extra authorized user list, specify each person by its login. Each person must have already registered with the given login. Separate the logins with commas and/or new lines.{/blocktrans}

+

{blocktrans}Only project members and admins have write access to the source. If you restrict the access to the source, anonymous access is not provided and the users must authenticate themselves with their password or SSH key.{/blocktrans}

+

{trans 'Notifications'}

+

{blocktrans}Here you can configure who should be notified about changes in a particular section. You can also configure additional addresses, like the one of a mailing list, that should be notified. (Keep in mind that you might have to register the sender address {$from_email} to let the mailing list actually accept notification emails.) Multiple email addresses must be separated through commas (',').{/blocktrans}

{/block} {block javascript}{literal} {/literal}{/block} diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index 96dc4af..d2b4c47 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -43,8 +43,12 @@ a:active{ padding: 0 1em; } +.left { + text-align: left !important; +} + .right { - text-align: right; + text-align: right !important; } .a-c { @@ -1232,3 +1236,19 @@ table.issue-summary td.graph-color { table.issue-summary td.graph-percent { padding-left: 1em; } + +table.form.access-rights {} + +table.form.access-rights th + th, +table.form.access-rights td + td { + padding-left: 1em; +} + +table.form.access-rights td + td label { + padding-right: 0.5em; +} + +table.form.access-rights th *, +table.form.access-rights td * { + vertical-align: middle; +}
 {trans 'Access Rights'}{trans 'Notification Email'}{trans 'Access Rights'}{trans 'Notifications'}
{$form.f.downloads_access_rights.labelTag}: {if $form.f.downloads_notification_email.errors}{$form.f.downloads_notification_email.fieldErrors}{/if} +{$form.f.downloads_notification_owners_enabled|unsafe} +{$form.f.downloads_notification_owners_enabled.labelTag} +{$form.f.downloads_notification_members_enabled|unsafe} +{$form.f.downloads_notification_members_enabled.labelTag} +{$form.f.downloads_notification_email_enabled|unsafe} +{$form.f.downloads_notification_email_enabled.labelTag} {$form.f.downloads_notification_email|unsafe}
{if $form.f.wiki_notification_email.errors}{$form.f.wiki_notification_email.fieldErrors}{/if} +{$form.f.wiki_notification_owners_enabled|unsafe} +{$form.f.wiki_notification_owners_enabled.labelTag} +{$form.f.wiki_notification_members_enabled|unsafe} +{$form.f.wiki_notification_members_enabled.labelTag} +{$form.f.wiki_notification_email_enabled|unsafe} +{$form.f.wiki_notification_email_enabled.labelTag} {$form.f.wiki_notification_email|unsafe}
{if $form.f.issues_notification_email.errors}{$form.f.issues_notification_email.fieldErrors}{/if} +{$form.f.issues_notification_owners_enabled|unsafe} +{$form.f.issues_notification_owners_enabled.labelTag} +{$form.f.issues_notification_members_enabled|unsafe} +{$form.f.issues_notification_members_enabled.labelTag} +{$form.f.issues_notification_email_enabled|unsafe} +{$form.f.issues_notification_email_enabled.labelTag} {$form.f.issues_notification_email|unsafe}
{if $form.f.source_notification_email.errors}{$form.f.source_notification_email.fieldErrors}{/if} +{$form.f.source_notification_owners_enabled|unsafe} +{$form.f.source_notification_owners_enabled.labelTag} +{$form.f.source_notification_members_enabled|unsafe} +{$form.f.source_notification_members_enabled.labelTag} +{$form.f.source_notification_email_enabled|unsafe} +{$form.f.source_notification_email_enabled.labelTag} {$form.f.source_notification_email|unsafe}
  -{blocktrans} -Only project members and admins have write access to the source.
-If you restrict the access to the source, anonymous access is
-not provided and the users must authenticate themselves with their
-password or SSH key.{/blocktrans} -
{$form.f.review_access_rights.labelTag}: {if $form.f.review_access_rights.errors}{$form.f.review_access_rights.fieldErrors}{/if} {$form.f.review_access_rights|unsafe} {if $form.f.review_notification_email.errors}{$form.f.review_notification_email.fieldErrors}{/if} +{$form.f.review_notification_owners_enabled|unsafe} +{$form.f.review_notification_owners_enabled.labelTag} +{$form.f.review_notification_members_enabled|unsafe} +{$form.f.review_notification_members_enabled.labelTag} +{$form.f.review_notification_email_enabled|unsafe} +{$form.f.review_notification_email_enabled.labelTag} {$form.f.review_notification_email|unsafe}
{if $form.f.private_project.errors}{$form.f.private_project.fieldErrors}{/if} +  +{if $form.f.private_project.errors}{$form.f.private_project.fieldErrors}{/if} {$form.f.private_project|unsafe} - -{$form.f.private_project.labelTag}