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

Commit

Permalink
Added functionality to detect if user input exists, and select privac…
Browse files Browse the repository at this point in the history
…y accordingly.
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Feb 19, 2011
1 parent f9848b8 commit 0a9a465
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion components/privacy/controllers/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,37 @@ public function _Prep ( $pType = null, $pIdentifier = null ) {
$li->innertext = '';

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

$inputPrivacy = $this->GetSys ( 'Request' )->Get ( 'Privacy' );

if ( ( $pType ) && ( $pIdentifier ) ) {
if ( $inputPrivacy ) {
// Use REQUEST instead of the current or default.
$currentPrivacy = new stdClass();
$currentPrivacy->Circles = array ();

$nobody = $inputPrivacy['nobody'];
$friends = $inputPrivacy['friends'];
$everybody = $inputPrivacy['everybody'];
if ( $friends == 'on' ) {
$this->_View->Find ( '[name=Privacy[friends]]', 0 )->checked = true;
$this->_View->Find ( '[name=Privacy[nobody]]', 0 )->checked = false;
} else if ( $everybody == 'on' ) {
$this->_View->Find ( '[name=Privacy[everybody]]', 0 )->checked = true;
$this->_View->Find ( '[name=Privacy[nobody]]', 0 )->checked = false;
} else if ( $nobody == 'on' ) {
} else {
$this->_View->Find ( '[name=Privacy[nobody]]', 0 )->checked = false;
$circleKeys = array_flip ( $circles );
foreach ( $inputPrivacy as $i => $input ) {
$selected[] = strtolower ( $i );
}
foreach ( $circleKeys as $circle => $id ) {
if ( in_array ( strtolower ( $circle ), $selected ) ) {
$currentPrivacy->Circles[] = $id;
}
}
}
} else 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;
Expand Down

0 comments on commit 0a9a465

Please sign in to comment.