Completed
Branch 1.2 (19915c)
by Jason
02:54
created
code/controllers/FoxyStripe_Controller.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -34,6 +34,10 @@
 block discarded – undo
34 34
 		}
35 35
 	}
36 36
 	
37
+	/**
38
+	 * @param string $encrypted
39
+	 * @param string $decrypted
40
+	 */
37 41
 	public function handleDataFeed($encrypted, $decrypted){
38 42
         //handle encrypted & decrypted data
39 43
         $orders = new SimpleXMLElement($decrypted);
Please login to merge, or discard this patch.
Spacing   +68 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,9 +17,8 @@  discard block
 block discarded – undo
17 17
 	    // handle POST from FoxyCart API transaction
18 18
 		if ((isset($_POST["FoxyData"]) OR isset($_POST['FoxySubscriptionData']))) {
19 19
 			$FoxyData_encrypted = (isset($_POST["FoxyData"])) ?
20
-                urldecode($_POST["FoxyData"]) :
21
-                urldecode($_POST["FoxySubscriptionData"]);
22
-			$FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(),$FoxyData_encrypted);
20
+                urldecode($_POST["FoxyData"]) : urldecode($_POST["FoxySubscriptionData"]);
21
+			$FoxyData_decrypted = rc4crypt::decrypt(FoxyCart::getStoreKey(), $FoxyData_encrypted);
23 22
 			self::handleDataFeed($FoxyData_encrypted, $FoxyData_decrypted);
24 23
 			
25 24
 			// extend to allow for additional integrations with Datafeed
@@ -27,65 +26,63 @@  discard block
 block discarded – undo
27 26
 			
28 27
 			return 'foxy';
29 28
 			
30
-		} else {
29
+		}else {
31 30
 			
32 31
 			return "No FoxyData or FoxySubscriptionData received.";
33 32
 			
34 33
 		}
35 34
 	}
36 35
 	
