1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Can Edit Row list plugin

Jan 6, 2021
Can Edit Row list plugin
  • This plug-in provides a fine grained control over which records can be edited.

    The list's Access->edit records option takes precedence over this plugin. That is to say that if you are logged in as a registered user, and the list's delete records option is set to Special, then no records can be edited, regardless of any match that might be made with this plugin. In other words, this plugin can only be used to deny access to a row which the built in list ACL's would usually allow. It cannot permit edit access, if the normal list ACL's do not allow permission.

    If more than one can edit plugin is used, and any one of the plugins returns false, then the row will not be editable.


    NOTE the above precedence was change on 12/1/2017. The plugin now takes precedence over the list's normal group/user ACLs. If the plugin returns true or false, this overrides the list's ACLs. If the plugin returns null, then the list ACL's are used. If more than one plugin returns a result, 'false' takes precedence.

    caneditrow-options.png

    • Access - Which Joomla User 'Access level' will this plug-in be applied to
    • Element - The element whose data needs to make the value specified in the 'value' field.
    • Use Raw - Should we compare the element's raw data or the visible data (e.g. if using a user element, do we compare against the raw value '62' or the display value of 'Admin')
    • Value - The value to compare against. If the element's value matches this then the row IS editable
    caneditrow-example.png

    caneditrow-advanced.png
    • PHP (eval) - A PHP statement which needs to return the value to match against the element's data. Anything entered here takes precedence over the 'value' field. usual placeholders can be used, like {tablename___elementname}, {$my->id}, etc.
    Code (Text):

    /**
     * If status is 1, allow edit.  If status is 2, don't allow edit.  If status is 3, punt and let normal ACLs decide
     */
    switch ('{tablename___status_raw}') {
       case '1':
          return true;
       case '2':
          return false;
       case '3':
          return null;
    }
     
    Here is another php plugin example based on date.
    In this example, there is a Date element (field) called "flight_date" - the date of an aircraft flight.
    If the flight date is prior to last year, the record is read only.
    So - the user with the specified permission can edit a flight this year and last year, but not before.

    Note: the php DateTime() function could be used - perhaps to good effect.

    Code (Text):

    /* This plugin compares the flight date to the jan 1 of the previous year and makes this record read only if the flight is that old.
    * So - if it is 2021, and you try to edit a flight, if that flight happened in 2020 or 2021, you can edit it.  If it happened in 2019, you cannot.
    */

    $flight_date = strtotime('{daily_log___flight_date}');  // date of the flight as entered in the log.
    $compare_date = strtotime(date('Y')-1 . '-01-01');  //Take this year - 1 and jan 1 to it and convert to unix time

    if ( $flight_date < $compare_date) {
    return false; // flight too old - cannot edit
    }
    return true;  // Go ahead and edit.
     
  • Loading...