ให้ในกระทู้มีได้มากกว่า1โพล
- +



ของในห้องแจกของแจกฟรีทุกชิ้น

^ประกาศ pordoo.com คือเว็บสำหรับแจกสิ่งของ สมาชิกสะสมพอยท์ภายในเว็บเพื่อนำไปแลกของรางวัลที่ต้องการ
พอยท์ได้มาจากไหนบ้าง?
1.สมัครสมาชิกรับ 100 พอยท์
2.กดรับจากAdmin สัปดาห์ละ 100 พอยท์
3.สมาชิกคนอื่นกดให้พอยท์ (กดที่กล่องของขวัญ)
แจก 2,000 พอยท์ทุกสัปดาห์ รอบ15 คลิ้กเลย

ผู้เขียน หัวข้อ: ให้ในกระทู้มีได้มากกว่า1โพล  (อ่าน 301 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ smfTopic starter

  • "ถ้าคุณไม่สามารถอธิบายอย่างง่ายๆ ให้คนอื่นเข้าใจได้แล้วล่ะก็ แสดงว่าคุณยังเข้าใจมันไม่ดีพอ"
  • Administrator
  • Hero Member
  • *****
  • กระทู้: 1,353
  • พอยท์: 4
    • ดูรายละเอียด
    • pordoo.com
    • อีเมล์
  • คอมเมนต์สินค้า: (1)
ให้ในกระทู้มีได้มากกว่า1โพล
« เมื่อ: 5 พฤศจิกายน 2015, 15:53:59 »
Mod Name:Additional Polls
http://custom.simplemachines.org/mods/index.php?mod=1586








File Edits
./Sources/Display.php
Find:

p.question, p.voting_locked, p.hide_results, p.expire_time, p.max_votes, p.change_vote,

Replace With: [Select]

p.id_poll, p.question, p.voting_locked, p.hide_results, p.expire_time, p.max_votes, p.change_vote,


Find: [Select]

WHERE p.id_poll = {int:id_poll}
         LIMIT 1',
         array(
            'id_poll' => $topicinfo['id_poll'],
         )

Replace With: [Select]

WHERE p.id_poll = {int:id_poll} OR p.id_topic = {int:topic}
         ORDER BY p.question',
         array(
            'id_poll' => $topicinfo['id_poll'],
            'topic' => $topic,
         )


Find: [Select]

$pollinfo = $smcFunc['db_fetch_assoc']($request);
      $smcFunc['db_free_result']($request);

Replace With: [Select]

$pollinfo = array();
      while($row = $smcFunc['db_fetch_assoc']($request)) $pollinfo[] = $row;
      $smcFunc['db_free_result']($request);
      foreach($pollinfo as $poll)
      {
      


Find: [Select]

$request = $smcFunc['db_query']('', '
         SELECT COUNT(DISTINCT id_member) AS total
         FROM {db_prefix}log_polls
         WHERE id_poll = {int:id_poll}
            AND id_member != {int:not_guest}',
         array(
            'id_poll' => $topicinfo['id_poll'],
            'not_guest' => 0,
         )
      );
      list ($pollinfo['total']) = $smcFunc['db_fetch_row']($request);
      $smcFunc['db_free_result']($request);

      // Total voters needs to include guest voters
      $pollinfo['total'] += $pollinfo['num_guest_voters'];

Replace With: [Select]

$request = $smcFunc['db_query']('', '
         SELECT COUNT(DISTINCT id_member) AS total
         FROM {db_prefix}log_polls
         WHERE id_poll = {int:id_poll}
            AND id_member != {int:not_guest}',
         array(
            'id_poll' => $poll['id_poll'],
            'not_guest' => 0,
         )
      );
      list ($poll['total']) = $smcFunc['db_fetch_row']($request);
      $smcFunc['db_free_result']($request);

      // Total voters needs to include guest voters
      $poll['total'] += $poll['num_guest_voters'];


Find: [Select]

'current_member' => $user_info['id'],
            'id_poll' => $topicinfo['id_poll'],

Replace With: [Select]

'current_member' => $user_info['id'],
            'id_poll' => $poll['id_poll'],


Find: [Select]

$pollinfo['has_voted'] = false;

Replace With: [Select]

$poll['has_voted'] = false;


Find: [Select]

$pollinfo['has_voted'] |= $row['voted_this'] != -1;

Replace With: [Select]

$poll['has_voted'] |= $row['voted_this'] != -1;


Find: [Select]

if (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $topicinfo['id_poll'] . ',') !== false)

Replace With: [Select]

if (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $poll['id_poll'] . ',') !== false)


