root / drupal7 / sites / all / modules / panelizer / plugins / entity / PanelizerEntityUser.class.php @ 73ab1d0a
1 | 85ad3d82 | Assos Assos | <?php
|
---|---|---|---|
2 | /**
|
||
3 | * @file
|
||
4 | * Class for the Panelizer taxonomy term entity plugin.
|
||
5 | */
|
||
6 | |||
7 | /**
|
||
8 | * Panelizer Entity user plugin class.
|
||
9 | *
|
||
10 | * Handles user specific functionality for Panelizer.
|
||
11 | */
|
||
12 | class PanelizerEntityUser extends PanelizerEntityDefault { |
||
13 | public $entity_admin_root = 'admin/config/people/accounts'; |
||
14 | // No bundle support so we hardcode the default bundle.
|
||
15 | public $entity_admin_bundle = 'user'; |
||
16 | public $views_table = 'users'; |
||
17 | public $uses_page_manager = TRUE; |
||
18 | |||
19 | public function entity_access($op, $entity) { |
||
20 | // This must be implemented by the extending class.
|
||
21 | if ($op == 'update' || $op == 'delete') { |
||
22 | return user_edit_access($entity); |
||
23 | } |
||
24 | |||
25 | if ($op == 'view') { |
||
26 | return user_view_access($entity); |
||
27 | } |
||
28 | |||
29 | return FALSE; |
||
30 | } |
||
31 | |||
32 | /**
|
||
33 | * Implement the save function for the entity.
|
||
34 | */
|
||
35 | public function entity_save($entity) { |
||
36 | // IMPORTANT NOTE: this can *only* update panelizer items!
|
||
37 | user_save($entity, array('panelizer' => $entity->panelizer)); |
||
38 | } |
||
39 | |||
40 | public function entity_identifier($entity) { |
||
41 | return t('This user'); |
||
42 | } |
||
43 | |||
44 | public function entity_bundle_label() { |
||
45 | return t('User'); |
||
46 | } |
||
47 | |||
48 | function get_default_display($bundle, $view_mode) { |
||
49 | // For now we just go with the empty display.
|
||
50 | // @todo come up with a better default display.
|
||
51 | return parent::get_default_display($bundle, $view_mode); |
||
52 | } |
||
53 | |||
54 | /**
|
||
55 | * Implements a delegated hook_page_manager_handlers().
|
||
56 | *
|
||
57 | * This makes sure that all panelized entities have the proper entry
|
||
58 | * in page manager for rendering.
|
||
59 | */
|
||
60 | public function hook_default_page_manager_handlers(&$handlers) { |
||
61 | $handler = new stdClass; |
||
62 | $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ |
||
63 | $handler->api_version = 1; |
||
64 | $handler->name = 'user_view_panelizer'; |
||
65 | $handler->task = 'user_view'; |
||
66 | $handler->subtask = ''; |
||
67 | $handler->handler = 'panelizer_node'; |
||
68 | $handler->weight = -100; |
||
69 | $handler->conf = array( |
||
70 | 'title' => t('User panelizer'), |
||
71 | 'context' => 'argument_entity_id:user_1', |
||
72 | 'access' => array(), |
||
73 | ); |
||
74 | $handlers['user_view_panelizer'] = $handler; |
||
75 | |||
76 | return $handlers; |
||
77 | } |
||
78 | |||
79 | /**
|
||
80 | * Implements a delegated hook_form_alter.
|
||
81 | *
|
||
82 | * We want to add Panelizer settings for the bundle to the node type form.
|
||
83 | */
|
||
84 | public function hook_form_alter(&$form, &$form_state, $form_id) { |
||
85 | if ($form_id == 'user_admin_settings') { |
||
86 | $this->add_bundle_setting_form($form, $form_state, 'user', NULL); |
||
87 | } |
||
88 | } |
||
89 | |||
90 | /**
|
||
91 | * Fetch the entity out of a build for hook_entity_view.
|
||
92 | *
|
||
93 | * @param $build
|
||
94 | * The render array that contains the entity.
|
||
95 | */
|
||
96 | public function get_entity_view_entity($build) { |
||
97 | $element = '#account'; |
||
98 | if (isset($build[$element])) { |
||
99 | return $build[$element]; |
||
100 | } |
||
101 | } |
||
102 | |||
103 | } |