zikula-modules/EZComments — Issue #26: Mograte comments from Reviews 1.0
Author: rmaiwald
Created: 2011-10-09 15:13:33+00:00
State: open

Durung upgrade from Reviews module 1.0 to version 2.3 or 2.4 the old style reviews comments in Reviews 1.0 will be migrated to EZComments. This fails because EZComments_migrateapi_reviews() declares the function Reviews_pntables() a second time in EZComments/pnmigrateapi/Reviews/pntables.php. This is not neccessary because the old style table structure will be added correctly in EZComments_get76xcolumns_reviews.

Above this I extended the migrate function to preserve the content owner IDs and use the actual parameter names for EZComments_userapi_create().

Here are the modification on EZComments 2.0.0.0:

*** pnmigrateapi/Attic/reviews.php	Thu Sep 23 21:44:58 2010
--- pnmigrateapi/reviews.php	Sat Oct 8 23:47:42 2011
***************
*** 27 ****
! pnModDBInfoLoad('Reviews', 'EZComments/pnmigrateapi/Reviews', true);
--- 27 ----
! pnModDBInfoLoad('Reviews', 'Reviews', true);
***************
*** 35 ****
--- 36,37 ----
+ $Reviewstable = $pntable['reviews'];
+ $Reviewscolumn = $pntable['reviews_column'];
***************
*** 45 ****
--- 48,49 ----
+ $Objecttable = $pntable['objectdata_attributes'];
+ $Objectcolumn = $pntable['objectdata_attributes_column'];
***************
*** 50 ****
! $Commentscolumn[date],
--- 54 ----
! C.$Commentscolumn[date],
***************
*** 51 ****
--- 56 ----
+ $Objectcolumn[object_id] AS 'owneruid',
***************
*** 53,54 ****
! $Commentscolumn[score]
! FROM $Commentstable
--- 58,59 ----
! C.$Commentscolumn[score]
! FROM $Commentstable C
***************
*** 56 ****
! ON $Commentscolumn[userid] = $Usercolumn[uname]";
--- 61,67 ----
! ON $Commentscolumn[userid] = $Usercolumn[uname]
! LEFT JOIN $Reviewstable
! ON $Commentscolumn[rid] = $Reviewscolumn[id]
! LEFT JOIN $Objecttable
! ON $Objectcolumn[object_type] = 'users'
! AND $Objectcolumn[attribute_name] = 'realname'
! AND $Reviewscolumn[reviewer] LIKE $Objectcolumn[value]";
***************
*** 65 ****
! $items = DBUtil::marshalObjects($result, array('cid', 'rid', 'date', 'uid', 'comment', 'score'));
--- 76 ----
! $items = DBUtil::marshallObjects($result, array('cid', 'rid', 'date', 'uid', 'owneruid', 'comment', 'score'));
***************
*** 71 ****
--- 83,85 ----
+ if (empty($item['owneruid'])) {
+ $item['owneruid'] = 1;
+ }
***************
*** 76 ****
! 'url' => pnModURL('Reviews', 'user', 'display', array('id' => $item['rid'])),
--- 90 ----
! 'useurl' => pnModURL('Reviews', 'user', 'display', array('id' => $item['rid'])),
***************
*** 79 ****
--- 94 ----
+ 'owneruid' => $item['owneruid'],