Index: branches/5.2.x/core/units/spam_reports/spam_report_tp.php
===================================================================
diff -u
--- branches/5.2.x/core/units/spam_reports/spam_report_tp.php (revision 0)
+++ branches/5.2.x/core/units/spam_reports/spam_report_tp.php (revision 14789)
@@ -0,0 +1,88 @@
+getObject();
+ /* @var $object kDBList */
+
+ $prefix = $object->GetDBField('ItemPrefix');
+
+ $url_params = Array (
+ 'm_opener' => 'd',
+ $prefix.'_mode' => 't',
+ $prefix.'_event' => 'OnEdit',
+ $prefix.'_id' => $object->GetDBField('ItemId'),
+ 'pass' => 'all,'.$prefix,
+ );
+
+ if ( $this->IsReviewReport($params) ) {
+ $edit_template = 'reviews/review_direct_edit';
+ $url_params['pass_through'] = 'item_prefix';
+ $url_params['item_prefix'] = $prefix;
+ }
+ else {
+ $edit_template = '';
+ }
+
+ return $this->Application->HREF($edit_template,'', $url_params);
+ }
+
+ /**
+ * Builds a link, to delete item, associated with this spam report
+ *
+ * @param Array $params
+ * @return string
+ */
+ function AssocItemDeleteLink($params)
+ {
+ $object =& $this->getObject();
+ /* @var $object kDBList */
+
+ $prefix = $this->getPrefixSpecial();
+
+ $url_params = Array (
+ $prefix . '_event' => 'OnDeleteAssocItem',
+ $prefix . '_id' => $object->GetID(),
+ 'pass' => 'm,'.$prefix,
+ );
+
+ return $this->Application->HREF('','', $url_params);
+ }
+
+ /**
+ * Checks, that it's review report
+ *
+ * @param Array $params
+ * @return string
+ * @access protected
+ */
+ protected function IsReviewReport($params)
+ {
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
+ return preg_match('/rev$/', $object->GetDBField('ItemPrefix'));
+ }
+}
\ No newline at end of file
Index: branches/5.2.x/core/admin_templates/spam_reports/spam_report_edit.tpl
===================================================================
diff -u
--- branches/5.2.x/core/admin_templates/spam_reports/spam_report_edit.tpl (revision 0)
+++ branches/5.2.x/core/admin_templates/spam_reports/spam_report_edit.tpl (revision 14789)
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: branches/5.2.x/core/admin_templates/spam_reports/spam_report_list.tpl
===================================================================
diff -u
--- branches/5.2.x/core/admin_templates/spam_reports/spam_report_list.tpl (revision 0)
+++ branches/5.2.x/core/admin_templates/spam_reports/spam_report_list.tpl (revision 14789)
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+ ', this.href);">
+
+
+
+
+
+
+ ()
+
+
+
+
+
+
\ No newline at end of file
Index: branches/5.2.x/core/install/install_schema.sql
===================================================================
diff -u -r14726 -r14789
--- branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14726)
+++ branches/5.2.x/core/install/install_schema.sql (.../install_schema.sql) (revision 14789)
@@ -814,6 +814,19 @@
KEY `Status` (`Status`)
);
+CREATE TABLE SpamReports (
+ ReportId int(11) NOT NULL AUTO_INCREMENT,
+ ItemPrefix varchar(255) NOT NULL,
+ ItemId int(11) NOT NULL,
+ MessageText text,
+ ReportedOn int(11) DEFAULT NULL,
+ ReportedById int(11) DEFAULT NULL,
+ PRIMARY KEY (ReportId),
+ KEY ItemPrefix (ItemPrefix),
+ KEY ItemId (ItemId),
+ KEY ReportedById (ReportedById)
+);
+
CREATE TABLE ItemTypes (
ItemType int(11) NOT NULL default '0',
Module varchar(50) NOT NULL default '',
Index: branches/5.2.x/core/units/spam_reports/spam_report_eh.php
===================================================================
diff -u
--- branches/5.2.x/core/units/spam_reports/spam_report_eh.php (revision 0)
+++ branches/5.2.x/core/units/spam_reports/spam_report_eh.php (revision 14789)
@@ -0,0 +1,140 @@
+ Array ('self' => true),
+ 'OnDeleteAssocItem' => Array ('self' => 'delete'),
+ );
+
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Checks permissions
+ *
+ * @param kEvent $event
+ */
+// function CheckPermission(&$event)
+// {
+// if ( $event->Name == 'OnNewReport' ) {
+// $perm_helper =& $this->Application->recallObject('PermissionsHelper');
+// /* @var $perm_helper kPermissionsHelper */
+//
+// return $perm_helper->finalizePermissionCheck($event, $this->Application->LoggedIn());
+// }
+//
+// return parent::CheckPermission($event);
+// }
+
+ /**
+ * Prefills missing fields
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemCreate(&$event)
+ {
+ parent::OnBeforeItemCreate($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $item_prefix = $this->Application->GetVar('item_prefix');
+ $item_id = $this->Application->GetVar($item_prefix . '_id');
+
+ if ( $item_id ) {
+ $object->SetDBField('ItemPrefix', $item_prefix);
+ $object->SetDBField('ItemId', $item_id);
+ }
+
+ $object->SetDBField('ReportedById', $this->Application->RecallVar('user_id'));
+ }
+
+ /**
+ * Send e-mail after new spam report was created
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemCreate(&$event)
+ {
+ parent::OnAfterItemCreate($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $item_prefix = $object->GetDBField('ItemPrefix');
+
+ if ( preg_match('/rev$/', $item_prefix) ) {
+ $item =& $this->Application->recallObject($item_prefix);
+ /* @var $item kDBItem */
+
+ $object->SetDBField('ItemName', $item->GetDBField('ReviewText'));
+ }
+
+ $this->Application->EmailEventAdmin('SPAM.REPORT');
+ }
+
+ /**
+ * Sends new spam report
+ *
+ * @param kEvent $event
+ */
+ function OnNewReport(&$event)
+ {
+ $ajax_form_helper =& $this->Application->recallObject('AjaxFormHelper');
+ /* @var $ajax_form_helper AjaxFormHelper */
+
+ $ajax_form_helper->transitEvent($event, 'OnCreate');
+ }
+
+ /**
+ * Deletes item, associated with given spam report
+ *
+ * @param kEvent $event
+ */
+ function OnDeleteAssocItem(&$event)
+ {
+ $temp_handlers = Array ();
+ $ids = $this->StoreSelectedIDs($event);
+
+ $object =& $event->getObject( Array ('skip_autoload' => true) );
+ /* @var $object kDBItem */
+
+ foreach ($ids as $id) {
+ $object->Load($id);
+ $item_prefix = $object->GetDBField('ItemPrefix');
+
+ if ( !isset($temp_handlers[$item_prefix]) ) {
+ $temp_handlers[$item_prefix] =& $this->Application->recallObject($item_prefix . '_TempHandler', 'kTempTablesHandler');
+ }
+
+ $temp_handlers[$item_prefix]->DeleteItems($item_prefix, '', Array ($object->GetDBField('ItemId')));
+ }
+
+ $this->clearSelectedIDs($event);
+
+ $event->SetRedirectParam('opener', 'u');
+ }
+}
\ No newline at end of file
Index: branches/5.2.x/core/install/remove_schema.sql
===================================================================
diff -u -r14671 -r14789
--- branches/5.2.x/core/install/remove_schema.sql (.../remove_schema.sql) (revision 14671)
+++ branches/5.2.x/core/install/remove_schema.sql (.../remove_schema.sql) (revision 14789)
@@ -43,6 +43,7 @@
DROP TABLE Images;
DROP TABLE ItemRating;
DROP TABLE ItemReview;
+DROP TABLE SpamReports;
DROP TABLE ItemTypes;
DROP TABLE ItemFiles;
DROP TABLE Relationship;
Index: branches/5.2.x/core/install/upgrades.sql
===================================================================
diff -u -r14745 -r14789
--- branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14745)
+++ branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 14789)
@@ -2282,3 +2282,16 @@
'lu_field_CachedDescendantCatsQty', 'lu_field_hits', 'lu_field_cachedrating', 'lu_field_cachedvotesqty',
'lu_field_cachedreviewsqty', 'lu_field_orgid'
);
+
+CREATE TABLE SpamReports (
+ ReportId int(11) NOT NULL AUTO_INCREMENT,
+ ItemPrefix varchar(255) NOT NULL,
+ ItemId int(11) NOT NULL,
+ MessageText text,
+ ReportedOn int(11) DEFAULT NULL,
+ ReportedById int(11) DEFAULT NULL,
+ PRIMARY KEY (ReportId),
+ KEY ItemPrefix (ItemPrefix),
+ KEY ItemId (ItemId),
+ KEY ReportedById (ReportedById)
+);
\ No newline at end of file
Index: branches/5.2.x/core/units/spam_reports/spam_reports_config.php
===================================================================
diff -u
--- branches/5.2.x/core/units/spam_reports/spam_reports_config.php (revision 0)
+++ branches/5.2.x/core/units/spam_reports/spam_reports_config.php (revision 14789)
@@ -0,0 +1,110 @@
+ 'spam-report',
+ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array ('class' => 'SpamReportEventHandler', 'file' => 'spam_report_eh.php', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array ('class' => 'SpamReportTagProcessor', 'file' => 'spam_report_tp.php', 'build_event' => 'OnBuild'),
+
+ 'AutoLoad' => true,
+
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'Page',
+ 3 => 'PerPage',
+ 4 => 'event',
+ 5 => 'mode',
+ ),
+
+ 'IDField' => 'ReportId',
+
+ 'TableName' => TABLE_PREFIX . 'SpamReports',
+
+ 'TitleField' => 'MessageText',
+
+ 'TitlePresets' => Array (
+ 'default' => Array (
+ 'edit_status_labels' => Array ('spam-report' => '!la_title_EditingSpamReport!'),
+ ),
+
+ 'spam_report_list' => Array (
+ 'prefixes' => Array ('spam-report_List'), 'format' => "!la_title_SpamReports!",
+ ),
+
+ 'spam_report_edit' => Array (
+ 'prefixes' => Array ('spam-report'), 'format' => "#spam-report_status# '#spam-report_titlefield#'",
+ ),
+ ),
+
+ 'PermSection' => Array('main' => 'in-portal:spam_reports'),
+
+ 'Sections' => Array (
+ 'in-portal:spam_reports' => Array (
+ 'parent' => 'in-portal:reports',
+ 'icon' => 'conf_spam_reports',
+ 'label' => 'la_title_SpamReports',
+ 'url' => Array('t' => 'spam_reports/spam_report_list', 'pass' => 'm'),
+ 'permissions' => Array('view', 'edit', 'delete'),
+ 'priority' => 8,
+ 'type' => stTREE,
+ ),
+ ),
+
+ 'ListSQLs' => Array (
+ '' => ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN ' . TABLE_PREFIX . 'PortalUser reported_by ON reported_by.PortalUserId = %1$s.ReportedById
+ LEFT JOIN ' . TABLE_PREFIX . 'ItemReview review ON review.ReviewId = %1$s.ItemId AND %1$s.ItemPrefix LIKE "%rev"',
+ ),
+
+ 'CalculatedFields' => Array (
+ '' => Array (
+ 'ItemName' => 'IF(%1$s.ItemPrefix LIKE "%rev", review.ReviewText, "")',
+ 'ReportedBy' => 'reported_by.Username',
+ ),
+ ),
+
+ 'ListSortings' => Array (
+ '' => Array (
+ 'Sorting' => Array ('ReportId' => 'desc'),
+ )
+ ),
+
+ 'Fields' => Array (
+ 'ReportId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'ItemPrefix' => Array (
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options' => Array ('p-rev' => 'la_opt_ProductReview'), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => ''
+ ),
+ 'ItemId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'MessageText' => Array ('type' => 'string', 'required' => 1, 'default' => NULL),
+ 'ReportedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'),
+ 'ReportedById' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kLEFTFormatter', 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Username', 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest',
+ 'default' => NULL
+ )
+ ),
+
+ 'VirtualFields' => Array (
+ 'ItemName' => Array ('type' => 'string', 'default' => ''),
+ 'ReportedBy' => Array ('type' => 'string', 'default' => ''),
+ ),
+
+ 'Grids' => Array (
+ 'Default' => Array (
+ 'Fields' => Array (
+ 'ReportId' => Array ('title' => 'column:la_fld_Id', 'filter_block' => 'grid_range_filter'),
+ 'ItemPrefix' => Array ('data_block' => 'grid_item_prefix_td', 'filter_block' => 'grid_options_filter', 'width' => 150),
+ 'ItemId' => Array ('filter_block' => 'grid_range_filter'),
+ 'ItemName' => Array ('data_block' => 'grid_edit_item_td', 'filter_block' => 'grid_like_filter'),
+ 'MessageText' => Array ('filter_block' => 'grid_like_filter'),
+ 'ReportedOn' => Array ('filter_block' => 'grid_date_range_filter'),
+ 'ReportedBy' => Array ('filter_block' => 'grid_like_filter'),
+ ),
+ ),
+ ),
+);
\ No newline at end of file
Index: branches/5.2.x/core/install/english.lang
===================================================================
diff -u -r14745 -r14789
--- branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14745)
+++ branches/5.2.x/core/install/english.lang (.../english.lang) (revision 14789)
@@ -24,6 +24,7 @@
Q29udGVudCBNb2Rl
RGVsZXRl
RGVsZXRl
+ ZGVsZXRlIHJldmlldw==
RGVwbG95
RGVzaWduIE1vZGU=
RG93bg==
@@ -440,6 +441,8 @@
U3lzdGVtIFRlbXBsYXRl
VXNlciBGaWVsZA==
SXRlbSBJRA==
+ SXRlbSBOYW1l
+ SXRlbSBQcmVmaXg=
SXRlbSBUZW1wbGF0ZQ==
TGFuZ3VhZ2U=
TGFuZ3VhZ2UgRmlsZQ==
@@ -543,6 +546,8 @@
UmVwbHkgRnJvbSBOYW1l
UmVwbHkgTWVzc2FnZSBTaWduYXR1cmU=
UmVwbGllZA==
+ UmVwb3J0ZWQgQnk=
+ UmVwb3J0ZWQgT24=
UmVxdWlyZWQ=
UmVxdWlyZSBMb2dpbg==
Q29tbWVudA==
@@ -1245,6 +1250,7 @@
RWRpdGluZyBQZXJtaXNzaW9uIFR5cGU=
RWRpdGluZyBTaXRlIERvbWFpbg==
RWRpdGluZyBTa2lu
+ RWRpdGluZyBTUEFNIFJlcG9ydA==
RWRpdGluZyBTcGVsbGluZyBEaWN0aW9uYXJ5
RWRpdGluZyBTdG9wIFdvcmQ=
RWRpdGluZyBTdHlsZQ==
@@ -1320,6 +1326,7 @@
U2VuZGluZyBQcmVwYXJlZCBFLW1haWxz
TWFpbCBoYXMgYmVlbiBzZW50IFN1Y2Nlc3NmdWxseQ==
U2l0ZSBEb21haW5z
+ U1BBTSBSZXBvcnRz
U3BlbGxpbmcgRGljdGlvbmFyeQ==
U3RvcCBXb3Jkcw==
U3RydWN0dXJlICYgRGF0YQ==
@@ -1368,6 +1375,8 @@
RGVjbGluZQ==
RGVsZXRl
RGVsZXRlIEFsbA==
+ RGVsZXRlIFJldmlldw==
+ RGVsZXRlIFJlcG9ydCBPbmx5
RGVueQ==
RGV0YWlscw==
RGlzYWJsZQ==
@@ -1870,4 +1879,4 @@
-
+
\ No newline at end of file