From b3bfd7adf4b835fb47e296f6648e25cb87f97189 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Thu, 15 Aug 2024 10:48:13 -0700 Subject: [PATCH 01/23] skeleton of like button --- core/components/com_forum/site/assets/css/like.css | 4 ++++ core/components/com_forum/site/assets/js/like.js | 1 + .../com_forum/site/views/threads/tmpl/_comment.php | 7 +++++++ 3 files changed, 12 insertions(+) create mode 100644 core/components/com_forum/site/assets/css/like.css create mode 100644 core/components/com_forum/site/assets/js/like.js diff --git a/core/components/com_forum/site/assets/css/like.css b/core/components/com_forum/site/assets/css/like.css new file mode 100644 index 00000000000..7ec5b1fc980 --- /dev/null +++ b/core/components/com_forum/site/assets/css/like.css @@ -0,0 +1,4 @@ +/* Should put this in the comments.less file */ +ol.comments .comment-options a.like { + float: right; +} \ No newline at end of file diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js new file mode 100644 index 00000000000..268238ce509 --- /dev/null +++ b/core/components/com_forum/site/assets/js/like.js @@ -0,0 +1 @@ +console.log("like on site forum"); \ No newline at end of file diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index 82b6231e022..e68e6649de7 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -7,6 +7,9 @@ defined('_HZEXEC_') or die(); +$this->css('like.css') + ->js('like.js'); + $this->comment->set('section', $this->filters['section']); $this->comment->set('category', $this->category->get('alias')); @@ -122,6 +125,10 @@ ) ) { ?>

+ + comment->get('parent') && $this->config->get('access-delete-thread')) || ($this->comment->get('parent') && $this->config->get('access-delete-post'))) { ?> - comment->get('parent') && $this->config->get('access-delete-thread')) || ($this->comment->get('parent') && $this->config->get('access-delete-post'))) { ?> - comment->get('parent') && $this->config->get('access-delete-thread')) || ($this->comment->get('parent') && $this->config->get('access-delete-post'))) { ?> diff --git a/core/components/com_forum/site/views/threads/tmpl/display.php b/core/components/com_forum/site/views/threads/tmpl/display.php index 07541aa8f66..94a143fc913 100644 --- a/core/components/com_forum/site/views/threads/tmpl/display.php +++ b/core/components/com_forum/site/views/threads/tmpl/display.php @@ -15,6 +15,8 @@ $this->thread->set('section', $this->filters['section']); $this->thread->set('category', $this->category->get('alias')); +print_r($this->likes); + $now = Date::of('now')->toSql(); ?>

From 80a153237dd8c17c2e0aafaec6a74a18b819fd8d Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Mon, 19 Aug 2024 17:34:13 -0700 Subject: [PATCH 06/23] add in count and red to likes --- .../site/views/threads/tmpl/_comment.php | 15 +++++++++++++-- .../com_forum/site/views/threads/tmpl/_list.php | 14 ++++++++++++++ .../com_forum/site/views/threads/tmpl/display.php | 3 +-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index 4fbed4df942..70ff055bbc3 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -10,6 +10,17 @@ $this->css('like.css') ->js('like.js'); + $likeArray = $this->like; + $countLike = count($likeArray); + $currentUserId = User::get('id'); + + $userLikesComment = false; + foreach ( $likeArray as $likeObj ) { + if ( $currentUserId == $likeObj->userId ) { + $userLikesComment = true; + } + } + $this->comment->set('section', $this->filters['section']); $this->comment->set('category', $this->category->get('alias')); @@ -127,11 +138,11 @@

- comment->get('parent') && $this->config->get('access-delete-thread')) || ($this->comment->get('parent') && $this->config->get('access-delete-post'))) { ?> + +

+
comment->attachments()->whereEquals('state', Components\Forum\Models\Attachment::STATE_PUBLISHED)->rows() as $attachment) @@ -136,14 +154,6 @@ ) ) { ?>

- - - comment->get('parent') && $this->config->get('access-delete-thread')) || ($this->comment->get('parent') && $this->config->get('access-delete-post'))) { ?> -

diff --git a/core/components/com_forum/site/views/threads/tmpl/_list.php b/core/components/com_forum/site/views/threads/tmpl/_list.php index 09e894bb6cf..fe3e4a38072 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_list.php +++ b/core/components/com_forum/site/views/threads/tmpl/_list.php @@ -18,11 +18,12 @@ } } +//print_r($hash_map); + ?>
    comments) -{ +if ($this->comments) { $cls = 'odd'; if (isset($this->cls)) { @@ -36,16 +37,16 @@ $this->depth++; - foreach ($this->comments as $comment) - { - $postId = $comment->get('id'); - $likesByPostId = $hash_map[$postId]; - + foreach ($this->comments as $comment) { + + $postId = $comment->get('id'); + $likesByPostId = isset($hash_map[$postId]) ? $hash_map[$postId] : []; + $this->view('_comment') ->set('option', $this->option) ->set('controller', $this->controller) ->set('comment', $comment) - ->set('like', $likesByPostId) + ->set('like', $likesByPostId) ->set('thread', $this->thread) ->set('config', $this->config) ->set('depth', $this->depth) From 5b236c65378295d5eb45b3af0aa646e906b132eb Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Fri, 23 Aug 2024 15:09:46 -0700 Subject: [PATCH 10/23] updated hover over of likes --- .../com_forum/site/assets/css/like.css | 9 ++++--- .../com_forum/site/assets/js/like.js | 27 ++++++++++--------- .../site/views/threads/tmpl/_comment.php | 5 +++- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/core/components/com_forum/site/assets/css/like.css b/core/components/com_forum/site/assets/css/like.css index 63621137ef5..34603708844 100644 --- a/core/components/com_forum/site/assets/css/like.css +++ b/core/components/com_forum/site/assets/css/like.css @@ -15,12 +15,15 @@ } .elementToPopup { - /*display: none;*/ + display: none; position: absolute; top: 30px; - left: 7px; + left: -80px; background-color: #555; color: #fff; - padding: 8px; + padding: 10px; border-radius: 5px; + z-index: 1; + width: 150px; + text-align: right; } \ No newline at end of file diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 1bf5df5137a..f7102da48a2 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -3,12 +3,8 @@ console.log("like on site forum"); window.addEventListener('DOMContentLoaded', (domEvent) => { // Find all the "like" button const likeButton = document.querySelectorAll('.comment-body .like') - const likePopup = document.querySelectorAll('.comment-body .elementToPopup') if (likeButton.length) { for(let i = 0; i < likeButton.length;i++) { - console.log(likeButton); - console.log(likePopup); - likeButton[i].onclick = (e) => { e.preventDefault(); @@ -31,13 +27,17 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const newLikeCount = Number(likeCount) - 1; const newLikesString = likesListArray.filter(e => e !== userName).join('/'); + // Create ELEMENT + const element = document.createElement('span'); + element.classList.add("elementToPopup"); + element.innerHTML = newLikesString.split("/").join("
    "); + likeButton[i].dataset.count = `${newLikeCount}`; likeButton[i].innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; + likeButton[i].appendChild(element); likeButton[i].classList.remove("userLiked"); likeButton[i].dataset.likesList = newLikesString; - likePopup[i].innerHTML = newLikesString; - console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } }) @@ -47,13 +47,17 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const newLikeCount = Number(likeCount) + 1; const newLikesString = [...likesListArray, userName].join('/'); + // Create ELEMENT + const element = document.createElement('span'); + element.classList.add("elementToPopup"); + element.innerHTML = newLikesString.split("/").join("
    "); + likeButton[i].dataset.count = `${newLikeCount}`; likeButton[i].innerHTML = `Like (${newLikeCount})`; + likeButton[i].appendChild(element); likeButton[i].classList.add("userLiked"); likeButton[i].dataset.likesList = newLikesString; - likePopup[i].innerHTML = newLikesString; - console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } }) @@ -62,15 +66,14 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { return false; }; + // Hover over and mouse leave likeButton[i].onmouseover = (e) => { - likePopup[i].style.display = 'block'; + likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; }; likeButton[i].onmouseleave = (e) => { - likePopup[i].style.display = 'none'; + likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'none'; }; - - // https://www.geeksforgeeks.org/how-to-open-a-popup-on-hover-using-javascript/ } } }); diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index 9f7bf59a31c..f3c523a265f 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -84,7 +84,10 @@ > 0) ? "Like (" . $countLike . ")" : "Like"; ?> - + ",$nameArray); + ?>
    From 3e63c5d2401198f8b16cf4091e846e3a5f7ae140 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Fri, 23 Aug 2024 15:44:35 -0700 Subject: [PATCH 11/23] change after revert failed merge --- core/components/com_forum/site/assets/css/like.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/components/com_forum/site/assets/css/like.css b/core/components/com_forum/site/assets/css/like.css index 34603708844..10592a9eadc 100644 --- a/core/components/com_forum/site/assets/css/like.css +++ b/core/components/com_forum/site/assets/css/like.css @@ -24,6 +24,6 @@ padding: 10px; border-radius: 5px; z-index: 1; - width: 150px; + width: 151px; text-align: right; } \ No newline at end of file From 9d7ebd95d4f23805205353cdbbac4e3ee2dee182 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Mon, 26 Aug 2024 22:00:43 -0700 Subject: [PATCH 12/23] forum in plugin groups --- core/plugins/groups/forum/assets/css/like.css | 29 +++++ core/plugins/groups/forum/assets/js/like.js | 121 ++++++++++++++++++ core/plugins/groups/forum/forum.php | 10 ++ .../forum/views/threads/tmpl/_comment.php | 37 ++++++ .../groups/forum/views/threads/tmpl/_list.php | 19 ++- .../forum/views/threads/tmpl/display.php | 1 + 6 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 core/plugins/groups/forum/assets/css/like.css create mode 100644 core/plugins/groups/forum/assets/js/like.js diff --git a/core/plugins/groups/forum/assets/css/like.css b/core/plugins/groups/forum/assets/css/like.css new file mode 100644 index 00000000000..10592a9eadc --- /dev/null +++ b/core/plugins/groups/forum/assets/css/like.css @@ -0,0 +1,29 @@ +/* Should put this in the comments.less file */ +.comment-body a.like { + float: right; + color: gray; + margin-bottom: 10px; +} + +.comment-body a.userLiked { + color: red; +} + +.elementToHover { + display: inline-block; + position: relative; +} + +.elementToPopup { + display: none; + position: absolute; + top: 30px; + left: -80px; + background-color: #555; + color: #fff; + padding: 10px; + border-radius: 5px; + z-index: 1; + width: 151px; + text-align: right; +} \ No newline at end of file diff --git a/core/plugins/groups/forum/assets/js/like.js b/core/plugins/groups/forum/assets/js/like.js new file mode 100644 index 00000000000..01f361b2c72 --- /dev/null +++ b/core/plugins/groups/forum/assets/js/like.js @@ -0,0 +1,121 @@ +console.log("like on GROUP forum"); + +window.addEventListener('DOMContentLoaded', (domEvent) => { + // Find all the "like" button + const likeButton = document.querySelectorAll('.comment-body .like') + if (likeButton.length) { + for(let i = 0; i < likeButton.length;i++) { + likeButton[i].onclick = (e) => { + e.preventDefault(); + + let hasHeart = likeButton[i].classList.contains("userLiked"); + + const threadId = likeButton[i].dataset.thread; + const postId = likeButton[i].dataset.post; + const userId = likeButton[i].dataset.user; + const userName = likeButton[i].dataset.userName; + const likesList = likeButton[i].dataset.likesList; + const likeCount = likeButton[i].dataset.count; + + console.log(threadId, postId, userId, likeCount, userName, likesList); + + const likesListArray = likesList.split("/"); + + if (hasHeart) { + removeLike(threadId, postId, userId).then((res) => { + if (res.ok) { + const newLikeCount = Number(likeCount) - 1; + const newLikesString = likesListArray.filter(e => e !== userName).join('/'); + + // Create ELEMENT + const element = document.createElement('span'); + element.classList.add("elementToPopup"); + element.innerHTML = newLikesString.split("/").join("
    "); + + likeButton[i].dataset.count = `${newLikeCount}`; + likeButton[i].innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; + likeButton[i].appendChild(element); + likeButton[i].classList.remove("userLiked"); + likeButton[i].dataset.likesList = newLikesString; + + console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + } + }) + } else { + addLike(threadId, postId, userId).then((res) => { + if (res.ok) { + const newLikeCount = Number(likeCount) + 1; + const newLikesString = [...likesListArray, userName].join('/'); + + // Create ELEMENT + const element = document.createElement('span'); + element.classList.add("elementToPopup"); + element.innerHTML = newLikesString.split("/").join("
    "); + + likeButton[i].dataset.count = `${newLikeCount}`; + likeButton[i].innerHTML = `Like (${newLikeCount})`; + likeButton[i].appendChild(element); + likeButton[i].classList.add("userLiked"); + likeButton[i].dataset.likesList = newLikesString; + + console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + } + }) + } + + return false; + }; + + // Hover over and mouse leave + likeButton[i].onmouseover = (e) => { + likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; + }; + + likeButton[i].onmouseleave = (e) => { + likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'none'; + }; + } + } +}); + +const addLike = async (threadId, postId, userId) => { + const postUrl = "/api/forum/likes/addLikeToPost"; + const data = {threadId, postId, userId}; + + try { + let response = await fetch(postUrl, { + method: "POST", headers: {"Content-Type": "application/x-www-form-urlencoded"}, + body: new URLSearchParams(data) // urlencoded form body + }); + + if (!response.ok) { + window.confirm("Server Error with API"); + console.error(`Error Code: ${response.status} / Error Message: ${response.statusText}`); + } + + return response; + } catch (error) { + if (error instanceof SyntaxError) { + console.error('There was a SyntaxError', error); + } else { + console.error('There was an error', error); + } + } +}; + +const removeLike = async (threadId, postId, userId) => { + const deleteAssertionUrl = "/api/forum/likes/deleteLikeFromPost"; + const data = {threadId, postId, userId}; + + const deleteAssertionResp = await fetch(deleteAssertionUrl, { + method: "DELETE", headers: {"Content-Type": "application/x-www-form-urlencoded"}, + body: new URLSearchParams(data) + }) + + if (!deleteAssertionResp.ok) { + window.confirm("Server Error with API"); + console.error(`Error Code: ${response.status} / Error Message: ${response.statusText}`); + } + + return deleteAssertionResp; +} \ No newline at end of file diff --git a/core/plugins/groups/forum/forum.php b/core/plugins/groups/forum/forum.php index 9dfb97f3d89..3642e7c0d84 100644 --- a/core/plugins/groups/forum/forum.php +++ b/core/plugins/groups/forum/forum.php @@ -1246,6 +1246,15 @@ public function threads() $this->_authorize('thread', $thread->get('id')); $this->_authorize('post'); + // Get all the likes of this thread + $db = \App::get('db'); + $queryLikes = "SELECT LIKES.threadId as 'threadId', LIKES.postId as 'postId', + LIKES.userId as 'userId', USERS.name as 'userName', USERS.email as 'userEmail' + FROM jos_forum_posts_like as LIKES, jos_users AS USERS + WHERE LIKES.userId = USERS.id AND LIKES.threadId = " . $thread->get('id'); + $db->setQuery($queryLikes); + $initialLikesList = $db->loadObjectList(); + // If the access is anything beyond public, // make sure they're logged in. if (User::isGuest() && !in_array($thread->get('access'), User::getAuthorisedViewLevels())) @@ -1280,6 +1289,7 @@ public function threads() ->set('section', $section) ->set('category', $category) ->set('thread', $thread) + ->set('likes', $initialLikesList) ->set('filters', $filters) ->setErrors($this->getErrors()) ->loadTemplate(); diff --git a/core/plugins/groups/forum/views/threads/tmpl/_comment.php b/core/plugins/groups/forum/views/threads/tmpl/_comment.php index 73811a2382a..e23930959d2 100644 --- a/core/plugins/groups/forum/views/threads/tmpl/_comment.php +++ b/core/plugins/groups/forum/views/threads/tmpl/_comment.php @@ -7,6 +7,24 @@ defined('_HZEXEC_') or die(); +$this->css('like.css') + ->js('like.js'); + + $likeArray = $this->like; + $countLike = count($likeArray); + $currentUserId = User::get('id'); + + $userLikesComment = false; + $userNameLikesArray = ""; + foreach ( $likeArray as $likeObj ) { + if ( $currentUserId == $likeObj->userId ) { + $userLikesComment = true; + } + + $userNameLikesArray .= "/" . ($likeObj->userName); + } + $userNameLikesArray = substr($userNameLikesArray,1); + $this->comment->set('section', $this->filters['section']); $this->comment->set('category', $this->category->get('alias')); @@ -60,6 +78,25 @@

    likes)) { + foreach ($this->likes as $like){ + $postId = $like->postId; + if (isset($hash_map[$postId])) { + $hash_map[$postId][] = $like; + } else { + $hash_map[$postId] = array($like); + } + } +} + ?>
      depth++; - foreach ($this->comments as $comment) - { + foreach ($this->comments as $comment) { + $postId = $comment->get('id'); + $likesByPostId = isset($hash_map[$postId]) ? $hash_map[$postId] : []; + $this->view('_comment') ->set('option', $this->option) ->set('group', $this->group) ->set('comment', $comment) + ->set('like', $likesByPostId) ->set('thread', $this->thread) ->set('config', $this->config) ->set('depth', $this->depth) diff --git a/core/plugins/groups/forum/views/threads/tmpl/display.php b/core/plugins/groups/forum/views/threads/tmpl/display.php index fa193178ad0..069128c70c3 100644 --- a/core/plugins/groups/forum/views/threads/tmpl/display.php +++ b/core/plugins/groups/forum/views/threads/tmpl/display.php @@ -70,6 +70,7 @@ ->set('group', $this->group) ->set('comments', $posts) ->set('thread', $this->thread) + ->set('likes', $this->likes) ->set('parent', 0) ->set('config', $this->config) ->set('depth', 0) From a317759b94051cbd7787e08ce8c5ababfee4c7b7 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Mon, 26 Aug 2024 22:05:08 -0700 Subject: [PATCH 13/23] don't show popup when count is 0 --- core/components/com_forum/site/assets/js/like.js | 4 +++- core/plugins/groups/forum/assets/js/like.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index f7102da48a2..c6062ba4f9e 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -68,7 +68,9 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { // Hover over and mouse leave likeButton[i].onmouseover = (e) => { - likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; + if (likeButton[i].dataset.count > 0) { + likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; + } }; likeButton[i].onmouseleave = (e) => { diff --git a/core/plugins/groups/forum/assets/js/like.js b/core/plugins/groups/forum/assets/js/like.js index 01f361b2c72..119071d562e 100644 --- a/core/plugins/groups/forum/assets/js/like.js +++ b/core/plugins/groups/forum/assets/js/like.js @@ -68,7 +68,9 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { // Hover over and mouse leave likeButton[i].onmouseover = (e) => { - likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; + if (likeButton[i].dataset.count > 0) { + likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; + } }; likeButton[i].onmouseleave = (e) => { From b63bc98e0fd5ef30582c7f6e45ff59667bcfecbd Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Wed, 28 Aug 2024 15:17:02 -0700 Subject: [PATCH 14/23] fixing nesting issues --- core/components/com_forum/site/assets/js/like.js | 4 +--- .../components/com_forum/site/views/threads/tmpl/_comment.php | 1 + core/components/com_forum/site/views/threads/tmpl/_list.php | 1 + core/plugins/groups/forum/assets/js/like.js | 4 ---- core/plugins/groups/forum/views/threads/tmpl/_comment.php | 1 + core/plugins/groups/forum/views/threads/tmpl/_list.php | 1 + 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index c6062ba4f9e..9ac2b24417e 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -1,5 +1,3 @@ -console.log("like on site forum"); - window.addEventListener('DOMContentLoaded', (domEvent) => { // Find all the "like" button const likeButton = document.querySelectorAll('.comment-body .like') @@ -17,7 +15,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const likesList = likeButton[i].dataset.likesList; const likeCount = likeButton[i].dataset.count; - console.log(threadId, postId, userId, likeCount, userName, likesList); + // console.log(threadId, postId, userId, likeCount, userName, likesList); const likesListArray = likesList.split("/"); diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index f3c523a265f..17f54a09b64 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -257,6 +257,7 @@ ->set('controller', $this->controller) ->set('comments', $this->comment->get('replies')) ->set('thread', $this->thread) + ->set('likes', $this->likes) ->set('parent', $this->comment->get('id')) ->set('config', $this->config) ->set('depth', $this->depth) diff --git a/core/components/com_forum/site/views/threads/tmpl/_list.php b/core/components/com_forum/site/views/threads/tmpl/_list.php index fe3e4a38072..8af8e534114 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_list.php +++ b/core/components/com_forum/site/views/threads/tmpl/_list.php @@ -47,6 +47,7 @@ ->set('controller', $this->controller) ->set('comment', $comment) ->set('like', $likesByPostId) + ->set('likes', $this->likes) ->set('thread', $this->thread) ->set('config', $this->config) ->set('depth', $this->depth) diff --git a/core/plugins/groups/forum/assets/js/like.js b/core/plugins/groups/forum/assets/js/like.js index 119071d562e..0ea5dbed53e 100644 --- a/core/plugins/groups/forum/assets/js/like.js +++ b/core/plugins/groups/forum/assets/js/like.js @@ -1,5 +1,3 @@ -console.log("like on GROUP forum"); - window.addEventListener('DOMContentLoaded', (domEvent) => { // Find all the "like" button const likeButton = document.querySelectorAll('.comment-body .like') @@ -17,8 +15,6 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const likesList = likeButton[i].dataset.likesList; const likeCount = likeButton[i].dataset.count; - console.log(threadId, postId, userId, likeCount, userName, likesList); - const likesListArray = likesList.split("/"); if (hasHeart) { diff --git a/core/plugins/groups/forum/views/threads/tmpl/_comment.php b/core/plugins/groups/forum/views/threads/tmpl/_comment.php index e23930959d2..4150829a90d 100644 --- a/core/plugins/groups/forum/views/threads/tmpl/_comment.php +++ b/core/plugins/groups/forum/views/threads/tmpl/_comment.php @@ -255,6 +255,7 @@ ->set('group', $this->group) ->set('comments', $this->comment->get('replies')) ->set('thread', $this->thread) + ->set('likes', $this->likes) ->set('parent', $this->comment->get('id')) ->set('config', $this->config) ->set('depth', $this->depth) diff --git a/core/plugins/groups/forum/views/threads/tmpl/_list.php b/core/plugins/groups/forum/views/threads/tmpl/_list.php index 96cd6c24dd2..bc30edba6ce 100644 --- a/core/plugins/groups/forum/views/threads/tmpl/_list.php +++ b/core/plugins/groups/forum/views/threads/tmpl/_list.php @@ -47,6 +47,7 @@ ->set('group', $this->group) ->set('comment', $comment) ->set('like', $likesByPostId) + ->set('likes', $this->likes) ->set('thread', $this->thread) ->set('config', $this->config) ->set('depth', $this->depth) From 7e6af8a85ba50f8b9fbdf810648fe69f61f67afb Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Wed, 25 Sep 2024 10:07:25 -0700 Subject: [PATCH 15/23] modifications on placement of heart --- .../com_forum/site/assets/css/like.css | 35 +++--- .../com_forum/site/assets/js/like.js | 107 +++++++++++------- .../site/views/threads/tmpl/_comment.php | 49 +++++--- 3 files changed, 117 insertions(+), 74 deletions(-) diff --git a/core/components/com_forum/site/assets/css/like.css b/core/components/com_forum/site/assets/css/like.css index 10592a9eadc..e0c9c520d00 100644 --- a/core/components/com_forum/site/assets/css/like.css +++ b/core/components/com_forum/site/assets/css/like.css @@ -1,29 +1,36 @@ /* Should put this in the comments.less file */ .comment-body a.like { - float: right; color: gray; - margin-bottom: 10px; + margin-right: 5px; + font-size:20px; } .comment-body a.userLiked { color: red; } -.elementToHover { - display: inline-block; - position: relative; +.comment-body .likesStat { + font-size: 14px; + vertical-align:middle; + margin-top: 5px; +} + +.elementInline { + display: inline-flex; + float: right; + vertical-align:middle; +} + +.whoLikedPost { + height: 0; + overflow: hidden; + transition: height 0.8s ease; } -.elementToPopup { - display: none; - position: absolute; - top: 30px; - left: -80px; - background-color: #555; - color: #fff; +.names { padding: 10px; + background-color: #eeeeee; border-radius: 5px; - z-index: 1; - width: 151px; text-align: right; + font-size: 12px; } \ No newline at end of file diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 9ac2b24417e..fb56d94947f 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -1,21 +1,39 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { // Find all the "like" button - const likeButton = document.querySelectorAll('.comment-body .like') - if (likeButton.length) { - for(let i = 0; i < likeButton.length;i++) { - likeButton[i].onclick = (e) => { + const commentSections = document.querySelectorAll('.comment-body') + if (commentSections.length) { + for(let i = 0; i < commentSections.length;i++) { + let likeButton = commentSections[i].querySelector('.like'); + let likeStatsLink = commentSections[i].querySelector('.likesStat'); + let whoLikedPostDiv = commentSections[i].querySelector('.whoLikedPost'); + + console.log(whoLikedPostDiv.scrollHeight); + + likeStatsLink.onclick = (e) => { + this.__toggle = !this.__toggle; + console.log(this.__toggle) + if(this.__toggle) { + whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; + } else { + whoLikedPostDiv.style.height = 0; + } + } + + likeButton.onclick = (e) => { e.preventDefault(); - let hasHeart = likeButton[i].classList.contains("userLiked"); + let hasHeart = likeButton.classList.contains("userLiked"); - const threadId = likeButton[i].dataset.thread; - const postId = likeButton[i].dataset.post; - const userId = likeButton[i].dataset.user; - const userName = likeButton[i].dataset.userName; - const likesList = likeButton[i].dataset.likesList; - const likeCount = likeButton[i].dataset.count; + const threadId = likeButton.dataset.thread; + const postId = likeButton.dataset.post; + const userId = likeButton.dataset.user; + const userName = likeButton.dataset.userName; + const nameAndId = `${userName}#${userId}`; - // console.log(threadId, postId, userId, likeCount, userName, likesList); + const likesList = likeButton.dataset.likesList; + const likeCount = likeButton.dataset.count; + + console.log(threadId, postId, userId, likeCount, userName, likesList); const likesListArray = likesList.split("/"); @@ -23,18 +41,25 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { removeLike(threadId, postId, userId).then((res) => { if (res.ok) { const newLikeCount = Number(likeCount) - 1; - const newLikesString = likesListArray.filter(e => e !== userName).join('/'); + const newLikesString = likesListArray.filter(e => e !== nameAndId).join('/'); + + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.remove("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; + + let whoLikedArray = []; + const newLikesArray = newLikesString.split("/"); + for (let i = 0; i < newLikesArray.length; i++) { + const nameArray = newLikesArray[i].split('#') + const userName = nameArray[0]; + const userId = nameArray[1]; + const userProfileUrl = `/members/${userId}/profile`; - // Create ELEMENT - const element = document.createElement('span'); - element.classList.add("elementToPopup"); - element.innerHTML = newLikesString.split("/").join("
      "); + whoLikedArray.push(`${userName}`); + } - likeButton[i].dataset.count = `${newLikeCount}`; - likeButton[i].innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; - likeButton[i].appendChild(element); - likeButton[i].classList.remove("userLiked"); - likeButton[i].dataset.likesList = newLikesString; + whoLikedPostDiv.innerHTML = "
      " + whoLikedArray.join(', ') + "
      "; console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } @@ -43,18 +68,25 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { addLike(threadId, postId, userId).then((res) => { if (res.ok) { const newLikeCount = Number(likeCount) + 1; - const newLikesString = [...likesListArray, userName].join('/'); + const newLikesString = [...likesListArray, nameAndId].join('/'); - // Create ELEMENT - const element = document.createElement('span'); - element.classList.add("elementToPopup"); - element.innerHTML = newLikesString.split("/").join("
      "); + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.add("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = `Like (${newLikeCount})`; - likeButton[i].dataset.count = `${newLikeCount}`; - likeButton[i].innerHTML = `Like (${newLikeCount})`; - likeButton[i].appendChild(element); - likeButton[i].classList.add("userLiked"); - likeButton[i].dataset.likesList = newLikesString; + let whoLikedArray = []; + const newLikesArray = newLikesString.split("/"); + for (let i = 0; i < newLikesArray.length; i++) { + const nameArray = newLikesArray[i].split('#') + const userName = nameArray[0]; + const userId = nameArray[1]; + const userProfileUrl = `/members/${userId}/profile`; + + whoLikedArray.push(`${userName}`); + } + + whoLikedPostDiv.innerHTML = "
      " + whoLikedArray.join(', ') + "
      "; console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } @@ -63,17 +95,6 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { return false; }; - - // Hover over and mouse leave - likeButton[i].onmouseover = (e) => { - if (likeButton[i].dataset.count > 0) { - likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; - } - }; - - likeButton[i].onmouseleave = (e) => { - likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'none'; - }; } } }); diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index 17f54a09b64..7bc2d0f9776 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -21,7 +21,7 @@ $userLikesComment = true; } - $userNameLikesArray .= "/" . ($likeObj->userName); + $userNameLikesArray .= "/" . ($likeObj->userName) . "#" . ($likeObj->userId); } $userNameLikesArray = substr($userNameLikesArray,1); @@ -73,24 +73,40 @@
      - - +
      + +
      +
      ",$nameArray); + $links = array(); + foreach ($nameArray as $nameString) { + $nameArray = explode("#", $nameString); + $userName = $nameArray[0]; + $userId = $nameArray[1]; + $userProfileUrl = "/members/$userId/profile"; + + $links[] = "$userName"; + } + echo join(", ", $links); ?> - - -
      +
      +
      +
      @@ -257,7 +273,6 @@ ->set('controller', $this->controller) ->set('comments', $this->comment->get('replies')) ->set('thread', $this->thread) - ->set('likes', $this->likes) ->set('parent', $this->comment->get('id')) ->set('config', $this->config) ->set('depth', $this->depth) From 17ab68c3b84b30b8252e31607df0227bab5f5808 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Wed, 25 Sep 2024 14:33:03 -0700 Subject: [PATCH 16/23] added in text --- core/components/com_forum/site/assets/css/like.css | 6 ++++++ core/components/com_forum/site/assets/js/like.js | 11 ++++------- .../com_forum/site/views/threads/tmpl/_comment.php | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/components/com_forum/site/assets/css/like.css b/core/components/com_forum/site/assets/css/like.css index e0c9c520d00..67051a567ba 100644 --- a/core/components/com_forum/site/assets/css/like.css +++ b/core/components/com_forum/site/assets/css/like.css @@ -15,6 +15,12 @@ margin-top: 5px; } +.comment-body .likesStat:hover { + cursor: pointer; + color: black; + text-decoration: underline; +} + .elementInline { display: inline-flex; float: right; diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index fb56d94947f..091c44cd297 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -1,17 +1,14 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { - // Find all the "like" button - const commentSections = document.querySelectorAll('.comment-body') + // Find all the "like" / stat button + const commentSections = document.querySelectorAll('.comment-content') if (commentSections.length) { for(let i = 0; i < commentSections.length;i++) { let likeButton = commentSections[i].querySelector('.like'); let likeStatsLink = commentSections[i].querySelector('.likesStat'); let whoLikedPostDiv = commentSections[i].querySelector('.whoLikedPost'); - console.log(whoLikedPostDiv.scrollHeight); - likeStatsLink.onclick = (e) => { this.__toggle = !this.__toggle; - console.log(this.__toggle) if(this.__toggle) { whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; } else { @@ -59,7 +56,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedArray.push(`${userName}`); } - whoLikedPostDiv.innerHTML = "
      " + whoLikedArray.join(', ') + "
      "; + whoLikedPostDiv.innerHTML = "
      " + whoLikedArray.join(', ') + " liked this
      "; console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } @@ -86,7 +83,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedArray.push(`${userName}`); } - whoLikedPostDiv.innerHTML = "
      " + whoLikedArray.join(', ') + "
      "; + whoLikedPostDiv.innerHTML = "
      " + whoLikedArray.join(', ') + " liked this
      "; console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index 7bc2d0f9776..586145ef4e5 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -102,7 +102,7 @@ $links[] = "$userName"; } - echo join(", ", $links); + echo join(", ", $links) . " liked this"; ?>
    From adae70e46404cc8cea205842279906a33a1b89ff Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Wed, 25 Sep 2024 15:56:56 -0700 Subject: [PATCH 17/23] likes changed in groups --- .../com_forum/site/assets/js/like.js | 26 ++-- .../site/views/threads/tmpl/_comment.php | 30 ++--- core/plugins/groups/forum/assets/css/like.css | 41 ++++--- core/plugins/groups/forum/assets/js/like.js | 114 +++++++++++------- .../forum/views/threads/tmpl/_comment.php | 93 ++++++++------ 5 files changed, 183 insertions(+), 121 deletions(-) diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 091c44cd297..1334a4d0d14 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -45,19 +45,23 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { likeButton.dataset.likesList = newLikesString; likeStatsLink.innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; - let whoLikedArray = []; - const newLikesArray = newLikesString.split("/"); - for (let i = 0; i < newLikesArray.length; i++) { - const nameArray = newLikesArray[i].split('#') - const userName = nameArray[0]; - const userId = nameArray[1]; - const userProfileUrl = `/members/${userId}/profile`; - - whoLikedArray.push(`${userName}`); + if (newLikeCount > 0) { + let whoLikedArray = []; + const newLikesArray = newLikesString.split("/"); + for (let i = 0; i < newLikesArray.length; i++) { + const nameArray = newLikesArray[i].split('#') + const userName = nameArray[0]; + const userId = nameArray[1]; + const userProfileUrl = `/members/${userId}/profile`; + + whoLikedArray.push(`${userName}`); + } + + whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; + } else { + whoLikedPostDiv.innerHTML = ""; } - whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; - console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } }) diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index 586145ef4e5..60feb6fc794 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -90,21 +90,23 @@
    -
    - 0) { ?> +
    + $userName"; - } - echo join(", ", $links) . " liked this"; - ?> -
    + $links[] = "$userName"; + } + echo join(", ", $links) . " liked this"; + ?> +
    +
    diff --git a/core/plugins/groups/forum/assets/css/like.css b/core/plugins/groups/forum/assets/css/like.css index 10592a9eadc..67051a567ba 100644 --- a/core/plugins/groups/forum/assets/css/like.css +++ b/core/plugins/groups/forum/assets/css/like.css @@ -1,29 +1,42 @@ /* Should put this in the comments.less file */ .comment-body a.like { - float: right; color: gray; - margin-bottom: 10px; + margin-right: 5px; + font-size:20px; } .comment-body a.userLiked { color: red; } -.elementToHover { - display: inline-block; - position: relative; +.comment-body .likesStat { + font-size: 14px; + vertical-align:middle; + margin-top: 5px; +} + +.comment-body .likesStat:hover { + cursor: pointer; + color: black; + text-decoration: underline; +} + +.elementInline { + display: inline-flex; + float: right; + vertical-align:middle; +} + +.whoLikedPost { + height: 0; + overflow: hidden; + transition: height 0.8s ease; } -.elementToPopup { - display: none; - position: absolute; - top: 30px; - left: -80px; - background-color: #555; - color: #fff; +.names { padding: 10px; + background-color: #eeeeee; border-radius: 5px; - z-index: 1; - width: 151px; text-align: right; + font-size: 12px; } \ No newline at end of file diff --git a/core/plugins/groups/forum/assets/js/like.js b/core/plugins/groups/forum/assets/js/like.js index 0ea5dbed53e..1334a4d0d14 100644 --- a/core/plugins/groups/forum/assets/js/like.js +++ b/core/plugins/groups/forum/assets/js/like.js @@ -1,19 +1,36 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { - // Find all the "like" button - const likeButton = document.querySelectorAll('.comment-body .like') - if (likeButton.length) { - for(let i = 0; i < likeButton.length;i++) { - likeButton[i].onclick = (e) => { + // Find all the "like" / stat button + const commentSections = document.querySelectorAll('.comment-content') + if (commentSections.length) { + for(let i = 0; i < commentSections.length;i++) { + let likeButton = commentSections[i].querySelector('.like'); + let likeStatsLink = commentSections[i].querySelector('.likesStat'); + let whoLikedPostDiv = commentSections[i].querySelector('.whoLikedPost'); + + likeStatsLink.onclick = (e) => { + this.__toggle = !this.__toggle; + if(this.__toggle) { + whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; + } else { + whoLikedPostDiv.style.height = 0; + } + } + + likeButton.onclick = (e) => { e.preventDefault(); - let hasHeart = likeButton[i].classList.contains("userLiked"); + let hasHeart = likeButton.classList.contains("userLiked"); + + const threadId = likeButton.dataset.thread; + const postId = likeButton.dataset.post; + const userId = likeButton.dataset.user; + const userName = likeButton.dataset.userName; + const nameAndId = `${userName}#${userId}`; - const threadId = likeButton[i].dataset.thread; - const postId = likeButton[i].dataset.post; - const userId = likeButton[i].dataset.user; - const userName = likeButton[i].dataset.userName; - const likesList = likeButton[i].dataset.likesList; - const likeCount = likeButton[i].dataset.count; + const likesList = likeButton.dataset.likesList; + const likeCount = likeButton.dataset.count; + + console.log(threadId, postId, userId, likeCount, userName, likesList); const likesListArray = likesList.split("/"); @@ -21,18 +38,29 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { removeLike(threadId, postId, userId).then((res) => { if (res.ok) { const newLikeCount = Number(likeCount) - 1; - const newLikesString = likesListArray.filter(e => e !== userName).join('/'); - - // Create ELEMENT - const element = document.createElement('span'); - element.classList.add("elementToPopup"); - element.innerHTML = newLikesString.split("/").join("
    "); - - likeButton[i].dataset.count = `${newLikeCount}`; - likeButton[i].innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; - likeButton[i].appendChild(element); - likeButton[i].classList.remove("userLiked"); - likeButton[i].dataset.likesList = newLikesString; + const newLikesString = likesListArray.filter(e => e !== nameAndId).join('/'); + + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.remove("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; + + if (newLikeCount > 0) { + let whoLikedArray = []; + const newLikesArray = newLikesString.split("/"); + for (let i = 0; i < newLikesArray.length; i++) { + const nameArray = newLikesArray[i].split('#') + const userName = nameArray[0]; + const userId = nameArray[1]; + const userProfileUrl = `/members/${userId}/profile`; + + whoLikedArray.push(`${userName}`); + } + + whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; + } else { + whoLikedPostDiv.innerHTML = ""; + } console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } @@ -41,18 +69,25 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { addLike(threadId, postId, userId).then((res) => { if (res.ok) { const newLikeCount = Number(likeCount) + 1; - const newLikesString = [...likesListArray, userName].join('/'); + const newLikesString = [...likesListArray, nameAndId].join('/'); - // Create ELEMENT - const element = document.createElement('span'); - element.classList.add("elementToPopup"); - element.innerHTML = newLikesString.split("/").join("
    "); + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.add("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = `Like (${newLikeCount})`; - likeButton[i].dataset.count = `${newLikeCount}`; - likeButton[i].innerHTML = `Like (${newLikeCount})`; - likeButton[i].appendChild(element); - likeButton[i].classList.add("userLiked"); - likeButton[i].dataset.likesList = newLikesString; + let whoLikedArray = []; + const newLikesArray = newLikesString.split("/"); + for (let i = 0; i < newLikesArray.length; i++) { + const nameArray = newLikesArray[i].split('#') + const userName = nameArray[0]; + const userId = nameArray[1]; + const userProfileUrl = `/members/${userId}/profile`; + + whoLikedArray.push(`${userName}`); + } + + whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } @@ -61,17 +96,6 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { return false; }; - - // Hover over and mouse leave - likeButton[i].onmouseover = (e) => { - if (likeButton[i].dataset.count > 0) { - likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'block'; - } - }; - - likeButton[i].onmouseleave = (e) => { - likeButton[i].getElementsByClassName('elementToPopup')[0].style.display = 'none'; - }; } } }); diff --git a/core/plugins/groups/forum/views/threads/tmpl/_comment.php b/core/plugins/groups/forum/views/threads/tmpl/_comment.php index 4150829a90d..a3e33f1d097 100644 --- a/core/plugins/groups/forum/views/threads/tmpl/_comment.php +++ b/core/plugins/groups/forum/views/threads/tmpl/_comment.php @@ -8,24 +8,24 @@ defined('_HZEXEC_') or die(); $this->css('like.css') - ->js('like.js'); + ->js('like.js'); - $likeArray = $this->like; - $countLike = count($likeArray); - $currentUserId = User::get('id'); + $likeArray = $this->like; + $countLike = count($likeArray); + $currentUserId = User::get('id'); - $userLikesComment = false; - $userNameLikesArray = ""; - foreach ( $likeArray as $likeObj ) { - if ( $currentUserId == $likeObj->userId ) { - $userLikesComment = true; - } + $userLikesComment = false; + $userNameLikesArray = ""; + foreach ( $likeArray as $likeObj ) { + if ( $currentUserId == $likeObj->userId ) { + $userLikesComment = true; + } - $userNameLikesArray .= "/" . ($likeObj->userName); - } - $userNameLikesArray = substr($userNameLikesArray,1); + $userNameLikesArray .= "/" . ($likeObj->userName) . "#" . ($likeObj->userId); + } + $userNameLikesArray = substr($userNameLikesArray,1); - $this->comment->set('section', $this->filters['section']); + $this->comment->set('section', $this->filters['section']); $this->comment->set('category', $this->category->get('alias')); $this->config->set('access-edit-post', false); @@ -79,25 +79,43 @@ + +
    + 0) { ?> +
    + $userName"; + } + echo join(", ", $links) . " liked this"; + ?> +
    + +
    + +
    comment->attachments()->whereEquals('state', Components\Forum\Models\Attachment::STATE_PUBLISHED)->rows() as $attachment) @@ -187,7 +205,7 @@ thread->get('closed') && $this->config->get('threading') == 'tree' && $this->depth < $this->config->get('threading_depth', 3)) { ?>
    -
    +
    comment->get('anonymous') ? $name : Lang::txt('JANONYMOUS'))); ?> @@ -212,10 +230,11 @@
    -
    @@ -254,8 +273,8 @@ ->set('option', $this->option) ->set('group', $this->group) ->set('comments', $this->comment->get('replies')) - ->set('thread', $this->thread) - ->set('likes', $this->likes) + ->set('thread', $this->thread) + ->set('likes', $this->likes) ->set('parent', $this->comment->get('id')) ->set('config', $this->config) ->set('depth', $this->depth) From 9d5fe433766ce78c409dc97cd357b569e2c4e4e1 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Fri, 27 Sep 2024 12:53:21 -0700 Subject: [PATCH 18/23] won't redirect users --- core/components/com_forum/config/access.xml | 1 - core/components/com_forum/site/forum.php | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/core/components/com_forum/config/access.xml b/core/components/com_forum/config/access.xml index b8661ea060c..91a57815e67 100644 --- a/core/components/com_forum/config/access.xml +++ b/core/components/com_forum/config/access.xml @@ -8,7 +8,6 @@
    - diff --git a/core/components/com_forum/site/forum.php b/core/components/com_forum/site/forum.php index 0cb09607abc..a0577d99fe2 100644 --- a/core/components/com_forum/site/forum.php +++ b/core/components/com_forum/site/forum.php @@ -17,16 +17,6 @@ require_once __DIR__ . DS . 'controllers' . DS . $controllerName . '.php'; $controllerName = __NAMESPACE__ . '\\Controllers\\' . ucfirst(strtolower($controllerName)); -if (!User::authorise('core.access', 'com_forum')) -{ - $return = base64_encode(Request::getString('REQUEST_URI', '', 'server')); - //$return = base64_encode($_SERVER['REQUEST_URI']); - App::redirect( Route::url('index.php?option=com_users&view=login&return=' . $return, false), - "Please Log in and then we will redirect you to the forum pages", - 'warning' - ); -} - // Instantiate controller $controller = new $controllerName(); $controller->execute(); From 7419fbb3ab94fd0217d6c808442fd7cac567cd1d Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Thu, 31 Oct 2024 11:05:49 -0700 Subject: [PATCH 19/23] component and plugin updates --- .../com_forum/site/assets/css/like.css | 20 ++++++++++++++++++- .../com_forum/site/assets/js/like.js | 9 ++++++--- .../site/views/threads/tmpl/_comment.php | 6 +++--- core/plugins/groups/forum/assets/css/like.css | 20 ++++++++++++++++++- core/plugins/groups/forum/assets/js/like.js | 9 ++++++--- .../forum/views/threads/tmpl/_comment.php | 4 ++-- 6 files changed, 55 insertions(+), 13 deletions(-) diff --git a/core/components/com_forum/site/assets/css/like.css b/core/components/com_forum/site/assets/css/like.css index 67051a567ba..38910761dee 100644 --- a/core/components/com_forum/site/assets/css/like.css +++ b/core/components/com_forum/site/assets/css/like.css @@ -1,18 +1,31 @@ /* Should put this in the comments.less file */ .comment-body a.like { - color: gray; + color: #dadada; margin-right: 5px; font-size:20px; } +.comment-body a.like:hover { + color: #a6a6a6; +} + .comment-body a.userLiked { color: red; } +.comment-body a.userLiked:hover { + color: #ce0202; +} + .comment-body .likesStat { font-size: 14px; vertical-align:middle; margin-top: 5px; + text-decoration: underline; +} + +.comment-body .noLikes { + text-decoration: none; } .comment-body .likesStat:hover { @@ -21,6 +34,11 @@ text-decoration: underline; } +.comment-body .noLikes:hover { + cursor: auto; + text-decoration: none; +} + .elementInline { display: inline-flex; float: right; diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 1334a4d0d14..13c98c5e61d 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -43,7 +43,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { likeButton.dataset.count = `${newLikeCount}`; likeButton.classList.remove("userLiked"); likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; + likeStatsLink.innerHTML = (newLikeCount === 0) ? 'No Likes' : `View Likes (${newLikeCount})`; if (newLikeCount > 0) { let whoLikedArray = []; @@ -57,8 +57,10 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedArray.push(`${userName}`); } + likeStatsLink.classList.remove("noLikes"); whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; } else { + likeStatsLink.classList.add("noLikes"); whoLikedPostDiv.innerHTML = ""; } @@ -69,12 +71,13 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { addLike(threadId, postId, userId).then((res) => { if (res.ok) { const newLikeCount = Number(likeCount) + 1; - const newLikesString = [...likesListArray, nameAndId].join('/'); + const newLikesString = [...likesListArray, nameAndId].filter(Boolean).join('/'); likeButton.dataset.count = `${newLikeCount}`; likeButton.classList.add("userLiked"); likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = `Like (${newLikeCount})`; + likeStatsLink.innerHTML = `View Likes (${newLikeCount})`; + likeStatsLink.classList.remove("noLikes"); let whoLikedArray = []; const newLikesArray = newLikesString.split("/"); diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index 60feb6fc794..23c6076d46c 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -83,14 +83,14 @@ data-likes-list="" data-count="" > - - 0) ? "Like (" . $countLike . ")" : "Like"; ?> + "> + 0) ? "View Likes (" . $countLike . ")" : "No Likes"; ?>
    - 0) { ?> + 0) { ?>
    { likeButton.dataset.count = `${newLikeCount}`; likeButton.classList.remove("userLiked"); likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = (newLikeCount === 0) ? 'Like' : `Like (${newLikeCount})`; + likeStatsLink.innerHTML = (newLikeCount === 0) ? 'No Likes' : `View Likes (${newLikeCount})`; if (newLikeCount > 0) { let whoLikedArray = []; @@ -57,8 +57,10 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedArray.push(`${userName}`); } + likeStatsLink.classList.remove("noLikes"); whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; } else { + likeStatsLink.classList.add("noLikes"); whoLikedPostDiv.innerHTML = ""; } @@ -69,12 +71,13 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { addLike(threadId, postId, userId).then((res) => { if (res.ok) { const newLikeCount = Number(likeCount) + 1; - const newLikesString = [...likesListArray, nameAndId].join('/'); + const newLikesString = [...likesListArray, nameAndId].filter(Boolean).join('/'); likeButton.dataset.count = `${newLikeCount}`; likeButton.classList.add("userLiked"); likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = `Like (${newLikeCount})`; + likeStatsLink.innerHTML = `View Likes (${newLikeCount})`; + likeStatsLink.classList.remove("noLikes"); let whoLikedArray = []; const newLikesArray = newLikesString.split("/"); diff --git a/core/plugins/groups/forum/views/threads/tmpl/_comment.php b/core/plugins/groups/forum/views/threads/tmpl/_comment.php index a3e33f1d097..7b347c1f925 100644 --- a/core/plugins/groups/forum/views/threads/tmpl/_comment.php +++ b/core/plugins/groups/forum/views/threads/tmpl/_comment.php @@ -89,8 +89,8 @@ data-likes-list="" data-count="" > - - 0) ? "Like (" . $countLike . ")" : "Like"; ?> + "> + 0) ? "View Likes (" . $countLike . ")" : "No Likes"; ?>
    From 64ff21538abdbee6fa8a1466e971cf7e8f44afcb Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Tue, 5 Nov 2024 14:29:23 -0800 Subject: [PATCH 20/23] e prevent default --- core/components/com_forum/site/assets/js/like.js | 1 + core/plugins/groups/forum/assets/js/like.js | 1 + 2 files changed, 2 insertions(+) diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 13c98c5e61d..9b821a2b447 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -8,6 +8,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { let whoLikedPostDiv = commentSections[i].querySelector('.whoLikedPost'); likeStatsLink.onclick = (e) => { + e.preventDefault(); this.__toggle = !this.__toggle; if(this.__toggle) { whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; diff --git a/core/plugins/groups/forum/assets/js/like.js b/core/plugins/groups/forum/assets/js/like.js index 13c98c5e61d..9b821a2b447 100644 --- a/core/plugins/groups/forum/assets/js/like.js +++ b/core/plugins/groups/forum/assets/js/like.js @@ -8,6 +8,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { let whoLikedPostDiv = commentSections[i].querySelector('.whoLikedPost'); likeStatsLink.onclick = (e) => { + e.preventDefault(); this.__toggle = !this.__toggle; if(this.__toggle) { whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; From f842415db4d5e8128331f005e0a8de37669921e7 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Tue, 5 Nov 2024 14:32:12 -0800 Subject: [PATCH 21/23] comment out comments --- core/components/com_forum/site/assets/js/like.js | 6 +++--- core/plugins/groups/forum/assets/js/like.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 9b821a2b447..73078483b8f 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -31,7 +31,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const likesList = likeButton.dataset.likesList; const likeCount = likeButton.dataset.count; - console.log(threadId, postId, userId, likeCount, userName, likesList); + // console.log(threadId, postId, userId, likeCount, userName, likesList); const likesListArray = likesList.split("/"); @@ -65,7 +65,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedPostDiv.innerHTML = ""; } - console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + // console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } }) } else { @@ -93,7 +93,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; - console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + // console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } }) } diff --git a/core/plugins/groups/forum/assets/js/like.js b/core/plugins/groups/forum/assets/js/like.js index 9b821a2b447..73078483b8f 100644 --- a/core/plugins/groups/forum/assets/js/like.js +++ b/core/plugins/groups/forum/assets/js/like.js @@ -31,7 +31,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const likesList = likeButton.dataset.likesList; const likeCount = likeButton.dataset.count; - console.log(threadId, postId, userId, likeCount, userName, likesList); + // console.log(threadId, postId, userId, likeCount, userName, likesList); const likesListArray = likesList.split("/"); @@ -65,7 +65,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedPostDiv.innerHTML = ""; } - console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + // console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } }) } else { @@ -93,7 +93,7 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; - console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + // console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } }) } From 6da606ba84d6dfcd32006354d2819bbf1e73f2cf Mon Sep 17 00:00:00 2001 From: HUBzero Admin System User Date: Wed, 6 Nov 2024 12:50:56 -0800 Subject: [PATCH 22/23] in place changes made on stage added to this branch so they are not lost - commit by drb logged in as hubadmin --- core/components/com_forum/config/access.xml | 3 ++- core/components/com_forum/site/forum.php | 10 ++++++++++ .../admin/language/en-GB/en-GB.com_groups.ini | 9 +++++++-- .../com_groups/admin/views/manage/tmpl/edit.php | 4 ++-- core/components/com_groups/config/config.xml | 6 +++++- .../com_groups/site/views/emails/tmpl/saved.php | 2 +- .../site/views/emails/tmpl/saved_plain.php | 2 +- .../com_groups/site/views/groups/tmpl/edit.php | 4 ++-- .../com_members/site/controllers/profiles.php | 2 +- .../site/views/profiles/tmpl/browse.php | 2 +- core/plugins/groups/forum/forum.php | 15 ++++++++++++--- .../language/en-GB/en-GB.plg_groups_forum.ini | 2 +- .../forum/views/email/tmpl/comment_html.php | 5 ++++- .../forum/views/email/tmpl/comment_plain.php | 5 ++++- .../forum/views/shared/tmpl/_email_settings.php | 2 +- .../en-GB/en-GB.plg_groups_memberoptions.ini | 2 +- .../memberoptions/views/browse/tmpl/default.php | 6 +++--- 17 files changed, 58 insertions(+), 23 deletions(-) diff --git a/core/components/com_forum/config/access.xml b/core/components/com_forum/config/access.xml index 91a57815e67..1db40b120da 100644 --- a/core/components/com_forum/config/access.xml +++ b/core/components/com_forum/config/access.xml @@ -8,6 +8,7 @@
    + @@ -68,4 +69,4 @@
    -
    \ No newline at end of file + diff --git a/core/components/com_forum/site/forum.php b/core/components/com_forum/site/forum.php index a0577d99fe2..5032dd13239 100644 --- a/core/components/com_forum/site/forum.php +++ b/core/components/com_forum/site/forum.php @@ -17,6 +17,16 @@ require_once __DIR__ . DS . 'controllers' . DS . $controllerName . '.php'; $controllerName = __NAMESPACE__ . '\\Controllers\\' . ucfirst(strtolower($controllerName)); +if (!User::authorise('core.access', 'com_forum')) +{ + $return = base64_encode(Request::getString('REQUEST_URI', '', 'server')); + //$return = base64_encode($_SERVER['REQUEST_URI']); + App::redirect( Route::url('index.php?option=com_users&view=login&return=' . $return, false), + Lang::txt('COM_FORUM_ALERTLOGIN_REQUIRED'), + 'warning' + ); +} + // Instantiate controller $controller = new $controllerName(); $controller->execute(); diff --git a/core/components/com_groups/admin/language/en-GB/en-GB.com_groups.ini b/core/components/com_groups/admin/language/en-GB/en-GB.com_groups.ini index 6763e189af0..ce4449036f0 100644 --- a/core/components/com_groups/admin/language/en-GB/en-GB.com_groups.ini +++ b/core/components/com_groups/admin/language/en-GB/en-GB.com_groups.ini @@ -548,8 +548,13 @@ COM_GROUPS_CONFIG_DEFAULT_DISCOVERABILITY_VISIBLE="Visible" COM_GROUPS_CONFIG_DEFAULT_DISCOVERABILITY_HIDDEN="Hidden" COM_GROUPS_CONFIG_DISPLAY_SYSTEM_USERS="Display System Users?" COM_GROUPS_CONFIG_DISPLAY_SYSTEM_USERS_DESC="Display system users in group member lists?" -COM_GROUPS_CONFIG_EMAIL_PROCESSING="Enable discussion comments via E-mail" -COM_GROUPS_CONFIG_EMAIL_PROCESSING_DESC="Enable logic to send group discussion comments via email and process and add responses via email" + +COM_GROUPS_CONFIG_FORUM_OUTGOING_EMAIL="Allow outgoing email notifications to users for forum posts" +COM_GROUPS_CONFIG_FORUM_OUTGOING_EMAIL_DESC="Allow notification of individual users of forum posts via email" + +COM_GROUPS_CONFIG_INCOMING_EMAIL_PROCESSING="Enable incoming user discussion comments via email" +COM_GROUPS_CONFIG_INCOMING_EMAIL_PROCESSING_DESC="Allow user comments sent via email to be added to group forum posts" + COM_GROUPS_CONFIG_EMAIL_PROCESSING_AUTOSUBSCRIBE="Enable groups to auto setup new members to receive discussion email by default" COM_GROUPS_CONFIG_EMAIL_PROCESSING_AUTOSUBSCRIBE_DESC="Automatically setup new group users to get email from the group discussions" COM_GROUPS_CONFIG_EMAIL_FORUM_DIGEST="Allow forum digest?" diff --git a/core/components/com_groups/admin/views/manage/tmpl/edit.php b/core/components/com_groups/admin/views/manage/tmpl/edit.php index d5d1bcef849..23f26aaaf60 100644 --- a/core/components/com_groups/admin/views/manage/tmpl/edit.php +++ b/core/components/com_groups/admin/views/manage/tmpl/edit.php @@ -27,7 +27,7 @@ // are we using the email gateway for group forum $params = Component::params('com_groups'); -$allowEmailResponses = $params->get('email_comment_processing', 0); +$emailForumComments = $params->get('email_forum_comments', 0); $autoEmailResponses = $this->group->get('discussion_email_autosubscribe'); if (is_null($autoEmailResponses)) @@ -300,7 +300,7 @@
    - +
    diff --git a/core/components/com_groups/config/config.xml b/core/components/com_groups/config/config.xml index 84b68322f9e..12c02c6c650 100644 --- a/core/components/com_groups/config/config.xml +++ b/core/components/com_groups/config/config.xml @@ -53,7 +53,11 @@
    - + + + + + diff --git a/core/components/com_groups/site/views/emails/tmpl/saved.php b/core/components/com_groups/site/views/emails/tmpl/saved.php index d2e3848797f..be42b34b4b4 100644 --- a/core/components/com_groups/site/views/emails/tmpl/saved.php +++ b/core/components/com_groups/site/views/emails/tmpl/saved.php @@ -326,7 +326,7 @@ - get('email_comment_processing')) :?> + get('email_forum_comments')) :?> diff --git a/core/components/com_groups/site/views/emails/tmpl/saved_plain.php b/core/components/com_groups/site/views/emails/tmpl/saved_plain.php index 096f38201e6..94e07814000 100644 --- a/core/components/com_groups/site/views/emails/tmpl/saved_plain.php +++ b/core/components/com_groups/site/views/emails/tmpl/saved_plain.php @@ -93,7 +93,7 @@ $message .= "\n"; $params = Component::params('com_groups'); -if ($params->get('email_comment_processing')) +if ($params->get('email_forum_comments')) { $message .= "\t" . Lang::txt('Discussion Group Emails Autosubscribe:') . ' ' . ($this->group->get('discussion_email_autosubscribe') ? Lang::txt('On') : Lang::txt('Off')) . "\n\n"; } diff --git a/core/components/com_groups/site/views/groups/tmpl/edit.php b/core/components/com_groups/site/views/groups/tmpl/edit.php index 8f067c9bfaa..d9702fdb486 100644 --- a/core/components/com_groups/site/views/groups/tmpl/edit.php +++ b/core/components/com_groups/site/views/groups/tmpl/edit.php @@ -17,7 +17,7 @@ //are we using the email gateway for group forum $params = Component::params('com_groups'); -$allowEmailResponses = $params->get('email_comment_processing', 0); +$emailForumComments = $params->get('email_forum_comments', 0); $autoEmailResponses = $params->get('email_member_groupsidcussionemail_autosignup', 0); //default logo @@ -263,7 +263,7 @@
    - +

    diff --git a/core/components/com_members/site/controllers/profiles.php b/core/components/com_members/site/controllers/profiles.php index 60b7601360e..01cec291194 100644 --- a/core/components/com_members/site/controllers/profiles.php +++ b/core/components/com_members/site/controllers/profiles.php @@ -271,7 +271,7 @@ public function displayTask() * @return void */ public function browseTask() - { + { // Get all the fields we can use on this page $fields = Field::all() ->whereIn('action_browse', User::getAuthorisedViewLevels()) diff --git a/core/components/com_members/site/views/profiles/tmpl/browse.php b/core/components/com_members/site/views/profiles/tmpl/browse.php index b13c372f61b..2d15f9705f3 100644 --- a/core/components/com_members/site/views/profiles/tmpl/browse.php +++ b/core/components/com_members/site/views/profiles/tmpl/browse.php @@ -237,7 +237,7 @@
    -
    +
    rows->count() > 0) diff --git a/core/plugins/groups/forum/forum.php b/core/plugins/groups/forum/forum.php index 3642e7c0d84..47489389628 100644 --- a/core/plugins/groups/forum/forum.php +++ b/core/plugins/groups/forum/forum.php @@ -1515,7 +1515,7 @@ public function savethread() // Email the group and insert email tokens to allow them to respond to group posts via email $params = Component::params('com_groups'); - if ($params->get('email_comment_processing') && (isset($moving) && $moving == false)) + if ($params->get('email_forum_comments') && (isset($moving) && $moving == false)) { $thread->set('section', $section->get('alias')); $thread->set('category', $category->get('alias')); @@ -1562,8 +1562,17 @@ public function savethread() $unsubscribeToken = $encryptor->buildEmailToken(1, 3, $userID, $this->group->get('gidNumber')); $unsubscribeLink = rtrim(Request::base(), '/') . '/' . ltrim(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') .'&active=forum&action=unsubscribe&t=' . $unsubscribeToken), DS); - $from['replytoname'] = Lang::txt('PLG_GROUPS_FORUM_REPLYTO') . ' @ ' . Config::get('sitename'); - $from['replytoemail'] = 'hgm-' . $token . '@' . $_SERVER['HTTP_HOST']; + + if(Component::params('com_groups')->get('email_comment_processing')) + { + $from['replytoname'] = Lang::txt('PLG_GROUPS_FORUM_REPLYTO') . ' @ ' . Config::get('sitename'); + $from['replytoemail'] = 'hgm-' . $token . '@' . $_SERVER['HTTP_HOST']; + } + else + { + $from['replytoname'] = 'noreply'; + $from['replytoemail'] = 'noreply@' . $_SERVER['HTTP_HOST']; + } } $msg = array(); diff --git a/core/plugins/groups/forum/language/en-GB/en-GB.plg_groups_forum.ini b/core/plugins/groups/forum/language/en-GB/en-GB.plg_groups_forum.ini index 978b1cf6ec8..00ac5450a32 100644 --- a/core/plugins/groups/forum/language/en-GB/en-GB.plg_groups_forum.ini +++ b/core/plugins/groups/forum/language/en-GB/en-GB.plg_groups_forum.ini @@ -72,7 +72,7 @@ PLG_GROUPS_FORUM_EMAIL_POSTS_DIGEST="digest email" PLG_GROUPS_FORUM_EMAIL_POSTS_DAILY="Daily" PLG_GROUPS_FORUM_EMAIL_POSTS_WEEKLY="Weekly" PLG_GROUPS_FORUM_EMAIL_POSTS_MONTHLY="Monthly" -PLG_GROUPS_FORUM_EMAIL_POSTS="Email forum posts" +PLG_GROUPS_FORUM_EMAIL_POSTS="Email forum post notifications" PLG_GROUPS_FORUM_EMAIL_CATEGORIES="Posts to:" PLG_GROUPS_FORUM_BY_USER="by %s" PLG_GROUPS_FORUM_REPORT_ABUSE="Report abuse" diff --git a/core/plugins/groups/forum/views/email/tmpl/comment_html.php b/core/plugins/groups/forum/views/email/tmpl/comment_html.php index 446a00dc324..f7daca082f0 100644 --- a/core/plugins/groups/forum/views/email/tmpl/comment_html.php +++ b/core/plugins/groups/forum/views/email/tmpl/comment_html.php @@ -15,7 +15,8 @@ $bgcolor = '#f1f1f1'; $bdcolor = '#e1e1e1'; ?> -delimiter) { ?> +delimiter) { + if(Component::params('com_groups')->get('email_comment_processing')) { ?> @@ -27,6 +28,8 @@
    + + diff --git a/core/plugins/groups/forum/views/email/tmpl/comment_plain.php b/core/plugins/groups/forum/views/email/tmpl/comment_plain.php index c50642a2048..0d3eb80e011 100644 --- a/core/plugins/groups/forum/views/email/tmpl/comment_plain.php +++ b/core/plugins/groups/forum/views/email/tmpl/comment_plain.php @@ -17,7 +17,10 @@ if ($this->delimiter) { $message .= $this->delimiter . "\n"; - $message .= Lang::txt('PLG_GROUPS_FORUM_EMAIL_REPLY_ABOVE') . "\n"; + + if(Component::params('com_groups')->get('email_comment_processing')) + $message .= Lang::txt('PLG_GROUPS_FORUM_EMAIL_REPLY_ABOVE') . "\n"; + $message .= 'Message from ' . $base . ' / ' . Lang::txt('PLG_GROUPS_FORUM_DETAILS_THREAD', $this->thread->get('id')) . "\n"; } $message .= ($this->post->get('anonymous')) ? Lang::txt('JANONYMOUS') : $this->post->creator->get('name') . ' (' . $this->post->creator->get('username') . ')'; diff --git a/core/plugins/groups/forum/views/shared/tmpl/_email_settings.php b/core/plugins/groups/forum/views/shared/tmpl/_email_settings.php index b750cddc9ab..9327e31b269 100644 --- a/core/plugins/groups/forum/views/shared/tmpl/_email_settings.php +++ b/core/plugins/groups/forum/views/shared/tmpl/_email_settings.php @@ -7,7 +7,7 @@ $base = $this->base; -if (Component::params('com_groups')->get('email_comment_processing') && $this->config->get('access-view-section')) : ?> +if (Component::params('com_groups')->get('email_forum_comments') && $this->config->get('access-view-section')) : ?>

    diff --git a/core/plugins/groups/memberoptions/language/en-GB/en-GB.plg_groups_memberoptions.ini b/core/plugins/groups/memberoptions/language/en-GB/en-GB.plg_groups_memberoptions.ini index 1c0a9d011a1..6838dbfffdf 100644 --- a/core/plugins/groups/memberoptions/language/en-GB/en-GB.plg_groups_memberoptions.ini +++ b/core/plugins/groups/memberoptions/language/en-GB/en-GB.plg_groups_memberoptions.ini @@ -6,6 +6,6 @@ GROUP_MEMBEROPTIONS="Member Options" GROUP_MEMBEROPTIONS_DESC="These settings are used to specify group specific configuration options for your account:" -GROUP_RECEIVE_EMAILS_DISCUSSION_POSTS="Enable Email for posts" +GROUP_RECEIVE_EMAILS_DISCUSSION_POSTS="Enable outgoing Email notifications for posts" GROUP_MEMBEROPTIONS_NONE="There are currently no user configuratble options for this group." GROUP_MEMBEROPTIONS_UPDATED="You have successfully updated your email settings" diff --git a/core/plugins/groups/memberoptions/views/browse/tmpl/default.php b/core/plugins/groups/memberoptions/views/browse/tmpl/default.php index 84c6de7b16a..d49f4ba593b 100644 --- a/core/plugins/groups/memberoptions/views/browse/tmpl/default.php +++ b/core/plugins/groups/memberoptions/views/browse/tmpl/default.php @@ -10,11 +10,11 @@ $params = $params = Component::params('com_groups'); -$allowEmailResponses = $params->get('email_comment_processing'); +$forumCommentEmailNotifications = $params->get('email_forum_comments'); // Be sure to update this if you add more options $atLeastOneOption = false; -if ($allowEmailResponses) +if ($forumCommentEmailNotifications) { $atLeastOneOption = true; } @@ -32,7 +32,7 @@

    - +
    recvEmailOptionValue == 1) { echo 'checked="checked"'; } ?> /> From 9ea70b2304f57d31d13b2ad74831f91e7c337f8b Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Fri, 15 Nov 2024 11:35:06 -0800 Subject: [PATCH 23/23] added in if condition --- .../com_forum/site/assets/js/like.js | 163 ++++++++--------- core/plugins/groups/forum/assets/js/like.js | 165 +++++++++--------- 2 files changed, 167 insertions(+), 161 deletions(-) diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 73078483b8f..12e400ea9f8 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -7,46 +7,81 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { let likeStatsLink = commentSections[i].querySelector('.likesStat'); let whoLikedPostDiv = commentSections[i].querySelector('.whoLikedPost'); - likeStatsLink.onclick = (e) => { - e.preventDefault(); - this.__toggle = !this.__toggle; - if(this.__toggle) { - whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; - } else { - whoLikedPostDiv.style.height = 0; + // Make sure all these HTML elements are present before assigning attributes + if (likeStatsLink && whoLikedPostDiv && likeButton) { + likeStatsLink.onclick = (e) => { + e.preventDefault(); + this.__toggle = !this.__toggle; + if(this.__toggle) { + whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; + } else { + whoLikedPostDiv.style.height = 0; + } } - } - - likeButton.onclick = (e) => { - e.preventDefault(); - - let hasHeart = likeButton.classList.contains("userLiked"); - - const threadId = likeButton.dataset.thread; - const postId = likeButton.dataset.post; - const userId = likeButton.dataset.user; - const userName = likeButton.dataset.userName; - const nameAndId = `${userName}#${userId}`; - - const likesList = likeButton.dataset.likesList; - const likeCount = likeButton.dataset.count; - - // console.log(threadId, postId, userId, likeCount, userName, likesList); - - const likesListArray = likesList.split("/"); - if (hasHeart) { - removeLike(threadId, postId, userId).then((res) => { - if (res.ok) { - const newLikeCount = Number(likeCount) - 1; - const newLikesString = likesListArray.filter(e => e !== nameAndId).join('/'); - - likeButton.dataset.count = `${newLikeCount}`; - likeButton.classList.remove("userLiked"); - likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = (newLikeCount === 0) ? 'No Likes' : `View Likes (${newLikeCount})`; - - if (newLikeCount > 0) { + likeButton.onclick = (e) => { + e.preventDefault(); + + let hasHeart = likeButton.classList.contains("userLiked"); + + const threadId = likeButton.dataset.thread; + const postId = likeButton.dataset.post; + const userId = likeButton.dataset.user; + const userName = likeButton.dataset.userName; + const nameAndId = `${userName}#${userId}`; + + const likesList = likeButton.dataset.likesList; + const likeCount = likeButton.dataset.count; + + // console.log(threadId, postId, userId, likeCount, userName, likesList); + + const likesListArray = likesList.split("/"); + + if (hasHeart) { + removeLike(threadId, postId, userId).then((res) => { + if (res.ok) { + const newLikeCount = Number(likeCount) - 1; + const newLikesString = likesListArray.filter(e => e !== nameAndId).join('/'); + + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.remove("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = (newLikeCount === 0) ? 'No Likes' : `View Likes (${newLikeCount})`; + + if (newLikeCount > 0) { + let whoLikedArray = []; + const newLikesArray = newLikesString.split("/"); + for (let i = 0; i < newLikesArray.length; i++) { + const nameArray = newLikesArray[i].split('#') + const userName = nameArray[0]; + const userId = nameArray[1]; + const userProfileUrl = `/members/${userId}/profile`; + + whoLikedArray.push(`${userName}`); + } + + likeStatsLink.classList.remove("noLikes"); + whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; + } else { + likeStatsLink.classList.add("noLikes"); + whoLikedPostDiv.innerHTML = ""; + } + + // console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + } + }) + } else { + addLike(threadId, postId, userId).then((res) => { + if (res.ok) { + const newLikeCount = Number(likeCount) + 1; + const newLikesString = [...likesListArray, nameAndId].filter(Boolean).join('/'); + + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.add("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = `View Likes (${newLikeCount})`; + likeStatsLink.classList.remove("noLikes"); + let whoLikedArray = []; const newLikesArray = newLikesString.split("/"); for (let i = 0; i < newLikesArray.length; i++) { @@ -54,52 +89,20 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const userName = nameArray[0]; const userId = nameArray[1]; const userProfileUrl = `/members/${userId}/profile`; - + whoLikedArray.push(`${userName}`); } - - likeStatsLink.classList.remove("noLikes"); + whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; - } else { - likeStatsLink.classList.add("noLikes"); - whoLikedPostDiv.innerHTML = ""; - } - - // console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); - } - }) - } else { - addLike(threadId, postId, userId).then((res) => { - if (res.ok) { - const newLikeCount = Number(likeCount) + 1; - const newLikesString = [...likesListArray, nameAndId].filter(Boolean).join('/'); - - likeButton.dataset.count = `${newLikeCount}`; - likeButton.classList.add("userLiked"); - likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = `View Likes (${newLikeCount})`; - likeStatsLink.classList.remove("noLikes"); - - let whoLikedArray = []; - const newLikesArray = newLikesString.split("/"); - for (let i = 0; i < newLikesArray.length; i++) { - const nameArray = newLikesArray[i].split('#') - const userName = nameArray[0]; - const userId = nameArray[1]; - const userProfileUrl = `/members/${userId}/profile`; - - whoLikedArray.push(`${userName}`); + + // console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } - - whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; - - // console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); - } - }) - } - - return false; - }; + }) + } + + return false; + }; + } } } }); diff --git a/core/plugins/groups/forum/assets/js/like.js b/core/plugins/groups/forum/assets/js/like.js index 73078483b8f..2c2fbf017b9 100644 --- a/core/plugins/groups/forum/assets/js/like.js +++ b/core/plugins/groups/forum/assets/js/like.js @@ -7,46 +7,81 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { let likeStatsLink = commentSections[i].querySelector('.likesStat'); let whoLikedPostDiv = commentSections[i].querySelector('.whoLikedPost'); - likeStatsLink.onclick = (e) => { - e.preventDefault(); - this.__toggle = !this.__toggle; - if(this.__toggle) { - whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; - } else { - whoLikedPostDiv.style.height = 0; + // Make sure all these HTML elements are present before assigning attributes + if (likeStatsLink && whoLikedPostDiv && likeButton) { + likeStatsLink.onclick = (e) => { + e.preventDefault(); + this.__toggle = !this.__toggle; + if(this.__toggle) { + whoLikedPostDiv.style.height = `${whoLikedPostDiv.scrollHeight}px`; + } else { + whoLikedPostDiv.style.height = 0; + } } - } - - likeButton.onclick = (e) => { - e.preventDefault(); - - let hasHeart = likeButton.classList.contains("userLiked"); - - const threadId = likeButton.dataset.thread; - const postId = likeButton.dataset.post; - const userId = likeButton.dataset.user; - const userName = likeButton.dataset.userName; - const nameAndId = `${userName}#${userId}`; - - const likesList = likeButton.dataset.likesList; - const likeCount = likeButton.dataset.count; - - // console.log(threadId, postId, userId, likeCount, userName, likesList); - - const likesListArray = likesList.split("/"); - - if (hasHeart) { - removeLike(threadId, postId, userId).then((res) => { - if (res.ok) { - const newLikeCount = Number(likeCount) - 1; - const newLikesString = likesListArray.filter(e => e !== nameAndId).join('/'); - - likeButton.dataset.count = `${newLikeCount}`; - likeButton.classList.remove("userLiked"); - likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = (newLikeCount === 0) ? 'No Likes' : `View Likes (${newLikeCount})`; - - if (newLikeCount > 0) { + + likeButton.onclick = (e) => { + e.preventDefault(); + + let hasHeart = likeButton.classList.contains("userLiked"); + + const threadId = likeButton.dataset.thread; + const postId = likeButton.dataset.post; + const userId = likeButton.dataset.user; + const userName = likeButton.dataset.userName; + const nameAndId = `${userName}#${userId}`; + + const likesList = likeButton.dataset.likesList; + const likeCount = likeButton.dataset.count; + + // console.log(threadId, postId, userId, likeCount, userName, likesList); + + const likesListArray = likesList.split("/"); + + if (hasHeart) { + removeLike(threadId, postId, userId).then((res) => { + if (res.ok) { + const newLikeCount = Number(likeCount) - 1; + const newLikesString = likesListArray.filter(e => e !== nameAndId).join('/'); + + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.remove("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = (newLikeCount === 0) ? 'No Likes' : `View Likes (${newLikeCount})`; + + if (newLikeCount > 0) { + let whoLikedArray = []; + const newLikesArray = newLikesString.split("/"); + for (let i = 0; i < newLikesArray.length; i++) { + const nameArray = newLikesArray[i].split('#') + const userName = nameArray[0]; + const userId = nameArray[1]; + const userProfileUrl = `/members/${userId}/profile`; + + whoLikedArray.push(`${userName}`); + } + + likeStatsLink.classList.remove("noLikes"); + whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; + } else { + likeStatsLink.classList.add("noLikes"); + whoLikedPostDiv.innerHTML = ""; + } + + // console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); + } + }) + } else { + addLike(threadId, postId, userId).then((res) => { + if (res.ok) { + const newLikeCount = Number(likeCount) + 1; + const newLikesString = [...likesListArray, nameAndId].filter(Boolean).join('/'); + + likeButton.dataset.count = `${newLikeCount}`; + likeButton.classList.add("userLiked"); + likeButton.dataset.likesList = newLikesString; + likeStatsLink.innerHTML = `View Likes (${newLikeCount})`; + likeStatsLink.classList.remove("noLikes"); + let whoLikedArray = []; const newLikesArray = newLikesString.split("/"); for (let i = 0; i < newLikesArray.length; i++) { @@ -54,52 +89,20 @@ window.addEventListener('DOMContentLoaded', (domEvent) => { const userName = nameArray[0]; const userId = nameArray[1]; const userProfileUrl = `/members/${userId}/profile`; - + whoLikedArray.push(`${userName}`); } - - likeStatsLink.classList.remove("noLikes"); + whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; - } else { - likeStatsLink.classList.add("noLikes"); - whoLikedPostDiv.innerHTML = ""; - } - - // console.warn(`Like removed for forum thread '${threadId}' of post '${postId}' for user ${userId}`); - } - }) - } else { - addLike(threadId, postId, userId).then((res) => { - if (res.ok) { - const newLikeCount = Number(likeCount) + 1; - const newLikesString = [...likesListArray, nameAndId].filter(Boolean).join('/'); - - likeButton.dataset.count = `${newLikeCount}`; - likeButton.classList.add("userLiked"); - likeButton.dataset.likesList = newLikesString; - likeStatsLink.innerHTML = `View Likes (${newLikeCount})`; - likeStatsLink.classList.remove("noLikes"); - - let whoLikedArray = []; - const newLikesArray = newLikesString.split("/"); - for (let i = 0; i < newLikesArray.length; i++) { - const nameArray = newLikesArray[i].split('#') - const userName = nameArray[0]; - const userId = nameArray[1]; - const userProfileUrl = `/members/${userId}/profile`; - - whoLikedArray.push(`${userName}`); + + // console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); } - - whoLikedPostDiv.innerHTML = "
    " + whoLikedArray.join(', ') + " liked this
    "; - - // console.log(`Like recorded for forum thread '${threadId}' of post '${postId}' for user ${userId}`); - } - }) - } - - return false; - }; + }) + } + + return false; + }; + } } } });