Plugin Directory

Changeset 167815


Ignore:
Timestamp:
10/27/2009 09:38:36 PM (16 years ago)
Author:
aaron_guitar
Message:
  • PHP 4 is now longer supported
  • Thickbox is used for account activation to make things less confusing
  • Upgraded to latest version of the Facebook PHP Client (which kills support for PHP4)
Location:
fotobook/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fotobook/trunk/fotobook.php

    r167260 r167815  
    5757$fb_message = null;
    5858
    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
     59function fb_admin_scripts() {
    6260  wp_enqueue_script('jquery');
    6361  wp_enqueue_script('prototype');
     
    6664  wp_enqueue_script('progressbar', FB_PLUGIN_URL.'js/progress.js', array('prototype'), '0.1');
    6765  wp_enqueue_script('fotobook-js', FB_PLUGIN_URL.'js/admin.js', array('prototype'), FB_VERSION);
    68 }
     66  add_thickbox();
     67}
     68add_action('load-fotobook/manage-fotobook.php', 'fb_admin_scripts');
     69add_action('load-fotobook/options-fotobook.php', 'fb_admin_scripts');
     70
    6971
    7072//--------------------//
     
    8284 
    8385  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');
    8987   
    9088    $this->facebook   = new Facebook(FB_API_KEY, FB_API_SECRET, null, true);
     
    10098      update_option('fb_facebook_session', '');
    10199    }
    102                
    103     if(isset($_POST['activate-facebook'])) {
    104       $this->get_auth_session($_POST['activate-facebook']);
    105     }
    106100
    107101    // get sessions
    108102    $this->get_sessions();
    109 
    110     if(isset($_GET['deactivate-facebook']) && isset($this->sessions[$_GET['deactivate-facebook']])) {
    111       $this->remove_user($_GET['deactivate-facebook']);
    112     }
    113103   
    114104    // get token every time for additional users
    115     $this->token = $this->get_auth_token();     
    116    
     105    $this->token = $this->get_auth_token();
     106
    117107  }
    118108
     
    157147    $this->get_sessions();
    158148    $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 ) {
    162153      $this->error = true;
    163       $this->msg = 'Unable to activate account. [Error #'.$this->client->error_code.']';
     154      $this->msg = 'Unable to activate account.';
    164155      return false;
    165     } 
    166      
     156    }
     157   
    167158    // check to see if this account is already linked
    168159    $active = array();
     
    186177    update_option('fb_facebook_session', $sessions);
    187178    $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();
    188181    return count($sessions) > 0;
    189182  }
     
    321314        $album['location'] = addslashes($album['location']);       
    322315      }
     316     
    323317      $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'",
    324318                            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); 
     
    478472  }
    479473
    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)
    481476    $wpdb->query('ALTER TABLE '.FB_PHOTO_TABLE.' CHANGE `caption` `caption` TEXT');
    482477}
  • fotobook/trunk/js/admin.js

    r167260 r167815  
    99};
    1010
    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   });
     11jQuery(document).ready(function($) {
     12    $('#grant-permissions').click(function() {
     13        setTimeout(function() {
     14            $('#TB_window').unload(function() {
     15                $('#apply-permissions').submit();
     16            });
     17        }, 200);
     18    });
    2419});
    2520
  • fotobook/trunk/options-fotobook.php

    r167260 r167815  
    77// get facebook authorization token
    88$facebook = new FacebookAPI;
     9
     10// authorize session
     11if(isset($_POST['activate-facebook'])) {
     12  $facebook->get_auth_session($_POST['activate-facebook']);
     13}
     14
     15// remove the user
     16if(isset($_GET['deactivate-facebook']) && isset($facebook->sessions[$_GET['deactivate-facebook']])) {
     17  $facebook->remove_user($_GET['deactivate-facebook']);
     18}
    919
    1020$this_page = $_SERVER['PHP_SELF'].'?page='.$_GET['page'];
     
    4959if(get_option('fb_albums_page') == 0) {
    5060  $page = array(
    51     'post_author'=> 1,
    52     'post_content'=>'',
    53     'post_title'=>'Photos',
    54     'post_name'=>'photos',
    55     'comment_status'=>1,
    56     'post_parent'=>0
     61    'post_author'    => 1,
     62    'post_content'   =>'',
     63    'post_title'     =>'Photos',
     64    'post_name'      =>'photos',
     65    'comment_status' =>1,
     66    'post_parent'    =>0
    5767  );
    5868  // add a photo album page
     
    101111        <tr>
    102112          <td valign="top">
    103             <table>
     113            <table>
    104114              <tr>
    105115                <th colspan="2" style="text-align: center"><h3>Add an Account</h3></th>
    106               </tr>
    107               <?php if($facebook->token): ?>
     116              </tr>                           
    108117              <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 &gt;" />
    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 ?>&amp;v=1.0&amp;auth_token=<?php echo $facebook->token ?>&amp;popup=1&amp;skipcookie=1&amp;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">
    125122                    <input type="hidden" name="activate-facebook" value="<?php echo $facebook->token ?>" />
    126123                    <input type="submit" class="button-secondary" value="Apply Permissions &gt;" />
    127124                  </form>
     125                  <?php else: ?>
     126                  Unable to get authorization token.
     127                  <?php endif ?>
    128128                </td>
    129129              </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; ?>
    134130            </table>
    135131          </td>
  • fotobook/trunk/readme.txt

    r167260 r167815  
    7979
    8080== 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)
    8187
    8288= 3.1.7 =
Note: See TracChangeset for help on using the changeset viewer.