Changeset 167815
- Timestamp:
- 10/27/2009 09:38:36 PM (16 years ago)
- Location:
- fotobook/trunk
- Files:
-
- 4 edited
-
fotobook.php (modified) (8 diffs)
-
js/admin.js (modified) (1 diff)
-
options-fotobook.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
fotobook/trunk/fotobook.php
r167260 r167815 57 57 $fb_message = null; 58 58 59 // handle different requests 60 if(@$_GET['page'] == 'fotobook/manage-fotobook.php' || @$_GET['page'] == 'fotobook/options-fotobook.php') { 61 // load prototype if this is the management page 59 function fb_admin_scripts() { 62 60 wp_enqueue_script('jquery'); 63 61 wp_enqueue_script('prototype'); … … 66 64 wp_enqueue_script('progressbar', FB_PLUGIN_URL.'js/progress.js', array('prototype'), '0.1'); 67 65 wp_enqueue_script('fotobook-js', FB_PLUGIN_URL.'js/admin.js', array('prototype'), FB_VERSION); 68 } 66 add_thickbox(); 67 } 68 add_action('load-fotobook/manage-fotobook.php', 'fb_admin_scripts'); 69 add_action('load-fotobook/options-fotobook.php', 'fb_admin_scripts'); 70 69 71 70 72 //--------------------// … … 82 84 83 85 function FacebookAPI() { 84 if(version_compare('5', PHP_VERSION, "<=")) { 85 require_once('facebook-platform/client/facebook.php'); 86 } else { 87 require_once('facebook-platform/php4client/facebook.php'); 88 } 86 include_once('facebook-platform/facebook.php'); 89 87 90 88 $this->facebook = new Facebook(FB_API_KEY, FB_API_SECRET, null, true); … … 100 98 update_option('fb_facebook_session', ''); 101 99 } 102 103 if(isset($_POST['activate-facebook'])) {104 $this->get_auth_session($_POST['activate-facebook']);105 }106 100 107 101 // get sessions 108 102 $this->get_sessions(); 109 110 if(isset($_GET['deactivate-facebook']) && isset($this->sessions[$_GET['deactivate-facebook']])) {111 $this->remove_user($_GET['deactivate-facebook']);112 }113 103 114 104 // get token every time for additional users 115 $this->token = $this->get_auth_token(); 116 105 $this->token = $this->get_auth_token(); 106 117 107 } 118 108 … … 157 147 $this->get_sessions(); 158 148 $sessions = $this->sessions; 159 $new_session = $this->client->auth_getSession($token); 160 161 if(!$new_session) { 149 150 try { 151 $new_session = $this->client->auth_getSession($token); 152 } catch( Exception $e ) { 162 153 $this->error = true; 163 $this->msg = 'Unable to activate account. [Error #'.$this->client->error_code.']';154 $this->msg = 'Unable to activate account.'; 164 155 return false; 165 } 166 156 } 157 167 158 // check to see if this account is already linked 168 159 $active = array(); … … 186 177 update_option('fb_facebook_session', $sessions); 187 178 $this->msg = 'Fotobook is now linked to '.$new_session['name'].'\'s Facebook account. Now you need to <a href="'.FB_MANAGE_URL.'">import</a> your albums.'; 179 180 $this->get_sessions(); 188 181 return count($sessions) > 0; 189 182 } … … 321 314 $album['location'] = addslashes($album['location']); 322 315 } 316 323 317 $album_query = sprintf("INSERT INTO %s SET page_id='%s', aid='%s', cover_pid='%s', owner='%s', name='%s', created=FROM_UNIXTIME(%s), modified=FROM_UNIXTIME(%s), description='%s', location='%s', link='%s', size='%s', hidden='%s', ordinal='%s'", 324 318 FB_ALBUM_TABLE, $page_id, $album['aid'], $album['cover_pid'], $album['owner'], $album['name'], $album['created'], $album['modified'], $album['description'], $album['location'], $album['link'], $album['size'], $hidden, $ordinal); … … 478 472 } 479 473 480 if(get_option('fb_version') < 3.17) 474 // allow captions to contain more than 255 characters 475 if(get_option('fb_version') <= 3.2) 481 476 $wpdb->query('ALTER TABLE '.FB_PHOTO_TABLE.' CHANGE `caption` `caption` TEXT'); 482 477 } -
fotobook/trunk/js/admin.js
r167260 r167815 9 9 }; 10 10 11 window.onbeforeunload = function(e) { 12 if($j('#grant-submit').attr('disabled')) 13 return ('If this page is refreshed or changed between granting and applying permissions the activation process will not work.'); 14 }; 15 16 $j(document).ready(function() { 17 $j('#grant-submit').removeAttr('disabled'); 18 $j('#grant').submit(function() { 19 $j('#grant-submit').attr('disabled', 'true'); 20 }); 21 $j('#apply').submit(function() { 22 $j('#grant-submit').removeAttr('disabled'); 23 }); 11 jQuery(document).ready(function($) { 12 $('#grant-permissions').click(function() { 13 setTimeout(function() { 14 $('#TB_window').unload(function() { 15 $('#apply-permissions').submit(); 16 }); 17 }, 200); 18 }); 24 19 }); 25 20 -
fotobook/trunk/options-fotobook.php
r167260 r167815 7 7 // get facebook authorization token 8 8 $facebook = new FacebookAPI; 9 10 // authorize session 11 if(isset($_POST['activate-facebook'])) { 12 $facebook->get_auth_session($_POST['activate-facebook']); 13 } 14 15 // remove the user 16 if(isset($_GET['deactivate-facebook']) && isset($facebook->sessions[$_GET['deactivate-facebook']])) { 17 $facebook->remove_user($_GET['deactivate-facebook']); 18 } 9 19 10 20 $this_page = $_SERVER['PHP_SELF'].'?page='.$_GET['page']; … … 49 59 if(get_option('fb_albums_page') == 0) { 50 60 $page = array( 51 'post_author' => 1,52 'post_content' =>'',53 'post_title' =>'Photos',54 'post_name' =>'photos',55 'comment_status' =>1,56 'post_parent' =>061 'post_author' => 1, 62 'post_content' =>'', 63 'post_title' =>'Photos', 64 'post_name' =>'photos', 65 'comment_status' =>1, 66 'post_parent' =>0 57 67 ); 58 68 // add a photo album page … … 101 111 <tr> 102 112 <td valign="top"> 103 <table>113 <table> 104 114 <tr> 105 115 <th colspan="2" style="text-align: center"><h3>Add an Account</h3></th> 106 </tr> 107 <?php if($facebook->token): ?> 116 </tr> 108 117 <tr> 109 <th scope="row"><?php _e('Step 1') ?></th> 110 <td> 111 <form method="get" id="grant" action="http://www.facebook.com/login.php" target="_blank"> 112 <input type="hidden" name="api_key" value="<?php echo FB_API_KEY ?>" /> 113 <input type="hidden" name="v" value="1.0" /> 114 <input type="hidden" name="auth_token" value="<?php echo $facebook->token ?>" /> 115 <input type="hidden" name="popup" value="1" /> 116 <input type="hidden" name="skipcookie" value="1" /> 117 <input type="submit" class="button-secondary" id="grant-submit" value="Grant Permissions >" /> 118 </form> 119 </td> 120 </tr> 121 <tr> 122 <th scope="row"><?php _e('Step 2') ?></th> 123 <td> 124 <form method="post" id="apply" action="<?php echo FB_OPTIONS_URL ?>"> 118 <td colspan="2"> 119 <?php if($facebook->token): ?> 120 <p><a id="grant-permissions" href="http://www.facebook.com/login.php?api_key=<?php echo FB_API_KEY ?>&v=1.0&auth_token=<?php echo $facebook->token ?>&popup=1&skipcookie=1&KeepThis=true&TB_iframe=true&height=400&width=600" class="button-secondary thickbox">Authorize Account</a></p> 121 <form method="post" id="apply-permissions" action="<?php echo FB_OPTIONS_URL ?>" style="display: none"> 125 122 <input type="hidden" name="activate-facebook" value="<?php echo $facebook->token ?>" /> 126 123 <input type="submit" class="button-secondary" value="Apply Permissions >" /> 127 124 </form> 125 <?php else: ?> 126 Unable to get authorization token. 127 <?php endif ?> 128 128 </td> 129 129 </tr> 130 <tr><td colspan="2"><p style="width: 200px"><small>NOTE: Do not refresh this page between granting and applying permissions.</small></p></tr>131 <?php else: ?>132 <tr><td colspan="2">Unable to get authorization token.</td></tr>133 <?php endif; ?>134 130 </table> 135 131 </td> -
fotobook/trunk/readme.txt
r167260 r167815 79 79 80 80 == Changelog == 81 82 = 3.2 = 83 84 * PHP 4 is now longer supported 85 * Thickbox is used for account activation to make things less confusing 86 * Upgraded to latest version of the Facebook PHP Client (which kills support for PHP4) 81 87 82 88 = 3.1.7 =
Note: See TracChangeset
for help on using the changeset viewer.