M_Wizard

The Membership 2 M Wizard class.

Defined (1)

The class is defined in the following location(s).

/app_old/membershipincludes/classes/class.wizard.php  
  1. class M_Wizard { 
  2.  
  3. var $tables = array('membership_levels', 'membership_rules', 'subscriptions', 'subscriptions_levels', 'membership_relationships', 'membermeta', 'communications', 'urlgroups', 'ping_history', 'pings'); 
  4.  
  5. var $membership_levels; 
  6. var $membership_rules; 
  7. var $membership_relationships; 
  8. var $subscriptions; 
  9. var $subscriptions_levels; 
  10. var $membermeta; 
  11. var $communications; 
  12. var $urlgroups; 
  13. var $ping_history; 
  14. var $pings; 
  15.  
  16. function __construct( ) { 
  17.  
  18. global $wpdb; 
  19.  
  20. $this->db =& $wpdb; 
  21.  
  22. foreach($this->tables as $table) { 
  23. $this->$table = membership_db_prefix($this->db, $table); 
  24.  
  25. // if logged in: 
  26. add_action( 'wp_ajax_processwizard', array(&$this, 'ajax_process_wizard') ); 
  27. add_action( 'admin_init', array(&$this, 'process_visibility') ); 
  28.  
  29. function M_Wizard( ) { 
  30. $this->__construct(); 
  31.  
  32. function ajax_process_wizard() { 
  33.  
  34. global $page, $action, $step; 
  35.  
  36. wp_reset_vars( array('action', 'page', 'step') ); 
  37.  
  38. switch( $_POST['from']) { 
  39. case 'stepone': if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  40. switch($_POST['wizardtype']) { 
  41. case 'normal': echo $this->show_normal_wizard_step( "admin.php?page=membership&step=3" ); 
  42. break; 
  43.  
  44. case 'dripped': echo $this->show_dripped_wizard_step( "admin.php?page=membership&step=3" ); 
  45. break; 
  46.  
  47. case 'advanced': // Skips wizard and goes to pointer tutorial 
  48. $this->hide_wizard(); 
  49. echo "clear"; 
  50. break; 
  51. break; 
  52.  
  53. case 'steptwo': 
  54. if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  55. switch($_POST['wizardtype']) { 
  56. case 'normal': echo $this->process_normal_wizard_step(); 
  57. break; 
  58.  
  59. case 'dripped': echo $this->process_dripped_wizard_step(); 
  60. break; 
  61. // Show the thank you message 
  62. echo $this->page_end(); 
  63. break; 
  64. exit; 
  65.  
  66. function process_visibility() { 
  67.  
  68. if(isset($_GET['action']) && $_GET['action'] == 'deactivatewelcome') { 
  69.  
  70. check_admin_referer('deactivate-welcome'); 
  71.  
  72. $this->hide_wizard(); 
  73.  
  74. wp_safe_redirect( remove_query_arg( 'action', remove_query_arg( '_wpnonce') ) ); 
  75.  
  76.  
  77. function wizard_visible() { 
  78. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  79. if(function_exists('get_blog_option')) { 
  80. if(function_exists('switch_to_blog')) { 
  81. switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); 
  82. $wizard_visible = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_wizard_visible', 'yes'); 
  83. if(function_exists('restore_current_blog')) { 
  84. restore_current_blog(); 
  85. } else { 
  86. $wizard_visible = get_option('membership_wizard_visible', 'yes'); 
  87. } else { 
  88. $wizard_visible = get_option('membership_wizard_visible', 'yes'); 
  89.  
  90. return $wizard_visible; 
  91.  
  92. function hide_wizard() { 
  93. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  94. if(function_exists('update_blog_option')) { 
  95. update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_wizard_visible', 'no'); 
  96. } else { 
  97. update_option('membership_wizard_visible', 'no'); 
  98. } else { 
  99. update_option('membership_wizard_visible', 'no'); 
  100.  
  101. function conditional_show() { 
  102.  
  103. global $page, $action, $step; 
  104.  
  105. wp_reset_vars( array('action', 'page', 'step') ); 
  106.  
  107. // carry on and see if we should display the wizard and then what we should display 
  108. if($this->wizard_visible() != 'no') { 
  109.  
  110. if(isset($_GET['step'])) { 
  111. $current_step = (int) $_GET['step']; 
  112. } else { 
  113. $current_step = 1; 
  114.  
  115. switch($current_step) { 
  116.  
  117. case 1: $step2 = "admin.php?page=" . $page. "&step=2"; 
  118. $this->show_with_wrap( $this->page_one( $step2 ) ); 
  119. break; 
  120.  
  121. case 2: if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  122. switch($_POST['wizardtype']) { 
  123. case 'normal': $step3 = "admin.php?page=membership&step=3"; 
  124. echo $this->show_normal_wizard_step( $step3 ); 
  125. break; 
  126.  
  127. case 'dripped': $step3 = "admin.php?page=membership&step=3"; 
  128. echo $this->show_dripped_wizard_step( $step3 ); 
  129. break; 
  130.  
  131. case 'advanced': // Skips wizard and goes to pointer tutorial 
  132. $this->hide_wizard(); 
  133. echo ""; 
  134. break; 
  135. break; 
  136.  
  137. case 3: // Do the processing and then show an end message 
  138. if(wp_verify_nonce( $_POST['nonce'], 'membership_wizard' )) { 
  139. switch($_POST['wizardtype']) { 
  140. case 'normal': echo $this->process_normal_wizard_step(); 
  141. break; 
  142.  
  143. case 'dripped': echo $this->process_dripped_wizard_step(); 
  144. break; 
  145. // Show the thank you message 
  146. echo $this->page_end(); 
  147. break; 
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155. function show_with_wrap( $content ) { 
  156.  
  157. global $page, $action, $step; 
  158.  
  159. $deactivateurl = wp_nonce_url("admin.php?page=" . $page. "&action=deactivatewelcome", 'deactivate-welcome'); 
  160. ?> 
  161. <div class="welcome-panel" id="welcome-panel"> 
  162. <a href="<?php echo $deactivateurl; ?>" class="welcome-panel-close"><?php _e('Dismiss', 'membership'); ?></a> 
  163.  
  164. <div class="welcome-panel-content"> 
  165. <?php 
  166. echo $content; 
  167. ?> 
  168. <p class="welcome-panel-dismiss"><?php _e('Already know what you\'re doing?', 'membership'); ?> <a href="<?php echo $deactivateurl; ?>"><?php _e('Dismiss this message', 'membership'); ?></a>.</p> 
  169. </div> 
  170.  
  171. </div> 
  172. <?php 
  173.  
  174. function page_one( $nextsteplink = false ) { 
  175.  
  176. ob_start(); 
  177. ?> 
  178. <h3><?php _e('Welcome to Membership', 'membership'); ?></h3> 
  179. <p class="about-description"> 
  180. <?php 
  181. if ( !defined('WPMUDEV_REMOVE_BRANDING') ) { 
  182. _e('If you need help getting started, check out our documentation over on <a href="http://premium.wpmudev.org/project/membership">WPMUDEV</a>. ', 'membership'); 
  183. _e('You can use the Help tabs in the upper right corner to get information on how to use your current screen. ', 'membership'); 
  184. _e('If you would like us to set up some basic things for you then choose an option below.', 'membership'); 
  185. ?> 
  186. </p> 
  187. <form action='<?php echo $nextsteplink; ?>' method='post' name='wizardform' id='wizardform'> 
  188. <input type='hidden' name='action' value='processwizard' /> 
  189. <input type='hidden' name='from' value='stepone' /> 
  190. <input type='hidden' name='nonce' value='<?php echo wp_create_nonce('membership_wizard'); ?>' /> 
  191. <ul class='wizardoptions'> 
  192. <li><input type='radio' name='wizardtype' value='normal' checked='checked' /> <?php _e('Standard membership site.', 'membership'); ?></li> 
  193. <li><input type='radio' name='wizardtype' value='dripped' /> <?php _e('Dripped content site.', 'membership'); ?></li> 
  194. <li><input type='radio' name='wizardtype' value='advanced' /> <?php _e('Advanced.', 'membership'); ?></li> 
  195. </ul> 
  196. <p class="about-description"> 
  197. <input type='submit' name='submit' class='button-primary alignright' value='<?php _e('Next Step »', 'membership'); ?>' /> 
  198. </p> 
  199. </form> 
  200.  
  201. <?php 
  202. return ob_get_clean(); 
  203.  
  204. function show_normal_wizard_step( $nextsteplink = false ) { 
  205.  
  206. global $page, $action, $step; 
  207.  
  208. $deactivateurl = wp_nonce_url("admin.php?page=" . $page. "&action=deactivatewelcome", 'deactivate-welcome'); 
  209. ob_start(); 
  210. ?> 
  211. <h3><?php _e('Create your levels', 'membership'); ?></h3> 
  212. <p class="about-description"> 
  213. <?php 
  214. _e('A level controls what parts of your website a user has access to, so we will need to set some initial ones up. ', 'membership'); 
  215. _e('Select the number of levels you think you will need to get started (you can add or remove them later).', 'membership'); 
  216. ?> 
  217. </p> 
  218. <form action='<?php echo $nextsteplink; ?>' method='post' name='wizardform' id='wizardform'> 
  219. <input type='hidden' name='action' value='processwizard' /> 
  220. <input type='hidden' name='from' value='steptwo' /> 
  221. <input type='hidden' name='nonce' value='<?php echo wp_create_nonce('membership_wizard'); ?>' /> 
  222. <input type='hidden' name='wizardtype' value='normal' /> 
  223. <p class="about-description createsteps"> 
  224. <?php _e('Create ', 'membership'); ?> 
  225. <select name='numberoflevels' id='wizardnumberoflevels'> 
  226. <?php 
  227. for($n=1; $n <= 2; $n++) { 
  228. if($n == 2) { 
  229. ?> 
  230. <option value='<?php echo $n; ?>' selected='selected'><?php echo $n; ?></option> 
  231. <?php 
  232. } else { 
  233. ?> 
  234. <option value='<?php echo $n; ?>'><?php echo $n; ?></option> 
  235. <?php 
  236. ?> 
  237. </select> 
  238. <?php _e(' levels and give them the following names:', 'membership'); ?> 
  239. </p> 
  240. <ul class='wizardlevelnames'> 
  241. <li><input type='text' name='levelname[]' placeholder='<?php _e('Level 1', 'membership'); ?>' class='wizardlevelname' /></li> 
  242. <li><input type='text' name='levelname[]' placeholder='<?php _e('Level 2', 'membership'); ?>' class='wizardlevelname' /></li> 
  243. </ul> 
  244. <p class="about-description createsteps"> 
  245. <input type='checkbox' name='creatavisitorlevel' value='yes' checked='checked' /> <?php _e('also create a level to control what non-members can see?', 'membership'); ?> 
  246. <br/><br/> 
  247. <?php _e('Finally, I would like to use the ', 'membership'); ?> 
  248. <select name='wizardgateway' > 
  249. <option value=''><?php _e('Select a gateway...', 'membership'); ?></option> 
  250. <?php $gateways = get_membership_gateways(); 
  251. if(!empty($gateways)) { 
  252. foreach($gateways as $key => $gateway) { 
  253. $default_headers = array( 
  254. 'Name' => 'Addon Name',  
  255. 'Author' => 'Author',  
  256. 'Description' => 'Description',  
  257. 'AuthorURI' => 'Author URI',  
  258. 'gateway_id' => 'Gateway ID' 
  259. ); 
  260.  
  261. $gateway_data = get_file_data( membership_dir('membershipincludes/gateways/' . $gateway), $default_headers, 'plugin' ); 
  262.  
  263. if(empty($gateway_data['Name'])) { 
  264. continue; 
  265. ?> 
  266. <option value='<?php echo $gateway_data['gateway_id']; ?>'><?php echo $gateway_data['Name']; ?></option> 
  267. <?php 
  268.  
  269. ?> 
  270. </select> 
  271. <?php _e(' gateway to receive payments.', 'membership'); ?> 
  272. </p> 
  273. <p class="about-description"> 
  274. <input type='submit' name='submit' class='button-primary alignright' value='<?php _e('Finish', 'membership'); ?>' /> 
  275. </p> 
  276. </form> 
  277.  
  278. <p class="welcome-panel-dismiss"><?php _e('Already know what you\'re doing?', 'membership'); ?> <a href="<?php echo $deactivateurl; ?>"><?php _e('Dismiss this message', 'membership'); ?></a>.</p> 
  279.  
  280. <?php 
  281. return ob_get_clean(); 
  282.  
  283.  
  284. function show_dripped_wizard_step( $nextsteplink = false ) { 
  285.  
  286. global $page, $action, $step; 
  287.  
  288. $deactivateurl = wp_nonce_url("admin.php?page=" . $page. "&action=deactivatewelcome", 'deactivate-welcome'); 
  289. ob_start(); 
  290. ?> 
  291. <h3><?php _e('Create your levels', 'membership'); ?></h3> 
  292. <p class="about-description"> 
  293. <?php 
  294. _e('A level controls what parts of your website a user has access to, so we will need to set some initial ones up. ', 'membership'); 
  295. _e('Select the number of levels you think you will need to get started (you can add or remove them later).', 'membership'); 
  296. ?> 
  297. </p> 
  298. <form action='<?php echo $nextsteplink; ?>' method='post' name='wizardform' id='wizardform'> 
  299. <input type='hidden' name='action' value='processwizard' /> 
  300. <input type='hidden' name='from' value='steptwo' /> 
  301. <input type='hidden' name='nonce' value='<?php echo wp_create_nonce('membership_wizard'); ?>' /> 
  302. <input type='hidden' name='wizardtype' value='dripped' /> 
  303. <p class="about-description createsteps"> 
  304. <?php _e('Create ', 'membership'); ?> 
  305. <select name='numberoflevels' id='wizardnumberoflevels'> 
  306. <?php 
  307. for($n=1; $n <= 2; $n++) { 
  308. if($n == 2) { 
  309. ?> 
  310. <option value='<?php echo $n; ?>' selected='selected'><?php echo $n; ?></option> 
  311. <?php 
  312. } else { 
  313. ?> 
  314. <option value='<?php echo $n; ?>'><?php echo $n; ?></option> 
  315. <?php 
  316. ?> 
  317. </select> 
  318. <?php _e(' levels and give them the following names:', 'membership'); ?> 
  319. </p> 
  320. <ul class='wizardlevelnames'> 
  321. <li><input type='text' name='levelname[]' value='<?php _e('Level 1', 'membership'); ?>' class='wizardlevelname' /></li> 
  322. <li><input type='text' name='levelname[]' value='<?php _e('Level 2', 'membership'); ?>' class='wizardlevelname' /></li> 
  323. </ul> 
  324. <p class="about-description createsteps"> 
  325. <input type='checkbox' name='creatavisitorlevel' value='yes' checked='checked' /> <?php _e('also create a level to control what non-members can see?', 'membership'); ?> 
  326. <br/><br/> 
  327. <?php _e('Finally, I would like to use the ', 'membership'); ?> 
  328. <select name='wizardgateway' > 
  329. <option value=''><?php _e('Select a gateway...', 'membership'); ?></option> 
  330. <?php $gateways = get_membership_gateways(); 
  331. if(!empty($gateways)) { 
  332. foreach($gateways as $key => $gateway) { 
  333. $default_headers = array( 
  334. 'Name' => 'Addon Name',  
  335. 'Author' => 'Author',  
  336. 'Description' => 'Description',  
  337. 'AuthorURI' => 'Author URI',  
  338. 'gateway_id' => 'Gateway ID' 
  339. ); 
  340.  
  341. $gateway_data = get_file_data( membership_dir('membershipincludes/gateways/' . $gateway), $default_headers, 'plugin' ); 
  342.  
  343. if(empty($gateway_data['Name'])) { 
  344. continue; 
  345. ?> 
  346. <option value='<?php echo $gateway_data['gateway_id']; ?>'><?php echo $gateway_data['Name']; ?></option> 
  347. <?php 
  348.  
  349. ?> 
  350. </select> 
  351. <?php _e(' gateway to receive payments.', 'membership'); ?> 
  352. </p> 
  353. <p class="about-description"> 
  354. <input type='submit' name='submit' class='button-primary alignright' value='<?php _e('Finish', 'membership'); ?>' /> 
  355. </p> 
  356. </form> 
  357.  
  358. <p class="welcome-panel-dismiss"><?php _e('Already know what you\'re doing?', 'membership'); ?> <a href="<?php echo $deactivateurl; ?>"><?php _e('Dismiss this message', 'membership'); ?></a>.</p> 
  359.  
  360. <?php 
  361. return ob_get_clean(); 
  362.  
  363.  
  364. function process_normal_wizard_step() { 
  365. // This function sets up the normal wizard 
  366.  
  367. if(isset($_POST['levelname'])) { 
  368. foreach($_POST['levelname'] as $key => $value) { 
  369. if(empty($value)) { 
  370. $value = __('Level ', 'membership') . ((int) $key + 1); 
  371. // Create a level 
  372. $level_id = $this->create_level( $value ); 
  373. // Create a subscription with that level 
  374. $sub_id = $this->create_subscription( $value ); 
  375. // Add the level to the subscription 
  376. $this->add_level_to_subscription( $level_id, $sub_id ); 
  377.  
  378. // Activate and make public the levels and subscriptions 
  379. $sub = new M_Subscription( $sub_id ); 
  380. $sub->toggleactivation(); 
  381. $sub->togglepublic(); 
  382. $level = new M_Level( $level_id ); 
  383. $level->toggleactivation(); 
  384.  
  385. // Create a visitor level and set it in the options 
  386. if(isset($_POST['creatavisitorlevel']) && $_POST['creatavisitorlevel'] == 'yes') { 
  387. $level_id = $this->create_level( __('Visitors', 'membership') ); 
  388. $level = new M_Level( $level_id ); 
  389. $level->toggleactivation(); 
  390.  
  391. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  392. if(function_exists('get_blog_option')) { 
  393. if(function_exists('switch_to_blog')) { 
  394. switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); 
  395.  
  396. $M_options = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', array()); 
  397. } else { 
  398. $M_options = get_option('membership_options', array()); 
  399. } else { 
  400. $M_options = get_option('membership_options', array()); 
  401.  
  402. $M_options['strangerlevel'] = (int) $level_id; 
  403.  
  404. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  405. if(function_exists('update_blog_option')) { 
  406. update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', $M_options); 
  407. } else { 
  408. update_option('membership_options', $M_options); 
  409. } else { 
  410. update_option('membership_options', $M_options); 
  411.  
  412. // Activate the relevant gateway if it's set 
  413. if(isset($_POST['wizardgateway'])) { 
  414. $active = get_option('membership_activated_gateways', array()); 
  415. if(!in_array($_POST['wizardgateway'], $active)) { 
  416. $active[] = $_POST['wizardgateway']; 
  417. update_option('membership_activated_gateways', array_unique($active)); 
  418.  
  419.  
  420.  
  421. function process_dripped_wizard_step() { 
  422.  
  423. if(isset($_POST['levelname'])) { 
  424. // Create an initial subscription 
  425. $sub_id = $this->create_subscription( __('Dripped Subscription', 'membership') ); 
  426. $sub = new M_Subscription( $sub_id ); 
  427. $sub->toggleactivation(); 
  428. $sub->togglepublic(); 
  429.  
  430. foreach($_POST['levelname'] as $key => $value) { 
  431. if(empty($value)) { 
  432. $value = __('Level ', 'membership') . ((int) $key + 1); 
  433. // Create a level 
  434. $level_id = $this->create_level( $value ); 
  435. // Add the level to the subscription 
  436. $this->add_level_to_subscription( $level_id, $sub_id, 'finite' ); 
  437. // Activate and make public the levels and subscriptions 
  438. $level = new M_Level( $level_id ); 
  439. $level->toggleactivation(); 
  440. // Create a visitor level and set it in the options 
  441. if(isset($_POST['creatavisitorlevel']) && $_POST['creatavisitorlevel'] == 'yes') { 
  442. $level_id = $this->create_level( __('Visitors', 'membership') ); 
  443. $level = new M_Level( $level_id ); 
  444. $level->toggleactivation(); 
  445.  
  446. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  447. if(function_exists('get_blog_option')) { 
  448. if(function_exists('switch_to_blog')) { 
  449. switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); 
  450.  
  451. $M_options = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', array()); 
  452. } else { 
  453. $M_options = get_option('membership_options', array()); 
  454. } else { 
  455. $M_options = get_option('membership_options', array()); 
  456.  
  457. $M_options['strangerlevel'] = (int) $level_id; 
  458.  
  459. if(defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { 
  460. if(function_exists('update_blog_option')) { 
  461. update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', $M_options); 
  462. } else { 
  463. update_option('membership_options', $M_options); 
  464. } else { 
  465. update_option('membership_options', $M_options); 
  466.  
  467. // Activate the relevant gateway if it's set 
  468. if(isset($_POST['wizardgateway'])) { 
  469. $active = get_option('membership_activated_gateways', array()); 
  470. if(!in_array($_POST['wizardgateway'], $active)) { 
  471. $active[] = $_POST['wizardgateway']; 
  472. update_option('membership_activated_gateways', array_unique($active)); 
  473.  
  474.  
  475. function page_end( $nextsteplink = false ) { 
  476.  
  477. global $M_options, $page, $action, $step; 
  478.  
  479. ob_start(); 
  480. ?> 
  481. <h3><?php _e('Thank you', 'membership'); ?></h3> 
  482. <p class="about-description"> 
  483. <?php 
  484.  
  485. $deactivateurl = wp_nonce_url("admin.php?page=membership&action=deactivatewelcome", 'deactivate-welcome'); 
  486.  
  487. _e('Thank you, we have now set up some of the initial Membership options. ', 'membership'); 
  488. _e('If you would like more tips on using the system then you can now follow the tutorial pointers we have included, or check out the help guides at the top of every page.', 'membership'); 
  489.  
  490. ?> 
  491. <br/> 
  492. <a href='<?php echo $deactivateurl; ?>' class='button-primary alignright'><?php _e('Close this wizard', 'membership'); ?></a> 
  493. </p> 
  494.  
  495. <?php 
  496. return ob_get_clean(); 
  497.  
  498. // Helper functions 
  499. function create_level( $title = false ) { 
  500.  
  501. $return = $this->db->insert($this->membership_levels, array('level_title' => $title, 'level_slug' => sanitize_title($title))); 
  502.  
  503. return $this->db->insert_id; 
  504.  
  505.  
  506. function create_subscription( $title = false ) { 
  507.  
  508. $return = $this->db->insert($this->subscriptions, array('sub_name' => $title, 'sub_description' => '', 'sub_pricetext' => '')); 
  509.  
  510. return $this->db->insert_id; 
  511.  
  512.  
  513. function add_level_to_subscription( $level_id, $sub_id, $type = 'serial' ) { 
  514.  
  515. $max = $this->db->get_var( "SELECT max(level_order) FROM {$this->subscriptions_levels} WHERE sub_id = " . $sub_id ); 
  516.  
  517. if(empty($max)) $max = 0; 
  518.  
  519. $this->db->insert($this->subscriptions_levels, array( "sub_id" => $sub_id,  
  520. "level_period" => 20,  
  521. "sub_type" => $type,  
  522. "level_price" => 0,  
  523. "level_currency" => 'USD',  
  524. "level_order" => ++$max,  
  525. "level_id" => $level_id,  
  526. "level_period_unit" => 'd' 
  527. )); 
  528.  
  529. function activate_gateway( $gateway = false ) { 
  530.  
  531.