Michael Zülsdorff
4 years ago
Toggling wall post privacy from public to friends or vice versa
(in response to https://www.opensource-socialnetwork.org/discussion/view/5921/privacy-switching-for-members)

Changes
V 8.1
V 7.1
V 6.2
V 6.1 (final)
V 6.1dev2
V 6.1dev1:
Michael Zülsdorff
Replied 4 months ago
Thank you, Arsalan.
Your fix comes included with Privacy Changer 8.1.
Arsalan Shah
Replied 4 months ago
.
<?php
/**
* Open Source Social Network
* @link https://www.opensource-socialnetwork.org/
* @package Privacy Changer
* @author Michael Zülsdorff <[email protected]>
* @copyright (C) Michael Zülsdorff
* @license GNU General Public License https://www.gnu.de/documents/gpl-2.0.en.html
*/
$user = ossn_loggedin_user();
$id = input('post');
$ossnwall = new OssnWall();
$post = $ossnwall->GetPost($id);
if($user && $post && ossn_is_xhr()) {
header('Content-Type: application/json');
if($post->type != 'user' || ($post->type == 'user' && !$user->canModerate())) {
if($post->type != 'user' || ($post->type == 'user' && $post->poster_guid != $user->guid && $post->owner_guid != $user->guid)) {
echo json_encode(array(
'success' => 0,
'error' => ossn_print('com:privacy:changer:access:denied'),
));
exit();
}
}
if($post->access == OSSN_PUBLIC) {
$post->data->access = OSSN_FRIENDS;
$icon = 'fa-users';
$title = ossn_print('title:access:3');
$menu = ossn_print('com:privacy:changer:change:privacy:3');
} else {
if($post->access == OSSN_FRIENDS) {
$post->data->access = OSSN_PUBLIC;
$icon = 'fa-globe-americas';
$title = ossn_print('title:access:2');
$menu = ossn_print('com:privacy:changer:change:privacy:2');
}
}
if($post->save()) {
echo json_encode(array(
'success' => 1,
'icon' => $icon,
'title' => $title,
'menu' => $menu,
));
exit();
} else {
echo json_encode(array(
'success' => 0,
'error' => ossn_print('com:privacy:changer:change:failed'),
));
exit();
}
}
ossn_trigger_message(ossn_print('com:privacy:changer:access:denied'), 'error');
redirect(REF);
Fixed code above for action file
Arsalan Shah
Replied 4 months ago
It needs update because of OssnWall change, as it no longer require JSON saving in post
json_encode($data, JSON_UNESCAPED_UNICODE)
Michael Zülsdorff
Replied 3 years ago
Thanks for applying that bug fix, Arsalan.
Release 6.2 is working flawlessly now.
Arsalan Shah
Replied 3 years ago
The action needs update because of we are storing json for post object and on save() it need to be restored to actual json again. https://gist.github.com/lianglee/1c2fa4ef1aea09cb081bf626798e71b3
TalkToAi Online
Replied 4 years ago
Thank you : )
Arsalan Shah
Replied 4 years ago
Its not possible for us to start testing components from OSSN 1.x.
If something wrong happens to website site owner will tell developer about it and after days of testing it will appears person edited the component to make it work on non supported OSSN version.
Allon Prooit
Replied 4 years ago
Right on Mr. Michael! But, I must say that I have found on numerous occasions with a large number of components that they work quite well with versions of OSSN that are far below the requirements and that the component developers are just posting components that work on said versions without having even tried them out on earlier versions of OSSN. For instance, the Images with Messages component works fine with OSSN 5.6. All one has to do is alter the OSSN_COM.xml file for the OSSN version being used to see if it will work for their installation. Most times it does. In those cases where it doesn't all you have to do is go into phpMyAdmin and change the site settings for CACHE to "0" and then the component that caused the crash from ACTIVE "1" to "0" to resolve the crash. Just trying to help. Been working with OSSN some 4 years now and this is my best advise for crashes caused by components.
Michael Zülsdorff
Replied 4 years ago
Okay, let me take this opportunity to say that we implement requirement checks for good reasons, not to make your life a little harder. In the best case, ignoring may lead to immediate crashes, but also to problems of the category My site stopped working all of a sudden that are only visible much later.
Allon Prooit
Replied 4 years ago
Many thanks for this great component!
Just to note... V 6.1dev2 can be made to work for OSSN 5.6 but V 6.1 does not.
Sorry, not able to upgrade to OSSN 6.1 just yet.