Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
When do PNObjectUtil functions trigger?
  • Posted: 07.02.2008, 23:06
     
    uheweb
    rank:
    Professional Professional
    registered:
     September 2004
    Status:
    offline
    last visit:
    10.11.08
    Posts:
    815
    When creating an object from a class:

    Code

    $object = new $class ('D', $id)


    What is the 'D' for?

    Also, does the previous trigger PNObjectUtil select and selectPostProcess functions in the object class?

    What I need to do is find a suitable place to do an "Edit Own" check and am using a generic edit function for all objects. This would only need to trigger during the edit function, not detail or view functions.

    Using class functions, what would be the best way? If I create a custom class function that is defined for 1 object class, and not for another, will the script fail? ie, $object->checkeditown(); where checkeditown exists in the class definition for object A but not for object B

    Or, what is the best method for passing to the class functions that the current mode is EDIT and to trigger a special case in a standard function - like selectPostProcess or validate()

    Any ideas? icon_smile

    NCM



  • Posted: 08.02.2008, 14:55
     
    rgasch
    rank:
    Steering Committee Steering Committee
    registered:
     January 2003
    Status:
    offline
    last visit:
    19.11.08
    Posts:
    567

    Quote

    What is the 'D' for?

    The 'D' stands for 'get from Database'. This evaluates to the same code as:

    Code

    $object = new $class ();
    $object->get($id)



    Quote

    Also, does the previous trigger PNObjectUtil select and selectPostProcess functions in the object class?

    Yes.

    Quote

    What I need to do is find a suitable place to do an "Edit Own" check and am using a generic edit function for all objects. This would only need to trigger during the edit function, not detail or view functions.

    Use/Overide the PNObject->validate() or implement the PNObject->validatePostProcess() function(s) for this.

    Quote

    Or, what is the best method for passing to the class functions that the current mode is EDIT and to trigger a special case in a standard function - like selectPostProcess or validate()

    What I usually do in this case is to see if the object data has the object/table ID field set. If it has a proper ID field, you're editing, otherwise you're creating/inserting a new object.


    Greetings
    R
  • Posted: 08.02.2008, 22:35
     
    uheweb
    rank:
    Professional Professional
    registered:
     September 2004
    Status:
    offline
    last visit:
    10.11.08
    Posts:
    815
    Thx for the info!

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula