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

Extending a Model

Discussion in 'XenForo Development Discussions' started by DroidHost, Jun 5, 2011.

  1. DroidHost

    DroidHost Well-Known Member

    I do want to Extend Attachment model to alter a function ... Constraints ....
    so did this :
    class Demo_Model Extends XFCP_Demo_Model {

    public function 
    $params parent::getAttachmentConstraints();

            return    array(
    'extensions' => preg_split('/\s+/'trim($options->attachmentExtensions)),
    'size' => $options->attachmentMaxFileSize 1024,
    'width' => $options->attachmentMaxDimensions['width'],
    'height' => $options->attachmentMaxDimensions['height'],
    'count' => $options->attachmentMaxPerMessage
    but it seems not working ...
    I do this to Test the function ,,,
    I do change this line
    'size' => $options->attachmentMaxFileSize * 1024,
    'size' => $options->attachmentMaxFileSize * 0,

    in the original[Core] file not that of my addon ...
    It should not be able to upload ,,,
    but I could ,,,,

    what is wrong ?
  2. Martin Aronsen

    Martin Aronsen Active Member

    1. You have created a code event listener that listens to load_class_model?

    2. Why are you doing a call to the parent, when you're not using any of the data returned?
    If you're just planing to change one or two parameters of the array, you can do that like this:
    public function getAttachmentConstraints()
    $params parent::getAttachmentConstraints();
    $params['size'] = 4096;


    3. $options is not created in your function. Just because something is created in the parent, it is not carried over to their children.

    4. Put a debugging call in your method. Just something that lets you know straight away that it is executed. Something like die( "This is working!" );
  3. DroidHost

    DroidHost Well-Known Member

    thanks Martin Aronsen
    I know .. I did all of what u said ....it just I was lazy to add what I previously did
    but now I just remember something in setting the is this statement :"Use 0 to allow an unlimited number of attachments per message."
    so ervery time I put size equal zero I was think it will be -the max size- = zero so no upload ...
    but it is in revers :)


Share This Page