Commit b4afd747 authored by Doris Tam's avatar Doris Tam Committed by Robert Lyon
Browse files

Bug 1530050: Grouping portfolio pages as well as display single pages

Change-Id: I644095019bd73eb330865e6e843100854506f04f
parent 673bc1bb
......@@ -299,6 +299,7 @@ $string['backtofriendslist'] = 'Back to friends list';
$string['findnewfriends'] = 'Find new friends';
$string['Collections'] = 'Collections';
$string['Views'] = 'Pages';
$string['Portfolios'] = 'Portfilios';
$string['Viewscollections'] = 'Pages and collections';
$string['Files'] = 'Files';
$string['noviewstosee'] = 'None that you can see';
......
......@@ -473,6 +473,7 @@ $string['mostcomments1'] = 'Most comments';
$string['dashboard'] = 'Dashboard';
$string['Profile'] = 'Profile';
$string['Portfolio'] = 'Portfolio';
$string['Portfolios'] = 'Portfilios';
$string['Grouphomepage'] = 'Group homepage';
$string['grouphomepagedescription'] = 'The group homepage contains the content that appears on the "About" tab for this group';
......
......@@ -2039,29 +2039,57 @@ function get_users_data($userids, $getviews=true) {
}
if (!$data || !$getviews || !$views = get_views(array_keys($data), null, null)) {
$views = array();
$views = array();
}
if ($getviews) {
$viewcount = array_map('count', $views);
// since php is so special and inconsistent, we can't use array_map for this because it breaks the top level indexes.
$cleanviews = array();
foreach ($views as $userindex => $viewarray) {
$cleanviews[$userindex] = array_slice($viewarray, 0, 5);
// Don't reveal any more about the view than necessary
foreach ($cleanviews as $userviews) {
foreach ($userviews as &$view) {
foreach (array_keys(get_object_vars($view)) as $key) {
if ($key != 'id' && $key != 'title' && $key != 'url' && $key != 'fullurl') {
unset($view->$key);
foreach ($views as $userindex => $view) {
$collectionobject = null;
foreach ($view as $viewid => $vdata) {
//pages in a collection
if (!empty($vdata->collection)) {
if (!$collectionobject) {
$collectionobject = $vdata->collection;
$cleanviews[$userindex][] = $vdata;
}
else {
if ($collectionobject != $vdata->collection && isset($collectionobject)) {
$collectionobject = $vdata->collection;
$cleanviews[$userindex][] = $vdata;
}
}
}
}
// pages not in a collection, separating the loop to display collections first, then single pages
foreach ($view as $viewid => $vdata) {
if (empty($vdata->collection)) {
$cleanviews[$userindex][] = $vdata;
}
}
// $cleanviews[$userindex] = array_slice($cleanviews[$userindex], 0, 10); // if we want to limit output
}
}
// Don't reveal any more about the view than necessary
foreach ($cleanviews as $userviews) {
foreach ($userviews as &$view) {
foreach (array_keys(get_object_vars($view)) as $key) {
if (!empty($view->collection)) {
if ($key == 'title') {
$view->$key = $view->collection->get('name');
}
}
if ($key != 'id' && $key != 'title' && $key != 'url' && $key != 'fullurl') {
// pages in a collection should appear with collection name as title
unset($view->$key);
}
}
}
}
}
foreach ($data as $friend) {
if ($getviews && isset($cleanviews[$friend->id])) {
$friend->views = $cleanviews[$friend->id];
......@@ -2086,7 +2114,7 @@ function get_users_data($userids, $getviews=true) {
function build_userlist_html(&$data, $searchtype, $admingroups, $filter='', $query='') {
if ($data['data']) {
$userlist = array_map(function($u) { return (int)$u['id']; }, $data['data']);
$userdata = get_users_data($userlist, $searchtype == 'myfriends');
$userdata = get_users_data($userlist, $filter != 'pending');
}
$smarty = smarty_core();
$smarty->assign('data', isset($userdata) ? $userdata : null);
......@@ -2101,7 +2129,6 @@ function build_userlist_html(&$data, $searchtype, $admingroups, $filter='', $que
if (isset($data['filter'])) {
$params['filter'] = $data['filter'];
}
if ($searchtype == 'myfriends') {
$resultcounttextsingular = get_string('friend', 'group');
$resultcounttextplural = get_string('friends', 'group');
......
<div class="list-group-item {if $user->pending} list-group-item-warning{/if}">
<a href="{profile_url($user)}" class="outer-link">
<span class="sr-only">{$user->display_name}</span>
</a>
<div class="row" id="friendinfo_{$user->id}">
<div class="col-md-8">
<div class="usericon-heading">
......@@ -9,7 +6,10 @@
<img src="{profile_icon_url user=$user maxwidth=40 maxheight=40}" alt="{str tag=profileimagetext arg1=$user|display_default_name}">
</div>
<h4 class="list-group-item-heading middle">
{$user->display_name}
<a href="{profile_url($user)}" >
<span class="sr-only">{$user->display_name}</span>
{$user->display_name}
</a>
{if $user->pending}
<span class="pendingfriend text-small text-midtone">
- {str tag='pendingsince' section='group' arg1=$user->pending_time}
......@@ -19,6 +19,18 @@
- {str tag='existingfriend' section='group'}
</span>
{/if}
{if $user->friend && $user->views}
<p class="viewlist">
<strong>
{str tag='Portfolios' section='view'}:
</strong>
{foreach from=$user->views item=view name=addr}
<a href="{$view->fullurl}">{$view->title}</a>{if !$dwoo.foreach.addr.last}, {/if}
{/foreach}
</p>
{/if}
</h4>
{if $user->institutions}
<div class="memberof detail text-small">
......
@javascript @core
Feature: Go to People page
As a user
I want to see a list of my friends and pending requests and their portfolio if they exist
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| UserA | Kupuh1pa!| userA@example.org | Anglela | Ava | mahara | internal | member|
| UserB | Kupuh1pa!| userB@example.org | Benjamin | Bobby | mahara | internal | member|
And the following "pages" exist:
| title | description | ownertype | ownername |
| PageA | Page A desc | user | UserA |
| PageB | Page B desc | user | UserB |
| PageA single | Page A s desc | user | UserA |
| PageB single | Page B s desc | user | UserB |
And the following "collections" exist:
| title | description | ownertype | ownername | pages |
| CollectionA | Angela's Collection | user | UserA |PageA |
| CollectionB | Benjamin's Collections | user | UserB |PageB |
Scenario: Create friends and portfolios for each to see portfolios on People page
# Log in as a UserA and create portfolio and set sharing access to friends
Given I log in as "UserA" with password "Kupuh1pa!"
When I choose "Pages and collections" in "Create" from main menu
And I click on "Manage access" in "CollectionA" card access menu
And I select "friends" from "General" in shared with select2 box
And I press "Save"
Then I choose "Pages and collections" in "Create" from main menu
And I click on "Manage access" in "PageA single" card access menu
And I select "friends" from "General" in shared with select2 box
And I press "Save"
# Let UserA add UserB as a friend
Then I choose "People" in "Engage" from main menu
And I click on "Send friend request" in "Benjamin Bobby" row
And I set the field "Message" to "Love me, love me, say you do!"
And I press "Request friendship"
And I log out
# Log in as UserB, accept UserA's friend request
Then I log in as "UserB" with password "Kupuh1pa!"
And I follow "pending friend"
And I click on "Approve"
# Change sharing permissions
When I choose "Pages and collections" in "Create" from main menu
And I click on "Manage access" in "CollectionB" card access menu
And I select "friends" from "General" in shared with select2 box
And I press "Save"
Then I choose "Pages and collections" in "Create" from main menu
And I click on "Manage access" in "PageB single" card access menu
And I select "friends" from "General" in shared with select2 box
Then I press "Save"
# UserB should now be able to see UserA's Portfolio on the People page
When I choose "People" in "Engage" from main menu
And I select "Friends" from "filter"
Then I should see "CollectionA, PageA single"
Then I log out
# Log in as UserA (who is now friends with UserB), to see UserB's Portfolio on the People page
Given I log in as "UserA" with password "Kupuh1pa!"
And I choose "People" in "Engage" from main menu
And I select "Friends" from "filter"
And I press "Search"
Then I should see "CollectionB, PageB single"
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