c9503b9f46908a69375987fda17fc4c5cf7fa39f
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\data\paid\subscription\transaction\log;
3 use wcf\data\DatabaseObject;
4 use wcf\data\object\type\ObjectTypeCache;
5 use wcf\data\paid\subscription\PaidSubscription;
6 use wcf\data\user\User;
7 use wcf\system\WCF;
8
9 /**
10 * Represents a paid subscription transaction log entry.
11 *
12 * @author Marcel Werk
13 * @copyright 2001-2014 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package com.woltlab.wcf
16 * @subpackage data.paid.subscription.transaction.log
17 * @category Community Framework
18 */
19 class PaidSubscriptionTransactionLog extends DatabaseObject {
20 /**
21 * @see \wcf\data\DatabaseObject::$databaseTableName
22 */
23 protected static $databaseTableName = 'paid_subscription_transaction_log';
24
25 /**
26 * @see \wcf\data\DatabaseObject::$databaseIndexName
27 */
28 protected static $databaseTableIndexName = 'logID';
29
30 /**
31 * user object
32 * @var \wcf\data\user\User
33 */
34 protected $user = null;
35
36 /**
37 * paid subscription object
38 * @var \wcf\data\paid\subscription\PaidSubscription
39 */
40 protected $subscription = null;
41
42 /**
43 * Returns the payment method of this transaction.
44 *
45 * @return string
46 */
47 public function getPaymentMethodName() {
48 $objectType = ObjectTypeCache::getInstance()->getObjectType($this->paymentMethodObjectTypeID);
49 return $objectType->objectType;
50 }
51
52 /**
53 * Returns transaction details.
54 *
55 * @return array
56 */
57 public function getTransactionDetails() {
58 return unserialize($this->transactionDetails);
59 }
60
61 /**
62 * Returns the user of this transaction.
63 *
64 * @return \wcf\data\user\User
65 */
66 public function getUser() {
67 if ($this->user === null) {
68 $this->user = new User($this->userID);
69 }
70
71 return $this->user;
72 }
73
74 /**
75 * Returns the paid subscription of this transaction.
76 *
77 * @return \wcf\data\paid\subscription\PaidSubscription
78 */
79 public function getSubscription() {
80 if ($this->subscription === null) {
81 $this->subscription = new PaidSubscription($this->subscriptionID);
82 }
83
84 return $this->subscription;
85 }
86
87 /**
88 * Gets a transaction log entry by transaction id.
89 *
90 * @param integer $paymentMethodObjectTypeID
91 * @param string $transactionID
92 * @return \wcf\data\paid\subscription\transaction\log\PaidSubscriptionTransactionLog
93 */
94 public static function getLogByTransactionID($paymentMethodObjectTypeID, $transactionID) {
95 $sql = "SELECT *
96 FROM wcf".WCF_N."_paid_subscription_transaction_log
97 WHERE paymentMethodObjectTypeID = ?
98 AND transactionID = ?";
99 $statement = WCF::getDB()->prepareStatement($sql);
100 $statement->execute(array($paymentMethodObjectTypeID, $transactionID));
101 $row = $statement->fetchArray();
102 if ($row !== false) {
103 return new PaidSubscriptionTransactionLog(null, $row);
104 }
105
106 return null;
107 }
108 }