Voter Visibility

Started by Ray Cardillo, May 02, 2012, 12:25:01 PM

Previous topic - Next topic

Tyrsson

Can you attach that file to your next post please. The more important question at the moment is "why" is $context['poll'] undefined? Because if $context['poll'] is undefined then so is the conditions that the mod author is trying to check against in that series of checks. I got an idea of how to fix it  but I would like to check on something else before I suggest it.
PM at your own risk, some I answer, if they are interesting, some I ignore.

Tyrsson

Quote from: FrizzleFried on April 27, 2022, 01:41:48 PMI figured it was close to that.  As to how to FIX said problem... err...

I wonder what happens if I simply REMOVE that code (being I can't find what it's doing negative to the mod anyway to be honest... again,  I think it has something to do with whether or not to allow someone to see that page.)
Its checking, or should I say its actually setting the value of which will be used to determine whether its displayed or not.
PM at your own risk, some I answer, if they are interesting, some I ignore.

FrizzleFried

I am happy to report that between bsmithers work (posted earlier) and some work by Joey Smith... the Voter Visibility mod is up and working 100% (dare I say) on my live forum.  I am working on complete instructions to get this mod to work for you.


FrizzleFried

Want Voter Visibility to work with your 2.1.x forum?  Follow these instructions...

I have at least nine different edits of this mod... and I am not the most organized of individuals so after some internal debate I've decided to list all the edit differences between the version available here and the final version that I have working on multiple forums.  I figured that would be the best way to make sure you get the correct edits, etc.  These edits include work primarily from bsmither (there is a post above with his edits attached),  but member Joey Smith also jumped in and helped out with a few edits to get the final errors the mod was generating handled.

I've tested this mod pretty thoroughly on both a sandbox and live site with success... I am not sure what the legality issue is with my offering up the already edited files people could simply drop in to their current installations is... but if it's at all possible,  please let me know and I'd be happy to either post here or even host said files with said edits already done.  If that can't happen... it's been demonstrated that posted edits are OK... so here you go:


(1) Download the votervisibility-2.1.zip file from the packages tab here: https://custom.simplemachines.org/index.php?mod=3373

(2) Unzip the file.  It will create a folder called votervisibility-2.1.  Within that folder you will find a Sources folder,  a Themes folder and some files.  We'll start from top and work our way down.

(3) Load up Notepad ++ (or whatever editor you use) and make the following edits:


FILE: Sources/VoteLog.php

Code (find) Select
    // the table needs some special sauce
    $context['html_headers'] .= '
    <link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/css/votelog.css" />
    <script language="javascript" type="text/javascript">
    if (typeof jQuery == "undefined" || jQuery.fn.jquery != "1.11.3") {
        // if we do not already have jQuery 1.11.3 loaded then load using Google CDN (better for caching, less bandwidth, etc).
        document.write(unescape("%3Cscript language=\'javascript\' type=\'text/javascript\' src=\'http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\'%3E%3C/script%3E"));
    }
    </script>
    <script language="javascript" type="text/javascript">
    if (typeof jQuery == "undefined" || jQuery.fn.jquery != "1.11.3") {
        // if we still do not have jQuery 1.11.3 loaded then load the locally deployed version as a backup.
        document.write(unescape("%3Cscript language=\'javascript\' type=\'text/javascript\' src=\'' . $settings['default_theme_url'] . '/scripts/jquery-1.11.3.min.js\'%3E%3C/script%3E"));
    }
    </script>
    <script language="javascript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/jquery-tablesorter-2.0.5.min.js"></script>';
   
Code ("replace with") Select
    loadCSSFile('votelog.css');
    loadJavaScriptFile('jquery-tablesorter-2.0.5.min.js');
    addInlineJavascript('$(document).ready(function(){$("#voteLogTable").tablesorter({sortList:[[0,0],[2,0]]});});',true);


Code (find) Select
    $context['allow_poll_view'] = allowedTo('moderate_board') || $pollinfo['hide_results'] == 0 || ($pollinfo['hide_results'] == 1 && $context['poll']['has_voted']) || $context['poll']['is_expired'];   
Code ("replace with") Select
    $context['allow_poll_view'] = allowedTo('moderate_board') || $pollinfo['hide_results'] == 0 || ($pollinfo['hide_results'] == 1 && isset($context['poll']['has_voted']) ? $context['poll']['has_voted'] : 0)  || ( isset($context['poll']['is_expired']) ? $context['poll']['is_expired'] : 1);

