By James on Tuesday, 10 November 2020
Replies 8
Likes 0
Views 2.2K
Votes 0
I have updated the default EasySocial Polls to include (3) badges for Polls.

The badges included are for the following triggers:
- Poll Creation
- Commenting on a Poll
- Reacting to a Poll

You will want to add the following code below (EasySocial 3.2.21):

ROOT > media > com_easysocial > apps > users > polls > polls.php(Add a new Line at 418) just below the following:

// Only notify if the actor is not the poll's owner
if ($likes->created_by != $stream->actor_id) {
ES::notify('likes.item', array($stream->actor_id), false, $systemParams);
}



Replace the code above with the following:

// Only notify if the actor is not the poll's owner
if ($likes->created_by != $stream->actor_id) {
ES::notify('likes.item', array($stream->actor_id), false, $systemParams);
}

ES::badges()->log('com_easysocial', 'polls.react', $likes->created_by, '');



In the same file, we need to add the trigger for reactions. (Add a new Line at 478) just below the following:

// Notify the owner of the photo first
if ($comment->created_by != $polls->created_by) {
ES::notify('comments.item', array($polls->created_by), $mailParams, $systemParams);
}


Replace the code above with the following:

// Notify the owner of the photo first
if ($comment->created_by != $polls->created_by) {
ES::notify('comments.item', array($polls->created_by), $mailParams, $systemParams);
}

ES::badges()->log('com_easysocial', 'polls.comment', $comment->created_by, '');



We need to edit one more file here:
ROOT > administrator > components > com_easysocial > includes > polls > polls.php (Add line 291) just below the following:

// Insert the poll options
if ($template->items) {

foreach ($template->items as $item) {

$pollItem = ES::table('PollsItems');
$pollItem->poll_id = $table->id;
$pollItem->value = $item->text;
$pollItem->count = 0;

$pollItem->store();
}
}

ES::points()->assign('polls.add', 'com_easysocial', $this->my->id);


Replace the code above with the following:

// Insert the poll options
if ($template->items) {

foreach ($template->items as $item) {

$pollItem = ES::table('PollsItems');
$pollItem->poll_id = $table->id;
$pollItem->value = $item->text;
$pollItem->count = 0;

$pollItem->store();
}
}

ES::points()->assign('polls.add', 'com_easysocial', $this->my->id);
ES::badges()->log('com_easysocial', 'polls.create', $this->my->id, '');



I have attached a file called (polls.badge) you will need to go to the EasySocial backend and install it in Achievements:
SITE ADMIN > Components > EasySocial > Achievements > Install > select the attached file and install

Next, you will need to upload the badge images to the folder: ROOT > media > com_easysocial > badges

Lastly you will need to either add language overrides to your site for the language strings, or update the language strings in the badges in EasySocials admin panel.

My hope is that StackIdeas will incorporate this in the next public release of EasySocial. If I missed anything I apologize, I am not a programmer. I would HIGHLY encourage anyone who wants to use these hacks to take a backup of their site first, and I would recommend testing on a development server first.

Thank you,
James
James, thanks for your input.
Stackteam, please include this in the core!
·
Wednesday, 11 November 2020 00:58
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi James thanks for this,

Polls are one of the coolest things on Twitter.
I would also live to see this functionality included in the SI core

thanks
Paul
·
Wednesday, 18 November 2020 16:10
·
0 Likes
·
0 Votes
·
0 Comments
·
No problem Paul!

Happy to help.

James
·
Wednesday, 18 November 2020 21:26
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello. Was it added to official release?
·
Saturday, 28 August 2021 02:14
·
0 Likes
·
0 Votes
·
0 Comments
·
"Poll Creation" is a default (core) badge.
How to add only:
- Commenting on a Poll
- Reacting to a Poll?
Thanks.
·
Sunday, 02 January 2022 05:33
·
0 Likes
·
0 Votes
·
0 Comments
·
OK, I’ll try to apply new badges to EasySocial 4.0.x and will let you know how it’s work.
·
Wednesday, 26 January 2022 04:51
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello. Does anybody tested this Badges in ES 4.0.x?
Support Team, can you please add this badges as core?
it will shake up community and interesting people.
Thanks.
·
Wednesday, 19 October 2022 03:54
·
0 Likes
·
0 Votes
·
0 Comments
·
It's probably not working anymore.

Haven't tested, unfortunately.
·
Wednesday, 19 October 2022 04:14
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post