<name>com.woltlab.wcf.user</name>
<definitionname>com.woltlab.wcf.rebuildData</definitionname>
<classname><![CDATA[wcf\system\worker\UserRebuildDataWorker]]></classname>
+ <nicevalue>70</nicevalue>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.like</name>
+ <definitionname>com.woltlab.wcf.rebuildData</definitionname>
+ <classname><![CDATA[wcf\system\worker\LikeRebuildDataWorker]]></classname>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.attachment</name>
+ <definitionname>com.woltlab.wcf.rebuildData</definitionname>
+ <classname><![CDATA[wcf\system\worker\AttachmentRebuildDataWorker]]></classname>
+ <nicevalue>100</nicevalue>
</type>
<!-- /rebuild data workers -->
</import>
// get object types
$this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.rebuildData');
- // @todo: sort object types
+ // sort object types
+ uasort($this->objectTypes, function ($a, $b) {
+ $niceValueA = ($a->nicevalue ?: 0);
+ $niceValueB = ($b->nicevalue ?: 0);
+
+ if ($niceValueA < $niceValueB) {
+ return -1;
+ }
+ else if ($niceValueA > $niceValueB) {
+ return 1;
+ }
+
+ return 0;
+ });
}
/**
}
else {
return strcmp($listenerA['listenerClassName'], $listenerB['listenerClassName']);
- }
+ }
}
}
$progress = (($this->limit * ($this->loopCount + 1)) / $this->count) * 100;
if ($progress > 100) $progress = 100;
- return floor($progress, 0);
+ return floor($progress);
}
/**
--- /dev/null
+<?php
+namespace wcf\system\worker;
+use wcf\data\attachment\AttachmentAction;
+
+/**
+ * Worker implementation for updating attachments.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.worker
+ * @category Community Framework
+ */
+class AttachmentRebuildDataWorker extends AbstractRebuildDataWorker {
+ /**
+ * @see wcf\system\worker\AbstractRebuildDataWorker::$objectListClassName
+ */
+ protected $objectListClassName = 'wcf\data\attachment\AttachmentList';
+
+ /**
+ * @see wcf\system\worker\AbstractWorker::$limit
+ */
+ protected $limit = 50;
+
+ /**
+ * @see wcf\system\worker\AbstractRebuildDataWorker::initObjectList
+ */
+ protected function initObjectList() {
+ parent::initObjectList();
+
+ $this->objectList->sqlOrderBy = 'attachment.attachmentID';
+ $this->objectList->getConditionBuilder()->add('attachment.isImage = ?', array(1));
+ }
+
+ /**
+ * @see wcf\system\worker\IWorker::execute()
+ */
+ public function execute() {
+ parent::execute();
+
+ $action = new AttachmentAction($this->objectList->getObjects(), 'generateThumbnails');
+ $action->executeAction();
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\worker;
+use wcf\system\user\activity\point\UserActivityPointHandler;
+
+/**
+ * Worker implementation for updating likes.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.worker
+ * @category Community Framework
+ */
+class LikeRebuildDataWorker extends AbstractRebuildDataWorker {
+ /**
+ * @see wcf\system\worker\AbstractRebuildDataWorker::$objectListClassName
+ */
+ protected $objectListClassName = 'wcf\data\like\LikeList';
+
+ /**
+ * @see wcf\system\worker\AbstractWorker::$limit
+ */
+ protected $limit = 1000;
+
+ /**
+ * @see wcf\system\worker\AbstractRebuildDataWorker::initObjectList
+ */
+ protected function initObjectList() {
+ parent::initObjectList();
+
+ $this->objectList->sqlOrderBy = 'like_table.likeID';
+ $this->objectList->getConditionBuilder()->add('like_table.objectUserID IS NOT NULL');
+ }
+
+ /**
+ * @see wcf\system\worker\IWorker::execute()
+ */
+ public function execute() {
+ parent::execute();
+
+ if (!$this->loopCount) {
+ // reset activity points
+ UserActivityPointHandler::getInstance()->reset('com.woltlab.wcf.like.activityPointEvent.receivedLikes');
+ }
+
+ $itemsToUser = array();
+ foreach ($this->objectList as $like) {
+ if (!isset($itemsToUser[$like->objectUserID])) {
+ $itemsToUser[$like->objectUserID] = 0;
+ }
+
+ $itemsToUser[$like->objectUserID]++;
+ }
+
+ // update activity points
+ UserActivityPointHandler::getInstance()->fireEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $itemsToUser, false);
+ }
+}