Find: [Select]

if ($guestvoted[0] == $topicinfo['id_poll'])

Replace With: [Select]

if ($guestvoted[0] == $poll['id_poll'])


Find: [Select]

if ($pollinfo['reset_poll'] > $guestvoted[1])

Replace With: [Select]

if ($poll['reset_poll'] > $guestvoted[1])


Find: [Select]

$pollinfo['has_voted'] |= $pollOptions[$choice]['voted_this'] != -1;

Replace With: [Select]

$poll['has_voted'] |= $pollOptions[$choice]['voted_this'] != -1;


Find: [Select]

if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote'))

Replace With: [Select]

if ($user_info['is_guest'] && $poll['guest_vote'] && allowedTo('poll_vote'))


Find: [Select]

'id' => $topicinfo['id_poll'],
         'image' => 'normal_' . (empty($pollinfo['voting_locked']) ? 'poll' : 'locked_poll'),
         'question' => parse_bbc($pollinfo['question']),
         'total_votes' => $pollinfo['total'],
         'change_vote' => !empty($pollinfo['change_vote']),
         'is_locked' => !empty($pollinfo['voting_locked']),
         'options' => array(),
         'lock' => allowedTo('poll_lock_any') || ($context['user']['started'] && allowedTo('poll_lock_own')),
         'edit' => allowedTo('poll_edit_any') || ($context['user']['started'] && allowedTo('poll_edit_own')),
         'allowed_warning' => $pollinfo['max_votes'] > 1 ? sprintf($txt['poll_options6'], min(count($pollOptions), $pollinfo['max_votes'])) : '',
         'is_expired' => !empty($pollinfo['expire_time']) && $pollinfo['expire_time'] < time(),
         'expire_time' => !empty($pollinfo['expire_time']) ? timeformat($pollinfo['expire_time']) : 0,
         'has_voted' => !empty($pollinfo['has_voted']),
         'starter' => array(
            'id' => $pollinfo['id_member'],
            'name' => $row['poster_name'],
            'href' => $pollinfo['id_member'] == 0 ? '' : $scripturl . '?action=profile;u=' . $pollinfo['id_member'],
            'link' => $pollinfo['id_member'] == 0 ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $pollinfo['id_member'] . '">' . $row['poster_name'] . '</a>'
         )
      );

Replace With: [Select]

'id' => $poll['id_poll'],
         'image' => 'normal_' . (empty($poll['voting_locked']) ? 'poll' : 'locked_poll'),
         'question' => parse_bbc($poll['question']),
         'total_votes' => $poll['total'],
         'change_vote' => !empty($poll['change_vote']),
         'is_locked' => !empty($poll['voting_locked']),
         'options' => array(),
         'lock' => allowedTo('poll_lock_any') || ($context['user']['started'] && allowedTo('poll_lock_own')),
         'edit' => allowedTo('poll_edit_any') || ($context['user']['started'] && allowedTo('poll_edit_own')),
         'allowed_warning' => $poll['max_votes'] > 1 ? sprintf($txt['poll_options6'], min(count($pollOptions), $poll['max_votes'])) : '',
         'is_expired' => !empty($poll['expire_time']) && $poll['expire_time'] < time(),
         'expire_time' => !empty($poll['expire_time']) ? timeformat($poll['expire_time']) : 0,
         'has_voted' => !empty($poll['has_voted']),
         'starter' => array(
            'id' => $poll['id_member'],
            'name' => $row['poster_name'],
            'href' => $poll['id_member'] == 0 ? '' : $scripturl . '?action=profile;u=' . $poll['id_member'],
            'link' => $poll['id_member'] == 0 ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $poll['id_member'] . '">' . $row['poster_name'] . '</a>'
         )
      );


