Changeset 706

Show
Ignore:
Timestamp:
11/09/08 16:45:24 (5 years ago)
Author:
MDMAN
Message:

racing-league modified

Location:
racing.league
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • racing.league/files/lib/form/RacingLeaguePunishForm.class.php

    r699 r706  
    11<?php 
    22// wcf imports 
    3 require_once(WCF_DIR.'lib/form/RacingLeagueResultsForm.class.php'); 
     3require_once(WCF_DIR.'lib/form/RacingLeagueForm.class.php'); 
    44 
    55/** 
     
    1212 */ 
    1313 
    14 class RacingLeaguePunishForm extends RacingLeagueResultsForm { 
     14class RacingLeaguePunishForm extends RacingLeagueForm { 
    1515  
    1616        public $templateName = 'racingLeaguePunish'; 
    17         public $punishRaceID = 0; 
     17        public $saisonID = 0; 
     18        public $editPunishID = 0; 
     19        public $newPunish = 0; 
    1820        public $punish = array(); 
    1921        public $addPunish = 0; 
     22        public $raceID = 0; 
     23        public $driver = 0; 
     24        public $minusPoints = ''; 
     25        public $punishReason = ''; 
     26         
     27        public $drivedRaces = array(); 
    2028         
    2129        public $redirect = 'RacingLeaguePunish'; 
    22          
     30 
    2331        /** 
    2432         * @see Form::readParameters() 
     
    2634        public function readParameters() { 
    2735                parent::readParameters(); 
    28                  
    29                 if (isset($_REQUEST["punishRaceID"]))   $this->punishRaceID = intval($_REQUEST["punishRaceID"]); 
    30                 if (isset($_REQUEST["addPunish"]))      $this->addPunish = intval($_REQUEST["addPunish"]);               
     36 
     37                if (isset($_REQUEST["saisonID"]))               $this->saisonID = intval($_REQUEST["saisonID"]); 
     38                if (isset($_REQUEST["editPunishID"]))   $this->editPunishID = intval($_REQUEST["editPunishID"]); 
     39                if (isset($_REQUEST["addPunish"]))              $this->addPunish = intval($_REQUEST["addPunish"]); 
     40                if (isset($_REQUEST["raceID"]))         $this->raceID = intval($_REQUEST["raceID"]); 
    3141                                         
    3242        } 
     
    3848                parent::readFormParameters(); 
    3949                 
    40                                  
     50                if (isset($_POST["raceID"]))    $this->raceID = intval($_POST["raceID"]); 
     51                if (isset($_POST["driver"]))    $this->driver = intval($_POST["driver"]); 
     52                if (isset($_POST["minusPoints"]))       $this->minusPoints = intval($_POST["minusPoints"]); 
     53                if (isset($_POST["punishReason"]))      $this->punishReason = StringUtil::trim($_POST["punishReason"]); 
     54 
    4155        } 
    4256         
     
    4761                parent::validate(); 
    4862 
    49                                                  
     63                // driver 
     64                if (empty($this->driver)) { 
     65                        throw new UserInputException('driver'); 
     66                } 
     67 
     68                // punishReason 
     69                if (empty($this->punishReason)) { 
     70                        throw new UserInputException('punishReason'); 
     71                }                                
    5072        } 
    5173 
     
    5880                // Hier werden alle Rennen inklusive Strafen geladen 
    5981                if ($this->activeSaisonID != 0) { 
    60                         $sql = "SELECT  `a`.`saisonID`, 
    61                                                 `a`.`raceID`, 
    62                                                 `a`.`raceNo`, 
    63                                                 `a`.`raceName`, 
    64                                                 `a`.`drived`, 
    65                                                 `b`.`punishID`, 
    66                                                 `b`.`raceID`, 
    67                                                 `b`.`userID`, 
    68                                                 `b`.`minusPoints`, 
    69                                                 `b`.`punishReason` 
    70                                         FROM `wcf".WCF_N."_racing_races` AS `a` 
    71                                         LEFT JOIN `wcf".WCF_N."_racing_punish` AS `b` 
    72                                         ON              (`b`.`raceID` = `a`.`raceID`) 
    73                                         AND             (`b`.saisonID = '".$this->activeSaisonID."') 
    74                                         WHERE           `a`.`raceID` = '".$this->editRaceID."' 
    75                                         AND             `a`.saisonID = '".$this->activeSaisonID."' 
    76                                         AND             `b`.saisonID = '".$this->activeSaisonID."' 
    77                                         ORDER BY `raceNo` ASC 
    78                                         "; 
     82                         
     83                } 
     84 
     85                if ($this->activeSaisonID != 0 && $this->addPunish == 1) { 
     86                        // Hier werden alle gefahrenen Rennen geladen (drived = 1) 
     87                        $sql = "SELECT * 
     88                                FROM `wcf".WCF_N."_racing_races` 
     89                                WHERE `saisonID` = '".$this->activeSaisonID."' 
     90                                AND `drived` = '1' 
     91                                ORDER BY `raceNO` ASC 
     92                                ";               
    7993                         
    8094                        $res = WCF::getDB()->sendQuery($sql); 
    8195 
    8296                        while ($row = WCF::getDB()->fetchArray($res)) { 
    83                                 $this->punish[] = $row; 
    84                         } 
     97                                $this->drivedRaces[] = $row; 
     98                        }                        
    8599                } 
     100                 
     101                if ($this->activeSaisonID != 0 && $this->raceID > 0) { 
    86102 
    87                  
    88  
    89  
    90                 if ($this->activeSaisonID != 0 && $this->punishRaceID != 0) { 
    91103                         
    92                                          
    93                          
    94                 }        
    95                                          
     104                }                        
    96105                 
    97106        } 
     
    102111        public function save() { 
    103112                parent::save(); 
    104                                  
     113 
     114                if ($this->addPunish == 1 && isset($this->driver) && isset($this->minusPoints) && isset($this->punishReason) && $this->raceID > 0 && $this->activeSaisonID != 0) { 
    105115                 
     116                        $sql = "INSERT INTO `wcf".WCF_N."_racing_punish` 
     117                                (`saisonID`, `raceID`, `userID`, `minusPoints`, `punishReason`) 
     118                                VALUES ('".escapeString($this->activeSaisonID)."', '".escapeString($this->raceID)."', '".escapeString($this->driver)."', '".escapeString($this->minusPoints)."', '".escapeString($this->punishReason)."') 
     119                                "; 
     120 
     121                        $res = WCF::getDB()->sendQuery($sql); 
     122 
     123                        $row = 0; 
     124                        $row = WCF::getDB()->getAffectedRows($res); 
     125                        $this->addPunish = 0; 
     126                        $this->raceID = 0; 
     127                        if ($row > 0) {                          
     128                                WCF::getTPL()->append('userMessages', WCF::getTPL()->fetch('racingLeagueNewSuccess')); 
     129                        } 
     130                        else { 
     131                                WCF::getTPL()->append('userMessages', WCF::getTPL()->fetch('racingLeagueNewError')); 
     132                        } 
     133                         
     134                }        
    106135        }        
    107136         
     
    113142 
    114143                WCF::getTPL()->assign(array( 
    115                         'punishRaceID' => $this->punishRaceID, 
     144                        'saisonID' => $this->saisonID, 
     145                        'editPunishID' => $this->editPunishID, 
    116146                        'punish' => $this->punish, 
    117147                        'addPunish' => $this->addPunish, 
     148                        'drivedRaces' => $this->drivedRaces, 
     149                        'raceID' => $this->raceID, 
     150                        'driver' => $this->driver, 
    118151                                                                         
    119152                        'redirect' => $this->redirect 
  • racing.league/templates/racingLeaguePunish.tpl

    r699 r706  
    3737        {if $saisons.$activeSaisonID|isset}<p class="info">{lang}wcf.racing.league.saison.selected{/lang}</p>{/if} 
    3838 
    39         {if $addPunish == 1} 
    40         <form method="post" action="index.php?form=RacingLeaguePunish{@SID_ARG_2ND}&amp;newResults=1&amp;raceID={$raceID}"> 
     39        {if $addPunish == 1 && $raceID == 0} 
     40        //hier wird das Rennen ausgewÀhlt, in der die Straftat gefahren wurde 
     41        <form method="post" action="index.php?form=RacingLeaguePunish{@SID_ARG_2ND}&amp;addPunish=1"> 
    4142        <div class="border content"> 
    4243                <div class="container-1">                
    43                 <h3 class="subHeadline"><img src="{@RELATIVE_WCF_DIR}icon/saisonS.png" alt="" /> {lang}wcf.racing.league.punish.newPunish{/lang}</h3> 
    44                         <p class="description">{lang}wcf.racing.league.punish.newPunish.description{/lang}</p>                                           
     44                <h3 class="subHeadline"><img src="{@RELATIVE_WCF_DIR}icon/saisonWarningAddS.png" alt="" /> {lang}wcf.racing.league.punish.addPunish{/lang}</h3> 
     45                        <p class="description">{lang}wcf.racing.league.punish.addPunish.description{/lang}</p>                                           
    4546                <br /> 
    46                         {$raceName} 
    47                         <div class="formElement{if $errorField == 'place'} formError{/if}"> 
    48                                 <div class="formFieldLabel"> 
    49                                         <label for="place">{lang}wcf.racing.league.newResult{/lang}</label> 
    50                                 </div> 
    51                                 <div class="formField"> 
    52                                  
    53                                 {foreach from=$places item=value} 
    54                                 {$value.place} 
    55                                 <select name='result[{$value.place}]'> 
    56                                         <option value=''> ---------- <option> 
    57                                         {foreach from=$users item=user} 
    58                                                 <option value='{$user.userID}'> {$user.username} </option> 
    59                                         {/foreach} 
     47                        <div class="formElement{if $errorField == 'punishRace'} formError{/if}"> 
     48                                <div class="formFieldLabel"> 
     49                                        <label for="punishRace">{lang}wcf.racing.league.addPunish.racename{/lang}</label> 
     50                                </div> 
     51                                <div class="formField"> 
     52                                 
     53                                <select name='raceID'> 
     54                                {foreach from=$drivedRaces item=value} 
     55                                        <option value='{$value.raceID}'>{$value.raceName}<option>                                
     56                                {/foreach} 
    6057                                </select> 
    61                                 <br /> 
    62                                 {/foreach} 
    63                                  
    64                                 {if $errorField == 'result'} 
     58                                 
     59                                 
     60                                {if $errorField == 'punishRace'} 
    6561                                        <p class="innerError"> 
    6662                                                {if $errorType == 'empty'}{lang}wcf.global.error.empty{/lang}{/if} 
     
    7975        {/if} 
    8076 
    81         {if $editRaceID > 0} 
    82         <form method="post" action="index.php?form=RacingLeagueResults{@SID_ARG_2ND}&amp;editRaceID={$editRaceID}&amp;edit=1"> 
     77        {if $addPunish == 1 && $raceID > 0} 
     78        //hier kann man die Strafe einem Fahrer zuordnen und den Grund sowie die Minuspunkte deklarieren. 
     79        <form method="post" action="index.php?form=RacingLeaguePunish{@SID_ARG_2ND}&amp;addPunish=1&amp;raceID={$raceID}"> 
     80        <div class="border content"> 
     81                <div class="container-1">                
     82                <h3 class="subHeadline"><img src="{@RELATIVE_WCF_DIR}icon/saisonWarningAddS.png" alt="" /> {lang}wcf.racing.league.punish.addaddPunish{/lang}</h3> 
     83                        <p class="description">{lang}wcf.racing.league.punish.addaddPunish.description{/lang}</p>                                                
     84                <br /> 
     85                        <div class="formElement{if $errorField == 'driver'} formError{/if}"> 
     86                                <div class="formFieldLabel"> 
     87                                        <label for="driver">{lang}wcf.racing.league.addPunish.driver{/lang}</label> 
     88                                </div> 
     89                                <div class="formField"> 
     90                                 
     91                                <select name='driver'> 
     92                                        <option value="">----------</option> 
     93                                {foreach from=$users item=value} 
     94                                        <option value='{$value.userID}' {if $driver == $value.userID}selected{/if}>{$value.username}<option>                             
     95                                {/foreach} 
     96                                </select> 
     97                                <br /> 
     98                                 
     99                                {if $errorField == 'driver'} 
     100                                        <p class="innerError"> 
     101                                                {if $errorType == 'empty'}{lang}wcf.global.error.empty{/lang}{/if} 
     102                                        </p> 
     103                                {/if} 
     104                                </div> 
     105                        </div> 
     106 
     107                        <div class="formElement{if $errorField == 'minusPoints'} formError{/if}"> 
     108                                <div class="formFieldLabel"> 
     109                                        <label for="minusPoints">{lang}wcf.racing.league.addPunish.minusPoints{/lang}</label> 
     110                                </div> 
     111                                <div class="formField"> 
     112                                        <input type="text" class="inputText" name="minusPoints" id="minusPoints" value="0" /> 
     113                                 
     114                                {if $errorField == 'minusPoints'} 
     115                                        <p class="innerError"> 
     116                                                {if $errorType == 'empty'}{lang}wcf.global.error.empty{/lang}{/if} 
     117                                        </p> 
     118                                {/if} 
     119                                </div> 
     120                        </div> 
     121 
     122                        <div class="formElement{if $errorField == 'punishReason'} formError{/if}"> 
     123                                <div class="formFieldLabel"> 
     124                                        <label for="punishReason">{lang}wcf.racing.league.addPunish.punishReason{/lang}</label> 
     125                                </div> 
     126                                <div class="formField"> 
     127                                        <textarea rows="8" cols="20" name="punishReason" id="punishReason"></textarea>                           
     128                                {if $errorField == 'punishReason'} 
     129                                        <p class="innerError"> 
     130                                                {if $errorType == 'empty'}{lang}wcf.global.error.empty{/lang}{/if} 
     131                                        </p> 
     132                                {/if} 
     133                                </div> 
     134                        </div> 
     135 
     136                                                 
     137                </div> 
     138        </div> 
     139        <div class="formSubmit"> 
     140                <input type="submit" accesskey="s" value="{lang}wcf.global.button.submit{/lang}" /> 
     141                <input type="reset" accesskey="r" value="{lang}wcf.global.button.reset{/lang}" /> 
     142                {@SID_INPUT_TAG} 
     143        </div> 
     144        </form> 
     145        {/if} 
     146 
     147        {if $editPunishID > 0} 
     148        <form method="post" action="index.php?form=RacingLeaguePunish{@SID_ARG_2ND}&amp;editPunishID={$editPunishID}&amp;edit=1"> 
    83149        <div class="border content"> 
    84150                <div class="container-1">                
     
    183249        {/if} 
    184250 
    185         {if $groupID == 0} 
    186  
    187         <div class="formField"> 
    188                 <p class="info" id="results.noGroup"> 
    189                 {lang}wcf.racing.league.results.noGroup{/lang} 
    190                 </p> 
    191         </div> 
    192  
    193         {/if} 
    194  
    195251        {if $saisons|count} 
    196252        <div class="largeButtons">