'author-pane', 'arguments' => array('account' => NULL, 'image_path' => NULL), ); return $items; } // TEMPLATE PREPROCESS *******************************************************/ /** * Load advanced forum files on behalf of modules. * * This function, taken from the views include system, allows us to include * an appropriately named include file bundled with any enabled module. * It is currently used only to load the MODULE.author-pane.inc files which * allow other modules to add to the author pane. */ function author_pane_include($file) { static $cache; $includes = array(); if (!isset($cache->data) || !$cache->data) { $cache = cache_get('author_pane_includes', 'cache'); } if (isset($cache->data) && $cache->data) { $includes = $cache->data; } else { $author_pane_path = drupal_get_path('module', 'author_pane') . '/modules'; foreach (module_list() as $module) { $module_path = drupal_get_path('module', $module); if (file_exists("$module_path/$module.$file")) { $includes[] = "./$module_path/$module.$file"; } else if (file_exists("$module_path/includes/$module.$file")) { $includes[] = "./$module_path/includes/$module.$file"; } else if (file_exists("$author_pane_path/$module.$file")) { $includes[] = "./$author_pane_path/$module.$file"; } } cache_set('author_pane_includes', $includes); } if (!empty($includes)) { foreach ($includes as $include) { require_once $include; } } } /** * Preprocesses template variables for the author info template. */ function template_preprocess_author_pane(&$variables) { author_pane_include('author-pane.inc'); // The passed in $variables['account'] refers to the user who's info is in the pane. $account = $variables['account']; $account_id = $account->uid; $image_path = $variables['image_path']; drupal_add_css(drupal_get_path('module', 'author_pane') . '/author_pane.css'); // Get a reference to the currently logged in user. global $user; // Username $variables['account_name'] = theme('username', $account); $variables['account_id'] = $account_id; // Avatar $variables['picture'] = theme('user_picture', $account); // Nothing else applies to anon users, so just stop here if ($account_id == 0) { return; } // Join date / since $just_date = str_replace(array('H:i', 'g:ia', ' - '), '', variable_get('date_format_short', 'm/d/Y - H:i')); $variables['joined'] = format_date($account->created, 'custom', $just_date); $variables['joined_ago'] = format_interval(time() - $account->created); // Online status $variables['last_active'] = format_interval(time() - $account->access); if (round((time()-$account->access)/60) < 15) { $variables['online_icon'] = theme('image', "$image_path/user-online.png", t('User is online')); $variables['online_status'] = t('Online'); } else { $variables['online_icon'] = theme('image', "$image_path/user-offline.png", t('User offline. Last seen @time ago.', array('@time' => $variables['last_active']))); $variables['online_status'] = t('Offline'); } }