Skip to content

Commit

Permalink
Foursquare plugin
Browse files Browse the repository at this point in the history
* Gathers and displays a user's Foursquare checkin archive including comments and photos
* Maps recent checkins on a Google Map, displays checkin frequency per hour all-time and last week, pie-charts checkin place types
* Supports "flashback" checkins on this day in past years
Closes #718
  • Loading branch information
AaronKalair authored and ginatrapani committed Aug 29, 2012
1 parent b411e78 commit 688a27c
Show file tree
Hide file tree
Showing 47 changed files with 4,694 additions and 114 deletions.
31 changes: 31 additions & 0 deletions docs/source/userguide/settings/plugins/foursquare.rst
@@ -0,0 +1,31 @@
Foursquare
==========

ThinkUp's Foursquare plugin captures your Foursquare checkins, photos and comments.


Configure the Foursquare Plugin (Admin only)
--------------------------------------------

To set up the Foursquare plugin:

1. Go to https://foursquare.com/oauth/ and click on "Register a New Consumer."
2. Set the application name to anything you like, perhaps "ThinkUp."
3. Set application web site to: the URL of your ThinkUp installation home page.
4. Set the callback URL to the URL displayed on the Foursquare settings page in ThinkUp.
5. Fill in the CAPTCHA.
6. Click on the green "Register Application" button at the bottom of the page.
7. In ThinkUp->Settings->Foursquare, fill in the Foursquare-provided Client ID and Secret.

Plugin Settings
---------------

**Client ID** (required) is the Client ID provided when you register a new consumer on Foursquare.

**Client secret** (required) is the Client secret provided when you register a new consumer on Foursquare.

Add a Foursquare User to ThinkUp
--------------------------------

Click on the "Add a Foursquare User" button in ThinkUp->Settings->Foursquare to add your Foursquare user account to
ThinkUp. This button will only appear if the foursquare plugin is configured.
1 change: 1 addition & 0 deletions docs/source/userguide/settings/plugins/index.rst
Expand Up @@ -8,6 +8,7 @@ The official ThinkUp distribution comes with a set of approved plugins. Click on

expandurls
facebook
foursquare
geoencoder
googleplus
twitter
Expand Down
18 changes: 9 additions & 9 deletions tests/TestOfAccountConfigurationController.php
Expand Up @@ -349,7 +349,7 @@ public function testAuthControlLoggedInNotAdmin() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand All @@ -372,7 +372,7 @@ public function testAuthControlLoggedInAdmin() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -463,7 +463,7 @@ public function testAuthControlLoggedInChangePasswordSuccess() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -498,7 +498,7 @@ public function testAuthControlLoggedInChangePasswordOldPwdDoesntMatch() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -527,7 +527,7 @@ public function testAuthControlLoggedInChangePasswordOldPwdEmpty() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -556,7 +556,7 @@ public function testAuthControlLoggedInChangePasswordNewPwdsDontMatch() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -586,7 +586,7 @@ public function testAuthControlLoggedInChangePasswordNewPwdTooShort() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -617,7 +617,7 @@ public function testAuthControlLoggedInChangePasswordNewPwdNotAlphanumeric() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down Expand Up @@ -698,7 +698,7 @@ public function testResetAPIKey() {
//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
$this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 8);

$owner = $v_mgr->getTemplateDataItem('owner');
$this->assertIsA($owner, 'Owner');
Expand Down
41 changes: 33 additions & 8 deletions tests/TestOfDashboardController.php
Expand Up @@ -41,6 +41,7 @@ public function setUp(){
$webapp_plugin_registrar->registerPlugin('twitter', 'TwitterPlugin');
$webapp_plugin_registrar->registerPlugin('facebook', 'FacebookPlugin');
$webapp_plugin_registrar->registerPlugin('google+', 'GooglePlusPlugin');
$webapp_plugin_registrar->registerPlugin('foursquare', 'FoursquarePlugin');
}

public function testConstructor() {
Expand Down Expand Up @@ -77,12 +78,12 @@ public function testNoInstancesLoggedIn() {
public function testNotLoggedInNoUserOrViewSpecifiedDefaultServiceUserSet() {
$builders = $this->buildData();
//Add another public instance
$instance_builder = FixtureBuilder::build('instances', array('id'=>4, 'network_user_id'=>14,
$instance_builder = FixtureBuilder::build('instances', array('id'=>6, 'network_user_id'=>14,
'network_username'=>'jack', 'is_public'=>1, 'crawler_last_run'=>'-2d'));
$instance_owner_builder = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>4));
$instance_owner_builder = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>6));
//Set the default service user to jack, who is not last updated
$app_option_builder = FixtureBuilder::build('options', array('namespace'=>'application_options',
'option_name'=>'default_instance', 'option_value'=>'4'));
'option_name'=>'default_instance', 'option_value'=>'6'));

$controller = new DashboardController(true);
$results = $controller->go();
Expand All @@ -99,9 +100,9 @@ public function testNotLoggedInNoUserOrViewSpecifiedDefaultServiceUserSet() {
public function testNotLoggedInNoUserOrViewSpecifiedNoDefaultServiceUserSet() {
$builders = $this->buildData();
//Add another public instance
$instance_builder = FixtureBuilder::build('instances', array('id'=>4, 'network_user_id'=>14,
$instance_builder = FixtureBuilder::build('instances', array('id'=>5, 'network_user_id'=>14,
'network_username'=>'jack', 'is_public'=>1, 'crawler_last_run'=>'-2d'));
$instance_owner_builder = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>4));
$instance_owner_builder = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>5));

$controller = new DashboardController(true);
$results = $controller->go();
Expand Down Expand Up @@ -243,6 +244,20 @@ public function testLoggedInPostsGooglePlus() {
$this->assertPattern('/Export/', $results);
}

