| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* @name ebay_bewertungsmodul.functions.includes.php
|
|
|
4 |
* @description This file includes the functions for '../ebay_bewertungsmodul.php'.
|
|
|
5 |
*
|
|
|
6 |
* @author Patrick Lautsch
|
|
|
7 |
* @copyright 2011 Webagentur Niewerth
|
|
|
8 |
* @package Content-management
|
|
|
9 |
* @version
|
|
|
10 |
* @license propietary
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* Setzt eine Positive Bewertung bei eBay.
|
|
|
16 |
*
|
|
|
17 |
* @param array
|
|
|
18 |
* @param EbatNs_ServiceProxy-Object
|
|
|
19 |
* @return array
|
|
|
20 |
*
|
|
|
21 |
*/
|
|
|
22 |
function leaveFeedback($positveBewertungen, $sp)
|
|
|
23 |
{
|
|
|
24 |
for ( $i=0; $i<count($positveBewertungen); $i++ )
|
|
|
25 |
{
|
|
|
26 |
$req = new LeaveFeedbackRequestType();
|
|
|
27 |
|
|
|
28 |
$req->ItemID = $positveBewertungen[$i]['ItemID'];
|
|
|
29 |
$req->CommentText = getCommentText();
|
|
|
30 |
$req->CommentType = 'Positive';
|
|
|
31 |
$req->TransactionID = $positveBewertungen[$i]['TransactionID'];
|
|
|
32 |
$req->TargetUser = $positveBewertungen[$i]['UserID'];
|
|
|
33 |
|
|
|
34 |
//$res = $sp->LeaveFeedback($req);
|
|
|
35 |
//errorDetection($res);
|
|
|
36 |
setFeedbackInDB( $req->ItemID, $req->TransactionID, $req->CommentText, $req->CommentType );
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Setzt in der Datenbank den abgegebnen Kommentar
|
|
|
42 |
*
|
|
|
43 |
* @param int
|
|
|
44 |
* @param int
|
|
|
45 |
* @param string
|
|
|
46 |
* @param string
|
|
|
47 |
*
|
|
|
48 |
*/
|
|
|
49 |
function setFeedbackInDB( $ItemID, $TransactionID, $CommentText, $CommentType )
|
|
|
50 |
{
|
|
|
51 |
// Parameter korrekt?
|
|
|
52 |
if ( empty( $ItemID ) || empty( $TransactionID ) || empty( $CommentText ) || empty( $CommentType ) )
|
|
|
53 |
die();
|
|
|
54 |
|
|
|
55 |
// QUERY: Setzte in der Datenbank den Kommentar und den Kommentar Typ.
|
|
|
56 |
// Die Identifikation der Transaction findet über das "Paar" $ItemID und $Tran$TransactionID statt.
|
|
|
57 |
$sql = '
|
|
|
58 |
INSERT INTO
|
|
|
59 |
eBay_Feedback
|
|
|
60 |
(ItemID, TransactionID, CommentText, CommentType, FeedbackReceivedCommentType)
|
|
|
61 |
VALUES
|
|
|
62 |
("'.$ItemID.'", "'.$TransactionID.'", "'.$CommentText.'", "'.$CommentType.'", "Positive")
|
|
|
63 |
';
|
|
|
64 |
mysql_query( $sql ) or die( mail("info@weban.de", "eBay-Bewertungsmodul Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* Holt per Zufall einen Bewertungstext aus der Datenbank
|
|
|
69 |
*
|
|
|
70 |
* @return string
|
|
|
71 |
*/
|
|
|
72 |
function getCommentText()
|
|
|
73 |
{
|
|
|
74 |
// QUERY: Hole aus der Tabelle eBay_settings,
|
|
|
75 |
// alle Kommentare die eine ID haben die >=179 und <= 199 ist.
|
|
|
76 |
$sql = '
|
|
|
77 |
SELECT
|
|
|
78 |
Inhalt AS feedback
|
|
|
79 |
FROM
|
|
|
80 |
eBay_settings
|
|
|
81 |
WHERE
|
|
|
82 |
(ID BETWEEN 179 AND 199)
|
|
|
83 |
AND Inhalt != ""
|
|
|
84 |
AND shops_id = '.$_GET['shops_id'].'
|
|
|
85 |
';
|
|
|
86 |
$result = mysql_query( $sql ) or die( mail("info@weban.de", "eBay-Bewertungsmodul Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
87 |
$i=0;
|
|
|
88 |
while ( $row = mysql_fetch_assoc($result) )
|
|
|
89 |
{
|
|
|
90 |
$feedback_array[$i] = $row['feedback'];
|
|
|
91 |
$i++;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
// Anzahl der Zufallszahlen ist die Anzahl der abgefragten Kommentare
|
|
|
95 |
$zufallszahl = rand( 0, ($i-1) );
|
|
|
96 |
|
|
|
97 |
// Auswahl eines Kommentars auf Basis der Zufallszahl
|
|
|
98 |
$feedback = $feedback_array[$zufallszahl];
|
|
|
99 |
|
|
|
100 |
// Rückgabe des Kommentars
|
|
|
101 |
return $feedback;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
/**
|
|
|
105 |
* Returns the Path of the 'ConfDatei', which is needed for the constructor of the
|
|
|
106 |
* 'EbatNs_Session'-Class
|
|
|
107 |
*
|
|
|
108 |
* @param int
|
|
|
109 |
* @return string
|
|
|
110 |
**/
|
|
|
111 |
function getConfDateiPath($shops_id)
|
|
|
112 |
{
|
|
|
113 |
// Param. correct?
|
|
|
114 |
if ( !is_int($shops_id) || $shops_id == 0 )
|
|
|
115 |
{
|
|
|
116 |
die('getConfDateiPath(): Variable \'shops_id\' is not int.');
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
// the select-statement to get the path of the 'confDatei'
|
|
|
120 |
$sql = "
|
|
|
121 |
SELECT
|
|
|
122 |
Inhalt
|
|
|
123 |
FROM
|
|
|
124 |
eBay_settings
|
|
|
125 |
WHERE
|
|
|
126 |
Typ = 'confDatei'
|
|
|
127 |
AND shops_id = '" . $shops_id . "'
|
|
|
128 |
";
|
|
|
129 |
|
|
|
130 |
// execute the query
|
|
|
131 |
$result = mysql_query( $sql ) or die( mail("info@weban.de", "eBay-Bewertungsmodul Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
132 |
|
|
|
133 |
// create an asso. array of the result
|
|
|
134 |
$row = mysql_fetch_assoc( $result );
|
|
|
135 |
|
|
|
136 |
// return the path of the 'confDatei'
|
|
|
137 |
return (string)$row['Inhalt'];
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
/**
|
|
|
141 |
* Überprüft die "Response" auf Fehler
|
|
|
142 |
*
|
|
|
143 |
* @param mixed-Object
|
|
|
144 |
**/
|
|
|
145 |
function errorDetection($res)
|
|
|
146 |
{
|
|
|
147 |
if (!isset($res)) die ('errorDetection: $res wurde nicht gesetzt!');
|
|
|
148 |
|
|
|
149 |
if ( !($res->getAck() == 'Success') )
|
|
|
150 |
{
|
|
|
151 |
foreach ($res->getErrors() as $error)
|
|
|
152 |
{
|
|
|
153 |
die("#" . $error->getErrorCode() . " " . htmlentities($error->getShortMessage()) . "/" . htmlentities($error->getLongMessage()) . "<br>");
|
|
|
154 |
}
|
|
|
155 |
}
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
/**
|
|
|
159 |
* Holt das Transaktions-Array.
|
|
|
160 |
*
|
|
|
161 |
* @param object
|
|
|
162 |
* @return object
|
|
|
163 |
*/
|
|
|
164 |
function getTransactionArray($res)
|
|
|
165 |
{
|
|
|
166 |
return $res->ItemsAwaitingFeedback->TransactionArray;
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
/**
|
|
|
170 |
* Holt alle Positven Bewertungen aus dem Transaktions-Array,
|
|
|
171 |
* in dem kein 'Seller' existiert (Nur Käufer werden bewertet, nicht Verkäufer!)
|
|
|
172 |
* Des Weiteren erstellt diese Funktion einen Eintrag in 'eBay_Feedback',
|
|
|
173 |
* wenn der Kommentar des Käufers nicht positiv ist.
|
|
|
174 |
*
|
|
|
175 |
* @param array
|
|
|
176 |
* @return array
|
|
|
177 |
*/
|
|
|
178 |
function getTransactionWithPositiveFeedback($transactionArray)
|
|
|
179 |
{
|
|
|
180 |
$i = 0;
|
|
|
181 |
foreach ($transactionArray as $taa)
|
|
|
182 |
{
|
|
|
183 |
if ( $taa->FeedbackReceived->CommentType == 'Positive' && !isset($taa->Item->Seller) )
|
|
|
184 |
{
|
|
|
185 |
$transaction[$i]['ItemID'] = $taa->Item->ItemID;
|
|
|
186 |
$transaction[$i]['TransactionID'] = $taa->TransactionID;
|
|
|
187 |
$transaction[$i]['UserID'] = $taa->Buyer->UserID;
|
|
|
188 |
$i++;
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
if ( ($taa->FeedbackReceived->CommentType == 'Neutral' || $taa->FeedbackReceived->CommentType == 'Negative') && !isset($taa->Item->Seller) )
|
|
|
192 |
{
|
|
|
193 |
$sql = '
|
|
|
194 |
INSERT INTO
|
|
|
195 |
eBay_Feedback
|
|
|
196 |
(
|
|
|
197 |
ItemID,
|
|
|
198 |
TransactionID,
|
|
|
199 |
FeedbackReceivedCommentType
|
|
|
200 |
)
|
|
|
201 |
VALUES
|
|
|
202 |
(
|
|
|
203 |
'.$taa->Item->ItemID.',
|
|
|
204 |
'.$taa->TransactionID.',
|
|
|
205 |
"'.$taa->FeedbackReceived->CommentType.'"
|
|
|
206 |
)
|
|
|
207 |
';
|
|
|
208 |
|
|
|
209 |
// execute the query
|
|
|
210 |
$result = mysql_query( $sql ) or die( mail("info@weban.de", "eBay-Bewertungsmodul Fehler", mysql_errno() . ': ' . mysql_error() . '<hr />' . $sql) );
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
return $transaction;
|
|
|
215 |
}
|
|
|
216 |
?>
|