Thread: [Openfirst-cvscommit] awards/admin index.php,1.25,1.26
Brought to you by:
xtimg
From: Jamie <ast...@us...> - 2005-11-22 16:37:20
|
Update of /cvsroot/openfirst/awards/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25779/awards/admin Modified Files: index.php Log Message: -Serious updates (A whole lot of changes...) (admin/index.php) -no trailing line (awards.php) Index: index.php =================================================================== RCS file: /cvsroot/openfirst/awards/admin/index.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** index.php 30 Jun 2005 03:28:30 -0000 1.25 --- index.php 22 Nov 2005 16:37:09 -0000 1.26 *************** *** 1,312 **** ! <?php ! /* ! * openFIRST.awards - admin/index.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: David Di Biase <dav...@ea...> ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! * ! */ ! include_once("../../includes/globals.php"); ! include_once($Header); ! ! // Check if user is an admin then allow processes ! if(isset($user->user)){ ! ! if($user->membertype=="administrator"){ ! // If user has posted delete then delete specified record in querystring DELETE ! if (isset($_GET['DELETE'])){ ! ofirst_dbquery('DELETE FROM '. ! ofirst_dbquote_table('awards'). ! ' WHERE '. ! ofirst_dbquote_name('ID'). ! ' = '. ! ofirst_dbquote_data($_GET['DELETE']) ! ) or die("DELETE: ". ofirst_dberror()); ! ! echo("<p>Award information has been deleted.</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! die(include_once($footer)); ! } ! $DisplayForm = true; ! $CreateNew = true; ! if (array_key_exists('AwardID', $_POST)) { ! $CreateNew = false; ! $DisplayForm = false; ! } ! if (array_key_exists('create', $_POST)) { ! $CreateNew = true; ! $DisplayForm = false; ! } ! if (array_key_exists('modify', $_POST)) { ! $CreateNew = false; ! $DisplayForm = false; ! } ! ! $firstaward = false; ! if (isset($_POST['firstaward'])) $firstaward = $_POST['firstaward'] == '1' ? true : false; ! $firstawardname = ''; ! if (isset($_POST['firstawardname'])) $firstawardname = $_POST['firstawardname']; ! $award = ''; ! if (isset($_POST['award'])) $award = $_POST['award']; ! $event = ''; ! if (isset($_POST['event'])) $event = $_POST['event']; ! $date = date('Y-n-j'); ! if (isset($_POST['date'])) $date = $_POST['date']; ! $recipient = ''; ! if (isset($_POST['recipient'])) $recipient = $_POST['recipient']; ! $description = ''; ! if (isset($_POST['description'])) $description = $_POST['description']; ! $type = 'gold'; ! if (isset($_POST['type'])) $type = $_POST['type']; ! ! ! // If user has posted create then insert new award record ! if ($CreateNew && !$DisplayForm){ ! if ($award != '' || $firstaward){ ! if($firstaward) { ! $sql = 'SELECT * FROM '.$ogDB->quoteTable('firstawards'). ! ' WHERE '.$ogDB->quoteField('AwardName').'='.$ogDB->quoteData($firstawardname). ! ' LIMIT 0,1'; ! $faq = $ogDB->query($sql); ! $fa = $ogDB->fetchObject($faq); ! $award = $fa->AwardName; ! $description = $fa->Description; ! } ! $sql = 'INSERT INTO '. ! $ogDB->quoteTable('awards').' SET '. ! $ogDB->quoteFDPairs(array('AwardName' => $award, ! 'FIRSTAward' => $firstaward, ! 'Event' => $event, ! 'Date' => $date, ! 'Image' => $type, ! 'Description' => $description, ! 'Recipient' => $recipient ! )); ! $ogDB->query($sql) or die(trigger_error('an openFIRST DB error')); ! ! echo("<p>Congratulations on your new award. Award submitted!</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } else { ! echo("<p>Please enter a name for the award.</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } ! die(include_once($Footer)); ! } ! ! // If the user has submitted modifications to an award, then make them. ! ! if (!$CreateNew && !$DisplayForm){ ! if ($award != "" || $firstaward){ ! if ($firstaward) { ! $faq = ofirst_dbquery('SELECT * FROM '.ofirst_dbquote_table('awards').' WHERE '. ! ofirst_dbquote_name('AwardName').'='. ! ofirst_dbquote_data($firstawardname)); ! $fa = ofirst_dbfetch_object($faq); ! $award = $fa->AwardName; ! $description = $fa->Description; ! } ! ! ofirst_dbquery('UPDATE '.ofirst_dbquote_table('awards').' SET '. ! ofirst_dbquote_fd_pairs(array( ! 'AwardName' => $award, ! 'FIRSTAward' => $firstaward, ! 'Event' => $event, ! 'Date' => $date, ! 'Image' => $type, ! 'Description' => $description, ! 'Recipient' => $recipient)). ! ' WHERE '.ofirst_dbquote_name('ID').'='.ofirst_dbquote_data(AwardID)) ! or die("UPDATE: ".ofirst_dberror()); ! ! echo("<p>Award modifications submitted!</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } else { ! echo("<p>Please enter a name for the award.</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } ! die(include_once($footer)); ! } ! ! ! // If the user has elected to modify an award, fill the form with those details. ! if(!$CreateNew) { ! $sql = 'SELECT * FROM '.$ogDB->quoteTable('awards'). ! ' WHERE '.$ogDB->quoteField('ID').'='.$ogDB->quoteData('AwardID'); ! $award = $ogDB->fetchObject($ogDB->query($sql)); ! $award->template = false; ! ! } else { ! $award = (object)''; ! $award->template = true; ! $award->AwardName = 'Autodesk Visualization Award'; ! $award->Description = ''; ! $award->Event = ''; ! $award->Date = date('Y-n-j'); ! $award->Recipient = 'Team Award'; ! $award->Image = 'gold'; ! $award->FIRSTAward = '1'; ! } ! ?> ! ! <h1>Manage Award Information</h1> ! <form method="post" action="index.php"> ! <table> ! <colgroup> ! <col /> ! </colgroup> ! <colgroup> ! <col /> ! </colgroup> ! <tr> ! <th colspan="2"><?php ! if (!$award->template) { ! echo("Modify an Existing Award ! <input type='hidden' id='AwardID' name='AwardID' value='$award->ID'>"); ! } else { ! echo("Add A New Award"); ! } ! ?></th> ! </tr> ! <tr> ! <th>Award Name</th> ! <td class="left"> ! <table class="no-space left"> ! <tr> ! <td> ! <input type='radio' name='firstaward' value='1' <?php if ($award->FIRSTAward) echo 'checked="checked"'; ?>> ! </td> ! <td> FIRST Award</td> ! </td> ! <td> ! <select name='firstawardname'> ! <?php ! $faq = $ogDB->query('SELECT * FROM '.$ogDB->quoteTable('firstawards').' ORDER BY '.$ogDB->quoteField('AwardName')); ! while($fa = $ogDB->fetchObject($faq)) { ! echo "<option value='$fa->AwardName'"; ! if ($award->AwardName == $fa->AwardName) echo 'selected'; ! echo ">$fa->AwardName</option>"; ! } ! ?> ! </select> ! </td> ! </tr> ! <tr> ! <td> ! <input type='radio' name='firstaward' value='0' <?php if (!$award->FIRSTAward) echo 'checked="checked"'; ?>> ! </td> ! <td> Custom Award</td> ! </td> ! <td> ! <input name="award" type="text" id="award" value="<?php if (!$award->FIRSTAward) echo $award->AwardName; ?>"> ! </td> ! </tr> ! </table> ! </td> ! </tr> ! <tr> ! <th>Regional/Event</th> ! <td class="left"><input name="event" type="text" id="event" value="<?php echo $award->Event; ?>"></td> ! </tr> ! <tr> ! <th>Date</th> ! <td class="left"><input name="date" type="text" id="date" value="<?php ! echo $award->Date; ! ?>" size="10"> ! <sub>(Use this syntax: Year-Month-Day)</sub></td> ! </tr> ! <tr> ! <th>Recipient</th> ! <td class="left"><input name="recipient" type="text" id="recipient" value="<?php ! echo $award->Recipient; ! ?>"></td> ! </tr> ! <tr> ! <th>Description<br />(leave blank for FIRST Awards)</th> ! <td><textarea name="description" cols="30" rows="5"><?php echo $award->Description; ?></textarea></td> ! </tr> ! <tr> ! <th>Award Type</th> ! <td class="left"><table> ! <tr> ! <td><img src="<?php echo($BasePath); ?>/awards/awardsgold.png" alt="Gold"></td> ! <td><img src="<?php echo($BasePath); ?>/awards/awardssilver.png" alt="Silver"></td> ! <td><img src="<?php echo($BasePath); ?>/awards/awardsbronze.png" alt="Bronze"></td> ! </tr> ! <tr> ! <td><div align="center"> ! <input name="type" type="radio" value="gold" <?php ! if (strcasecmp($award->Image, 'gold') == 0) echo 'checked="checked"'; ! ?>> ! </div></td> ! <td><div align="center"> ! <input type="radio" name="type" value="silver" <?php ! if (strcasecmp($award->Image, 'silver') == 0) echo 'checked="checked"'; ! ?>> ! </div></td> ! <td><div align="center"> ! <input type="radio" name="type" value="bronze" <?php ! if (strcasecmp($award->Image, 'bronze') == 0) echo 'checked="checked"'; ! ?>> ! </div></td> ! </tr> ! </table></td> ! </tr> ! <tr> ! <td colspan="2" class="center"> ! <?php if($award->template) { ?> ! <input name="create" type="submit" id="create" value="Create Award"> ! <?php } else { ?> ! <input name="modify" type="submit" id="modify" value="Modify Award"></td> ! <?php } ?> ! </td> ! </tr> ! </table> ! </form> ! <table> ! <tr> ! <th colspan="2">Award Name</th> ! <th>Event</th> ! <th>Date</th> ! <th>Recipient</th> ! <th>Option</th> ! </tr> ! <?php ! // Loop through awards ordered by date ! $query = $ogDB->query('SELECT * FROM '.$ogDB->quoteTable('awards').' ORDER BY '.$ogDB->quoteName('Date')); ! while($awards = $ogDB->fetchObject($query)){ ! ?> ! <tr> ! <td><img src="<?php echo($BasePath); ?>/awards/awards<?php echo $awards->Image; ?>.png" alt="<?php echo $awards->Image; ?>"></td> ! <td><?php echo $awards->AwardName; ?></td> ! <td><?php echo $awards->Event; ?></td> ! <td><?php echo $awards->Date; ?></td> ! <td><?php echo $awards->Recipient; ?></td> ! <td><div align="center">[ <a href='./?DELETE=<?php echo $awards->ID; ?>'>Delete</a> | <a href='./?MODIFY=<?php echo $awards->ID; ?>'>Modify</a> ]</div></td> ! </tr> ! <?php ! } ! if($ogDB->numberOfRows($query) == 0){ ! echo '<tr><td colspan="6">No awards entered!</td></tr>'; ! } ! ?> ! </table> ! <br /> ! <?php ! } else { ! echo("<h1>Manage Award Information</h1><p>Only administrators can use this feature</p>"); ! } ! } else { ! showlogin(); ! } ! include_once($Footer); ! ?> --- 1,293 ---- ! <?php ! /* ! * openFIRST.awards - admin/index.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: David Di Biase <dav...@ea...> ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! * ! */ ! include_once("../../includes/globals.php"); ! $ogUser->mustBeAdmin(); ! include_once($Header); ! ! // Check if user is an admin then allow processes ! // If user has posted delete then delete specified record in querystring DELETE ! if (isset($_GET['DELETE'])){ ! $ogDB->delete('awards', array('ID' => $_GET['DELETE'])) or die("DELETE: ". $ogDB->errorString()); ! ! ! echo("<p>Award information has been deleted.</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! die(include_once($footer)); ! } ! $DisplayForm = true; ! $CreateNew = true; ! if (array_key_exists('AwardID', $_POST)) { ! $CreateNew = false; ! $DisplayForm = false; ! } ! if (array_key_exists('create', $_POST)) { ! $CreateNew = true; ! $DisplayForm = false; ! } ! if (array_key_exists('modify', $_POST)) { ! $CreateNew = false; ! $DisplayForm = false; ! } ! ! $firstaward = false; ! if (isset($_POST['firstaward'])) $firstaward = $_POST['firstaward'] == '1' ? true : false; ! $firstawardname = ''; ! if (isset($_POST['firstawardname'])) $firstawardname = $_POST['firstawardname']; ! $award = ''; ! if (isset($_POST['award'])) $award = $_POST['award']; ! $event = ''; ! if (isset($_POST['event'])) $event = $_POST['event']; ! $date = date('Y-n-j'); ! if (isset($_POST['date'])) $date = $_POST['date']; ! $recipient = ''; ! if (isset($_POST['recipient'])) $recipient = $_POST['recipient']; ! $description = ''; ! if (isset($_POST['description'])) $description = $_POST['description']; ! $type = 'gold'; ! if (isset($_POST['type'])) $type = $_POST['type']; ! ! ! // If user has posted create then insert new award record ! if ($CreateNew && !$DisplayForm){ ! if ($award != '' || $firstaward){ ! if($firstaward) { ! $faq = $ogDB->select( 'firstawards', '*', array('AwardName' => $firstawardname), array('LIMIT' => '0,1') ); ! $fa = $ogDB->fetchObject($faq); ! $award = $fa->AwardName; ! $description = $fa->Description; ! } ! $ogDB->insert( 'awards', ! array( 'AwardName' => $award, ! 'FIRSTAward' => $firstaward, ! 'Event' => $event, ! 'Date' => $date, ! 'Image' => $type, ! 'Description' => $description, ! 'Recipient' => $recipient ! ) ! ) or trigger_error('an openFIRST DB error'); ! ! echo("<p>Congratulations on your new award. Award submitted!</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } else { ! echo("<p>Please enter a name for the award.</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } ! include_once($Footer); ! die(); ! } ! ! // If the user has submitted modifications to an award, then make them. ! ! if (!$CreateNew && !$DisplayForm){ ! if ($award != "" || $firstaward){ ! if ($firstaward) { ! $faq = $ogDB->select('awards', '*', array('AwardName' => $firstawardname)); ! $fa = $ogDB->fetchObject($faq); ! $award = $fa->AwardName; ! $description = $fa->Description; ! } ! ! $ogDB->update( 'awards', ! array( 'AwardName' => $award, ! 'FIRSTAward' => $firstaward, ! 'Event' => $event, ! 'Date' => $date, ! 'Image' => $type, ! 'Description' => $description, ! 'Recipient' => $recipient ! ), ! array('ID' => AwardID) ! ) or die("UPDATE: ".$ogDB->errorString()); ! ! echo("<p>Award modifications submitted!</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } else { ! echo("<p>Please enter a name for the award.</p><p>[ <a href='./'>Manage Awards</a> ]</p>"); ! } ! include_once($Footer); ! die(); ! } ! ! ! // If the user has elected to modify an award, fill the form with those details. ! if(!$CreateNew) { ! $award = $ogDB->fetchObject($ogDB->select('awards', array('ID' => $AwardID))); ! $award->template = false; ! ! } else { ! $award = (object)''; ! $award->template = true; ! $award->AwardName = 'Autodesk Visualization Award'; ! $award->Description = ''; ! $award->Event = ''; ! $award->Date = date('Y-n-j'); ! $award->Recipient = 'Team Award'; ! $award->Image = 'gold'; ! $award->FIRSTAward = '1'; ! } ! ?> ! ! <h1>Manage Award Information</h1> ! <form method="post" action="index.php"> ! <table> ! <colgroup> ! <col /> ! </colgroup> ! <colgroup> ! <col /> ! </colgroup> ! <tr> ! <th colspan="2"><?php ! if (!$award->template) { ! echo("Modify an Existing Award ! <input type='hidden' id='AwardID' name='AwardID' value='".htmlentities($award->ID)."'>"); ! } else { ! echo("Add A New Award"); ! } ! ?></th> ! </tr> ! <tr> ! <th>Award Name</th> ! <td class="left"> ! <table class="no-space left"> ! <tr> ! <td> ! <input type='radio' name='firstaward' value='1' <?php if ($award->FIRSTAward) echo 'checked="checked"'; ?>> ! </td> ! <td> FIRST Award</td> ! </td> ! <td> ! <select name='firstawardname'> ! <?php ! $faq = $ogDB->select('firstawards', 'AwardName', array(), array('order' => 'AwardName')); ! while($fa = $ogDB->fetchObject($faq)) { ! echo "<option value='$fa->AwardName'"; ! if ($award->AwardName == $fa->AwardName) echo 'selected'; ! echo ">$fa->AwardName</option>"; ! } ! ?> ! </select> ! </td> ! </tr> ! <tr> ! <td> ! <input type='radio' name='firstaward' value='0' <?php if (!$award->FIRSTAward) echo 'checked="checked"'; ?>> ! </td> ! <td> Custom Award</td> ! </td> ! <td> ! <input name="award" type="text" id="award" value="<?php if (!$award->FIRSTAward) echo $award->AwardName; ?>"> ! </td> ! </tr> ! </table> ! </td> ! </tr> ! <tr> ! <th>Regional/Event</th> ! <td class="left"><input name="event" type="text" id="event" value="<?php echo $award->Event; ?>"></td> ! </tr> ! <tr> ! <th>Date</th> ! <td class="left"><input name="date" type="text" id="date" value="<?php ! echo $award->Date; ! ?>" size="10"> ! <sub>(Use this syntax: Year-Month-Day)</sub></td> ! </tr> ! <tr> ! <th>Recipient</th> ! <td class="left"><input name="recipient" type="text" id="recipient" value="<?php ! echo $award->Recipient; ! ?>"></td> ! </tr> ! <tr> ! <th>Description<br />(leave blank for FIRST Awards)</th> ! <td><textarea name="description" cols="30" rows="5"><?php echo $award->Description; ?></textarea></td> ! </tr> ! <tr> ! <th>Award Type</th> ! <td class="left"><table> ! <tr> ! <td><img src="<?php echo($BasePath); ?>/awards/awardsgold.png" alt="Gold"></td> ! <td><img src="<?php echo($BasePath); ?>/awards/awardssilver.png" alt="Silver"></td> ! <td><img src="<?php echo($BasePath); ?>/awards/awardsbronze.png" alt="Bronze"></td> ! </tr> ! <tr> ! <td><div align="center"> ! <input name="type" type="radio" value="gold" <?php ! if (strcasecmp($award->Image, 'gold') == 0) echo 'checked="checked"'; ! ?>> ! </div></td> ! <td><div align="center"> ! <input type="radio" name="type" value="silver" <?php ! if (strcasecmp($award->Image, 'silver') == 0) echo 'checked="checked"'; ! ?>> ! </div></td> ! <td><div align="center"> ! <input type="radio" name="type" value="bronze" <?php ! if (strcasecmp($award->Image, 'bronze') == 0) echo 'checked="checked"'; ! ?>> ! </div></td> ! </tr> ! </table></td> ! </tr> ! <tr> ! <td colspan="2" class="center"> ! <?php if($award->template) { ?> ! <input name="create" type="submit" id="create" value="Create Award"> ! <?php } else { ?> ! <input name="modify" type="submit" id="modify" value="Modify Award"></td> ! <?php } ?> ! </td> ! </tr> ! </table> ! </form> ! <table> ! <tr> ! <th colspan="2">Award Name</th> ! <th>Event</th> ! <th>Date</th> ! <th>Recipient</th> ! <th>Option</th> ! </tr> ! <?php ! // Loop through awards ordered by date ! $query = $ogDB->select('awards', '*', array(), array('order' => 'Date')); ! while($awards = $ogDB->fetchObject($query)){ ! ?> ! <tr> ! <td><img src="<?php echo($BasePath); ?>/awards/awards<?php echo $awards->Image; ?>.png" alt="<?php echo $awards->Image; ?>"></td> ! <td><?php echo $awards->AwardName; ?></td> ! <td><?php echo $awards->Event; ?></td> ! <td><?php echo $awards->Date; ?></td> ! <td><?php echo $awards->Recipient; ?></td> ! <td><div align="center">[ <a href='./?DELETE=<?php echo $awards->ID; ?>'>Delete</a> | <a href='./?MODIFY=<?php echo $awards->ID; ?>'>Modify</a> ]</div></td> ! </tr> ! <?php ! } ! if($ogDB->numberOfRows($query) == 0){ ! echo '<tr><td colspan="6">No awards entered!</td></tr>'; ! } ! ?> ! </table> ! <br /> ! <?php ! include_once($Footer); ! ?> |