Commit 51998ff9 authored by sylvieg's avatar sylvieg

[MOD]INVITE: 2 params including to limit groups + preselected defaultgroup

parent 4ae33dd6
......@@ -6,7 +6,18 @@ function wikiplugin_invite_info() {
'description' => tra( 'Invite an email in groups.' ),
'prefs' => array( 'wikiplugin_invite' ),
'body' => tra('Confirmation message after posting form'),
'params' => array()
'params' => array(
'including' => array(
'required' => false,
'name' => tra('Including group'),
'description' => tra('Group'),
),
'defaultgroup' => array(
'required' => false,
'name' => tra('Default group'),
'description' => tra('Group'),
),
)
);
}
function wikiplugin_invite( $data, $params) {
......@@ -16,6 +27,14 @@ function wikiplugin_invite( $data, $params) {
return;
}
$userGroups = $userlib->get_user_groups_inclusion($user);
if (!empty($params['including'])) {
$groups = $userlib->get_including_groups($params['including']);
foreach ($userGroups as $gr=>$inc) {
if (!in_array($gr, $groups)) {
unset($userGroups[$gr]);
}
}
}
$errors = array();
$feedbacks = array();
if (isset($_REQUEST['invite'])) {
......@@ -75,6 +94,7 @@ function wikiplugin_invite( $data, $params) {
if (!empty($_REQUEST['message'])) $smarty->assign_by_ref('message', $_REQUEST['message']);
}
}
$smarty->assign_by_ref('params', $params);
$smarty->assign_by_ref('userGroups', $userGroups);
return '~np~'.$smarty->fetch('wiki-plugins/wikiplugin_invite.tpl').'~/np~';
}
\ No newline at end of file
......@@ -32,7 +32,7 @@
<td>
<select name="groups[]" id="groups" multiple="multiple">
{foreach from=$userGroups key=gx item=gi}
<option value="{$gx|escape}"{if isset($groups) && in_array($gx, $groups)} selected="selected"{/if}>{$gx|escape}</option>
<option value="{$gx|escape}"{if (isset($groups) && in_array($gx, $groups)) or (!isset($groups) && $gx eq $params.defaultgroup)} selected="selected"{/if}>{$gx|escape}</option>
{/foreach}
</select>
</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment