Commit 3ca8f0be authored by Gregor Anzelj's avatar Gregor Anzelj Committed by Robert Lyon

Enhance the Watchlist block (Bug #1516981)

Enhance the "Watched pages" block to configure it so as to
display changes relating to users' friends since their last
login of different time frame (e.g. last week, last month,
last quarter, last year, etc.).

behatnotneeded: Tests will be written later.

Change-Id: I0ed978a5070120e5b32e79d25f99c2bca84feb20
Signed-off-by: default avatarGregor Anzelj <gregor.anzelj@gmail.com>
parent 7eb54c41
function toggle_watchlist_type_class(value, state) {
$j('#instconf_settings_header').toggleClass(value, state);
$j('#instconf_settings_container').toggleClass(value, state);
$j('#instconf_settings_header fieldset').toggleClass(value, state);
$j('#instconf_settings_container fieldset').toggleClass(value, state);
}
$j('#instconf_mode_container input[type="radio"][value="watchlist"]').on('click', function() {
toggle_watchlist_type_class('hidden', true);
});
$j('#instconf_mode_container input[type="radio"][value="follower"]').on('click', function() {
toggle_watchlist_type_class('hidden', false);
});
$j(function() {
if ($j('#instconf_mode_container input[type="radio"]:checked').val() == 'watchlist') {
toggle_watchlist_type_class('hidden', true);
}
});
......@@ -4,6 +4,7 @@
* @package mahara
* @subpackage blocktype-watchlist
* @author Catalyst IT Ltd
* @author Gregor An¸elj <gregor.anzelj@gmail.com>
* @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.
*
......@@ -16,3 +17,25 @@ $string['defaulttitledescription'] = 'A default title will be generated if you l
$string['description'] = 'Display pages on your watchlist';
$string['nopages'] = 'There are no pages on your watchlist.';
$string['itemstoshow'] = 'Items to show';
$string['typetoshow'] = 'Display';
$string['typetoshowdesc'] = 'Select whether to display pages from your watchlist or portfolios your friends created on your dashboard.';
$string['noactivities'] = 'There is nothing to display for the selected time period.';
$string['list.watchlist'] = 'Pages on my watchlist';
$string['list.follower'] = 'Activities of my friends';
$string['additionalfilters'] = 'Additional filters and settings';
$string['filterby'] = 'Filter by time';
$string['filterbydesc'] = 'Select the time period from which you want to display activities.';
$string['filterby.week'] = 'Last week';
$string['filterby.month'] = 'Last month';
$string['filterby.2months'] = 'Last 2 months';
$string['filterby.quarter'] = 'Last 3 months';
$string['filterby.half'] = 'Last 6 months';
$string['filterby.year'] = 'Last year';
$string['filterby.login'] = 'Since last login';
$string['orderby'] = 'Order by';
$string['orderbydesc'] = 'Select to show pages in reverse chronological order or by page owner.';
$string['orderby.activity'] = 'Reverse chronological order';
$string['orderby.owner'] = 'Page owner';
This diff is collapsed.
......@@ -4,6 +4,7 @@
* @package mahara
* @subpackage blocktype-watchlist
* @author Catalyst IT Ltd
* @author Gregor Anelj <gregor.anzelj@gmail.com>
* @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.
*
......@@ -12,5 +13,5 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2011090701;
$config->release = '1.0.1';
$config->version = 2016061400;
$config->release = '1.1.0';
File mode changed from 100644 to 100755
......@@ -4915,3 +4915,26 @@ function clear_all_caches() {
return $result;
}
/*
* Replaces all accented characters with un-accented counterparts.
*
* See: http://stackoverflow.com/questions/3371697/replacing-accented-characters-php
*/
function no_accents($str) {
$accents = array(
'Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A',
'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N',
'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'ss', 'à'=>'a',
'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i',
'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b',
'ÿ'=>'y', 'ă'=>'a', 'Ă'=>'A', 'ș'=>'s', 'Ș'=>'S', 'ț'=>'t', 'Ț'=>'T',
'Ğ'=>'G', 'İ'=>'I', 'Ş'=>'S', 'ğ'=>'g', 'ı'=>'i', 'ş'=>'s', 'ü'=>'u',
'Č'=>'C', 'č'=>'c', 'Ć'=>'c', 'ć'=>'c', 'Đ'=>'dz', 'đ'=>'dz'
);
return strtr($str, $accents);
}
......@@ -1074,7 +1074,7 @@ function get_search_plugins() {
* ),
* );
*/
function search_friend($filter, $limit, $offset) {
function search_friend($filter, $limit = null, $offset = 0) {
global $USER;
$userid = $USER->get('id');
......@@ -1109,12 +1109,17 @@ function search_friend($filter, $limit, $offset) {
array_push($sql, 'SELECT requester AS id, 1 AS status FROM {usr_friend_request} WHERE "owner" = ?
');
}
$data = get_column_sql('SELECT f.id FROM (' . join('UNION ', $sql) . ') f
JOIN {usr} u ON (f.id = u.id AND u.deleted = 0)
ORDER BY status, firstname, lastname, u.id
LIMIT ?
OFFSET ?', array_merge(array_pad($values=array(), count($sql), $userid), array($limit, $offset)));
$sqlstr = 'SELECT f.id FROM (' . join('UNION ', $sql) . ') f
JOIN {usr} u ON (f.id = u.id AND u.deleted = 0)
ORDER BY status, firstname, lastname, u.id';
if ($limit) {
$data = get_column_sql($sqlstr . ' LIMIT ? OFFSET ?',
array_merge(array_pad($values=array(), count($sql), $userid), array($limit, $offset)));
}
else {
$data = get_column_sql($sqlstr,
array_merge(array_pad($values=array(), count($sql), $userid)));
}
foreach ($data as &$result) {
$result = array('id' => $result);
......
......@@ -4190,7 +4190,21 @@ class View {
$where .= join(',', array_map('db_quote', $types)) . ')';
if ($ownedby) {
$where .= ' AND v.' . self::owner_sql($ownedby);
if (is_array($ownedby)) {
// we have an array of owner objects
$ownerwherestr = '(';
foreach ($ownedby as $key => $ownedbyobject) {
if ($key !== 0) {
$ownerwherestr .= ' OR ';
}
$ownerwherestr .= 'v.' . self::owner_sql($ownedbyobject);
}
$ownerwherestr .= ')';
$where .= ' AND ' . $ownerwherestr;
}
else {
$where .= ' AND v.' . self::owner_sql($ownedby);
}
}
if ($copyableby) {
......
{foreach $views as item=view}
<li class="list-group-item">
<h4 class="title list-group-item-heading">
<a href="{$view.fullurl}">
{$view.title}
</a>
</h4>
{if $view.sharedby}
<div class="groupuserdate text-small">
{if $view.group && $loggedin}
<a class="inner-link" href="{group_homepage_url($view.groupdata)}">{$view.sharedby}</a>
{elseif $view.owner && $loggedin}
{if $view.anonymous}
{if $view.staff_or_admin}
{assign var='realauthor' value=$view.sharedby}
{assign var='realauthorlink' value=profile_url($view.user)}
{/if}
{assign var='author' value=get_string('anonymoususer')}
{include file=author.tpl}
{else}
<a class="inner-link" href="{profile_url($view.user)}">{$view.sharedby}</a>
{/if}
{else}
{$view.sharedby}
{/if}
<span class="postedon text-midtone">
- {str tag=Updated} {$view.mtime|strtotime|format_date:'strftimedatetime'}
</span>
</div>
{/if}
</li>
{/foreach}
{foreach $views as item=owner}
<li class="list-group-item">
<h4 class="title list-group-item-heading">
<span class="icon icon-user"></span>
<b>{$owner[0].sharedby}</b>
</h4>
</li>
{foreach $owner as item=view}
<li class="list-group-item">
<a href="{$view.fullurl}" class=" outer-link watchlist-showview">
<span class="sr-only">{$view.title}</span>
</a>
<h4 class="title list-group-item-heading">
{$view.title}
</h4>
{if $view.sharedby}
<div class="groupuserdate text-small">
{if $view.group && $loggedin}
<a class="inner-link" href="{group_homepage_url($view.groupdata)}">{$view.sharedby}</a>
{elseif $view.owner && $loggedin}
{if $view.anonymous}
{if $view.staff_or_admin}
{assign var='realauthor' value=$view.sharedby}
{assign var='realauthorlink' value=profile_url($view.user)}
{/if}
{assign var='author' value=get_string('anonymoususer')}
{include file=author.tpl}
{else}
<a class="inner-link" href="{profile_url($view.user)}">{$view.sharedby}</a>
{/if}
{else}
{$view.sharedby}
{/if}
<span class="postedon text-midtone">
- {str tag=Updated} {$view.mtime|strtotime|format_date:'strftimedatetime'}
</span>
</div>
{/if}
</li>
{/foreach}
{/foreach}
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