How to overwrite default access permissions?: Revision

Overwrite default access permissions could be acomplished easily using the "Elgg way" philosophy. In other words you just need to overwrite the default behavior using the plugin architecture.

In this specific case you need:

  1. Create a theme plugin
  2. Create the view path for access permissions (yourplugin/views/default/input)
  3. Copy there the code from (views/default/input/access.php)
  4. Add the following line after the line 28:
    if(empty($vars["value"]) && strval($vars["value"])!=="0"){
      $vars["value"]=2;
    }
  5. Done!

You can use this method for add specific access permissions or to overwrite the display order.

Note: This approach assumes that $vars["value"] comes empty when your are creating a new content, unfortunately looky deeply the access_id values is hardcoded in the code of some forms like blog/views/default/blog/forms/edit.php so you can not diferentiate when the "0" value from private access comes from default or it is setting by the user.

However you can use the same approach for overwrite those forms and acomplish the same objetive. In fact you can mix both. In this way you can get your desired functionality without modify the core and in case the feature is implemented you only needs to drop those files.