/[drupal]/contributions/modules/profile_map/profile_map.module
ViewVC logotype

Diff of /contributions/modules/profile_map/profile_map.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Jul 23 22:06:50 2008 UTC revision 1.2, Fri Jul 25 18:29:44 2008 UTC
# Line 6  Line 6 
6   * Enables arbitrary profile fields to be mapped to a fixed data model.   * Enables arbitrary profile fields to be mapped to a fixed data model.
7   */   */
8    
9    define('PROFILE_HIDDEN', 4);
10    
11  /**  /**
12   * Implementation of hook_help().   * Implementation of hook_help().
13   */   */
# Line 58  function profile_map_help($section) { Line 60  function profile_map_help($section) {
60        )        )
61        </pre>';        </pre>';
62    
63      case 'admin/settings/profile_map':      case 'admin/user/profile/profile_map':
64        return t('Profile Map enables arbitrary profile fields to be mapped to a fixed data model in the $user object.',        return t('Profile Map enables arbitrary profile fields to be mapped to a fixed data model in the $user object.',
65          array('!node_types' => l('node types', 'admin/content/types')));          array('!node_types' => l('node types', 'admin/content/types')));
66    }    }
# Line 71  function profile_map_menu($may_cache) { Line 73  function profile_map_menu($may_cache) {
73    $items = array();    $items = array();
74    if ($may_cache) {    if ($may_cache) {
75      $items[] = array(      $items[] = array(
76        'path' => 'admin/settings/profile_map',        'path' => 'admin/user/profile/profile_map',
77        'title' => 'Profile Map',        'title' => 'Profile Map',
78        'description' => t('Maps profile fields to a fixed data model.'),        'description' => t('Maps profile fields to a fixed data model.'),
79        'callback' => 'drupal_get_form',        'callback' => 'drupal_get_form',
# Line 93  function profile_map_settings() { Line 95  function profile_map_settings() {
95    $form = array();    $form = array();
96    
97    // Get profile fields and group by categories    // Get profile fields and group by categories
98      $category = 0;
99    $categories[0] = '<none>';    $categories[0] = '<none>';
100    $result = db_query('SELECT p.fid, p.title, p.category FROM {profile_fields} p ORDER BY p.category, p.weight');    $result = db_query('SELECT p.fid, p.title, p.category FROM {profile_fields} p WHERE p.visibility <> %d ORDER BY p.category, p.weight', PROFILE_HIDDEN);
101    while ($profile = db_fetch_object($result)) {    while ($profile = db_fetch_object($result)) {
102      if ($profile->category != $category) {      if ($profile->category != $category) {
103        if (isset($category)) {        if ($category) {
104          $categories[$profile->category] = $fields;          $categories[$category] = $fields;
105          unset($fields);          unset($fields);
106        }        }
       $category = $profile->category;  
107      }      }
108        $category = $profile->category;
109      $fields[$profile->fid] = $profile->title;      $fields[$profile->fid] = $profile->title;
110    }    }
111      $categories[$category] = $fields;
112    
113    // Get previous settings. We could use the standard system_settings_form but    // Get previous settings. We could use the standard system_settings_form but
114    // it would be more cumbersome to get the profile map from vars.    // it would be more cumbersome to get the profile map from vars.
# Line 375  function profile_map_user($type, &$edit, Line 379  function profile_map_user($type, &$edit,
379   * module_invoke_all().   * module_invoke_all().
380   */   */
381  function profile_map_profile_alter(&$account, &$fields) {  function profile_map_profile_alter(&$account, &$fields) {
382    $profile_map_category = $profile_map_fields = $profile_map_fields_keys = $profile_map_view = array();    $profile_map_category = $profile_map_fields = $profile_map_fields_keys = array();
383    
384    /**    /**
385     * Get profile map category and profile field name and create two arrays:     * Get profile map category and profile field name and create two arrays:
# Line 411  function profile_map_profile_alter(&$acc Line 415  function profile_map_profile_alter(&$acc
415      /**      /**
416       * Build profile map view array and merge with $fields[$user_category]       * Build profile map view array and merge with $fields[$user_category]
417       */       */
418      foreach ($profile_map_category as $category => $user_category) {      foreach (array_reverse($profile_map_category) as $category => $user_category) {
419        if (strlen($account->profile_map[$category]['view'])) {        if (strlen($account->profile_map[$category]['view'])) {
420          $profile_map_view['profile_map-' . $category] = array(          $fields[$user_category] = array_merge(
421            'title' => variable_get('profile_map_' . $category . '-label_view', NULL),            array('profile_map-' . $category => array(
422            'value' => $account->profile_map[$category]['view'],              'title' => variable_get('profile_map_' . $category . '-label_view', NULL),
423            'class' => 'profile_map-' . $category              'value' => $account->profile_map[$category]['view'],
424                'class' => 'profile_map-' . $category
425              )), (array)$fields[$user_category]
426          );          );
427        }        }
428      }      }
     $fields[$user_category] = array_merge($profile_map_view, (array)$fields[$user_category]);  
429    }    }
430  }  }
431    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2