Projet

Général

Profil

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

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

1
<?php
2

    
3
/**
4
 * Plugins are described by creating a $plugin array which will be used
5
 * by the system that includes this file.
6
 */
7
$plugin = array(
8
  'single' => TRUE,
9
  'title' => t('User picture'),
10
  'icon' => 'icon_user.png',
11
  'description' => t('The picture of a user.'),
12
  'required context' => new ctools_context_required(t('User'), 'user'),
13
  'category' => t('User'),
14
);
15

    
16
function ctools_user_picture_content_type_render($subtype, $conf, $panel_args, $context) {
17
  global $user;
18

    
19
  if (empty($context->data)) {
20
    return;
21
  }
22

    
23
  $account = clone $context->data;
24

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

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

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

    
39

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

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

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