1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Attachment Handler Changes

Discussion in 'Notices for Add-on and Style Developers' started by Kier, Aug 31, 2011.

  1. Kier

    Kier XenForo Developer Staff Member

    Please note that from XenForo 1.1, it is expected that classes extending XenForo_AttachmentHandler define two new properties:
    PHP:
    /**
     * Route to get to a post
     *
     * @var string
     */
    protected $_contentRoute 'posts';

    /**
     * Name of the phrase that describes the
     * conversation_message content type
     *
     * @var string
     */
    protected $_contentTypePhraseKey 'post';
    These properties are used to enable an attachment handler to identify the content type to which it applies, and to enable linking back to the host content from an attachment.

    They should be able to be used in the following examples:
    PHP:
    $contentLink XenForo_Link::buildPublicLink($this->_contentRoute$contentData);
    // returns '/posts/321'

    $contentTypePhrase = new XenForo_Phrase($this->_contentTypePhraseKey);
    // returns 'Post'
    It is possible to override the new method XenForo_AttachmentHandler_Abstract::getContentLink(array $attachment, array $extraParams = array(), $skipPrepend = false) in order to pass additional parameters to the link builder if your content type should require it.
     
    Bob, CurveGotti, Hillbilly and 6 others like this.
  2. Digital Doctor

    Digital Doctor Well-Known Member

    The best attachment handler ever (and I mean ever) just got even better.
    Sweet.
     
  3. ragtek

    ragtek Guest

  4. Jaxel

    Jaxel Well-Known Member

    So all I need to do is this?

    Code:
    <?php
    
    class EWRcarta_AttachmentHandler_Wiki extends XenForo_AttachmentHandler_Abstract
    {
        protected $_contentRoute = 'wiki';
        protected $_contentTypePhraseKey = 'wiki';
        protected $_contentIdKey = 'page_id';
    
        protected function _canUploadAndManageAttachments(array $contentData, array $viewingUser)
        {
            return true;
        }
    
        public function _canViewAttachment(array $attachment, array $viewingUser)
        {
            return true;
        }
    
        public function attachmentPostDelete(array $attachment, Zend_Db_Adapter_Abstract $db)
        {
            return true;
        }
    
        public function getAttachmentCountLimit()
        {
            return true;
        }
    }
     
  5. ragtek

    ragtek Guest

    Much more importent would have been the info, that several methods have changed

    e.g SearchModel::insertSearch=>

    THIS CHANGE broke several add-ons, the attachment handler change didn't break anything.​
    Without the new attachment handler change there's no "critical" problem, but the changed insertSearch method will throw an error...​
    I hope this stuff (BIG CHANGES) will also be shared in the future:p
     
    CurveGotti likes this.
  6. Kier

    Kier XenForo Developer Staff Member

    Oops, sorry about that. I actually had a post authored explaining that change, but forgot to move it into public view with the 1.1 release.
     
  7. Jaxel

    Jaxel Well-Known Member

    So... where is it? =P
     
  8. ragtek

    ragtek Guest

    Another 1.1 problem because of changed code:

    if you're using the XenForo_DataWriter_DiscussionMessage for your own comments, you need to create 2 new fields in the comment table for warning_id & warning_message

    PHP:
            warning_id INT UNSIGNED NOT NULL DEFAULT 0,
            
    warning_message VARCHAR(255NOT NULL DEFAULT ''
     
  9. Marc

    Marc Well-Known Member

    Ahhhhh so thats why they call you drama queen? :p lol
     
  10. ragtek

    ragtek Guest

    yes
     
  11. Robbo

    Robbo Well-Known Member

    Kier likes this.
  12. ragtek

    ragtek Guest

    Another "code" change which could break add-ons (breaks link / business directory addon):

    Thread ModeL
    PHP:
        /**
        * Marks the given thread as read up to a certain point (usually the most recent post read).
        * Thread must have thread_read_date key. (Forum should have forum_read_date key.)
        *
        * @param array $thread Thread info
        * @param array $forum Forum info
        * @param integer $readDate Timestamp to mark
        * @param integer $userId User marking the thread as read
        *
        * @return boolean True if marked as read
        */
        
    public function markThreadRead(array $thread, array $forum$readDate$userId)
        {
    is now
    PHP:
        public function markThreadRead(array $thread, array $forum$readDate, array $viewingUser null)
        {
     
    CurveGotti and Fuhrmann like this.

Share This Page