Skip to content

Commit

Permalink
changes related to password protection for private files
Browse files Browse the repository at this point in the history
  • Loading branch information
cisvarun committed Mar 15, 2016
1 parent 03bbc4d commit ff3e5d8
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/install/protected_pages.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ others:
protected_pages_password_label: 'Enter Password'
protected_pages_submit_button_text: 'Authenticate'
protected_pages_incorrect_password_msg: 'Incorrect password!'
langcode: en
langcode: en
2 changes: 1 addition & 1 deletion protected_pages.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ type: module
description: 'Allow you to protect pages by secure password.'
configure: protected_pages_settings
package: 'Access'
core: 8.x
core: 8.x
2 changes: 1 addition & 1 deletion protected_pages.install
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ function protected_pages_install() {
Visit the <a href="@permissions">permissions</a> for your site.',
[
'@permissions' => Url::fromUri('internal:/admin/people/permissions', array('fragment' => 'module-protected_pages'))
->toString()
->toString(),
]), 'status');
}
2 changes: 1 addition & 1 deletion protected_pages.links.action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ protected_pages_add:
route_name: protected_pages_add
title: 'Add Protected Page'
appears_on:
- protected_pages_list
- protected_pages_list
1 change: 1 addition & 0 deletions protected_pages.links.menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ protected_pages.list_pages:
route_name: protected_pages_list
parent: system.admin_config_system
description: 'Configure protected pages setting.'

2 changes: 1 addition & 1 deletion protected_pages.links.task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ protected_pages_list:
protected_pages_settings:
title: Settings
route_name: protected_pages_settings
base_route: protected_pages_list
base_route: protected_pages_list
4 changes: 2 additions & 2 deletions protected_pages.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
* Admin (uid = 1) or user with bypass protection permission can view page.
*/

use Drupal\Component\Utility\Html;
use Drupal\protected_pages\ProtectedPagesStorage;
use Symfony\Component\HttpFoundation\RedirectResponse;
Expand Down Expand Up @@ -48,7 +49,6 @@ function protected_pages_file_download($uri) {
}

$target = file_uri_target($uri);
//echo $target;exit;
$file_path = '/system/files/' . $target;

$fields = array('pid');
Expand All @@ -58,7 +58,7 @@ function protected_pages_file_download($uri) {
'value' => $file_path,
'operator' => '=',
);

$pid = ProtectedPagesStorage::load($fields, $conditions, TRUE);

if (isset($_SESSION['_protected_page']['passwords'][$pid]['expire_time'])) {
Expand Down
2 changes: 1 addition & 1 deletion protected_pages.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ services:
protected_pages.check_protected_page:
class: Drupal\protected_pages\EventSubscriber\ProtectedPagesSubscriber
tags:
- {name: event_subscriber}
- {name: event_subscriber}
2 changes: 1 addition & 1 deletion src/Controller/ProtectedPagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function protectedPagesList() {
'#empty' => t('No records available.'),
);
$content['pager'] = array('#type' => 'pager');

// Don't cache this page.
$content['#cache']['max-age'] = 0;

Expand Down
1 change: 0 additions & 1 deletion src/Form/ProtectedPagesEditForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU
$conditions['general'][] = array(
'field' => 'pid',
'value' => $pid,
'=',
'operator' => '=',
);

Expand Down
3 changes: 1 addition & 2 deletions src/Form/ProtectedPagesSendEmailForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU
'#title' => $this->t('Send email'),
'#description' => $this->t('You send details of this protected page by email to multiple users. Please click <a href="@here">here</a> to configure email settings.', [
'@here' => Url::fromUri('internal:/admin/config/system/protected_pages/settings', array('query' => $this->getDestinationArray()))
->toString()
->toString(),
]),
'#open' => TRUE,
);
Expand Down Expand Up @@ -144,7 +144,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$conditions['general'][] = array(
'field' => 'pid',
'value' => $form_state->get('pid'),
'=',
'operator' => '=',
);

Expand Down
7 changes: 3 additions & 4 deletions src/ProtectedPagesStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function load($fields = array(), $query_conditions = array(), $get

return $result;
}

/**
* Fetches all protected pages records from database.
*/
Expand All @@ -128,10 +128,9 @@ public static function loadAllPages() {
->limit(20)
->execute()
->fetchAll();



return $results;

}

}

0 comments on commit ff3e5d8

Please sign in to comment.