I'm using this module in conjunction with Token Authentication (tokenauth) to provide some semblance of security to feeds.
Unfortunately, this module manually generates the ical links in a theme function, rather than allowing Drupal to know about it. (I'm guessing because of the webcal:// format.)
In order to add the user's token to the end of the URL you can override this theme function using MYTHEME_date_ical_icon($vars).
<?php
/**
* Alternate theme function to include tokenauth support.
*/
function MYTHEME_date_ical_icon($variables) {
if (empty($variables['tooltip'])) {
$variables['tooltip'] = t('Add this event to my calendar');
}
$variables['path'] = drupal_get_path('module', 'date_ical') . '/images/ical-feed-icon-34x14.png';
$variables['alt'] = $variables['title'] = $variables['tooltip'];
$token = tokenauth_get_token();
if ($image = theme('image', $variables)) {
return "<a href='{$variables['url']}?token={$token}' class='ical-icon'>$image</a>";
}
else {
return "<a href='{$variables['url']}?token={$token}' class='ical-icon'>{$variables['tooltip']}</a>";
}
}
?>
Comments
Comment #1
coredumperror commentedDo you have any suggestions for how I could improve Date iCal to make it more compatible by default? You mention "this module manually generates the ical links in a theme function, rather than allowing Drupal to know about it." How would you suggest that I let Drupal know about it?
In fact, the webcal:// mechanism is handled in the Views Style plugin (the
attach_to()function), rather than in that theme function. The theme function is a holdover from the previous version of Date iCal, before I took over. I'd be more than happy to completely refactor that functionality for better intermodule compatibility, but I don't really know what I should do.Comment #2
jessehsThe tokenauth module implements hook_url_outbound_alter, and appends the current user's token to any path run through url()
that also passes tokenauth's allowed pages filter. If you use the Drupal url() function to generate the URL, I think that would do it.
Comment #3
coredumperror commentedHuh, that's odd. Date iCal already uses the
url()function (line 27 indate_ical_plugin_style_ical_feed.inc), so tokenauth'shook_url_outbound_alter()should be getting invoked.Looking at tokenauth's code, I see that it runs
tokenauth_allowed_pages($original_path)to check if it should do anything. Maybe the URL for the feed isn't "allowed"? Unless you explicitly tell tokenauth to allow your feed URLs, with all necessary wildcards, it won't add the token.Comment #5
jhedstromFor others finding this issue looking to add tokenauth tokens to ical feeds, I accomplished this using the following:
Comment #6
rbrownellRe opening this. I believe that this is an essential component that should probably be integrated at some point.
Comment #7
coredumperror commentedI'm not entirely certain what Date iCal can even do differently here. It already uses the
url()function to generate that link, so Token Authentication should be adding the token as long as it's configured properly.Do you have a specific request regarding how Date iCal should behave differently?
Comment #8
rbrownellYes. This functionality requires modification to a theme's template.php file. To make this more user friendly for non-developers this functionality should be implemented into Date iCal.
Comment #9
coredumperror commented> This functionality requires modification to a theme's template.php file
What modification are you referring to?
Comment #10
rbrownell@coredumperror The functionality that is indicated in the summary of this issue. That is, we are looking for an option that would enable token authentication support without the need to add extra code to our template.php files.
Comment #11
coredumperror commentedAs I stated in comment #3, this is not Date iCal's fault:
You need to configure tokenauth to "allow" your feeds' URLs, or it will not inject that token into the URLs that Date iCal generates.
Comment #12
coredumperror commentedThis works as designed, so I'm closing this issue.