| 1 | <? |
|---|
| 2 | |
|---|
| 3 | /***************************************************************************
|
|---|
| 4 | * Dolphin Smart Community Builder
|
|---|
| 5 | * -----------------
|
|---|
| 6 | * begin : Mon Mar 23 2006
|
|---|
| 7 | * copyright : (C) 2006 BoonEx Group
|
|---|
| 8 | * website : http://www.boonex.com/
|
|---|
| 9 | * This file is part of Dolphin - Smart Community Builder
|
|---|
| 10 | *
|
|---|
| 11 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
|
|---|
| 12 | * http://creativecommons.org/licenses/by/3.0/
|
|---|
| 13 | *
|
|---|
| 14 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|---|
| 15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 16 | * See the Creative Commons Attribution 3.0 License for more details.
|
|---|
| 17 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
|
|---|
| 18 | * see license.txt file; if not, write to marketing@boonex.com
|
|---|
| 19 | ***************************************************************************/
|
|---|
| 20 | |
|---|
| 21 | require_once( 'inc/header.inc.php' ); |
|---|
| 22 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' ); |
|---|
| 23 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' ); |
|---|
| 24 | |
|---|
| 25 | // --------------- page variables |
|---|
| 26 | |
|---|
| 27 | $_page['name_index'] = 28; |
|---|
| 28 | $_page['css_name'] = 'polls.css'; |
|---|
| 29 | |
|---|
| 30 | $logged['member'] = member_auth( 0, false ); |
|---|
| 31 | |
|---|
| 32 | $_page['header'] = _t( "_Site Polls" ); |
|---|
| 33 | $_page['header_text'] = _t( "_Site Polls" ); |
|---|
| 34 | |
|---|
| 35 | // this is dynamic page - send headers to do not cache this page |
|---|
| 36 | send_headers_page_changed(); |
|---|
| 37 | |
|---|
| 38 | // --------------- page components |
|---|
| 39 | |
|---|
| 40 | $_ni = $_page['name_index']; |
|---|
| 41 | $_page_cont[$_ni]['page_main_code'] = MemberPrintPolls( ); |
|---|
| 42 | |
|---|
| 43 | // --------------- [END] page components |
|---|
| 44 | |
|---|
| 45 | PageCode(); |
|---|
| 46 | |
|---|
| 47 | // --------------- page components functions |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * page code function |
|---|
| 51 | */ |
|---|
| 52 | function MemberPrintPolls( ) |
|---|
| 53 | { |
|---|
| 54 | $query = "SELECT `ID`, `Question` FROM `polls_q` WHERE `Active` = 'on' ORDER BY `Question`"; |
|---|
| 55 | |
|---|
| 56 | $res = db_res($query); |
|---|
| 57 | |
|---|
| 58 | if ( !$res or !mysql_num_rows($res) ) |
|---|
| 59 | return "<div align=center>". _t("_No polls available") ."</div>"; |
|---|
| 60 | |
|---|
| 61 | $ret = |
|---|
| 62 | '<div style="position:relative;"> |
|---|
| 63 | <div class="clear_both"></div>'; |
|---|
| 64 | |
|---|
| 65 | while ( $arr = mysql_fetch_array($res)) |
|---|
| 66 | $ret .= MemberPrintPoll( $arr['ID'] ); |
|---|
| 67 | |
|---|
| 68 | $ret .= |
|---|
| 69 | '<div class="clear_both"></div> |
|---|
| 70 | </div>'; |
|---|
| 71 | |
|---|
| 72 | return $ret; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | function MemberPrintPoll( $ID ) |
|---|
| 76 | { |
|---|
| 77 | |
|---|
| 78 | $queryQuestion = "SELECT `Question` FROM `polls_q` WHERE `Active` = 'on' AND `ID` = $ID"; |
|---|
| 79 | $queryAnswers = "SELECT `IDanswer`, `Answer`, `Votes` FROM `polls_a` WHERE `ID` = $ID"; |
|---|
| 80 | |
|---|
| 81 | $aQuestion = db_arr( $queryQuestion ); |
|---|
| 82 | $rAnswers = db_res( $queryAnswers ); |
|---|
| 83 | |
|---|
| 84 | if ( !$aQuestion or !mysql_num_rows($rAnswers) ) |
|---|
| 85 | return _t_err("_Poll not available"); |
|---|
| 86 | |
|---|
| 87 | $aVotes = db_arr( "SELECT SUM(`Votes`) FROM `polls_a` WHERE `ID` = $ID" ); |
|---|
| 88 | $iTotalVotes = (int)$aVotes[0]; |
|---|
| 89 | |
|---|
| 90 | ob_start(); |
|---|
| 91 | ?> |
|---|
| 92 | <div class="tableVote_wrapper"> |
|---|
| 93 | <form method="post" name="FormVote" action="poll.php"> |
|---|
| 94 | <input type="hidden" name="ID" value="<?=$ID?>" /> |
|---|
| 95 | <table class="tableVote"> |
|---|
| 96 | <tr><th colspan="2"><?=process_line_output( $aQuestion['Question'] )?></th> |
|---|
| 97 | </tr> |
|---|
| 98 | <? |
|---|
| 99 | |
|---|
| 100 | $j = 1; |
|---|
| 101 | while ( $aAnswer = mysql_fetch_array($rAnswers) ) |
|---|
| 102 | { |
|---|
| 103 | if( ($j%2) == 0) |
|---|
| 104 | $add = '2'; |
|---|
| 105 | else |
|---|
| 106 | $add = '1'; |
|---|
| 107 | |
|---|
| 108 | ?> |
|---|
| 109 | <tr> |
|---|
| 110 | <td> |
|---|
| 111 | <input type="radio" onclick="javascript: this.form.submit()" name="vote" |
|---|
| 112 | value="<?=$aAnswer['IDanswer']?>" ID="l<?=$aAnswer['IDanswer']?>" /> |
|---|
| 113 | <label for="l<?=$aAnswer['IDanswer']?>"><?=process_line_output( $aAnswer['Answer'] )?></label> |
|---|
| 114 | </td> |
|---|
| 115 | <td><?=DesignProgressPos( _t("_votes").": ".$aAnswer['Votes'], 100, $iTotalVotes, $aAnswer['Votes'], $add )?></td> |
|---|
| 116 | </tr> |
|---|
| 117 | <? |
|---|
| 118 | $j++; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | ?> |
|---|
| 122 | </table> |
|---|
| 123 | </form> |
|---|
| 124 | </div> |
|---|
| 125 | <? |
|---|
| 126 | |
|---|
| 127 | return ob_get_clean(); |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | ?> |
|---|