Not signed in (Sign In)
 
Nov 20th 2007 edited
 
I added the delegation and modification requested by Grahack (r678).

One of the modification needed in the Discussion class is weird though. $Configuration need now to be passed by reference: function GetPropertiesFromDataSet($DataSet, &$Configuration) {
...
if ($Configuration['ENABLE_WHISPERS']) {
...
$TmpCount = ($this->CountComments / $Configuration['COMMENTS_PER_PAGE']);
...
}

Why does Discussion::GetPropertiesFromDataSet() need the $Configuration as argument in the first place. Can't it use $Context->Configuration? Maybe it has been left before the class became a Delegation children class. I don't see other raison. Do you think I can replace $Configuration with $Context->Configuration?
 
Dec 7th 2007
 
I think its safe to make that change... but then that would make the parameter useless. I notice there is also a GetPropertiesFromForm method in this class that gets passed $Context.

I wonder if this is legal:function GetPropertiesFromDataSet($DataSet, &$Configuration = &$this->Context->Configuration) {
That way, it won't break existing code that calls the function expecting to have to pass configuration.

I suppose it is probably better to break existing code and force it to be updated properly instead of keeping a strange hack around.
 
Jun 9th 2008 edited
 
The patch:
Index: src/library/Vanilla/Vanilla.Class.Discussion.php
===================================================================
--- src/library/Vanilla/Vanilla.Class.Discussion.php (revision 708)
+++ src/library/Vanilla/Vanilla.Class.Discussion.php (working copy)
@@ -120,7 +120,7 @@
}

// Retrieve properties from current DataRowSet
- function GetPropertiesFromDataSet($DataSet, &$Configuration) {
+ function GetPropertiesFromDataSet($DataSet) {
$this->DiscussionID = @$DataSet['DiscussionID'];
$this->FirstCommentID = @$DataSet['FirstCommentID'];
$this->CategoryID = @$DataSet['CategoryID'];
@@ -138,8 +138,8 @@
$this->DateCreated = UnixTimestamp(@$DataSet['DateCreated']);
$this->DateLastActive = UnixTimestamp(@$DataSet['DateLastActive']);
$this->CountComments = @$DataSet['CountComments'];
-
- if ($Configuration['ENABLE_WHISPERS']) {
+
+ if ($this->Context->Configuration['ENABLE_WHISPERS']) {
$this->WhisperUserID = @$DataSet['WhisperUserID'];
$this->WhisperUsername = @$DataSet['WhisperUsername'];

@@ -192,7 +192,7 @@

// Define the last page
$this->CallDelegate('PreDefineLastPage');
- $TmpCount = ($this->CountComments / $Configuration['COMMENTS_PER_PAGE']);
+ $TmpCount = ($this->CountComments / $this->Context->Configuration['COMMENTS_PER_PAGE']);
$RoundedCount = intval($TmpCount);
if ($TmpCount > 1) {
if ($TmpCount > $RoundedCount) {
Index: src/library/Vanilla/Vanilla.Class.DiscussionManager.php
===================================================================
--- src/library/Vanilla/Vanilla.Class.DiscussionManager.php (revision 708)
+++ src/library/Vanilla/Vanilla.Class.DiscussionManager.php (working copy)
@@ -153,7 +153,7 @@
$Discussion = false;
}
while ($rows = $this->Context->Database->GetRow($result)) {
- $Discussion->GetPropertiesFromDataSet($rows, $this->Context->Configuration);
+ $Discussion->GetPropertiesFromDataSet($rows);
}

if ($Discussion && $RecordDiscussionView) {
Index: src/library/Vanilla/Vanilla.Control.SearchForm.php
===================================================================
--- src/library/Vanilla/Vanilla.Control.SearchForm.php (revision 708)
+++ src/library/Vanilla/Vanilla.Control.SearchForm.php (working copy)
@@ -179,7 +179,7 @@
$ThemeFilePath = ThemeFilePath($this->Context->Configuration, 'discussion.php');
while ($Row = $this->Context->Database->GetRow($this->Data)) {
$Discussion->Clear();
- $Discussion->GetPropertiesFromDataSet($Row, $this->Context->Configuration);
+ $Discussion->GetPropertiesFromDataSet($Row);
$Discussion->FormatPropertiesForDisplay();
if ($Counter < $this->Context->Configuration['SEARCH_RESULTS_PER_PAGE']) {
$this->DelegateParameters['Discussion'] = &$Discussion;
Index: src/themes/discussions.php
===================================================================
--- src/themes/discussions.php (revision 708)
+++ src/themes/discussions.php (working copy)
@@ -25,7 +25,7 @@
$RowNumber++;
$this->DelegateParameters['RowNumber'] = &$RowNumber;
$Discussion->Clear();
- $Discussion->GetPropertiesFromDataSet($Row, $this->Context->Configuration);
+ $Discussion->GetPropertiesFromDataSet($Row);
$Discussion->FormatPropertiesForDisplay();
// Prefix the discussion name with the whispered-to username if this is a whisper
if ($Discussion->WhisperUserID > 0) {

Issue information

  • 36
  • Dinoboff

    Dinoboff

    Bug Tracker

  • Resolved
  • Low
  • Feature

Vanilla 1.1.2 is a product of Lussumo. More Information: Documentation, Community Support.