37
-	public function handleDataFeed($encrypted, $decrypted){
36
+	public function handleDataFeed($encrypted, $decrypted) {
38 37
         //handle encrypted & decrypted data
39 38
         $orders = new SimpleXMLElement($decrypted);
40 39
 
41 40
 		// loop over each transaction
42 41
         foreach ($orders->transactions->transaction as $order) {
43 42
 
44
-            if(isset($order->id)) {
43
+            if (isset($order->id)) {
45 44
                 ($transaction = Order::get()->filter('Order_ID', $order->id)->First()) ?
46
-                    $transaction :
47
-                    $transaction = Order::create();
45
+                    $transaction : $transaction = Order::create();
48 46
             }
49 47
 
50 48
             // Record transaction data from FoxyCart Datafeed:
51
-            $transaction->Order_ID = (int) $order->id;
52
-            $transaction->Store_ID = (int) $order->store_id;
53
-            $transaction->StoreVersion = (string) $order->store_version;
54
-            $transaction->IsTest = (int) $order->is_test;
55
-            $transaction->IsHidden = (int) $order->is_hidden;
56
-            $transaction->DataIsFed = (int) $order->data_is_fed;
57
-            $transaction->TransactionDate = (string) $order->transaction_date;
58
-            $transaction->ProcessorResponse = (string) $order->processor_response;
59
-            $transaction->ShiptoShippingServiceDescription = (string) $order->shipto_shipping_service_description;
60
-            $transaction->ProductTotal = (float) $order->product_total;
61
-            $transaction->TaxTotal = (float) $order->tax_total;
62
-            $transaction->ShippingTotal = (float) $order->shipping_total;
63
-            $transaction->OrderTotal = (float) $order->order_total;
64
-            $transaction->PaymentGatewayType = (string) $order->payment_gateway_type;
65
-            $transaction->ReceiptURL = (string) $order->receipt_url;
66
-            $transaction->OrderStatus = (string) $order->status;
67
-            $transaction->CustomerIP = (string) $order->customer_ip;
49
+            $transaction->Order_ID = (int)$order->id;
50
+            $transaction->Store_ID = (int)$order->store_id;
51
+            $transaction->StoreVersion = (string)$order->store_version;
52
+            $transaction->IsTest = (int)$order->is_test;
53
+            $transaction->IsHidden = (int)$order->is_hidden;
54
+            $transaction->DataIsFed = (int)$order->data_is_fed;
55
+            $transaction->TransactionDate = (string)$order->transaction_date;
56
+            $transaction->ProcessorResponse = (string)$order->processor_response;
57
+            $transaction->ShiptoShippingServiceDescription = (string)$order->shipto_shipping_service_description;
58
+            $transaction->ProductTotal = (float)$order->product_total;
59
+            $transaction->TaxTotal = (float)$order->tax_total;
60
+            $transaction->ShippingTotal = (float)$order->shipping_total;
61
+            $transaction->OrderTotal = (float)$order->order_total;
62
+            $transaction->PaymentGatewayType = (string)$order->payment_gateway_type;
63
+            $transaction->ReceiptURL = (string)$order->receipt_url;
64
+            $transaction->OrderStatus = (string)$order->status;
65
+            $transaction->CustomerIP = (string)$order->customer_ip;
68 66
             $transaction->Response = $decrypted;
69 67
 
70 68
             // Customer info
71 69
             // if not a guest transaction in FoxyCart
72
-            if(isset($order->customer_email) && $order->is_anonymous == 0) {
70
+            if (isset($order->customer_email) && $order->is_anonymous == 0) {
73 71
 
74 72
                 // set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again
75 73
                 Config::inst()->update('Security', 'password_encryption_algorithm', 'none');
76 74
 
77 75
                 // if Customer is existing member, associate with current order
78 76
                 ($customer = Member::get()->filter('Email', $order->customer_email)->First()) ?
79
-                    $customer :
80
-                    $customer = Member::create();
81
-
82
-                $customer->Customer_ID = (int) $order->customer_id;
83
-                $customer->MinifraudScore = (string) $order->minifraud_score;
84
-                $customer->FirstName = (string) $order->customer_first_name;
85
-                $customer->Surname = (string) $order->customer_last_name;
86
-                $customer->Email = (string) $order->customer_email;
87
-                $customer->Password = (string) $order->customer_password;
88
-                $customer->Salt = (string) $order->customer_password_salt;
77
+                    $customer : $customer = Member::create();
78
+
79
+                $customer->Customer_ID = (int)$order->customer_id;
80
+                $customer->MinifraudScore = (string)$order->minifraud_score;
81
+                $customer->FirstName = (string)$order->customer_first_name;
82
+                $customer->Surname = (string)$order->customer_last_name;
83
+                $customer->Email = (string)$order->customer_email;
84
+                $customer->Password = (string)$order->customer_password;
85
+                $customer->Salt = (string)$order->customer_password_salt;
89 86
                 $customer->PasswordEncryption = 'none';
90 87
 
91 88
                 // record member record
@@ -98,38 +95,36 @@  discard block
 block discarded – undo
98 95
 
99 96
 			// billing address
100 97
 			($billingAddress = OrderAddress::get()->filter('OrderID', $transaction->Order_ID)->First()) ?
101
-                    $billingAddress :
102
-                    $billingAddress = OrderAddress::create();
103
-
104
-            $billingAddress->Name = $customer->FirstName . ' ' . $customer->Surname;
105
-            $billingAddress->Company = (string) $order->customer_company;
106
-            $billingAddress->Address1 = (string) $order->customer_address1;
107
-            $billingAddress->Address2 = (string) $order->customer_address2;
108
-            $billingAddress->City = (string) $order->customer_city;
109
-            $billingAddress->State = (string) $order->customer_state;
110
-            $billingAddress->PostalCode = (string) $order->customer_postal_code;
111
-            $billingAddress->Country = (string) $order->customer_country;
112
-            $billingAddress->Phone = (string) $order->customer_phone;
113
-            if($customer) $billingAddress->CustomerID = $customer->ID;
98
+                    $billingAddress : $billingAddress = OrderAddress::create();
99
+
100
+            $billingAddress->Name = $customer->FirstName.' '.$customer->Surname;
101
+            $billingAddress->Company = (string)$order->customer_company;
102
+            $billingAddress->Address1 = (string)$order->customer_address1;
103
+            $billingAddress->Address2 = (string)$order->customer_address2;
104
+            $billingAddress->City = (string)$order->customer_city;
105
+            $billingAddress->State = (string)$order->customer_state;
106
+            $billingAddress->PostalCode = (string)$order->customer_postal_code;
107
+            $billingAddress->Country = (string)$order->customer_country;
108
+            $billingAddress->Phone = (string)$order->customer_phone;
109
+            if ($customer) $billingAddress->CustomerID = $customer->ID;
114 110
 
115 111
             // record billing address
116 112
             $billingAddress->write();
117 113
 
118 114
             // shipping address
119 115
             ($shippingAddress = OrderAddress::get()->filter('OrderID', $transaction->Order_ID)->First()) ?
120
-                    $shippingAddress :
121
-                    $shippingAddress = OrderAddress::create();
122
-
123
-            $shippingAddress->Name = $customer->FirstName . ' ' . $customer->Surname;
124
-            $shippingAddress->Company = (string) $order->shipping_company;
125
-            $shippingAddress->Address1 = (string) $order->shipping_address1;
126
-            $shippingAddress->Address2 = (string) $order->shipping_address2;
127
-            $shippingAddress->City = (string) $order->shipping_city;
128
-            $shippingAddress->State = (string) $order->shipping_state;
129
-            $shippingAddress->PostalCode = (string) $order->shipping_postal_code;
130
-            $shippingAddress->Country = (string) $order->shipping_country;
131
-            $shippingAddress->Phone = (string) $order->shipping_phone;
132
-            if($customer) $shippingAddress->CustomerID = $customer->ID;
116
+                    $shippingAddress : $shippingAddress = OrderAddress::create();
117
+
118
+            $shippingAddress->Name = $customer->FirstName.' '.$customer->Surname;
119
+            $shippingAddress->Company = (string)$order->shipping_company;
120
+            $shippingAddress->Address1 = (string)$order->shipping_address1;
121
+            $shippingAddress->Address2 = (string)$order->shipping_address2;
122
+            $shippingAddress->City = (string)$order->shipping_city;
123
+            $shippingAddress->State = (string)$order->shipping_state;
124
+            $shippingAddress->PostalCode = (string)$order->shipping_postal_code;
125
+            $shippingAddress->Country = (string)$order->shipping_country;
126
+            $shippingAddress->Phone = (string)$order->shipping_phone;
127
+            if ($customer) $shippingAddress->CustomerID = $customer->ID;
133 128
 
134 129
             // record shipping address
135 130
             $shippingAddress->write();
@@ -152,17 +147,17 @@  discard block
 block discarded – undo
152 147
                 $ProductOption = OrderDetail::create();
153 148
 
154 149
                 // set Quantity
155
-                $ProductOption->Quantity = (int) $product->product_quantity;
150
+                $ProductOption->Quantity = (int)$product->product_quantity;
156 151
 
157 152
                 // set calculated price (after option modifiers)
158
-                $ProductOption->Price = (float) $product->product_price;
153
+                $ProductOption->Price = (float)$product->product_price;
159 154
 
160 155
                 // Find product via product_id custom variable
161 156
                 foreach ($product->transaction_detail_options->transaction_detail_option as $productID) {
162 157
                     if ($productID->product_option_name == 'product_id') {
163 158
 
164 159
                         $OrderProduct = ProductPage::get()
165
-                        	->filter('ID', (int) $productID->product_option_value)
160
+                        	->filter('ID', (int)$productID->product_option_value)
166 161
                             ->First();
167 162
 
168 163
 						// if product could be found, then set Option Items
@@ -175,15 +170,15 @@  discard block
 block discarded – undo
175 170
 		                    foreach ($product->transaction_detail_options->transaction_detail_option as $option) {
176 171
 		
177 172
 		                        $OptionItem = OptionItem::get()->filter(array(
178
-		                            'ProductID' => (string) $OrderProduct->ID,
179
-		                            'Title' => (string) $option->product_option_value
173
+		                            'ProductID' => (string)$OrderProduct->ID,
174
+		                            'Title' => (string)$option->product_option_value
180 175
 		                        ))->First();
181 176
 		                        
182 177
 		                        if ($OptionItem) {
183 178
 		                            $ProductOption->Options()->add($OptionItem);
184 179
 		                            
185 180
 		                            // modify product price 
186
-			                        if($priceMod = $option->price_mod) {
181
+			                        if ($priceMod = $option->price_mod) {
187 182
 				                        $ProductOption->Price += $priceMod;
188 183
 			                        }
189 184
 		                        }
@@ -215,17 +210,17 @@  discard block
 block discarded – undo
215 210
         // get current member if logged in. If not, create a 'fake' user with Customer_ID = 0
216 211
         // fake user will redirect to FC checkout, ask customer to log in
217 212
         // to do: consider a login/registration form here if not logged in
218
-        if($Member = Member::currentUser()) {
213
+        if ($Member = Member::currentUser()) {
219 214
             $Member = Member::currentUser();
220
-        } else {
215
+        }else {
221 216
             $Member = new Member();
222 217
             $Member->Customer_ID = 0;
223 218
         }
224 219
 
225
-        $auth_token = sha1($Member->Customer_ID . '|' . $timestampNew . '|' . FoxyCart::getStoreKey());
220
+        $auth_token = sha1($Member->Customer_ID.'|'.$timestampNew.'|'.FoxyCart::getStoreKey());
226 221
 
227
-        $redirect_complete = 'https://' . FoxyCart::getFoxyCartStoreName() . '.foxycart.com/checkout?fc_auth_token=' . $auth_token .
228
-            '&fcsid=' . $fcsid . '&fc_customer_id=' . $Member->Customer_ID . '&timestamp=' . $timestampNew;
222
+        $redirect_complete = 'https://'.FoxyCart::getFoxyCartStoreName().'.foxycart.com/checkout?fc_auth_token='.$auth_token.
223
+            '&fcsid='.$fcsid.'&fc_customer_id='.$Member->Customer_ID.'&timestamp='.$timestampNew;
229 224
 	
230 225
 	    $this->redirect($redirect_complete);
231 226
 
Please login to merge, or discard this patch.
code/model/foxycart.cart_validation.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -43,6 +43,9 @@
 block discarded – undo
43 43
 		self::setSecret(FoxyCart::getStoreKey());
44 44
 	}
45 45
 
46
+	/**
47
+	 * @return string
48
+	 */
46 49
 	public static function getSecret(){
47 50
 		return FoxyCart::getStoreKey();
48 51
 	}
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -30,20 +30,20 @@  discard block
 block discarded – undo
30 30
 	// protected static $cart_url = 'https://yourdomain.foxycart.com/cart';
31 31
 	protected static $cart_url;
32 32
 
33
-	public static function setCartURL($storeName = null){
33
+	public static function setCartURL($storeName = null) {
34 34
 		self::$cart_url = 'https://'.$storeName.'.faxycart.com/cart';
35 35
 	}
36 36
 
37
-	public static function setSecret($secret = null){
37
+	public static function setSecret($secret = null) {
38 38
 		self::$secret = $secret;
39 39
 	}
40 40
 
41
-	public function __construct(){
41
+	public function __construct() {
42 42
 		self::setCartURL(FoxyCart::getFoxyCartStoreName());
43 43
 		self::setSecret(FoxyCart::getStoreKey());
44 44
 	}
45 45
 
46
-	public static function getSecret(){
46
+	public static function getSecret() {
47 47
 		return FoxyCart::getStoreKey();
48 48
 	}
49 49
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 				$codes[$pair['prefix']] = $pair['value'];
108 108
 			}
109 109
 		}
110
-		if ( ! count($codes)) {
110
+		if (!count($codes)) {
111 111
 			self::$log[] = '<strong style="color:#600;">No code found</strong> for the above link.';
112 112
 			return $fail;
113 113
 		}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 		if ($output) {
133 133
 			echo self::$cart_url.'?'.$qs;
134
-		} else {
134
+		}else {
135 135
 			return self::$cart_url.'?'.$qs;
136 136
 		}
137 137
 	}
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 		if ($option_value == '--OPEN--') {
150 150
 			$hash = hash_hmac('sha256', $product_code.$option_name.$option_value, self::getSecret());
151 151
 			$value = ($urlencode) ? urlencode($option_name).'||'.$hash.'||open' : $option_name.'||'.$hash.'||open';
152
-		} else {
152
+		}else {
153 153
 			$hash = hash_hmac('sha256', $product_code.$option_name.$option_value, self::getSecret());
154 154
 			if ($method == 'name') {
155 155
 				$value = ($urlencode) ? urlencode($option_name).'||'.$hash : $option_name.'||'.$hash;
156
-			} else {
156
+			}else {
157 157
 				$value = ($urlencode) ? urlencode($option_value).'||'.$hash : $option_value.'||'.$hash;
158 158
 			}
159 159
 		}
160 160
 
161 161
 		if ($output) {
162 162
 			echo $value;
163
-		} else {
163
+		}else {
164 164
 			return $value;
165 165
 		}
166 166
 	}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 						$value[2] = ($value[2] == '') ? '--OPEN--' : $value[2];
249 249
 						if ($type[2] == 'radio') {
250 250
 							$input_signed = preg_replace('%([\'"])'.preg_quote($value[2]).'\1%', '${1}'.self::fc_hash_value($code, $name[2], $value[2], 'value', FALSE)."$1", $input);
251
-						} else {
251
+						}else {
252 252
 							$input_signed = preg_replace('%([\'"])'.$prefix.preg_quote($name[2]).'\1%', '${1}'.$prefix.self::fc_hash_value($code, $name[2], $value[2], 'name', FALSE)."$1", $input);
253 253
 						}
254 254
 						self::$log[] = '<strong>INPUT:</strong> Code: <strong>'.htmlspecialchars($prefix.$code).
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 					$count['lists']++;
268 268
 					preg_match_all('%<option [^>]*value=([\'"])(.+?)\1[^>]*>(?:.*?)</option>%i', $list[0], $options, PREG_SET_ORDER);
269 269
 					self::$log[] = '<strong>Options:</strong> <pre>'.htmlspecialchars(print_r($options, true)).'</pre>';
270
-					unset( $form_part_signed );
270
+					unset($form_part_signed);
271 271
 					foreach ($options as $option) {
272
-						if( !isset($form_part_signed) ) $form_part_signed = $list[0];
272
+						if (!isset($form_part_signed)) $form_part_signed = $list[0];
273 273
 						$option_signed = preg_replace(
274 274
 							'%'.preg_quote($option[1]).preg_quote($option[2]).preg_quote($option[1]).'%',
275 275
 							$option[1].self::fc_hash_value($code, $list[2], $option[2], 'value', FALSE).$option[1],
276 276
 							$option[0]);
277
-						$form_part_signed = str_replace($option[0], $option_signed, $form_part_signed );
277
+						$form_part_signed = str_replace($option[0], $option_signed, $form_part_signed);
278 278
 						self::$log[] = '<strong>OPTION:</strong> Code: <strong>'.htmlspecialchars($prefix.$code).
279 279
 						               '</strong> :: Name: <strong>'.htmlspecialchars($prefix.$list[2]).
280 280
 						               '</strong> :: Value: <strong>'.htmlspecialchars($option[2]).
Please login to merge, or discard this patch.
code/pages/ProductHolder.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@
 block discarded – undo
110 110
 	 * Products function.
111 111
 	 *
112 112
 	 * @access public
113
-	 * @return array
113
+	 * @return PaginatedList
114 114
 	 */
115 115
 	public function ProductList($limit = 10) {
116 116
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
 
36 36
 	);
37 37
 
38
-	public function getCMSFields(){
38
+	public function getCMSFields() {
39 39
 		$fields = parent::getCMSFields();
40 40
 
41
-		if(SiteConfig::current_site_config()->MultiGroup){
41
+		if (SiteConfig::current_site_config()->MultiGroup) {
42 42
 
43 43
 			$config = GridFieldConfig_RelationEditor::create();
44
-			if(class_exists('GridFieldManyRelationHandler')){
44
+			if (class_exists('GridFieldManyRelationHandler')) {
45 45
 				$config->addComponent(new GridFieldManyRelationHandler(), 'GridFieldPaginator');
46
-				if(class_exists('GridFieldSortableRows')) {
46
+				if (class_exists('GridFieldSortableRows')) {
47 47
 					$config->addComponent(new GridFieldSortableRows("SortOrder"), 'GridFieldManyRelationHandler');
48 48
 				}
49 49
 				$config->removeComponentsByType('GridFieldAddExistingAutocompleter');
50
-			}else{
51
-				if(class_exists('GridFieldSortableRows')) $config->addComponent(new GridFieldSortableRows("SortOrder"));
50
+			}else {
51
+				if (class_exists('GridFieldSortableRows')) $config->addComponent(new GridFieldSortableRows("SortOrder"));
52 52
 			}
53 53
 			$config->removeComponentsByType($config->getComponentByType('GridFieldAddNewButton'));
54 54
 
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function loadDescendantProductGroupIDListInto(&$idList) {
85 85
 		if ($children = $this->AllChildren()) {
86
-			foreach($children as $child) {
87
-				if(in_array($child->ID, $idList)) continue;
86
+			foreach ($children as $child) {
87
+				if (in_array($child->ID, $idList)) continue;
88 88
 
89
-				if($child instanceof ProductHolder) {
89
+				if ($child instanceof ProductHolder) {
90 90
 					$idList[] = $child->ID;
91 91
 					$child->loadDescendantProductGroupIDListInto($idList);
92 92
 				}
@@ -116,23 +116,23 @@  discard block
 block discarded – undo
116 116
 
117 117
 		$config = SiteConfig::current_site_config();
118 118
 
119
-		if($config->ProductLimit>0){
119
+		if ($config->ProductLimit > 0) {
120 120
 			$limit = $config->ProductLimit;
121 121
 		}
122 122
 
123
-		if($config->MultiGroup){
123
+		if ($config->MultiGroup) {
124 124
 			$entries = $this->Products()->sort('SortOrder');
125
-		}else{
126
-			$filter = '"ParentID" = ' . $this->ID;
125
+		}else {
126
+			$filter = '"ParentID" = '.$this->ID;
127 127
 
128 128
 			// Build a list of all IDs for ProductGroups that are children
129 129
 			$holderIDs = $this->ProductGroupIDs();
130 130
 
131 131
 			// If no ProductHolders, no ProductPages. So return false
132
-			if($holderIDs) {
132
+			if ($holderIDs) {
133 133
 				// Otherwise, do the actual query
134
-				if($filter) $filter .= ' OR ';
135
-				$filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ")";
134
+				if ($filter) $filter .= ' OR ';
135
+				$filter .= '"ParentID" IN ('.implode(',', $holderIDs).")";
136 136
 			}
137 137
 
138 138
 			$order = '"SiteTree"."Title" ASC';
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 class ProductHolder_Controller extends Page_Controller {
152 152
 
153
-	public function init(){
153
+	public function init() {
154 154
 		parent::init();
155 155
 
156 156
 	}
Please login to merge, or discard this patch.
thirdparty/rc4crypt.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param string $pwd Key to encrypt with (can be binary of hex)
33 33
 	 * @param string $data Content to be encrypted
34
-	 * @param bool $ispwdHex Key passed is in hexadecimal or not
34
+	 * @param integer $ispwdHex Key passed is in hexadecimal or not
35 35
 	 * @access public
36 36
 	 * @return string
37 37
 	 */
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param string $pwd Key to decrypt with (can be binary of hex)
78 78
 	 * @param string $data Content to be decrypted
79
-	 * @param bool $ispwdHex Key passed is in hexadecimal or not
79
+	 * @param integer $ispwdHex Key passed is in hexadecimal or not
80 80
 	 * @access public
81 81
 	 * @return string
82 82
 	 */
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 * @return string
37 37
 	 */
38
-	static function encrypt ($pwd, $data, $ispwdHex = 0)
38
+	static function encrypt($pwd, $data, $ispwdHex = 0)
39 39
 	{
40 40
 		if ($ispwdHex)
41 41
 			$pwd = @pack('H*', $pwd); // valid input, please!
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @access public
81 81
 	 * @return string
82 82
 	 */
83
-	static function decrypt ($pwd, $data, $ispwdHex = 0)
83
+	static function decrypt($pwd, $data, $ispwdHex = 0)
84 84
 	{
85 85
 		return self::encrypt($pwd, $data, $ispwdHex);
86 86
 	}
Please login to merge, or discard this patch.
code/model/FoxyCart.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,43 +9,43 @@  discard block
 block discarded – undo
9 9
 
10 10
 	private static $keyPrefix = 'dYnm1c';
11 11
 
12
-	public static function setStoreKey($length = 54, $count = 0){
12
+	public static function setStoreKey($length = 54, $count = 0) {
13 13
 		$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.strtotime('now');
14 14
 		$strLength = strlen($charset);
15 15
 		$str = '';
16
-		while($count < $length){
17
-			$str .= $charset[mt_rand(0, $strLength-1)];
16
+		while ($count < $length) {
17
+			$str .= $charset[mt_rand(0, $strLength - 1)];
18 18
 			$count++;
19 19
 		}
20
-		return self::getKeyPrefix().substr(base64_encode($str),0,$length);
20
+		return self::getKeyPrefix().substr(base64_encode($str), 0, $length);
21 21
 	}
22 22
 
23
-	public static function getStoreKey(){
23
+	public static function getStoreKey() {
24 24
 		$config = SiteConfig::current_site_config();
25
-		if($config->StoreKey){
25
+		if ($config->StoreKey) {
26 26
 			return $config->StoreKey;
27 27
 		}
28 28
 		return null;
29 29
 	}
30 30
 
31
-	public static function store_name_warning(){
31
+	public static function store_name_warning() {
32 32
 		$warning = null;
33
-		if(self::getFoxyCartStoreName()===null){
33
+		if (self::getFoxyCartStoreName() === null) {
34 34
 			$warning = 'Must define FoxyCart Store Name in your site settings in the cms';
35 35
 		}
36 36
 		return $warning;
37 37
 	}
38 38
 
39
-	public static function getFoxyCartStoreName(){
39
+	public static function getFoxyCartStoreName() {
40 40
 		$config = SiteConfig::current_site_config();
41
-		if($config->StoreName){
41
+		if ($config->StoreName) {
42 42
 			return $config->StoreName;
43 43
 		}
44 44
 		return null;
45 45
 	}
46 46
 
47 47
 	public static function FormActionURL() {
48
-		return sprintf('https://%s.foxycart.com/cart', self::getFoxyCartStoreName() );
48
+		return sprintf('https://%s.foxycart.com/cart', self::getFoxyCartStoreName());
49 49
 	}
50 50
 
51 51
     /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $foxyData["api_token"] = FoxyCart::getStoreKey();
60 60
 
61 61
         $ch = curl_init();
62
-        curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api");
62
+        curl_setopt($ch, CURLOPT_URL, "https://".$foxy_domain."/api");
63 63
         curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData);
64 64
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
65 65
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         // The following if block will print any CURL errors you might have
72 72
         if ($response == false) {
73 73
             //trigger_error("Could not connect to FoxyCart API", E_USER_ERROR);
74
-            SS_Log::log("Could not connect to FoxyCart API: " . $response, SS_Log::ERR);
74
+            SS_Log::log("Could not connect to FoxyCart API: ".$response, SS_Log::ERR);
75 75
         }
76 76
         curl_close($ch);
77 77
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
     public static function putCustomer($Member = null) {
98 98
         // throw error if no $Member Object
99
-        if (!isset($Member)) ;//trigger_error('No Member set', E_USER_ERROR);
99
+        if (!isset($Member)); //trigger_error('No Member set', E_USER_ERROR);
100 100
 
101 101
         // send updated customer record from API
102 102
         $foxyData = array();
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         return self::getAPIRequest($foxyData);
113 113
     }
114 114
 
115
-	public static function getKeyPrefix(){
115
+	public static function getKeyPrefix() {
116 116
 		return self::$keyPrefix;
117 117
 	}
118 118
 
Please login to merge, or discard this patch.
code/objects/OrderDetail.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         'Price.Nice'
27 27
     );
28 28
 
29
-	public function getCMSFields(){
29
+	public function getCMSFields() {
30 30
 		$fields = parent::getCMSFields();
31 31
 
32 32
         $fields->addFieldsToTab('Root.Options', array(
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		return $fields;
38 38
 	}
39 39
 
40
-	public function validate(){
40
+	public function validate() {
41 41
 		$result = parent::validate();
42 42
 
43 43
 		/*if($this->Country == 'DE' && $this->Postcode && strlen($this->Postcode) != 5) {
Please login to merge, or discard this patch.
code/objects/ProductImage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-class ProductImage extends DataObject{
8
+class ProductImage extends DataObject {
9 9
 
10 10
 	private static $db = array(
11 11
 		'Title' => 'Text',
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		'Title' => 'Caption'
25 25
 	);
26 26
 
27
-	public function getCMSFields(){
27
+	public function getCMSFields() {
28 28
 		$fields = FieldList::create(
29 29
             TextField::create('Title')
30 30
                 ->setTitle(_t('ProductImage.Title', 'Product Image Title')),
Please login to merge, or discard this patch.
code/objects/Order.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class Order extends DataObject implements PermissionProvider{
3
+class Order extends DataObject implements PermissionProvider {
4 4
 
5 5
 	private static $db = array(
6 6
         'Order_ID' => 'Int',
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
         return $this->getReceiptLink();
92 92
     }
93 93
 
94
-    function getReceiptLink(){
95
-        $obj= HTMLVarchar::create();
96
-        $obj->setValue('<a href="' . $this->ReceiptURL . '" target="_blank" class="cms-panel-link action external-link">view</a>');
94
+    function getReceiptLink() {
95
+        $obj = HTMLVarchar::create();
96
+        $obj->setValue('<a href="'.$this->ReceiptURL.'" target="_blank" class="cms-panel-link action external-link">view</a>');
97 97
         return $obj;
98 98
     }
99 99
 
Please login to merge, or discard this patch.
code/objects/OptionGroup.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-class OptionGroup extends DataObject{
8
+class OptionGroup extends DataObject {
9 9
 
10 10
 	private static $db = array(
11 11
 		'Title' => 'Varchar(100)'
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	private static $plural_name = 'Product Option Groups';
16 16
 	private static $description = 'Groups of product options, e.g. size, color, etc';
17 17
 
18
-	function getCMSFields(){
18
+	function getCMSFields() {
19 19
 
20 20
 		$fields = parent::getCMSFields();
21 21
 
@@ -27,22 +27,22 @@  discard block
 block discarded – undo
27 27
 	public function requireDefaultRecords() {
28 28
 		parent::requireDefaultRecords();
29 29
 		// create a catch-all group
30
-		if(!OptionGroup::get()->filter(array('Title' => 'Options'))->first()) {
30
+		if (!OptionGroup::get()->filter(array('Title' => 'Options'))->first()) {
31 31
 			$do = new OptionGroup();
32 32
 			$do->Title = "Options";
33 33
 			$do->write();
34 34
 		}
35
-		if(!OptionGroup::get()->filter(array('Title' => 'Size'))->first()) {
35
+		if (!OptionGroup::get()->filter(array('Title' => 'Size'))->first()) {
36 36
             $do = new OptionGroup();
37 37
             $do->Title = "Size";
38 38
             $do->write();
39 39
         }
40
-        if(!OptionGroup::get()->filter(array('Title' => 'Color'))->first()) {
40
+        if (!OptionGroup::get()->filter(array('Title' => 'Color'))->first()) {
41 41
             $do = new OptionGroup();
42 42
             $do->Title = "Color";
43 43
             $do->write();
44 44
         }
45
-        if(!OptionGroup::get()->filter(array('Title' => 'Type'))->first()) {
45
+        if (!OptionGroup::get()->filter(array('Title' => 'Type'))->first()) {
46 46
             $do = new OptionGroup();
47 47
             $do->Title = "Type";
48 48
             $do->write();
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
 		return new RequiredFields(array('Title'));
54 54
 	}
55 55
 
56
-	public function validate(){
56
+	public function validate() {
57 57
 		$result = parent::validate();
58 58
 
59 59
 		$title = $this->Title;
60 60
 		$firstChar = substr($title, 0, 1);
61
-		if(preg_match('/[^a-zA-Z]/', $firstChar)){
61
+		if (preg_match('/[^a-zA-Z]/', $firstChar)) {
62 62
 			$result->error('The first character of the Title can only be a letter', 'bad');
63 63
 		}
64
-		if(preg_match('/[^a-zA-Z]\s/', $title)){
64
+		if (preg_match('/[^a-zA-Z]\s/', $title)) {
65 65
 			$result->error('Please only use letters, numbers and spaces in the title', 'bad');
66 66
 		}
67 67
 
68 68
 		return $result;
69 69
 	}
70 70
 
71
-	public function onBeforeDelete(){
71
+	public function onBeforeDelete() {
72 72
 		parent::onBeforeDelete();
73 73
 
74 74
 		//make sure that if we delete this option group, we reassign the group's option items to the 'None' group.
75 75
 		$items = OptionItem::get()->filter(array('ProductOptionGroupID' => $this->ID));
76 76
 
77
-		if(isset($items)){
77
+		if (isset($items)) {
78 78
 			$noneGroup = OptionGroup::get()->filter(array('Title' => 'Options'))->first();
79
-			foreach($items as $item){
79
+			foreach ($items as $item) {
80 80
 				$item->ProductOptionGroupID = $noneGroup->ID;
81 81
 				$item->write();
82 82
 			}
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	public function canEdit($member = null) {
91
-		switch($this->Title){
91
+		switch ($this->Title) {
92 92
 			case 'Options':
93 93
 				return false;
94 94
 				break;
Please login to merge, or discard this patch.