SMF Poll Mod

Started by clemenzo, June 09, 2007, 11:09:33 AM

Previous topic - Next topic

DHC

Quote from: clemenzo on January 20, 2008, 09:10:31 AM
Quote from: DHC on January 19, 2008, 05:06:52 PM
I am having no success in downloading the file from the Modifications site. Maybe it is related to the SMF server problem recently, but it would be appreciated if the Modification could be uploaded here.

Can you try again? I was able to download the mod without uploading yet.. :)

I just downloaded it - which worked this time.

Unfortunately, upon installing it, I received THIS message:

QuoteThe package you tried to upload either is not a valid package or has become corrupted.

This is being reported for a number of the Modification that were re-installed following the server problems. PLEASE upload the current version to THIS THREAD.

Thanks!

clemenzo

Done! Mod added to mod page and first post of this topic.

DHC

Thanks!

It works like a champ!

clemenzo

No problem! Thanks for using this mod!

madaisy

Sorry but i really don't know what to do after the installation.
I have SMF 1.1.4
Please help me!!

clemenzo

Quote from: madaisy on March 23, 2008, 07:18:15 AM
Sorry but i really don't know what to do after the installation.
I have SMF 1.1.4
Please help me!!

What is your site address? Do you use tinyportal?

Basie

In the first post, the demo for 'default theme' is not using the default theme.... ???

madaisy

Quote from: clemenzo on March 23, 2008, 07:31:56 AM
Quote from: madaisy on March 23, 2008, 07:18:15 AM
Sorry but i really don't know what to do after the installation.
I have SMF 1.1.4
Please help me!!

What is your site address? Do you use tinyportal?
hxxp:www.extremesubs.it [nonactive]
no tinyportal...

clemenzo

Quote from: seek2501 on March 23, 2008, 01:42:17 PM
In the first post, the demo for 'default theme' is not using the default theme.... ???
Can you provide a screenshot of what you see, including the url address in the browser? I just checked and it is still using the default theme..

clemenzo

Quote from: madaisy on March 23, 2008, 03:57:42 PM
Quote from: clemenzo on March 23, 2008, 07:31:56 AM
Quote from: madaisy on March 23, 2008, 07:18:15 AM
Sorry but i really don't know what to do after the installation.
I have SMF 1.1.4
Please help me!!

I see that you are using MkPortal. This mod has not been tested with that CMS. Anyway, you should be able to see this mod in action within any poll topic in your forum. If you want to display a poll block within your CMS, you need to use SSI include with a php block to call the poll display function as described in the first post.

What is your site address? Do you use tinyportal?
www.extremesubs.it
no tinyportal...

bros

Will this be modified to work with SMF 2.0?

clemenzo

Quote from: bros on May 04, 2008, 09:02:12 PM
Will this be modified to work with SMF 2.0?
It should be, after SMF 2.0 final is out.. :)

bros

Quote from: clemenzo on May 04, 2008, 09:17:55 PM
Quote from: bros on May 04, 2008, 09:02:12 PM
Will this be modified to work with SMF 2.0?
It should be, after SMF 2.0 final is out.. :)

Awww. I want it for beta 3.1

midiof[f]

Modification file for SMF 1.1.5


modification.xml

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is an example modification file for SMF packages.

ATTENTION: If you are trying to install this manually, you should try
the package manager.  If it will not work for you, please take a look
at the following for information on this format:
http://mods.simplemachines.org/docs/manual-install.php

================================================================================

Modification files can be used to modify files so that they do what
your package needs them to do to work properly.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>clemenzo:SMFpoll</id>
<version>1.1.1</version>

<file name="$sourcedir/Display.php">
<operation>
<search position="replace"><![CDATA[ 'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll_left.gif" alt="" /><img src="' . $settings['images_url'] . '/poll_middle.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll_right.gif" alt="" /></span>',]]></search>
<add><![CDATA[ 'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll/poll_left_c'. $i%10 . '.gif" alt="" /><img src="' . $settings['images_url'] . '/poll/poll_middle_c' . $i%10 . '.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll/poll_right_c' . $i%10 . '.gif" alt="" /></span>',]]></add>
</operation>
</file>
 
  <file name="$themedir/Display.template.php">
<operation>
<search position="replace"><![CDATA[ // Are they not allowed to vote but allowed to view the options?
if ($context['poll']['show_results'] || !$context['allow_vote'])
{
echo '
<table>
<tr>
<td style="padding-top: 2ex;">
<table border="0" cellpadding="0" cellspacing="0">';

// Show each option with its corresponding percentage bar.
foreach ($context['poll']['options'] as $option)
echo '
<tr>
<td style="padding-right: 2ex;', $option['voted_this'] ? 'font-weight: bold;' : '', '">', $option['option'], '</td>', $context['allow_poll_view'] ? '
<td nowrap="nowrap">' . $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)</td>' : '', '
</tr>';

echo '
</table>
</td>
<td valign="bottom" style="padding-left: 15px;">';]]></search>
<add><![CDATA[ // Are they not allowed to vote but allowed to view the options?
if ($context['poll']['show_results'] || !$context['allow_vote'])
{
echo '
<table>
<tr>
<td style="padding-top: 2ex;">
<table border="0" cellpadding="0" cellspacing="1" width="100%">';

// Show each option with its corresponding percentage bar.
foreach ($context['poll']['options'] as $option)
echo '
<tr>
<td style="padding-right: 2ex;', $option['voted_this'] ? 'font-weight: bold;' : '', '" class="smalltext">', $option['option'], '</td>', $context['allow_poll_view'] ? '
<td nowrap="nowrap" class="smalltext">' . $option['bar'] . '</td>
<td nowrap="nowrap" class="smalltext">' . $option['votes']. ' (' . $option['percent'] . '%)</td>' : '', '
</tr>';

echo '
</table>
</td>
<td valign="bottom" style="padding-left: 15px;" class="smalltext">';]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ <tr>
<td colspan="2"><b>' . $txt['smf24'] . ': ' . $context['poll']['total_votes'] . '</b></td>
</tr>' : '', '
</table><br />';
}]]></search>
<add><![CDATA[ <tr>
  <td colspan="2">&nbsp;</td>
</tr>
        <tr>
<td colspan="2" class="smalltext"><b>' . $txt['smf24'] . ': ' . $context['poll']['total_votes'] . '</b></td>
</tr>' : '', '
</table><br />';
}]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ // They are allowed to vote! Go to it!
else
{
echo '
<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0px;">
<table>
<tr>
<td colspan="2">';

// Show a warning if they are allowed more than one option.
if ($context['poll']['allowed_warning'])
echo '
', $context['poll']['allowed_warning'], '
</td>
</tr><tr>
<td>';

// Show each option with its button - a radio likely.
foreach ($context['poll']['options'] as $option)
echo '
', $option['vote_button'], ' ', $option['option'], '<br />';

echo '
</td>
<td valign="bottom" style="padding-left: 15px;">';]]></search>
<add><![CDATA[ // They are allowed to vote! Go to it!
else
{
echo '
<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0px;">
<table>
<tr>
<td colspan="2" class="smalltext">';

// Show a warning if they are allowed more than one option.
if ($context['poll']['allowed_warning'])
echo '
', $context['poll']['allowed_warning'], '
</td>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
  </tr>
          <tr>
<td class="smalltext">';

// Show each option with its button - a radio likely.
foreach ($context['poll']['options'] as $option)
echo '
', $option['vote_button'], ' ', $option['option'], '<br />';

echo '
</td>
<td valign="bottom" style="padding-left: 15px;" class="smalltext">';]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ </tr><tr>
<td colspan="2"><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>';
}]]></search>
<add><![CDATA[ </tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
          <tr>
<td colspan="2"><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>';
}]]></add>
</operation>
</file>

  <file name="$boarddir/SSI.php">
<operation>
<search position="replace"><![CDATA[ $barWide = $bar == 0 ? 1 : floor(($bar * 5) / 3);]]></search>
<add><![CDATA[ $barWide = $bar == 0 ? 1 : floor(($bar * 5) / 9);]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ 'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll_left.gif" alt="" /><img src="' . $settings['images_url'] . '/poll_middle.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll_right.gif" alt="" /></span>',]]></search>
<add><![CDATA[ 'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll/poll_left_c' . $i%10 . '.gif" alt="" /><img src="' . $settings['images_url'] . '/poll/poll_middle_c' . $i%10 . '.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll/poll_right_c' . $i%10 . '.gif" alt="" /></span>',]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ <table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td><b>', $return['question'], '</b></td>
</tr>
<tr>
<td>', $return['allowed_warning'], '</td>
</tr>';]]></search>
<add><![CDATA[ <table border="0" cellspacing="1" cellpadding="0" class="ssi_table" width="100%">
<tr>
<td class="smalltext"><a href="', $boardurl, '/index.php?topic=', $return['topic'], '"><b>', $return['question'], '</b></a></td>
</tr>
<tr>
<td class="smalltext">', $return['allowed_warning'], '</td>
</tr>
        <tr>
  <td>&nbsp;</td>
</tr>';]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ foreach ($return['options'] as $option)
echo '
<tr>
<td><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
<tr>
<td><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';]]></search>
<add><![CDATA[ foreach ($return['options'] as $option)
echo '
<tr>
<td class="smalltext"><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
  <tr>
      <td>&nbsp;</td>
    </tr>
<tr>
<td align="center"><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';]]></add>
</operation>

<operation>
<search position="after"><![CDATA[
function ssi_showPoll($topic = null, $output_method = 'echo')
{]]></search>
<add><![CDATA[function random_poll($boards = "", $mode = "exclude"){
  global $db_prefix, $settings, $user_info;

  $boardsAllowed = boardsAllowedTo('poll_view');

  $request = db_query("SELECT t.ID_TOPIC FROM {$db_prefix}topics t, {$db_prefix}boards b, {$db_prefix}polls p WHERE t.locked = 0 AND t.ID_BOARD = b.ID_BOARD AND t.ID_POLL = p.ID_POLL AND p.votingLocked = 0 AND (p.expireTime = 0 OR p.expireTime > unix_timestamp())" . ($boards == "" ? "" : (" AND t.id_board" . ($mode == "exclude" ? " NOT": "") . " IN (" . implode(', ', $boards) . ")")) . " AND $user_info[query_see_board]" . (!in_array(0, $boardsAllowed) ? " AND b.id_board IN (" . implode(', ', $boardsAllowed) . ")" : '') . " ORDER BY rand() LIMIT 0, 1", __FILE__, __LINE__);

  $poll_topic = mysql_fetch_assoc($request);
  mysql_free_result($request);

  if(empty($poll_topic['ID_TOPIC']))
    echo "<p style=\"text-align: center; font-size: small;\">Sorry, no poll found.</p>";
  else
    ssi_showPoll($poll_topic['ID_TOPIC']);
}
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ $request = db_query("
SELECT
p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes]]></search>
<add><![CDATA[ $request = db_query("
SELECT
p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes, b.ID_BOARD]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ $barWide = $bar == 0 ? 1 : floor(($bar * 5) / 3);]]></search>
<add><![CDATA[ $barWide = $bar == 0 ? 1 : floor(($bar * 5) / 9);]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ 'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll_left.gif" alt="" /><img src="' . $settings['images_url'] . '/poll_middle.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll_right.gif" alt="" /></span>',]]></search>
<add><![CDATA[ 'bar' => '<span style="white-space: nowrap;"><img src="' . $settings['images_url'] . '/poll/poll_left_c' . $i%10 . '.gif" alt="" /><img src="' . $settings['images_url'] . '/poll/poll_middle_c' . $i%10 . '.gif" width="' . $barWide . '" height="12" alt="-" /><img src="' . $settings['images_url'] . '/poll/poll_right_c' . $i%10 . '.gif" alt="" /></span>',]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ <table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td><b>', $return['question'], '</b></td>
</tr>
<tr>
<td>', $return['allowed_warning'], '</td>
</tr>';]]></search>
<add><![CDATA[ <table border="0" cellspacing="1" cellpadding="0" class="ssi_table" width="100%">
<tr>
<td class="smalltext"><a href="', $boardurl, '/index.php?topic=', $return['topic'], '"><b>', $return['question'], '</b></a></td>
</tr>
<tr>
<td class="smalltext">', $return['allowed_warning'], '</td>
</tr>
          <tr>
    <td>&nbsp;</td>
  </tr>';]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ foreach ($return['options'] as $option)
echo '
<tr>
<td><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
<tr>
<td><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';]]></search>
<add><![CDATA[ foreach ($return['options'] as $option)
echo '
<tr>
<td class="smalltext"><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
      <tr>
        <td>&nbsp;</td>
      </tr>
<tr>
<td align="center"><input type="submit" value="', $txt['smf23'], '" /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';]]></search>
<add><![CDATA[ echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table" width="100%">
<tr>
<td colspan="2" class="smalltext"><a href="', $boardurl, '/index.php?topic=', $return['topic'], '"><b>', $return['question'], '</b></a></td>
</tr>
          <tr>
            <td colspan="2">&nbsp;</td>
          </tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td colspan="2" class="smalltext" style="border-top: #dddddd 1px dotted;">', $option['option'], '</td>
</tr>
          <tr>
            <td class="smalltext">', $option['bar'], '</td>
            <td align="right" class="smalltext" nowrap="nowrap">', $option['votes'], ' (', $option['percent'], '%)</td>
          </tr>';
echo '
  <tr>
        <td colspan="2" style="border-top: #dddddd 1px dotted;">&nbsp;</td>
      </tr>
<tr>
<td colspan="2" class="smalltext"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[ // Check if they can vote.
if (!empty($row['expireTime']) && $row['expireTime'] < time())
$allow_vote = false;
elseif ($user_info['is_guest'] || !empty($row['votingLocked']) || !allowedTo('poll_vote', array($row['ID_BOARD'])))
$allow_vote = false;
else
{
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}log_polls
WHERE ID_POLL = $row[ID_POLL]
AND ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
$allow_vote = mysql_num_rows($request) == 0;
mysql_free_result($request);
}]]></search>
<add><![CDATA[ // Check if they can vote.
if ((!empty($row['expireTime']) && $row['expireTime'] < time()) || $user_info['is_guest'] || !empty($row['votingLocked']) || !allowedTo('poll_vote', $row['ID_BOARD'])){
$allow_vote = false;
} else {
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}log_polls
WHERE ID_POLL = $row[ID_POLL]
AND ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
$allow_vote = mysql_num_rows($request) == 0;
mysql_free_result($request);
}]]></add>
</operation>
</file>
</modification>
Yaarar clan Azure L2 [nofollow] Admin

clemenzo

Updated for SMF 1.1.5!

DistantJ

Hey, I really like this! Good job! I was never quite happy with those one-colour polls. Another one of the many little mods which have gone to make my board more colourful. :)

the_shadow

i install this mode but the buttun new pool on my template does't appear!!!! i'm not use a defaut template but a custom...someone have the solution?

thnkx

clemenzo

Quote from: the_shadow on July 06, 2008, 01:56:27 PM
i install this mode but the buttun new pool on my template does't appear!!!! i'm not use a defaut template but a custom...someone have the solution?

thnkx

You'll need modify your theme manually.. :) There are already many topics on and I think someone has developed a tool to help you make the changes.

the_shadow

the problem is....i don't understand much off this...

To show a poll in tinyportal block, add a block of type "phpbox" and enter the one of the following:

ssi_showPoll(X); - For a single fixed poll where X is a topic number.
random_poll(); - For a random poll from all boards accessible by user.
random_poll(Y); - For a random poll from all boards except Y where Y is a board number.
random_poll(array(Y, Z)); - For a random poll from all boards except Y, Z where Y and Z are board numbers.
random_poll(array(A, B, C), 'include'); - For a random poll from A, B, C where A, B and C are board numbers. Users unable to see board A would still be unable to see the poll from board A.

what this means???'

clemenzo

Quote from: the_shadow on July 08, 2008, 04:05:52 PM
the problem is....i don't understand much off this...

To show a poll in tinyportal block, add a block of type "phpbox" and enter the one of the following:

ssi_showPoll(X); - For a single fixed poll where X is a topic number.
random_poll(); - For a random poll from all boards accessible by user.
random_poll(Y); - For a random poll from all boards except Y where Y is a board number.
random_poll(array(Y, Z)); - For a random poll from all boards except Y, Z where Y and Z are board numbers.
random_poll(array(A, B, C), 'include'); - For a random poll from A, B, C where A, B and C are board numbers. Users unable to see board A would still be unable to see the poll from board A.

what this means???'

This is only relevant if you use TinyPortal mod. Else, simply install this mod and you should see the effect in your poll topic.

Advertisement: