Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Added Privacy to loading of journal entries
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Dec 4, 2010
1 parent 5f2227e commit 3f0fc0a
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 14 deletions.
5 changes: 4 additions & 1 deletion components/friends/friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function Circles ( $pData = null ) {
$Requesting = $pData['Requesting'];
$Target = $pData['Target'];

// The All parameter states to return all circles regardless of sharing.
$All = $pData['All'] ? $pData['All'] : false;

$this->_Focus = $this->Talk ( 'User', 'Focus' );
$this->_Current = $this->Talk ( 'User', 'Current' );

Expand All @@ -69,7 +72,7 @@ public function Circles ( $pData = null ) {
} else {
foreach ( $circles as $c => $circle ) {
if ( in_array ( $circle['name'], $circleMembership ) ) {
if ( ( $circle['protected'] ) || ( $circle['shared'] ) ) {
if ( ( $circle['protected'] ) || ( $circle['shared'] ) || ( $All ) ) {
$id = $circle['id'];
$return[$id] = $circle['name'];
}
Expand Down
28 changes: 21 additions & 7 deletions components/journal/controllers/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ public function Display ( $pView = null, $pData = array ( ) ) {

$this->Model = $this->GetModel();

$Entry = urldecode ( $this->GetSys ( 'Request' )->Get ( 'Entry' ) );

if ( !$this->Model->Load ( $this->_Focus->Id, $Entry ) ) {
$this->GetSys ( 'Foundation' )->Redirect ( 'common/404.php' );
return ( false );
}

$Access = $this->Talk ( 'Privacy', 'Check', array ( 'Requesting' => $this->_Current->Account, 'Type' => 'Journal', 'Identifier' => $this->Model->Get ( 'Identifier' ) ) );

if ( ( !$Access ) && ( $this->_Current->Account != $this->_Focus->Account ) ) {
if ( !$this->_Current->Account ) {
$this->GetSys ( 'Session' )->Context ( 'login.login.(\d)+.login' );
$this->GetSys ( 'Session' )->Set ( 'Message', __( 'Login To See This Page' ) );
$this->GetSys ( 'Session' )->Set ( 'Error', true );
$this->GetSys ( 'Foundation' )->Redirect ( 'login/login.php' );
} else {
$this->GetSys ( 'Foundation' )->Redirect ( 'common/denied.php' );
}
return ( false );
}

$this->_Prep ( );

$this->View->Display();
Expand All @@ -47,13 +68,6 @@ public function Display ( $pView = null, $pData = array ( ) ) {

private function _Prep ( ) {

$Entry = urldecode ( $this->GetSys ( 'Request' )->Get ( 'Entry' ) );

if ( !$this->Model->Load ( $this->_Focus->Id, $Entry ) ) {
$this->GetSys ( 'Foundation' )->Redirect ( 'common/404.php' );
return ( false );
}

$this->View->Find ( '.title', 0 )->innertext = $this->Model->Get ( 'Title' );
$this->View->Find ( '.permalink-link', 0 )->href = '/profile/' . $this->_Focus->Username . '/journal/' . $this->Model->Get ( 'Identifier' );
$this->View->Find ( '.permalink-link', 0 )->innertext = 'http://' . ASD_DOMAIN . '/profile/' . $this->_Focus->Username . '/journal/' . $this->Model->Get ( 'Identifier' );
Expand Down
4 changes: 3 additions & 1 deletion components/journal/languages/en-US/journal.lang
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ REMOVE="Delete"

ADD_NEW="New"
RSS_FEED="RSS"
BACK_TO_ENTRIES="← journal entries"
BACK_TO_ENTRIES="← journal entries"

LOGIN_TO_SEE_THIS_PAGE="You must log in to see this page."
63 changes: 62 additions & 1 deletion components/journal/models/journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,70 @@ public function Store ( $pUserId, $pIdentifier, $pTitle, $pBody ) {
}

public function Entries ( $pUserId, $pLimit ) {
eval ( GLOBALS );

$this->Retrieve ( array ( 'Owner_FK' => $pUserId ), 'Created DESC', $pLimit );
// $this->Retrieve ( array ( 'Owner_FK' => $pUserId ), 'Created DESC', $pLimit );

$start = $pLimit['start'] ? $pLimit['start'] : 0;
$limit = $pLimit['limit'] ? $pLimit['limit'] : 10;

// Get a list of circles the current member is a member of.
$Current = $zApp->GetSys ( 'Components' )->Talk ( 'User', 'Current' );
$Focus = $zApp->GetSys ( 'Components' )->Talk ( 'User', 'Focus' );

$Circles = $zApp->GetSys ( 'Components' )->Talk ( 'Friends', 'Circles', array ( 'Requesting' => $Current->Account, 'All' => true ) );
$Friends = $zApp->GetSys ( 'Components' )->Talk ( 'Friends', 'Friends', array ( 'Requesting' => $Current->Account, 'All' => true ) );

$prepared[] = $pUserId;

$this->Privacy = new cModel('PrivacySettings');

if ( $Focus->Account == $Current->Account ) {
// We're looking at our own journal, so return everything.
} elseif ( !$Current->Account ) {
// We're not logged in, so search for Everybody
$criteria = array ( 'User_FK' => $pUserId, 'Everybody' => true );

$this->Privacy->Retrieve ( $criteria );

// No identifiers were found, which means no entries were found.
if ( $this->Privacy->Get ( 'Total' ) == 0 ) return ( false );

while ( $this->Privacy->Fetch() ) {
$Identifiers[] = $this->Privacy->Get ( 'Identifier' );
}
} else {
// We're logged in, so search based on our criteria
$subcriteria['Everybody'] = true;

if ( in_array ( $Current->Account, $Friends ) ) {
$subcriteria['||Friends'] = true;
}

foreach ( $Circles as $c => $circle ) {
$circleList[] = $c;
}
if ( count ( $circleList > 0 ) ) {
$subcriteria['||Circle_FK'] = '()' . implode ( $circleList );
}
$criteria = array ( 'User_FK' => $pUserId, $subcriteria );
$this->Privacy->Retrieve ( $criteria );

// No identifiers were found, which means no entries were found.
if ( $this->Privacy->Get ( 'Total' ) == 0 ) return ( false );

while ( $this->Privacy->Fetch() ) {
$Identifiers[] = $this->Privacy->Get ( 'Identifier' );
}
}

if ( $Focus->Account == $Current->Account ) {
$this->Retrieve ( array ( 'Owner_FK' => $pUserId ), 'Created DESC', $pLimit );
} else {
$this->Retrieve ( array ( 'Owner_FK' => $pUserId, 'Identifier' => '()' . implode ( ',', $Identifiers ) ), 'Created DESC', $pLimit );
}

return ( true );
}

}
3 changes: 1 addition & 2 deletions components/page/controllers/share.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ public function Display ( $pView = null, $pData = array ( ) ) {

$this->View = $this->GetView ( 'share' );

$privacyData = array ( 'start' => $start, 'step' => $step, 'total' => $total, 'link' => $link );
$privacyControls = $this->View->Find ('.privacy');

foreach ( $privacyControls as $c => $control ) {
$control->innertext = $this->GetSys ( 'Components' )->Buffer ( 'privacy', $pageData );
$control->innertext = $this->GetSys ( 'Components' )->Buffer ( 'privacy' );
}

$Contexts = $this->View->Find ( '[name=Context]' );
Expand Down
2 changes: 1 addition & 1 deletion components/privacy/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function Check ( $pData = null ) {

$Identifier = $pData['Identifier'];
$Type = $pData['Type'];
$Circles = $this->Talk ( 'Friends', 'Circles', array ( 'Requesting' => $Requesting ) );
$Circles = $this->Talk ( 'Friends', 'Circles', array ( 'Requesting' => $Requesting, 'All' => true ) );
$Friends = $this->Talk ( 'Friends', 'Friends' );

include_once ( ASD_PATH . 'components/privacy/models/privacy.php' );
Expand Down
6 changes: 5 additions & 1 deletion components/profile/languages/en-US/profile.lang
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ PING_CONTACT_USER="Ping %firstname$s"
[mutual-summary]
SEE_ALL_MUTUAL_FRIENDS="See all"

CLEAR_STATUS=clear
CLEAR_STATUS=clear

[denied]
CONTENT_IS_UNAVAILABLE="This content is unavailable"
PAGE_REQUESTED_CANNOT_BE_DISPLAYED="The page you requested is unavailable. This may be temporary, the link may have expired, or you may not have permission to view this page."

0 comments on commit 3f0fc0a

Please sign in to comment.