FILE: Themes\default\css\votelog.css

Code ("add to the end of file") Select
#edit_poll dl.poll_options dd {
    padding: 0 0 .25em 0;
}


REMOVE THE FILE: Themes\default\scripts\jquery-1.11.3.min.js


FILE: Themes\default\VoteLog.template.php

Code (find) Select
    <th style="text-align:center; halign:center; width:5em;">', $txt['poll_vv_vlog_th_choicenum'], '</th>                   
Code ("replace with") Select
    <th style="text-align:left;  halign:left;  width:3em;">', $txt['poll_vv_vlog_th_choicenum'], '</th>   
Code (find) Select
    <td style="text-align:left;  halign:left;"><a href="', $memberurl, '" title="', $txt['profile_of'], ' ', $votelog['member_name'], '">', $votelog['member_name'], '</a></td>   
Code ("replace with") Select
    <td style="text-align:left;  halign:left;"><a href="', $memberurl, '" title="' . sprintf($txt['view_profile_of_username'], $votelog['member_name']) . '">', $votelog['member_name'], '</a></td>
Code ("find and delete") Select
            <script language="javascript" type="text/javascript"><!-- // --><![CDATA[
                $(document).ready(function() {
                    $("#voteLogTable").tablesorter( {sortList: [[0,0], [2,0]]} );
                });
            // ]]></script>

Create a new file in your editor and post the following code then save it as database_211.php in the root folder of the Voter Visibility mod (same folder that has the license.txt and readme.txt, etc.)

<?php

global $db_prefix$smcFunc;

$smcFunc['db_add_column'](
    
'{db_prefix}polls',
    array(
        
'name'    => 'vote_visibility',
        
'type'    => 'tinyint',
        
'size'    => 1,
        
'not_null' => true,
        
'default'  => 0,
        
'unsigned' => true
    
)
);

$smcFunc['db_add_column'](
    
'{db_prefix}polls',
    array(
        
'name'    => 'allow_comments',
        
'type'    => 'tinyint',
        
'size'    => 1,
        
'not_null' => true,
        
'default'  => 0,
        
'unsigned' => true
    
)
);

$smcFunc['db_add_column'](
    
'{db_prefix}poll_choices',
    array(
        
'name'    => 'requires_comment',
        
'type'    => 'tinyint',
        
'size'    => 1,
        
'not_null' => true,
        
'default'  => 0,
        
'unsigned' => true
    
)
);

$smcFunc['db_add_column'](
    
'{db_prefix}log_polls',
    array(
        
'name'    => 'timestamp',
        
'type'    => 'int',
        
'size'    => 11,
        
'not_null' => false,
        
'unsigned' => true
    
)
);

$smcFunc['db_add_column'](
    
'{db_prefix}log_polls',
    array(
        
'name'    => 'comments',
        
'type'    => 'text',
        
'not_null' => false,
    )
);

?>
       
       
FILE: package-info.xml

Code (find) Select
</uninstall>   

</package-info>

Code (replace with) Select
</uninstall>   

    <install for="2.1.1 - 2.1.9">
        <readme type="file" parsebbc="true" lang="english">readme.txt</readme>
        <database type="file">database_211.php</database>       
        <require-dir name="Sources" destination="$boarddir" />
        <require-dir name="Themes" destination="$boarddir" />
        <modification format="xml" type="file">mods-2.1.1.xml</modification>
        <modification format="xml" type="file">mods-translations.xml</modification>
    </install>
   
    <uninstall for="2.1.1 - 2.1.9">
        <modification format="xml" type="file" reverse="true">mods-2.1.1.xml</modification>
        <modification format="xml" type="file" reverse="true">mods-translations.xml</modification>
        <remove-file name="$sourcedir/VoteLog.php" />
        <remove-file name="$themedir/VoteLog.template.php" />
        <remove-file name="$themedir/css/votelog.css" />
        <remove-file name="$themedir/scripts/jquery-tablesorter-2.0.5.min.js" />
        <remove-dir name="$themedir/images/votelog" />
    </uninstall>   

</package-info>

That should be it!  It looks like more work than it actually is to convert.  Please note that once you do convert that the mod will no longer be compatible with the 2.0.x version of SMF.  I would like to thank @bsmither for his hard work getting this mod to work with 2.1.x and for @Joey Smith™ for his work purging the final buggers remaining!  You both ROCK and my users and I appreciate the help!!


       


