Changeset 706
- Timestamp:
- 11/09/08 16:45:24 (5 years ago)
- Location:
- racing.league
- Files:
-
- 2 modified
-
files/lib/form/RacingLeaguePunishForm.class.php (modified) (8 diffs)
-
templates/racingLeaguePunish.tpl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
racing.league/files/lib/form/RacingLeaguePunishForm.class.php
r699 r706 1 1 <?php 2 2 // wcf imports 3 require_once(WCF_DIR.'lib/form/RacingLeague ResultsForm.class.php');3 require_once(WCF_DIR.'lib/form/RacingLeagueForm.class.php'); 4 4 5 5 /** … … 12 12 */ 13 13 14 class RacingLeaguePunishForm extends RacingLeague ResultsForm {14 class RacingLeaguePunishForm extends RacingLeagueForm { 15 15 16 16 public $templateName = 'racingLeaguePunish'; 17 public $punishRaceID = 0; 17 public $saisonID = 0; 18 public $editPunishID = 0; 19 public $newPunish = 0; 18 20 public $punish = array(); 19 21 public $addPunish = 0; 22 public $raceID = 0; 23 public $driver = 0; 24 public $minusPoints = ''; 25 public $punishReason = ''; 26 27 public $drivedRaces = array(); 20 28 21 29 public $redirect = 'RacingLeaguePunish'; 22 30 23 31 /** 24 32 * @see Form::readParameters() … … 26 34 public function readParameters() { 27 35 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"]); 31 41 32 42 } … … 38 48 parent::readFormParameters(); 39 49 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 41 55 } 42 56 … … 47 61 parent::validate(); 48 62 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 } 50 72 } 51 73 … … 58 80 // Hier werden alle Rennen inklusive Strafen geladen 59 81 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 "; 79 93 80 94 $res = WCF::getDB()->sendQuery($sql); 81 95 82 96 while ($row = WCF::getDB()->fetchArray($res)) { 83 $this-> punish[] = $row;84 } 97 $this->drivedRaces[] = $row; 98 } 85 99 } 100 101 if ($this->activeSaisonID != 0 && $this->raceID > 0) { 86 102 87 88 89 90 if ($this->activeSaisonID != 0 && $this->punishRaceID != 0) {91 103 92 93 94 } 95 104 } 96 105 97 106 } … … 102 111 public function save() { 103 112 parent::save(); 104 113 114 if ($this->addPunish == 1 && isset($this->driver) && isset($this->minusPoints) && isset($this->punishReason) && $this->raceID > 0 && $this->activeSaisonID != 0) { 105 115 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 } 106 135 } 107 136 … … 113 142 114 143 WCF::getTPL()->assign(array( 115 'punishRaceID' => $this->punishRaceID, 144 'saisonID' => $this->saisonID, 145 'editPunishID' => $this->editPunishID, 116 146 'punish' => $this->punish, 117 147 'addPunish' => $this->addPunish, 148 'drivedRaces' => $this->drivedRaces, 149 'raceID' => $this->raceID, 150 'driver' => $this->driver, 118 151 119 152 'redirect' => $this->redirect -
racing.league/templates/racingLeaguePunish.tpl
r699 r706 37 37 {if $saisons.$activeSaisonID|isset}<p class="info">{lang}wcf.racing.league.saison.selected{/lang}</p>{/if} 38 38 39 {if $addPunish == 1} 40 <form method="post" action="index.php?form=RacingLeaguePunish{@SID_ARG_2ND}&newResults=1&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}&addPunish=1"> 41 42 <div class="border content"> 42 43 <div class="container-1"> 43 <h3 class="subHeadline"><img src="{@RELATIVE_WCF_DIR}icon/saison S.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> 45 46 <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} 60 57 </select> 61 <br /> 62 {/foreach} 63 64 {if $errorField == 'result'} 58 59 60 {if $errorField == 'punishRace'} 65 61 <p class="innerError"> 66 62 {if $errorType == 'empty'}{lang}wcf.global.error.empty{/lang}{/if} … … 79 75 {/if} 80 76 81 {if $editRaceID > 0} 82 <form method="post" action="index.php?form=RacingLeagueResults{@SID_ARG_2ND}&editRaceID={$editRaceID}&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}&addPunish=1&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}&editPunishID={$editPunishID}&edit=1"> 83 149 <div class="border content"> 84 150 <div class="container-1"> … … 183 249 {/if} 184 250 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 195 251 {if $saisons|count} 196 252 <div class="largeButtons">
