/** * Convert wallobject to wall post item * * @param object $post A wall object * * @return array|false */ function ossn_wallpost_to_item($post) { if ($post && $post instanceof OssnWall) { if (!isset($post->poster_guid)) { $post = ossn_get_object($post->guid); } $data = json_decode(html_entity_decode($post->description)); $text = ossn_restore_new_lines($data->post, true); $location = ''; if (isset($data->location)) { $location = '- ' . $data->location; } if (isset($post->{'file:wallphoto'})) { $image = str_replace('ossnwall/images/', '', $post->{'file:wallphoto'}); } else { $image = ''; } $user = ossn_user_by_guid($post->poster_guid); return array('post' => $post, 'friends' => explode(',', $data->friend), 'text' => $text, 'location' => $location, 'user' => $user, 'image' => $image); } return false; }
* @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(); if ($accesstype == 'public' || ossn_isAdminLoggedin()) { $posts = $wall->GetPosts(); $count = $wall->GetPosts(array('count' => true)); } elseif ($accesstype == 'friends') { $posts = $wall->getFriendsPosts(); } if ($posts) { foreach ($posts as $post) { if (!isset($post->poster_guid)) { $post = ossn_get_object($post->guid); } $data = json_decode(html_entity_decode($post->description)); $text = ossn_restore_new_lines($data->post, true); $location = ''; if (isset($data->location)) { $location = '- ' . $data->location; } if (isset($post->{'file:wallphoto'})) { $image = str_replace('ossnwall/images/', '', $post->{'file:wallphoto'}); } else { $image = ''; } $user = ossn_user_by_guid($post->poster_guid); if ($post->access == OSSN_FRIENDS) { if (ossn_user_is_friend(ossn_loggedin_user()->guid, $post->owner_guid) || ossn_loggedin_user()->guid == $post->owner_guid) {
/** * Delete profile photo/cover wall post * * @param int $fileguid Profile/Cover file id * @return bool */ public function deletePhotoWallPost($fileguid) { if (empty($fileguid)) { return false; } //prepare a query to get post guid $statement = "SELECT * FROM ossn_entities, ossn_entities_metadata WHERE(\n\t\t\t\t \t ossn_entities_metadata.guid = ossn_entities.guid \n\t\t\t\t AND ossn_entities.subtype='item_guid'\n\t\t\t\t AND ossn_entities.type = 'object'\n\t\t\t\t AND ossn_entities_metadata.value = '{$fileguid}'\n\t\t\t\t );"; $this->statement($statement); $this->execute(); $entity = $this->fetch(); //check if post exists or not if ($entity) { //get object $object = ossn_get_object($entity->owner_guid); if ($object && $object->subtype == 'wall') { $wall = new OssnWall(); //delete wall post if ($wall->deletePost($object->guid)) { return true; } } } return false; }
/** * Open Source Social Network * * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ $comment = input('comment'); $delete = new OssnComments(); $comment = $delete->GetComment($comment); //group admins must be able to delete ANY comment in their own group #170 //first get wall post then get group and check if loggedin user is group owner if ($comment->type == 'comments:post') { $post = ossn_get_object($comment->subject_guid); if ($post && $post->type == 'group') { $group = ossn_get_group_by_guid($post->owner_guid); } } $user = ossn_loggedin_user(); if ($comment->type == 'comments:entity') { $entity = ossn_get_entity($comment->subject_guid); } //Post owner can not delete others comments #607 if ($comment->owner_guid == $user->guid || $post->type == 'user' && $user->guid == $post->owner_guid || $group->owner_guid == $user->guid || $entity->owner_guid == $user->guid || ossn_isAdminLoggedin()) { if ($delete->deleteComment($comment->getID())) { if (ossn_is_xhr()) { echo 1; } else { ossn_trigger_message(ossn_print('comment:deleted'), 'success');