Find: [Select]

$context['allow_vote'] = !$context['poll']['is_expired'] && (!$user_info['is_guest'] || ($pollinfo['guest_vote'] && allowedTo('poll_vote'))) && empty($pollinfo['voting_locked']) && allowedTo('poll_vote') && !$context['poll']['has_voted'];

Replace With: [Select]

$context['poll']['allow_vote'] = !$context['poll']['is_expired'] && (!$user_info['is_guest'] || ($poll['guest_vote'] && allowedTo('poll_vote'))) && empty($poll['voting_locked']) && allowedTo('poll_vote') && !$context['poll']['has_voted'];


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'];

Replace With: [Select]

$context['poll']['allow_poll_view'] = allowedTo('moderate_board') || $poll['hide_results'] == 0 || ($poll['hide_results'] == 1 && $context['poll']['has_voted']) || $context['poll']['is_expired'];


Find: [Select]

$context['poll']['show_results'] = $context['allow_poll_view'] && (isset($_REQUEST['viewresults']) || isset($_REQUEST['viewResults']));

Replace With: [Select]

$context['poll']['show_results'] = $context['poll']['allow_poll_view'] &&(isset($_REQUEST['viewresults']) || isset($_REQUEST['viewResults'])) && $poll['id_poll'] == $_REQUEST['poll'];


Find: [Select]

$context['show_view_results_button'] = $context['allow_vote'] && $context['allow_poll_view'] && !$context['poll']['show_results'];

Replace With: [Select]

$context['poll']['show_view_results_button'] = $context['poll']['allow_vote'] && (!$context['poll']['allow_poll_view'] || !$context['poll']['show_results'] || !$context['poll']['has_voted']);


Find: [Select]

$context['allow_change_vote'] = !$context['poll']['is_expired'] && !$user_info['is_guest'] && empty($pollinfo['voting_locked']) && allowedTo('poll_vote') && $context['poll']['has_voted'] && $context['poll']['change_vote'];

Replace With: [Select]

$context['poll']['allow_change_vote'] = !$context['poll']['is_expired'] && !$user_info['is_guest'] && empty($poll['voting_locked']) && allowedTo('poll_vote') && $context['poll']['has_voted'] && $context['poll']['change_vote'];


Find: [Select]

$context['allow_return_vote'] = $context['allow_vote'] && $context['poll']['show_results'];

Replace With: [Select]

$context['poll']['allow_return_vote'] = $context['poll']['allow_vote'] && $context['poll']['show_results'];


Find: [Select]

