Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
Help keep Vanilla free:<td class="MailBoxDate">'.TimeDiff($this->Context, $Discussion->DateCreated).'</td><td class="MailBoxDate">'.TimeDiff($this->Context, $Discussion->DateLastActive,mktime()).'</td>
$ItemUrl = GetUrl($this->Context->Configuration, 'extension.php',
'', 'DiscussionID', $Discussion->DiscussionID, '', 'PostBackAction=PrivateMessages&View=Message');
Posted: Wednesday, 14 February 2007 at 11:20AM (AEDT)
if ( in_array($Context->SelfUrl, array("post.php", "comments.php")) )
function GetDiscussionCount($View) {
$TotalNumberOfRecords = 0;
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s->SetMainTable('Discussion', 't');
// MINOR KLUDGE: There's not apparent way w/ SqlBuilder to add 'DISTINCT' within
// the MySQL function Count(). It works just fine, but breaks the rules a bit.
$s->AddSelect('DISTINCT t.DiscussionID', '', 'Count', 'count');
$s->AddWhere('t', 'Active', '', '1', '=');
$s->AddWhere('t', 'CategoryID', '', $this->CategoryID, '=');
if ($View == 'Inbox') {
// Count discussions in the Inbox when they are addressed directly to you.
$s->AddWhere('t', 'WhisperUserID', '', $this->UserID, '=', 'and', '', 1, 1);
// Count discussions in the Inbox that *you* have sent, but only after one or
// more reply has been made. This may or may not be how you want
//this to work.
$s->AddWhere('t', 'CountComments', '', 1, '>', 'or', '', 1, 1);
$s->AddWhere('t', 'AuthUserID', '', $this->UserID, '=', 'and');
$s->EndWhereGroup();
$s->EndWhereGroup();
} else {
// Add join to access all users who have contributed to a discussion.
// Trying work this with AuthUserID or LastUserId just doesn't cut it.
$s->AddJoin('Comment', 'co', 'DiscussionID', 't', 'DiscussionID', 'join');
$s->AddWhere('co', 'AuthUserID', '', $this->UserID, '=');
}
$result = $this->Context->Database->Select($s, $this->Name, 'GetDiscussionCount', 'An error occurred while retrieving Discussion information.');
while ($rows = $this->Context->Database->GetRow($result)) {
$TotalNumberOfRecords = $rows['Count'];
}
return $TotalNumberOfRecords;
}
function GetDiscussionList($RowsPerPage, $CurrentPage, $View) {
$TotalNumberOfRecords = 0;
if ($RowsPerPage > 0) {
$CurrentPage = ForceInt($CurrentPage, 1);
if ($CurrentPage < 1) $CurrentPage == 1;
$RowsPerPage = ForceInt($RowsPerPage, 50);
$FirstRecord = ($CurrentPage * $RowsPerPage) - $RowsPerPage;
}
$s = $this->GetDiscussionBuilder();
$s->AddJoin('Comment', 'm', 'CommentID', 't', 'FirstCommentID', 'join');
$s->AddSelect('Body', 'm');
$s->AddWhere('t', 'Active', '', '1', '=');
$s->AddWhere('t', 'CategoryID', '', $this->CategoryID, '=');
if ($View == 'Inbox') {
// Display discussions in the Inbox when they are addressed directly to you.
$s->AddWhere('t', 'WhisperUserID', '', $this->UserID, '=', 'and', '', 1, 1);
// Display discussions in the Inbox that *you* have sent, but only after one or
// more reply has been made. This may or may not be how you want
//this to work.
$s->AddWhere('t', 'CountComments', '', 1, '>', 'or', '', 1, 1);
$s->AddWhere('t', 'AuthUserID', '', $this->UserID, '=', 'and');
$s->EndWhereGroup();
$s->EndWhereGroup();
} else {
// Add join to access all users who have contributed to a discussion.
// Trying work this with AuthUserID or LastUserId just doesn't cut it.
$s->AddJoin('Comment', 'co', 'DiscussionID', 't', 'DiscussionID', 'join');
$s->AddWhere('co', 'AuthUserID', '', $this->UserID, '=');
}
$s->AddOrderBy('DateLastActive', 't', 'desc');
if ($RowsPerPage > 0) $s->AddLimit($FirstRecord, $RowsPerPage);
return $this->Context->Database->Select($s, $this->Name, 'GetDiscussionList', 'An error occurred while retrieving discussions.');
}$Context->Dictionary['ErrNoWhisperToSelf'] = 'You cannot send a Private Message to yourself. Please choose a valid recipient.';if (ForceIncomingString('WhisperUsername', '') == '') {
$ResultDiscussion = false;
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrWhisperUsernameMandatory'));
} else {
$ResultDiscussion = $dm->SaveDiscussion($this->Discussion);
}if (ForceIncomingString('WhisperUsername', '') == '') {
$ResultDiscussion = false;
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrWhisperUsernameMandatory'));
} elseif(ForceIncomingString('WhisperUsername', '') == $this->Context->Session->User->Name) {
$ResultDiscussion = false;
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrNoWhisperToSelf'));
} else {
$ResultDiscussion = $dm->SaveDiscussion($this->Discussion);
}
if (in_array($Context->SelfUrl, array("post.php", "comments.php")){if (in_array($Context->SelfUrl, array("post.php", "comments.php"))
|| ($Context->SelfUrl == 'extension.php' && ForceIncomingString('PostBackAction', '') == 'PrivateMessages')){http://some.host/extension/PrivateMessages/19/Messagehttp://some.host/extension/?PostBackAction=PrivateMessages&DiscussionID=19&View=Message
<?php
$remote_uri = '/extension/?DiscussionID=123&PostBackAction=PrivateMessages&View=Message'; //$_SERVER['REQUEST_URI'];
$remote_uri = str_replace('/','',$remote_uri);
$remote_uri_split = array('?','&');
$remote_uri = str_replace($remote_uri_split,',',$remote_uri);
$remote_uri = explode(',',$remote_uri);
echo '<pre>';
print_r($remote_uri);
echo '</pre>';
?>
Array
(
[0] => extension
[1] => DiscussionID=123
[2] => PostBackAction=PrivateMessages
[3] => View=Message
)
$url = 'http://www.coolr.de'.str_replace('.php','',$_SERVER['SCRIPT_NAME']).'/?DiscussionID'.$Discussion->DiscussionID.'/PostBackAction=PrivateMessages&View=Message';