Index: branches/5.2.x/core/units/logs/system_logs/system_log_eh.php
===================================================================
--- branches/5.2.x/core/units/logs/system_logs/system_log_eh.php
+++ branches/5.2.x/core/units/logs/system_logs/system_log_eh.php
@@ -89,32 +89,84 @@
 	}
 
 	/**
+	 * Deletes all selected items.
+	 *
+	 * @param kEvent $event Event.
+	 *
+	 * @return void
+	 */
+	protected function OnMassDelete(kEvent $event)
+	{
+		$ids = $this->StoreSelectedIDs($event);
+		$this->clearSelectedIDs($event);
+
+		if ( !$ids ) {
+			return;
+		}
+
+		$this->deleteRecords(
+			$this->Application->getUnitOption($event->Prefix, 'IDField') . ' IN (' . implode(',', $ids) . ')'
+		);
+	}
+
+	/**
+	 * Deletes all records from table
+	 *
+	 * @param kEvent $event Event.
+	 *
+	 * @return void
+	 */
+	protected function OnDeleteAll(kEvent $event)
+	{
+		$this->deleteRecords('TRUE');
+	}
+
+	/**
 	 * [SCHEDULED TASK] Will remove old system logs
 	 *
-	 * @param kEvent $event
+	 * @param kEvent $event Event.
+	 *
 	 * @return void
-	 * @access protected
 	 */
 	protected function OnRotate(kEvent $event)
 	{
 		$rotation_interval = (int)$this->Application->ConfigValue('SystemLogRotationInterval');
 
+		// Forever.
 		if ( $rotation_interval === -1 ) {
-			// forever
 			return;
 		}
 
-		$sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
-				FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
-				WHERE ' . TIMENOW . ' - LogTimestamp > ' . $rotation_interval . '
-				LIMIT 0,50';
-		$ids = $this->Conn->GetCol($sql);
-
-		if ( $ids ) {
-			/** @var kTempTablesHandler $temp_handler */
-			$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event));
+		$this->deleteRecords('LogTimestamp < ' . strtotime('-' . $rotation_interval . ' seconds'));
+	}
+
+	/**
+	 * Deletes records & connected records by a WHERE clause.
+	 *
+	 * @param string $where_clause Where clause.
+	 *
+	 * @return void
+	 */
+	protected function deleteRecords($where_clause)
+	{
+		$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+		$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+
+		$sql = 'SELECT ' . $id_field . '
+				FROM ' . $table_name . '
+				WHERE ' . $where_clause . '
+				LIMIT 0,500';
+
+		while ( true ) {
+			$ids = $this->Conn->GetCol($sql);
+
+			if ( !$ids ) {
+				break;
+			}
 
-			$temp_handler->DeleteItems($event->Prefix, $event->Special, $ids);
+			$sql = 'DELETE FROM ' . $table_name . '
+					WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ')';
+			$this->Conn->Query($sql);
 		}
 	}