'vote_button' => '<input type="' . ($pollinfo['max_votes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="input_' . ($pollinfo['max_votes'] > 1 ? 'check' : 'radio') . '" />'

Replace With: [Select]

'vote_button' => '<input type="' . ($poll['max_votes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="input_' . ($poll['max_votes'] > 1 ? 'check' : 'radio') . '" />'


Find: [Select]


   }

   // Calculate the fastest way to get the messages!

Add Before: [Select]


         $context['polls'][] = $context['poll'];
         unset($context['poll']);
      }


Find: [Select]

$context['can_add_poll'] &= $modSettings['pollMode'] == '1' && $topicinfo['id_poll'] <= 0;

Replace With: [Select]

$context['can_add_poll'] &= $modSettings['pollMode'] == '1';


« แก้ไขครั้งสุดท้าย: 5 พฤศจิกายน 2015, 16:05:35 โดย smf »

ออฟไลน์ smfTopic starter

  • "ถ้าคุณไม่สามารถอธิบายอย่างง่ายๆ ให้คนอื่นเข้าใจได้แล้วล่ะก็ แสดงว่าคุณยังเข้าใจมันไม่ดีพอ"
  • Administrator
  • Hero Member
  • *****
  • กระทู้: 1,353
  • พอยท์: 4
    • ดูรายละเอียด
    • pordoo.com
    • อีเมล์
  • คอมเมนต์สินค้า: (1)
Re: ให้ในกระทู้มีได้มากกว่า1โพล
« ตอบกลับ #1 เมื่อ: 5 พฤศจิกายน 2015, 15:55:46 »
./Sources/Poll.php
Find: [Select]

global $topic, $txt, $user_info, $smcFunc, $sourcedir, $modSettings;

Add After: [Select]

$poll = !empty($_REQUEST['poll']) ? (int)$_REQUEST['poll'] : 0;
   


Find: [Select]

FROM {db_prefix}topics AS t
         INNER JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
         LEFT JOIN {db_prefix}log_polls AS lp ON (p.id_poll = lp.id_poll AND lp.id_member = {int:current_member} AND lp.id_member != {int:not_guest})
      WHERE t.id_topic = {int:current_topic}
      LIMIT 1',
      array(
         'current_member' => $user_info['id'],
         'current_topic' => $topic,
         'not_guest' => 0,
      )

Replace With: [Select]

FROM {db_prefix}topics AS t
         INNER JOIN {db_prefix}polls AS p ON (p.id_topic = t.id_topic)
         LEFT JOIN {db_prefix}log_polls AS lp ON (p.id_poll = lp.id_poll AND lp.id_member = {int:current_member} AND lp.id_member != {int:not_guest})
      WHERE p.id_topic = {int:current_topic} AND (p.id_poll = {int:poll} OR p.id_poll = t.id_poll)
      ORDER BY p.id_poll DESC
      LIMIT 1',
      array(
         'current_member' => $user_info['id'],
         'current_topic' => $topic,
         'not_guest' => 0,
         'poll' => $poll,
      )


Find: [Select]

global $topic, $user_info, $smcFunc;

   checkSession('get');

Add After: [Select]

$poll = !empty($_REQUEST['poll']) ? (int)$_REQUEST['poll'] : 0;
   


Find: [Select]

SELECT t.id_member_started, t.id_poll, p.voting_locked
      FROM {db_prefix}topics AS t
         INNER JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
      WHERE t.id_topic = {int:current_topic}
      LIMIT 1',
      array(
         'current_topic' => $topic,
      )

Replace With: [Select]

SELECT t.id_member_started, p.id_poll, p.voting_locked
      FROM {db_prefix}topics AS t
         INNER JOIN {db_prefix}polls AS p ON (p.id_topic = t.id_topic)
      WHERE p.id_topic = {int:current_topic} AND (p.id_poll = {int:poll} OR p.id_poll = t.id_poll)
      ORDER BY p.id_poll DESC
      LIMIT 1',
      array(
         'current_topic' => $topic,
         'poll' => $poll,
      )


Find: [Select]

global $txt, $user_info, $context, $topic, $board, $smcFunc, $sourcedir, $scripturl;

Add After: [Select]

$poll = !empty($_REQUEST['poll']) ? (int)$_REQUEST['poll'] : 0;
   


Find: [Select]

// Check if a poll currently exists on this topic, and get the id, question and starter.
   $request = $smcFunc['db_query']('', '
      SELECT
         t.id_member_started, p.id_poll, p.question, p.hide_results, p.expire_time, p.max_votes, p.change_vote,
         m.subject, p.guest_vote, p.id_member AS poll_starter
      FROM {db_prefix}topics AS t
         INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
         LEFT JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
      WHERE t.id_topic = {int:current_topic}
      LIMIT 1',
      array(
         'current_topic' => $topic,
      )
   );

Replace With: [Select]

if($context['is_edit'])
   {
      // Check if a poll currently exists on this topic, and get the id, question and starter.
      $request = $smcFunc['db_query']('', '
         SELECT
            t.id_member_started, p.id_poll, p.question, p.hide_results, p.expire_time, p.max_votes, p.change_vote,
            m.subject, p.guest_vote, p.id_member AS poll_starter
         FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
            LEFT JOIN {db_prefix}polls AS p ON (p.id_topic = t.id_topic)
         WHERE p.id_topic = {int:current_topic} AND (p.id_poll = {int:poll} OR p.id_poll = t.id_poll)
            ORDER BY p.id_poll DESC
         LIMIT 1',
         array(
            'current_topic' => $topic,
            'poll' => $poll
         )
      );
   }
   else
   {
      // Check if a poll currently exists on this topic, and get the id, question and starter.
      $request = $smcFunc['db_query']('', '
         SELECT
            t.id_member_started, p.id_poll, p.question, p.hide_results, p.expire_time, p.max_votes, p.change_vote,
            m.subject, p.guest_vote, p.id_member AS poll_starter
         FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
            LEFT JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
         WHERE t.id_topic = {int:current_topic}
         LIMIT 1',
         array(
            'current_topic' => $topic,
         )
      );
   }


Find: [Select]

// If we are adding a new poll - make sure that there isn't already a poll there.
   if (!$context['is_edit'] && !empty($pollinfo['id_poll']))
      fatal_lang_error('poll_already_exists');

Replace With: [Select]

/* REMEMBER TO RE-ADD CODE HERE 289347 */


Find: [Select]

elseif ($context['is_edit'] && empty($pollinfo['id_poll']))

Replace With: [Select]

if ($context['is_edit'] && empty($pollinfo['id_poll']))


Find: [Select]

global $modSettings, $user_info, $smcFunc, $sourcedir;

Add After: [Select]

   $poll = !empty($_REQUEST['poll']) ? (int)$_REQUEST['poll'] : 0;
   


Find: [Select]

// Get the starter and the poll's ID - if it's an edit.
   $request = $smcFunc['db_query']('', '
      SELECT t.id_member_started, t.id_poll, p.id_member AS poll_starter, p.expire_time
      FROM {db_prefix}topics AS t
         LEFT JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
      WHERE t.id_topic = {int:current_topic}
      LIMIT 1',
      array(
         'current_topic' => $topic,
      )
   )

Replace With: [Select]

if($isEdit)
   {
      // Check if a poll currently exists on this topic, and get the id, question and starter.
      $request = $smcFunc['db_query']('', '
         SELECT
            t.id_member_started, p.id_poll, p.question, p.hide_results, p.expire_time, p.max_votes, p.change_vote,
            m.subject, p.guest_vote, p.id_member AS poll_starter
         FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
            LEFT JOIN {db_prefix}polls AS p ON (p.id_topic = t.id_topic)
         WHERE p.id_topic = {int:current_topic} AND (p.id_poll = {int:poll} OR p.id_poll = t.id_poll)
            ORDER BY p.id_poll DESC
         LIMIT 1',
         array(
            'current_topic' => $topic,
            'poll' => $poll
         )
      );
   }
   else
   {
      // Check if a poll currently exists on this topic, and get the id, question and starter.
      $request = $smcFunc['db_query']('', '
         SELECT
            t.id_member_started
         FROM {db_prefix}topics AS t
         WHERE t.id_topic = {int:current_topic}
         LIMIT 1',
         array(
            'current_topic' => $topic,
         )
      );
   }


Find: [Select]

// Check their adding/editing is valid.
   if (!$isEdit && !empty($bcinfo['id_poll']))
      fatal_lang_error('poll_already_exists');

Replace With: [Select]

/* REMEMBER TO RE-ADD CODE HERE 892734 */


Find: [Select]

elseif ($isEdit && empty($bcinfo['id_poll']))

Replace With: [Select]

if ($isEdit && empty($bcinfo['id_poll']))


Find: [Select]

$smcFunc['db_insert']('',
         '{db_prefix}polls',
         array(
            'question' => 'string-255', 'hide_results' => 'int', 'max_votes' => 'int', 'expire_time' => 'int', 'id_member' => 'int',
            'poster_name' => 'string-255', 'change_vote' => 'int', 'guest_vote' => 'int'
         ),
         array(
            $_POST['question'], $_POST['poll_hide'], $_POST['poll_max_votes'], $_POST['poll_expire'], $user_info['id'],
            $user_info['username'], $_POST['poll_change_vote'], $_POST['poll_guest_vote'],
         ),
         array('id_poll')
      );

Replace With: [Select]

$smcFunc['db_insert']('',
         '{db_prefix}polls',
         array(
            'id_topic' => 'int', 'question' => 'string-255', 'hide_results' => 'int', 'max_votes' => 'int', 'expire_time' => 'int', 'id_member' => 'int',
            'poster_name' => 'string-255', 'change_vote' => 'int', 'guest_vote' => 'int'
         ),
         array(
            $topic, $_POST['question'], $_POST['poll_hide'], $_POST['poll_max_votes'], $_POST['poll_expire'], $user_info['id'],
            $user_info['username'], $_POST['poll_change_vote'], $_POST['poll_guest_vote'],
         ),
         array('id_poll')
      );


Find: [Select]

$smcFunc['db_query']('', '
         UPDATE {db_prefix}polls
         SET question = {string:question}, change_vote = {int:change_vote},' . (allowedTo('moderate_board') ? '
            hide_results = {int:hide_results}, expire_time = {int:expire_time}, max_votes = {int:max_votes},
            guest_vote = {int:guest_vote}' : '
            hide_results = CASE WHEN expire_time = {int:expire_time_zero} AND {int:hide_results} = 2 THEN 1 ELSE {int:hide_results} END') . '
         WHERE id_poll = {int:id_poll}',
         array(
            'change_vote' => $_POST['poll_change_vote'],
            'hide_results' => $_POST['poll_hide'],
            'expire_time' => !empty($_POST['poll_expire']) ? $_POST['poll_expire'] : 0,
            'max_votes' => !empty($_POST['poll_max_votes']) ? $_POST['poll_max_votes'] : 0,
            'guest_vote' => $_POST['poll_guest_vote'],
            'expire_time_zero' => 0,
            'id_poll' => $bcinfo['id_poll'],
            'question' => $_POST['question'],
         )
      );

Replace With: [Select]

$smcFunc['db_query']('', '
         UPDATE {db_prefix}polls
         SET id_topic = {int:current_topic},
            question = {string:question}, change_vote = {int:change_vote},' . (allowedTo('moderate_board') ? '
            hide_results = {int:hide_results}, expire_time = {int:expire_time}, max_votes = {int:max_votes},
            guest_vote = {int:guest_vote}' : '
            hide_results = CASE WHEN expire_time = {int:expire_time_zero} AND {int:hide_results} = 2 THEN 1 ELSE {int:hide_results} END') . '
         WHERE id_poll = {int:id_poll}',
         array(
            'current_topic' => $topic,
            'change_vote' => $_POST['poll_change_vote'],
            'hide_results' => $_POST['poll_hide'],
            'expire_time' => !empty($_POST['poll_expire']) ? $_POST['poll_expire'] : 0,
            'max_votes' => !empty($_POST['poll_max_votes']) ? $_POST['poll_max_votes'] : 0,
            'guest_vote' => $_POST['poll_guest_vote'],
            'expire_time_zero' => 0,
            'id_poll' => $bcinfo['id_poll'],
            'question' => $_POST['question'],
         )
      );


Find: [Select]

// Link the poll to the topic
      $smcFunc['db_query']('', '
         UPDATE {db_prefix}topics
         SET id_poll = {int:id_poll}
         WHERE id_topic = {int:current_topic}',
         array(
            'current_topic' => $topic,
            'id_poll' => $bcinfo['id_poll'],
         )
      );

Replace With: [Select]

// Link the poll to the topic
      $smcFunc['db_query']('', '
         UPDATE {db_prefix}topics
         SET id_poll = {int:id_poll}
         WHERE id_topic = {int:current_topic} AND id_poll = 0',
         array(
            'current_topic' => $topic,
            'id_poll' => $bcinfo['id_poll'],
         )
      );


Find: [Select]

global $topic, $user_info, $smcFunc;

   // Make sure the topic is not empty.

Add After: [Select]


         $poll = !empty($_REQUEST['poll']) ? (int)$_REQUEST['poll'] : 0;
   


Find: [Select]

$request = $smcFunc['db_query']('', '
         SELECT t.id_member_started, p.id_member AS poll_starter
         FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
         WHERE t.id_topic = {int:current_topic}
         LIMIT 1',
         array(
            'current_topic' => $topic,
         )
      );

Replace With: [Select]

$request = $smcFunc['db_query']('', '
         SELECT t.id_member_started, p.id_member AS poll_starter
         FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}polls AS p ON (p.id_topic = t.id_topic)
         WHERE p.id_topic = {int:current_topic} AND (p.id_poll = {int:poll} OR p.id_poll = t.id_poll)
         LIMIT 1',
         array(
            'current_topic' => $topic,
            'poll' => $poll,
         )
      );


Find: [Select]

$request = $smcFunc['db_query']('', '
      SELECT id_poll
      FROM {db_prefix}topics
      WHERE id_topic = {int:current_topic}
      LIMIT 1',
      array(
         'current_topic' => $topic,
      )
   );

Replace With: [Select]

$request = $smcFunc['db_query']('', '
      SELECT p.id_poll
      FROM {db_prefix}topics AS t
         LEFT JOIN {db_prefix}polls AS p ON (p.id_topic = t.id_topic)
      WHERE p.id_topic = {int:current_topic} AND (p.id_poll = {int:poll} OR p.id_poll = t.id_poll)
      ORDER BY p.ID_POLL DESC
      LIMIT 1',
      array(
         'current_topic' => $topic,
         'poll' => $poll
      )
   );


Find: [Select]

// Finally set the topic poll ID back to 0!
   $smcFunc['db_query']('', '
      UPDATE {db_prefix}topics
      SET id_poll = {int:no_poll}
      WHERE id_topic = {int:current_topic}',
      array(
         'current_topic' => $topic,
         'no_poll' => 0,
      )
   );

Replace With: [Select]

// Finally set the topic poll ID back to 0!
   $smcFunc['db_query']('', '
      UPDATE {db_prefix}topics
      SET id_poll = {int:no_poll}
      WHERE id_topic = {int:current_topic} AND id_poll = {int:id_poll}',
      array(
         'current_topic' => $topic,
         'no_poll' => 0,
         'id_poll' => $pollID,
      )
   );


Find: [Select]

// Take the moderator back to the topic.
   redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
}

