Changeset 39


Ignore:
Timestamp:
Apr 19, 2007, 3:26:39 PM (11 years ago)
Author:
julian
Message:
  • EditTopic?.class.php now also edits the poll
  • fixed a small bug in core
  • improved Functions::getSGValues() to handle standard value exceptions
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/Core.class.php

    r37 r39  
    4040            $_REQUEST = Functions::addSlashes($_REQUEST);
    4141        }
    42         if(isset($_POST['p']) == FALSE || is_array($_POST['p']) == FALSE) $_POST['p'] = array();
    43         if(isset($_POST['c']) == FALSE || is_array($_POST['c']) == FALSE) $_POST['c'] = array();
    44         if(isset($_GET['doIt'])) {
    45             while(list($curKey) = each($_POST['c'])) {
    46                 $_POST['c'][$curKey] = 1;
    47             }
     42        if(!isset($_POST['p']) || !is_array($_POST['p'])) $_POST['p'] = array();
     43        if(!isset($_POST['c']) || !is_array($_POST['c'])) $_POST['c'] = array();
     44        if(isset($_GET['doit'])) {
     45            foreach($_POST['c'] AS &$curValue)
     46                $curValue = 1;
    4847        }
    4948
  • trunk/core/Functions.class.php

    r37 r39  
    6363
    6464        while(list(,$curValue) = each($KeysArray)) {
    65             $ValuesArray[$curValue] = isset($SGVar[$curValue]) ? $SGVar[$curValue] : (isset($stdValues[$curValue]) ? $stdValues[$curValue] : $stdValue);
     65            if(is_array($curValue)) $ValuesArray[$curValue[0]] = isset($SGVar[$curValue[0]]) ? $SGVar[$curValue[0]] : (isset($stdValues[$curValue[0]]) ? $stdValues[$curValue[0]] : $curValue[1]);
     66            else $ValuesArray[$curValue] = isset($SGVar[$curValue]) ? $SGVar[$curValue] : (isset($stdValues[$curValue]) ? $stdValues[$curValue] : $stdValue);
    6667        }
    6768
  • trunk/languages/de/EditTopic.language

    r24 r39  
    55Topic_moved = Thema verschoben
    66error_invalid_forum = Bitte wählen Sie ein gültiges Forum aus
     7error_poll_title_missing = Bitte geben Sie einen gültigen Titel für die Umfrage an
     8error_poll_option_missing = Bitte geben Sie gültige Antwortmöglichkeiten an
     9error_invalid_poll_duration = Bitte geben Sie eine gültige Umfragedauer an
  • trunk/modules/EditTopic.class.php

    r38 r39  
    3737
    3838            $p = Functions::getSGValues($_POST['p'],array('topicTitle','smileyID'),'',Functions::addSlashes($topicData));
     39            $c = array();
     40
     41            if($topicData['topicHasPoll'] == 1) {
     42                $this->modules['Language']->addFile('Posting');
     43
     44                $this->modules['DB']->query("SELECT * FROM ".TBLPFX."polls WHERE topicID='$topicID'");
     45                $pollData = $this->modules['DB']->fetchArray();
     46                $pollID = &$pollData['pollID'];
     47
     48                $this->modules['DB']->query("SELECT * FROM ".TBLPFX."polls_options WHERE pollID='$pollID' ORDER BY optionID ASC");
     49                $optionsData = $this->modules['DB']->raw2Array();
     50
     51                $p['optionsData'] = array();
     52
     53                foreach($optionsData AS $curOption)
     54                    $p['optionsData'][$curOption['optionID']] = isset($_POST['p']['optionsData'][$curOption['optionID']]) ? $_POST['p']['optionsData'][$curOption['optionID']] : Functions::addSlashes($curOption['optionTitle']);
     55
     56                $p['pollDuration'] = isset($_POST['p']['pollDuration']) ? intval($_POST['p']['pollDuration']) : (($pollData['pollEndTimestamp']-$pollData['pollStartTimestamp'])/86400);
     57
     58                $p += Functions::getSGValues($_POST['p'],array('pollTitle'),'',Functions::addSlashes($pollData));
     59                $c = Functions::getSGValues($pollData,array('pollGuestsVote','pollShowResultsAfterEnd','pollGuestsViewResults'),0);
     60
     61                $this->modules['Template']->assign('optionsData',$optionsData);
     62            }
    3963
    4064            if(isset($_GET['doit'])) {
     65                if($topicData['topicHasPoll'] == 1) {
     66                    $optionTitleMissing = FALSE;
     67                    foreach($p['optionsData'] AS $curOption) {
     68                        if(trim($curOption) == '') {
     69                            $optionTitleMissing = TRUE;
     70                            break;
     71                        }
     72                    }
     73                }
     74
     75                $c = Functions::getSGValues($_POST['c'],array('pollGuestsVote','pollShowResultsAfterEnd','pollGuestsViewResults'),0);
     76
    4177                if(trim($p['topicTitle']) == '') $error = $this->modules['Language']->getString('error_no_title');
     78                elseif($topicData['topicHasPoll'] == 1 && trim($p['pollTitle']) == '') $error = $this->modules['Language']->getString('error_poll_title_missing');
     79                elseif($topicData['topicHasPoll'] == 1 && $optionTitleMissing) $error = $this->modules['Language']->getString('error_poll_option_missing');
     80                elseif($topicData['topicHasPoll'] == 1 && $p['pollDuration'] <= 0) $error = $this->modules['Language']->getString('error_invalid_poll_duration');
    4281                else {
    4382                    $this->modules['DB']->query("
     
    61100                    ");
    62101
     102                    if($topicData['topicHasPoll'] == 1) {
     103                        $this->modules['DB']->query("
     104                            UPDATE
     105                                ".TBLPFX."polls
     106                            SET
     107                                pollTitle='".$p['pollTitle']."',
     108                                pollEndTimestamp='".($pollData['pollStartTimestamp']+$p['pollDuration']*86400)."',
     109                                pollGuestsVote='".$c['pollGuestsVote']."',
     110                                pollGuestsViewResults='".$c['pollGuestsViewResults']."',
     111                                pollShowResultsAfterEnd='".$c['pollShowResultsAfterEnd']."'
     112                            WHERE
     113                                pollID='$pollID'
     114                        ");
     115
     116                        foreach($p['optionsData'] AS $curKey => $curValue)
     117                            $this->modules['DB']->query("UPDATE ".TBLPFX."polls_options SET optionTitle='".$curValue."' WHERE pollID='$pollID' AND optionID='$curKey'");
     118                    }
     119
    63120                    Functions::myHeader(INDEXFILE."?action=ViewTopic&topicID=$topicID&".MYSID);
    64121                }
     
    71128            $this->modules['Template']->assign(array(
    72129                'p'=>Functions::HTMLSpecialChars(Functions::stripSlashes($p)),
     130                'c'=>$c,
    73131                'error'=>$error,
    74132                'postPicsBox'=>$postPicsBox,
    75                 'topicID'=>$topicID
     133                'topicID'=>$topicID,
     134                'topicData'=>$topicData
    76135            ));
    77136            $this->modules['PageParts']->printPage('EditTopicEdit.tpl');
  • trunk/templates/std/files/EditTopicEdit.tpl

    r21 r39  
    11<form method="post" action="{$indexFile}?action=EditTopic&amp;mode=Edit&amp;topicID={$topicID}&amp;doit=1&amp;{$mySID}">
    22<table class="TableStd" width="100%">
     3<colgroup>
     4 <col width="23%"/>
     5 <col width="77%"/>
     6</colgroup>
    37<tr><td class="CellTitle" colspan="2"><span class="FontTitle">{$modules.Language->getString('Edit_topic')}</span></td></tr>
    4 {if $error != ''}<tr><td class="CellError" colspan="2"><img src="{$modules.Template->getTD()}/images/icons/Warning.png" alt=""/><span class="FontError">{$error}</span></td></tr>{/if}
     8{if $error != ''}<tr><td class="CellError" colspan="2"><img class="ImageIcon" src="{$modules.Template->getTD()}/images/icons/Warning.png" alt=""/><span class="FontError">{$error}</span></td></tr>{/if}
     9<tr><td class="CellCat" colspan="2"><span class="FontCat">{$modules.Language->getString('Topic')}</span></td></tr>
    510<tr>
    611 <td class="CellStd" valign="top"><span class="FontNorm">{$modules.Language->getString('Post_pic')}:</span></td>
     
    1116 <td class="CellAlt"><input class="FormText" type="text" size="65" name="p[topicTitle]" value="{$p.topicTitle}"/></td>
    1217</tr>
     18{if $topicData.topicHasPoll}
     19 <tr><td class="CellCat" colspan="2"><span class="FontCat">{$modules.Language->getString('Poll')}</span></td></tr>
     20 <tr>
     21  <td class="CellStd" valign="top"><span class="FontNorm">{$modules.Language->getString('Poll_title')}:</span><br/><span class="FontSmall">{$modules.Language->getString('add_poll_info')}</span></td>
     22  <td class="CellAlt" valign="top"><input class="FormText" type="text" name="p[pollTitle]" maxlength="255" size="60" value="{$p.pollTitle}"/></td>
     23 </tr>
     24 <tr>
     25  <td class="CellStd" valign="top"><span class="FontNorm">{$modules.Language->getString('Poll_duration')}:</span></td>
     26  <td class="CellAlt" valign="top"><input class="FormText" size="5" name="p[pollDuration]" value="{$p.pollDuration}"/> <span class="FontSmall">({$modules.Language->getString('in_days')})</span></td>
     27 </tr>
     28 <tr>
     29  <td class="CellStd" valign="top"><span class="FontNorm">{$modules.Language->getString('Options')}:</span></td>
     30  <td class="CellAlt" valign="top"><span class="FontNorm">
     31   <label><input class="FormCheckbox" type="checkbox" name="c[pollShowResultsAfterEnd]"{if $c.pollShowResultsAfterEnd == 1} checked="checked"{/if}/>&nbsp;{$modules.Language->getString('Show_results_after_end')}</label>
     32   <br/><label><input class="FormCheckbox" type="checkbox" name="c[pollGuestsVote]"{if $c.pollGuestsVote == 1} checked="checked"{/if}/>&nbsp;{$modules.Language->getString('Guests_allowed_vote')}</label>
     33   <br/><label><input class="FormCheckbox" type="checkbox" name="c[pollGuestsViewResults]"{if $c.pollGuestsViewResults == 1} checked="checked"{/if}/>&nbsp;{$modules.Language->getString('Guests_allowed_view_results')}</label>
     34  </span></td>
     35 </tr>
     36 <tr>
     37  <td class="CellStd" valign="top"><span class="FontNorm">{$modules.Language->getString('Poll_options')}:</span></td>
     38  <td class="CellAlt" valign="top">
     39   <table>
     40   {foreach from=$optionsData item=curOption}
     41    {assign var=curOptionID value=$curOption.optionID}
     42    <tr><td style="padding:3px;"><input type="text" class="FormText" size="30" value="{$p.optionsData.$curOptionID}" name="p[optionsData][{$curOption.optionID}]""/></td></tr>
     43   {/foreach}
     44   </table>
     45  </td>
     46 </tr>
     47{/if}
    1348<tr><td class="CellButtons" colspan="2" align="center"><input class="FormBButton" type="submit" value="{$modules.Language->getString('Edit_topic')}"/>&nbsp;&nbsp;&nbsp;<input class="FormButton" type="reset" value="{$modules.Language->getString('Reset')}"/></td></tr>
    1449</table>
  • trunk/templates/std/files/ForumIndex.tpl

    r37 r39  
    1515            if(closedCatIDs[i] == catID) {
    1616                closedCatIDs.splice(i,1);
    17                 setCookieValue("ClosedCatIDs",closedCatIDs.join("."));
     17                setCookieValue("closedCatIDs",closedCatIDs.join("."));
    1818                break;
    1919            }
  • trunk/templates/std/files/styles/ts_tbb2_standard.css

    r37 r39  
    345345td.CellNav:hover {
    346346    background-color:#E5F3FF;
    347     border:1px #4169E1 dotted;
     347    border:1px #4169E1 dashed;
    348348    cursor:pointer;
    349349    padding:2px;
Note: See TracChangeset for help on using the changeset viewer.