Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit adfcd6c

Browse files
committed
Add caching back into permalink.
This caches the vars that are fetched, but leaves the button out caching. Fixes #4255
1 parent 9dd577f commit adfcd6c

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

lib/modules/dosomething/dosomething_reportback/dosomething_reportback.module

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,17 @@ function dosomething_reportback_view_entity($entity) {
442442
$fid = array_pop($entity->fids);
443443
}
444444
// Try to get the permalink from cache.
445-
// if ($cached_permalink = cache_get('ds_permalink_' . $entity->rbid . '_' . $fid . '_' . $is_owner, 'cache_dosomething_reportback')) {
446-
// return $cached_permalink->data;
447-
// }
448-
// else {
445+
if ($cached_permalink = cache_get('ds_permalink_' . $entity->rbid . '_' . $fid . '_' . $is_owner, 'cache_dosomething_reportback')) {
446+
$permalink_vars = $cached_permalink->data;
447+
}
448+
else {
449449
// Additional reportback file specific data.
450450
$file = reportback_file_load($fid);
451451
$rb['image'] = $file->getImage('480x480');
452452
$rb['caption'] = $file->caption;
453453
$node = dosomething_campaign_load(node_load($entity->nid));
454454
$copy_vars = _dosomething_reportback_get_permalink_copy_vars($rb_user);
455455

456-
$signup = dosomething_signup_get_signup_button('Sign Up', $entity->nid, 'dosomething_signup_form');
457-
458456
$incentive = ($node->scholarship) ? $copy_vars['owners_rb_scholarship'] : "";
459457
$title = ($is_owner) ? $copy_vars['owners_title'] : $copy_vars['non_owners_title'];
460458
$subtitle = ($is_owner) ? $copy_vars['owners_rb_subtitle'] . " " . $incentive : $node->call_to_action;
@@ -488,7 +486,7 @@ function dosomething_reportback_view_entity($entity) {
488486
$tumblr_link = paraneue_dosomething_tumblr_intent($tumblr_options);
489487
$share_enabled = variable_get('dosomething_reportback_display_permalink_share', '');
490488

491-
$permalink = theme('reportback_permalink', array(
489+
$permalink_vars = array(
492490
'rb' => $rb,
493491
'reportback' => $entity,
494492
'node' => $node,
@@ -497,17 +495,25 @@ function dosomething_reportback_view_entity($entity) {
497495
'copy_vars' => $copy_vars,
498496
'title' => $title,
499497
'subtitle' => $subtitle,
500-
'signup_button' => $signup,
501498
'fb_link' => $fb_link,
502499
'twitter_link' => $twitter_link,
503500
'tumblr_link' => $tumblr_link,
504501
'share_enabled' => $share_enabled,
505502
'why_participated_short' => $why_participated_short,
506-
)
507503
);
508-
cache_set('ds_permalink_' . $entity->rbid . '_' . $fid . '_' . $is_owner, $permalink, 'cache_dosomething_reportback');
509-
return $permalink;
510-
// }
504+
505+
cache_set('ds_permalink_' . $entity->rbid . '_' . $fid . '_' . $is_owner, $permalink_vars, 'cache_dosomething_reportback');
506+
}
507+
// Don't ever cache the signup button, as this changes/blocks submission.
508+
if($node->status == 'closed') {
509+
$signup = l($copy_vars['non_owners_closed_button'], 'campaigns', array('attributes' => array('class' => array('button'))));
510+
}
511+
else {
512+
$signup = dosomething_signup_get_signup_button('Sign Up', $entity->nid, 'dosomething_signup_form');
513+
}
514+
$permalink_vars['signup_button'] = $signup;
515+
516+
return theme('reportback_permalink', $permalink_vars);
511517
}
512518
/**
513519
* Custom submit handler for signup form.

0 commit comments

Comments
 (0)