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 mark a friends circle as Private, Protected or Shared.
Browse files Browse the repository at this point in the history
Added private/protected/shared retrieval to Circles function of Interface class.
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Oct 20, 2010
1 parent 17b53ba commit cb47c6f
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 11 deletions.
12 changes: 12 additions & 0 deletions components/friends/controllers/circles.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ public function Edit ( $pView = null, $pData = array ( ) ) {

$this->_Prep();

$Private = $this->Circles->Get ( "Private" );
$Protected = $this->Circles->Get ( "Protected" );
$Shared = $this->Circles->Get ( "Shared" );

if ( $Protected ) {
$this->View->Find ( '#sharing-protected', 0 )->checked = "checked";
} else if ( $Shared ) {
$this->View->Find ( '#sharing-shared', 0 )->checked = "checked";
} else {
$this->View->Find ( '#sharing-private', 0 )->checked = "checked";
}

$this->View->Display();

return ( true );
Expand Down
38 changes: 35 additions & 3 deletions components/friends/friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,43 @@ public function Circles ( $pData = null ) {
$return = array();
$circles = $this->_Model->Circles ( $this->_Focus->Id );

foreach ( $circles as $c => $circle ) {
$id = $circle['id'];
$return[$id] = $circle['name'];
$circleMembership = $this->_Model->CirclesByMember ( $this->_Focus->Id, $this->_Current->Account );

if ( $this->_Focus->Account == $this->_Current->Account ) {
foreach ( $circles as $c => $circle ) {
$id = $circle['id'];
$return[$id] = $circle['name'];
}
} else {
foreach ( $circles as $c => $circle ) {
if ( in_array ( $circle['name'], $circleMembership ) ) {
if ( ( $circle['protected'] ) || ( $circle['shared'] ) ) {
$id = $circle['id'];
$return[$id] = $circle['name'];
}
}
}
}

return ( $return );
}

public function Friends ( $pData = null ) {

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

include_once ( ASD_PATH . '/components/friends/models/friends.php');
$this->_Model = new cFriendsModel();

$return = array();
$this->_Model->RetrieveFriends ( $this->_Focus->Id );

while ( $this->_Model->Fetch() ) {
$return[] = $this->_Model->Get ( 'Username' ) . '@' . $this->_Model->Get ( 'Domain' );
}

return ( $return );

}
}
4 changes: 4 additions & 0 deletions components/friends/languages/en-US/friends.lang
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ MUTUAL_TITLE="%fullname$s's Mutual Friends"
ADD_TO_CIRCLE="Add Circle ↓"
REMOVE_FROM_CIRCLE="Remove Circle ↓"

PRIVATE_CIRCLE_LABEL="Private"
PROTECTED_CIRCLE_LABEL="Protected"
SHARED_CIRCLE_LABEL="Shared"

NUMBER_OF_FRIENDS="%count$s Friends"
NUMBER_OF_MUTUAL_FRIENDS="%count$s Mutual Friends"
NUMBER_OF_FRIEND_REQUESTS="%count$s Requests"
Expand Down
22 changes: 16 additions & 6 deletions components/friends/models/circles.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public function SaveCircle ( $pCircle, $pUserId, $pId = null ) {

$this->Protect( "tID" );

$Sharing = $this->GetSys ( "Request" )->Get ( "Sharing" );

$this->Set ( 'Private', (int)false );
$this->Set ( 'Protected', (int)false );
$this->Set ( 'Shared', (int)false );

if ( $Sharing == 'protected' ) {
$this->Set ( 'Protected', (int)true );
} else if ( $Sharing == 'shared' ) {
$this->Set ( 'Shared', (int)true );
} else {
$this->Set ( 'Private', (int)true );
}

$this->Set ( "userAuth_uID", $pUserId );
$this->Set ( "Name", $pCircle );

Expand All @@ -70,7 +84,7 @@ public function Circles ( $pUserId ) {
$this->Retrieve ( array ( "userAuth_uID" => $pUserId ), 'sID ASC' );

while ( $this->Fetch() ) {
$return[] = array ( "id" => $this->Get ( "tID" ), "name" => $this->Get ( "Name" ) );
$return[] = array ( 'id' => $this->Get ( 'tID' ), 'name' => $this->Get ( 'Name' ), 'private' => $this->Get ( 'Private' ), 'protected' => $this->Get ( 'Protected' ), 'shared' => $this->Get ( 'Shared' ) );
}

return ( $return );
Expand All @@ -89,7 +103,7 @@ public function CirclesByMember ( $pUserId, $pFriend ) {
list ( $username, $domain ) = explode ( '@', $pFriend );

// Get the friend id
$this->Friend = new cModel ( "friendInformation" );
$this->Friend = new cModel ( 'friendInformation' );
$this->Friend->Structure();
$this->Friend->Retrieve ( array ( "userAuth_uID" => $pUserId, "Username" => $username, "Domain" => $domain ) );
$this->Friend->Fetch();
Expand All @@ -106,10 +120,6 @@ public function CirclesByMember ( $pUserId, $pFriend ) {
}

return ( $return );

$return = array ();

return ( $return );
}

public function SaveFriendToCircle ( $pUserId, $pFriend, $pCircle ) {
Expand Down
8 changes: 6 additions & 2 deletions components/friends/views/circles.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
<input type="hidden" name="Original" value="" />
<input type="hidden" name="tID" value="" />
<fieldset>
<div><label>Name Field Label</label><input name="Name" class="required" maxlength="20" /></div>
</legend>
<div>
<label>Name Field Label</label><input name="Name" class="required" maxlength="20" /></div>
<label>Sharing</label>
<input type="radio" name="Sharing" id="sharing-private" value="private" /><label class="radio" for="radio3">Private Circle Label</label>
<input type="radio" name="Sharing" id="sharing-protected" value="protected" /><label class="radio" for="radio3">Protected Circle Label</label>
<input type="radio" name="Sharing" id="sharing-shared" value="shared" /><label class="radio" for="radio3">Shared Circle Label</label>
<p>
<input type="submit" name="Task" value="Save" />
Expand Down

0 comments on commit cb47c6f

Please sign in to comment.