gde_form_to_profile

Write profile from form data.

Description

gde_form_to_profile( $pid, $data ); 

Parameters (2)

0. $pid
The pid.
1. $data
The data.

Usage

  1. if ( !function_exists( 'gde_form_to_profile' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/functions-admin.php'; 
  3.  
  4. // The pid. 
  5. $pid = null; 
  6.  
  7. // The data. 
  8. $data = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = gde_form_to_profile($pid, $data); 
  12.  

Defined (1)

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

/functions-admin.php  
  1. function gde_form_to_profile( $pid, $data ) { 
  2.  
  3. // get current profile data 
  4. $profile = gde_get_profiles( $pid, false ); 
  5.  
  6. // initialize checkbox values (values if options unchecked) 
  7. $profile['tb_flags'] = "przn"; 
  8. $profile['tb_fullwin'] = "same"; 
  9. $profile['tb_fulluser'] = "no"; 
  10. $profile['tb_print'] = "no"; 
  11. $profile['vw_flags'] = ""; 
  12. $profile['link_force'] = "no"; 
  13. $profile['link_mask'] = "no"; 
  14. $profile['link_block'] = "no"; 
  15.  
  16. // enforce trailing slash on base_url 
  17. $data['base_url'] = trailingslashit( $data['base_url'] ); 
  18.  
  19. // sanitize width/height 
  20. $data['default_width'] = gde_sanitize_dims( $data['default_width'] ); 
  21. $data['default_height'] = gde_sanitize_dims( $data['default_height'] ); 
  22. if ( ! $data['default_width'] ) { 
  23. $data['default_width'] = $profile['default_width']; 
  24. if ( ! $data['default_height'] ) { 
  25. $data['default_height'] = $profile['default_height']; 
  26.  
  27. foreach ( $data as $k => $v ) { 
  28. if ( array_key_exists( $k, $profile ) ) { 
  29. // all fields where name == profile key 
  30. $profile[$k] = stripslashes( $v ); 
  31. } elseif ( strstr( $k, 'gdet_' ) && ( strstr( $v, 'gdet_' ) ) ) { 
  32. // toolbar checkboxes 
  33. if ( $k == 'gdet_h' ) { 
  34. $profile['tb_flags'] .= "h"; 
  35. } else { 
  36. $profile['tb_flags'] = str_replace( str_replace( "gdet_", "", $v ), "", $profile['tb_flags'] ); 
  37. } elseif ( $k == "fs_win" ) { 
  38. $profile['tb_fullwin'] = "new"; 
  39. } elseif ( $k == "fs_user" ) { 
  40. $profile['tb_fulluser'] = "yes"; 
  41. } elseif ( $k == "fs_print" ) { 
  42. $profile['tb_print'] = "yes"; 
  43. } elseif ( strstr( $k, 'gdev_' ) && ( strstr( $v, 'gdev_' ) ) ) { 
  44. $profile['vw_flags'] .= str_replace( "gdev_", "", $v ); 
  45. } elseif ( $k == "force" ) { 
  46. $profile['link_force'] = "yes"; 
  47. } elseif ( $k == "mask" ) { 
  48. $profile['link_mask'] = "yes"; 
  49. } elseif ( $k == "block" && gde_is_blockable( $profile ) ) { 
  50. $profile['link_block'] = "yes"; 
  51.  
  52. $newprofile = array( '', '', serialize( $profile ) ); 
  53. if ( gde_write_profile( $newprofile, $pid, true ) > 0 ) { 
  54. // update successful 
  55. return true; 
  56. } else { 
  57. return false;