Index: trunk/kernel/units/reviews/reviews_config.php
===================================================================
diff -u -r8378 -r8441
--- trunk/kernel/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8378)
+++ trunk/kernel/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8441)
@@ -2,7 +2,7 @@
$config = Array (
'Prefix' => 'rev',
-
+
'Clones' => Array (
'l-rev' => Array(
'ParentPrefix' => 'l',
@@ -13,9 +13,12 @@
'DefaultSorting2Field' => 'Link_ReviewsSort2',
'DefaultSorting1Dir' => 'Link_ReviewsOrder',
'DefaultSorting2Dir' => 'Link_ReviewsOrder2',
+
+ 'ReviewDelayInterval' => 'link_ReviewDelay_Interval',
+ 'ReviewDelayValue' => 'link_ReviewDelay_Value',
),
),
-
+
'n-rev' => Array (
'ParentPrefix' => 'n',
'ConfigMapping' => Array (
@@ -25,43 +28,55 @@
'DefaultSorting2Field' => 'News_SortReviews2',
'DefaultSorting1Dir' => 'News_SortReviewsOrder',
'DefaultSorting2Dir' => 'News_SortReviewsOrder2',
+
+ 'ReviewDelayInterval' => 'News_ReviewDelay_Interval',
+ 'ReviewDelayValue' => 'News_ReviewDelay_Value',
),
),
-
- 'bb-rev'=> Array(
- 'ParentPrefix' => 'bb',
+
+ 'bb-rev' => Array (
+ 'ParentPrefix' => 'bb',
+
+ 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval',
+ 'ReviewDelayValue' => 'topic_ReviewDelay_Value',
),
- /*'p-rev' => Array('ParentPrefix' => 'p'),*/
+
+ 'p-rev' => Array (
+ 'ParentPrefix' => 'p',
+
+ 'ReviewDelayInterval' => 'product_ReviewDelay_Value',
+ 'ReviewDelayValue' => 'product_ReviewDelay_Interval',
+ ),
),
-
+
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'ReviewsEventHandler','file'=>'reviews_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'ReviewsTagProcessor','file'=>'reviews_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
-
+
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'event',
4 => 'mode',
),
-
+
'ParentPrefix' => 'p', // replace all usage of rev to "p-rev" and then remove this param from here and Prefix too
-
+
'IDField' => 'ReviewId',
'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events
'TableName' => TABLE_PREFIX.'ItemReview',
'ParentTableKey' => 'ResourceId', // linked field in master table
'ForeignKey' => 'ItemId', // linked field in subtable
-
+
'AutoDelete' => true,
'AutoClone' => true,
-
+
'TitlePresets' => Array (
'reviews_edit' => Array('format' => "!la_title_Editing_Review!"),
),
-
+
'FilterMenu' => Array (
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array('show_active','show_pending','show_disabled'), 'type' => WHERE_FILTER),
@@ -77,13 +92,13 @@
'' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
),
-
+
'products' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
'ItemName' => 'pr.l1_Name',
'ProductId' => 'pr.ProductId',
),
-
+
'product' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
'ItemName' => 'pr.l1_Name',
@@ -123,7 +138,7 @@
'ItemType' => Array('type'=>'int','not_null'=>1,'default'=>0),
'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0),
'Status' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'use_phrases' => 1, 'options'=>Array(1=>'la_Active',2=>'la_Pending',0=>'la_Disabled'),'not_null'=>1,'default'=>2 ),
- 'TextFormat' => Array('type'=>'int','not_null'=>1,'default'=>0),
+ 'TextFormat' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_text', 1 => 'la_html'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
'Module' => Array('type'=>'string','not_null'=>1,'default'=>''),
),
'VirtualFields' => Array(
Index: trunk/kernel/units/reviews/reviews_tag_processor.php
===================================================================
diff -u -r8369 -r8441
--- trunk/kernel/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8369)
+++ trunk/kernel/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8441)
@@ -47,36 +47,19 @@
}
return parent::Field($params);
-
}
function AlreadyReviewed($params)
{
- $user_id = $this->getUserID();
$object =& $this->getObject( Array('skip_autoload' => true) );
- $product_info = $object->getLinkedInfo();
+ $parent_info = $object->getLinkedInfo();
- $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl
- WHERE ItemResourceId='.$product_info['ParentId'].'
- AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
- AND PortalUserId='.$user_id.'
- AND DataType="Review"';
- $res = $this->Conn->GetRow($sql);
- if($res['Expire'] > adodb_mktime())
- {
- $ret = 1;
- }
- else
- {
- $sql = 'DELETE FROM '.TABLE_PREFIX.'SpamControl
- WHERE ItemResourceId='.$product_info['ParentId'].'
- AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
- AND PortalUserId='.$user_id.'
- AND DataType="Review"';
- $this->Conn->Query($sql);
- $ret = 0;
- }
- return $ret;
+ $spam_helper =& $this->Application->recallObject('SpamHelper');
+ /* @var $spam_helper SpamHelper */
+
+ $spam_helper->InitHelper($parent_info['ParentId'], 'Review', 0);
+
+ return $spam_helper->InSpamControl();
}
function HasError($params)
@@ -89,28 +72,18 @@
return 0;
}
}
-
+
/**
- * Returns current user id for reviews, for logic ask Kostja T.
+ * Preserve main item id in subitem pagination url
*
- * @return int
+ * @param Array $params
+ * @return string
*/
- function getUserID()
- {
- $user_id = $this->Application->RecallVar('user_id');
-
- if ($user_id == 0) {
- $user_id = -2;
- }
-
- return $user_id;
- }
-
function PageLink($params)
{
$object =& $this->getObject($params);
/* @var kDBList */
-
+
$parent_info = $object->getLinkedInfo();
if ($parent_info['ParentId'] > 0) {
$params['pass'] = 'm,'.$this->getPrefixSpecial().','.$parent_info['ParentPrefix'];
Index: trunk/core/units/reviews/reviews_tag_processor.php
===================================================================
diff -u -r8369 -r8441
--- trunk/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8369)
+++ trunk/core/units/reviews/reviews_tag_processor.php (.../reviews_tag_processor.php) (revision 8441)
@@ -47,36 +47,19 @@
}
return parent::Field($params);
-
}
function AlreadyReviewed($params)
{
- $user_id = $this->getUserID();
$object =& $this->getObject( Array('skip_autoload' => true) );
- $product_info = $object->getLinkedInfo();
+ $parent_info = $object->getLinkedInfo();
- $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl
- WHERE ItemResourceId='.$product_info['ParentId'].'
- AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
- AND PortalUserId='.$user_id.'
- AND DataType="Review"';
- $res = $this->Conn->GetRow($sql);
- if($res['Expire'] > adodb_mktime())
- {
- $ret = 1;
- }
- else
- {
- $sql = 'DELETE FROM '.TABLE_PREFIX.'SpamControl
- WHERE ItemResourceId='.$product_info['ParentId'].'
- AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
- AND PortalUserId='.$user_id.'
- AND DataType="Review"';
- $this->Conn->Query($sql);
- $ret = 0;
- }
- return $ret;
+ $spam_helper =& $this->Application->recallObject('SpamHelper');
+ /* @var $spam_helper SpamHelper */
+
+ $spam_helper->InitHelper($parent_info['ParentId'], 'Review', 0);
+
+ return $spam_helper->InSpamControl();
}
function HasError($params)
@@ -89,28 +72,18 @@
return 0;
}
}
-
+
/**
- * Returns current user id for reviews, for logic ask Kostja T.
+ * Preserve main item id in subitem pagination url
*
- * @return int
+ * @param Array $params
+ * @return string
*/
- function getUserID()
- {
- $user_id = $this->Application->RecallVar('user_id');
-
- if ($user_id == 0) {
- $user_id = -2;
- }
-
- return $user_id;
- }
-
function PageLink($params)
{
$object =& $this->getObject($params);
/* @var kDBList */
-
+
$parent_info = $object->getLinkedInfo();
if ($parent_info['ParentId'] > 0) {
$params['pass'] = 'm,'.$this->getPrefixSpecial().','.$parent_info['ParentPrefix'];
Index: trunk/themes/default2007/phrases_edit.tpl
===================================================================
diff -u -r8368 -r8441
--- trunk/themes/default2007/phrases_edit.tpl (.../phrases_edit.tpl) (revision 8368)
+++ trunk/themes/default2007/phrases_edit.tpl (.../phrases_edit.tpl) (revision 8441)
@@ -1,5 +1,5 @@
-
-
+
- There is a problem with the form, please check the error messages below.
+
*
@@ -26,20 +26,20 @@
-
+
" />
" value="" />
" value="0" />
-
+
"/>
|
-
+
Index: trunk/themes/default2007/platform/my_account/my_profile.tpl
===================================================================
diff -u -r8428 -r8441
--- trunk/themes/default2007/platform/my_account/my_profile.tpl (.../my_profile.tpl) (revision 8428)
+++ trunk/themes/default2007/platform/my_account/my_profile.tpl (.../my_profile.tpl) (revision 8441)
@@ -15,7 +15,7 @@
- There is a problem with the form, please check the error messages below.
+
*
Index: trunk/kernel/units/reviews/reviews_event_handler.php
===================================================================
diff -u -r8369 -r8441
--- trunk/kernel/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8369)
+++ trunk/kernel/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8441)
@@ -3,15 +3,24 @@
class ReviewsEventHandler extends kDBEventHandler
{
/**
- * Checks permissions of user
+ * Checks REVIEW/REVIEW.PENDING permission by main object primary category (not current category)
*
* @param kEvent $event
*/
function CheckPermission(&$event)
{
- if ($event->Name == 'OnAddReview') {
- $item_prefix = $this->getPermPrefix($event);
- $res = $this->Application->CheckPermission($item_prefix.'.REVIEW.PENDING', 0) || $this->Application->CheckPermission($item_prefix.'.REVIEW', 0);
+ if ($event->Name == 'OnAddReview' || $event->Name == 'OnCreate') {
+ $perm_helper =& $this->Application->recallObject('PermissionsHelper');
+ /* @var $perm_helper kPermissionsHelper */
+
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $main_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $main_object kCatDBItem */
+
+ $perm_name = $this->getPermPrefix($event).'.REVIEW';
+ $res = $this->Application->CheckPermission($perm_name, 0, $main_object->GetDBField('CategoryId')) ||
+ $this->Application->CheckPermission($perm_name.'.PENDING', 0, $main_object->GetDBField('CategoryId'));
+
if (!$res) {
$event->status = erPERM_FAIL;
}
@@ -35,7 +44,6 @@
return $item_prefix;
}
-
/**
* Apply any custom changes to list's sql query
*
@@ -46,11 +54,11 @@
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
-
+
if (!$this->Application->IsAdmin()) {
$object->addFilter('active', '%1$s.Status = '.STATUS_ACTIVE);
}
-
+
switch ($event->Special)
{
case 'showall':
@@ -69,7 +77,7 @@
$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');
@@ -180,17 +188,148 @@
}
/**
- * Enter description here...
+ * Get new review status on user review permission
*
* @param kEvent $event
+ * @return int
*/
+ function getReviewStatus(&$event)
+ {
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $main_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $main_object kCatDBItem */
+
+ $ret = STATUS_DISABLED;
+ $perm_name = $this->getPermPrefix($event).'.REVIEW';
+ if ($this->Application->CheckPermission($perm_name, 0, $main_object->GetDBField('CategoryId'))) {
+ $ret = STATUS_ACTIVE;
+ }
+ else if ($this->Application->CheckPermission($perm_name.'.PENDING', 0, $main_object->GetDBField('CategoryId'))) {
+ $ret = STATUS_PENDING;
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Prefills all fields on front-end
+ *
+ * @param kEvent $event
+ */
function OnBeforeItemCreate(&$event)
{
+ if ($this->Application->IsAdmin()) {
+ return ;
+ }
+
$object =& $event->getObject();
- $object->SetDBField('Module', $this->Application->findModule('Var',$this->Application->getUnitOption($this->Prefix, 'ParentPrefix'), 'Name'));
+ /* @var $object kDBItem */
+
+ $parent_info = $object->getLinkedInfo();
+
+ $spam_helper =& $this->Application->recallObject('SpamHelper');
+ /* @var $spam_helper SpamHelper */
+
+ $spam_helper->InitHelper($parent_info['ParentId'], 'Review', 0);
+
+ if ($spam_helper->InSpamControl()) {
+ $event->status = erFAIL;
+ $object->SetError('ReviewText', 'too_frequent', 'lu_ferror_review_duplicate');
+ return ;
+ }
+
+ $item_type = $this->Application->getUnitOption($parent_info['ParentPrefix'], 'ItemType');
+
+ $object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR']);
+ $object->SetDBField('ItemId', $parent_info['ParentId']); // ResourceId
+ $object->SetDBField('CreatedById', $this->Application->RecallVar('user_id'));
+ $object->SetDBField('ItemType', $item_type);
+ $object->SetDBField('Status', $this->getReviewStatus($event));
+ $object->SetDBField('TextFormat', 0); // set plain text format directly
+ $object->SetDBField('Module', $this->Application->findModule('Var', $parent_info['ParentPrefix'], 'Name'));
}
/**
+ * Updates item review counter
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemCreate(&$event)
+ {
+ $this->updateReviewsCounter($event);
+
+ if (!$this->Application->IsAdmin()) {
+ $spam_helper =& $this->Application->recallObject('SpamHelper');
+ /* @var $spam_helper SpamHelper */
+
+ $object =& $event->getObject();
+ $parent_info = $object->getLinkedInfo($event->Special);
+
+ $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
+ $review_settings = $config_mapping['ReviewDelayValue'].':'.$config_mapping['ReviewDelayInterval'];
+ $spam_helper->InitHelper($parent_info['ParentId'], 'Review', $review_settings);
+
+ $spam_helper->AddToSpamControl();
+ }
+ }
+
+ /**
+ * Updates total review counter
+ *
+ * @param kEvent $event
+ */
+ function updateReviewsCounter(&$event)
+ {
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $main_object =& $this->Application->recallObject($parent_prefix, null, Array ('raise_warnings' => 0));
+ /* @var $main_object kCatDBItem */
+
+ if (!$main_object->isLoaded()) {
+ // deleting main item / cloning main item
+ return ;
+ }
+
+ $object =& $event->getObject(); // for temp tables
+
+ $sql = 'SELECT COUNT(ReviewId)
+ FROM '.$object->TableName.'
+ WHERE ItemId = '.$main_object->GetDBField('ResourceId');
+ $review_count = $this->Conn->GetOne($sql);
+ $main_object->SetDBField('CachedReviewsQty', $review_count);
+ $main_object->Update();
+ }
+
+
+ /**
+ * Updates main item cached review counter
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemDelete(&$event)
+ {
+ $this->updateReviewsCounter($event);
+ }
+
+ /**
+ * Creates review & redirect to confirmation template
+ *
+ * @param kEvent $event
+ */
+ function OnCreate(&$event)
+ {
+ parent::OnCreate($event);
+
+ if ($event->status != erSUCCESS || $this->Application->IsAdmin()) {
+ return ;
+ }
+
+ $object =& $event->getObject();
+ $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
Index: trunk/core/units/reviews/reviews_event_handler.php
===================================================================
diff -u -r8369 -r8441
--- trunk/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8369)
+++ trunk/core/units/reviews/reviews_event_handler.php (.../reviews_event_handler.php) (revision 8441)
@@ -3,15 +3,24 @@
class ReviewsEventHandler extends kDBEventHandler
{
/**
- * Checks permissions of user
+ * Checks REVIEW/REVIEW.PENDING permission by main object primary category (not current category)
*
* @param kEvent $event
*/
function CheckPermission(&$event)
{
- if ($event->Name == 'OnAddReview') {
- $item_prefix = $this->getPermPrefix($event);
- $res = $this->Application->CheckPermission($item_prefix.'.REVIEW.PENDING', 0) || $this->Application->CheckPermission($item_prefix.'.REVIEW', 0);
+ if ($event->Name == 'OnAddReview' || $event->Name == 'OnCreate') {
+ $perm_helper =& $this->Application->recallObject('PermissionsHelper');
+ /* @var $perm_helper kPermissionsHelper */
+
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $main_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $main_object kCatDBItem */
+
+ $perm_name = $this->getPermPrefix($event).'.REVIEW';
+ $res = $this->Application->CheckPermission($perm_name, 0, $main_object->GetDBField('CategoryId')) ||
+ $this->Application->CheckPermission($perm_name.'.PENDING', 0, $main_object->GetDBField('CategoryId'));
+
if (!$res) {
$event->status = erPERM_FAIL;
}
@@ -35,7 +44,6 @@
return $item_prefix;
}
-
/**
* Apply any custom changes to list's sql query
*
@@ -46,11 +54,11 @@
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
-
+
if (!$this->Application->IsAdmin()) {
$object->addFilter('active', '%1$s.Status = '.STATUS_ACTIVE);
}
-
+
switch ($event->Special)
{
case 'showall':
@@ -69,7 +77,7 @@
$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');
@@ -180,17 +188,148 @@
}
/**
- * Enter description here...
+ * Get new review status on user review permission
*
* @param kEvent $event
+ * @return int
*/
+ function getReviewStatus(&$event)
+ {
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $main_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $main_object kCatDBItem */
+
+ $ret = STATUS_DISABLED;
+ $perm_name = $this->getPermPrefix($event).'.REVIEW';
+ if ($this->Application->CheckPermission($perm_name, 0, $main_object->GetDBField('CategoryId'))) {
+ $ret = STATUS_ACTIVE;
+ }
+ else if ($this->Application->CheckPermission($perm_name.'.PENDING', 0, $main_object->GetDBField('CategoryId'))) {
+ $ret = STATUS_PENDING;
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Prefills all fields on front-end
+ *
+ * @param kEvent $event
+ */
function OnBeforeItemCreate(&$event)
{
+ if ($this->Application->IsAdmin()) {
+ return ;
+ }
+
$object =& $event->getObject();
- $object->SetDBField('Module', $this->Application->findModule('Var',$this->Application->getUnitOption($this->Prefix, 'ParentPrefix'), 'Name'));
+ /* @var $object kDBItem */
+
+ $parent_info = $object->getLinkedInfo();
+
+ $spam_helper =& $this->Application->recallObject('SpamHelper');
+ /* @var $spam_helper SpamHelper */
+
+ $spam_helper->InitHelper($parent_info['ParentId'], 'Review', 0);
+
+ if ($spam_helper->InSpamControl()) {
+ $event->status = erFAIL;
+ $object->SetError('ReviewText', 'too_frequent', 'lu_ferror_review_duplicate');
+ return ;
+ }
+
+ $item_type = $this->Application->getUnitOption($parent_info['ParentPrefix'], 'ItemType');
+
+ $object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR']);
+ $object->SetDBField('ItemId', $parent_info['ParentId']); // ResourceId
+ $object->SetDBField('CreatedById', $this->Application->RecallVar('user_id'));
+ $object->SetDBField('ItemType', $item_type);
+ $object->SetDBField('Status', $this->getReviewStatus($event));
+ $object->SetDBField('TextFormat', 0); // set plain text format directly
+ $object->SetDBField('Module', $this->Application->findModule('Var', $parent_info['ParentPrefix'], 'Name'));
}
/**
+ * Updates item review counter
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemCreate(&$event)
+ {
+ $this->updateReviewsCounter($event);
+
+ if (!$this->Application->IsAdmin()) {
+ $spam_helper =& $this->Application->recallObject('SpamHelper');
+ /* @var $spam_helper SpamHelper */
+
+ $object =& $event->getObject();
+ $parent_info = $object->getLinkedInfo($event->Special);
+
+ $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
+ $review_settings = $config_mapping['ReviewDelayValue'].':'.$config_mapping['ReviewDelayInterval'];
+ $spam_helper->InitHelper($parent_info['ParentId'], 'Review', $review_settings);
+
+ $spam_helper->AddToSpamControl();
+ }
+ }
+
+ /**
+ * Updates total review counter
+ *
+ * @param kEvent $event
+ */
+ function updateReviewsCounter(&$event)
+ {
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $main_object =& $this->Application->recallObject($parent_prefix, null, Array ('raise_warnings' => 0));
+ /* @var $main_object kCatDBItem */
+
+ if (!$main_object->isLoaded()) {
+ // deleting main item / cloning main item
+ return ;
+ }
+
+ $object =& $event->getObject(); // for temp tables
+
+ $sql = 'SELECT COUNT(ReviewId)
+ FROM '.$object->TableName.'
+ WHERE ItemId = '.$main_object->GetDBField('ResourceId');
+ $review_count = $this->Conn->GetOne($sql);
+ $main_object->SetDBField('CachedReviewsQty', $review_count);
+ $main_object->Update();
+ }
+
+
+ /**
+ * Updates main item cached review counter
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemDelete(&$event)
+ {
+ $this->updateReviewsCounter($event);
+ }
+
+ /**
+ * Creates review & redirect to confirmation template
+ *
+ * @param kEvent $event
+ */
+ function OnCreate(&$event)
+ {
+ parent::OnCreate($event);
+
+ if ($event->status != erSUCCESS || $this->Application->IsAdmin()) {
+ return ;
+ }
+
+ $object =& $event->getObject();
+ $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
Index: trunk/themes/default2007/platform/login/register.tpl
===================================================================
diff -u -r8368 -r8441
--- trunk/themes/default2007/platform/login/register.tpl (.../register.tpl) (revision 8368)
+++ trunk/themes/default2007/platform/login/register.tpl (.../register.tpl) (revision 8441)
@@ -1,5 +1,5 @@
-
-
-
+
+
- There is a problem with the form, please check the error messages below.
+
*
-
+
Index: trunk/core/units/reviews/reviews_config.php
===================================================================
diff -u -r8378 -r8441
--- trunk/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8378)
+++ trunk/core/units/reviews/reviews_config.php (.../reviews_config.php) (revision 8441)
@@ -2,7 +2,7 @@
$config = Array (
'Prefix' => 'rev',
-
+
'Clones' => Array (
'l-rev' => Array(
'ParentPrefix' => 'l',
@@ -13,9 +13,12 @@
'DefaultSorting2Field' => 'Link_ReviewsSort2',
'DefaultSorting1Dir' => 'Link_ReviewsOrder',
'DefaultSorting2Dir' => 'Link_ReviewsOrder2',
+
+ 'ReviewDelayInterval' => 'link_ReviewDelay_Interval',
+ 'ReviewDelayValue' => 'link_ReviewDelay_Value',
),
),
-
+
'n-rev' => Array (
'ParentPrefix' => 'n',
'ConfigMapping' => Array (
@@ -25,43 +28,55 @@
'DefaultSorting2Field' => 'News_SortReviews2',
'DefaultSorting1Dir' => 'News_SortReviewsOrder',
'DefaultSorting2Dir' => 'News_SortReviewsOrder2',
+
+ 'ReviewDelayInterval' => 'News_ReviewDelay_Interval',
+ 'ReviewDelayValue' => 'News_ReviewDelay_Value',
),
),
-
- 'bb-rev'=> Array(
- 'ParentPrefix' => 'bb',
+
+ 'bb-rev' => Array (
+ 'ParentPrefix' => 'bb',
+
+ 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval',
+ 'ReviewDelayValue' => 'topic_ReviewDelay_Value',
),
- /*'p-rev' => Array('ParentPrefix' => 'p'),*/
+
+ 'p-rev' => Array (
+ 'ParentPrefix' => 'p',
+
+ 'ReviewDelayInterval' => 'product_ReviewDelay_Value',
+ 'ReviewDelayValue' => 'product_ReviewDelay_Interval',
+ ),
),
-
+
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'ReviewsEventHandler','file'=>'reviews_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'ReviewsTagProcessor','file'=>'reviews_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
-
+
'QueryString' => Array (
1 => 'id',
2 => 'Page',
3 => 'event',
4 => 'mode',
),
-
+
'ParentPrefix' => 'p', // replace all usage of rev to "p-rev" and then remove this param from here and Prefix too
-
+
'IDField' => 'ReviewId',
'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events
'TableName' => TABLE_PREFIX.'ItemReview',
'ParentTableKey' => 'ResourceId', // linked field in master table
'ForeignKey' => 'ItemId', // linked field in subtable
-
+
'AutoDelete' => true,
'AutoClone' => true,
-
+
'TitlePresets' => Array (
'reviews_edit' => Array('format' => "!la_title_Editing_Review!"),
),
-
+
'FilterMenu' => Array (
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array('show_active','show_pending','show_disabled'), 'type' => WHERE_FILTER),
@@ -77,13 +92,13 @@
'' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
),
-
+
'products' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
'ItemName' => 'pr.l1_Name',
'ProductId' => 'pr.ProductId',
),
-
+
'product' => Array (
'ReviewedBy' => 'IF( ISNULL(pu.Login), IF (%1$s.CreatedById = -1, \'root\', IF (%1$s.CreatedById = -2, \'Guest\', \'n/a\')), pu.Login )',
'ItemName' => 'pr.l1_Name',
@@ -123,7 +138,7 @@
'ItemType' => Array('type'=>'int','not_null'=>1,'default'=>0),
'Priority' => Array('type'=>'int','not_null'=>1,'default'=>0),
'Status' => Array('type' => 'int', 'formatter'=>'kOptionsFormatter', 'use_phrases' => 1, 'options'=>Array(1=>'la_Active',2=>'la_Pending',0=>'la_Disabled'),'not_null'=>1,'default'=>2 ),
- 'TextFormat' => Array('type'=>'int','not_null'=>1,'default'=>0),
+ 'TextFormat' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (0 => 'la_text', 1 => 'la_html'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 0),
'Module' => Array('type'=>'string','not_null'=>1,'default'=>''),
),
'VirtualFields' => Array(
Index: trunk/core/kernel/db/db_connection.php
===================================================================
diff -u -r8438 -r8441
--- trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8438)
+++ trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8441)
@@ -402,7 +402,8 @@
}
// set 2nd checkpoint: begin
if(!$isSkipTable) {
- $first_cell = count($ret) == 1 && count($ret[0]) == 1 ? current($ret[0]) : null;
+ $first_cell = count($ret) == 1 && count(current($ret)) == 1 ? current(current($ret)) : null;
+
$debugger->profileFinish('sql_'.$queryID, null, null, $this->getAffectedRows(), $first_cell);
$debugger->profilerAddTotal('sql', 'sql_'.$queryID);
}