public function testLoggedInPostsFoursquare() {
$builders = $this->buildData();
$this->simulateLogin('me@example.com');
//required params
$_GET['u'] ='kim@kim.com';
$_GET['n'] = 'foursquare';
$_GET['v'] = 'posts';
$controller = new DashboardController(true);
$results = $controller->go();

$config = Config::getInstance();
$this->assertPattern('/kim@kim.com on Foursquare/', $results);
}

public function testLoggedInPostsWithUsernameApostrophe() {
$builders = $this->buildData();
$this->simulateLogin('me@example.com');
Expand Down Expand Up @@ -356,9 +371,11 @@ private function buildData($with_xss = false) {
//Add instance_owner
$instance_owner_builder_1 = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>1));
$instance_owner_builder_2 = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>2));

$instance_owner_builder_3 = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>3,
'auth_error'=>'Error validating access token: Session has expired at unix time SOME_TIME. The current unix '.
'time is SOME_TIME.'));
$instance_owner_builder_4 = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>4));

//Insert test data into test table
$user_builders = array();
Expand All @@ -375,15 +392,22 @@ private function buildData($with_xss = false) {
$user_builders[] = FixtureBuilder::build('users', array('user_id'=>'16', 'user_name'=>"Kim",
'last_updated'=>'-5d', 'network'=>'google+'));

$user_builders[] = FixtureBuilder::build('users', array('user_id'=>'17', 'user_name'=>"kim@kim.com",
'last_updated'=>'-5d', 'network'=>'foursquare'));

//Make public
$instance_builder_1 = FixtureBuilder::build('instances', array('id'=>1, 'network_user_id'=>'13',
'network_username'=>'ev', 'is_public'=>1, 'crawler_last_run'=>'-1d', 'network'=>'twitter'));

$instance_builder_2 = FixtureBuilder::build('instances', array('id'=>2, 'network_user_id'=>'16',
'network_username'=>"Kim", 'is_public'=>0, 'crawler_last_run'=>'-1d', 'network'=>'google+'));

$instance_builder_3 = FixtureBuilder::build('instances', array('id'=>3, 'network_user_id'=>'14',
'network_username'=>"Joe O'Malley", 'is_public'=>0, 'crawler_last_run'=>'-1d', 'network'=>'facebook'));

$instance_builder_2 = FixtureBuilder::build('instances', array('id'=>2, 'network_user_id'=>'16',
'network_username'=>"Kim", 'is_public'=>0, 'crawler_last_run'=>'-1d', 'network'=>'google+'));
$instance_builder_4 = FixtureBuilder::build('instances', array('id'=>4, 'network_user_id'=>'17',
'network_username'=>"kim@kim.com", 'is_public'=>1, 'crawler_last_run'=>'-1d',
'network'=>'foursquare'));

$post_builders = array();
//Add a bunch of posts
Expand Down Expand Up @@ -422,6 +446,7 @@ private function buildData($with_xss = false) {
}

return array($owner_builder, $instance_owner_builder_1, $instance_owner_builder_2, $instance_owner_builder_3,
$user_builders, $instance_builder_1, $instance_builder_2, $instance_builder_3, $post_builders);
$instance_owner_builder_4, $user_builders, $instance_builder_1, $instance_builder_2, $instance_builder_3,
$instance_builder_4, $post_builders);
}
}
25 changes: 14 additions & 11 deletions tests/TestOfPluginMySQLDAO.php
Expand Up @@ -61,7 +61,7 @@ public function testGetInstalledPlugins() {
$dao = new PluginMySQLDAO();

$plugins = $dao->getInstalledPlugins();
$this->assertEqual(count($plugins), 7);
$this->assertEqual(count($plugins), 8);

usort($plugins, 'TestOfPluginMySQLDAO::pluginSort');
$this->assertEqual($plugins[0]->name,"Expand URLs");
Expand All @@ -70,20 +70,23 @@ public function testGetInstalledPlugins() {
$this->assertEqual($plugins[1]->name,"Facebook");
$this->assertEqual($plugins[1]->folder_name,"facebook");

$this->assertEqual($plugins[2]->name, "GeoEncoder");
$this->assertEqual($plugins[2]->folder_name, "geoencoder");
$this->assertEqual($plugins[2]->name,"Foursquare");
$this->assertEqual($plugins[2]->folder_name,"foursquare");

$this->assertEqual($plugins[3]->name,"Google+");
$this->assertEqual($plugins[3]->folder_name,"googleplus");
$this->assertEqual($plugins[3]->name, "GeoEncoder");
$this->assertEqual($plugins[3]->folder_name, "geoencoder");

$this->assertEqual($plugins[4]->name,"Hello ThinkUp");
$this->assertEqual($plugins[4]->folder_name,"hellothinkup");
$this->assertEqual($plugins[4]->name,"Google+");
$this->assertEqual($plugins[4]->folder_name,"googleplus");

$this->assertEqual($plugins[5]->name,"Twitter");
$this->assertEqual($plugins[5]->folder_name,"twitter");
$this->assertEqual($plugins[5]->name,"Hello ThinkUp");
$this->assertEqual($plugins[5]->folder_name,"hellothinkup");

$this->assertEqual($plugins[6]->name,"Twitter Realtime");
$this->assertEqual($plugins[6]->folder_name,"twitterrealtime");
$this->assertEqual($plugins[6]->name,"Twitter");
$this->assertEqual($plugins[6]->folder_name,"twitter");

$this->assertEqual($plugins[7]->name,"Twitter Realtime");
$this->assertEqual($plugins[7]->folder_name,"twitterrealtime");
}

public function testInsertPugin() {
Expand Down

0 comments on commit 688a27c

Please sign in to comment.