Skip to content

Instantly share code, notes, and snippets.

@funtimeerror
Created December 2, 2011 15:59
Show Gist options
  • Select an option

  • Save funtimeerror/1423740 to your computer and use it in GitHub Desktop.

Select an option

Save funtimeerror/1423740 to your computer and use it in GitHub Desktop.
ClanApply.php update to fix database table prefix naming issue
<?php
/**
* Clan CMS
*
* An open source application for gaming clans
*
* @package Clan CMS
* @author Xcel Gaming Development Team
* @copyright Copyright (c) 2010 - 2011, Xcel Gaming, Inc.
* @license http://www.xcelgaming.com/about/license/
* @link http://www.xcelgaming.com
* @since Version 0.5.0
*/
// ------------------------------------------------------------------------
/** #######################################################
* @project Clan Application
* @author Alan Reynolds
* @license http://www.opensource.org/licenses/OSL-3.0
* @link http://www.geoprogramming.com
* @version Version 1.0.0
* @compatible Version 0.6.1
##########################################################*/
class Clanapply extends CI_Controller {
/**
* Constructor
*
*/
function __construct()
{
// Call the Controller constructor
parent::__construct();
// Load the Squads model
$this->load->model('Squads_model', 'squads');
}
// --------------------------------------------------------------------
/**
* Index
*
* Display's the sponsors
*
* @access public
* @return void
*/
function index()
{
// Check to see if the user is logged in
if (!$this->user->logged_in())
{
// User is not logged in, redirect them
redirect('account/login');
}
if($_POST[squad_id]){
$show = "no";
//Check all Feilds
if($_POST[squad_id] == ""){
$error .="<p>Error in squad selection.</p>";
}elseif($_POST[gamertag] == ""){
$error .="<p>Gamertag is required.</p>";
}elseif($_POST[firstname] == ""){
$error .="<p>First name is required.</p>";
}elseif($_POST[lastname] == ""){
$error .="<p>Last name is required.</p>";
}elseif($_POST[age] == ""){
$error .="<p>Age is required.</p>";
}elseif($_POST[phone] == ""){
$error .="<p>Phone is required.</p>";
}elseif($_POST[whypickyou] == ""){
$error .="<p>Why we should pick you is required.</p>";
}
//Check to see if the user is already in that squad
if($this->checkMemSquad($this->stripString($_POST[squad_id])) == "yes"){
$error ="<p>You are already on this squad</p>";
}
//Check to see if there is an application for that user
if($this->checkApp($this->stripString($_POST[squad_id])) == "yes"){
if($this->appStatus($_POST[squad_id]) == "Declined"){
$error .= "<p>Application Status: [".$this->appStatus($_POST[squad_id])."]</p>";
}else{
if($this->checkMemSquad($this->stripString($_POST[squad_id])) != "yes"){
$error .= "<p>You have a pending application for this squad.</p>";
$error .= "<p>Application Status: [".$this->appStatus($_POST[squad_id])."]</p>";
}
}
}
if($error){
//Ref
$this->data->error =& $error;
}else{
//Insert info into Database
$data = array(
'app_id' => $this->stripString('0'),
'user_id' => $this->session->userdata('user_id'),
'squad_id' => $this->stripString($_POST[squad_id]),
'gamertag' => $this->stripString($_POST[gamertag]),
'firstname' => $this->stripString($_POST[firstname]),
'lastname' => $this->stripString($_POST[lastname]),
'age' => $this->stripString($_POST[age]),
'phone' => $this->stripString($_POST[phone]),
'whypickyou' => $this->stripString($_POST[whypickyou]),
'status' => $this->stripString('0'),
);
$this->db->insert('clan_application',$data);
redirect('/roster');
}
}else{
$squads = $this->squads->get_squads();
// Create a reference
$this->data->squads =& $squads;
}
//TRUE if the form should show else FALSE
$this->data->show =& $show;
// Load the sponsors view
$this->load->view(THEME . 'clanapply', $this->data);
}
function checkMemSquad($squad_id){
$memsquad = array('user_id' => $this->session->get_userdata('user_id'),'squad_id' => $squad_id);
if($this->squads->get_member($memsquad)){
$out = "yes";
}else{
$out = "no";
}
return $out;
}
function appStatus($squad_id){
$chkappsquad = array('user_id' => $this->session->get_userdata('user_id'),'squad_id' => $squad_id);
$checkApp = $this->db->where($chkappsquad)->get('clan_application')->result();
if($checkApp->status == 0){
$status = "Pending";
}elseif($checkApp->status == 1){
$status = "Accepted";
}else{
$status = "Declined";
}
return $status;
}
function checkApp($squad_id){
$chkappsquad = array('user_id' => $this->session->get_userdata('user_id'),'squad_id' => $squad_id);
$checkApp = $this->db->where($chkappsquad)->get('clan_application')->count_all_results();
if($checkApp > 0){
$out = "yes";
}else{
$out = "no";
}
return $out;
}
function stripString($string){
return mysql_real_escape_string(stripslashes(strip_tags($string)));
}
}
/* End of file clanapply.php */
/* Location: ./clancms/controllers/clanapply.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment