News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

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!!


       


Advertisement: