Skip to content
This repository was archived by the owner on Nov 2, 2022. It is now read-only.

Commit 5b95fa6

Browse files
committed
ny fil utils.php
1 parent 3cd751d commit 5b95fa6

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

GFDibsHook.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,13 @@ public static function addPaymentDetails($form, $lead){
595595
<tbody>
596596
<tr>
597597
<td><?php echo date('d.m.y h:i', strtotime($Transaction->date_created) ); ?></td>
598-
<td ><?php echo $Transaction->transaction_id; ?></td>
599-
<td ><?php echo $Transaction->ticket; ?></td>
600-
<td ><?php echo $Transaction->payment_type; ?></td>
601-
<td><?php echo ( ($Transaction->completed) ? __('yes', DIBS_LANG) : __('no', DIBS_LANG) ); ?></td>
602-
<td><?php echo ($Transaction->amount/100); ?> <?php echo get_option('rg_gforms_currency');?></td>
603-
<td><?php echo ( ($Transaction->paytype) ? $Transaction->paytype : '' ); ?></td>
604-
<td><?php echo ( ($Transaction->test) ? __('yes', DIBS_LANG) : __('no', DIBS_LANG) ); ?></td>
598+
<td><?php echo _is($Transaction, 'transaction_id'); ?></td>
599+
<td><?php echo _is($Transaction, 'ticket'); ?></td>
600+
<td><?php echo _is($Transaction, 'payment_type'); ?></td>
601+
<td><?php echo ( (_is($Transaction, 'completed') ) ? __('yes', DIBS_LANG) : __('no', DIBS_LANG) ); ?></td>
602+
<td><?php echo ( _is($Transaction, 'amount')/100); ?> <?php echo get_option('rg_gforms_currency');?></td>
603+
<td><?php echo _is($Transaction, 'paytype'); ?></td>
604+
<td><?php echo ( ( _is($Transaction, 'test') ) ? __('yes', DIBS_LANG) : __('no', DIBS_LANG) ); ?></td>
605605
</tr>
606606
</tbody>
607607
</table>

gravityformsdibs.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Author URI: http://mediebruket.no
99
*/
1010

11+
require_once 'utils/utils.php';
1112
require_once 'GFDibsDao.php';
1213
require_once 'GFDibsAddOn.php';
1314
require_once 'GFDibsHook.php';

utils/utils.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
if ( !function_exists('_is') ){
3+
function _is($object, $attribute, $fallback = null ){
4+
$value = $fallback;
5+
if ( is_object($object) ){
6+
if ( isset($object->$attribute) ){
7+
$value = $object->$attribute;
8+
}
9+
}
10+
else if ( is_array($object) ){
11+
12+
if ( isset($object[$attribute]) && is_array($object[$attribute]) && count($object[$attribute]) == 1 && isset($object[$attribute][0]) ){
13+
$value = $object[$attribute][0];
14+
}
15+
elseif ( isset($object[$attribute]) ){
16+
$value = $object[$attribute];
17+
}
18+
}
19+
20+
21+
if ( is_string($value) ){
22+
return trim($value);
23+
}
24+
else{
25+
// _log($value);
26+
return $value;
27+
}
28+
29+
}
30+
}

0 commit comments

Comments
 (0)