'checkbox', '#title' => t('Collect during registration'), '#default_value' => isset($settings['form']['register']) ? $settings['form']['register'] : FALSE, '#weight' => -5, ); } /** * Implementation of hook_user(). */ function location_user_user($op, &$edit, &$account, $category = NULL) { global $user; switch ($op) { case 'load': $account->locations = location_load_locations($account->uid, 'uid'); $account->location = count($account->locations) ? $account->locations[0] : array(); break; case 'insert': case 'update': if (!empty($edit['locations'])) { location_save_locations($edit['locations'], array('uid' => $account->uid)); } unset($edit['locations']); break; case 'delete': $locations = array(); location_save_locations($locations, array('uid' => $account->uid)); break; case 'form': if ($category == 'account') { if ((($user->uid == $account->uid) && user_access('set own user location')) || user_access('administer user locations')) { $settings = variable_get('location_settings_user', array()); $form['locations'] = location_form($settings, $account->locations); return $form; } } break; case 'register': $settings = variable_get('location_settings_user', array()); if (isset($settings['form']['register']) && $settings['form']['register']) { $form['locations'] = location_form($settings, array()); return $form; } break; case 'view': if ((($user->uid == $account->uid) && user_access('view own user location')) || user_access('administer users') || user_access('view all user locations') || user_access('administer user locations')) { if (variable_get('location_display_location', 1) && isset($account->locations) && count($account->locations)) { $settings = variable_get('location_settings_user', array()); $account->content['locations'] = location_display($settings, $account->locations); } } break; } } /** * Implementation of hook_locationapi(). */ function location_user_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL) { switch ($op) { case 'instance_links': foreach ($obj as $k => $v) { if ($v['uid'] != 0) { $account = user_load(array('uid' => $v['uid'])); $obj[$k]['href'] = 'user/'. $v['uid']; $obj[$k]['title'] = $account->name; $obj[$k]['type'] = t('User location'); } } } }