@@ -12,83 +12,83 @@ |
||
12 | 12 | * Implementation of hook_token_values(). |
13 | 13 | */ |
14 | 14 | function content_profile_tokens_token_values($type, $object = NULL, $options = array()) { |
15 | - $values = array(); |
|
16 | - $types = content_profile_get_types('types'); |
|
17 | - switch ($type) { |
|
15 | + $values = array(); |
|
16 | + $types = content_profile_get_types('types'); |
|
17 | + switch ($type) { |
|
18 | 18 | case 'user': |
19 | 19 | foreach($types as $type_name => $type) { |
20 | 20 | if (isset($object)) { |
21 | - $profile = content_profile_load($type_name, $object->uid); |
|
21 | + $profile = content_profile_load($type_name, $object->uid); |
|
22 | 22 | } |
23 | 23 | else { |
24 | - global $user; |
|
25 | - $profile = content_profile_load($type_name, $user->uid); |
|
24 | + global $user; |
|
25 | + $profile = content_profile_load($type_name, $user->uid); |
|
26 | 26 | } |
27 | 27 | $fields = content_types($type_name); |
28 | 28 | foreach ($fields['fields'] as $field_name => $field) { |
29 | - if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
|
30 | - $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']); |
|
31 | - $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value']; |
|
32 | - } |
|
29 | + if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
|
30 | + $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']); |
|
31 | + $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value']; |
|
32 | + } |
|
33 | + } |
|
33 | 34 | } |
34 | - } |
|
35 | - break; |
|
35 | + break; |
|
36 | 36 | |
37 | 37 | case 'flag_friend': |
38 | 38 | if(!empty($object)) { |
39 | 39 | foreach($types as $type_name => $type) { |
40 | - $profile_requestor = content_profile_load($type_name, $object->friend->uid); |
|
41 | - $profile_requestee = content_profile_load($type_name, $object->uid); |
|
40 | + $profile_requestor = content_profile_load($type_name, $object->friend->uid); |
|
41 | + $profile_requestee = content_profile_load($type_name, $object->uid); |
|
42 | 42 | |
43 | - $fields = content_types($type_name); |
|
44 | - foreach ($fields['fields'] as $field_name => $field) { |
|
43 | + $fields = content_types($type_name); |
|
44 | + foreach ($fields['fields'] as $field_name => $field) { |
|
45 | 45 | if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
46 | - $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']); |
|
47 | - $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value']; |
|
46 | + $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']); |
|
47 | + $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value']; |
|
48 | 48 | |
49 | - $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']); |
|
50 | - $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value']; |
|
49 | + $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']); |
|
50 | + $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value']; |
|
51 | 51 | } |
52 | - } |
|
52 | + } |
|
53 | + } |
|
53 | 54 | } |
54 | - } |
|
55 | - break; |
|
56 | - } |
|
57 | - return $values; |
|
55 | + break; |
|
56 | + } |
|
57 | + return $values; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Implementation of hook_token_list(). |
62 | 62 | */ |
63 | 63 | function content_profile_tokens_token_list($type = 'all') { |
64 | - $tokens = array(); |
|
65 | - if ($type == 'user' || $type == 'all') { |
|
64 | + $tokens = array(); |
|
65 | + if ($type == 'user' || $type == 'all') { |
|
66 | 66 | $types = content_profile_get_types('types'); |
67 | 67 | foreach ($types as $type_name => $type) { |
68 | 68 | |
69 | - $fields = content_types($type_name); |
|
70 | - foreach ($fields['fields'] as $field_name => $field) { |
|
69 | + $fields = content_types($type_name); |
|
70 | + foreach ($fields['fields'] as $field_name => $field) { |
|
71 | 71 | if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
72 | - $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6)] = t($fields['description']) .'-'. t($field['widget']['label']); |
|
73 | - $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); |
|
72 | + $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6)] = t($fields['description']) .'-'. t($field['widget']['label']); |
|
73 | + $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); |
|
74 | + } |
|
74 | 75 | } |
75 | - } |
|
76 | 76 | } |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | - if ($type == 'flag_friend' && module_exists('flag_friend')) { |
|
79 | + if ($type == 'flag_friend' && module_exists('flag_friend')) { |
|
80 | 80 | foreach($types as $type_name => $type) { |
81 | - $fields = content_types($type_name); |
|
82 | - foreach ($fields['fields'] as $field_name => $field) { |
|
81 | + $fields = content_types($type_name); |
|
82 | + foreach ($fields['fields'] as $field_name => $field) { |
|
83 | 83 | if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { |
84 | - $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6)] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']); |
|
85 | - $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); |
|
84 | + $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6)] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']); |
|
85 | + $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); |
|
86 | 86 | |
87 | - $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6)] = t('Requestee:') . t($fields['description']) .'-'. t($field['widget']['label']); |
|
88 | - $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestee:') .t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); |
|
87 | + $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6)] = t('Requestee:') . t($fields['description']) .'-'. t($field['widget']['label']); |
|
88 | + $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestee:') .t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); |
|
89 | + } |
|
89 | 90 | } |
90 | - } |
|
91 | 91 | } |
92 | - } |
|
93 | - return $tokens; |
|
92 | + } |
|
93 | + return $tokens; |
|
94 | 94 | } |
@@ -11,56 +11,56 @@ discard block |
||
11 | 11 | * Implementation of hook_init(). |
12 | 12 | */ |
13 | 13 | function content_profile_init() { |
14 | - module_load_include('inc', 'content_profile', 'content_profile.theme_vars'); |
|
14 | + module_load_include('inc', 'content_profile', 'content_profile.theme_vars'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Implementation of hook_ctools_plugin_directory(). |
19 | 19 | */ |
20 | 20 | function content_profile_ctools_plugin_directory($module, $plugin) { |
21 | - if ($module == 'ctools' && $plugin == 'relationships') { |
|
21 | + if ($module == 'ctools' && $plugin == 'relationships') { |
|
22 | 22 | return 'panels/' . $plugin; |
23 | - } |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Implementation of hook_menu(). |
28 | 28 | */ |
29 | 29 | function content_profile_menu() { |
30 | - $items = array(); |
|
30 | + $items = array(); |
|
31 | 31 | |
32 | - //Register a path for each content profile type |
|
33 | - foreach (content_profile_get_types('names') as $type => $typename) { |
|
32 | + //Register a path for each content profile type |
|
33 | + foreach (content_profile_get_types('names') as $type => $typename) { |
|
34 | 34 | $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/edit'] = array( |
35 | - 'title' => 'Edit', |
|
36 | - 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
35 | + 'title' => 'Edit', |
|
36 | + 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
37 | 37 | ); |
38 | 38 | $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/profile'] = array( |
39 | - 'title' => 'Content profile', |
|
40 | - 'description' => 'Configure the display and management of this content profile.', |
|
41 | - 'page callback' => 'drupal_get_form', |
|
42 | - 'page arguments' => array('content_profile_admin_settings', $type), |
|
43 | - 'access callback' => 'user_access', |
|
44 | - 'access arguments' => array('administer nodes'), |
|
45 | - 'type' => MENU_LOCAL_TASK, |
|
46 | - 'weight' => 1, |
|
39 | + 'title' => 'Content profile', |
|
40 | + 'description' => 'Configure the display and management of this content profile.', |
|
41 | + 'page callback' => 'drupal_get_form', |
|
42 | + 'page arguments' => array('content_profile_admin_settings', $type), |
|
43 | + 'access callback' => 'user_access', |
|
44 | + 'access arguments' => array('administer nodes'), |
|
45 | + 'type' => MENU_LOCAL_TASK, |
|
46 | + 'weight' => 1, |
|
47 | 47 | ); |
48 | - } |
|
49 | - foreach (content_profile_get_types('names') as $type => $type_name) { |
|
48 | + } |
|
49 | + foreach (content_profile_get_types('names') as $type => $type_name) { |
|
50 | 50 | $items['user/%user/profile/'. $type] = array( |
51 | - 'title callback' => 'check_plain', |
|
52 | - 'title' => drupal_ucfirst($type_name), |
|
53 | - 'page callback' => 'content_profile_page_edit', |
|
54 | - 'page arguments' => array($type, 1), |
|
55 | - 'access callback' => 'content_profile_page_access', |
|
56 | - 'access arguments' => array($type, 1), |
|
57 | - 'weight' => content_profile_get_settings($type, 'weight'), |
|
58 | - 'file' => 'node.pages.inc', |
|
59 | - 'file path' => drupal_get_path('module', 'node'), |
|
60 | - 'type' => content_profile_get_settings($type, 'edit_tab') == 'top' ? MENU_LOCAL_TASK : MENU_CALLBACK, |
|
51 | + 'title callback' => 'check_plain', |
|
52 | + 'title' => drupal_ucfirst($type_name), |
|
53 | + 'page callback' => 'content_profile_page_edit', |
|
54 | + 'page arguments' => array($type, 1), |
|
55 | + 'access callback' => 'content_profile_page_access', |
|
56 | + 'access arguments' => array($type, 1), |
|
57 | + 'weight' => content_profile_get_settings($type, 'weight'), |
|
58 | + 'file' => 'node.pages.inc', |
|
59 | + 'file path' => drupal_get_path('module', 'node'), |
|
60 | + 'type' => content_profile_get_settings($type, 'edit_tab') == 'top' ? MENU_LOCAL_TASK : MENU_CALLBACK, |
|
61 | 61 | ); |
62 | - } |
|
63 | - return $items; |
|
62 | + } |
|
63 | + return $items; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -68,45 +68,45 @@ discard block |
||
68 | 68 | * Take over menu items generated by the user module for our categories. |
69 | 69 | */ |
70 | 70 | function content_profile_menu_alter(&$items) { |
71 | - foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) { |
|
71 | + foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) { |
|
72 | 72 | if (!empty($items['user/%user_category/edit/'. $type])) { |
73 | - $item = &$items['user/%user_category/edit/'. $type]; |
|
74 | - $item = array( |
|
73 | + $item = &$items['user/%user_category/edit/'. $type]; |
|
74 | + $item = array( |
|
75 | 75 | 'page callback' => 'content_profile_page_edit', |
76 | 76 | 'page arguments' => array($type, 1), |
77 | 77 | 'access callback' => 'content_profile_page_access', |
78 | 78 | 'access arguments' => array($type, 1), |
79 | 79 | 'file' => 'node.pages.inc', |
80 | 80 | 'file path' => drupal_get_path('module', 'node'), |
81 | - ) + $item; |
|
81 | + ) + $item; |
|
82 | + } |
|
82 | 83 | } |
83 | - } |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | function content_profile_page_access($type, $account) { |
88 | - if ($node = content_profile_load($type, $account->uid)) { |
|
88 | + if ($node = content_profile_load($type, $account->uid)) { |
|
89 | 89 | return node_access('update', $node); |
90 | - } |
|
91 | - // Else user may view the page when they are going to create their own profile |
|
92 | - // or have permission to create it for others. |
|
93 | - global $user; |
|
94 | - if ($user->uid == $account->uid || user_access('administer nodes') ){ |
|
90 | + } |
|
91 | + // Else user may view the page when they are going to create their own profile |
|
92 | + // or have permission to create it for others. |
|
93 | + global $user; |
|
94 | + if ($user->uid == $account->uid || user_access('administer nodes') ){ |
|
95 | 95 | return node_access('create', $type); |
96 | - } |
|
97 | - return FALSE; |
|
96 | + } |
|
97 | + return FALSE; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Presents a node editing or adding form for the given content profile. |
102 | 102 | */ |
103 | 103 | function content_profile_page_edit($type, $account) { |
104 | - drupal_set_title(check_plain($account->name)); |
|
105 | - $node = content_profile_load($type, $account->uid); |
|
106 | - if (!$node) { |
|
104 | + drupal_set_title(check_plain($account->name)); |
|
105 | + $node = content_profile_load($type, $account->uid); |
|
106 | + if (!$node) { |
|
107 | 107 | $node = array('uid' => $account->uid, 'name' => (isset($account->name) ? $account->name : ''), 'type' => $type, 'language' => ''); |
108 | - } |
|
109 | - return drupal_get_form($type .'_node_form', $node); |
|
108 | + } |
|
109 | + return drupal_get_form($type .'_node_form', $node); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * Implementation of hook_views_api(). |
115 | 115 | */ |
116 | 116 | function content_profile_views_api() { |
117 | - return array( |
|
117 | + return array( |
|
118 | 118 | 'api' => 2, |
119 | 119 | 'path' => drupal_get_path('module', 'content_profile') .'/views', |
120 | - ); |
|
120 | + ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
@@ -125,71 +125,71 @@ discard block |
||
125 | 125 | * Menu callback; content profile settings. |
126 | 126 | */ |
127 | 127 | function content_profile_admin_settings(&$form_state, $type) { |
128 | - $form_state['type'] = $type; |
|
128 | + $form_state['type'] = $type; |
|
129 | 129 | |
130 | - $form['weight'] = array( |
|
130 | + $form['weight'] = array( |
|
131 | 131 | '#type' => 'weight', |
132 | 132 | '#title' => t("Weight"), |
133 | 133 | '#default_value' => content_profile_get_settings($type, 'weight'), |
134 | 134 | '#description' => t('The weight of content of this content type where ever they appear - this applies to the input form integration as well to the display integration.'), |
135 | 135 | '#weight' => 5, |
136 | - ); |
|
137 | - $form['display'] = array( |
|
136 | + ); |
|
137 | + $form['display'] = array( |
|
138 | 138 | '#type' => 'fieldset', |
139 | 139 | '#title' => t('Display settings'), |
140 | 140 | '#description' => t('Customize the display of this content profile.'), |
141 | 141 | '#collapsible' => TRUE, |
142 | - ); |
|
143 | - $form['display']['user_display'] = array( |
|
142 | + ); |
|
143 | + $form['display']['user_display'] = array( |
|
144 | 144 | '#type' => 'radios', |
145 | 145 | '#title' => t("User page display style"), |
146 | 146 | '#default_value' => content_profile_get_settings($type, 'user_display'), |
147 | 147 | '#options' => array( |
148 | - 0 => t("Don't display this content profile on the user account page"), |
|
149 | - 'link' => t('Display it as link to the profile content'), |
|
150 | - 'full' => t('Display the full content'), |
|
151 | - 'teaser' => t("Display the content's teaser"), |
|
148 | + 0 => t("Don't display this content profile on the user account page"), |
|
149 | + 'link' => t('Display it as link to the profile content'), |
|
150 | + 'full' => t('Display the full content'), |
|
151 | + 'teaser' => t("Display the content's teaser"), |
|
152 | 152 | ), |
153 | - ); |
|
154 | - $form['display']['edit_link'] = array( |
|
153 | + ); |
|
154 | + $form['display']['edit_link'] = array( |
|
155 | 155 | '#type' => 'checkbox', |
156 | 156 | '#title' => t("Include an edit link to the display"), |
157 | 157 | '#default_value' => content_profile_get_settings($type, 'edit_link'), |
158 | - ); |
|
159 | - $form['display']['add_link'] = array( |
|
158 | + ); |
|
159 | + $form['display']['add_link'] = array( |
|
160 | 160 | '#type' => 'checkbox', |
161 | 161 | '#title' => t("Show a link to the content profile creation page, if there is no profile."), |
162 | 162 | '#default_value' => content_profile_get_settings($type, 'add_link'), |
163 | 163 | '#description' => t("If selected and the user has no profile of this type yet, a link to add one is shown on the user page."), |
164 | - ); |
|
165 | - $form['display']['edit_tab'] = array( |
|
164 | + ); |
|
165 | + $form['display']['edit_tab'] = array( |
|
166 | 166 | '#type' => 'radios', |
167 | 167 | '#title' => t("Profile edit tab"), |
168 | 168 | '#default_value' => content_profile_get_settings($type, 'edit_tab'), |
169 | 169 | '#options' => array( |
170 | - 0 => t('None'), |
|
171 | - 'top' => t("Show a tab at the user's page"), |
|
172 | - 'sub' => t("Show a secondary tab below the user's edit tab"), |
|
170 | + 0 => t('None'), |
|
171 | + 'top' => t("Show a tab at the user's page"), |
|
172 | + 'sub' => t("Show a secondary tab below the user's edit tab"), |
|
173 | 173 | ), |
174 | - ); |
|
175 | - $form['submit'] = array( |
|
174 | + ); |
|
175 | + $form['submit'] = array( |
|
176 | 176 | '#type' => 'submit', |
177 | 177 | '#value' => t('Submit'), |
178 | 178 | '#weight' => 10, |
179 | - ); |
|
180 | - return $form; |
|
179 | + ); |
|
180 | + return $form; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | function content_profile_admin_settings_submit($form, &$form_state) { |
184 | - $settings = content_profile_get_settings($form_state['type']); |
|
185 | - foreach (content_profile_settings_info() as $setting => $default) { |
|
184 | + $settings = content_profile_get_settings($form_state['type']); |
|
185 | + foreach (content_profile_settings_info() as $setting => $default) { |
|
186 | 186 | if (isset($form_state['values'][$setting])) { |
187 | - $settings[$setting] = $form_state['values'][$setting]; |
|
187 | + $settings[$setting] = $form_state['values'][$setting]; |
|
188 | + } |
|
188 | 189 | } |
189 | - } |
|
190 | - content_profile_set_settings($form_state['type'], $settings); |
|
191 | - drupal_set_message('Your changes have been saved.'); |
|
192 | - menu_rebuild(); |
|
190 | + content_profile_set_settings($form_state['type'], $settings); |
|
191 | + drupal_set_message('Your changes have been saved.'); |
|
192 | + menu_rebuild(); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | * The node object or the node's type |
199 | 199 | */ |
200 | 200 | function is_content_profile($type) { |
201 | - if (is_object($type)) { |
|
201 | + if (is_object($type)) { |
|
202 | 202 | $type = $type->type; |
203 | - } |
|
204 | - return variable_get('content_profile_use_'. $type, FALSE); |
|
203 | + } |
|
204 | + return variable_get('content_profile_use_'. $type, FALSE); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * The value to compare the given setting too. |
219 | 219 | */ |
220 | 220 | function content_profile_get_types($op = 'types', $setting = NULL , $value = TRUE) { |
221 | - $types = array(); |
|
221 | + $types = array(); |
|
222 | 222 | |
223 | - foreach (node_get_types($op) as $type => $info) { |
|
223 | + foreach (node_get_types($op) as $type => $info) { |
|
224 | 224 | if (is_content_profile($type) && (!isset($setting) || content_profile_get_settings($type, $setting) == $value)) { |
225 | - $types[$type] = $info; |
|
225 | + $types[$type] = $info; |
|
226 | 226 | } |
227 | - } |
|
228 | - return $types; |
|
227 | + } |
|
228 | + return $types; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -233,79 +233,79 @@ discard block |
||
233 | 233 | * Rename or delete the settings variable if a type changes. |
234 | 234 | */ |
235 | 235 | function content_profile_node_type($op, $info) { |
236 | - switch ($op) { |
|
236 | + switch ($op) { |
|
237 | 237 | case 'delete': |
238 | 238 | variable_del('content_profile_use_'. $info->type); |
239 | - variable_del('content_profile_'. $info->type); |
|
240 | - break; |
|
239 | + variable_del('content_profile_'. $info->type); |
|
240 | + break; |
|
241 | 241 | case 'update': |
242 | 242 | if (!empty($info->old_type) && $info->old_type != $info->type) { |
243 | 243 | if (is_content_profile($info->old_type)) { |
244 | - $settings = variable_get('content_profile_'. $info->old_type, array()); |
|
245 | - variable_del('content_profile_use_'. $info->old_type); |
|
246 | - variable_del('content_profile_'. $info->old_type); |
|
247 | - variable_set('content_profile_use_'. $info->type, 1); |
|
248 | - variable_set('content_profile_'. $info->type, $settings); |
|
244 | + $settings = variable_get('content_profile_'. $info->old_type, array()); |
|
245 | + variable_del('content_profile_use_'. $info->old_type); |
|
246 | + variable_del('content_profile_'. $info->old_type); |
|
247 | + variable_set('content_profile_use_'. $info->type, 1); |
|
248 | + variable_set('content_profile_'. $info->type, $settings); |
|
249 | + } |
|
249 | 250 | } |
250 | - } |
|
251 | - break; |
|
252 | - } |
|
251 | + break; |
|
252 | + } |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | 256 | * Implementation of hook_form_alter(). |
257 | 257 | */ |
258 | 258 | function content_profile_form_alter(&$form, $form_state, $form_id) { |
259 | - if ($form_id == 'node_type_form') { |
|
259 | + if ($form_id == 'node_type_form') { |
|
260 | 260 | $form['content_profile'] = array( |
261 | - '#type' => 'fieldset', |
|
262 | - '#title' => t('Content Profile'), |
|
263 | - '#group' => 'additional_settings', |
|
264 | - '#collapsible' => TRUE, |
|
265 | - '#collapsed' => TRUE, |
|
266 | - '#weight' => 32, |
|
261 | + '#type' => 'fieldset', |
|
262 | + '#title' => t('Content Profile'), |
|
263 | + '#group' => 'additional_settings', |
|
264 | + '#collapsible' => TRUE, |
|
265 | + '#collapsed' => TRUE, |
|
266 | + '#weight' => 32, |
|
267 | 267 | ); |
268 | 268 | $form['content_profile']['content_profile_use'] = array( |
269 | - '#type' => 'checkbox', |
|
270 | - '#title' => t('Use this content type as a content profile for users'), |
|
271 | - '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE), |
|
269 | + '#type' => 'checkbox', |
|
270 | + '#title' => t('Use this content type as a content profile for users'), |
|
271 | + '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE), |
|
272 | 272 | ); |
273 | - } |
|
274 | - elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) { |
|
273 | + } |
|
274 | + elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) { |
|
275 | 275 | // Customize the redirect target and buttons of our own node forms. |
276 | 276 | if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') { |
277 | - $form['buttons']['preview']['#access'] = FALSE; |
|
278 | - $form['buttons']['delete']['#access'] = FALSE; |
|
279 | - $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q']; |
|
277 | + $form['buttons']['preview']['#access'] = FALSE; |
|
278 | + $form['buttons']['delete']['#access'] = FALSE; |
|
279 | + $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q']; |
|
280 | 280 | } |
281 | 281 | // Set the author value - note that this works only for admins. |
282 | 282 | if (!empty($_GET['uid']) && ($uid = intval($_GET['uid'])) && ($user = user_load($uid))) { |
283 | - $form['author']['name']['#default_value'] = $user->name; |
|
283 | + $form['author']['name']['#default_value'] = $user->name; |
|
284 | + } |
|
284 | 285 | } |
285 | - } |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Implementation of hook_user(). |
290 | 290 | */ |
291 | 291 | function content_profile_user($op, &$edit, &$account, $category = NULL) { |
292 | - global $user; |
|
292 | + global $user; |
|
293 | 293 | |
294 | - switch ($op) { |
|
294 | + switch ($op) { |
|
295 | 295 | case 'categories': |
296 | 296 | $data = array(); |
297 | - foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) { |
|
297 | + foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) { |
|
298 | 298 | $data[] = array( |
299 | - 'name' => $type, |
|
300 | - 'title' => drupal_ucfirst($type_name), |
|
301 | - 'weight' => content_profile_get_settings($type, 'weight') + 1, |
|
299 | + 'name' => $type, |
|
300 | + 'title' => drupal_ucfirst($type_name), |
|
301 | + 'weight' => content_profile_get_settings($type, 'weight') + 1, |
|
302 | 302 | ); |
303 | - } |
|
304 | - return $data; |
|
303 | + } |
|
304 | + return $data; |
|
305 | 305 | |
306 | 306 | case 'view': |
307 | 307 | $account->content['content_profile'] = content_profile_show_profiles($account->uid); |
308 | - break; |
|
308 | + break; |
|
309 | 309 | |
310 | 310 | case 'delete': |
311 | 311 | // Retrieve all profile nodes (in any language) for this user by issueing an SQL query. |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | |
316 | 316 | $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments); |
317 | 317 | while ($node = db_fetch_object($result)) { |
318 | - _content_profile_node_delete($node); |
|
318 | + _content_profile_node_delete($node); |
|
319 | + } |
|
319 | 320 | } |
320 | - } |
|
321 | - break; |
|
322 | - } |
|
321 | + break; |
|
322 | + } |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -333,42 +333,42 @@ discard block |
||
333 | 333 | * "SELECT * FROM {node}" query) instead of just the $nid. |
334 | 334 | */ |
335 | 335 | function _content_profile_node_delete($node) { |
336 | - // Copied over from node_load(), so that node_invoke('delete') gets |
|
337 | - // the fully extended node object, like modules would expect: |
|
336 | + // Copied over from node_load(), so that node_invoke('delete') gets |
|
337 | + // the fully extended node object, like modules would expect: |
|
338 | 338 | |
339 | - if ($node->nid) { |
|
339 | + if ($node->nid) { |
|
340 | 340 | // Call the node specific callback (if any) and piggy-back the |
341 | 341 | // results to the node or overwrite some values. |
342 | 342 | if ($extra = node_invoke($node, 'load')) { |
343 | - foreach ($extra as $key => $value) { |
|
343 | + foreach ($extra as $key => $value) { |
|
344 | 344 | $node->$key = $value; |
345 | - } |
|
345 | + } |
|
346 | 346 | } |
347 | 347 | if ($extra = node_invoke_nodeapi($node, 'load')) { |
348 | - foreach ($extra as $key => $value) { |
|
348 | + foreach ($extra as $key => $value) { |
|
349 | 349 | $node->$key = $value; |
350 | - } |
|
350 | + } |
|
351 | + } |
|
351 | 352 | } |
352 | - } |
|
353 | 353 | |
354 | - // Copied over from node_delete(): |
|
354 | + // Copied over from node_delete(): |
|
355 | 355 | |
356 | - db_query('DELETE FROM {node} WHERE nid = %d', $node->nid); |
|
357 | - db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid); |
|
356 | + db_query('DELETE FROM {node} WHERE nid = %d', $node->nid); |
|
357 | + db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid); |
|
358 | 358 | |
359 | - // Call the node-specific callback (if any): |
|
360 | - node_invoke($node, 'delete'); |
|
361 | - node_invoke_nodeapi($node, 'delete'); |
|
359 | + // Call the node-specific callback (if any): |
|
360 | + node_invoke($node, 'delete'); |
|
361 | + node_invoke_nodeapi($node, 'delete'); |
|
362 | 362 | |
363 | - // Clear the cache so an anonymous poster can see the node being deleted. |
|
364 | - cache_clear_all(); |
|
363 | + // Clear the cache so an anonymous poster can see the node being deleted. |
|
364 | + cache_clear_all(); |
|
365 | 365 | |
366 | - // Remove this node from the search index if needed. |
|
367 | - if (function_exists('search_wipe')) { |
|
366 | + // Remove this node from the search index if needed. |
|
367 | + if (function_exists('search_wipe')) { |
|
368 | 368 | search_wipe($node->nid, 'node'); |
369 | - } |
|
370 | - watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title)); |
|
371 | - drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title))); |
|
369 | + } |
|
370 | + watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title)); |
|
371 | + drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title))); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -376,30 +376,30 @@ discard block |
||
376 | 376 | */ |
377 | 377 | function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { |
378 | 378 | |
379 | - if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') { |
|
379 | + if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') { |
|
380 | 380 | // Check if this nodetype already exists |
381 | 381 | if ($nid = content_profile_profile_exists($node, $node->uid)) { |
382 | - // This node already exists, redirect to edit page |
|
383 | - drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid); |
|
382 | + // This node already exists, redirect to edit page |
|
383 | + drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid); |
|
384 | 384 | } |
385 | - } |
|
386 | - elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) { |
|
385 | + } |
|
386 | + elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) { |
|
387 | 387 | $form = $a3; |
388 | 388 | // Only validate if the user-name changed or we add a new node |
389 | 389 | if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) { |
390 | - return; |
|
390 | + return; |
|
391 | 391 | } |
392 | 392 | //check whether the selected user has already a profile |
393 | 393 | $uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $node->name)); |
394 | 394 | if ($uid && content_profile_profile_exists($node, $uid)) { |
395 | - form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.')); |
|
395 | + form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.')); |
|
396 | + } |
|
396 | 397 | } |
397 | - } |
|
398 | - elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) { |
|
398 | + elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) { |
|
399 | 399 | // Make sure the translated profile belongs to the same user. |
400 | 400 | $node->uid = $node->translation_source->uid; |
401 | 401 | $node->name = $node->translation_source->name; |
402 | - } |
|
402 | + } |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | * @return If a node exists, the node id, FALSE else. |
413 | 413 | */ |
414 | 414 | function content_profile_profile_exists($node, $uid) { |
415 | - $query = "SELECT n.nid AS nid FROM {node} n WHERE n.type = '%s' AND n.uid = %d "; |
|
416 | - if (module_exists('translation') && translation_supported_type($node->type)) { |
|
415 | + $query = "SELECT n.nid AS nid FROM {node} n WHERE n.type = '%s' AND n.uid = %d "; |
|
416 | + if (module_exists('translation') && translation_supported_type($node->type)) { |
|
417 | 417 | $query .= "AND n.language = '%s'"; |
418 | - } |
|
419 | - return db_result(db_query($query, $node->type, $uid, $node->language)); |
|
418 | + } |
|
419 | + return db_result(db_query($query, $node->type, $uid, $node->language)); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -428,19 +428,19 @@ discard block |
||
428 | 428 | * e.g. user_edit, register or weight. |
429 | 429 | */ |
430 | 430 | function content_profile_get_settings($type, $return = 'all') { |
431 | - $settings = variable_get('content_profile_'. $type, array()); |
|
432 | - $settings += content_profile_settings_info(); |
|
433 | - if ($return == 'all') { |
|
431 | + $settings = variable_get('content_profile_'. $type, array()); |
|
432 | + $settings += content_profile_settings_info(); |
|
433 | + if ($return == 'all') { |
|
434 | 434 | return $settings; |
435 | - } |
|
436 | - return $settings[$return]; |
|
435 | + } |
|
436 | + return $settings[$return]; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
440 | 440 | * Saves the content_profile settings of a content type. |
441 | 441 | */ |
442 | 442 | function content_profile_set_settings($type, $settings) { |
443 | - variable_set('content_profile_'. $type, $settings); |
|
443 | + variable_set('content_profile_'. $type, $settings); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * and their default value. |
449 | 449 | */ |
450 | 450 | function content_profile_settings_info() { |
451 | - return module_invoke_all('content_profile_settings'); |
|
451 | + return module_invoke_all('content_profile_settings'); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | * Defines content profile settings and their default value. |
458 | 458 | */ |
459 | 459 | function content_profile_content_profile_settings() { |
460 | - return array( |
|
460 | + return array( |
|
461 | 461 | 'weight' => 0, |
462 | 462 | 'user_display' => 'full', |
463 | 463 | 'edit_link' => 0, |
464 | 464 | 'edit_tab' => 'sub', |
465 | 465 | 'add_link' => 1, |
466 | - ); |
|
466 | + ); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | * Optional. If set, the cache is reset. |
480 | 480 | */ |
481 | 481 | function content_profile_load($type, $uid, $lang = '', $reset = NULL) { |
482 | - static $cache = array(); |
|
482 | + static $cache = array(); |
|
483 | 483 | |
484 | - if (!isset($cache[$type][$uid][$lang]) || $reset) { |
|
484 | + if (!isset($cache[$type][$uid][$lang]) || $reset) { |
|
485 | 485 | $cache[$type][$uid][$lang] = FALSE; |
486 | 486 | $params = array('type' => $type, 'uid' => $uid); |
487 | 487 | if ($node = node_load($lang ? $params + array('language' => $lang) : $params, NULL, $reset)) { |
488 | - $cache[$type][$uid][$lang] = $node->nid; |
|
488 | + $cache[$type][$uid][$lang] = $node->nid; |
|
489 | 489 | } |
490 | 490 | return $node; |
491 | - } |
|
492 | - return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE; |
|
491 | + } |
|
492 | + return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -498,19 +498,19 @@ discard block |
||
498 | 498 | * Show node submission guidelines for content profile node forms. |
499 | 499 | */ |
500 | 500 | function content_profile_help($path, $arg) { |
501 | - if (preg_match('/user\/\%\/(profile|edit)\/(.*)/', $path, $matches)) { |
|
501 | + if (preg_match('/user\/\%\/(profile|edit)\/(.*)/', $path, $matches)) { |
|
502 | 502 | foreach (content_profile_get_types('names') as $type => $typename) { |
503 | - if ($type == $matches[2]) { |
|
503 | + if ($type == $matches[2]) { |
|
504 | 504 | $node = content_profile_load($type, $arg[1]); |
505 | 505 | if ($node) { |
506 | - return node_help('node/%/edit', array(1 => $node->nid)); |
|
506 | + return node_help('node/%/edit', array(1 => $node->nid)); |
|
507 | 507 | } |
508 | 508 | else { |
509 | - return node_help('node/add/'. $type, array('node', 'add', $type)); |
|
509 | + return node_help('node/add/'. $type, array('node', 'add', $type)); |
|
510 | 510 | } |
511 | - } |
|
511 | + } |
|
512 | + } |
|
512 | 513 | } |
513 | - } |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -518,14 +518,14 @@ discard block |
||
518 | 518 | * that shows all content_profiles as configured by the admin. |
519 | 519 | */ |
520 | 520 | function content_profile_show_profiles($uid) { |
521 | - global $user; |
|
521 | + global $user; |
|
522 | 522 | |
523 | - $content = array(); |
|
524 | - foreach (content_profile_get_types('names') as $type => $type_name) { |
|
523 | + $content = array(); |
|
524 | + foreach (content_profile_get_types('names') as $type => $type_name) { |
|
525 | 525 | $node = content_profile_load($type, $uid); |
526 | 526 | |
527 | 527 | if (($style = content_profile_get_settings($type, 'user_display')) && $node && node_access('view', $node)) { |
528 | - $content['content_profile_'. $type] = array( |
|
528 | + $content['content_profile_'. $type] = array( |
|
529 | 529 | '#theme' => ($style == 'link') ? 'content_profile_display_link' : 'content_profile_display_view', |
530 | 530 | '#edit_link' => content_profile_get_settings($type, 'edit_link'), |
531 | 531 | '#uid' => $uid, |
@@ -533,59 +533,59 @@ discard block |
||
533 | 533 | '#content_type' => $type, |
534 | 534 | '#weight' => content_profile_get_settings($type, 'weight'), |
535 | 535 | '#suffix' => '<br />', |
536 | - ); |
|
536 | + ); |
|
537 | 537 | |
538 | - // Working around the bug described at http://drupal.org/node/302873 |
|
539 | - module_load_include('inc', 'content_profile', 'content_profile.theme'); |
|
538 | + // Working around the bug described at http://drupal.org/node/302873 |
|
539 | + module_load_include('inc', 'content_profile', 'content_profile.theme'); |
|
540 | 540 | } |
541 | 541 | elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) { |
542 | - $content['content_profile_'. $type] = array( |
|
542 | + $content['content_profile_'. $type] = array( |
|
543 | 543 | '#admin' => $uid != $user->uid, |
544 | 544 | '#theme' => 'content_profile_display_add_link', |
545 | 545 | '#uid' => $uid, |
546 | 546 | '#content_type' => $type, |
547 | 547 | '#weight' => content_profile_get_settings($type, 'weight'), |
548 | 548 | '#suffix' => '<br />', |
549 | - ); |
|
549 | + ); |
|
550 | + } |
|
550 | 551 | } |
551 | - } |
|
552 | - if ($content) { |
|
552 | + if ($content) { |
|
553 | 553 | $content['#prefix'] = '<p id="content-profile-view">'; |
554 | 554 | $content['#suffix'] = '</p>'; |
555 | - } |
|
556 | - return $content; |
|
555 | + } |
|
556 | + return $content; |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
560 | 560 | * Implementation of hook_theme(). |
561 | 561 | */ |
562 | 562 | function content_profile_theme() { |
563 | - $return = array( |
|
563 | + $return = array( |
|
564 | 564 | 'content_profile_display_view' => array( |
565 | - 'template' => 'content_profile-display-view', |
|
566 | - 'arguments' => array('element' => NULL), |
|
567 | - 'file' => 'content_profile.theme.inc', |
|
565 | + 'template' => 'content_profile-display-view', |
|
566 | + 'arguments' => array('element' => NULL), |
|
567 | + 'file' => 'content_profile.theme.inc', |
|
568 | 568 | ), |
569 | 569 | 'content_profile_display_add_link' => array( |
570 | - 'file' => 'content_profile.theme.inc', |
|
570 | + 'file' => 'content_profile.theme.inc', |
|
571 | 571 | ), |
572 | 572 | 'content_profile_display_link' => array( |
573 | - 'file' => 'content_profile.theme.inc', |
|
573 | + 'file' => 'content_profile.theme.inc', |
|
574 | 574 | ), |
575 | 575 | 'content_profile_display_tab_view' => array( |
576 | - 'file' => 'content_profile.theme.inc', |
|
576 | + 'file' => 'content_profile.theme.inc', |
|
577 | 577 | ), |
578 | 578 | 'content_profile_display_tab_edit' => array( |
579 | - 'file' => 'content_profile.theme.inc', |
|
579 | + 'file' => 'content_profile.theme.inc', |
|
580 | 580 | ), |
581 | - ); |
|
582 | - if (module_exists('pageroute')) { |
|
581 | + ); |
|
582 | + if (module_exists('pageroute')) { |
|
583 | 583 | $return['content_profile_pageroute_empty'] = array( |
584 | - 'arguments' => array('type_name' => NULL), |
|
585 | - 'file' => 'content_profile.pageroute.inc', |
|
584 | + 'arguments' => array('type_name' => NULL), |
|
585 | + 'file' => 'content_profile.pageroute.inc', |
|
586 | 586 | ); |
587 | - } |
|
588 | - return $return; |
|
587 | + } |
|
588 | + return $return; |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * $conf['content_profile_extra_templates'] in settings.php. |
595 | 595 | */ |
596 | 596 | function content_profile_theme_registry_alter(&$items) { |
597 | - $templates = array_merge(array( |
|
597 | + $templates = array_merge(array( |
|
598 | 598 | 'author_pane', |
599 | 599 | 'comment', |
600 | 600 | 'node', |
@@ -603,47 +603,47 @@ discard block |
||
603 | 603 | 'username', |
604 | 604 | 'user_profile', |
605 | 605 | 'user_signature', |
606 | - ), variable_get('content_profile_extra_templates', array())); |
|
606 | + ), variable_get('content_profile_extra_templates', array())); |
|
607 | 607 | |
608 | - foreach ($templates as $key) { |
|
608 | + foreach ($templates as $key) { |
|
609 | 609 | if (isset($items[$key])) { |
610 | - $items[$key] += array('preprocess functions' => array()); |
|
611 | - $items[$key]['preprocess functions'][] = 'content_profile_template_preprocess'; |
|
610 | + $items[$key] += array('preprocess functions' => array()); |
|
611 | + $items[$key]['preprocess functions'][] = 'content_profile_template_preprocess'; |
|
612 | + } |
|
612 | 613 | } |
613 | - } |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
617 | 617 | * Adds $content_profile variable if we can find a $uid. |
618 | 618 | */ |
619 | 619 | function content_profile_template_preprocess(&$variables, $hook) { |
620 | - // Search the uid |
|
621 | - foreach (array('account_id', 'uid', 'account', 'node', 'comment', 'user') as $name) { |
|
620 | + // Search the uid |
|
621 | + foreach (array('account_id', 'uid', 'account', 'node', 'comment', 'user') as $name) { |
|
622 | 622 | if (isset($variables[$name])) { |
623 | - $uid = is_object($variables[$name]) ? $variables[$name]->uid : $variables[$name]; |
|
624 | - $variables['content_profile'] = new content_profile_theme_variables($uid); |
|
625 | - break; |
|
623 | + $uid = is_object($variables[$name]) ? $variables[$name]->uid : $variables[$name]; |
|
624 | + $variables['content_profile'] = new content_profile_theme_variables($uid); |
|
625 | + break; |
|
626 | + } |
|
626 | 627 | } |
627 | - } |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
631 | 631 | * Implementation of hook_simpletest(). |
632 | 632 | */ |
633 | 633 | function content_profile_simpletest() { |
634 | - // Scan through content_profile/tests directory for any .test files to tell SimpleTest module. |
|
635 | - $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test'); |
|
636 | - return array_keys($tests); |
|
634 | + // Scan through content_profile/tests directory for any .test files to tell SimpleTest module. |
|
635 | + $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test'); |
|
636 | + return array_keys($tests); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
640 | 640 | * Implementation of hook_pageroute_info() for Pageroute integration. |
641 | 641 | */ |
642 | 642 | function content_profile_pageroute_info() { |
643 | - return array( |
|
643 | + return array( |
|
644 | 644 | 'content_profile' => array( |
645 | - 'viewprofile' => 'content_profile.pageroute', |
|
646 | - 'editprofile' => 'content_profile.pageroute', |
|
645 | + 'viewprofile' => 'content_profile.pageroute', |
|
646 | + 'editprofile' => 'content_profile.pageroute', |
|
647 | 647 | ) |
648 | - ); |
|
648 | + ); |
|
649 | 649 | } |
@@ -10,79 +10,79 @@ discard block |
||
10 | 10 | * Implementation of hook_rules_condition_info(). |
11 | 11 | */ |
12 | 12 | function content_profile_rules_condition_info() { |
13 | - return array( |
|
13 | + return array( |
|
14 | 14 | 'content_profile_user_has_profile_condition' => array( |
15 | - 'label' => t('User has content profile'), |
|
16 | - 'arguments' => array( |
|
15 | + 'label' => t('User has content profile'), |
|
16 | + 'arguments' => array( |
|
17 | 17 | 'user' => array('type' => 'user', 'label' => t('User')), |
18 | - ), |
|
19 | - 'module' => 'Content Profile', |
|
18 | + ), |
|
19 | + 'module' => 'Content Profile', |
|
20 | 20 | ), |
21 | - ); |
|
21 | + ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | function content_profile_user_has_profile_condition($user, $settings) { |
25 | - $node = content_profile_load($settings['type'], $user->uid); |
|
26 | - return (bool)$node; |
|
25 | + $node = content_profile_load($settings['type'], $user->uid); |
|
26 | + return (bool)$node; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | function content_profile_user_has_profile_condition_form($settings, &$form) { |
30 | - $settings += array('type' => array()); |
|
31 | - $form['settings']['type'] = array( |
|
30 | + $settings += array('type' => array()); |
|
31 | + $form['settings']['type'] = array( |
|
32 | 32 | '#type' => 'select', |
33 | 33 | '#title' => t('Content Profile Content Type'), |
34 | 34 | '#options' => content_profile_get_types('names'), |
35 | 35 | '#default_value' => $settings['type'], |
36 | 36 | '#description' => t('Select the Content Profile content type to check for.'), |
37 | 37 | '#required' => TRUE, |
38 | - ); |
|
38 | + ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function content_profile_user_has_profile_condition_label($settings, $argument_labels) { |
42 | - return t('@user has his @type created', $argument_labels + array('@type' => node_get_types('name', $settings['type']))); |
|
42 | + return t('@user has his @type created', $argument_labels + array('@type' => node_get_types('name', $settings['type']))); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Implementation of hook_rules_action_info(). |
47 | 47 | */ |
48 | 48 | function content_profile_rules_action_info() { |
49 | - return array( |
|
49 | + return array( |
|
50 | 50 | 'content_profile_action_load' => array( |
51 | - 'label' => t('Load Content Profile'), |
|
52 | - 'arguments' => array( |
|
51 | + 'label' => t('Load Content Profile'), |
|
52 | + 'arguments' => array( |
|
53 | 53 | 'user' => array('type' => 'user', 'label' => t('User, whose profile should be loaded')), |
54 | - ), |
|
55 | - 'new variables' => array( |
|
54 | + ), |
|
55 | + 'new variables' => array( |
|
56 | 56 | 'profile_node' => array('type' => 'node', 'label' => t('Content Profile')), |
57 | - ), |
|
58 | - 'module' => 'Content Profile', |
|
57 | + ), |
|
58 | + 'module' => 'Content Profile', |
|
59 | 59 | ), |
60 | - ); |
|
60 | + ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Loads a Content Profile |
65 | 65 | */ |
66 | 66 | function content_profile_action_load($user, $settings) { |
67 | - if ($node = content_profile_load($settings['type'], $user->uid)) { |
|
67 | + if ($node = content_profile_load($settings['type'], $user->uid)) { |
|
68 | 68 | return array('profile_node' => $node); |
69 | - } |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function content_profile_action_load_form($settings, &$form) { |
73 | - $settings += array('type' => array()); |
|
74 | - $form['settings']['type'] = array( |
|
73 | + $settings += array('type' => array()); |
|
74 | + $form['settings']['type'] = array( |
|
75 | 75 | '#type' => 'select', |
76 | 76 | '#title' => t('Content Profile Content Type'), |
77 | 77 | '#options' => content_profile_get_types('names'), |
78 | 78 | '#default_value' => $settings['type'], |
79 | 79 | '#description' => t('Select the Content Profile content type to load.'), |
80 | 80 | '#required' => TRUE, |
81 | - ); |
|
81 | + ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | function content_profile_action_load_label($settings, $argument_labels) { |
85 | - return t("Load @user's @type", $argument_labels + array('@type' => node_get_types('name', $settings['type']))); |
|
85 | + return t("Load @user's @type", $argument_labels + array('@type' => node_get_types('name', $settings['type']))); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * Support upgrading from nodeprofile-workflow-ng integration. |
91 | 91 | */ |
92 | 92 | function nodeprofile_user_has_profile_condition_upgrade(&$element) { |
93 | - $element['#name'] = 'content_profile_user_has_profile_condition'; |
|
93 | + $element['#name'] = 'content_profile_user_has_profile_condition'; |
|
94 | 94 | } |
95 | 95 | function nodeprofile_action_load_upgrade(&$element) { |
96 | - $element['#name'] = 'content_profile_action_load'; |
|
96 | + $element['#name'] = 'content_profile_action_load'; |
|
97 | 97 | } |
@@ -6,46 +6,46 @@ discard block |
||
6 | 6 | * Specialized relationship handler to adding content profiles. |
7 | 7 | */ |
8 | 8 | class content_profile_views_handler_relationship extends views_handler_relationship { |
9 | - function option_definition() { |
|
9 | + function option_definition() { |
|
10 | 10 | $options = parent::option_definition(); |
11 | 11 | |
12 | 12 | $options['type'] = array('default' => ''); |
13 | 13 | return $options; |
14 | - } |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * Adds a form element for choosing the right content type. |
|
18 | - */ |
|
19 | - function options_form(&$form, &$form_state) { |
|
16 | + /** |
|
17 | + * Adds a form element for choosing the right content type. |
|
18 | + */ |
|
19 | + function options_form(&$form, &$form_state) { |
|
20 | 20 | parent::options_form($form, $form_state); |
21 | 21 | |
22 | 22 | $form['type'] = array( |
23 | - '#type' => 'radios', |
|
24 | - '#title' => t('Content type'), |
|
25 | - '#default_value' => $this->options['type'], |
|
26 | - '#options' => content_profile_get_types('names'), |
|
27 | - '#required' => TRUE, |
|
23 | + '#type' => 'radios', |
|
24 | + '#title' => t('Content type'), |
|
25 | + '#default_value' => $this->options['type'], |
|
26 | + '#options' => content_profile_get_types('names'), |
|
27 | + '#required' => TRUE, |
|
28 | 28 | ); |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Called to implement a relationship in a query. |
|
33 | - */ |
|
34 | - function query() { |
|
31 | + /** |
|
32 | + * Called to implement a relationship in a query. |
|
33 | + */ |
|
34 | + function query() { |
|
35 | 35 | // Figure out what base table this relationship brings to the party. |
36 | 36 | $join = new views_join(); |
37 | 37 | $join->definition = array( |
38 | - 'table' => 'node', |
|
39 | - 'field' => 'uid', |
|
40 | - 'left_table' => !empty($this->relationship) ? $this->relationship : 'users', |
|
41 | - 'left_field' => 'uid', |
|
42 | - 'extra' => array( |
|
38 | + 'table' => 'node', |
|
39 | + 'field' => 'uid', |
|
40 | + 'left_table' => !empty($this->relationship) ? $this->relationship : 'users', |
|
41 | + 'left_field' => 'uid', |
|
42 | + 'extra' => array( |
|
43 | 43 | array('field' => 'type', 'value' => $this->options['type']), |
44 | - ), |
|
44 | + ), |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | if (!empty($this->options['required'])) { |
48 | - $join->definition['type'] = 'INNER'; |
|
48 | + $join->definition['type'] = 'INNER'; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $join->construct(); |
@@ -53,5 +53,5 @@ discard block |
||
53 | 53 | |
54 | 54 | $alias = $join->definition['table'] .'_'. $join->definition['left_table']; |
55 | 55 | $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship); |
56 | - } |
|
56 | + } |
|
57 | 57 | } |
@@ -10,18 +10,18 @@ discard block |
||
10 | 10 | * Implementation of hook_views_data_alter(). |
11 | 11 | */ |
12 | 12 | function content_profile_views_data_alter(&$data) { |
13 | - // node relationship for profiles |
|
14 | - $data['users']['content_profile_rel'] = array( |
|
13 | + // node relationship for profiles |
|
14 | + $data['users']['content_profile_rel'] = array( |
|
15 | 15 | 'group' => t('Node'), |
16 | 16 | 'title' => t('Content Profile'), |
17 | 17 | 'help' => t('Create a relationship to a content profile of the user.'), |
18 | 18 | 'relationship' => array( |
19 | - 'handler' => 'content_profile_views_handler_relationship', |
|
20 | - 'base' => 'node', |
|
21 | - 'base field' => 'uid', |
|
22 | - 'label' => t('Content Profile'), |
|
19 | + 'handler' => 'content_profile_views_handler_relationship', |
|
20 | + 'base' => 'node', |
|
21 | + 'base field' => 'uid', |
|
22 | + 'label' => t('Content Profile'), |
|
23 | 23 | ), |
24 | - ); |
|
24 | + ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * Implementation of hook_views_handlers(). |
30 | 30 | */ |
31 | 31 | function content_profile_views_handlers() { |
32 | - return array( |
|
33 | - 'info' => array( |
|
32 | + return array( |
|
33 | + 'info' => array( |
|
34 | 34 | 'path' => drupal_get_path('module', 'content_profile') .'/views', |
35 | 35 | ), |
36 | - 'handlers' => array( |
|
36 | + 'handlers' => array( |
|
37 | 37 | 'content_profile_views_handler_relationship' => array( |
38 | - 'parent' => 'views_handler_relationship', |
|
39 | - ), |
|
38 | + 'parent' => 'views_handler_relationship', |
|
39 | + ), |
|
40 | 40 | ), |
41 | - ); |
|
41 | + ); |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * Implementation of specially named hook_ctools_relationships(). |
12 | 12 | */ |
13 | 13 | function content_profile_node_from_user_ctools_relationships() { |
14 | - $args['node_from_user'] = array( |
|
14 | + $args['node_from_user'] = array( |
|
15 | 15 | 'title' => t("Profile Node"), |
16 | 16 | 'keyword' => 'content_profile', |
17 | 17 | 'description' => t('Adds a Content Profile from user context'), |
@@ -19,49 +19,49 @@ discard block |
||
19 | 19 | 'context' => 'content_profile_node_from_user_ctools_context', |
20 | 20 | 'settings form' => 'content_profile_node_from_user_ctools_settings_form', |
21 | 21 | 'settings form validate' => 'content_profile_node_from_user_ctools_settings_form_validate', |
22 | - ); |
|
22 | + ); |
|
23 | 23 | |
24 | - return $args; |
|
24 | + return $args; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Return a new context based on an existing context. |
29 | 29 | */ |
30 | 30 | function content_profile_node_from_user_ctools_context($context, $conf) { |
31 | - // If unset it wants a generic, unfilled context, which is just NULL. |
|
32 | - if (empty($context->data) || !isset($context->data->uid)) { |
|
31 | + // If unset it wants a generic, unfilled context, which is just NULL. |
|
32 | + if (empty($context->data) || !isset($context->data->uid)) { |
|
33 | 33 | $new_context = ctools_context_create_empty('node', NULL); |
34 | - } |
|
35 | - else { |
|
34 | + } |
|
35 | + else { |
|
36 | 36 | // Load the node for the requested type |
37 | 37 | $uid = $context->data->uid; |
38 | 38 | $content_profile_node = content_profile_load($conf['type'], $uid); |
39 | 39 | |
40 | 40 | // Send it to ctools. |
41 | 41 | $new_context = ctools_context_create('node', $content_profile_node); |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - // Have content profile relationships limit CCK field availability. |
|
45 | - if (isset($new_context->restrictions['type'])) { |
|
44 | + // Have content profile relationships limit CCK field availability. |
|
45 | + if (isset($new_context->restrictions['type'])) { |
|
46 | 46 | $new_context->restrictions['type'][] = $conf['type']; |
47 | - } |
|
48 | - else { |
|
47 | + } |
|
48 | + else { |
|
49 | 49 | $new_context->restrictions['type'] = array($conf['type']); |
50 | - } |
|
51 | - return $new_context; |
|
50 | + } |
|
51 | + return $new_context; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Settings form for the relationship |
56 | 56 | */ |
57 | 57 | function content_profile_node_from_user_ctools_settings_form($conf) { |
58 | - $options = content_profile_get_types('names'); |
|
59 | - $form['type'] = array( |
|
58 | + $options = content_profile_get_types('names'); |
|
59 | + $form['type'] = array( |
|
60 | 60 | '#type' => 'select', |
61 | 61 | '#title' => t('Relationship type'), |
62 | 62 | '#options' => $options, |
63 | 63 | '#default_value' => $conf['type'] |
64 | - ); |
|
64 | + ); |
|
65 | 65 | |
66 | - return $form; |
|
66 | + return $form; |
|
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -11,109 +11,109 @@ |
||
11 | 11 | */ |
12 | 12 | class content_profile_theme_variables { |
13 | 13 | |
14 | - var $uid; |
|
15 | - var $_cache = array(); |
|
14 | + var $uid; |
|
15 | + var $_cache = array(); |
|
16 | 16 | |
17 | - function content_profile_theme_variables($uid) { |
|
17 | + function content_profile_theme_variables($uid) { |
|
18 | 18 | $this->uid = $uid; |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Gets the user id of the profiles owner. |
|
23 | - */ |
|
24 | - function get_uid() { |
|
21 | + /** |
|
22 | + * Gets the user id of the profiles owner. |
|
23 | + */ |
|
24 | + function get_uid() { |
|
25 | 25 | return $uid; |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Gets all type names keyed with their machine readable names. |
|
30 | - */ |
|
31 | - function get_profile_types() { |
|
28 | + /** |
|
29 | + * Gets all type names keyed with their machine readable names. |
|
30 | + */ |
|
31 | + function get_profile_types() { |
|
32 | 32 | return content_profile_get_types('names'); |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Gets all template variables for the content profile of this type. |
|
37 | - * |
|
38 | - * @param $type |
|
39 | - * The type of the user's content profile |
|
40 | - * @param $teaser |
|
41 | - * Whether the value is to be generated for the teaser. |
|
42 | - * @param $page |
|
43 | - * Whether the value is to be generated for the page view. |
|
44 | - * |
|
45 | - * @return |
|
46 | - * An array of variables available for the profile node |
|
47 | - * or FALSE if there has been no profile created yet. |
|
48 | - */ |
|
49 | - function get_variables($type, $teaser = FALSE, $page = FALSE) { |
|
35 | + /** |
|
36 | + * Gets all template variables for the content profile of this type. |
|
37 | + * |
|
38 | + * @param $type |
|
39 | + * The type of the user's content profile |
|
40 | + * @param $teaser |
|
41 | + * Whether the value is to be generated for the teaser. |
|
42 | + * @param $page |
|
43 | + * Whether the value is to be generated for the page view. |
|
44 | + * |
|
45 | + * @return |
|
46 | + * An array of variables available for the profile node |
|
47 | + * or FALSE if there has been no profile created yet. |
|
48 | + */ |
|
49 | + function get_variables($type, $teaser = FALSE, $page = FALSE) { |
|
50 | 50 | if (!isset($this->_cache[$type][$teaser][$page])) { |
51 | - $this->_cache[$type][$teaser][$page] = FALSE; |
|
51 | + $this->_cache[$type][$teaser][$page] = FALSE; |
|
52 | 52 | |
53 | - if ($node = content_profile_load($type, $this->uid)) { |
|
53 | + if ($node = content_profile_load($type, $this->uid)) { |
|
54 | 54 | // Make sure the node is prepared for viewing |
55 | 55 | $node = node_build_content($node, $teaser, $page); |
56 | 56 | $vars = array('node' => $node, 'teaser' => $teaser, 'page' => $page); |
57 | 57 | |
58 | 58 | // Apply all node template preprocessors |
59 | 59 | foreach ($this->_get_node_preprocessors() as $function) { |
60 | - if (function_exists($function)) { |
|
60 | + if (function_exists($function)) { |
|
61 | 61 | $function($vars, 'node'); |
62 | - } |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | $this->_cache[$type][$teaser][$page] = $vars; |
65 | - } |
|
65 | + } |
|
66 | 66 | } |
67 | 67 | return $this->_cache[$type][$teaser][$page]; |
68 | - } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Gets a single template variable for the content profile of this type. |
|
72 | - * |
|
73 | - * @param $type |
|
74 | - * The type of the user's content profile |
|
75 | - * @param $name |
|
76 | - * The name of the variable to get. |
|
77 | - * |
|
78 | - * @return |
|
79 | - * The variable or FALSE if there has been no profile created yet. |
|
80 | - */ |
|
81 | - function get_variable($type, $name) { |
|
70 | + /** |
|
71 | + * Gets a single template variable for the content profile of this type. |
|
72 | + * |
|
73 | + * @param $type |
|
74 | + * The type of the user's content profile |
|
75 | + * @param $name |
|
76 | + * The name of the variable to get. |
|
77 | + * |
|
78 | + * @return |
|
79 | + * The variable or FALSE if there has been no profile created yet. |
|
80 | + */ |
|
81 | + function get_variable($type, $name) { |
|
82 | 82 | if ($vars = $this->get_variables($type)) { |
83 | - return $vars[$name]; |
|
83 | + return $vars[$name]; |
|
84 | 84 | } |
85 | 85 | return FALSE; |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * Generate a display of the given node. |
|
91 | - * |
|
92 | - * @param $type |
|
93 | - * The type of the user's content profile |
|
94 | - * @param $teaser |
|
95 | - * Whether to display the teaser only or the full form. |
|
96 | - * @param $page |
|
97 | - * Whether the node is being displayed by itself as a page. |
|
98 | - * @param $links |
|
99 | - * Whether or not to display node links. Links are omitted for node previews. |
|
100 | - * |
|
101 | - * @return |
|
102 | - * An HTML representation of the themed node or FALSE if there has been no profile created yet. |
|
103 | - */ |
|
104 | - function get_view($type, $teaser = FALSE, $page = FALSE, $links = TRUE) { |
|
89 | + /** |
|
90 | + * Generate a display of the given node. |
|
91 | + * |
|
92 | + * @param $type |
|
93 | + * The type of the user's content profile |
|
94 | + * @param $teaser |
|
95 | + * Whether to display the teaser only or the full form. |
|
96 | + * @param $page |
|
97 | + * Whether the node is being displayed by itself as a page. |
|
98 | + * @param $links |
|
99 | + * Whether or not to display node links. Links are omitted for node previews. |
|
100 | + * |
|
101 | + * @return |
|
102 | + * An HTML representation of the themed node or FALSE if there has been no profile created yet. |
|
103 | + */ |
|
104 | + function get_view($type, $teaser = FALSE, $page = FALSE, $links = TRUE) { |
|
105 | 105 | if ($node = content_profile_load($type, $this->uid)) { |
106 | - return node_view($node, $teaser, $page, $links); |
|
106 | + return node_view($node, $teaser, $page, $links); |
|
107 | 107 | } |
108 | 108 | return FALSE; |
109 | - } |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | - function _get_node_preprocessors() { |
|
112 | + function _get_node_preprocessors() { |
|
113 | 113 | $hooks = theme_get_registry(); |
114 | 114 | $functions = $hooks['node']['preprocess functions']; |
115 | 115 | // We don't need 'template_preprocess' |
116 | 116 | unset($functions[0]); |
117 | 117 | return $functions; |
118 | - } |
|
118 | + } |
|
119 | 119 | } |
@@ -10,103 +10,103 @@ |
||
10 | 10 | * no profile. |
11 | 11 | */ |
12 | 12 | function content_profile_rules_defaults() { |
13 | - $types = array_keys(content_profile_get_types('names')); |
|
14 | - $type = array_shift($types); |
|
15 | - $config = |
|
13 | + $types = array_keys(content_profile_get_types('names')); |
|
14 | + $type = array_shift($types); |
|
15 | + $config = |
|
16 | 16 | array ( |
17 | - 'rules' => |
|
18 | - array ( |
|
17 | + 'rules' => |
|
18 | + array ( |
|
19 | 19 | 'content_profile_rule_1' => |
20 | 20 | array ( |
21 | - '#type' => 'rule', |
|
22 | - '#set' => 'event_user_login', |
|
23 | - '#label' => 'Redirect to profile creation page, if users have no profile.', |
|
24 | - '#active' => 0, |
|
25 | - '#weight' => '0', |
|
26 | - '#conditions' => |
|
27 | - array ( |
|
21 | + '#type' => 'rule', |
|
22 | + '#set' => 'event_user_login', |
|
23 | + '#label' => 'Redirect to profile creation page, if users have no profile.', |
|
24 | + '#active' => 0, |
|
25 | + '#weight' => '0', |
|
26 | + '#conditions' => |
|
27 | + array ( |
|
28 | 28 | 0 => |
29 | 29 | array ( |
30 | - '#negate' => 1, |
|
31 | - '#weight' => 0, |
|
32 | - '#info' => |
|
33 | - array ( |
|
30 | + '#negate' => 1, |
|
31 | + '#weight' => 0, |
|
32 | + '#info' => |
|
33 | + array ( |
|
34 | 34 | 'label' => 'Logged in user has his Profile created', |
35 | 35 | 'arguments' => |
36 | 36 | array ( |
37 | - 'user' => |
|
38 | - array ( |
|
37 | + 'user' => |
|
38 | + array ( |
|
39 | 39 | 'type' => 'user', |
40 | 40 | 'label' => 'User', |
41 | - ), |
|
41 | + ), |
|
42 | 42 | ), |
43 | 43 | 'module' => 'Content Profile', |
44 | - ), |
|
45 | - '#name' => 'content_profile_user_has_profile_condition', |
|
46 | - '#settings' => |
|
47 | - array ( |
|
44 | + ), |
|
45 | + '#name' => 'content_profile_user_has_profile_condition', |
|
46 | + '#settings' => |
|
47 | + array ( |
|
48 | 48 | 'type' => $type, |
49 | 49 | '#argument map' => |
50 | 50 | array ( |
51 | - 'account' => 'user', |
|
51 | + 'account' => 'user', |
|
52 | 52 | ), |
53 | - ), |
|
54 | - '#type' => 'condition', |
|
53 | + ), |
|
54 | + '#type' => 'condition', |
|
55 | + ), |
|
55 | 56 | ), |
56 | - ), |
|
57 | - '#actions' => |
|
58 | - array ( |
|
57 | + '#actions' => |
|
58 | + array ( |
|
59 | 59 | 0 => |
60 | 60 | array ( |
61 | - '#type' => 'action', |
|
62 | - '#settings' => |
|
63 | - array ( |
|
61 | + '#type' => 'action', |
|
62 | + '#settings' => |
|
63 | + array ( |
|
64 | 64 | 'path' => 'node/add/'. str_replace('_', '-', $type), |
65 | 65 | 'query' => '', |
66 | 66 | 'fragment' => '', |
67 | 67 | 'force' => 1, |
68 | 68 | 'override' => 1, |
69 | - ), |
|
70 | - '#name' => 'rules_action_drupal_goto', |
|
71 | - '#info' => |
|
72 | - array ( |
|
69 | + ), |
|
70 | + '#name' => 'rules_action_drupal_goto', |
|
71 | + '#info' => |
|
72 | + array ( |
|
73 | 73 | 'label' => 'Redirect to profile creation page', |
74 | 74 | 'label callback' => false, |
75 | 75 | 'module' => 'System', |
76 | 76 | 'eval input' => |
77 | 77 | array ( |
78 | - 0 => 'path', |
|
79 | - 1 => 'query', |
|
80 | - 2 => 'fragment', |
|
78 | + 0 => 'path', |
|
79 | + 1 => 'query', |
|
80 | + 2 => 'fragment', |
|
81 | + ), |
|
81 | 82 | ), |
82 | - ), |
|
83 | - '#weight' => 0, |
|
83 | + '#weight' => 0, |
|
84 | 84 | ), |
85 | 85 | 1 => |
86 | 86 | array ( |
87 | - '#weight' => 0, |
|
88 | - '#info' => |
|
89 | - array ( |
|
87 | + '#weight' => 0, |
|
88 | + '#info' => |
|
89 | + array ( |
|
90 | 90 | 'label' => 'Show a message', |
91 | 91 | 'label callback' => false, |
92 | 92 | 'module' => 'System', |
93 | 93 | 'eval input' => |
94 | 94 | array ( |
95 | - 0 => 'message', |
|
95 | + 0 => 'message', |
|
96 | + ), |
|
96 | 97 | ), |
97 | - ), |
|
98 | - '#name' => 'rules_action_drupal_message', |
|
99 | - '#settings' => |
|
100 | - array ( |
|
98 | + '#name' => 'rules_action_drupal_message', |
|
99 | + '#settings' => |
|
100 | + array ( |
|
101 | 101 | 'message' => 'You haven\'t filled out your profile information yet. Please do so now!', |
102 | 102 | 'error' => 1, |
103 | - ), |
|
104 | - '#type' => 'action', |
|
103 | + ), |
|
104 | + '#type' => 'action', |
|
105 | 105 | ), |
106 | - ), |
|
106 | + ), |
|
107 | + ), |
|
107 | 108 | ), |
108 | - ), |
|
109 | 109 | ); |
110 | 110 | |
111 | - return $config; |
|
111 | + return $config; |
|
112 | 112 | } |
@@ -10,83 +10,83 @@ discard block |
||
10 | 10 | * Themes the add link. |
11 | 11 | */ |
12 | 12 | function theme_content_profile_display_add_link($element) { |
13 | - $type = $element['#content_type']; |
|
14 | - $uid = $element['#admin'] ? 'uid='. intval($element['#uid']) .'&' : ''; |
|
15 | - $text = t($element['#admin'] ? "Create the user's @profile_node." : "Create your @profile_node.", array('@profile_node' => node_get_types('name', $type))); |
|
16 | - return l($text, content_profile_get_add_path($type, $element['#uid']), array('query' => $uid . drupal_get_destination(), 'html' => TRUE)); |
|
13 | + $type = $element['#content_type']; |
|
14 | + $uid = $element['#admin'] ? 'uid='. intval($element['#uid']) .'&' : ''; |
|
15 | + $text = t($element['#admin'] ? "Create the user's @profile_node." : "Create your @profile_node.", array('@profile_node' => node_get_types('name', $type))); |
|
16 | + return l($text, content_profile_get_add_path($type, $element['#uid']), array('query' => $uid . drupal_get_destination(), 'html' => TRUE)); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Theme function for the content_profile display as link |
21 | 21 | */ |
22 | 22 | function theme_content_profile_display_link($element) { |
23 | - if ($node = content_profile_load($element['#content_type'], $element['#uid'])) { |
|
23 | + if ($node = content_profile_load($element['#content_type'], $element['#uid'])) { |
|
24 | 24 | if (node_access('view', $node)) { |
25 | - $output = l(node_get_types('name', $node->type), 'node/'. $node->nid); |
|
26 | - if ($element['#edit_link'] && node_access('update', $node)) { |
|
25 | + $output = l(node_get_types('name', $node->type), 'node/'. $node->nid); |
|
26 | + if ($element['#edit_link'] && node_access('update', $node)) { |
|
27 | 27 | $output .= ' '. l('['. t('edit') .']', content_profile_get_edit_path($node), array('query' => drupal_get_destination())); |
28 | - } |
|
29 | - return $output; |
|
28 | + } |
|
29 | + return $output; |
|
30 | + } |
|
30 | 31 | } |
31 | - } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Implementation of content_profile_preprocess_HOOK() |
36 | 36 | */ |
37 | 37 | function content_profile_preprocess_content_profile_display_view(&$variables) { |
38 | - $element = $variables['element']; |
|
39 | - $node = content_profile_load($element['#content_type'], $element['#uid']); |
|
40 | - $variables['node'] = &$node; |
|
41 | - $variables['uid'] = $element['#uid']; |
|
42 | - $variables['type'] = $element['#content_type']; |
|
38 | + $element = $variables['element']; |
|
39 | + $node = content_profile_load($element['#content_type'], $element['#uid']); |
|
40 | + $variables['node'] = &$node; |
|
41 | + $variables['uid'] = $element['#uid']; |
|
42 | + $variables['type'] = $element['#content_type']; |
|
43 | 43 | |
44 | - $path = drupal_get_path('module', 'content_profile') .'/content_profile.css'; |
|
45 | - drupal_add_css($path, 'module', 'all', FALSE); |
|
44 | + $path = drupal_get_path('module', 'content_profile') .'/content_profile.css'; |
|
45 | + drupal_add_css($path, 'module', 'all', FALSE); |
|
46 | 46 | |
47 | - $variables['title'] = check_plain(node_get_types('name', $node->type)); |
|
47 | + $variables['title'] = check_plain(node_get_types('name', $node->type)); |
|
48 | 48 | |
49 | - $tabs = array(); |
|
50 | - if ($element['#edit_link']) { |
|
49 | + $tabs = array(); |
|
50 | + if ($element['#edit_link']) { |
|
51 | 51 | $tabs[] = theme('content_profile_display_tab_view', $node); |
52 | 52 | $tabs[] = theme('content_profile_display_tab_edit', $node); |
53 | - } |
|
54 | - if (count($tabs) > 0) { |
|
53 | + } |
|
54 | + if (count($tabs) > 0) { |
|
55 | 55 | $variables['tabs'] = $tabs; |
56 | - } |
|
57 | - $variables['content'] = node_view($node, ($element['#style'] == 'teaser'), TRUE, TRUE); |
|
56 | + } |
|
57 | + $variables['content'] = node_view($node, ($element['#style'] == 'teaser'), TRUE, TRUE); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Themes the view tab |
62 | 62 | */ |
63 | 63 | function theme_content_profile_display_tab_view($node) { |
64 | - return l(t('View'), 'node/'. $node->nid); |
|
64 | + return l(t('View'), 'node/'. $node->nid); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Themes the edit tab |
69 | 69 | */ |
70 | 70 | function theme_content_profile_display_tab_edit($node) { |
71 | - if (node_access('update', $node)) { |
|
71 | + if (node_access('update', $node)) { |
|
72 | 72 | return l(t('Edit'), content_profile_get_edit_path($node), array('query' => drupal_get_destination())); |
73 | - } |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Gets the edit path for a content_profile |
78 | 78 | */ |
79 | 79 | function content_profile_get_edit_path($node) { |
80 | - $handler = variable_get('content_profile_path_handler', 'content_profile_default_path_handler'); |
|
81 | - return $handler('edit', $node, $node->uid); |
|
80 | + $handler = variable_get('content_profile_path_handler', 'content_profile_default_path_handler'); |
|
81 | + return $handler('edit', $node, $node->uid); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Gets the add path for a content_profile of the active user |
86 | 86 | */ |
87 | 87 | function content_profile_get_add_path($type, $uid) { |
88 | - $handler = variable_get('content_profile_path_handler', 'content_profile_default_path_handler'); |
|
89 | - return $handler('add', $type, $uid); |
|
88 | + $handler = variable_get('content_profile_path_handler', 'content_profile_default_path_handler'); |
|
89 | + return $handler('add', $type, $uid); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | * @param $uid the uid of the profile's owner. |
98 | 98 | */ |
99 | 99 | function content_profile_default_path_handler($action, $arg, $uid) { |
100 | - $type = $action == 'add' ? $arg : $arg->type; |
|
101 | - if (content_profile_get_settings($type, 'edit_tab') == 'top') { |
|
100 | + $type = $action == 'add' ? $arg : $arg->type; |
|
101 | + if (content_profile_get_settings($type, 'edit_tab') == 'top') { |
|
102 | 102 | return 'user/'. $uid . '/profile/'. $type; |
103 | - } |
|
104 | - elseif (content_profile_get_settings($type, 'edit_tab') == 'sub') { |
|
103 | + } |
|
104 | + elseif (content_profile_get_settings($type, 'edit_tab') == 'sub') { |
|
105 | 105 | return 'user/'. $uid . '/edit/'. $type; |
106 | - } |
|
107 | - elseif ($action == 'add') { |
|
106 | + } |
|
107 | + elseif ($action == 'add') { |
|
108 | 108 | return 'node/add/'. str_replace('_', '-', $arg); |
109 | - } |
|
110 | - else { |
|
109 | + } |
|
110 | + else { |
|
111 | 111 | return 'node/'. $arg->nid .'/edit'; |
112 | - } |
|
112 | + } |
|
113 | 113 | } |