示例#1
0
 /**
  * Saves passed settings
  *
  * @global array $wpi_settings
  *
  * @param array $new_settings
  */
 function SaveSettings($new_settings)
 {
     global $wpi_settings;
     //** Set 'first_time_setup_ran' as 'true' to avoid loading First Time Setup Page in future */
     $new_settings['first_time_setup_ran'] = 'true';
     $this->options = WPI_Functions::array_merge_recursive_distinct($this->options, $new_settings);
     //** just fo now we use the merged options array and overwrite two brances with new values. It is the custom solution to be able detete currency. odokienko@UD */
     if (isset($new_settings['currency']) && $new_settings['currency']) {
         $this->options['currency']['symbol'] = $new_settings['currency']['symbol'];
         $this->options['currency']['types'] = $new_settings['currency']['types'];
     }
     //** Process Special Settings */
     //** Default predefined services */
     $this->options['predefined_services'][0]['name'] = __("Web Design Services", WPI);
     $this->options['predefined_services'][0]['quantity'] = 1;
     $this->options['predefined_services'][0]['price'] = 30;
     $this->options['predefined_services'][1]['name'] = __("Web Development Services", WPI);
     $this->options['predefined_services'][1]['quantity'] = 1;
     $this->options['predefined_services'][1]['price'] = 30;
     $this->options['predefined_services'] = isset($new_settings['predefined_services']) ? $new_settings['predefined_services'] : $this->options['predefined_services'];
     //** E-Mail Templates */
     if (isset($new_settings['notification'])) {
         $this->options['notification'] = $new_settings['notification'];
     }
     //** fix checkboxes */
     foreach ($this->options['billing'] as $key => $value) {
         if (!isset($new_settings['billing'][$key]['allow'])) {
             unset($this->options['billing'][$key]['allow']);
         }
     }
     $checkbox_array = array('increment_invoice_id', 'send_thank_you_email', 'cc_thank_you_email', 'force_https', 'show_recurring_billing', 'send_invoice_creator_email');
     foreach ($checkbox_array as $checkbox_name) {
         if (!isset($new_settings[$checkbox_name])) {
             unset($this->options[$checkbox_name]);
         }
     }
     $this->CommitUpdates();
     //** Update global variable */
     $wpi_settings = WPI_Functions::array_merge_recursive_distinct($wpi_settings, $this->options);
     //** Fix Predefined Services */
     $wpi_settings['predefined_services'] = $this->options['predefined_services'];
     //** Fix E-Mail Templates */
     $wpi_settings['notification'] = $this->options['notification'];
     wpi_gateway_base::sync_billing_objects();
 }
    /**
     * Saves passed settings
     * 
     * @global array $wpi_settings
     * @param array $new_settings 
     */
    function SaveSettings($new_settings) {
      global $wpi_settings;
        
        //** Set 'first_time_setup_ran' as 'true' to avoid loading First Time Setup Page in future */
        $new_settings['first_time_setup_ran'] = 'true';
        
        $this->options = WPI_Functions::array_merge_recursive_distinct($this->options, $new_settings);
        
        //** Copy template files from plugin folder to active theme/template */
        if(isset($new_settings['install_use_custom_templates']) &&
          isset($new_settings['use_custom_templates']) &&
          $new_settings['install_use_custom_templates'] == 'yes' && 
          $new_settings['use_custom_templates'] == 'yes') {
            WPI_Functions::install_templates();
        }
        
        //** Process Special Settings */
        //** Default predefined services */
        $this->options['predefined_services'][0]['name']     = __("Web Design Services", WPI);
        $this->options['predefined_services'][0]['quantity'] = 1;
        $this->options['predefined_services'][0]['price']    = 30;
        $this->options['predefined_services'][1]['name']     = __("Web Development Services", WPI);
        $this->options['predefined_services'][1]['quantity'] = 1;
        $this->options['predefined_services'][1]['price']    = 30;
        
        $this->options['predefined_services'] = ( isset($new_settings['predefined_services']) ? $new_settings['predefined_services'] : $this->options['predefined_services'] );

        //** E-Mail Templates */
        if(isset($new_settings['notification'])) {
          $this->options['notification'] = $new_settings['notification'];
        }
        
        //** Process Special Settings */
        
        //** fix checkboxes */
        foreach($this->options['billing'] as $key => $value) {
            if(!isset($new_settings['billing'][$key]['allow'])) unset($this->options['billing'][$key]['allow']);
        }
        
        $checkbox_array = array('increment_invoice_id', 'send_thank_you_email', 'cc_thank_you_email', 'force_https', 'show_recurring_billing', 'send_invoice_creator_email');
        foreach($checkbox_array as $checkbox_name) {
            if(!isset($new_settings[$checkbox_name])) unset($this->options[$checkbox_name]);
        }
        
        $this->CommitUpdates();
        
        //** Update global variable */
        $wpi_settings = WPI_Functions::array_merge_recursive_distinct($wpi_settings, $this->options);
        //** Fix Predefined Services */
        $wpi_settings['predefined_services'] = $this->options['predefined_services'];
        //** Fix E-Mail Templates */
        $wpi_settings['notification'] = $this->options['notification'];
        wpi_gateway_base::sync_billing_objects();
    }
示例#3
0
 /**
  * This function loads our payment gateways
  *
  * @since 3.0
  */
 function load_gateways()
 {
     global $wpi_settings;
     $default_headers = array('Name' => __('Name', 'wpi_gateway'), 'Version' => __('Version', 'wpi_gateway'), 'Description' => __('Description', 'wpi_gateway'));
     if (!is_dir(WPI_Gateways_Path)) {
         return;
     }
     if ($premium_dir = opendir(WPI_Gateways_Path)) {
         if (file_exists(WPI_Gateways_Path . "/index.php")) {
             if (WP_DEBUG) {
                 include_once WPI_Gateways_Path . "/index.php";
             } else {
                 @(include_once WPI_Gateways_Path . "/index.php");
             }
         }
         while (false !== ($file = readdir($premium_dir))) {
             if ($file == 'index.php') {
                 continue;
             }
             $ex = explode(".", $file);
             if (end($ex) == 'php') {
                 $slug = str_replace(array('.php'), '', $file);
                 if (substr($slug, 0, 6) == "class_") {
                     $t = explode("class_", $slug);
                     $slug = $t[1];
                 }
                 $plugin_data = @get_file_data(WPI_Gateways_Path . "/" . $file, $default_headers, 'plugin');
                 $wpi_settings['installed_gateways'][$slug]['name'] = $plugin_data['Name'];
                 $wpi_settings['installed_gateways'][$slug]['version'] = $plugin_data['Version'];
                 $wpi_settings['installed_gateways'][$slug]['description'] = $plugin_data['Description'];
                 if (WP_DEBUG) {
                     include_once WPI_Gateways_Path . "/" . $file;
                 } else {
                     @(include_once WPI_Gateways_Path . "/" . $file);
                 }
                 // Disable plugin if class does not exists - file is empty
                 if (!class_exists($slug)) {
                     unset($wpi_settings['installed_gateways'][$slug]);
                 } else {
                     /** Initialize the object, then update the billing permissions to show whats in the object */
                     eval("\$wpi_settings['installed_gateways']['" . $slug . "']['object'] = new " . $slug . "();");
                 }
             }
         }
         /** Sync our options */
         wpi_gateway_base::sync_billing_objects();
     }
 }