Hi Guys,
Edit: sorry title should be how to create a alerthandler for a custom content type?
I hope there are some experience members online who can help me.
I'm working on a upload center (file sharing) mod but I've been stuck all day trying to implement the alert system for likes.
I created a new content type and an AlertHandler for my mod. The like/unlike is working but when I like a custom content type it only display in the alert system if a post with the same ID excist on the forum, if there's no post with the same ID it will still say there's a new alert since it's inserted in the database correctly but it's not displaying it.
When I look at the query on the alerts page it does contain all the id numbers including the id's it doesn't show so I think somewhere there's a function that checks if the content excist and it's checking in the xf_post table.
Here's the code of my LikeHandler
Here's the code from ULC_Model_File which is called for function getFilesByIds
demo link: http://www.tech-addicts.com/upload_center/
Regards,
MainFrame
Edit: sorry title should be how to create a alerthandler for a custom content type?
I hope there are some experience members online who can help me.
I'm working on a upload center (file sharing) mod but I've been stuck all day trying to implement the alert system for likes.
I created a new content type and an AlertHandler for my mod. The like/unlike is working but when I like a custom content type it only display in the alert system if a post with the same ID excist on the forum, if there's no post with the same ID it will still say there's a new alert since it's inserted in the database correctly but it's not displaying it.
When I look at the query on the alerts page it does contain all the id numbers including the id's it doesn't show so I think somewhere there's a function that checks if the content excist and it's checking in the xf_post table.
Here's the code of my LikeHandler
Code:
<?php
class ULC_AlertHandler_File extends XenForo_AlertHandler_DiscussionMessage
{
public function getContentByIds(array $contentIds, $model, $userId, array $viewingUser)
{
// this
return $model->getModelFromCache('ULC_Model_Files')->getFilesByIds($contentIds);
}
public function canViewAlert(array $alert, $content, array $viewingUser)
{
return true;
}
}
Here's the code from ULC_Model_File which is called for function getFilesByIds
Code:
public function getFilesByIds(array $fileIds, array $fetchOptions = array())
{
if (!$fileIds)
{
return array();
}
return $this->fetchAllKeyed('
SELECT attachment.attachment_id, data.filename
FROM xf_attachment AS attachment
INNER JOIN xf_attachment_data AS data
ON (data.data_id = attachment.data_id)
WHERE attachment.attachment_id IN (' . $this->_getDb()->quote($fileIds) . ')
', 'file_id');
}
demo link: http://www.tech-addicts.com/upload_center/
Regards,
MainFrame