Closed PayBas closed 10 years ago
What is it you are wanting to modify about avatars? If it's 'cuz you don't like the default no avatars, maybe I can just make that an option.
My code:
public function display_topic_preview($row, $block, $tp_avatars) {
if($this->config['load_cpf_viewtopic'] && $tp_avatars) {
$grab_ids = array();
if(empty($row['first_poster_avatar'])) {
$grab_ids[] = $row['topic_poster'];
}
if($row['topic_poster'] !== $row['topic_last_poster_id'] && empty($row['last_poster_avatar'])) {
$grab_ids[] = $row['topic_last_poster_id'];
}
if(!empty($grab_ids)) {
$cp = $this->profilefields_manager->grab_profile_fields_data($grab_ids);
if(empty($row['first_poster_avatar']) && isset($cp[$row['topic_poster']])) {
$profile_fields = $this->profilefields_manager->generate_profile_fields_template_data($cp[$row['topic_poster']]);
$block['TOPIC_PREVIEW_FIRST_AVATAR'] = isset($profile_fields['row']['PROFILE_PBAVATAR']) ? $profile_fields['row']['PROFILE_PBAVATAR'] : '';
}
if(empty($row['last_poster_avatar']) && isset($cp[$row['topic_last_poster_id']])) {
if($row['topic_poster'] == $row['topic_last_poster_id']) {
$block['TOPIC_PREVIEW_LAST_AVATAR'] = $block['TOPIC_PREVIEW_FIRST_AVATAR'];
} else {
$profile_fields = $this->profilefields_manager->generate_profile_fields_template_data($cp[$row['topic_last_poster_id']]);
$block['TOPIC_PREVIEW_LAST_AVATAR'] = isset($profile_fields['row']['PROFILE_PBAVATAR']) ? $profile_fields['row']['PROFILE_PBAVATAR'] : '';
}
}
}
}
return $block;
}
If you need me to change anything in the PR, just let me know. But I hope we can merge this.
Having this event in place will allow us to do more fun things in the future as well.
Forgot about this. Can you rebase it to the latest version of this branch please.
Done
I will merge this as soon as the unit testing framework gets fixed/updated... may be a few days.
Think you can fix the test which are failing now? Should be just as simple as adding the mock dispatcher to the setup of the topic_preview instance in tests/topic_preview_base
The dispatcher depends on the phpbb container by calling $dispatcher = new \phpbb\event\dispatcher(new phpbb_mock_container_builder());
, but since I'm not well versed in the test platform yet, this is a bit tricky at the moment.
Will make it easier to modify the avatars. The alternative would be to modify all the same events as TP, but this is way easier of course.