Commit 2b79e29a authored by Lisa Seeto's avatar Lisa Seeto Committed by Robert Lyon
Browse files

Bug 1814621: Consolidate "My friends" and "Find people" screens



Change-Id: I4fc0334d50500d649e9f2c6125f0f181df0ccba4
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent 988ef71e
......@@ -31,15 +31,21 @@
<div class="col-md-4">
<ul class="list-unstyled inner-link text-small user-action-list">
{if $user->pending}
<li class="approvefriend">
<span class="icon icon-check icon-lg text-success" role="presentation" aria-hidden="true"></span>
{$user->accept|safe}
</li>
<li class="denyrequest">
<span class="icon icon-ban icon-lg text-danger left" role="presentation" aria-hidden="true"></span>
<a href="{$WWWROOT}user/denyrequest.php?id={$user->id}&amp;returnto={$page}&amp;offset={$offset}" class="btn-deny">
{str tag='denyrequest' section='group'}
</a>
<p>{str tag="pendingfriend" section="group"}</p>
<span class="whymakemeyourfriend">
<strong>
{str tag='whymakemeyourfriend' section='group'}
</strong>
<p>{$user->message|format_whitespace|safe}</p>
</span>
<li>
<div class="btn-group">
{$user->accept|safe}
<a href="{$WWWROOT}user/denyrequest.php?id={$user->id}&amp;returnto={$page}&amp;offset={$offset}" class="btn btn-secondary">
<span class="icon icon-ban icon-lg text-danger left" role="presentation" aria-hidden="true"></span>
{str tag='deny' section='group'}
</a>
</div>
</li>
{/if}
{if $user->friend}
......
{if $data}
{foreach from=$data item=user}
{if $page == 'myfriends'}
{include file="user/user.tpl" user=$user page=$page admingroups=$admingroups mrmoduleactive=$mrmoduleactive}
{elseif $page == 'find'}
{include file="user/userfind.tpl" user=$user page=$page admingroups=$admingroups mrmoduleactive=$mrmoduleactive}
{/if}
{/foreach}
{elseif $query}
<div class="no-results">{str tag=nosearchresultsfound section=group}</div>
......
......@@ -11,7 +11,7 @@
{elseif $accessgroup.accesstype == 'public'}
{str tag="public" section="view"}
{elseif $accessgroup.accesstype == 'friends'}
<a href="{$WWWROOT}user/myfriends.php" id="link-myfriends">{str tag="friends" section="view"}</a>
<a href="{$WWWROOT}user/index.php?filter=current" id="link-myfriends">{str tag="friends" section="view"}</a>
{elseif $accessgroup.accesstype == 'group'}
<a href="{$accessgroup.groupurl}">{$accessgroup.name}</a>{if $accessgroup.role} ({$accessgroup.roledisplay}){/if}
{elseif $accessgroup.accesstype == 'institution'}
......
......@@ -10,7 +10,8 @@
*/
define('INTERNAL', 1);
define('MENUITEM', 'engage/findfriends');
define('MENUITEM', 'engage/people');
define('SECTION_PAGE', 'denyrequest');
require(dirname(dirname(__FILE__)) . '/init.php');
define('TITLE', get_string('denyfriendrequest', 'group'));
require_once('searchlib.php');
......@@ -28,14 +29,11 @@ $user->introduction = get_field('artefact', 'title', 'artefacttype', 'introducti
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
$goto = 'user/index.php?filter=pending';
}
$goto .= (strpos($goto,'?') ? '&' : '?') . 'offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
......@@ -99,14 +97,11 @@ function denyrequest_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group'));
$offset = param_integer('offset', 0);
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
$goto = 'user/index.php?filter=current';
break;
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
......
......@@ -10,14 +10,14 @@
*/
define('INTERNAL', 1);
define('MENUITEM', 'engage/findfriends');
define('MENUITEM', 'engage/people');
require(dirname(dirname(__FILE__)) . '/init.php');
define('TITLE', get_string('findpeople'));
define('TITLE', get_string('people'));
require_once('searchlib.php');
safe_require('search', 'internal');
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'user');
define('SECTION_PAGE', 'find');
define('SECTION_PAGE', 'index');
if (param_variable('acceptfriend_submit', null)) {
acceptfriend_form(param_integer('id'));
......@@ -31,7 +31,12 @@ $offset = param_integer('offset', 0);
$filter = param_alpha('filter', $USER->get('admin') ? 'all' : 'myinstitutions');
$limit = 10;
$searchmode = 'find';
$options = array('exclude' => $USER->get('id'));
$data['query'] = $query;
if ($filter == 'myinstitutions' && $USER->get('institutions')) {
$options['myinstitutions'] = true;
}
......@@ -39,107 +44,89 @@ else {
$filter = 'all';
}
$data = search_user($query, $limit, $offset, $options);
$data['query'] = $query;
if (!empty($options['myinstitutions'])) {
$data['filter'] = $filter;
if ($filter == 'current' || $filter == 'pending') {
$searchmode = 'myfriends';
$data = search_friend($filter, $limit, $offset, $query);
}
else {
$data = search_user($query, $limit, $offset, $options);
}
require_once(get_config('libroot').'group.php');
$admingroups = (bool) group_get_user_admintutor_groups();
build_userlist_html($data, 'find', $admingroups);
$searchform = array(
'name' => 'search',
'checkdirtychange' => false,
'renderer' => 'div',
'class' => 'form-inline with-heading',
'elements' => array(
'inputgroup' => array(
'type' => 'fieldset',
'class' => 'input-group',
'title' => get_string('search'),
'elements' => array(
),
),
),
);
$searchform['elements']['inputgroup']['elements']['query'] = array(
'type' => 'text',
'title' => get_string('search'),
'hiddenlabel' => true,
'defaultvalue' => $query,
'placeholder' => get_string('searchusers'),
build_userlist_html($data, $searchmode, $admingroups, $filter, $query);
$elements = array();
$queryfield = array(
'title' => get_string('search') . ': ',
'hiddenlabel' => false,
'type' => 'text',
'class' => 'with-dropdown js-with-dropdown',
'defaultvalue' => $query
);
$searchform['elements']['inputgroup']['elements']['submit'] = array(
'type' => 'button',
'usebuttontag' => true,
'class' => 'btn-primary input-group-append',
'value' => get_string('search'),
$filterfield = array(
'title' => get_string('filter') . ': ',
'hiddenlabel' => false,
'type' => 'select',
'class' => 'dropdown-connect js-dropdown-connect',
'options' => array(
'all' => get_string('Everyone', 'group'),
'current' => get_string('Friends', 'group'),
'pending' => get_string('friendrequests', 'group')
),
'defaultvalue' => $filter
);
// Add institution filter, and combine the search query field and the
// institution filter into one combined element via CSS
//Only offer myinstitutions if user is a member
if ($USER->get('institutions')) {
unset($searchform['elements']['inputgroup']['title']);
$searchform['elements']['inputgroup']['class'] = 'dropdown-group js-dropdown-group';
$searchform['elements']['inputgroup']['elements']['query']['title'] .= ': ';
$searchform['elements']['inputgroup']['elements']['query']['hiddenlabel'] = false;
$searchform['elements']['inputgroup']['elements']['query']['class'] = 'with-dropdown js-with-dropdown';
// Move the submit button outside the inputgroup
unset($searchform['elements']['inputgroup']['elements']['submit']);
$searchform['elements']['submit'] = array(
'type' => 'submit',
'class' => 'btn-primary no-label',
'value' => get_string('search')
);
// Insert the filter into the inputgroup, after the query element
$searchform['elements']['inputgroup']['elements']['filter'] = array(
'title' => get_string('filter') . ': ',
'hiddenlabel' => false,
'type' => 'select',
'class' => 'dropdown-connect js-dropdown-connect',
'options' => array(
'all' => get_string('Everyone', 'group'),
'myinstitutions' => get_string('myinstitutions', 'group'),
),
'defaultvalue' => $filter,
unset($filterfield['options']);
$filterfield['options'] = array(
'all' => get_string('Everyone', 'group'),
'myinstitutions' => get_string('myinstitutions', 'group'),
'current' => get_string('Friends', 'group'),
'pending' => get_string('friendrequests', 'group')
);
}
$searchform = pieform($searchform);
$js = <<< EOF
jQuery(function ($) {
p = {$data['pagination_js']}
$('#search_submit').on('click', function (event) {
$('#messages').empty();
var params = {'query': $('#search_query').val(), 'extradata':JSON.stringify({'page':'find'})};
if ($('#search_filter').length) {
params.filter = $('#search_filter').val();
}
p.sendQuery(params);
event.preventDefault();
});
});
EOF;
$elements['searchwithin'] = array(
'type' => 'fieldset',
'class' => 'dropdown-group js-dropdown-group',
'elements' => array(
'query' => $queryfield,
'filter' => $filterfield
)
);
$elements['searchfield'] = array(
'type' => 'submit',
'class' => 'btn-primary no-label',
'value' => get_string('search')
);
$searchform = pieform(array(
'name' => 'search',
'checkdirtychange' => false,
'method' => 'post',
'class' => 'form-inline with-heading',
'elements' => $elements
)
);
$javascript = array('paginator');
if ($admingroups) {
array_push($javascript, 'groupbox');
}
$smarty = smarty($javascript, array(), array('applychanges' => 'mahara', 'nogroups' => 'group'), array('sideblocks' => array(friends_control_sideblock('find'))));
setpageicon($smarty, 'icon-user-plus');
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('results', $data);
$smarty->assign('count', $data['count']);
$smarty->assign('form', $searchform);
$smarty->display('user/find.tpl');
$smarty->display('user/index.tpl');
function search_submit(Pieform $form, $values) {
redirect('/user/find.php' . ((isset($values['query']) && ($values['query'] != '')) ? '?query=' . urlencode($values['query']) : ''));
$querystring = (isset($values['query']) && ($values['query'] != '')) ? '&query=' . urlencode($values['query']) : '';
redirect('/user/index.php?filter=' . urlencode($values['filter']) . $querystring);
}
<?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('MENUITEM', 'engage/myfriends');
require(dirname(dirname(__FILE__)) . '/init.php');
require_once('searchlib.php');
define('TITLE', get_string('myfriends'));
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'user');
define('SECTION_PAGE', 'myfriends');
if (param_variable('acceptfriend_submit', null)) {
acceptfriend_form(param_integer('id'));
}
else if (param_variable('addfriend_submit', null)) {
addfriend_form(param_integer('id'));
}
$filter = param_alpha('filter', 'all');
$offset = param_integer('offset', 0);
$limit = 10;
$data = search_friend($filter, $limit, $offset);
$data['filter'] = $filter;
require_once('group.php');
$admingroups = (bool) group_get_user_admintutor_groups();
build_userlist_html($data, 'myfriends', $admingroups);
$filterform = pieform(array(
'name' => 'filter',
'checkdirtychange' => false,
'renderer' => 'div',
'class' => 'form-inline with-heading',
'elements' => array(
'inputgroup' => array(
'type' => 'fieldset',
'title' => get_string('filter'),
'class' => 'input-group',
'elements' => array(
'filter' => array(
'type' => 'select',
'defaultvalue' => $filter,
'options' => array(
'all' => get_string('allfriends', 'group'),
'current' => get_string('currentfriends', 'group'),
'pending' => get_string('pendingfriends', 'group')
),
),
'submit' => array(
'type' => 'button',
'usebuttontag' => true,
'class' => 'btn-primary input-group-append',
'value' => '<span class="icon icon-filter left" role="presentation" aria-hidden="true"></span> ' . get_string('filter')
)
),
),
)
));
$js = <<< EOF
jQuery(function ($) {
p = {$data['pagination_js']}
$('#filter_submit').on('click', function (event) {
$('#messages').empty();
var params = {'filter': $('#filter_filter').val()};
p.sendQuery(params);
event.preventDefault();
});
});
EOF;
if (!$data['count']) {
if ($filter == 'pending') {
$message = get_string('nobodyawaitsfriendapproval', 'group');
}
else {
$message = get_string('trysearchingforfriends', 'group', '<a href="' . get_config('wwwroot') . 'user/find.php">', '</a>');
}
}
$javascript = array('paginator');
if ($admingroups) {
array_push($javascript, 'groupbox');
}
$smarty = smarty($javascript, array(), array('applychanges' => 'mahara', 'nogroups' => 'group'), array('sideblocks' => array(friends_control_sideblock())));
setpageicon($smarty, 'icon-users');
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('results', $data);
$smarty->assign('form', $filterform);
if (isset($message)) {
$smarty->assign('message', $message);
}
$smarty->display('user/myfriends.tpl');
function filter_submit(Pieform $form, $values) {
redirect('/user/myfriends.php?filter=' . $values['filter']);
}
......@@ -10,7 +10,7 @@
*/
define('INTERNAL', 1);
define('MENUITEM', 'engage/myfriends');
define('MENUITEM', 'engage/people');
define('SECTION_PAGE', 'removefriend');
require(dirname(dirname(__FILE__)) . '/init.php');
......@@ -27,14 +27,11 @@ define('TITLE', get_string('removefromfriends', 'group', display_name($id)));
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
$goto = 'user/index.php?filter=current';
}
$goto .= (strpos($goto,'?') ? '&' : '?') . 'offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
......@@ -99,14 +96,11 @@ function removefriend_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('friendformremovesuccess', 'group', display_name($id)));
$offset = param_integer('offset', 0);
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
$goto = 'user/index.php?filter=current';
break;
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
......
......@@ -10,7 +10,8 @@
*/
define('INTERNAL', 1);
define('MENUITEM', 'engage/findfriends');
define('MENUITEM', 'engage/people');
define('SECTION_PAGE', 'requestfriendship');
require(dirname(dirname(__FILE__)) . '/init.php');
$id = param_integer('id');
......@@ -28,10 +29,10 @@ define('TITLE', get_string('sendfriendshiprequest', 'group', display_name($id)))
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find': $goto = 'user/find.php'; break;
case 'find': $goto = 'user/index.php'; break;
case 'view': $goto = profile_url($user, false); break;
default:
$goto = 'user/myfriends.php';
$goto = 'user/index.php';
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
......@@ -42,7 +43,7 @@ if (is_friend($id, $USER->get('id'))) {
}
else if (get_friend_request($id, $USER->get('id'))) {
$SESSION->add_info_msg(get_string('friendshipalreadyrequestedowner', 'group', display_name($id)));
redirect(get_config('wwwroot') . 'user/myfriends.php?filter=pending');
redirect(get_config('wwwroot') . 'user/index.php?filter=pending');
}
$form = pieform(array(
......
......@@ -48,7 +48,7 @@ $returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find':
$goto = 'user/find.php';
$goto = 'user/index.php';
break;
case 'view':
$goto = profile_url($user, false);
......@@ -62,7 +62,7 @@ switch ($returnto) {
: 'account/activity';
break;
default:
$goto = 'user/myfriends.php';
$goto = 'user/index.php?filter=current';
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
......
......@@ -23,7 +23,7 @@ require_once('group.php');
require_once(get_config('libroot') . 'view.php');
if (param_variable('acceptfriend_submit', null)) {
acceptfriend_form(param_integer('id'));
acceptfriend_form(param_integer('id'), 'modal');
}
else if (param_variable('addfriend_submit', null)) {
addfriend_form(param_integer('id'));
......@@ -325,7 +325,7 @@ if ($remoteusermessage) {
$smarty->assign('message', $record->message);
}
if ($remoteuseracceptform) {
$smarty->assign('acceptform', acceptfriend_form($userid));
$smarty->assign('acceptform', acceptfriend_form($userid, 'modal'));
}
if ($remoteusernewfriendform) {
$smarty->assign('newfriendform', addfriend_form($userid));
......
......@@ -43,8 +43,7 @@ Scenario: Checking menu items are available as a student (Bug 1467368)
# Checking the sub navigation in Engage
When I follow "Engage"
Then I should see "Groups" in the "Engage sub-menu" property
And I should see "My friends" in the "Engage sub-menu" property
And I should see "Find people" in the "Engage sub-menu" property
And I should see "People" in the "Engage sub-menu" property
And I should see "Discussion topics" in the "Engage sub-menu" property
And I should see "Institution membership" in the "Engage sub-menu" property
......
......@@ -19,7 +19,7 @@ Background:
| UserE | Kupuh1pa! | UserE@example.org | Earl | UserE | insttwo | internal | member |
Given I log in as "UserA" with password "Kupuh1pa!"
And I choose "Find people" in "Engage" from main menu
And I choose "People" in "Engage" from main menu
When I click on "Send friend request" in "Bob UserB" row
Then I should see "Send Bob UserB a friendship request"
When I fill in "Would you like to be my friend?" for "Message"
......@@ -43,19 +43,19 @@ Background:
Given I log in as "UserB" with password "Kupuh1pa!"
When I follow "pending friend"
Then I should see "Angela UserA (UserA)"
When I press "Approve request"
When I press "Approve"
Then I should see "Accepted friend request"
And I log out
Given I log in as "UserC" with password "Kupuh1pa!"
When I follow "pending friend"
Then I should see "Angela UserA (UserA)"
When I press "Approve request"
When I press "Approve"
Then I should see "Accepted friend request"
And I log out
Given I log in as "UserD" with password "Kupuh1pa!"
When I follow "pending friend"
Then I should see "Angela UserA (UserA)"
When I press "Approve request"
When I press "Approve"
Then I should see "Accepted friend request"
And I log out
......
@javascript @core @core_messages
Feature: Edit group membership
In order to edit group membership
As an admin I can edit membership via the 'Find people' page
As an admin I can edit membership via the 'People' page
Background:
Given the following "users" exist:
......@@ -46,7 +46,7 @@ Scenario: User view members page, verify user list displayed and sorted by selec
Scenario: Check modal is working for the "Edit group memebership" on find people page (Bug 1513265)
# Log in as "Admin" user
Given I log in as "admin" with password "Kupuh1pa!"
And I choose "Find people" in "Engage" from main menu
And I choose "People" in "Engage" from main menu
And I follow "2" in the "Find people results" property
And I click on "Edit group membership" in "Liam User" row
# allow the modal to open
......
@javascript @core @core_user @core_portfolio @friends
Feature: Searching for users in the "Find people" page
In order to search by name on the "Find people" page
Feature: Searching for users in the "People" page
In order to search by name on the "People" page
So I can befriend them or send them messages
Background:
......@@ -8,7 +8,7 @@ Background:
| name | displayname |
| instone | Institution One |
| insttwo | Institution Two |
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname |role |
| UserA | Kupuh1pa! | UserA@example.org | Angela | User | instone | internal | member |
......@@ -18,7 +18,7 @@ Background:
Scenario: Find users in your institution and outside your institution
# Log in as a user
Given I log in as "UserA" with password "Kupuh1pa!"
And I choose "Find people" in "Engage" from main menu
And I choose "People" in "Engage" from main menu
# Searching within my own institution, I should only find users in my institution
And I select "My institutions" from "Filter"
......@@ -32,7 +32,7 @@ Scenario: Find users in your institution and outside your institution
When I select "Everyone" from "Filter"
And I fill in "Search" with "smith"
And I scroll to the id "main-nav"
And I press "search_submit"