Extending a Model

DroidHost

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

public function getAttachmentConstraints()
    {
        $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,
to
'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 ?
 
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:
PHP:
public function getAttachmentConstraints()
    {
        $params = parent::getAttachmentConstraints();
        $params['size'] = 4096;

        return $params;

    }

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!" );
 
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 :)


 
Top Bottom