?>

Add Before: [Select]

   if($smcFunc['db_affected_rows']() > 0)
   {
      $request = $smcFunc['db_query']('', '
         SELECT id_poll
         FROM {db_prefix}polls
         WHERE ID_TOPIC = {int:current_topic}
         LIMIT 1',
         array(
            'current_topic' => $topic
         )
      );         
      
      if($smcFunc['db_num_rows']($request) > 0)
      {
         list($pollID) = $smcFunc['db_fetch_row']($request);
         
         $smcFunc['db_free_result']($request);
         
         $smcFunc['db_query']('', '
            UPDATE {db_prefix}topics
            SET id_poll = {int:poll}
            WHERE ID_TOPIC = {int:current_topic}
            LIMIT 1',
            array(
               'current_topic' => $topic,
               'poll' => $pollID,
            )
         );
      }
   }
   



ออฟไลน์ smfTopic starter

  • "ถ้าคุณไม่สามารถอธิบายอย่างง่ายๆ ให้คนอื่นเข้าใจได้แล้วล่ะก็ แสดงว่าคุณยังเข้าใจมันไม่ดีพอ"
  • Administrator
  • Hero Member
  • *****
  • กระทู้: 1,353
  • พอยท์: 4
    • ดูรายละเอียด
    • pordoo.com
    • อีเมล์
  • คอมเมนต์สินค้า: (1)
