Commit eaf89f91 authored by Robert Lyon's avatar Robert Lyon

Bug 1848092: Add personal labels to groups

To allow for filtering by these labels (similar to tags) on
 - the group index page
 - in the mygroups block (on profile / dashboard pages)
 - usr account setting to filter the list in sideblock

Adjusted the filtering to 'OR' join so you can display groups with
'cat' OR 'dog' labels

Change-Id: Id8c36f05b7dd27d9bf9b90722b2d66c6f3db877e
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent f9c8dbf8
......@@ -248,6 +248,13 @@ function accountprefs_submit(Pieform $form, $values) {
$oldtheme = $USER->get_account_preference('theme');
$oldgroupsideblockmaxgroups = $USER->get_account_preference('groupsideblockmaxgroups');
$oldgroupsideblocksortby = $USER->get_account_preference('groupsideblocksortby');
$oldgroupsideblocklabels = $USER->get_account_preference('groupsideblocklabels');
if (isset($values['groupsideblocklabels'][0]) && empty($values['groupsideblocklabels'][0])) {
$values['groupsideblocklabels'] = '';
}
else {
$values['groupsideblocklabels'] = json_encode(array_values($values['groupsideblocklabels']));
}
// Set user account preferences
foreach ($expectedprefs as $eprefkey => $epref) {
......@@ -302,6 +309,9 @@ function accountprefs_submit(Pieform $form, $values) {
if ($values['groupsideblocksortby'] != $oldgroupsideblocksortby) {
$reload = true;
}
if ($values['groupsideblocklabels'] != $oldgroupsideblocklabels) {
$reload = true;
}
$reload = plugin_account_prefs_submit($form, $values) || $reload;
......
......@@ -73,6 +73,7 @@ class PluginBlocktypeMyGroups extends MaharaCoreBlocktype {
$configdata = $instance->get('configdata');
$sort = !empty($configdata['sort']) ? $configdata['sort'] : null;
$limit = !empty($configdata['limitto']) ? $configdata['limitto'] : null;
$grouplabels = !empty($configdata['grouplabels']) ? $configdata['grouplabels'] : array();
$view = $instance->get_view();
$baseurl = ($view->get('type') == 'dashboard') ? $view->get_url() . '?id=' . $view->get('id') : $view->get_url();
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $instance->get('id');
......@@ -86,10 +87,10 @@ class PluginBlocktypeMyGroups extends MaharaCoreBlocktype {
require_once('group.php');
// Group stuff
if (!empty($limit)) {
list($usergroups, $count) = group_get_user_groups($userid, null, $sort, $limit, 0);
list($usergroups, $count) = group_get_user_groups($userid, null, $sort, $limit, 0, true, $grouplabels);
}
else {
$usergroups = group_get_user_groups($userid, null, $sort);
$usergroups = group_get_user_groups($userid, null, $sort, null, 0, true, $grouplabels);
$count = count($usergroups);
}
foreach ($usergroups as $group) {
......@@ -121,7 +122,10 @@ class PluginBlocktypeMyGroups extends MaharaCoreBlocktype {
public static function instance_config_form(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$labels = array();
if (isset($configdata['grouplabels']) && is_array($configdata['grouplabels'])) {
$labels = $configdata['grouplabels'];
}
return array(
'sort' => array(
'type' => 'select',
......@@ -143,10 +147,24 @@ class PluginBlocktypeMyGroups extends MaharaCoreBlocktype {
'maxlength' => 4,
),
),
'grouplabels' => array(
'type' => 'autocomplete',
'title' => get_string('displayonlylabels', 'group'),
'ajaxurl' => get_config('wwwroot') . 'group/addlabel.json.php',
'multiple' => true,
'initfunction' => 'translate_landingpage_to_tags',
'ajaxextraparams' => array(),
'extraparams' => array('tags' => false),
'defaultvalue' => $labels,
'mininputlength' => 2,
),
);
}
public static function instance_config_save($values) {
if (isset($values['grouplabels'][0]) && empty($values['grouplabels'][0])) {
unset($values['grouplabels']);
}
$values['limitto'] = !empty($values['limitto']) ? (int)$values['limitto'] : '';
return $values;
}
......
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'group.php');
global $USER;
$request = param_variable('q');
$page = param_integer('page');
if ($page < 1) {
$page = 1;
}
$resultsperpage = 10;
$more = true;
$tmpresults = array();
while ($more && count($tmpresults) < $resultsperpage) {
$results = group_labels_for_group($request, null, $resultsperpage, $resultsperpage * ($page - 1));
$more = $results['count'] > $resultsperpage * $page;
if (!$results['data']) {
$results['data'] = array();
}
foreach ($results['data'] as $result) {
if (count($tmpresults) >= $resultsperpage) {
$more = true;
continue;
}
$tmpresults[] = (object) array(
'id' => $result->label,
'text' => hsc($result->label)
);
}
$page++;
}
echo json_encode(array(
'more' => $more,
'results' => $tmpresults,
));
......@@ -68,9 +68,9 @@ if ($groupcategory != 0) {
if ($query) {
$params['query'] = $query;
}
$paramsurl = get_config('wwwroot') . 'group/index.php' . ($params ? ('?' . http_build_query($params)) : '');
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'group/index.php' . ($params ? ('?' . http_build_query($params)) : ''),
'url' => $paramsurl,
'count' => $groups['count'],
'limit' => $groupsperpage,
'offset' => $offset,
......@@ -85,6 +85,7 @@ $pagination = build_pagination(array(
$smarty = smarty_core();
$smarty->assign('groups', $groups['data']);
$smarty->assign('paramsurl', $paramsurl);
$html = $smarty->fetch('group/mygroupresults.tpl');
json_reply(false, array(
......
......@@ -16,6 +16,35 @@ require(dirname(dirname(__FILE__)) . '/init.php');
define('TITLE', get_string('groups'));
require_once('group.php');
require_once('searchlib.php');
$labelfilter = param_variable('labelfilter', null);
$labelfilterremove = param_integer('remove', 0);
if ($labelfilter) {
$entitiesAttr = array('/\&quot;/' => '"',
'/\&amp;/' => '&',
'/\&lt;/' => '<',
'/\&gt;/' => '>',
'/\&\#39;/' => "'",
'/\&\#039;/' => "'",
'/\&\#x27;/' => "'"
);
$patterns = array_keys($entitiesAttr);
$replace = array_values($entitiesAttr);
$labelfilter = preg_replace($patterns, $replace, $labelfilter);
$userlabels = (array)json_decode(get_account_preference($USER->get('id'), 'grouplabels'));
$last = count($userlabels);
$flipped = array_flip($userlabels);
if ($labelfilterremove) {
unset($flipped[$labelfilter]);
}
else if (!isset($flipped[$labelfilter])) {
$flipped[$labelfilter] = $last;
}
$userlabels = array_flip($flipped);
natcasesort($userlabels);
set_account_preference($USER->get('id'), 'grouplabels', json_encode(array_values($userlabels)));
}
$filter = param_alpha('filter', 'allmy');
$offset = param_integer('offset', 0);
$groupcategory = param_signed_integer('groupcategory', 0);
......@@ -25,17 +54,28 @@ define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'group');
define('SECTION_PAGE', 'index');
// Create the "add label form " now if it's been submitted
if (param_exists('pieform_grouplabel')) {
pieform(group_label_form(param_integer('groupid')));
}
$activegrouplabels = (array)json_decode(get_account_preference($USER->get('id'), 'grouplabels'));
/* $searchmode will switch between 2 search funcs (with different queries)
* $searchmode = 'find' uses search_group
* $searchmode = 'mygroups' uses group_get_associated_groups
*/
$searchmode = 'find';
$showactivegrouplabels = false;
// check that the filter is valid, if not default to 'all'
if (in_array($filter, array('allmy', 'member', 'admin', 'invite', 'notmember', 'canjoin'))) {
if ($filter == 'allmy' || $filter == 'admin' || $filter == 'invite') {
if ($filter == 'allmy' || $filter == 'admin' || $filter == 'member' || $filter == 'invite') {
$searchmode = 'mygroups';
}
if ($filter == 'allmy' || $filter == 'member' || $filter == 'admin') {
$showactivegrouplabels = true;
}
$type = $filter;
}
else { // all or some other text
......@@ -161,7 +201,7 @@ else {
if ($searchmode == 'find') {
if ($groups['data']) {
$groups['data'] = group_get_extended_data($groups['data']);
}
}
}
group_prepare_usergroups_for_display($groups['data']);
......@@ -175,9 +215,9 @@ if ($groupcategory != 0) {
if ($query) {
$params['query'] = $query;
}
$paramsurl = get_config('wwwroot') . 'group/index.php' . ($params ? ('?' . http_build_query($params)) : '');
$pagination = build_pagination(array(
'url' => get_config('wwwroot') . 'group/index.php' . ($params ? ('?' . http_build_query($params)) : ''),
'url' => $paramsurl,
'count' => $groups['count'],
'limit' => $groupsperpage,
'offset' => $offset,
......@@ -194,9 +234,30 @@ function search_submit(Pieform $form, $values) {
redirect('/group/index.php?filter=' . $values['filter'] . ((isset($values['query']) && ($values['query'] != '')) ? '&query=' . urlencode($values['query']) : '') . (!empty($values['groupcategory']) ? '&groupcategory=' . intval($values['groupcategory']) : ''));
}
$labelfilter = array(
'name' => 'dummy',
'checkdirtychange' => false,
'elements' => array (
'grouplabelfilter' => array(
'type' => 'autocomplete',
'title' => get_string('filterbygrouplabel', 'group'),
'ajaxurl' => get_config('wwwroot') . 'group/addlabel.json.php',
'multiple' => true,
'initfunction' => 'translate_landingpage_to_tags',
'ajaxextraparams' => array(),
'extraparams' => array('tags' => false),
'defaultvalue' => $activegrouplabels,
'mininputlength' => 2,
)
),
);
$labelfilterform = pieform($labelfilter);
$smarty = smarty(array('paginator'));
setpageicon($smarty, 'icon-comments');
$smarty->assign('groups', $groups['data']);
$smarty->assign('paramsurl', $paramsurl);
$smarty->assign('activegrouplabels', $showactivegrouplabels ? $labelfilterform : false);
$smarty->assign('cancreate', group_can_create_groups());
$html = $smarty->fetch('group/mygroupresults.tpl');
$smarty->assign('groupresults', $html);
......
<?php
/**
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'group.php');
$id = param_integer('groupid');
$member = get_field('group_member', 'role', 'member', $USER->get('id'), 'group', $id);
if (!$member) {
// Not a member of the group - may be due to group not existing or has been deleted
$html = '<div class="alert alert-danger">' . get_string('grouplabelnotmember', 'group') . '</div>';
}
else {
// Group exists and is member
$html = group_label_form($id);
}
json_reply(false, array(
'message' => null,
'html' => $html,
));
......@@ -415,3 +415,20 @@ $string['groupparticipationreportsdesc1'] = "Group administrators can access a r
$string['returntogroupportfolios'] = "Return to group pages and collections";
$string['showintroduction'] = "Introduction";
$string['addgrouplabel'] = 'Add group labels';
$string['addgrouplabeldescription'] = 'Add one or more labels to this group that are only visible to you. By adding a label, you can organise the groups to your liking. You can also determine, which groups you want to see in the sidebar and on your profile page.';
$string['addgrouplabelfilter'] = 'Add the group label filter "%s"';
$string['addlabel'] = 'Add label';
$string['displayonlylabels'] = 'Display only groups labeled with';
$string['filterbygrouplabel'] = 'Filter by label';
$string['grouplabelnotmember'] = 'Currently, you are not a member of this group. Please refresh the page.';
$string['grouplabeladded'] = 'Group label added';
$string['grouplabelupdated'] = 'Group label updated';
$string['groupnovalidlabelsupplied'] = 'Your label must consist of at least two characters.';
$string['label'] = 'Label';
$string['labelfor'] = 'Add a label to group "%s"';
$string['mygrouplabel'] = 'My group labels';
$string['removegrouplabelfilter'] = 'Remove the group label filter "%s"';
$string['agrouplabeltooshort'] = 'One or more group labels are too short, they need at least %s characters.';
$string['agrouplabeltoolong'] = 'One or more group labels are too long, they can have at most %s characters.';
......@@ -1421,6 +1421,20 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
</KEYS>
</TABLE>
<TABLE NAME="group_usr_label">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="group" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="usr" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="ctime" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="label" TYPE="char" LENGTH="255" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" />
<KEY NAME="usrfk" TYPE="foreign" FIELDS="usr" REFTABLE="usr" REFFIELDS="id" />
</KEYS>
</TABLE>
<TABLE NAME="usr_institution_migrate">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
......
......@@ -1637,5 +1637,21 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql("UPDATE {block_instance} SET title = '' WHERE blocktype = 'signoff'");
}
if ($oldversion < 2020013000) {
log_debug('create group_usr_label table for group labels');
$table = new XMLDBTable('group_usr_label');
if (!table_exists($table)) {
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('group', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addFieldInfo('ctime', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('label', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('groupfk', XMLDB_KEY_FOREIGN, array('group'), 'group', array('id'));
$table->addKeyInfo('usrfk', XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));
create_table($table);
}
}
return $status;
}
......@@ -124,6 +124,9 @@ function pieform_element_autocomplete(Pieform $form, $element) {
if (isset($element['institution'])) {
$smarty->assign('institution', $element['institution']);
}
if (isset($element['group'])) {
$smarty->assign('group', $element['group']);
}
return $smarty->fetch('form/autocomplete.tpl');
}
......
This diff is collapsed.
......@@ -3865,15 +3865,16 @@ function profile_sideblock() {
if ($sortorder = $USER->get_account_preference('groupsideblocksortby')) {
$sort = $sortorder;
}
$grouplabels = (array)json_decode($USER->get_account_preference('groupsideblocklabels'));
if ($limitto === null) {
$data['groups'] = group_get_user_groups($USER->get('id'), null, $sort);
$data['groups'] = group_get_user_groups($USER->get('id'), null, $sort, null, 0, true, $grouplabels);
$total = count($data['groups']);
}
else if ($limitto === 0) {
$data['groups'] = null;
}
else {
list($data['groups'], $total) = group_get_user_groups($USER->get('id'), null, $sort, $limitto);
list($data['groups'], $total) = group_get_user_groups($USER->get('id'), null, $sort, $limitto, 0, true, $grouplabels);
}
$limitstr = '';
if (!empty($limitto) && $limitto < $total) {
......
......@@ -233,6 +233,7 @@ function expected_account_preferences() {
'tagssideblockmaxtags' => get_config('tagssideblockmaxtags'),
'groupsideblockmaxgroups' => '',
'groupsideblocksortby' => 'alphabetical',
'groupsideblocklabels' => '',
'hiderealname' => 0,
'multipleblogs' => get_config('defaultmultipleblogs'),
'showhomeinfo' => 1,
......@@ -248,6 +249,7 @@ function expected_account_preferences() {
'view_details_active' => 0,
'showlayouttranslatewarning' => 1,
'accessibilityprofile' => false,
'grouplabels' => '',
);
}
......@@ -410,6 +412,18 @@ function general_account_prefs_form_elements($prefs) {
'alphabetical' => get_string('alphabetical', 'blocktype.mygroups'),
),
);
$labels = (array)json_decode(get_account_preference($USER->get('id'), 'groupsideblocklabels'));
$elements['groupsideblocklabels'] = array(
'type' => 'autocomplete',
'title' => get_string('displayonlylabels', 'group'),
'ajaxurl' => get_config('wwwroot') . 'group/addlabel.json.php',
'multiple' => true,
'initfunction' => 'translate_landingpage_to_tags',
'ajaxextraparams' => array(),
'extraparams' => array('tags' => false),
'defaultvalue' => $labels,
'mininputlength' => 2,
);
if (get_config('userscanhiderealnames')) {
$elements['hiderealname'] = array(
'type' => 'switchbox',
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2020012800;
$config->version = 2020013000;
$config->series = '20.04';
$config->release = '20.04dev';
$config->minupgradefrom = 2017031605;
......
......@@ -963,7 +963,7 @@ class PluginSearchInternal extends PluginSearch {
}
else if ($type == 'canjoin') {
$sql .= '
AND (NOT (jointype = ? AND request = 0 AND g.id NOT IN (SELECT "group" FROM {group_member_invite} WHERE member = ?))
AND (NOT (jointype = ? AND request = 0 AND g.id NOT IN (SELECT "group" FROM {group_member_invite} WHERE "member" = ?))
AND NOT (jointype = ? AND request = 0)
) AND g.id NOT IN (' . $grouproles . ')';
$values = array_merge($values, array('controlled', $USER->get('id'), 'approve'));
......
......@@ -190,7 +190,7 @@ class BehatForms extends BehatBase {
*/
private function select2FillSearchField($page, $field, $value) {
$driver = $this->getSession()->getDriver();
$select2Input = $this->getSession()->getDriver()->getWebDriverSession()->element('xpath', "//html/descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]");
$select2Input = $this->getSession()->getDriver()->getWebDriverSession()->element('xpath', "//html//select[@id='" . $field . "']/../descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]");
if (!$select2Input) {
throw new \Exception(sprintf('No field "%s" found', $field));
}
......
......@@ -538,3 +538,13 @@ div.toolbarhtml {
#migrateinstitution_authinstance {
max-width: 420px;
}
.activegrouplabels.noresults form .form-group {
padding: $card-spacer-y $card-spacer-x;
border-bottom: 1px solid $input-border-color;
}
.activegrouplabels form .form-group {
border-bottom: 0;
padding: 0;
}
\ No newline at end of file
......@@ -518,6 +518,10 @@
}
}
label.sr-only ~ .errmsg {
margin-left: 0px; // No margin if the label is hidden
}
.description:not(.html) {
color: $gray-300;
font-style: italic;
......
......@@ -54,6 +54,15 @@
border-radius: $border-radius-sm;
border-width: 1px;
}
.activegrouplabels {
padding: $card-spacer-y $card-spacer-x;
+ .list-group {
.list-group-item:first-child {
@include border-top-radius(0);
}
}
}
}
.view-pane .card {
......
......@@ -26,6 +26,9 @@
{{if $institution}}
'institution': "{{$institution}}",
{{/if}}
{{if $group}}
'group': "{{$group}}",
{{/if}}
}
},
processResults: function(data, page) {
......
<div class="list-group-item {if $group->membershiptype == 'invite' || $group->membershiptype == 'request' || $group->requests} list-group-item-warning{/if}">
<div id="grouplist_{$group->id}" class="list-group-item {if $group->membershiptype == 'invite' || $group->membershiptype == 'request' || $group->requests} list-group-item-warning{/if}">
<a href="{$group->homeurl}" class="outer-link"><span class="sr-only">{$group->name}</span></a>
<div class="row">
<div class="col-md-8">
......@@ -15,7 +15,7 @@
{$group->description|str_shorten_html:100:true:true:false|safe}
</p>
<div class="groupsdetails text-small">
{if $group->editwindow}
{if $group->editwindow}
<div class="groupeditable">
{str tag=editable section=group}:
{$group->editwindow}
......@@ -24,10 +24,12 @@
{if $group->admins}
<div class="groupadmin">
<strong>{str tag=groupadmins section=group}:</strong>
{strip}
{foreach name=admins from=$group->admins item=user}
<a href="{profile_url($user)}" class="inner-link"> {$user|display_name}</a>
{if !$.foreach.admins.last},
{/if}{/foreach}
{if !$.foreach.admins.last},{/if}
{/foreach}
{/strip}
</div>
{/if}
{if $group->membercount}
......@@ -37,6 +39,29 @@
</a>
</div>
{/if}
{if $group->labels}
<div class="grouplabels">
<strong>{str tag=mygrouplabel section=group}:</strong>
{strip}
{foreach name=labels from=$group->labels item=label}
{assign var=labelselected value=0}
{if $activegrouplabels}
{foreach from=$activegrouplabels item=grouplabel}
{if $grouplabel === $label}
{assign var=labelselected value=1}
{/if}
{/foreach}
{/if}
{if $labelselected}
&nbsp;{$label}
{else}
<a href="{$paramsurl}&labelfilter={urlencode($label)}" title='{str tag=addgrouplabelfilter section=group arg1=$label}' class="inner-link"> {$label}</a>
{/if}
{if !$.foreach.labels.last},{/if}
{/foreach}
{/strip}
</div>
{/if}
</div>
</div>
......
<div class="modal fade page-modal js-page-modal" id="group-label-modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn close" data-dismiss="modal" aria-label="{str tag=Close}"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">
<span class="icon icon-lg icon-plus"></span>
{str tag=addgrouplabel section=group}
</h4>
</div>
<div class="modal-body">
<p>{str tag=addgrouplabeldescription section=group}</p>
<div class="labelform"></div>
</div>
</div>
</div>
</div>
{if $group->membershiptype == 'member'}
<div class="btn-action-list">
<div class="groupuserstatus btn-top-right btn-group btn-group-top">
{if $list}
<a href="#" class="label-btn btn btn-secondary" data-id="{$group->id}" title='{str tag="labelfor" section="group" arg1=$group->name}'>
<span class="icon icon-tag" role="presentation" aria-hidden="true"></span>
<span class="btn-title">{str tag="label" section="group"}</span>
</a>
{/if}
{if $group->canleave}
<a href ="{$WWWROOT}group/leave.php?id={$group->id}" class="btn btn-secondary">
<span class="icon icon-long-arrow-alt-right icon-lg text-danger left" role="presentation" aria-hidden="true"></span>
......@@ -24,6 +30,12 @@
{elseif $group->membershiptype == 'admin'}
<div class="btn-action-list">
<div class="groupuserstatus btn-top-right btn-group btn-group-top">
{if $list}
<a href="#" class="label-btn btn btn-secondary" data-id="{$group->id}" title='{str tag="labelfor" section="group" arg1=$group->name}'>
<span class="icon icon-tag" role="presentation" aria-hidden="true"></span>
<span class="btn-title">{str tag="label" section="group"}</span>
</a>
{/if}
{if $viewid}
<a href="{$WWWROOT}view/blocks.php?id={$viewid}&group={$group->id}" title="{str tag=editcontentandlayout section='view'}" class="btn btn-secondary">
<span class="icon icon-pencil-alt text-default" role="presentation" aria-hidden="true"></span>
......
......@@ -11,20 +11,79 @@
{if $groups}
<div class="card view-container">
<h2 class="card-header">{str tag=Results}</h2>
{if $activegrouplabels}
<div class="activegrouplabels">
{$activegrouplabels|safe}
</div>
{/if}
<div id="findgroups" class="list-group">
{$groupresults|safe}
</div>
</div>
{$pagination|safe}
<script>
function wire_labels() {
jQuery('.label-btn').each(function(k, label) {
$(label).off('click');
$(label).on('click', function(e) {
e.stopPropagation();
e.preventDefault();
var params = { 'groupid': $(label).data('id') };
sendjsonrequest(config.wwwroot + 'group/label.json.php', params, 'POST', function (data) {
$('#group-label-modal .modal-body .labelform').html(data.html);
$('#group-label-modal').off('hidden.bs.modal');
$('#group-label-modal').on('hidden.bs.modal', function () {
$('#messages').find('.alert-danger').hide();
});
$('#group-label-modal').modal('show');
});
});
});
}
function group_label_update(form, data) {
if (data.returnCode == 0) {
formSuccess(form, data);
$('#group-label-modal').modal('hide');
$('#' + data.data.id).replaceWith(data.data.html);
wire_labels();
}
else {
$('#grouplabel').prepend('<div class="alert alert-danger">' + data.message + '</div>');
formError(form, data);
}
}
// When paginating
$(document).on('pageupdated', function(e, data) {
wire_labels();
});
// On initial page load
wire_labels();
{if $pagination_js}
<script>
{$pagination_js|safe}
</script>
{/if}
</script>
{else}
{if $activegrouplabels}
<div class="activegrouplabels noresults">
{$activegrouplabels|safe}
</div>
{/if}
<p class="no-results">
{str tag="nogroupsfound" section="group"}
{str tag="trysearchingforgroups1" section="group" arg1=$WWWROOT}
</p>
{/if}