Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

guild.php

Go to the documentation of this file.
00001 <?php
00009 /***************************************************************************
00010  This program is free software; you can redistribute it and/or
00011  modify it under the terms of the GNU General Public License
00012  as published by the Free Software Foundation; either version 2
00013  of the License, or (at your option) any later version.
00014 
00015  This program is distributed in the hope that it will be useful,
00016  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  GNU General Public License for more details.
00019 
00020  You should have received a copy of the GNU General Public License
00021  along with this program; if not, write to the Free Software
00022  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023  ***************************************************************************/
00024 
00025 require_once( './general.php' );
00026 require_once( './lib/guild.php' );
00027 
00028 if( !$oUser->isAdmin( 'guild_list' ) )
00029 {
00030     die('Keine Admin Rechte.');
00031 }
00032 
00033 // get styles
00034 $oStyle->setTemplate('guild.html' );
00035 $oStyle->split_area('List');
00036 $oStyle->split_area('GuildRow');
00037 $oStyle->split_area('Edit');
00038 $oStyle->split_area('Add');
00039 
00040 $oGuild = new Guild( $oMysql, $oLog, $oUser );
00041 
00042 // get variables
00043 if(isset($_POST['action']))     $action = $_POST['action'];
00044 elseif(isset($_GET['action']))  $action = $_GET['action'];
00045 else $action = 'list';
00046 
00047 //-----------------------------------------------------------------------------
00048 if( $action == 'edit' && $oUser->isAdmin( 'guild_edit' ) )
00049 {
00050     if(isset($_POST['guildid']))    $intGuild = intval($_POST['guildid']);
00051     elseif(isset($_GET['guildid'])) $intGuild = intval($_GET['guildid']);
00052     else $intGuild = 0;
00053 
00054     if( !isset($_POST['submit']) ) // form not sent
00055     {
00056         $aGuild = $oGuild->get( $intGuild );
00057         if( $aGuild === false )
00058         {
00059             // error handling
00060         }
00061 
00062         // chose diplomacy
00063         $aDiplomacy = array( 0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '', 7 => '', 8 => '' );
00064         $aDiplomacy[$aGuild['diplomacy']] = ' checked="checked"';
00065         $oStyle->addReplacements( array( 'GUILD_NAME' => htmlspecialchars( $aGuild['name'] ),
00066                                          'GUILD_TAG' => htmlspecialchars( $aGuild['tag'] ),
00067                                          'GUILD_BGCOLOR' => $aGuild['bgcolor'],
00068                                          'GUILD_FGCOLOR' => $aGuild['fgcolor'],
00069                                          'GUILD_ID' => $aGuild['guild_id'],
00070                                          'DIPLOMACY_0' => $aDiplomacy[0],
00071                                          'DIPLOMACY_1' => $aDiplomacy[1],
00072                                          'DIPLOMACY_2' => $aDiplomacy[2],
00073                                          'DIPLOMACY_3' => $aDiplomacy[3],
00074                                          'DIPLOMACY_4' => $aDiplomacy[4],
00075                                          'DIPLOMACY_5' => $aDiplomacy[5],
00076                                          'DIPLOMACY_6' => $aDiplomacy[6],
00077                                          'DIPLOMACY_7' => $aDiplomacy[7],
00078                                          'DIPLOMACY_8' => $aDiplomacy[8]
00079                                         )
00080                                   );
00081     }
00082     else //form sent, update guild data
00083     {
00084         // get vars
00085         $strName       = (isset($_POST['guild_name']))      ? $_POST['guild_name']    : '';
00086         $strTag        = (isset($_POST['guild_tag']))       ? $_POST['guild_tag']     : '';
00087         $strFgColor    = (isset($_POST['guild_fgcolor']))   ? str_replace( '#', '', $_POST['guild_fgcolor'] ) : '';
00088         $strBgColor    = (isset($_POST['guild_bgcolor']))   ? str_replace( '#', '', $_POST['guild_bgcolor'] ) : '';
00089         $intDiplomacy  = (isset($_POST['guild_diplomacy'])) ? intval($_POST['guild_diplomacy']) : 0;
00090         // update guild
00091         $oGuild->set( $intGuild, $strName, $strTag, $strFgColor, $strBgColor, $intDiplomacy );
00092         // list all guilds
00093         $action = 'list';
00094     }
00095 }
00096 //-----------------------------------------------------------------------------
00097 if( $action == 'delete' && $oUser->isAdmin( 'guild_del' ) )
00098 {
00099     // get vars
00100     if(isset($_POST['guildid']))    $intGuild = intval($_POST['guildid']);
00101     elseif(isset($_GET['guildid'])) $intGuild = intval($_GET['guildid']);
00102     else $intGuild = 0;
00103     // delete guild
00104     if( !$oGuild->delete( $intGuild ) )
00105     {
00106         // error handling
00107     }
00108     // list all guilds
00109     $action = 'list';
00110 }
00111 //-----------------------------------------------------------------------------
00112 if( $action == 'add' && $oUser->isAdmin( 'guild_add' ) )
00113 {
00114     if( isset( $_POST['submit'] ) )
00115     {
00116         // form sent, update guild
00117         // get vars
00118         $strName       = (isset($_POST['guild_name']))      ? $_POST['guild_name']    : '';
00119         $strTag        = (isset($_POST['guild_tag']))       ? $_POST['guild_tag']     : '';
00120         $strFgColor    = (isset($_POST['guild_fgcolor']))   ? str_replace( '#', '', $_POST['guild_fgcolor'] ) : '';
00121         $strBgColor    = (isset($_POST['guild_bgcolor']))   ? str_replace( '#', '', $_POST['guild_bgcolor'] ) : '';
00122         $intDiplomacy  = (isset($_POST['guild_diplomacy'])) ? intval($_POST['guild_diplomacy']) : 0;
00123         // add the guild
00124         if( !$oGuild->add( $strName, $strTag, $strFgColor, $strBgColor, $intDiplomacy ) )
00125         {
00126             // error handling
00127         }
00128         // list all guilds
00129         $action = 'list';
00130     }
00131 }
00132 //-----------------------------------------------------------------------------
00133 
00134 if( $action == 'list' )
00135 {
00136     $aGuilds = $oGuild->getAll();
00137     $i = 0;
00138     $strGuildList = '';
00139     foreach( $aGuilds AS $aData )
00140     {
00141         $oStyle->addReplacements( array( 'GUILD_ID' => $aData['guild_id'] ) );
00142 
00143         $strGuildEdit = '';
00144         $strGuildDel  = '';
00145         if( $aData['guild_id'] > 1 )
00146         {
00147             $strGuildEdit = $oUser->isAdmin( 'guild_edit' ) ? $oStyle->get_area( 'ListEditLink' ) : '';
00148             $strGuildDel  = $oUser->isAdmin( 'guild_del' )  ? $oStyle->get_area( 'ListDelLink' ) : '';
00149         }
00150         $oStyle->addReplacements( array( 'DIPLOMACY_FGCOLOR' => $aDiploFgColor[$aData['diplomacy']],
00151                                          'DIPLOMACY_BGCOLOR' => $aDiploBgColor[$aData['diplomacy']],
00152                                          'GUILD_NAME' => ($aData['name']) ? $aData['name'] : '&nbsp;',
00153                                          'GUILD_FGCOLOR' => $aData['fgcolor'],
00154                                          'GUILD_BGCOLOR' => $aData['bgcolor'],
00155                                          'GUILD_TAG' => $aData['tag'] != '' ? '['.$aData['tag'].']' : '--',
00156                                          'GUILD_MEMBERS' => $aData['members'],
00157                                          'GUILD_TOWNS' => $aData['towns'],
00158                                          'GUILD_EDIT' => $strGuildEdit.$strGuildDel,
00159                                          'GUILD_ROW' => intval(($i % 2) == 0)
00160                                        )
00161                                   );
00162         $strGuildList .= $oStyle->get_area( 'GuildRow' );
00163         $i++;
00164     }
00165 
00166     // show Add Guild link only if the user has the admin rights
00167     $strGuildAdd = ( $oUser->isAdmin( 'guild_add' ) ) ? $oStyle->get_area( 'ListAddLink' ) : '';
00168     $oStyle->addReplacements( array( 'GUILD_RESULT' => $strGuildList,
00169                                      'GUILD_ADD' => $strGuildAdd ) );
00170 }
00171 
00172 // get the area
00173 $strTmpl_inhalt = $oStyle->get_area( ucfirst($action) );
00174 output();

Generated on Sun May 8 19:29:45 2005 for PhpMap by  doxygen 1.4.2