Lack of interest Discussion Message Definition

  • Thread starter Thread starter ragtek
  • Start date Start date
This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.
R

ragtek

Guest
I'M using the XenForo_DataWriter_DiscussionMessage for my comment features in the article system, gallery and for pages.

But it's IMHO too much.

PHP:
protected function _getCommonFields()
    {
        $structure = $this->_messageDefinition->getMessageStructure();

        $fields = array(
            $structure['table'] => array(
                $structure['key']        => array('type' => self::TYPE_UINT, 'autoIncrement' => true),
                $structure['container']  => array('type' => self::TYPE_UINT, 'required' => true),
                'user_id'                => array('type' => self::TYPE_UINT,   'required' => true),
                'username'               => array('type' => self::TYPE_STRING, 'required' => true, 'maxLength' => 50,
                        'requiredError' => 'please_enter_valid_name'
                ),
                'post_date'              => array('type' => self::TYPE_UINT,   'required' => true, 'default' => XenForo_Application::$time),
                'message'                => array('type' => self::TYPE_STRING, 'required' => true,
                        'requiredError' => 'please_enter_valid_message'
                ),
                'ip_id'                  => array('type' => self::TYPE_UINT,   'default' => 0),
                'message_state'          => array('type' => self::TYPE_STRING, 'default' => 'visible',
                        'allowedValues' => array('visible', 'moderated', 'deleted')
                ),
                'attach_count'           => array('type' => self::TYPE_UINT_FORCED, 'default' => 0, 'max' => 65535),
                'likes'                  => array('type' => self::TYPE_UINT_FORCED, 'default' => 0),
                'like_users'             => array('type' => self::TYPE_SERIALIZED, 'default' => 'a:0:{}')
            )
        );

        if ($this->_hasParentDiscussion)
        {
            $fields[$structure['table']]['position'] = array('type' => self::TYPE_UINT_FORCED);
        }

        return $fields;
    }

Wouldn't it be better to seperate this into 2 abstract classes?
This is a nice way to do this, but IMHO in most cases, i will only have a basic message without likes, attachments,etc...

What about=>
1. abstract class Basis:userid, message, post_date
2. abstract class Basis2 exteds Basis: parent::fields + ip_id, message_state, attach_count, likes, like_users

So the basis2 would be what you have NOW but you and the add-on coders would be able to use basis 1 for the "lite comments" like profile comment where you don't have attachments,likes,etc....

(Hope you know what i mean, i can't express myself today:D )
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Also, why do you save the username here?

Most queries link to the user table anyway, so isn't this useless and makes coding harder (because we need to update this fields on username change:P )
 
Top Bottom