Re: ให้ในกระทู้มีได้มากกว่า1โพล
« ตอบกลับ #2 เมื่อ: 5 พฤศจิกายน 2015, 15:56:55 »
./Sources/RemoveTopic.php
Find: [Select]

// Remove Polls.
   $request = $smcFunc['db_query']('', '
      SELECT id_poll
      FROM {db_prefix}topics
      WHERE id_topic IN ({array_int:topics})
         AND id_poll > {int:no_poll}
      LIMIT ' . count($topics),
      array(
         'no_poll' => 0,
         'topics' => $topics,
      )
   );

Replace With: [Select]

// Remove Polls.
   $request = $smcFunc['db_query']('', '
      SELECT id_poll
      FROM {db_prefix}polls
      WHERE id_topic IN ({array_int:topics})',
      array(
         'topics' => $topics,
      )
   );


./Sources/SplitTopics.php
Find: [Select]

if ($row['id_poll'] > 0)
         $polls[] = $row['id_poll'];

Replace With: [Select]

if ($row['id_poll'] > 0)
      {
         $polls[] = $row['id_poll'];
         
         $request2 = $smcFunc['db_query']('', '
            SELECT id_poll
            FROM {db_prefix}polls
            WHERE id_topic = {int:id_topic} AND id_poll != {int:id_poll}',
            array(
               'id_topic' => (int)$row['id_topic'],
               'id_poll' => (int)$row['id_poll'],
            )
         );
         
         while ($row2 = $smcFunc['db_fetch_assoc']($request2)) $polls[] = $row2['id_poll'];
         $smcFunc['db_free_result']($request2);
      
      }


Find: [Select]

SELECT t.id_topic, t.id_poll, m.subject, p.question
            FROM {db_prefix}polls AS p
               INNER JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll)
               INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)

Replace With: [Select]

SELECT t.id_topic, p.id_poll, m.subject, p.question
            FROM {db_prefix}polls AS p
               INNER JOIN {db_prefix}topics AS t ON (t.id_topic = p.id_topic)
               INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)


Find: [Select]

$target_poll = count($polls) > 1 ? (int) $_POST['poll'] : (count($polls) == 1 ? $polls[0] : 0);
   if ($target_poll > 0 && !in_array($target_poll, $polls))
      fatal_lang_error('no_access', false);
   $deleted_polls = empty($target_poll) ? $polls : array_diff($polls, array($target_poll));

Replace With: [Select]

$target_poll = array();
   if(!empty($_POST['poll']))
   {
      foreach($_POST['poll'] as $poll)
      {
         $poll = (int) $poll;
         if ($poll > 0 && !in_array($poll, $polls))
            fatal_lang_error(1, false);
         $target_poll[] = $poll;
      }
   }
   
   $deleted_polls = array_diff($polls, $target_poll);


Find: [Select]

   // Grab the response prefix (like 'Re: ') in the default forum language.

Add Before: [Select]

   
   foreach($target_poll as $poll)
   {
      $smcFunc['db_query'] ('', '
         UPDATE `{db_prefix}polls`
         SET `id_topic` = {int:id_topic}
         WHERE `id_poll` = {int:id_poll}',
            array(
                'id_topic' => (int)$id_topic,
            'id_poll' => (int)$poll,
            )
        );
   }
   


Find: [Select]

'id_poll' => $target_poll,

Replace With: [Select]

'id_poll' => (empty($target_poll) ? 0 : min($target_poll)),


./Themes/default/SplitTopics.template.php
Find: [Select]

<input type="radio" name="poll" value="'

Replace With: [Select]

<input type="checkbox" name="poll[]" value="'


Find: [Select]

<li>
                        <input type="radio" name="poll" value="-1" class="input_radio" /> (' . $txt['merge_no_poll'] . ')
                     </li>

Replace With: [Select]

', /* REMEMBER TO RE-ADD CODE HERE 2309478 */'


./Themes/default/Display.template.php
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.Add After:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Add After:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Add Before:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.         


Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

./Sources/RepairBoards.php
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

./Sources/Subs-Post.php
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Add Before:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
./Themes/default/css/index.css
Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.

Find:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Replace With:
โค๊ด:
Only registered users can see contents. Please click here to Register or Login.
Code
install2.php
This file should be able to execute standalone.

แท็ก:
 
แชร์บทความ...
โค้ดแบบ forum
(BBCode)
โค้ดแบบ site/blog
(HTML)


anything