Author Topic: [MOD] Votes saved in DB  (Read 245020 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Votes saved in DB
« Reply #45 on: June 01, 2005, 01:29:00 AM »
Here is a little addon for version A of this mod which I promised for a long time and never published it...
It will show who voted and if u logged in as admin also show what was the vote of each voted member on image details page (details.php)

Step 1
Open details.php
Find:
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

Insert above:
Code: [Select]
//-----------------------------------------------------
//--- Voted stats -------------------------------------
//-----------------------------------------------------
$sql = "SELECT v.user_id, v.vote, u.user_name
        FROM ".VOTED_TABLE." v
        LEFT JOIN ".USERS_TABLE." u ON (u.user_id = v.user_id)
        WHERE u.user_id = v.user_id AND image_id = ".$image_id;
$result = $site_db->query($sql);
$voted_list = "";
while ($row = $site_db->fetch_array($result))
{
  $vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
  $voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
//  $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
$site_template->register_vars(array(
  "voted_list" => $voted_list,
  "lang_voted_list" => $lang['voted_list']
));
//----- End Voted stats ----------------


Step 2
In lang/<your language>/main.php at the very end, above closing ?> insert:
Code: [Select]
$lang['voted_list'] = "Who voted";

Step 3
In templates/<your template>/details.html use the following tags:
{lang_voted_list} - this will show text "Who voted"
{voted_list} - this will show the list of members who has voted


P.S. if you installed a mod that changed details.php and that alteres $image_id variable, this mod might not work properly!
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline martrix

  • Hero Member
  • *****
  • Posts: 755
    • View Profile
    • overlord.cz
Re: [MOD] Votes saved in DB
« Reply #46 on: June 01, 2005, 09:35:49 AM »
wonderful... thanks for this addon - I guess it was not only me waiting for this (no matter if 2 lazy or 2 stoopid to find out, how to do that)

I'll try to implement that tonight :D
MAяTRIX


Offline txcherry1499

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #47 on: June 08, 2005, 04:15:08 PM »
Hi,
how can i insert more than one voting?
Perhaps u have a gallery and would like to let vote for graphic, quality, and so on ...

Best regards
Michaela

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Votes saved in DB
« Reply #48 on: June 09, 2005, 12:04:33 AM »
that would be a completly different mod ;)
perhaps u should start a new mod request topic
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Zyga

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #49 on: November 13, 2005, 09:57:07 AM »
What should I change to hide rating option ater vote (in version A) and show only how user rating this picture  :?:

something like "U voted already - > 5"



PS. thx great mod

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.421
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: [MOD] Votes saved in DB
« Reply #50 on: November 13, 2005, 02:41:32 PM »

Offline Zyga

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #51 on: November 13, 2005, 05:09:44 PM »
yes but how can i "mix it" with this mod ver. A

Offline Fastian

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #52 on: January 15, 2006, 06:50:56 PM »
Hi V@no

Few months back i install version B of this Mod. It was working good.

Now when i try to apply the mod "More than more statistics" I realised that i need Version A of your DB mode. I have undo the changes caused by v B in all three files but i dont know how to remove Database changes.

So what i am asking is. DO i need to remove anything caused by version B installer?

So far i cant see any error but i m not sure that i am not seeing it or is there no any error  :roll:
I m not a  Programmer.
          But
I m a Good Learner.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Votes saved in DB
« Reply #53 on: January 15, 2006, 07:43:59 PM »
Dont worry about that ;) everything is ok :)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Joss

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • All about digital photography
Re: [MOD] Votes saved in DB
« Reply #54 on: January 17, 2006, 04:00:12 PM »
What about old ratings, which were voted, before this mod installed?
Will be all old votes displayed togeter with new votes from DB or not?
Thank you!
Digital Photo Gallery: http://gallery.imagemaster.ru

Offline ch€ri{Bi}˛

  • Sr. Member
  • ****
  • Posts: 315
  • A PRoBLeM wIthOUt SoLuTioN Is NoT rEAllY a PRoBLeM
    • View Profile
    • Pat's Gallery
Re: [MOD] Votes saved in DB
« Reply #55 on: January 17, 2006, 07:04:20 PM »
What about old ratings, which were voted, before this mod installed?
Unless you are an excellent magician or one powerful sorcerer, you can't get informations about it  :mrgreen:

Will be all old votes displayed togeter with new votes from DB or not?
same answer : you must reveal them initially  :lol:
ch€ri{Bi}˛


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Votes saved in DB
« Reply #56 on: January 18, 2006, 12:49:42 AM »
What about old ratings, which were voted, before this mod installed?
Will be all old votes displayed togeter with new votes from DB or not?
Thank you!
This mod does not affect the image votes/ratings and it is more like a "logging" tool. But, as cheribibi said, you wont be able to tell who voted where and how much was the vote, before this mod installed ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Joss

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • All about digital photography
Re: [MOD] Votes saved in DB
« Reply #57 on: January 18, 2006, 01:07:18 PM »
Thanks! This was my bad english translation. I've spoke about the ratings, not about votes logging, of course.
Digital Photo Gallery: http://gallery.imagemaster.ru

Offline Joss

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • All about digital photography
Re: [MOD] Votes saved in DB
« Reply #58 on: January 18, 2006, 10:29:16 PM »
Here is my changes for "Voted stats". I want to display users list with a comma delimeter, instead of a new line.
E.g.:

User1 (7), User2 (12), User3 (24)

instead of

User1 (7)
User2 (12)
User3 (24)

Code: [Select]
//-----------------------------------------------------
//--- Voted stats -------------------------------------
//-----------------------------------------------------
$sql = "SELECT v.user_id, v.vote, u.user_name
        FROM ".VOTED_TABLE." v
        LEFT JOIN ".USERS_TABLE." u ON (u.user_id = v.user_id)
        WHERE u.user_id = v.user_id AND image_id = ".$image_id;
$result = $site_db->query($sql);
$voted_list = "";
$vcnt = 0;
$sdelimeter = "";
while ($row = $site_db->fetch_array($result))
{
  if ($vcnt > 0)
  $sdelimeter = ", ";
  $vcnt++;
  $vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
  $voted_list .= $sdelimeter."<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote;
  //member name WITH a link to their profile page

//$voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
$site_template->register_vars(array(
  "voted_list" => $voted_list,
  "lang_voted_list" => $lang['voted_list']
));
//----- End Voted stats ----------------

Digital Photo Gallery: http://gallery.imagemaster.ru

Offline Joss

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • All about digital photography
Re: [MOD] Votes saved in DB
« Reply #59 on: January 18, 2006, 10:48:11 PM »
V@no, can I fetch a number of votes for a user?  I want to decrease ulpoad limit for users who didn't votes, or who have less than 2 vote in DB. Thanks!
Digital Photo Gallery: http://gallery.imagemaster.ru