public static function handle_gateways_panel()
    {
        global $action, $page, $EM_Gateways, $EM_Pro;
        wp_reset_vars(array('action', 'page'));
        switch (addslashes($action)) {
            case 'edit':
                if (isset($EM_Gateways[addslashes($_GET['gateway'])])) {
                    $EM_Gateways[addslashes($_GET['gateway'])]->settings();
                }
                return;
                // so we don't show the list below
                break;
            case 'transactions':
                if (isset($EM_Gateways[addslashes($_GET['gateway'])])) {
                    global $EM_Gateways_Transactions;
                    $EM_Gateways_Transactions->output();
                }
                return;
                // so we don't show the list below
                break;
        }
        $messages = array();
        $messages[1] = __('Gateway activated.', 'em-pro');
        $messages[2] = __('Gateway not activated.', 'em-pro');
        $messages[3] = __('Gateway deactivated.', 'em-pro');
        $messages[4] = __('Gateway not deactivated.', 'em-pro');
        $messages[5] = __('Gateway activation toggled.', 'em-pro');
        ?>
		<div class='wrap'>
			<div class="icon32" id="icon-plugins"><br></div>
			<h2><?php 
        _e('Edit Gateways', 'em-pro');
        ?>
</h2>
			<?php 
        if (isset($_GET['msg']) && !empty($messages[$_GET['msg']])) {
            echo '<div id="message" class="updated fade"><p>' . $messages[$_GET['msg']] . '</p></div>';
        }
        ?>
			<form method="post" action="" id="posts-filter">
				<div class="tablenav">
					<div class="alignleft actions">
						<select name="action">
							<option selected="selected" value=""><?php 
        _e('Bulk Actions');
        ?>
</option>
							<option value="toggle"><?php 
        _e('Toggle activation');
        ?>
</option>
						</select>
						<input type="submit" class="button-secondary action" value="<?php 
        _e('Apply', 'em-pro');
        ?>
">		
					</div>		
					<div class="alignright actions"></div>		
					<br class="clear">
				</div>	
				<div class="clear"></div>	
				<?php 
        wp_original_referer_field(true, 'previous');
        wp_nonce_field('emp-gateways');
        $columns = array("name" => __('Gateway Name', 'em-pro'), "active" => __('Active', 'em-pro'), "transactions" => __('Transactions', 'em-pro'));
        $columns = apply_filters('em_gateways_columns', $columns);
        $gateways = EM_Gateways::gateways_list();
        $active = EM_Gateways::active_gateways();
        ?>
	
				<table class="widefat fixed">
					<thead>
					<tr>
					<th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th>
						<?php 
        foreach ($columns as $key => $col) {
            ?>
							<th style="" class="manage-column column-<?php 
            echo $key;
            ?>
" id="<?php 
            echo $key;
            ?>
" scope="col"><?php 
            echo $col;
            ?>
</th>
							<?php 
        }
        ?>
					</tr>
					</thead>	
					<tfoot>
					<tr>
					<th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th>
						<?php 
        reset($columns);
        foreach ($columns as $key => $col) {
            ?>
							<th style="" class="manage-column column-<?php 
            echo $key;
            ?>
" id="<?php 
            echo $key;
            ?>
" scope="col"><?php 
            echo $col;
            ?>
</th>
							<?php 
        }
        ?>
					</tr>
					</tfoot>
					<tbody>
						<?php 
        if ($gateways) {
            foreach ($gateways as $key => $gateway) {
                if (!isset($EM_Gateways[$key])) {
                    continue;
                }
                $EM_Gateway = $EM_Gateways[$key];
                /* @var $EM_Gateway EM_Gateway */
                ?>
								<tr valign="middle" class="alternate">
									<th class="check-column" scope="row"><input type="checkbox" value="<?php 
                echo esc_attr($key);
                ?>
" name="gateways[]"></th>
									<td class="column-name">
										<strong><a title="Edit <?php 
                echo esc_attr($gateway);
                ?>
" href="<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=<?php 
                echo $page;
                ?>
&amp;action=edit&amp;gateway=<?php 
                echo $key;
                ?>
" class="row-title"><?php 
                echo esc_html($gateway);
                ?>
</a></strong>
										<?php 
                //Check if Multi-Booking Ready
                if (get_option('dbem_multiple_bookings') && !$EM_Gateway->supports_multiple_bookings) {
                    echo '<br/><em>' . __('This gateway cannot be activated because it does not support multiple bookings mode.', 'em-pro') . '</em>';
                }
                $actions = array();
                $actions['edit'] = "<span class='edit'><a href='" . EM_ADMIN_URL . "&amp;page=" . $page . "&amp;action=edit&amp;gateway=" . $key . "'>" . __('Settings') . "</a></span>";
                if (array_key_exists($key, $active)) {
                    $actions['toggle'] = "<span class='edit activate'><a href='" . wp_nonce_url(EM_ADMIN_URL . "&amp;page=" . $page . "&amp;action=deactivate&amp;gateway=" . $key . "", 'toggle-gateway_' . $key) . "'>" . __('Deactivate') . "</a></span>";
                } else {
                    if (!get_option('dbem_multiple_bookings') || get_option('dbem_multiple_bookings') && $EM_Gateway->supports_multiple_bookings) {
                        $actions['toggle'] = "<span class='edit deactivate'><a href='" . wp_nonce_url(EM_ADMIN_URL . "&amp;page=" . $page . "&amp;action=activate&amp;gateway=" . $key . "", 'toggle-gateway_' . $key) . "'>" . __('Activate') . "</a></span>";
                    }
                }
                ?>
										<br><div class="row-actions"><?php 
                echo implode(" | ", $actions);
                ?>
</div>
										</td>
									<td class="column-active">
										<?php 
                if (array_key_exists($key, $active)) {
                    echo "<strong>" . __('Active', 'em-pro') . "</strong>";
                } else {
                    echo __('Inactive', 'em-pro');
                }
                ?>
									</td>
									<td class="column-transactions">
										<a href='<?php 
                echo EM_ADMIN_URL;
                ?>
&amp;page=<?php 
                echo $page;
                ?>
&amp;action=transactions&amp;gateway=<?php 
                echo $key;
                ?>
'><?php 
                _e('View transactions', 'em-pro');
                ?>
</a>
									</td>
							    </tr>
								<?php 
            }
        } else {
            $columncount = count($columns) + 1;
            ?>
							<tr valign="middle" class="alternate" >
								<td colspan="<?php 
            echo $columncount;
            ?>
" scope="row"><?php 
            _e('No Payment gateways were found for this install.', 'em-pro');
            ?>
</td>
						    </tr>
							<?php 
        }
        ?>
					</tbody>
				</table>
			</form>

		</div> <!-- wrap -->
		<?php 
    }
