Commit 768c0261 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix group shortnames in share with group buttons (bug #881681)



When running through the list of a user's groups for display in the
Share with my groups buttons, a group with a long name can cause
another group's button to have the long-named group's short name
displayed.  The php array pointer is not moved when items are added
to the array.

Change-Id: If90b63ec721bfbee2b2c1ad2c7d29d855c9ce1f2
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent d513d730
...@@ -120,7 +120,7 @@ function pieform_element_viewacl(Pieform $form, $element) { ...@@ -120,7 +120,7 @@ function pieform_element_viewacl(Pieform $form, $element) {
); );
$mygroups = array(); $mygroups = array();
foreach (group_get_user_groups($USER->get('id')) as $g) { foreach (group_get_user_groups($USER->get('id')) as $g) {
$mygroups[] = array( $group = array(
'type' => 'group', 'type' => 'group',
'id' => $g->id, 'id' => $g->id,
'start' => null, 'start' => null,
...@@ -129,13 +129,14 @@ function pieform_element_viewacl(Pieform $form, $element) { ...@@ -129,13 +129,14 @@ function pieform_element_viewacl(Pieform $form, $element) {
'preset' => false 'preset' => false
); );
if (mb_strlen($g->name) > 30) { if (mb_strlen($g->name) > 30) {
$mygroups[key($mygroups)]['shortname'] = str_shorten_text($g->name, 30, true); $group['shortname'] = str_shorten_text($g->name, 30, true);
} }
$mygroups[] = $group;
} }
$faves = array(); $faves = array();
foreach (get_user_favorites($USER->get('id')) as $u) { foreach (get_user_favorites($USER->get('id')) as $u) {
$faves[] = array( $fave = array(
'type' => 'user', 'type' => 'user',
'id' => $u->id, 'id' => $u->id,
'start' => null, 'start' => null,
...@@ -144,8 +145,9 @@ function pieform_element_viewacl(Pieform $form, $element) { ...@@ -144,8 +145,9 @@ function pieform_element_viewacl(Pieform $form, $element) {
'preset' => false 'preset' => false
); );
if (mb_strlen($u->name) > 30) { if (mb_strlen($u->name) > 30) {
$faves[key($faves)]['shortname'] = str_shorten_text($u->name, 30, true); $fave['shortname'] = str_shorten_text($u->name, 30, true);
} }
$faves[] = $fave;
} }
$smarty->assign('viewtype', $element['viewtype']); $smarty->assign('viewtype', $element['viewtype']);
......
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