/** * View post menu * * @param string $hook Name of hook * @param string $type Hook type * @param string $return mixed data * @param array $params Arrays or Objects * * @return mixed data * @access private */ function ossn_wall_post_menu($hook, $type, $return, $params) { if ($params['post']->poster_guid == ossn_loggedin_user()->guid || $params['post']->owner_guid == ossn_loggedin_user()->guid || ossn_isAdminLoggedin()) { $deleteurl = ossn_site_url("action/wall/post/delete?post={$params['post']->guid}", true); ossn_register_menu_link("delete", ossn_print('ossn:post:delete'), array('class' => 'ossn-wall-post-delete', 'href' => $deleteurl, 'data-guid' => $params['post']->guid), 'wallpost'); } else { ossn_unregister_menu('delete', 'wallpost'); } return ossn_view_menu('wallpost', 'wall/menus/post-controls'); }
/** * Delete comment menu * * @return voud; * @access private */ function ossn_comment_menu($name, $type, $params) { ossn_unregister_menu('delete', 'comments'); $OssnComment = new OssnComments(); if (is_object($params)) { $params = get_object_vars($params); } $comment = $OssnComment->getComment($params['id']); if ($comment->type == 'comments:post') { if (com_is_active('OssnWall')) { $ossnwall = new OssnWall(); $post = $ossnwall->GetPost($comment->subject_guid); //check if type is group if ($post->type == 'group') { $group = ossn_get_group_by_guid($post->owner_guid); } //group admins must be able to delete ANY comment in their own group #170 //just show menu if group owner is loggedin if (ossn_loggedin_user()->guid == $post->owner_guid || ossn_loggedin_user()->guid == $group->owner_guid) { ossn_register_menu_link('delete', ossn_print('comment:delete'), array('href' => ossn_site_url("action/delete/comment?comment={$params['id']}", true), 'class' => 'ossn-delete-comment'), 'comments'); } } } $user = ossn_loggedin_user(); if (ossn_isLoggedin()) { if ($comment->type == 'comments:entity') { $entity = ossn_get_entity($comment->subject_guid); } if ($user->guid == $params['owner_guid'] || ossn_isAdminLoggedin() || $comment->type == 'comments:entity' && ($entity->type = 'user' && $user->guid == $entity->owner_guid)) { ossn_register_menu_link('delete', ossn_print('comment:delete'), array('href' => ossn_site_url("action/delete/comment?comment={$params['id']}", true), 'class' => 'ossn-delete-comment'), 'comments'); } } }
/** * Add a entity like menu item * * @return void */ function ossn_entity_like_link($callback, $type, $params) { $guid = $params['entity']->guid; ossn_unregister_menu('like', 'entityextra'); if (!empty($guid)) { $likes = new OssnLikes(); if (!$likes->isLiked($guid, ossn_loggedin_user()->guid, 'entity')) { ossn_register_menu_item('entityextra', array('name' => 'like', 'href' => "javascript:;", 'id' => 'ossn-like-' . $guid, 'onclick' => "Ossn.EntityLike({$guid});", 'text' => ossn_print('ossn:like'))); } else { ossn_register_menu_item('entityextra', array('name' => 'like', 'href' => "javascript:;", 'id' => 'ossn-like-' . $guid, 'onclick' => "Ossn.EntityUnlike({$guid});", 'text' => ossn_print('ossn:unlike'))); } } }
/** * Delete comment menu * * @return voud; * @access private */ function ossn_comment_menu($name, $type, $params) { ossn_unregister_menu('delete', 'comments'); $OssnComment = new OssnComments(); if (is_object($params)) { $params = get_object_vars($params); } $comment = $OssnComment->getComment($params['id']); if ($comment->type == 'comments:post') { if (com_is_active('OssnWall')) { $ossnwall = new OssnWall(); $post = $ossnwall->GetPost($comment->subject_guid); if (ossn_loggedin_user()->guid == $post->owner_guid) { ossn_register_menu_link('delete', ossn_print('comment:delete'), array('href' => ossn_site_url("action/delete/comment?comment={$params['id']}"), 'class' => 'ossn-delete-comment'), 'comments'); } } } $user = ossn_loggedin_user(); if (ossn_isLoggedin()) { if ($user->guid == $params['owner_guid'] || ossn_isAdminLoggedin()) { ossn_register_menu_link('delete', ossn_print('comment:delete'), array('href' => ossn_site_url("action/delete/comment?comment={$params['id']}"), 'class' => 'ossn-delete-comment'), 'comments'); } } }
/** * Delete comment menu * * @return voud; * @access private */ function ossn_comment_menu($name, $type, $params) { //unset previous comment menu item //Post owner can not delete others comments #607 //Pull request #601 , refactoring ossn_unregister_menu('delete', 'comments'); $user = ossn_loggedin_user(); $OssnComment = new OssnComments(); if (is_object($params)) { $params = get_object_vars($params); } $comment = $OssnComment->getComment($params['id']); if ($comment->type == 'comments:post') { if (com_is_active('OssnWall')) { $ossnwall = new OssnWall(); $post = $ossnwall->GetPost($comment->subject_guid); //check if type is group if ($post->type == 'group') { $group = ossn_get_group_by_guid($post->owner_guid); } //group admins must be able to delete ANY comment in their own group #170 //just show menu if group owner is loggedin if (ossn_loggedin_user()->guid == $post->owner_guid || $user->guid == $comment->owner_guid || ossn_loggedin_user()->guid == $group->owner_guid) { ossn_unregister_menu('delete', 'comments'); ossn_register_menu_item('comments', array('name' => 'delete', 'href' => ossn_site_url("action/delete/comment?comment={$params['id']}", true), 'class' => 'ossn-delete-comment', 'text' => ossn_print('comment:delete'))); } } } //this section is for entity comment only if (ossn_isLoggedin() && $comment->type == 'comments:entity') { $entity = ossn_get_entity($comment->subject_guid); if ($user->guid == $params['owner_guid'] || ossn_isAdminLoggedin() || $comment->type == 'comments:entity' && ($entity->type = 'user' && $user->guid == $entity->owner_guid)) { ossn_unregister_menu('delete', 'comments'); ossn_register_menu_item('comments', array('name' => 'delete', 'href' => ossn_site_url("action/delete/comment?comment={$params['id']}", true), 'class' => 'ossn-delete-comment', 'text' => ossn_print('comment:delete'))); } } }