Projet

Général

Profil

Paste
Télécharger (1,4 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / plugins / content_types / user_context / user_picture.inc @ c304a780

1
<?php
2

    
3
/**
4
 * @file
5
 * Plugins are described by creating a $plugin array which will be used
6
 * by the system that includes this file.
7
 */
8

    
9
$plugin = array(
10
  'single' => TRUE,
11
  'title' => t('User picture'),
12
  'icon' => 'icon_user.png',
13
  'description' => t('The picture of a user.'),
14
  'required context' => new ctools_context_required(t('User'), 'user'),
15
  'category' => t('User'),
16
);
17

    
18
function ctools_user_picture_content_type_render($subtype, $conf, $panel_args, $context) {
19
  global $user;
20

    
21
  if (empty($context->data)) {
22
    return;
23
  }
24

    
25
  $account = clone $context->data;
26

    
27
  // Check if user has permissions to access the user.
28
  if ($user->uid != $account->uid && (!user_access('access user profiles') && !user_access('administer users'))) {
29
    return;
30
  }
31

    
32
  $block = new stdClass();
33
  $block->module = 'user-profile';
34
  $block->title = check_plain($account->name);
35

    
36
  $element['user_picture'] = array(
37
    '#theme' => 'user_picture',
38
    '#account' => $account,
39
  );
40

    
41
  $block->content = $element;
42
  return $block;
43
}
44

    
45
/**
46
 * Display the administrative title for a panel pane in the drag & drop UI.
47
 */
48
function ctools_user_picture_content_type_admin_title($subtype, $conf, $context) {
49
  return t('"@s" user picture', array('@s' => $context->identifier));
50
}
51

    
52
function ctools_user_picture_content_type_edit_form($form, &$form_state) {
53
  // Provide a blank form so we have a place to have context setting.
54
  return $form;
55
}