DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • May 18, 2013, 04:06:13 PM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1] 2   Go Down
  Print  
Author Topic: Module Suggestion  (Read 978 times)
0 Members and 1 Guest are viewing this topic.
~Ender~
Captain of the Guard
***
Offline Offline

Posts: 185


Google is our savior!


View Profile
« on: September 14, 2012, 05:09:23 PM »

Greetings:

An idea for those who understand PHP and MYSQL (I don't x.x)

On some sites, such as EvolutionAthens, there is a 'message' icon in front of every players name in chat linking the nav to a 'message' box.

The idea is almost the same. Instead of messaging a player, you could 'like' their comment. Ideally it would be a pre-determined message sent by the system, and there could/would be a limit of 'likes' a day.


As always, open for comments, suggestions, and of course criticism. 
Logged

insert sympathy here

Message me!
KaosKaizer
Mod God
*****
Offline Offline

Posts: 1000


Love bites, but so do I!


View Profile
« Reply #1 on: September 14, 2012, 05:58:28 PM »

I did make a like system for the commentary, however I have yet to release it as it was a core edit(my implementation could be fatal to a server if not done to a letter). If you want, I could try to make a module out of it, instead. Or I could release the core edits here. However, it did not send a message when someone liked a comment, and there was no limit. Beside the comment in the chat, it was just an upvote and a downvote button, with the number of likes and dislikes for each comment. I will work on making it a module for you, if those limitations are fine. Or I could try to make it a module and try to meet your wants, if you would prefer it that way. I originally did not make it send a message as I thought that would be too annoying due to the no per-day up/down voting limits.
Logged

My Mods
Like to read? "Like" my page. Smiley
For reasons I'd prefer not to explain, I will not be active until further notice. I will not make any posts and I will ignore all PMs.
Srch
Captain of the Guard
***
Offline Offline

Posts: 133

Hi, I'm Ver!


View Profile
« Reply #2 on: September 14, 2012, 05:59:51 PM »

Wouldn't it be kinda pointless, for some sites, considering how chats move quickly. If you liked a comment, people would only see that it was liked for about 30 minutes. it is possible.. Very easy in fact. But not suggested.
Logged

KaosKaizer
Mod God
*****
Offline Offline

Posts: 1000


Love bites, but so do I!


View Profile
« Reply #3 on: September 14, 2012, 06:33:47 PM »

Well, some servers are smaller so chats don't go by as fast. It is a thing that some servers would have, and others wouldn't, of course. Those that are too big might not want to have it.

As for modularizing it... I realized why I made it a core edit in the first place. The "viewcommentary" hook doesn't contain the comment ID and I can't do a query for $args['commentline'], as everything has already been appended there, including the delete button for staff, and the clan tags and names. I will tidy up my core edits and release them, unless somebody knows of a way to retrieve the ID of the comment from the viewcommentary hook.

:: EDIT ::
WARNING! Make sure that you are COMFORTABLE with making a core edit, and that you make a BACKUP of all files/tables that you will be editing. DragonPrime Staff is NOT responsible if your server crashes. I personally may try to help you if you make a mistake, so please, follow my words to a letter so you don't make a mistake.
You are going to need to place the attachment in your root folder. You are also going to need to create 2 new columns in your commentary table. Please note that if you upgrade, these columns will be removed(which is why I wanted to do this via module, that way there would be no need for extra rows...).
You can do so by running the PHP in RawSQL:
Code:
$sql = "ALTER TABLE `".db_prefix("commentary")."` ADD COLUMN likes int(11) NOT NULL default 0";
db_query($sql);
$sql = "ALTER TABLE `".db_prefix("commentary")."` ADD COLUMN dislikes int(11) NOT NULL default 0";
db_query($sql);

Then you need to modify your lib/commentary.php file with the following:
Code:
<?php
/* FIND LINE 424, it (and the 3 preceeding lines) should look something like, but with tabs:
if ($session['user']['superuser'] & SU_EDIT_COMMENTS) {
$out.="`2[<a href='".$return.$one."removecomment={$commentids[$i]}&section=$section&returnpath=".URLEncode($return)."'>$del</a>`2]`0&nbsp;";
addnav("",$return.$one."removecomment={$commentids[$i]}&section=$section&returnpath=".URLEncode($return)."");
}
*/
// Like/Dislike PREP
$id $commentids[$i];
$sql "SELECT likes,dislikes FROM ".db_prefix("commentary")." WHERE commentid=$id LIMIT 1";
$res db_query($sql);
$row db_fetch_assoc($res);
if (isset($session['user']['prefs']['comdislikes'])) $dislikes explode(",",$session['user']['prefs']['comdislikes']);
else $dislikes = array();
if (isset($session['user']['prefs']['comlikes'])) $likes explode(",",$session['user']['prefs']['comlikes']);
else $likes = array();
// Like code...
$lcount $row['likes'];
if (in_array($id,$likes) || in_array($id,$dislikes)){
$out .= "<img src='images/like.gif' width=10 height=10 alt='Like'> $lcount&nbsp;";
}else{
define("OVERRIDEFORCEDNAV",TRUE);
$out .= "<a href='likedis.php?op=like&id=$id&returnpath=".URLEncode($return)."'><img src='images/like.gif' width=10 height=10 alt='Like'> $lcount</a>&nbsp;";
addnav("","likedis.php?op=like&id=$id&returnpath=".URLEncode($return)."");
}
// End

// Dislike code...
$dcount $row['dislikes'];
if (in_array($id,$likes) || in_array($id,$dislikes)){
$out .= "<img src='images/dislike.gif' width=10 height=10 alt='Dislike'> $dcount&nbsp;";
}else{
define("OVERRIDEFORCEDNAV",TRUE);
$out .= "<a href='likedis.php?op=dislike&id=$id&returnpath=".URLEncode($return)."'><img src='images/dislike.gif' width=10 height=10 alt='Dislike'> $dcount</a>&nbsp;";
addnav("","likedis.php?op=dislike&id=$id&returnpath=".URLEncode($return)."");
}
// End
// END

Then, place the 2 images in the zip into your /images/ folder.
« Last Edit: September 14, 2012, 07:20:30 PM by KaosKaizer » Logged

My Mods
Like to read? "Like" my page. Smiley
For reasons I'd prefer not to explain, I will not be active until further notice. I will not make any posts and I will ignore all PMs.
Aeo
Mod God
*****
Offline Offline

Posts: 1077


Doctor.. Who?


View Profile WWW
« Reply #4 on: September 14, 2012, 09:47:06 PM »

And if you use live commentary, remember to put it in your ajaxcommentary.php file as well.. ^^
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
~Ender~
Captain of the Guard
***
Offline Offline

Posts: 185


Google is our savior!


View Profile
« Reply #5 on: September 15, 2012, 09:20:24 AM »

Thanks guys.
Logged

insert sympathy here

Message me!
Aeo
Mod God
*****
Offline Offline

Posts: 1077


Doctor.. Who?


View Profile WWW
« Reply #6 on: September 18, 2012, 12:53:53 AM »

As for modularizing it... I realized why I made it a core edit in the first place. The "viewcommentary" hook doesn't contain the comment ID and I can't do a query for $args['commentline'], as everything has already been appended there, including the delete button for staff, and the clan tags and names. I will tidy up my core edits and release them, unless somebody knows of a way to retrieve the ID of the comment from the viewcommentary hook.

I realize this would still be a core edit, but it wouldn't be as big.. Could you not simply allow the modulehook 'viewcommentary' to include the comment id, just as it includes the comment line?
« Last Edit: September 18, 2012, 12:56:47 AM by Aeolus » Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
KaosKaizer
Mod God
*****
Offline Offline

Posts: 1000


Love bites, but so do I!


View Profile
« Reply #7 on: September 18, 2012, 04:31:27 AM »

Well, yes, you could do that. My mind comes up with overly complicated solutions without even telling me of the simple ones, so... I didn't think of that xD
Logged

My Mods
Like to read? "Like" my page. Smiley
For reasons I'd prefer not to explain, I will not be active until further notice. I will not make any posts and I will ignore all PMs.
Aeo
Mod God
*****
Offline Offline

Posts: 1077


Doctor.. Who?


View Profile WWW
« Reply #8 on: September 18, 2012, 03:01:40 PM »

I've actually started working on working this into a module, and surprisingly, I'm almost finished, without even needing to edit the core. I've sorted out the comment IDs, only thing I need to work out now is separating similar comments to show their own likes/dislikes.
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
ArthuruhtrA
Mod God
*****
Offline Offline

Posts: 553


chown -R us ./base


View Profile WWW
« Reply #9 on: September 18, 2012, 07:25:05 PM »

Mind explaining to us how you got the comment IDs?

I've been meaning to make a like button module for a while... I'm sure most of us have...
Thanks KaosKaizer.
Logged

Dragons of MythMy Modules | Tynastera!
BOWTIES ARE COOL
Aeo
Mod God
*****
Offline Offline

Posts: 1077


Doctor.. Who?


View Profile WWW
« Reply #10 on: September 18, 2012, 07:33:35 PM »

Mind explaining to us how you got the comment IDs?

Basically extracting the comment from the $args['commentline'], and matching it with the one in the database. I'll show you when I finally get it fully working and post it. xD

The only problem is that it matches up with all similar comments..
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
ArthuruhtrA
Mod God
*****
Offline Offline

Posts: 553


chown -R us ./base


View Profile WWW
« Reply #11 on: September 19, 2012, 04:36:20 AM »

Are you searching for the exact string?
Logged

Dragons of MythMy Modules | Tynastera!
BOWTIES ARE COOL
Aeo
Mod God
*****
Offline Offline

Posts: 1077


Doctor.. Who?


View Profile WWW
« Reply #12 on: September 19, 2012, 10:30:30 AM »

Are you searching for the exact string?

I've done that, but there's still the problem of if two strings are identical. (Just to make sure we cover all cases.)
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Aeo
Mod God
*****
Offline Offline

Posts: 1077


Doctor.. Who?


View Profile WWW
« Reply #13 on: September 21, 2012, 10:42:55 PM »

Well, I got it to work for everyone who has the SU Edit Comments flag, but extracting "removecomment=" and the ID.. xD Is there any way to do that for a regular player? Perhaps turning the flag on, extracting it, and turning the flag back off as the commentary loads? Or is that stupid idea? o.o
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Eclypse ~ Xpert
Militia
**
Offline Offline

Posts: 75


View Profile
« Reply #14 on: September 22, 2012, 03:41:02 PM »

I took out the Dislike option.. I don't really deem it necessary as it could cause some butthurt between players and such.
I also turned the images into just a link.. As in [Like]..

Code:
if (in_array($id,$likes)){
$out .= "`2[<a".URLEncode($return)."'>`)Like`2] `&$lcount Likes</a>&nbsp;";
}else{
define("OVERRIDEFORCEDNAV",TRUE);
$out .= "`2[<a href='likedis.php?op=like&id=$id&returnpath=".URLEncode($return)."'>Like`2] `&$lcount Likes</a>&nbsp;";
addnav("","likedis.php?op=like&id=$id&returnpath=".URLEncode($return)."");
}

Obviously the above doesn't show the dislike part, as I've previously stated, I took it out.

Also:
Made this so users have the option to turn it on of off through their preferences..

Really recommend Aeolus adds this to his module as well. As I've had some complain about it.^^ Enjoy.
« Last Edit: September 22, 2012, 03:47:50 PM by Xpert » Logged

Senior Administrator, Coder, and Head of Staff

tynastera.com
isleofdarkness.com
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
17 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search