Snog
Well-known member
While extending the privacy options for users, I discovered there's no really clean way to do it (or I'm just not awake yet).
In account.php you have this quite normal code:
But immediately after that code is the basicEntitySave for the privacy options. This makes it next to impossible to extend the privacy options without adding another database query, maybe two.
What I suggest is adding this function and calling it rather than using $this->filter directly in the savePrivacyProcess function.
This would make extending the privacy options quite simple by extending the new getPrivacyInput function and adding whatever needs to be added.
There may be other places this same line of thought could be applied. But this is the only one I've found to date.
In account.php you have this quite normal code:
Code:
$input = $this->filter([
'user' => [
'visible' => 'bool',
'activity_visible' => 'bool'
],
'option' => [
'show_dob_date' => 'bool',
'show_dob_year' => 'bool'
],
'privacy' => [
'allow_view_profile' => 'str',
'allow_post_profile' => 'str',
'allow_receive_news_feed' => 'str',
'allow_send_personal_conversation' => 'str',
'allow_view_identities' => 'str'
]
]);
But immediately after that code is the basicEntitySave for the privacy options. This makes it next to impossible to extend the privacy options without adding another database query, maybe two.
What I suggest is adding this function and calling it rather than using $this->filter directly in the savePrivacyProcess function.
Code:
protected function getPrivacyInput()
{
return $this->filter([
'user' => [
'visible' => 'bool',
'activity_visible' => 'bool'
],
'option' => [
'show_dob_date' => 'bool',
'show_dob_year' => 'bool'
],
'privacy' => [
'allow_view_profile' => 'str',
'allow_post_profile' => 'str',
'allow_receive_news_feed' => 'str',
'allow_send_personal_conversation' => 'str',
'allow_view_identities' => 'str'
]
]);
}
This would make extending the privacy options quite simple by extending the new getPrivacyInput function and adding whatever needs to be added.
There may be other places this same line of thought could be applied. But this is the only one I've found to date.
Last edited:
Upvote
0