Skip to content

Commit

Permalink
Restore post export link to Facebook and Google+
Browse files Browse the repository at this point in the history
closes #1306, closes #1324
  • Loading branch information
kenyavs authored and ginatrapani committed May 1, 2012
1 parent dd3d2f2 commit 21a971b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 16 deletions.
66 changes: 55 additions & 11 deletions tests/TestOfDashboardController.php
Expand Up @@ -40,6 +40,7 @@ public function setUp(){
$webapp = Webapp::getInstance();
$webapp->registerPlugin('twitter', 'TwitterPlugin');
$webapp->registerPlugin('facebook', 'FacebookPlugin');
$webapp->registerPlugin('google+', 'GooglePlusPlugin');
}

public function testConstructor() {
Expand Down Expand Up @@ -76,12 +77,12 @@ public function testNoInstancesLoggedIn() {
public function testNotLoggedInNoUserOrViewSpecifiedDefaultServiceUserSet() {
$builders = $this->buildData();
//Add another public instance
$instance_builder = FixtureBuilder::build('instances', array('id'=>3, 'network_user_id'=>14,
$instance_builder = FixtureBuilder::build('instances', array('id'=>4, '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'=>3));
$instance_owner_builder = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>4));
//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'=>'3'));
'option_name'=>'default_instance', 'option_value'=>'4'));

$controller = new DashboardController(true);
$results = $controller->go();
Expand All @@ -98,9 +99,9 @@ public function testNotLoggedInNoUserOrViewSpecifiedDefaultServiceUserSet() {
public function testNotLoggedInNoUserOrViewSpecifiedNoDefaultServiceUserSet() {
$builders = $this->buildData();
//Add another public instance
$instance_builder = FixtureBuilder::build('instances', array('id'=>3, 'network_user_id'=>14,
$instance_builder = FixtureBuilder::build('instances', array('id'=>4, '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'=>3));
$instance_owner_builder = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>4));

$controller = new DashboardController(true);
$results = $controller->go();
Expand Down Expand Up @@ -164,6 +165,7 @@ public function testNonExistentUsername() {
$error_msg = $v_mgr->getTemplateDataItem('error_msg');
$this->assertNotNull($error_msg);
$this->assertEqual($error_msg, 'idontexist on Twitter is not in ThinkUp.');

}

public function testLoggedInPosts() {
Expand All @@ -176,6 +178,7 @@ public function testLoggedInPosts() {
$controller = new DashboardController(true);
$results = $controller->go();


//test if view variables were set correctly
$v_mgr = $controller->getViewManager();
$this->assertEqual($v_mgr->getTemplateDataItem('header'), 'Your tweets');
Expand All @@ -186,13 +189,45 @@ public function testLoggedInPosts() {
$config = Config::getInstance();
$this->assertEqual($controller->getCacheKeyString(), '.htdashboard.tpl-me@example.com-ev-twitter-tweets-all');
$this->assertTrue($v_mgr->getTemplateDataItem('is_searchable'));
$this->assertPattern('/Export/', $results);
}

public function testLoggedInPostsFacebook() {
$builders = $this->buildData();
$this->simulateLogin('me@example.com');


//required params
$_GET['u'] ="Joe O\'Malley";
$_GET['n'] = 'facebook';
$_GET['v'] = 'posts-all';
$controller = new DashboardController(true);
$results = $controller->go();

$config = Config::getInstance();
$this->assertPattern('/Export/', $results);
}

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

$config = Config::getInstance();
$this->assertPattern('/Export/', $results);
}


public function testLoggedInPostsWithUsernameApostrophe() {
$builders = $this->buildData();
$this->simulateLogin('me@example.com');
//required params
$_GET['u'] = "Joe O\'Malley";
$_GET['u'] ="Joe O\'Malley";
$_GET['n'] = 'facebook';
$_GET['v'] = 'posts-all';
$controller = new DashboardController(true);
Expand All @@ -207,6 +242,7 @@ public function testLoggedInPostsWithUsernameApostrophe() {
$this->assertEqual($controller->getCacheKeyString(),
".htdashboard.tpl-me@example.com-Joe O\'Malley-facebook-posts-all");
$this->assertTrue($v_mgr->getTemplateDataItem('is_searchable'));
$this->assertPattern('/Export/', $results);
}

public function testNotLoggedInNotPublicInstance() {
Expand Down Expand Up @@ -321,6 +357,7 @@ 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));

//Insert test data into test table
$user_builder_1 = FixtureBuilder::build('users', array('user_id'=>'13', 'user_name'=>'ev',
Expand All @@ -332,13 +369,18 @@ private function buildData($with_xss = false) {
$user_builder_3 = FixtureBuilder::build('users', array('user_id'=>'14', 'user_name'=>"Joe O'Malley",
'last_updated'=>'-5d', 'network'=>'facebook'));


//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'));

$instance_builder_2 = FixtureBuilder::build('instances', array('id'=>2, 'network_user_id'=>'14',
$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'=>'15',
'network_username'=>"Joe O'Malley", 'is_public'=>0, 'crawler_last_run'=>'-1d', 'network'=>'facebook'));


$post_builders = array();
//Add a bunch of posts
$counter = 0;
Expand All @@ -365,6 +407,7 @@ private function buildData($with_xss = false) {
'author_username'=>"Joe O'Malley", 'author_fullname'=>"Joe O\'Malley", 'post_text'=>"Joe's post",
'network'=>'facebook'));


$counter = 0;
$post_data = 'This is post ';
while ($counter < 40) {
Expand All @@ -375,8 +418,10 @@ private function buildData($with_xss = false) {
$counter++;
}

return array($owner_builder, $instance_owner_builder_1, $instance_owner_builder_2, $user_builder_1,
$user_builder_2, $instance_builder_1, $instance_builder_2, $post_builders);

return array($owner_builder, $instance_owner_builder_1, $instance_owner_builder_2, $instance_owner_builder_3,
$user_builder_1, $user_builder_2, $instance_builder_1, $instance_builder_2, $instance_builder_3,
$post_builders);
}


Expand Down Expand Up @@ -479,7 +524,6 @@ public function testGetClickStatsVisualizationData() {
$this->assertEqual($visualization_object->rows[0]->c[0]->v,
'Black Mirror punched me in the gut this weekend. Highly recommended. http://t.co/AnczD4Jc Thx @annal...');
$this->assertEqual($visualization_object->rows[0]->c[1]->v, 50);

$this->assertEqual($visualization_object->rows[1]->c[0]->v,
"@saenz a geeky uncle's only +Sprint http://t.co/cxZTmWhk...");
$this->assertEqual($visualization_object->rows[1]->c[1]->v, 150);
Expand All @@ -488,4 +532,4 @@ public function testGetClickStatsVisualizationData() {
'I\'ll admit Glee made me cry last night. Then it made me cringe. http://t.co/lgjaJWcW ...');
$this->assertEqual($visualization_object->rows[2]->c[1]->v, 23);
}
}
}
2 changes: 1 addition & 1 deletion webapp/plugins/facebook/view/facebook.inline.view.tpl
Expand Up @@ -16,7 +16,7 @@

<div class="header">
{if $is_searchable}<a href="#" class="grid_search" title="Search" onclick="return false;"><span id="grid_search_icon">Search</span></a>{/if}
{if $logged_in_user and $display eq 'all_facebook_posts'} | <a href="{$site_root_path}post/export.php?u={$instance->network_username|urlencode}&n={$instance->network|urlencode}">Export</a>{/if}
{if $logged_in_user and $display eq 'posts-all'} | <a href="{$site_root_path}post/export.php?u={$instance->network_username|urlencode}&n={$instance->network|urlencode}">Export</a>{/if}
</div>


Expand Down
8 changes: 4 additions & 4 deletions webapp/plugins/googleplus/view/googleplus.inline.view.tpl
Expand Up @@ -16,7 +16,7 @@
</div>
{/if}

{if $display eq 'all_gplus_posts' or $gplus_posts}
{if $display eq 'posts-all' or $gplus_posts}

<div class="section">
<div class="clearfix">
Expand All @@ -28,7 +28,7 @@
<div class="header">

{if $is_searchable}<a href="#" class="grid_search" title="Search" onclick="return false;"><span id="grid_search_icon">Search</span></a>{/if}
{if $logged_in_user and $display eq 'all_gplus_posts'} | <a href="{$site_root_path}post/export.php?u={$instance->network_username|urlencode}&n={$instance->network|urlencode}">Export</a>{/if}
{if $logged_in_user and $display eq 'posts-all'} | <a href="{$site_root_path}post/export.php?u={$instance->network_username|urlencode}&n={$instance->network|urlencode}">Export</a>{/if}

</div>

Expand All @@ -37,7 +37,7 @@
<script type="text/javascript" src="{$site_root_path}assets/js/grid_search.js"></script>
{/if}

{if ($display eq 'all_gplus_posts' and not $gplus_posts) or
{if ($display eq 'posts-all' and not $gplus_posts) or
($display eq 'most_replied_to_posts' and not $gplus_posts) }
<div class="alert urgent">
<p>
Expand Down Expand Up @@ -66,4 +66,4 @@
</div>

{/if}


0 comments on commit 21a971b

Please sign in to comment.