TRUE, 'title' => t('Custom User Profile (Profile2)'), 'icon' => 'icon_user.png', 'description' => t('The profile of a user.'), 'required context' => new ctools_context_required(t('User'), 'user'), 'category' => t('User'), 'defaults' => array('type' => 'main'), ); /** * Render the user profile2 content type. */ function ctools_user_profile2_content_type_render($subtype, $conf, $panel_args, $context) { $account = isset($context->data) ? clone($context->data) : NULL; if (!$account || ($account->access == 0 && !user_access('administer users'))) { return NULL; } // Retrieve all profile fields and attach to $account->content. user_build_content($account); if(isset($account->content['profile_'.$conf['type']])) { $profile=profile2_load_by_user($account, $conf['type']); unset($profile->label); } else { return ''; } $block = new stdClass(); $block->module = 'user-profile2'; $block->title = check_plain($account->name); $block->content = drupal_render($profile->view('account')); return $block; } /** * Display the administrative title for a panel pane in the drag & drop UI. */ function ctools_user_profile2_content_type_admin_title($subtype, $conf, $context) { return t('"@s" user custom profile', array('@s' => $context->identifier)); } /** * The submit form stores the data in $conf. */ function ctools_user_profile2_content_type_edit_form_submit($form, &$form_state) { foreach (array_keys($form_state['plugin']['defaults']) as $key) { if (isset($form_state['values'][$key])) { $form_state['conf'][$key] = $form_state['values'][$key]; } } } function ctools_user_profile2_content_type_edit_form($form, &$form_state) { // provide a blank form so we have a place to have context setting. $conf = $form_state['conf']; $form['type'] = array( '#type' => 'select', '#title' => t('Select Profile2 Type'), '#options' => _ctools_profile2_types(), '#prefix' => '
', '#suffix' => '
', ); return $form; } /** * Helper function : build the list of profile types for the 'edit' form. */ function _ctools_profile2_types() { $type_list = array(); $types= profile2_get_types(); foreach ($types as $type => $info) { $type_list[$type] = $info->label; } return $type_list; }