Пример #2
0
 /**
  * Hooks into em_booking_get_post filter and makes sure that if there's an active gateway for new bookings, if no $_REQUEST['gateway'] is supplied (i.e. hacking, spammer, or js problem with booking button mode).
  * @param boolean $result
  * @param EM_Booking $EM_Booking
  * @return boolean
  */
 static function em_booking_get_post($result, $EM_Booking)
 {
     if (!empty($_REQUEST['manual_booking']) && wp_verify_nonce($_REQUEST['manual_booking'], 'em_manual_booking_' . $_REQUEST['event_id'])) {
         return $result;
     }
     if (get_option('dbem_multiple_bookings') && get_class($EM_Booking) == 'EM_Booking') {
         //we only deal with the EM_Multiple_Booking class if we're in multi booking mode
         return $result;
     }
     if (empty($EM_Booking->booking_id) && (empty($_REQUEST['gateway']) || !array_key_exists($_REQUEST['gateway'], self::active_gateways())) && $EM_Booking->get_price() > 0 && count(EM_Gateways::active_gateways()) > 0) {
         //spammer or hacker trying to get around no gateway selection
         $error = __('Choice of payment method not recognized. If you are seeing this error and selecting a method of payment, we apologize for the inconvenience. Please contact us and we\'ll help you make a booking as soon as possible.', 'em-pro');
         $EM_Booking->add_error($error);
         $result = false;
         if (defined('DOING_AJAX')) {
             $return = array('result' => false, 'message' => $error, 'errors' => $error);
             echo EM_Object::json_encode($return);
             die;
         }
     }
     return $result;
 }
 public static function get_gateway_default_values($EM_Gateway = false)
 {
     global $EM_Gateways;
     $email_values = array();
     $gateways = is_object($EM_Gateway) ? array($EM_Gateway->gateway => $EM_Gateway->title) : EM_Gateways::active_gateways();
     foreach ($gateways as $gateway => $gateway_name) {
         $email_values[$gateway . '-admin'] = array(0 => array('subject' => get_option('dbem_bookings_contact_email_subject'), 'message' => get_option('dbem_bookings_contact_email_body'), 'status' => 0), 1 => array('subject' => get_option('dbem_bookings_contact_email_subject'), 'message' => get_option('dbem_bookings_contact_email_body'), 'status' => 0), 3 => array('subject' => get_option('dbem_contactperson_email_cancelled_subject'), 'message' => get_option('dbem_contactperson_email_cancelled_body'), 'status' => 0));
         $email_values[$gateway . '-user'] = array(0 => array('subject' => get_option('dbem_bookings_email_pending_subject'), 'message' => get_option('dbem_bookings_email_pending_body'), 'status' => 0), 1 => array('subject' => get_option('dbem_bookings_email_confirmed_subject'), 'message' => get_option('dbem_bookings_email_confirmed_body'), 'status' => 0), 2 => array('subject' => get_option('dbem_bookings_email_rejected_subject'), 'message' => get_option('dbem_bookings_email_rejected_body'), 'status' => 0), 3 => array('subject' => get_option('dbem_bookings_email_cancelled_subject'), 'message' => get_option('dbem_bookings_email_cancelled_body'), 'status' => 0));
         //temporary fix, we assume everything is online except for offline - maybe a good reason for split offline/online base gateway subclasses
         if ($gateway == 'offline') {
             $email_values[$gateway . '-admin'][5] = array('subject' => get_option('dbem_bookings_contact_email_subject'), 'message' => get_option('dbem_bookings_contact_email_body'), 'status' => 0);
             $email_values[$gateway . '-user'][5] = array('subject' => get_option('dbem_bookings_email_pending_subject'), 'message' => get_option('dbem_bookings_email_pending_body'), 'status' => 0);
         }
         //get custom values if applicable
         $possible_email_values = maybe_unserialize(get_option('em_' . $gateway . "_emails"));
         $email_values = self::merge_gateway_default_values($gateway, $email_values, $possible_email_values, count($gateways) > 1);
     }
     return $email_values;
 }