Commit 6652660f authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1499150: Allow anonymous author link to work via ajax"

parents 83c4fcab fd621d41
......@@ -73,7 +73,7 @@ if ($group->public) {
$headers[] = '<link rel="alternate" type="application/atom+xml" href="' . $feedlink . '">';
}
$javascript = array('paginator', 'author');
$javascript = array('paginator');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
......
......@@ -31,7 +31,7 @@ if ($USER->is_logged_in()) {
require_once(get_config('libroot') . 'view.php');
$view = $USER->get_view_by_type('dashboard');
$javascript = array('paginator', 'author');
$javascript = array('paginator');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
......
/**
* Javascript for the hidden author template
*
* @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.
*/
addLoadEvent(function () {
function callbackHandler(i) {
return function(e) {
e.stop();
addElementClass('hidden_author_' + i, 'js-safe-hidden');
addElementClass('hidden_author_' + i, 'hidden');
removeElementClass('real_author_' + i, 'js-safe-hidden');
removeElementClass('real_author_' + i, 'hidden');
}
};
index = 1;
while ($('show_real_author_' + index)) {
connect('show_real_author_' + index, 'onclick', callbackHandler(index));
index += 1;
}
});
{*
I wanted to put author_link_index in templates/author.tpl, but its
state is non-persistent. So until Dwoo gets smarter...
*}
{assign var='author_link_index' value=1}
{foreach from=$items item=view}
<li class="list-group-item">
<a href="{$view.fullurl}" class="outer-link">
......@@ -23,10 +18,7 @@
{assign var='realauthorlink' value=profile_url($view.user)}
{/if}
{assign var='author' value=get_string('anonymoususer')}
{include file=author.tpl}
{if $view.staff_or_admin}
{assign var='author_link_index' value=`$author_link_index+1`}
{/if},
{include file=author.tpl},
{else}
<a href="{profile_url($view.user)}" class="text-success text-small">
{$view.sharedby}
......
{if $views}
<div class="list-group">
{*
I wanted to put author_link_index in templates/author.tpl, but its
state is non-persistent. So until Dwoo gets smarter...
*}
{assign var='author_link_index' value=1}
{foreach from=$views item=view}
<div class="list-group-item">
<h4 class="list-group-item-heading text-inline">
......@@ -28,10 +22,6 @@
{assign var='author' value=get_string('anonymoususer')}
{include file=author.tpl}
{if $view.staff_or_admin}
{assign var='author_link_index' value=`$author_link_index+1`}
{/if}
{else}
<a href="{profile_url($view.user)}" class="text-link">
{$view.sharedby}
......
......@@ -4,11 +4,6 @@
</div>
{else}
<ul id="watchlistblock" class="viewlist list-group">
{*
I wanted to put author_link_index in templates/author.tpl, but its
state is non-persistent. So until Dwoo gets smarter...
*}
{assign var='author_link_index' value=1}
{foreach $views as item=view}
<li class="{cycle values='r0,r1'} list-group-item">
<h4 class="title list-group-item-heading">
......@@ -28,9 +23,6 @@
{/if}
{assign var='author' value=get_string('anonymoususer')}
{include file=author.tpl}
{if $view->staff_or_admin}
{assign var='author_link_index' value=$author_link_index+1}
{/if}
{else}
<a class="text-link" href="{profile_url($view->user)}">{$view->sharedby}</a>
{/if}
......
{if $realauthor}
<span id="hidden_author_{$author_link_index}">
<a id="show_real_author_{$author_link_index}" class="show_real_author" href="">{$author|safe}</a>
{assign var='indexhash' value=get_random_key()}
<span>
<a id="showauthor_{$indexhash}" href="">{$author|safe}</a>
</span>
<span id="real_author_{$author_link_index}" class="js-safe-hidden hidden">
<span class="real_author js-safe-hidden hidden">
{if $realauthorlink}
<a href="{$realauthorlink}">{$realauthor|safe}</a>
{else}
{$realauthor|safe}
{/if}
</span>
<script type="application/javascript">
jQuery('#showauthor_{$indexhash}').on('click', function(e) {
e.preventDefault();
jQuery(this).parent().parent().find('span.real_author').removeClass('hidden js-safe-hidden');
jQuery(this).parent().addClass('hidden js-safe-hidden');
});
</script>
{else}
{$author|safe}
{/if}
......@@ -78,7 +78,6 @@
</div>
<div class="pbxl with-heading text-small">
{assign var='author_link_index' value=1}
{include file=author.tpl}
{if $tags}
......
......@@ -191,7 +191,7 @@ function releaseview_submit() {
redirect($view->get_url());
}
$javascript = array('paginator', 'viewmenu', 'author', 'js/collection-navigation.js');
$javascript = array('paginator', 'viewmenu', 'js/collection-navigation.js');
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
......
@javascript @core @core_view @core_portfolio
Feature: The Anonymised pages option
In order to be able to see the (Author's name hidden) link
Background:
Given the following "users" exist:
| username | password | email | firstname | lastname | institution | authname | role |
| userA | Password1 | test01@example.com | Pete | Mc | mahara | internal | member |
| userB | Password1 | test02@example.com | Son | Nguyen | mahara | internal | member |
And the following "pages" exist:
| title | description| ownertype | ownername |
| Page 1 | page P1 | user | userA |
Scenario: Testing that views & collections are collated properly
# Turn on anonymous pages
Given I log in as "admin" with password "Password1"
And I go to "admin/site/options.php"
And I follow "General settings"
And I set the following fields to these values:
| Allow anonymous pages | 1 |
And I press "Update site options"
And I log out
# Make page anonymous
Given I log in as "userA" with password "Password1"
And I choose "Pages" in "Portfolio"
And I follow "Page 1"
And I follow "Edit this page"
And I follow "Edit title and description"
And I set the following fields to these values:
| Anonymise | 1 |
And I press "Save"
And I follow "Share page"
And I select "Registered users" from "accesslist[0][searchtype]"
And I press "Save"
And I log out
Given I log in as "userB" with password "Password1"
And I am on homepage
Then I should see "(Author's name hidden)"
And I log out
Given I log in as "admin" with password "Password1"
And I am on homepage
Then should see "(Author's name hidden)"
And I follow "(Author's name hidden)"
Then I should see "userA"
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