Kira_

@FrizzleFried, thank you for your work. I acted according to the instructions, I received an error during installation "mods-2.1.1.xml - File not found" and the absence of a button to view the vote. I took this file from the attachment in the answer No. 130 of this topic and everything worked as it should.
а нас
за що?

Johnfromhere

I should like to install this mod on my 2.1.3 forum.
I am a little(!) confused by the last two postings (143 & 144) above.

Could someone out there tell me how to install it, ie do I have to edit with all the bits in 143 above - and is it the original package that I download from https://custom.simplemachines.org/index.php?mod=3373 and install?

Any help to this somewhat struggling bloke would be gratefully received.

Many thanks.

John.

Johnfromhere

I have now upgraded to 2.1.4

I attempted to install the mod as modified in posting 143 above and got the following:-

    1.    Adapt Database    database_211.php   
    2.    Extract Tree    ./Sources   
    3.    Extract Tree    ./Themes   
    4.    Execute Modification    mods-2.1.1.xml    File not found
    5.    Execute Modification    ./Themes/default/languages/Modifications.english.php    Test successful
    6.    Execute Modification    ./Themes/default/languages/Modifications.english-utf8.php    Skipping file
    7.    Execute Modification    ./Themes/default/languages/Modifications.german-utf8.php    Skipping file
    8.    Execute Modification    ./Themes/default/languages/Modifications.polish-utf8.php    Skipping file

Nevertheless, I continued with the install (on a test forum) and it appeared to install OK – however :-

It does not show the voters, simply the number and percentage of the votes cast.

I run a band and I set up polls to see who is available on a given date.  The overall number is pretty useless when I can't work out what instruments are available/unavailable!!

Has anyone any ideas please about how to get this mod running?

Many thanks in anticipation.

Cheers.

John.

Kindred

well, I think this says it all...

Execute Modification    mods-2.1.1.xml    File not found

the xml to apply the mod in 2.1.x was not found in the package and so, was not applied
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Tyrsson

Quote from: Kira_ on December 13, 2022, 02:48:32 PMI took this file from the attachment in the answer No. 130 of this topic and everything worked as it should.
PM at your own risk, some I answer, if they are interesting, some I ignore.

Johnfromhere

Thanks, Tyrsson.

I looked for the file (mods-2.1.1.xml) in post #130 on this thread but couldn't find anything.
(and I'd had a bad day!).

Having read it #130 again, do I uderstand it correctly that as it was an attachment to a post it got deleted?
If so, any idea how I can recover it?

Or have I got it all confused and wrong ::) ?

Thanks again.

Cheers.

John.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Johnfromhere

Thanks for that - it WAS a bad day ::) !

I think I must have been just reading this thread without being logged in - when, for some reason, the attachment doesn't show.

Anyway, thanks again and I'll try it again.

Cheers.

John.

Johnfromhere

I have installed it and it appears to be working fine.

Apologies for being a little bit thick!

Many thanks.

Cheers.

John.

Tyrsson

Quote from: Johnfromhere on July 05, 2023, 04:39:05 PMI have installed it and it appears to be working fine.

Apologies for being a little bit thick!

Many thanks.

Cheers.

John.
We all have bad days ;)
PM at your own risk, some I answer, if they are interesting, some I ignore.

Johnfromhere

As stated - I installed the Voter Visibility mod and it appeared to be working fine when I tested it.

I a now trying to use it and it still appears to be working OK but I am getting errors written to the Error log as under.

Any ideas please?

Many thanks.

John.

Quotexxxxxx
xxx.xxx.xx.xxx
ba566005bc498b5d261d911fd38a1371
https://xxxxxxxxxx.xx.xx/smf/index.php?action=votelog;topic=36
/home/xxxxxxx/public_html/smf/Sources/VoteLog.php (Line 79)
Backtrace information

Type of error: General
Error message Select
8: Trying to access array offset on value of type null
3
 
Sep 25, 2023, 06:01 PM
________________________________________
xxxxxx
xxx.xxx.xx.xxx
ba566005bc498b5d261d911fd38a1371
https://xxxxxxxx.xx.xx/smf/index.php?action=votelog;topic=36
/home/xxxxxxxx/public_html/smf/Sources/VoteLog.php (Line 79)
Backtrace information

Type of error: Undefined
Error message Select
8: Undefined index: poll
2
 
Sep 25, 2023, 06:01 PM

Advertisement: