/** * 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'); } } }
/** * 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'))); } } }