Révision 13c3c9b4
Ajouté par Assos Assos il y a environ 9 ans
drupal7/sites/all/modules/advanced_forum/plugins/content_types/forum_most_active_poster.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
/** |
|
3 |
* @file |
|
4 |
* Most active poster. |
|
5 |
*/ |
|
2 | 6 |
|
3 | 7 |
/** |
4 | 8 |
* Callback function to supply a list of content types. |
... | ... | |
9 | 13 |
'single' => TRUE, |
10 | 14 |
'title' => t('Most active forum poster'), |
11 | 15 |
'icon' => 'icon_forum.png', |
12 |
'description' => t('A block with information about the most active forum poster.'), |
|
16 |
'description' => t( |
|
17 |
'A block with information about the most active forum poster.' |
|
18 |
), |
|
13 | 19 |
'required context' => new ctools_context_required(t('Forum'), 'forum'), |
14 | 20 |
'category' => t('Forum'), |
15 | 21 |
'defaults' => array('period' => 'ever', 'exclude' => 0, 'uidone' => TRUE), |
... | ... | |
20 | 26 |
/** |
21 | 27 |
* Render the content. |
22 | 28 |
*/ |
23 |
function advanced_forum_forum_most_active_poster_content_type_render($subtype, $conf, $panel_args, $context) { |
|
29 |
function advanced_forum_forum_most_active_poster_content_type_render( |
|
30 |
$subtype, |
|
31 |
$conf, |
|
32 |
$panel_args, |
|
33 |
$context |
|
34 |
) { |
|
24 | 35 |
if (!empty($context) && empty($context->data)) { |
25 | 36 |
return; |
26 | 37 |
} |
27 | 38 |
|
28 |
if (empty($context)) { |
|
29 |
$tid = 0; |
|
30 |
} |
|
31 |
else { |
|
39 |
$tid = 0; |
|
40 |
if (!empty($context)) { |
|
32 | 41 |
$tid = $context->data->tid; |
33 | 42 |
} |
34 | 43 |
|
... | ... | |
38 | 47 |
case 'day': |
39 | 48 |
$period_arg = 60 * 60 * 24; |
40 | 49 |
break; |
50 |
|
|
41 | 51 |
case 'week': |
42 | 52 |
$period_arg = 60 * 60 * 24 * 7; |
43 | 53 |
break; |
54 |
|
|
44 | 55 |
case 'month': |
45 | 56 |
$period_arg = 60 * 60 * 24 * 30; |
46 | 57 |
break; |
58 |
|
|
47 | 59 |
case 'quarter': |
48 | 60 |
$period_arg = 60 * 60 * 24 * 91; |
49 | 61 |
break; |
62 |
|
|
50 | 63 |
case 'year': |
51 | 64 |
$period_arg = 60 * 60 * 24 * 365; |
52 | 65 |
break; |
... | ... | |
73 | 86 |
|
74 | 87 |
if ($tid) { |
75 | 88 |
$forum = taxonomy_term_load($tid); |
76 |
$block->title = t('Most active poster in @forum', array('@forum' => $forum->name)); |
|
89 |
$block->title = t( |
|
90 |
'Most active poster in @forum', |
|
91 |
array('@forum' => $forum->name) |
|
92 |
); |
|
77 | 93 |
$query .= "AND f.tid = %d "; |
78 | 94 |
$args = array($tid); |
79 | 95 |
} |
... | ... | |
140 | 156 |
$query .= "ORDER BY n.created DESC LIMIT 1"; |
141 | 157 |
|
142 | 158 |
$last_post = node_load(db_result(db_query($query, $args))); |
143 |
$block->content = theme('advanced_forum_active_poster', array( |
|
144 |
'forum' => $tid, |
|
145 |
'account' => $account, |
|
146 |
'posts' => $info->posts, |
|
147 |
'topics' => $topics, |
|
148 |
'last_post' => $last_post |
|
149 |
)); |
|
159 |
$block->content = theme( |
|
160 |
'advanced_forum_active_poster', |
|
161 |
array( |
|
162 |
'forum' => $tid, |
|
163 |
'account' => $account, |
|
164 |
'posts' => $info->posts, |
|
165 |
'topics' => $topics, |
|
166 |
'last_post' => $last_post, |
|
167 |
) |
|
168 |
); |
|
150 | 169 |
$block->more = array( |
151 | 170 |
'title' => t('More posts'), |
152 | 171 |
'href' => 'forum/user/' . $info->uid, |
153 | 172 |
); |
173 |
|
|
154 | 174 |
return $block; |
155 | 175 |
} |
156 | 176 |
|
157 | 177 |
/** |
158 | 178 |
* Returns an edit form for the custom type. |
159 | 179 |
*/ |
160 |
function advanced_forum_forum_most_active_poster_content_type_edit_form($form, &$form_state) { |
|
161 |
// make sure conf contains newer defaults. CTools should do this for us: |
|
180 |
function advanced_forum_forum_most_active_poster_content_type_edit_form( |
|
181 |
$form, |
|
182 |
&$form_state |
|
183 |
) { |
|
184 |
// Make sure conf contains newer defaults. CTools should do this for us. |
|
162 | 185 |
$conf = $form_state['conf']; |
163 | 186 |
$conf += $form_state['plugin']['defaults']; |
164 | 187 |
|
... | ... | |
173 | 196 |
'year' => t('In the last year'), |
174 | 197 |
'ever' => t('Ever'), |
175 | 198 |
), |
176 |
'#description' => t('Select what period you want to search for the most active poster.'), |
|
199 |
'#description' => t( |
|
200 |
'Select what period you want to search for the most active poster.' |
|
201 |
), |
|
177 | 202 |
'#default_value' => $conf['period'], |
178 | 203 |
); |
179 | 204 |
|
... | ... | |
184 | 209 |
'#type' => 'select', |
185 | 210 |
'#title' => t('Exclude role'), |
186 | 211 |
'#options' => $roles, |
187 |
'#description' => t('Choose a role that will be excluded from being an active poster.'), |
|
212 |
'#description' => t( |
|
213 |
'Choose a role that will be excluded from being an active poster.' |
|
214 |
), |
|
188 | 215 |
'#default_value' => $conf['exclude'], |
189 | 216 |
); |
190 | 217 |
|
191 | 218 |
$form['uidone'] = array( |
192 | 219 |
'#type' => 'checkbox', |
193 | 220 |
'#title' => t('Exclude UID 1'), |
194 |
'#description' => t('If checked the super user will not be a possible most active poster.'), |
|
221 |
'#description' => t( |
|
222 |
'If checked the super user will not be a possible most active poster.' |
|
223 |
), |
|
195 | 224 |
'#default_value' => $conf['uidone'], |
196 | 225 |
); |
197 | 226 |
|
198 | 227 |
return $form; |
199 | 228 |
} |
200 | 229 |
|
201 |
function advanced_forum_forum_most_active_poster_content_type_edit_form_submit($form, &$form_state) { |
|
230 |
/** |
|
231 |
* Submit callback. |
|
232 |
*/ |
|
233 |
function advanced_forum_forum_most_active_poster_content_type_edit_form_submit( |
|
234 |
$form, |
|
235 |
&$form_state |
|
236 |
) { |
|
202 | 237 |
// Copy everything from our defaults. |
203 | 238 |
foreach (array_keys($form_state['plugin']['defaults']) as $key) { |
204 | 239 |
$form_state['conf'][$key] = $form_state['values'][$key]; |
205 | 240 |
} |
206 | 241 |
} |
207 | 242 |
|
208 |
function advanced_forum_forum_most_active_poster_content_type_admin_title($subtype, $conf, $context) { |
|
243 |
/** |
|
244 |
* Callback for admin title. |
|
245 |
*/ |
|
246 |
function advanced_forum_forum_most_active_poster_content_type_admin_title( |
|
247 |
$subtype, |
|
248 |
$conf, |
|
249 |
$context |
|
250 |
) { |
|
209 | 251 |
return t('"@s" most active poster', array('@s' => $context->identifier)); |
210 | 252 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules