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

Commit

Permalink
Added ability to change privacy settings on an existing item.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Dec 3, 2010
1 parent 4195d89 commit db8c439
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 13 deletions.
3 changes: 2 additions & 1 deletion components/journal/controllers/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private function _Prep ( ) {
$row = new cHTML ();
$row->Load ( $rowOriginal );

$row->Find ( '.title', 0 )->innertext = $this->Model->Get ( "Title" );
$row->Find ( '.title-link', 0 )->innertext = $this->Model->Get ( "Title" );
$row->Find ( '.title-link', 0 )->href = '/profile/' . $this->_Focus->Username . '/journal/' . $url;
$row->Find ( '.body', 0 )->innertext = $this->GetSys ( 'Render' )->Format ( $this->Model->Get ( "Body" ) );

$username = $this->Model->Get ( 'Submitted_Username');
Expand Down
8 changes: 6 additions & 2 deletions components/journal/controllers/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ private function _PrepEdit ( ) {

$this->View->Find ( '.journal', 0 )->action = "/profile/" . $this->_Focus->Username . '/journal/edit/' . $Identifier;

$privacyData = array ( 'start' => $start, 'step' => $step, 'total' => $total, 'link' => $link );
$privacyData = array ( 'Type' => 'journal', 'Identifier' => $Identifier );
$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', $privacyData );
}

$Contexts = $this->View->Find ( '[name=Context]' );
Expand Down Expand Up @@ -149,9 +149,13 @@ public function Save ( ) {
$Body = $this->GetSys ( 'Request' )->Get ( 'Body' );
$Title = $this->GetSys ( 'Request' )->Get ( 'Title' );
$Identifier = $this->GetSys ( 'Request' )->Get ( 'Identifier' );
$Privacy = $this->GetSys ( 'Request' )->Get ( 'Privacy' );

$Identifier = $this->Model->Store ( $this->_Focus->Id, $Identifier, $Title, $Body );

$privacyData = array ( 'Privacy' => $Privacy, 'Type' => 'Journal', 'Identifier' => $Identifier );
$this->GetSys ( 'Components' )->Talk ( 'Privacy', 'Store', $privacyData );

$location = '/profile/' . $this->_Focus->Username . '/journal/' . $this->Model->Get ( 'Identifier' );

$id = $this->Model->Get ( 'Entry_PK' );
Expand Down
1 change: 1 addition & 0 deletions components/journal/models/journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function Store ( $pUserId, $pIdentifier, $pTitle, $pBody ) {

if ( !$pIdentifier ) {
$pIdentifier = $this->CreateUniqueIdentifier();
$this->Set ( 'Created', NOW() );
} else {
$this->Retrieve ( array ( 'Owner_FK' => $pUserId, 'Identifier' => $pIdentifier ) );
if ( $this->Get ( 'Total' ) > 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion components/journal/views/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ul class="journal-entries">
<li class="summary">
<article>
<h2> <span class="title"></span> <abbr class="created"></abbr> </h2>
<h2> <span class="title"><a class="title-link"></a></span> <abbr class="created"></abbr> </h2>
<div class="body"></div>
<nav class="actions">
<a class="comments">0 Comments</a>
Expand Down
30 changes: 28 additions & 2 deletions components/privacy/controllers/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,24 @@ public function __construct ( ) {

public function Display ( $pView = null, $pData = array ( ) ) {

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

$this->_View = $this->GetView ( $pView );

$this->_Prep();
$Type = $pData['Type'];
$Identifier = $pData['Identifier'];

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

$this->_Prep( $Type, $Identifier );

$this->_View->Display();

return ( true );
}

public function _Prep ( ) {
public function _Prep ( $pType = null, $pIdentifier = null ) {

$li = $this->_View->Find ( '.circle', 0 );
$row = $this->_View->Copy ( '.circle', 0 )->Find ( '.circle', 0 );
$rowOriginal = $row->outertext;
Expand All @@ -49,12 +57,30 @@ public function _Prep ( ) {

$circles = $this->Talk ( 'Friends', 'Circles' );

if ( ( $pType ) && ( $pIdentifier ) ) {
$currentPrivacy = $this->_Model->RetrieveItem ( $this->_Focus->Id, $pType, $pIdentifier );
if ( $currentPrivacy->Friends == 1 ) {
$this->_View->Find ( '[name=Privacy[friends]]', 0 )->checked = true;
$this->_View->Find ( '[name=Privacy[nobody]]', 0 )->checked = false;
} else if ( $currentPrivacy->Everybody == 1 ) {
$this->_View->Find ( '[name=Privacy[everybody]]', 0 )->checked = true;
$this->_View->Find ( '[name=Privacy[nobody]]', 0 )->checked = false;
} else if ( count ( $currentPrivacy->Circles ) > 0 ) {
$this->_View->Find ( '[name=Privacy[nobody]]', 0 )->checked = false;
}
}

foreach ( $circles as $c => $circle ) {
$row = new cHTML ();
$row->Load ( $rowOriginal );
$row->Find ( 'label', 0 )->innertext = $circle;
$row->Find ( 'input', 0 )->name = 'Privacy[' . $circle . ']';

// Determine if this circle is selected.
if ( isset ( $currentPrivacy ) and ( in_array ( $c, $currentPrivacy->Circles ) ) ) {
$row->Find ( 'input', 0 )->checked = true;
}

$li->innertext .= $row->outertext;
unset ( $row );

Expand Down
17 changes: 11 additions & 6 deletions components/privacy/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,25 @@ function Store ( $pData ) {
$Identifier = $pData['Identifier'];
$Type = $pData['Type'];

// Nobody was selected, so disregard any other settings.
if ( (bool) $Privacy['nobody'] == true ) return ( true );

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

include_once ( ASD_PATH . 'components/privacy/models/privacy.php' );
$Model = new cPrivacyModel();

// Delete all current privacy settings for this user+type+identifier
$Model->Delete ( array ( 'User_FK' => $this->_Focus->Id, 'Identifier' => $Identifier, 'Type' => $Type ) );

// Nobody was selected, so disregard any other settings.
if ( (bool) $Privacy['nobody'] == true ) {
return ( true );
}

$Everybody = (bool) $Privacy['everybody'];
$Friends = (bool) $Privacy['friends'];

unset ( $Privacy['everybody'] );
unset ( $Privacy['friends'] );

include_once ( ASD_PATH . 'components/privacy/models/privacy.php' );
$Model = new cPrivacyModel();

if ( count ( $Privacy ) > 0 ) {
// One or more circles was selected, so preference them.
$circles = $this->Talk ( 'Friends', 'Circles' );
Expand Down
2 changes: 1 addition & 1 deletion themes/default/style/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
#profile-journal .journal-entries .rss { font-size:80%; float:right; padding:1px 5px; -moz-border-radius:5px; -webkit-border-radius:5px; -moz-box-shadow:0px 0px 2px rgba(0,0,0,0.4); -webkit-box-shadow:0px 0px 2px rgba(0,0,0,0.4); color:rgba(0,0,0,0.9); text-shadow:1px 1px 0px rgba(255,255,255,0.8); border:1px solid rgba(0,0,0,0.5); background:-webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,1)),to(rgba(185,185,185,1))); background:-moz-linear-gradient(top,rgba(255,255,255,1),rgba(185,185,185,1)); }
#profile-journal .journal-entries .rss:hover { text-decoration:none; }

#profile-journal .journal-entries .summary { margin:10px 0; list-style-type:none; float:left; clear:both; width:100%; }
#profile-journal .journal-entries .summary { margin:5px 0; list-style-type:none; float:left; clear:both; width:100%; }
#profile-journal .journal-entries .summary img { float:left; margin: 0px 5px 5px 0; }
#profile-journal .journal-entries .icon { width:64px; height:64px; }
#profile-journal .journal-entries .summary h2 { background-color:#c0d895; padding:3px 5px;}
Expand Down

0 comments on commit db8c439

Please sign in to comment.