Index: trunk/kernel/units/reviews/reviews_config.php =================================================================== diff -u -N -r8441 -r8444 --- trunk/kernel/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8441) +++ trunk/kernel/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8444) @@ -36,16 +36,22 @@ 'bb-rev' => Array ( 'ParentPrefix' => 'bb', + 'ConfigMapping' => Array ( + 'PerPage' => 'Perpage_TopicReviews', - 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval', - 'ReviewDelayValue' => 'topic_ReviewDelay_Value', + 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval', + 'ReviewDelayValue' => 'topic_ReviewDelay_Value', + ), ), 'p-rev' => Array ( 'ParentPrefix' => 'p', + 'ConfigMapping' => Array ( + 'PerPage' => 'Comm_Perpage_Reviews', - 'ReviewDelayInterval' => 'product_ReviewDelay_Value', - 'ReviewDelayValue' => 'product_ReviewDelay_Interval', + 'ReviewDelayInterval' => 'product_ReviewDelay_Value', + 'ReviewDelayValue' => 'product_ReviewDelay_Interval', + ), ), ), @@ -63,7 +69,13 @@ ), 'ParentPrefix' => 'p', // replace all usage of rev to "p-rev" and then remove this param from here and Prefix too + 'ConfigMapping' => Array ( + 'PerPage' => 'Comm_Perpage_Reviews', + 'ReviewDelayInterval' => 'product_ReviewDelay_Value', + 'ReviewDelayValue' => 'product_ReviewDelay_Interval', + ), + 'IDField' => 'ReviewId', 'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events 'TableName' => TABLE_PREFIX.'ItemReview', Index: trunk/kernel/units/reviews/reviews_tag_processor.php =================================================================== diff -u -N -r8441 -r8444 --- trunk/kernel/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8441) +++ trunk/kernel/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8444) @@ -51,13 +51,14 @@ function AlreadyReviewed($params) { - $object =& $this->getObject( Array('skip_autoload' => true) ); - $parent_info = $object->getLinkedInfo(); + $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); + $main_object =& $this->Application->recallObject($parent_prefix); + /* @var $main_object kCatDBItem */ $spam_helper =& $this->Application->recallObject('SpamHelper'); /* @var $spam_helper SpamHelper */ - $spam_helper->InitHelper($parent_info['ParentId'], 'Review', 0); + $spam_helper->InitHelper($main_object->GetDBField('ResourceId'), 'Review', 0); return $spam_helper->InSpamControl(); } Index: trunk/core/units/general/helpers/spam_helper.php =================================================================== diff -u -N --- trunk/core/units/general/helpers/spam_helper.php (revision 0) +++ trunk/core/units/general/helpers/spam_helper.php (revision 8444) @@ -0,0 +1,133 @@ +TableName = TABLE_PREFIX.'SpamControl'; + } + + /** + * Initializes helper for concrete item + * + * @param int $resource_id + * @param string $data_type + * @param int $expiration + */ + function InitHelper($resource_id, $data_type, $expiration) + { + $this->ResourceId = $resource_id; + $this->DataType = $data_type; + + if (preg_match('/(.*):(.*)/', $expiration, $regs)) { + $delay_value = $this->Application->ConfigValue($regs[1]); + $delay_interval = $this->Application->ConfigValue($regs[2]); + $expiration = $delay_value * $delay_interval; + } + + $this->Expiration = adodb_mktime() + $expiration; + } + + /** + * Returns WHERE clause that identified each spam control record + * + * @param bool $as_array return result as array, not string + * + * @return string + */ + function GetKeyClause($as_array = false) + { + $user_id = $this->Application->RecallVar('user_id'); + + if ($user_id == 0) { + $user_id = -2; + } + + $keys = Array ( + 'ItemResourceId' => $this->ResourceId, + 'IPaddress' => $_SERVER['REMOTE_ADDR'], + 'PortalUserId' => $user_id, + 'DataType' => $this->DataType, + ); + + if ($as_array) { + return $keys; + } + + $ret = ''; + foreach ($keys as $field_name => $field_value) { + $ret .= '('.$field_name.' = '.$this->Conn->qstr($field_value).') AND '; + } + + return preg_replace('/(.*) AND $/', '\\1', $ret); + } + + /** + * Allows to add current item in spam control + * + */ + function AddToSpamControl() + { + $fields_hash = $this->GetKeyClause(true); + + $fields_hash['Expire'] = $this->Expiration; + $this->Conn->doInsert($fields_hash, $this->TableName); + } + + /** + * Allows to check if current item is in spam control + * + * @return bool + */ + function InSpamControl() + { + $key_clause = $this->GetKeyClause(); + + $sql = 'SELECT Expire + FROM '.$this->TableName.' + WHERE '.$key_clause; + $expires = $this->Conn->GetOne($sql); + + if ($expires && $expires < adodb_mktime()) { + // spam control record is expired + $sql = 'DELETE FROM '.$this->TableName.' + WHERE '.$key_clause; + $this->Conn->Query($sql); + return false; + } + + return $expires ? true : false; + } + + } + +?> \ No newline at end of file Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r8402 -r8444 --- trunk/core/kernel/application.php (.../application.php) (revision 8402) +++ trunk/core/kernel/application.php (.../application.php) (revision 8444) @@ -2489,7 +2489,7 @@ if (constOn('IS_INSTALL')) { return ; } - + $count_helper =& $this->Application->recallObject('CountHelper'); /* @var $count_helper kCountHelper */ Index: trunk/core/units/reviews/reviews_tag_processor.php =================================================================== diff -u -N -r8441 -r8444 --- trunk/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8441) +++ trunk/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8444) @@ -51,13 +51,14 @@ function AlreadyReviewed($params) { - $object =& $this->getObject( Array('skip_autoload' => true) ); - $parent_info = $object->getLinkedInfo(); + $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); + $main_object =& $this->Application->recallObject($parent_prefix); + /* @var $main_object kCatDBItem */ $spam_helper =& $this->Application->recallObject('SpamHelper'); /* @var $spam_helper SpamHelper */ - $spam_helper->InitHelper($parent_info['ParentId'], 'Review', 0); + $spam_helper->InitHelper($main_object->GetDBField('ResourceId'), 'Review', 0); return $spam_helper->InSpamControl(); } Index: trunk/kernel/units/helpers/spam_helper.php =================================================================== diff -u -N --- trunk/kernel/units/helpers/spam_helper.php (revision 0) +++ trunk/kernel/units/helpers/spam_helper.php (revision 8444) @@ -0,0 +1,133 @@ +TableName = TABLE_PREFIX.'SpamControl'; + } + + /** + * Initializes helper for concrete item + * + * @param int $resource_id + * @param string $data_type + * @param int $expiration + */ + function InitHelper($resource_id, $data_type, $expiration) + { + $this->ResourceId = $resource_id; + $this->DataType = $data_type; + + if (preg_match('/(.*):(.*)/', $expiration, $regs)) { + $delay_value = $this->Application->ConfigValue($regs[1]); + $delay_interval = $this->Application->ConfigValue($regs[2]); + $expiration = $delay_value * $delay_interval; + } + + $this->Expiration = adodb_mktime() + $expiration; + } + + /** + * Returns WHERE clause that identified each spam control record + * + * @param bool $as_array return result as array, not string + * + * @return string + */ + function GetKeyClause($as_array = false) + { + $user_id = $this->Application->RecallVar('user_id'); + + if ($user_id == 0) { + $user_id = -2; + } + + $keys = Array ( + 'ItemResourceId' => $this->ResourceId, + 'IPaddress' => $_SERVER['REMOTE_ADDR'], + 'PortalUserId' => $user_id, + 'DataType' => $this->DataType, + ); + + if ($as_array) { + return $keys; + } + + $ret = ''; + foreach ($keys as $field_name => $field_value) { + $ret .= '('.$field_name.' = '.$this->Conn->qstr($field_value).') AND '; + } + + return preg_replace('/(.*) AND $/', '\\1', $ret); + } + + /** + * Allows to add current item in spam control + * + */ + function AddToSpamControl() + { + $fields_hash = $this->GetKeyClause(true); + + $fields_hash['Expire'] = $this->Expiration; + $this->Conn->doInsert($fields_hash, $this->TableName); + } + + /** + * Allows to check if current item is in spam control + * + * @return bool + */ + function InSpamControl() + { + $key_clause = $this->GetKeyClause(); + + $sql = 'SELECT Expire + FROM '.$this->TableName.' + WHERE '.$key_clause; + $expires = $this->Conn->GetOne($sql); + + if ($expires && $expires < adodb_mktime()) { + // spam control record is expired + $sql = 'DELETE FROM '.$this->TableName.' + WHERE '.$key_clause; + $this->Conn->Query($sql); + return false; + } + + return $expires ? true : false; + } + + } + +?> \ No newline at end of file Index: trunk/themes/default2007/platform/designs/content_boxes.tpl =================================================================== diff -u -N -r8391 -r8444 --- trunk/themes/default2007/platform/designs/content_boxes.tpl (.../content_boxes.tpl) (revision 8391) +++ trunk/themes/default2007/platform/designs/content_boxes.tpl (.../content_boxes.tpl) (revision 8444) @@ -1,8 +1,8 @@ - + "> - + "> @@ -24,7 +24,7 @@ - Review By:
+ [] Review By: at
Review Text: @@ -47,11 +47,11 @@ - + - +
\ No newline at end of file Index: trunk/kernel/units/reviews/reviews_event_handler.php =================================================================== diff -u -N -r8441 -r8444 --- trunk/kernel/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8441) +++ trunk/kernel/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8444) @@ -3,6 +3,22 @@ class ReviewsEventHandler extends kDBEventHandler { /** + * Get's special of main item for linking with subitem + * + * @param kEvent $event + * @return string + */ + function getMainSpecial(&$event) + { + if ($event->Special == 'product' && !$this->Application->IsAdmin()) { + // rev.product should auto-link + return ''; + } + + return parent::getMainSpecial($event); + } + + /** * Checks REVIEW/REVIEW.PENDING permission by main object primary category (not current category) * * @param kEvent $event @@ -54,6 +70,7 @@ function SetCustomQuery(&$event) { $object =& $event->getObject(); + /* @var $object kDBList */ if (!$this->Application->IsAdmin()) { $object->addFilter('active', '%1$s.Status = '.STATUS_ACTIVE); @@ -65,36 +82,28 @@ $object->clearFilters(); break; - case 'item': + case 'item': // used ? $object->clearFilters(); $info = $object->getLinkedInfo(); $this->Application->setUnitOption($info['ParentPrefix'], 'AutoLoad', true); $parent =& $this->Application->recallObject($info['ParentPrefix']); $object->addFilter('item_reviews', '%1$s.ItemId = '.$parent->GetDBField('ResourceId')); break; - case 'products': + case 'products': // used ? $object->removeFilter('parent_filter'); // this is important $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId'); break; case 'product': - $object->clearFilters(); - $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId'); - $this->Application->setUnitOption('p', 'AutoLoad', true); - $product =& $this->Application->recallObject('p'); - $object->addFilter('current_product', 'pr.ResourceId = '.$product->GetDBField('ResourceId')); + $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId'); // for LEFT JOIN break; } if ($event->getEventParam('type') == 'current_user') { - $user_id = $this->getUserID(); - $ip = $_SERVER['REMOTE_ADDR']; - $object =& $event->getObject( Array('skip_autoload' => true) ); - $product_info = $object->getLinkedInfo(); - $object->addFilter('current_item', '%1$s.ItemId = '.$product_info['ParentId']); - $object->addFilter('current_user', '%1$s.CreatedById = '.$user_id); - $object->addFilter('current_ip', '%1$s.IPAddress = "'.$ip.'"'); + $object->removeFilter('active'); + $object->addFilter('current_user', '%1$s.CreatedById = '.$this->Application->RecallVar('user_id')); + $object->addFilter('current_ip', '%1$s.IPAddress = "'.$_SERVER['REMOTE_ADDR'].'"'); } } @@ -105,86 +114,7 @@ */ function OnAddReview(&$event) { - $user_id = $this->getUserID(); - $event->redirect_params = Array('pass' => 'all,p'); - - $object =& $event->getObject( Array('skip_autoload' => true) ); - $parent_info = $object->getLinkedInfo(); - $review_fields = $this->Application->GetVar($event->getPrefixSpecial(true)); - - $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl - WHERE ItemResourceId='.$parent_info['ParentId'].' - AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'" - AND PortalUserId='.$user_id.' - AND DataType="Review"'; - $res = $this->Conn->GetRow($sql); - - if( $res && $res['Expire'] < adodb_mktime() ) - { - $sql = ' DELETE FROM '.TABLE_PREFIX.'SpamControl - WHERE ItemResourceId='.$parent_info['ParentId'].' - AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'" - AND PortalUserId='.$user_id.' - AND DataType="Review"'; - $this->Conn->Query($sql); - unset($res); - } - - if(!$res) - { - $object->SetFieldsFromHash( array_shift($review_fields) ); - $object->SetDBField('CreatedById', $user_id); - $object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR']); - $object->SetDBField('CreatedOn', adodb_mktime()); - - $module_info = $this->Application->findModule('Var',$parent_info['ParentPrefix']); - $object->SetDBField('Module', $module_info['Name']); - if( $this->Application->CheckPermission( $this->getPermPrefix($event).'.REVIEW.PENDING', 0) ) - { - $object->SetDBField('Status', 2); - $template_var = 'success_pending_template'; - } - if( $this->Application->CheckPermission($this->getPermPrefix($event).'.REVIEW', 0) ) - { - $object->SetDBField('Status', 1); - $template_var = 'success_template'; - } - - $object->SetDBField('ItemId', $parent_info['ParentId']); - - $event->CallSubEvent('OnCreate'); - - if($event->status == erSUCCESS) - { - $parent =& $this->Application->recallObject($parent_info['ParentPrefix']); - $sql = ' SELECT COUNT(ReviewId) - FROM '.$object->TableName.' - WHERE ItemId='.$parent_info['ParentId']; - $review_qty = $this->Conn->GetOne($sql); - $parent->SetDBField('CachedReviewsQty', $review_qty); - $parent->Update(); - $expire = adodb_mktime() + $this->Application->ConfigValue('product_ReviewDelay_Value') * $this->Application->ConfigValue('product_ReviewDelay_Interval'); - $sql = ' INSERT INTO '.TABLE_PREFIX.'SpamControl - (ItemResourceId, IPaddress, PortalUserId, DataType, Expire) - VALUES ('.$parent_info['ParentId'].', - "'.$_SERVER['REMOTE_ADDR'].'", - '.$user_id.', - "Review", - '.$expire.')'; - $this->Conn->Query($sql); - - $event->redirect_params = Array('pass' => 'all,'.$parent_info['ParentPrefix']); - $event->redirect = $this->Application->GetVar($template_var); - } - } - else - { -// $this->Application->removeObject($event->getPrefixSpecial()); - $event->status == erFAIL; - $event->redirect=false; - $object->FieldErrors['ReviewText']['pseudo'] = 'too_frequent'; - $object->ErrorMsgs['too_frequent'] = $this->Application->Phrase('lu_ferror_review_duplicate'); - } + $event->CallSubEvent('OnCreate'); } /** @@ -263,7 +193,7 @@ /* @var $spam_helper SpamHelper */ $object =& $event->getObject(); - $parent_info = $object->getLinkedInfo($event->Special); + $parent_info = $object->getLinkedInfo(); $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); $review_settings = $config_mapping['ReviewDelayValue'].':'.$config_mapping['ReviewDelayInterval']; @@ -327,22 +257,9 @@ $next_template = $object->GetDBField('Status') == STATUS_ACTIVE ? 'success_template' : 'success_pending_template'; $event->redirect = $this->Application->GetVar($next_template); $event->SetRedirectParam('opener', 's'); - } - /** - * Returns current user id for reviews, for logic ask Kostja T. - * - * @return int - */ - function getUserID() - { - $user_id = $this->Application->RecallVar('user_id'); - - if ($user_id == 0) { - $user_id = -2; - } - - return $user_id; + $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $event->SetRedirectParam('pass', 'm,'.$parent_prefix); } } Index: trunk/core/units/reviews/reviews_event_handler.php =================================================================== diff -u -N -r8441 -r8444 --- trunk/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8441) +++ trunk/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8444) @@ -3,6 +3,22 @@ class ReviewsEventHandler extends kDBEventHandler { /** + * Get's special of main item for linking with subitem + * + * @param kEvent $event + * @return string + */ + function getMainSpecial(&$event) + { + if ($event->Special == 'product' && !$this->Application->IsAdmin()) { + // rev.product should auto-link + return ''; + } + + return parent::getMainSpecial($event); + } + + /** * Checks REVIEW/REVIEW.PENDING permission by main object primary category (not current category) * * @param kEvent $event @@ -54,6 +70,7 @@ function SetCustomQuery(&$event) { $object =& $event->getObject(); + /* @var $object kDBList */ if (!$this->Application->IsAdmin()) { $object->addFilter('active', '%1$s.Status = '.STATUS_ACTIVE); @@ -65,36 +82,28 @@ $object->clearFilters(); break; - case 'item': + case 'item': // used ? $object->clearFilters(); $info = $object->getLinkedInfo(); $this->Application->setUnitOption($info['ParentPrefix'], 'AutoLoad', true); $parent =& $this->Application->recallObject($info['ParentPrefix']); $object->addFilter('item_reviews', '%1$s.ItemId = '.$parent->GetDBField('ResourceId')); break; - case 'products': + case 'products': // used ? $object->removeFilter('parent_filter'); // this is important $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId'); break; case 'product': - $object->clearFilters(); - $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId'); - $this->Application->setUnitOption('p', 'AutoLoad', true); - $product =& $this->Application->recallObject('p'); - $object->addFilter('current_product', 'pr.ResourceId = '.$product->GetDBField('ResourceId')); + $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId'); // for LEFT JOIN break; } if ($event->getEventParam('type') == 'current_user') { - $user_id = $this->getUserID(); - $ip = $_SERVER['REMOTE_ADDR']; - $object =& $event->getObject( Array('skip_autoload' => true) ); - $product_info = $object->getLinkedInfo(); - $object->addFilter('current_item', '%1$s.ItemId = '.$product_info['ParentId']); - $object->addFilter('current_user', '%1$s.CreatedById = '.$user_id); - $object->addFilter('current_ip', '%1$s.IPAddress = "'.$ip.'"'); + $object->removeFilter('active'); + $object->addFilter('current_user', '%1$s.CreatedById = '.$this->Application->RecallVar('user_id')); + $object->addFilter('current_ip', '%1$s.IPAddress = "'.$_SERVER['REMOTE_ADDR'].'"'); } } @@ -105,86 +114,7 @@ */ function OnAddReview(&$event) { - $user_id = $this->getUserID(); - $event->redirect_params = Array('pass' => 'all,p'); - - $object =& $event->getObject( Array('skip_autoload' => true) ); - $parent_info = $object->getLinkedInfo(); - $review_fields = $this->Application->GetVar($event->getPrefixSpecial(true)); - - $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl - WHERE ItemResourceId='.$parent_info['ParentId'].' - AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'" - AND PortalUserId='.$user_id.' - AND DataType="Review"'; - $res = $this->Conn->GetRow($sql); - - if( $res && $res['Expire'] < adodb_mktime() ) - { - $sql = ' DELETE FROM '.TABLE_PREFIX.'SpamControl - WHERE ItemResourceId='.$parent_info['ParentId'].' - AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'" - AND PortalUserId='.$user_id.' - AND DataType="Review"'; - $this->Conn->Query($sql); - unset($res); - } - - if(!$res) - { - $object->SetFieldsFromHash( array_shift($review_fields) ); - $object->SetDBField('CreatedById', $user_id); - $object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR']); - $object->SetDBField('CreatedOn', adodb_mktime()); - - $module_info = $this->Application->findModule('Var',$parent_info['ParentPrefix']); - $object->SetDBField('Module', $module_info['Name']); - if( $this->Application->CheckPermission( $this->getPermPrefix($event).'.REVIEW.PENDING', 0) ) - { - $object->SetDBField('Status', 2); - $template_var = 'success_pending_template'; - } - if( $this->Application->CheckPermission($this->getPermPrefix($event).'.REVIEW', 0) ) - { - $object->SetDBField('Status', 1); - $template_var = 'success_template'; - } - - $object->SetDBField('ItemId', $parent_info['ParentId']); - - $event->CallSubEvent('OnCreate'); - - if($event->status == erSUCCESS) - { - $parent =& $this->Application->recallObject($parent_info['ParentPrefix']); - $sql = ' SELECT COUNT(ReviewId) - FROM '.$object->TableName.' - WHERE ItemId='.$parent_info['ParentId']; - $review_qty = $this->Conn->GetOne($sql); - $parent->SetDBField('CachedReviewsQty', $review_qty); - $parent->Update(); - $expire = adodb_mktime() + $this->Application->ConfigValue('product_ReviewDelay_Value') * $this->Application->ConfigValue('product_ReviewDelay_Interval'); - $sql = ' INSERT INTO '.TABLE_PREFIX.'SpamControl - (ItemResourceId, IPaddress, PortalUserId, DataType, Expire) - VALUES ('.$parent_info['ParentId'].', - "'.$_SERVER['REMOTE_ADDR'].'", - '.$user_id.', - "Review", - '.$expire.')'; - $this->Conn->Query($sql); - - $event->redirect_params = Array('pass' => 'all,'.$parent_info['ParentPrefix']); - $event->redirect = $this->Application->GetVar($template_var); - } - } - else - { -// $this->Application->removeObject($event->getPrefixSpecial()); - $event->status == erFAIL; - $event->redirect=false; - $object->FieldErrors['ReviewText']['pseudo'] = 'too_frequent'; - $object->ErrorMsgs['too_frequent'] = $this->Application->Phrase('lu_ferror_review_duplicate'); - } + $event->CallSubEvent('OnCreate'); } /** @@ -263,7 +193,7 @@ /* @var $spam_helper SpamHelper */ $object =& $event->getObject(); - $parent_info = $object->getLinkedInfo($event->Special); + $parent_info = $object->getLinkedInfo(); $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); $review_settings = $config_mapping['ReviewDelayValue'].':'.$config_mapping['ReviewDelayInterval']; @@ -327,22 +257,9 @@ $next_template = $object->GetDBField('Status') == STATUS_ACTIVE ? 'success_template' : 'success_pending_template'; $event->redirect = $this->Application->GetVar($next_template); $event->SetRedirectParam('opener', 's'); - } - /** - * Returns current user id for reviews, for logic ask Kostja T. - * - * @return int - */ - function getUserID() - { - $user_id = $this->Application->RecallVar('user_id'); - - if ($user_id == 0) { - $user_id = -2; - } - - return $user_id; + $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $event->SetRedirectParam('pass', 'm,'.$parent_prefix); } } Index: trunk/kernel/units/helpers/helpers_config.php =================================================================== diff -u -N --- trunk/kernel/units/helpers/helpers_config.php (revision 0) +++ trunk/kernel/units/helpers/helpers_config.php (revision 8444) @@ -0,0 +1,12 @@ + 'in-custom-helpers', + 'EventHandlerClass' => Array('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'), + + 'RegisterClasses' => Array ( + Array('pseudo' => 'SpamHelper', 'class' => 'SpamHelper','file' => 'spam_helper.php', 'build_event' => '', 'require_classes' => Array('kHelper')), + ), + ); + +?> \ No newline at end of file Index: trunk/core/units/reviews/reviews_config.php =================================================================== diff -u -N -r8441 -r8444 --- trunk/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8441) +++ trunk/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8444) @@ -36,16 +36,22 @@ 'bb-rev' => Array ( 'ParentPrefix' => 'bb', + 'ConfigMapping' => Array ( + 'PerPage' => 'Perpage_TopicReviews', - 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval', - 'ReviewDelayValue' => 'topic_ReviewDelay_Value', + 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval', + 'ReviewDelayValue' => 'topic_ReviewDelay_Value', + ), ), 'p-rev' => Array ( 'ParentPrefix' => 'p', + 'ConfigMapping' => Array ( + 'PerPage' => 'Comm_Perpage_Reviews', - 'ReviewDelayInterval' => 'product_ReviewDelay_Value', - 'ReviewDelayValue' => 'product_ReviewDelay_Interval', + 'ReviewDelayInterval' => 'product_ReviewDelay_Value', + 'ReviewDelayValue' => 'product_ReviewDelay_Interval', + ), ), ), @@ -63,7 +69,13 @@ ), 'ParentPrefix' => 'p', // replace all usage of rev to "p-rev" and then remove this param from here and Prefix too + 'ConfigMapping' => Array ( + 'PerPage' => 'Comm_Perpage_Reviews', + 'ReviewDelayInterval' => 'product_ReviewDelay_Value', + 'ReviewDelayValue' => 'product_ReviewDelay_Interval', + ), + 'IDField' => 'ReviewId', 'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events 'TableName' => TABLE_PREFIX.'ItemReview',