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:
if(empty($vars["value"]) && strval($vars["value"])!=="0"){
$vars["value"]=2;
}
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.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
A quick note: This fix does not work exactly as intended. If the stored value happens to be private, which is 0, the empty function will return true. So even though the user has specifically set a private value, it will show as public. I have tried all kinds of things like empty() && !=0 but its not entirely bulletproof (i don't think).
Just a heads up. I personally might not even include a "private" option. After testing it, I can't see why i would WANT anyone to house private things on a community site. If you want a private blog, whats the point of blogging? If you want private albums, whats the point of posting on www.mycommunity.com So I'm on the verge of disabling any private option and if that happens, this will no longer be a problem.
Yeap Jade, your are right the empty function doens't is enough. I updated the page adding the !== comparation to check against the 0 value.
In another hand you can use the same procedure to disabling the private access level for your site. Just overwrite the $vars["options"] array ;)
Extremely interesting approach. It opens all kinds of possibilities. Hopefully it can be worked out. I'll set this up on one of my installs.
Regarding Private--it makes sense for things like drafts or works in progress.
Diego--
I'm not much of a coder. Could you tell me exactly where you appended the !==?
It sounds like I could use this approach to create a K12 school theme with required access controls
Thanks,
Steve
I'm put the comment just before of testing the idea :-/
The !== comparator check against exact value and I added inside the "if", just like
if(empty($vars["value"]) && intval($vars["value"])!==0){
The problem here is that I assumed that $vars["value"] comes without any value when you create a new content but checking the code more in depth I discover that It is "assigned" just before of calling the input/access view so there is no way to know if the "private" permission setting comes from "default" or is the already assigned value :(
In fact the safer comparition is strval($vars["value"])!=="0"
So--
if(empty($vars["value"]) && strval($vars["value"])!=="0"){
Yeap Steve. I updated the page with the correct code and a explainatorie note about why this approach is not "bulletproof" but can be used for acomplish the same result.
how is it that you ensure "$vars["value"]" stays empty? do you somehow delete the dropdown box?
Hey there, can you tell me how I can only let administrators create pages using the built in pages plugin?
I know a bit of code so if it has to be coded that is fine?
Thanks in advance