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

Commit

Permalink
Added Remove functionality, fixed Clear Status functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Oct 20, 2010
1 parent cb47c6f commit e8607d8
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 10 deletions.
35 changes: 34 additions & 1 deletion components/page/controllers/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ public function Display ( $pView = null, $pData = array ( ) ) {
$this->_Focus = $this->Talk ( 'User', 'Focus' );
$this->_Current = $this->Talk ( 'User', 'Current' );

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

if ( !$this->_Current ) {
$this->View->Find ( '.post', 0 )->outertext = '';
$this->_Prep();
} else if ( $this->_Current->Account == $this->_Focus->Account ) {
$this->_Prep();
} else if ( !in_array ( $this->_Current->Account, $friends ) ) {
$this->View->Find ( '.post', 0 )->outertext = '';
$this->_Prep();
} else {
$this->_Prep();
}
Expand Down Expand Up @@ -83,6 +90,11 @@ private function _Prep ( ) {
$data = array ( 'username' => $username, 'domain' => $domain, 'width' => 64, 'height' => 64 );
$row->Find ( '.owner-icon', 0 )->src = $this->GetSys ( 'Event' )->Trigger ( 'On', 'User', 'Icon', $data );

$row->Find ( '[name=Context]', 0 )->value = $this->Get ( 'Context' );
$row->Find ( '[name=Identifier]', 0 )->value = $this->Model->Get ( 'Identifier' );

$row->Find ( '.delete', 0 )->action = $this->GetSys ( "Router" )->Get ( "Base" );

$li->innertext .= $row->outertext;
unset ( $row );
}
Expand Down Expand Up @@ -113,7 +125,7 @@ public function Share ( $pView = null, $pData = array ( ) ) {

$this->Model->Post ( $Content, $Privacy, $this->_Focus->Id, $Owner, $Current );

$redirect = '/profile/' . $this->_Focus->Username . '/page/';
$redirect = $this->GetSys ( "Router" )->Get ( "Base" );
header ( 'Location:' . $redirect );
exit;
}
Expand All @@ -127,4 +139,25 @@ public function _CheckEditor () {
return ( false );
}

public function Remove ( $pData = null ) {

if ( !$this->_CheckEditor () ) {
$this->GetSys ( 'Foundation' )->Redirect ( 'common/403.php' );
return ( false );
}

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

$Identifier = $this->GetSys ( 'Request' )->Get ( 'Identifier' );
$UserId = $this->_Focus->Id;

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

$this->Model->Remove ( $Identifier, $this->_Focus->Id );

$redirect = $this->GetSys ( "Router" )->Get ( "Base" );
header ( 'Location:' . $redirect );
exit;
}

}
17 changes: 10 additions & 7 deletions components/page/models/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ public function ClearCurrent ( $pUserId ) {

return ( true );

$criteria = array ( 'User_FK' => $pUserId, 'Current' => 1 );
$this->Retrieve ( $criteria );

if ( $this->Get ( 'Total' ) == 0 ) return ( true );
}

function Remove ( $pIdentifier, $pUserId ) {

$this->Fetch();
$this->Set ( 'Current', 0 );
// Remove the Page Post
// Note: Eventually, we'll have to determine which Type of post we're deleting.
$this->Delete ( array ( 'Identifier' => $pIdentifier, 'User_FK' => $pUserId ) );

$this->Save();
// Remove the page reference.
include_once ( ASD_PATH . '/components/page/models/references.php' );
$Reference = new cPageReferencesModel ();
$Reference->Delete ( array ( 'Identifier' => $pIdentifier, 'User_FK' => $pUserId ) );

return ( true );
}
Expand Down
12 changes: 12 additions & 0 deletions components/page/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,16 @@ public function Status ( $pData = null ) {
return ( $return );
}

public function ClearStatus ( $pData = null ) {

$user = $pData['UserId'];

include ( ASD_PATH . 'components/page/models/page.php' );
$Page = new cPageModel ();

$Page->ClearCurrent ( $user );

return ( true );
}

}
7 changes: 5 additions & 2 deletions components/page/views/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
<li class="item">
<a class="owner-icon-link" href="http://lost.appleseed/profile/abed/"><img class="owner-icon" src="http://community.appleseed/?_social=true&_task=user.icon&_request=abed&_width=64&_height=64"></a>
<span class="info">
<p class="content"><a class="owner-link" rel="abed@community.appleseed">abed@community.appleseed</a><span class="content"></span></p>
<p class="content-full"><a class="owner-link" rel="abed@community.appleseed">abed@community.appleseed</a><span class="content"></span></p>
<abbr class="stamp">4 minutes ago</abbr>
<span class="actions">
<a class='add-comment'>Add Comment</a>
<a class='like'>Like</a>
</span>
</span>
<form class="delete">
<form class="delete" method="post">
<input type="hidden" name="Task" value="Remove" />
<input type="hidden" name="Context" />
<input type="hidden" name="Identifier" />
<button class="delete-post">Delete Post</button>
</form>
</li>
Expand Down

0 comments on commit e8607d8

Please sign in to comment.