"admin/settings/advanced-profile", 'title' => t('Advanced Profile'), 'callback' => 'drupal_get_form', 'callback arguments' => array('advanced_profile_settings_page'), 'access' => user_access('administer advanced profile'), ); } elseif (arg(0) == 'user' && arg(2) == '') { advanced_profile_add_css(); } return $items; } // SETTINGS ****************************************************************/ /** * Define settings form */ function advanced_profile_settings_page() { // Choose image directory. $form['advanced_profile_image_directory'] = array( '#type' => 'textfield', '#title' => t('Image directory'), '#size' => 50, '#description' => t('Path from active theme to image directory. If left blank the images in the module directory will be used.'), '#default_value' => variable_get('advanced_profile_image_directory', ''), ); // Interval granularity. $form['advanced_profile_visits_interval_granularity'] = array( '#type' => 'textfield', '#title' => t('Granularity of time ago to use on profile visits listing'), '#size' => 10, '#default_value' => variable_get('advanced_profile_visits_interval_granularity', 2), '#description' => t('1 gives you "1 hour ago". 2 gives you "1 hour 4 minutes ago". 3 gives you "1 hour 4 minutes and 2 seconds ago"'), ); // Check if uprofile type exists. $uprofile_exists = db_result(db_query("SELECT count(type) FROM {node_type} WHERE type='%s'", 'uprofile')); $ccopy_installed = module_exists('content_copy'); // Auto create uprofile type option $form['advanced_profile_node_type_setup'] = array( '#type' => 'checkboxes', '#title' => t('Profile type auto creation'), '#options' => array( 'Create' => t('Create the user profile node type with included fields'), ), '#description' => t("If you'd like to auto create the node type for user profiles, check this. The option will be disabled if you have a uprofile node type or do not have content copy (from CCK) enabled."), '#disabled' => $uprofile_exists || !$ccopy_installed, ); // Create the uprofile content type if requested by the user checking the box $node_type_setup = variable_get('advanced_profile_node_type_setup', 0); if ($node_type_setup['Create']) { $cck_definition_file = drupal_get_path('module', 'advanced_profile') . '/includes/uprofile.inc'; _create_content_type($cck_definition_file); } // Dump the checkbox vars to make sure we don't try to run this more than once variable_del('advanced_profile_node_type_setup'); // Send our form to Drupal to make a settings page return system_settings_form($form); } // PANELS ********************************************************************/ if (module_exists('panels')) { include_once drupal_get_path('module', 'advanced_profile') . '/includes/panels.inc'; } // VIEWS *********************************************************************/ if (module_exists('views')) { include_once drupal_get_path('module', 'advanced_profile') . '/includes/views.inc'; } // THEME *********************************************************************/ include_once drupal_get_path('module', 'advanced_profile') . '/includes/theme.inc'; /** * Returns the path to the images used by this module. */ function advanced_profile_path_to_images() { $image_directory = variable_get('advanced_profile_image_directory', ''); if (!empty($image_directory)) { $image_directory = path_to_theme() . '/' . $image_directory; } else { $image_directory = drupal_get_path('module', 'advanced_profile') . '/images'; } return $image_directory; } /** * Adds the needed CSS. */ function advanced_profile_add_css() { // Find the CSS file by looking first in the theme and then in the module. $css_file = path_to_theme() . '/advanced_profile.css'; if (!file_exists($css_file)) { $css_file = drupal_get_path('module', 'advanced_profile') . '/theme/advanced_profile.css'; } drupal_add_css($css_file); } // OUTSIDE MODULE INTEGRATION ************************************************/ include_once drupal_get_path('module', 'advanced_profile') . '/includes/integration.inc'; // GENERAL FUNCTIONS *********************************************************/ /** * This function is no longer used but is kept to avoid errors from people * who have the call in their template.php from using earlier versions. */ function advanced_profile_addvars($hook, $vars) { return $vars; } /** * Returns recent visits to a profile page excluding that user and anonymous. */ function advanced_profile_tracker($uid) { if (module_exists('statistics')) { $interval_granularity = variable_get('advanced_profile_visits_interval_granularity', 2); if (empty($uid)) { $uid = arg(1); } $result = db_query_range('SELECT a.timestamp, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.uid <> %d AND a.uid > 0 AND a.path LIKE \'user/%d%%\' ORDER BY a.timestamp DESC', $uid, $uid, 0, 10); $items = array(); while ($log = db_fetch_object($result)) { $items[] = theme('username', $log) . " " . format_interval(time() - $log->timestamp, $interval_granularity) . " ago."; } return $items; } return -1; } /** * Helper function to import a CCK content type definition from a text file. * Thanks Wim Leers * * @param $cck_definition_file * The full path to the file containing the CCK definition. */ function _create_content_type($cck_definition_file) { include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc'); include_once('./'. drupal_get_path('module', 'content') .'/content_admin.inc'); $values = array(); $values['type_name'] = ''; $values['macro'] = file_get_contents($cck_definition_file); drupal_execute("content_copy_import_form", $values); }