Created
January 20, 2016 17:28
-
-
Save lianglee/e0b7a03f15f145ca3652 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Open Source Social Network | |
| * | |
| * @packageOpen Source Social Network | |
| * @author Open Social Website Core Team <info@informatikon.com> | |
| * @copyright 2014 iNFORMATIKON TECHNOLOGIES | |
| * @license General Public Licence http://www.opensource-socialnetwork.org/licence | |
| * @link http://www.opensource-socialnetwork.org/licence | |
| */ | |
| $wall = new OssnWall; | |
| $accesstype = ossn_get_homepage_wall_access(); | |
| $user = ossn_loggedin_user(); | |
| $friends = $user->getFriends('', array('count' => true)); | |
| if($accesstype == 'public' || ossn_isAdminLoggedin()) { | |
| if(!$user->canModerate() && $friends > 0){ | |
| $posts = $wall->GetPosts(array( | |
| 'type' => 'user', | |
| 'joins' => array( | |
| 'JOIN ossn_entities as ec ON o.guid = ec.owner_guid', | |
| 'JOIN ossn_entities_metadata as emdc ON ec.guid=emdc.guid', | |
| 'JOIN ossn_entities as ea ON o.guid = ea.owner_guid', | |
| 'JOIN ossn_entities_metadata as emda ON ea.guid=emda.guid', | |
| " JOIN ossn_relationships as r ON ( | |
| (r.relation_from=emdc.value AND (r.type='friend:request' AND r.relation_to={$user->guid}) OR (emdc.value={$user->guid} AND emda.value IN(2, 3))) OR | |
| ((r.relation_to != {$user->guid}) AND (ea.subtype='access' AND emda.value=2)))", | |
| "JOIN ossn_relationships as r1 ON ( | |
| (r1.relation_to=emdc.value AND (r1.type='friend:request' AND r1.relation_from={$user->guid}) OR (emdc.value={$user->guid} AND emda.value IN(2, 3))) OR | |
| ((r1.relation_from != {$user->guid}) AND (ea.subtype='access' AND emda.value=2)))", | |
| ), | |
| 'wheres' => "ea.type='object' AND ea.subtype='access' AND ec.type = 'object' AND ec.subtype='poster_guid' AND o.subtype ='wall' OR emdc.value={$user->guid}", | |
| 'distinct' => true, | |
| )); | |
| $count = $wall->GetPosts(array( | |
| 'count' => true, | |
| 'joins' => array( | |
| 'JOIN ossn_entities as ec ON o.guid = ec.owner_guid', | |
| 'JOIN ossn_entities_metadata as emdc ON ec.guid=emdc.guid', | |
| 'JOIN ossn_entities as ea ON o.guid = ea.owner_guid', | |
| 'JOIN ossn_entities_metadata as emda ON ea.guid=emda.guid', | |
| " JOIN ossn_relationships as r ON ( | |
| (r.relation_from=emdc.value AND (r.type='friend:request' AND r.relation_to={$user->guid}) OR (emdc.value={$user->guid} AND emda.value IN(2, 3))) OR | |
| ((r.relation_to != {$user->guid}) AND (ea.subtype='access' AND emda.value=2)))", | |
| "JOIN ossn_relationships as r1 ON ( | |
| (r1.relation_to=emdc.value AND (r1.type='friend:request' AND r1.relation_from={$user->guid}) OR (emdc.value={$user->guid} AND emda.value IN(2, 3))) OR | |
| ((r1.relation_from != {$user->guid}) AND (ea.subtype='access' AND emda.value=2)))", | |
| ), | |
| 'wheres' => "ea.type='object' AND ea.subtype='access' AND ec.type = 'object' AND ec.subtype='poster_guid' AND o.subtype ='wall' OR emdc.value={$user->guid}", | |
| 'distinct' => true, | |
| )); | |
| } elseif(!$user->canModerate()){ | |
| $posts = $wall->GetPosts(array( | |
| 'type' => 'user', | |
| 'joins' => array( | |
| 'JOIN ossn_entities as ec ON o.guid = ec.owner_guid', | |
| 'JOIN ossn_entities_metadata as emdc ON ec.guid=emdc.guid', | |
| 'JOIN ossn_entities as eca ON o.guid = eca.owner_guid', | |
| 'JOIN ossn_entities_metadata as emdca ON eca.guid=emdca.guid', | |
| ), | |
| 'wheres' => "ec.type = 'object' AND ec.subtype='poster_guid' AND o.subtype ='wall' AND ( | |
| (eca.subtype='access' AND emdca.value IN (1, 2)) OR emdca.value={$user->guid})", | |
| 'distinct' => true, | |
| )); | |
| $count = $wall->GetPosts(array( | |
| 'count' => true, | |
| 'type' => 'user', | |
| 'joins' => array( | |
| 'JOIN ossn_entities as ec ON o.guid = ec.owner_guid', | |
| 'JOIN ossn_entities_metadata as emdc ON ec.guid=emdc.guid', | |
| 'JOIN ossn_entities as eca ON o.guid = eca.owner_guid', | |
| 'JOIN ossn_entities_metadata as emdca ON eca.guid=emdca.guid', | |
| ), | |
| 'wheres' => "ec.type = 'object' AND ec.subtype='poster_guid' AND o.subtype ='wall' AND ( | |
| (eca.subtype='access' AND emdca.value IN (1, 2)) OR emdca.value={$user->guid})", | |
| 'distinct' => true, | |
| )); | |
| } elseif($user->canModerate()){ | |
| $posts = $wall->GetPosts(array( | |
| 'type' => 'user', | |
| )); | |
| $count = $wall->GetPosts(array( | |
| 'count' => true, | |
| 'type' => 'user', | |
| )); | |
| } | |
| } elseif($accesstype == 'friends') { | |
| $posts = $wall->getFriendsPosts(); | |
| $count = $wall->getFriendsPosts(array( | |
| 'count' => true | |
| )); | |
| } | |
| $loggedinuser = ossn_loggedin_user(); | |
| if($posts) { | |
| foreach($posts as $post) { | |
| $item = ossn_wallpost_to_item($post); | |
| echo ossn_wall_view_template($item); | |
| } | |
| } | |
| echo ossn_view_pagination($count); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment