--- /dev/null
+<?php
+namespace wcf\system\user\activity\point;
+use wcf\data\object\type\AbstractObjectTypeProcessor;
+
+/**
+ * Abstract implementation of a user activity point object processor.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.user.activity.point
+ * @category Community Framework
+ */
+abstract class AbstractUserActivityPointObjectProcessor extends AbstractObjectTypeProcessor implements IUserActivityPointObjectProcessor {
+ /**
+ * number of objects processed during one request
+ * @var integer
+ */
+ public $limit = 500;
+}
use wcf\data\like\Like;
use wcf\data\object\type\ObjectType;
use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\user\activity\point\IUserActivityPointObjectProcessor;
use wcf\system\WCF;
/**
* @subpackage system.user.activity.point
* @category Community Framework
*/
-class ReceivedLikesUserActivityPointObjectProcessor implements IUserActivityPointObjectProcessor {
- public $limit = 500;
- public $objectType = null;
-
- /**
- * Creates a new instance of ReceivedLikesUserActivityPointObjectProcessor.
- *
- * @param wcf\data\object\type\ObjectType $objectType
- */
- public function __construct(ObjectType $objectType) {
- $this->objectType = $objectType;
- }
-
+class ReceivedLikesUserActivityPointObjectProcessor extends AbstractUserActivityPointObjectProcessor {
/**
- * @see wcf\system\user\activity\point\IUserActivityPointObject::countRequests();
+ * @see wcf\system\user\activity\point\IUserActivityPointObjectProcessor::countRequests();
*/
public function countRequests() {
- $sql = "SELECT COUNT(*) AS count
+ $sql = "SELECT COUNT(*)
FROM wcf".WCF_N."_like
WHERE likeValue = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(Like::LIKE));
- $row = $statement->fetchArray();
- return ceil($row['count'] / $this->limit) + 1;
+ return ceil($statement->fetchColumn() / $this->limit) + 1;
}
/**
- * @see wcf\system\user\activity\point\IUserActivityPointObject::updateActivityPointEvents();
+ * @see wcf\system\user\activity\point\IUserActivityPointObjectProcessor::updateActivityPointEvents();
*/
public function updateActivityPointEvents($request) {
if ($request == 0) {
$sql = "DELETE FROM wcf".WCF_N."_user_activity_point_event
WHERE objectTypeID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->objectType->objectTypeID));
+ $statement->execute(array($this->objectTypeID));
}
else {
$sql = "SELECT likeID
if (empty($likeIDs)) return;
$conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add("objectTypeID = ?", array($this->objectType->objectTypeID));
+ $conditionBuilder->add("objectTypeID = ?", array($this->objectTypeID));
$conditionBuilder->add("objectID IN (?)", array($likeIDs));
// avoid problems with duplicate keys, as likes may be created in the meantime
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add("likeID IN (?)", array($likeIDs));
- // use INSERT … SELECT as this makes bulk updating easier
+
+ // use INSERT ... SELECT as this makes bulk updating easier
$sql = "INSERT INTO wcf".WCF_N."_user_activity_point_event
(userID, objectTypeID, objectID, additionalData)
SELECT objectUserID AS userID,
FROM wcf".WCF_N."_like
".$conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array_merge(array($this->objectType->objectTypeID, serialize(array())), $conditionBuilder->getParameters()));
+ $statement->execute(array_merge(array(
+ $this->objectTypeID,
+ serialize(array())
+ ), $conditionBuilder->getParameters()));
}
}
}