Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ COM_CONFIG_AIP_FIELDSET_LABEL="AIP"
COM_CONFIG_SECTIONS_FIELDSET_LABEL="Sections"
COM_CONFIG_DOI_FIELDSET_LABEL="DOI Configuration"
COM_CONFIG_CURATION_FIELDSET_LABEL="Curation"
COM_PUBLICATIONS_CONFIG_ALLOW_PUBLIC_SEARCH="Allow Public Search"
COM_PUBLICATIONS_CONFIG_ALLOW_PUBLIC_SEARCH_DESC="Allow guests to browse and search publications."

COM_PUBLICATIONS_PUBLICATIONS_ADMIN_CONTROLS="Administrative Controls"
COM_PUBLICATIONS_GALLERY="Gallery"
Expand Down
4 changes: 4 additions & 0 deletions core/components/com_publications/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="allow_public_search" type="radio" default="1" label="COM_PUBLICATIONS_CONFIG_ALLOW_PUBLIC_SEARCH" description="COM_PUBLICATIONS_CONFIG_ALLOW_PUBLIC_SEARCH_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="contribute" type="list" default="1" label="COM_PUBLICATIONS_CONFIG_ALLOW_CONTRIB" description="COM_PUBLICATIONS_CONFIG_ALLOW_CONTRIB_DESC">
<option value="0">COM_PUBLICATIONS_NOT_ALLOW</option>
<option value="1">COM_PUBLICATIONS_ALLOW</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,25 @@ public function introTask()
*/
public function browseTask()
{
if (!$this->config->get('allow_public_search', 1) && User::isGuest())
{
$query = Request::getString('QUERY_STRING', '', 'server');

if (Request::getString('tag', '', 'request') || preg_match('/(?:^|[&;])(?:amp;)?tag=/i', $query))
{
throw new Exception(Lang::txt('COM_PUBLICATIONS_SEARCH_LOGIN_REQUIRED'), 410);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

410 Gone tells crawlers this URL is permanently dead, but it's valid for anyone logged in and whenever the option is re-enabled; and a guest gets an error page with no login link. The replacement sends guests to log in with a return URL, like the other guarded paths. (The QUERY_STRING regex above only differs from Request::getString('tag') for an empty ?tag=, which then lands here too.)

}

$return = base64_encode(Request::current(true));

App::redirect(
Route::url('index.php?option=com_users&view=login&return=' . $return, false),
Lang::txt('COM_PUBLICATIONS_SEARCH_LOGIN_REQUIRED'),
'warning'
);
return;
}

// Set the default sort
$default_sort = 'date';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ COM_PUBLICATIONS_NO_RESULTS="No results found"
COM_PUBLICATIONS_RESULTS="Results"
COM_PUBLICATIONS_RESULT="result"
COM_PUBLICATIONS_LOGIN_NOTICE="You must log in before you can proceed."
COM_PUBLICATIONS_SEARCH_LOGIN_REQUIRED="You must log in to browse and search publications."
COM_PUBLICATIONS_PRIVATE_PUB_LOGIN="This is a private publication. You must login to access this page."
COM_PUBLICATIONS_PRIVATE_NO_ACCESS="Sorry, this is a private publication with restricted access."
COM_PUBLICATIONS_BROWSE="Browse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ COM_CONFIG_FILES_FIELDSET_LABEL="Files"
COM_CONFIG_CREATION_FIELDSET_LABEL="New Submissions"
COM_CONFIG_ENTRY_FIELDSET_LABEL="Entries"
COM_CONFIG_IMPORT_FIELDSET_LABEL="Import"
COM_RESOURCES_ALLOW_PUBLIC_SEARCH_LABEL="Allow Public Search"
COM_RESOURCES_ALLOW_PUBLIC_SEARCH_DESC="Allow guests to browse and search resources."

; Filters
COM_RESOURCES_FILTER_CATEGORY="Category"
Expand Down
4 changes: 4 additions & 0 deletions core/components/com_resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

<config>
<fieldset name="basic">
<field name="allow_public_search" type="radio" default="1" label="COM_RESOURCES_ALLOW_PUBLIC_SEARCH_LABEL" description="COM_RESOURCES_ALLOW_PUBLIC_SEARCH_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="defaultpic" type="text" menu="hide" default="/components/com_resources/site/assets/img/resource_thumb.gif" label="COM_RESOURCES_DEFAULTPIC_LABEL" description="COM_RESOURCES_DEFAULTPIC_DESC" />
<field name="tagstool" type="text" menu="hide" default="screenshots,poweredby,bio,credits,citations,sponsoredby,references,publications" label="COM_RESOURCES_TAGSTOOL_LABEL" description="COM_RESOURCES_TAGSTOOL_DESC" />
<field name="tagsothr" type="text" menu="hide" default="bio,credits,citations,sponsoredby,references,publications" label="COM_RESOURCES_TAGSOTHR_LABEL" description="COM_RESOURCES_TAGSOTHR_DESC" />
Expand Down
12 changes: 12 additions & 0 deletions core/components/com_resources/site/controllers/resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ public function displayTask()
*/
public function browseTask()
{
if (!$this->config->get('allow_public_search', 1) && User::isGuest())
{
$return = base64_encode(Request::current(true));

App::redirect(
Route::url('index.php?option=com_users&view=login&return=' . $return, false),
Lang::txt('COM_RESOURCES_SEARCH_LOGIN_REQUIRED'),
'warning'
);
return;
}

// Set the default sort
$default_sort = 'date';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ COM_RESOURCES_PENDING="Pending"
COM_RESOURCES_ALERTNOTAUTH="You are not authorized to view this resource."
COM_RESOURCES_ALERTNOTAUTH_GROUP="You are not authorized to view this resource. You must be logged in and a member of the group &quot;%s&quot;. If you would like to join this group, please see the <a href="%s">group info</a> for instructions. If you are already a member or feel this message is in error, please contact support."
COM_RESOURCES_ALERTLOGIN_REQUIRED="You must login to view this resource."
COM_RESOURCES_SEARCH_LOGIN_REQUIRED="You must log in to browse and search resources."
COM_RESOURCES_SELECT="Select..."
COM_RESOURCES_AUDIO_PODCAST="Audio podcast"
COM_RESOURCES_VIDEO_PODCAST="Video podcast"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

COM_TAGS="Tags"
COM_TAGS_CONFIGURATION="Tags Configuration"
COM_TAGS_ALLOW_PUBLIC_SEARCH_LABEL="Allow Public Search"
COM_TAGS_ALLOW_PUBLIC_SEARCH_DESC="Allow guests to search using multiple tags."
COM_TAGS_NEW="New"
COM_TAGS_RELATIONSHIPS="Relationships"
COM_TAGS_FOCUS_AREAS="Focus Areas"
Expand Down
4 changes: 4 additions & 0 deletions core/components/com_tags/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

<config>
<fieldset name="basic">
<field name="allow_public_search" type="radio" default="1" label="COM_TAGS_ALLOW_PUBLIC_SEARCH_LABEL" description="COM_TAGS_ALLOW_PUBLIC_SEARCH_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="focus_area_01" type="text" menu="hide" default="" label="COM_TAGS_FOCUS_AREA1" description="COM_TAGS_FOCUS_AREA_DESC" />
<field name="focus_area_02" type="text" menu="hide" default="" label="COM_TAGS_FOCUS_AREA2" description="COM_TAGS_FOCUS_AREA_DESC" />
<field name="focus_area_03" type="text" menu="hide" default="" label="COM_TAGS_FOCUS_AREA3" description="COM_TAGS_FOCUS_AREA_DESC" />
Expand Down
12 changes: 12 additions & 0 deletions core/components/com_tags/site/controllers/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ public function viewTask()
$tgs[] = $addtag;
}

if (!$this->config->get('allow_public_search', 1) && count($tgs) > 1 && User::isGuest())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count($tgs) > 1 is the raw exploded list, so /tags/foo, or /tags/foo,foo or ?addtag=Foo bounce a guest for what is really a single tag. The de-duplicated $added after the sanitize loop is the right thing to count. feedTask also needs the same check; it takes the same list and returns the multi-tag results as RSS.

{
$return = base64_encode(Request::current(true));

App::redirect(
Route::url('index.php?option=com_users&view=login&return=' . $return, false),
Lang::txt('COM_TAGS_SEARCH_LOGIN_REQUIRED'),
'warning'
);
return;
}

// Sanitize the tag
$tags = array();
$added = array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ COM_TAGS_TAG_REMOVED="Tag removed"

; Introduction
COM_TAGS_SEARCH="Search"
COM_TAGS_SEARCH_LOGIN_REQUIRED="You must log in to search using multiple tags."
COM_TAGS_SEARCH_TAGS="Search tags"
COM_TAGS_SEARCH_PLACEHOLDER="Keyword or phrase..."
COM_TAGS_TOP_USED="Top Used"
Expand Down