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.
This commit is contained in:
Thomas Keller 2011-11-04 00:46:33 +01:00
parent 099e4888e8
commit 2b5efb7fee
5 changed files with 141 additions and 51 deletions

View File

@ -12,6 +12,8 @@ by the friendly folks from Scilab <http://www.scilab.org/>!
implementations of this web hook as this setting is likely to be removed implementations of this web hook as this setting is likely to be removed
in future versions of Indefero. in future versions of Indefero.
- Indefero now needs PHP's zip module which is not enabled by default. - 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 ## New Features

View File

@ -57,21 +57,45 @@ class IDF_Form_TabsConf extends Pluf_Form
'widget' => 'Pluf_Form_Widget_SelectInput', 'widget' => 'Pluf_Form_Widget_SelectInput',
)); ));
} }
$ak = array('downloads_notification_email',
'review_notification_email', $sections = array(
'wiki_notification_email', 'downloads_notification',
'source_notification_email', 'review_notification',
'issues_notification_email',); 'wiki_notification',
foreach ($ak as $key) { 'source_notification',
$this->fields[$key] = new IDF_Form_Field_EmailList( 'issues_notification',
);
foreach ($sections as $section) {
$this->fields[$section.'_owners_enabled'] = new Pluf_Form_Field_Boolean(
array('required' => false, array('required' => false,
'label' => $key, 'label' => __('Project owners'),
'initial' => $this->conf->getVal($key, ''), 'initial' => $this->conf->getVal($section.'_owners_enabled', false),
'widget_attrs' => array('size' => 40), '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( $this->fields['private_project'] = new Pluf_Form_Field_Boolean(
array('required' => false, array('required' => false,
'label' => __('Private project'), 'label' => __('Private project'),

View File

@ -508,21 +508,24 @@ class IDF_Views_Project
} }
} }
$form->save(); // Save the authorized users. $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', $url = Pluf_HTTP_URL_urlForView('IDF_Views_Project::adminTabs',
array($prj->shortname)); array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url); return new Pluf_HTTP_Response_Redirect($url);
} }
} else { } else {
$params = array(); $params = array();
$keys = array('downloads_access_rights', 'source_access_rights', $sections = array('downloads', 'wiki', 'source', 'issues', 'review');
'issues_access_rights', 'review_access_rights', $keys = array();
'wiki_access_rights',
'downloads_notification_email', foreach ($sections as $section) {
'review_notification_email', $keys[] = $section.'_access_rights';
'wiki_notification_email', $keys[] = $section.'_notification_owners_enabled';
'source_notification_email', $keys[] = $section.'_notification_members_enabled';
'issues_notification_email'); $keys[] = $section.'_notification_email_enabled';
$keys[] = $section.'_notification_email';
}
foreach ($keys as $key) { foreach ($keys as $key) {
$_val = $request->conf->getVal($key, false); $_val = $request->conf->getVal($key, false);
if ($_val !== false) { if ($_val !== false) {

View File

@ -10,11 +10,11 @@
</div> </div>
{/if} {/if}
<form method="post" action="."> <form method="post" action=".">
<table class="form" summary=""> <table class="form access-rights" summary="">
<tr> <tr>
<th>&nbsp;</th> <th>&nbsp;</th>
<th class="a-c"><strong>{trans 'Access Rights'}</strong></th> <th class="left"><strong>{trans 'Access Rights'}</strong></th>
<th class="a-c"><strong>{trans 'Notification Email'}</strong></th> <th class="left"><strong>{trans 'Notifications'}</strong></th>
</tr> </tr>
<tr> <tr>
<th><strong>{$form.f.downloads_access_rights.labelTag}:</strong></th> <th><strong>{$form.f.downloads_access_rights.labelTag}:</strong></th>
@ -22,6 +22,12 @@
{$form.f.downloads_access_rights|unsafe} {$form.f.downloads_access_rights|unsafe}
</td> </td>
<td>{if $form.f.downloads_notification_email.errors}{$form.f.downloads_notification_email.fieldErrors}{/if} <td>{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} {$form.f.downloads_notification_email|unsafe}
</td> </td>
</tr> </tr>
@ -31,6 +37,12 @@
{$form.f.wiki_access_rights|unsafe} {$form.f.wiki_access_rights|unsafe}
</td> </td>
<td>{if $form.f.wiki_notification_email.errors}{$form.f.wiki_notification_email.fieldErrors}{/if} <td>{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} {$form.f.wiki_notification_email|unsafe}
</td> </td>
</tr> </tr>
@ -40,6 +52,12 @@
{$form.f.issues_access_rights|unsafe} {$form.f.issues_access_rights|unsafe}
</td> </td>
<td>{if $form.f.issues_notification_email.errors}{$form.f.issues_notification_email.fieldErrors}{/if} <td>{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} {$form.f.issues_notification_email|unsafe}
</td> </td>
</tr> </tr>
@ -49,32 +67,37 @@
{$form.f.source_access_rights|unsafe} {$form.f.source_access_rights|unsafe}
</td> </td>
<td>{if $form.f.source_notification_email.errors}{$form.f.source_notification_email.fieldErrors}{/if} <td>{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} {$form.f.source_notification_email|unsafe}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>&nbsp;</td>
<td colspan="2" class="helptext">
{blocktrans}
Only project members and admins have write access to the source.<br />
If you restrict the access to the source, anonymous access is<br />
not provided and the users must authenticate themselves with their<br />
password or SSH key.{/blocktrans}
</td></tr>
<tr>
<th><strong>{$form.f.review_access_rights.labelTag}:</strong></th> <th><strong>{$form.f.review_access_rights.labelTag}:</strong></th>
<td>{if $form.f.review_access_rights.errors}{$form.f.review_access_rights.fieldErrors}{/if} <td>{if $form.f.review_access_rights.errors}{$form.f.review_access_rights.fieldErrors}{/if}
{$form.f.review_access_rights|unsafe} {$form.f.review_access_rights|unsafe}
</td> </td>
<td>{if $form.f.review_notification_email.errors}{$form.f.review_notification_email.fieldErrors}{/if} <td>{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} {$form.f.review_notification_email|unsafe}
</td> </td>
</tr> </tr>
<tr> <tr>
<th>{if $form.f.private_project.errors}{$form.f.private_project.fieldErrors}{/if} <th>&nbsp;</th>
<td>
{if $form.f.private_project.errors}{$form.f.private_project.fieldErrors}{/if}
{$form.f.private_project|unsafe} {$form.f.private_project|unsafe}
</th> {$form.f.private_project.labelTag}
<td>{$form.f.private_project.labelTag}</td> </td>
</tr> </tr>
<tr id="authorized-users-row"> <tr id="authorized-users-row">
<td>&nbsp;</td> <td>&nbsp;</td>
@ -94,27 +117,45 @@ password or SSH key.{/blocktrans}
{/block} {/block}
{block context} {block context}
<div class="issue-submit-info"> <div class="issue-submit-info">
<p><strong>{trans 'Instructions:'}</strong></p> <p>{blocktrans}This section allows you to configure project tabs access rights and notifications.{/blocktrans}</p>
<p>{blocktrans}You can configure here the project tabs access rights and notification emails.{/blocktrans}</p> <p><strong>{trans 'Access Rights'}</strong></p>
<p>{blocktrans}Notification emails will be sent from the <strong>{$from_email}</strong> 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}</p> <p>{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}</p>
<p>{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}</p> <p>{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}</p>
<p>{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}</p> <p>{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}</p>
<p>{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}</p>
<p><strong>{trans 'Notifications'}</strong></p>
<p>{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 <strong>{$from_email}</strong> to let the mailing list actually accept notification emails.) Multiple email addresses must be separated through commas (',').{/blocktrans}</p>
</div> </div>
{/block} {/block}
{block javascript}{literal} {block javascript}{literal}
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function() {
// If not checked, hide // if not checked, hide
if (!$("#id_private_project").is(":checked")) if (!$("#id_private_project").is(":checked")) {
$("#authorized-users-row").hide(); $("#authorized-users-row").hide();
$("#id_private_project").click(function(){ }
$("#id_private_project").click(function() {
if ($("#id_private_project").is(":checked")) { if ($("#id_private_project").is(":checked")) {
$("#authorized-users-row").show(); $("#authorized-users-row").show();
} else { } else {
$("#authorized-users-row").hide(); $("#authorized-users-row").hide();
} }
}); });
// if not checked, hide
$.each(['downloads', 'wiki', 'issues', 'source', 'review'], function(index, section) {
if (!$("#id_" + section + "_notification_email_enabled").is(":checked")) {
$("#id_" + section + "_notification_email").hide();
}
$("#id_" + section + "_notification_email_enabled").click(function() {
if ($("#id_" + section + "_notification_email_enabled").is(":checked")) {
$("#id_" + section + "_notification_email").show();
} else {
$("#id_" + section + "_notification_email").hide();
}
}); });
});
});
</script> </script>
{/literal}{/block} {/literal}{/block}

View File

@ -43,8 +43,12 @@ a:active{
padding: 0 1em; padding: 0 1em;
} }
.left {
text-align: left !important;
}
.right { .right {
text-align: right; text-align: right !important;
} }
.a-c { .a-c {
@ -1232,3 +1236,19 @@ table.issue-summary td.graph-color {
table.issue-summary td.graph-percent { table.issue-summary td.graph-percent {
padding-left: 1em; 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;
}