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

Commit

Permalink
Adding friend circle filter to newsfeed.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Nov 18, 2010
1 parent f1cd2b2 commit ecb76c5
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 21 deletions.
34 changes: 34 additions & 0 deletions components/friends/friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,40 @@ public function Friends ( $pData = null ) {
return ( $return );
}

public function FriendsInCircle ( $pData = null ) {

$Target = $pData['Target'];
$Circle = $pData['Circle'];

if ( $this->_Source != 'Component' ) return ( false );

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

if ( !$Target ) $Target = $this->_Focus->Id;
if ( !$Circle ) return ( false );

include_once ( ASD_PATH . '/components/friends/models/circles.php');
$this->Circles = new cFriendsCirclesModel();

if ( !$this->Circles->Load ( $this->_Focus->Id, $Circle ) ) {
return ( false );
}

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

$return = array();
$this->_Model->RetrieveFriends ( $Target );
$this->_Model->RetrieveCircle ( $Target, $this->Circles->Get ( 'tID' ) );

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

return ( $return );
}

public function NotifyAdd ( $pData = null ) {
$this->Load ( 'Friends', null, 'NotifyAdd', $pData );

Expand Down
87 changes: 87 additions & 0 deletions components/newsfeed/controllers/menu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* @version $Id$
* @package Appleseed.Components
* @subpackage Newsfeed
* @copyright Copyright (C) 2004 - 2010 Michael Chisari. All rights reserved.
* @link http://opensource.appleseedproject.org
* @license GNU General Public License version 2.0 (See LICENSE.txt)
*/

// Restrict direct access
defined( 'APPLESEED' ) or die( 'Direct Access Denied' );

/** Newsfeed Component Menu Controller
*
* Newsfeed Component Menu Controller Class
*
* @package Appleseed.Components
* @subpackage Newsfeed
*/
class cNewsfeedMenuController extends cController {

/**
* Constructor
*
* @access public
*/
public function __construct ( ) {
parent::__construct( );
}

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

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

if ( $this->_Focus->Account != $this->_Current->Account ) {
$this->GetSys ( "Foundation" )->Redirect ( "common/403.php" );
return ( false );
}

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

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

$this->_Prep();

$this->View->Display();

return ( true );
}

private function _Prep ( ) {
$Circles = $this->Talk ( 'Friends', 'Circles' );

$Current = urldecode ( str_replace ( '-', ' ' , $this->GetSys ( 'Request' )->Get ( 'Circle' ) ) );

if ( !$Current ) $this->View->Find ( '.friends', 0 )->class .= ' selected ';

$this->View->Find ( '.friends .link', 0 )->href = '/profile/' . $this->_Current->Username . '/news/';
$this->View->Find ( '.add', 0 )->href = '/profile/' . $this->_Current->Username . '/friends/circles/add';

if ( !$Circles ) return ( false );

$li = $this->View->Find ( '.list', 0);

$row = $this->View->Copy ( '.list' )->Find ( '.circle', 0 );

$rowOriginal = $row->outertext;

$this->View->Find ( '.circle', 0 )->outertext = '';

foreach ($Circles as $c => $circle ) {
$row = new cHTML ();
$row->Load ( $rowOriginal );
$row->Find ( '.link', 0 )->innertext = $circle;
$row->Find ( '.link', 0 )->href = '/profile/' . $this->_Current->Username . '/news/' . $circle;
if ( $Current == $circle ) $row->Find ( '.item', 0 )->class .= ' selected ';
$li->innertext .= $row->outertext;
unset ( $row );
}

$this->View->Reload();

return ( true );
}
}
6 changes: 5 additions & 1 deletion components/newsfeed/controllers/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public function Display ( $pView = null, $pData = array ( ) ) {

private function _Prep ( ) {

$this->Model->Incoming ( $this->_Focus->Id );
$Circle = urldecode ( str_replace ( '-', ' ' , $this->GetSys ( 'Request' )->Get ( 'Circle' ) ) );

$friendsInCircle = $this->Talk ( 'Friends', 'FriendsInCircle', array ( 'Circle' => $Circle ) );

$this->Model->Incoming ( $this->_Focus->Id, $friendsInCircle );

$li = $this->View->Find ( '.list .item', 0);

Expand Down
7 changes: 6 additions & 1 deletion components/newsfeed/languages/en-US/newsfeed.lang
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ YOU_POSTED_ON_A_PAGE="You posted on %contextowner$s's page."
YOU_ARE_NOW_FRIENDS_WITH="You are now friends with %friend$s."
SOMEONE_IS_NOW_FRIENDS_WITH="%actionowner$s is now friends with %subjectowner$s."

ADD_COMMENT="Comment"
ADD_COMMENT="Comment"

NEWSFEED_FILTER_TITLE="Newsfeed Filter"

ALL_FRIENDS_FILTER="All friends"
ADD_A_CIRCLE="+ New Circle"
8 changes: 6 additions & 2 deletions components/newsfeed/models/incoming.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ public function Queue ( $pOwnerId, $pAction, $pActionOwner, $pActionLink, $pSubj
return ( true );
}

public function Incoming ( $pOwnerId, $pStart = 0, $pStep = 50 ) {
public function Incoming ( $pOwnerId, $pFriends = null, $pStart = 0, $pStep = 50 ) {

$this->Retrieve ( array ( 'Owner_FK' => $pOwnerId ), 'Updated DESC', array ( "start" => $pStart, "step" => $pStep ) );
if ( $pFriends ) {
$this->Retrieve ( array ( 'Owner_FK' => $pOwnerId, 'ActionOwner' => '()' . join ( ',', $pFriends ) ), 'Updated DESC', array ( "start" => $pStart, "step" => $pStep ) );
} else {
$this->Retrieve ( array ( 'Owner_FK' => $pOwnerId ), 'Updated DESC', array ( "start" => $pStart, "step" => $pStep ) );
}

return ( true );
}
Expand Down
14 changes: 14 additions & 0 deletions components/newsfeed/views/menu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<section id="newsfeed-menu">

<h1 class="menu-title">Newsfeed Filter Title</h1>
<p class="menu-message"></p>
<ul class="list">
<li class="item friends"><a class="link">All Friends Filter</a></li>
<li class="item circle"><a class="link"></a></li>
</ul>
<a class='add'>Add A Circle</a>
</section>

4 changes: 2 additions & 2 deletions foundations/default/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ routes[profile/(.*)/page/(.*)]="profile/page.php?Username=$1&Identifier=$2"
routes["profile/([^/]+)/"]="profile/landing.php?Username=$1"

[news]
routes[profile/(.*)/news/(.*)]="profile/news.php?Username=$1&Circle=$2"
routes[profile/(.*)/news]="profile/news.php?Username=$1"

[photos]
Expand Down Expand Up @@ -163,5 +164,4 @@ routes[/api]="/system/interface.php"

[pages]
;Pages route should be last, to catch anything that wasn't already caught.
;routes[(.*)]="/pages/pages.php"

;routes[(.*)]="/pages/pages.php"
16 changes: 1 addition & 15 deletions foundations/default/profile/news.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,7 @@

<div id="appleseed-profile-main" class="grid_16">
<div id="appleseed-profile-info" class="grid_4 alpha">
<div id="profile-photo">
<?php $zApp->Components->Go ( "photos", "profile", "profile" ); ?>
</div>
<div id="profile-contact">
<?php $zApp->Components->Go ( "profile", "contact", "contact" ); ?>
</div>
<div id="profile-summary">
<?php $zApp->Components->Go ( "profile", "summary", "summary" ); ?>
</div>
<div id="profile-invites">
<?php $zApp->Components->Go ( "user", "invites", "invites" ); ?>
</div>
<div id="profile-mutual">
<?php $zApp->Components->Go ( "friends", "mutual", "summary" ); ?>
</div>
<?php $zApp->Components->Go ( "newsfeed", "menu", "menu" ); ?>
</div>
<div id="appleseed-profile-content" class="grid_12 omega">
<?php $zApp->Components->Go ( "page", "share" ); ?>
Expand Down
6 changes: 6 additions & 0 deletions themes/default/style/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@
#profile-newsfeed .list .item.friends .actions { display:none; }
#profile-newsfeed .list .item.friends .content { height:auto; min-height:0; }

#newsfeed-menu { position:relative; top:100px; }
#newsfeed-menu li { list-style-type:none; padding:3px; padding-left:20px; }
#newsfeed-menu li.selected { list-style-type:none; background-color:#c0d895; color:#406300; }
#newsfeed-menu li a { background:none; padding:0; }
#newsfeed-menu .add { background:none; padding:0; float:right; margin-top:20px; font-size:90%; }

/* 404 */
#appleseed-404 { float:left; background-color:#f1fed5; min-height:840px; }
#appleseed-404-menu { height:80px; background-color:#c0d895; border-bottom:1px solid #80af1f; }
Expand Down

0 comments on commit ecb76c5

Please sign in to comment.