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

Commit

Permalink
Posting to a user's page now works.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Oct 17, 2010
1 parent d5e221b commit 7baaab3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 12 deletions.
22 changes: 17 additions & 5 deletions components/page/controllers/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function Display ( $pView = null, $pData = array ( ) ) {
$this->_Current = $this->Talk ( 'User', 'Current' );

if ( !$this->_Current ) {
$this->View->Find ( "[class=post]", 0 )->outertext = "";
$this->View->Find ( '.post', 0 )->outertext = "";
$this->_Prep();
} else {
$this->_Prep();
}
Expand Down Expand Up @@ -89,13 +90,24 @@ private function _Prep ( ) {

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

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

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

$Owner = $this->_Current->Account;
$Comments = $this->GetSys ( "Request" )->Get ( "Comment" );
$Privacy = $this->GetSys ( "Request" )->Get ( "Privacy" );
echo "<pre>";
print_r ( $_REQUEST );
print_r ( $Privacy );

return ( true );
$Current = false;

if ( $this->_Focus->Account == $this->_Current->Account ) $Current = true;

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

$redirect = '/profile/' . $this->_Focus->Username . '/page/';
header ( 'Location:' . $redirect );
exit;
}

}
45 changes: 38 additions & 7 deletions components/page/models/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class cPageModel extends cModel {

protected $_Tablename = "PagePosts";
protected $_Tablename = 'PagePosts';

/**
* Constructor
Expand All @@ -33,20 +33,30 @@ public function __construct ( $pTables = null ) {

public function RetrieveCurrent ( $pUserId ) {

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

return ( true );
}

public function ClearCurrent ( $pUserId ) {
$criteria = array ( "User_FK" => $pUserId, "Current" => 1 );
$table = $this->_Prefix . $this->_Tablename;
$query = 'UPDATE `' . $table . '` SET `Current` = ? WHERE `User_FK` = ?';

$prepared[] = '0';
$prepared[] = $pUserId;

$this->Query ( $query, $prepared );

return ( true );

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

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

$this->Fetch();
$this->Set ( "Current", 0 );
$this->Set ( 'Current', 0 );

$this->Save();

Expand All @@ -55,9 +65,30 @@ public function ClearCurrent ( $pUserId ) {

public function RetrievePagePosts ( $pUserId ) {

$criteria = array ( "User_FK" => $pUserId );
$this->Retrieve ( $criteria );
$criteria = array ( 'User_FK' => $pUserId );
$this->Retrieve ( $criteria, 'Stamp DESC' );

return ( true );
}

public function Post ( $pComment, $pPrivacy, $pUser, $pOwner, $pCurrent = false ) {
$this->Protect ( 'Post_PK', null );
$this->Set ( 'User_FK', $pUser );
$this->Set ( 'Action', 'posted' );
$this->Set ( 'ActionOwner', $pOwner );
$this->Set ( 'Comment', $pComment );
$this->Set ( 'Stamp', NOW() );

if ( $pCurrent ) {
$this->Set ( 'Current', (int)true );
$this->ClearCurrent ( $pUser );
} else {
$this->Set ( 'Current', '0' );
}

$this->Save();

return ( true );
}

}

0 comments on commit 7baaab3

Please sign in to comment.