• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Modern AAC] Fixed Guild System

MiPo91

Member
Joined
Mar 30, 2010
Messages
299
Reaction score
18
Location
Finland
Hello, I decided to release my fix for the Modern AAC guild system.

NOTE: That you need to be offline when leaving, inviting-, kicking players or making guild

This one fixes the following problems:
1.Players can't leave from guild.
2.Vice leaders cant invite players.
3.Guild Leaders cant do anything(only owner could).

----------------------------------------------------------------
Replace the following files with these codes:

1. system/application/controllers/guilds.php
Code:
<?php
class Guilds extends Controller {

	public function index() {
		$this->load->helper("form");
		$this->load->model("guilds_model");
		require_once("system/application/config/create_character.php");
		$data = array();
		$data['config'] = $config;
		$data['guilds'] = @$this->guilds_model->getGuildsList((int)$_REQUEST['world_id']);
		$this->load->view("guilds", $data);
	}
	
	public function view($id = null, $action = 0) {
		$ide = new IDE;
		if(empty($id)) $ide->redirect('../');
		if($action == 1) { success("You have joined the guild."); echo "<br />";}
		$ots = POT::getInstance();
		$ots->connect(POT::DB_MYSQL, connection());
		$guild = $ots->createObject('Guild');
		try {$guild->load($id); } catch(Exception $e) {show_error('Problem occured while loading guild. Err code: 220612072010 Futher information: '.$e->getMessage()); }
		if(!$guild->isLoaded()) error("Could not find guild.");
		$data['guild'] = $guild;
		$this->load->model("guilds_model");
		$data['viceleaders'] = $this->guilds_model->isViceLeader($id);  
		$data['leaders'] = $this->guilds_model->isLeader($id); 
		$this->load->view("view_guild", $data);		
	}
	
	public function _checkPlayer($id) {
		$this->load->model("guilds_model");
		if($this->guilds_model->checkPlayerCreatingGuild($id)) {
			return true;
		}
		else {
			$this->form_validation->set_message('_checkPlayer', 'Could not find character.');
			return false;
		}
	}
	
	public function _checkGuildName($name){
		$this->load->model("guilds_model");
		if($this->guilds_model->checkGuildName($name)) {
			return true;
		}
		else {
			$this->form_validation->set_message('_checkGuildName', 'Guild name is already taken.');
			return false;
		}
	}
	
	public function create() {
		$ide = new IDE;
		$ide->requireLogin();
		$this->load->helper("form");
		$this->load->model("guilds_model");
		require_once("system/application/config/create_character.php");
		$this->load->library("form_validation");
		if(isset($_POST['submit'])) {
			$this->form_validation->set_rules('character', 'Character', 'required|numeric|callback__checkPlayer');
			$this->form_validation->set_rules('name', 'Guild Name', 'required|alpha_space|callback__checkGuildName');
		}
		if($this->form_validation->run() == true) {
			$id = $this->guilds_model->createGuild($_POST['name'], $_POST['character']);
			$this->load->model("forum_model");
			global $config;
			
			// Get name of the creator, for he is gonna be a moderator!
			$ots = POT::getInstance();
			$ots->connect(POT::DB_MYSQL, connection());
			$owner = new OTS_Player();
			try {$owner->load($_POST['character']); } catch(Exception $e) {show_error('Problem occured while loading character. Err code: 220812072010 Futher information: '.$e->getMessage()); }
        	if(!$owner->isLoaded())
        		error("A strange error happend while trying to create the guild board, this guild won't have a board!");
        	else	
				$this->forum_model->createBoard(str_replace('%NAME%', $_POST['name'], $config['guildboardTitle']), str_replace('%NAME%', $_POST['name'], $config['guildboardTitle']), 0, 0, 9999, 1, $owner->getName(), $id);
					
			$ide->redirect(WEBSITE."/index.php/guilds/view/".$id);
			success("{$_POST['name']} has been created.");
		}
		$data = array();
		$data['characters'] = $this->guilds_model->getCharactersAllowedToCreateGuild($config['levelToCreateGuild']);
		$data['config'] = $config;
		$this->load->view("create_guild", $data);
		
	}
	
	public function join($guild_name, $player_name) {
		$guild_name = (int)$guild_name;
		$player_name = (int)$player_name;
		$ide = new IDE;
		if(empty($guild_name) or empty($player_name)) $ide->redirect(WEBSITE."/index.php/guilds");
		$ots = POT::getInstance();
		$ots->connect(POT::DB_MYSQL, connection());
		$guild = $ots->createObject('Guild');
		try {$guild->load($guild_name); } catch(Exception $e) {show_error('Problem occured while loading guild. Err code: 220912072010 Futher information: '.$e->getMessage()); }
		if(!$guild->isLoaded()) $ide->redirect(WEBSITE."/index.php/guilds");
		$player = new OTS_Player();
		try {$player->load($player_name);; } catch(Exception $e) {show_error('Problem occured while loading player. Err code: 221012072010 Futher information: '.$e->getMessage()); }
		if(!$player->isLoaded()) $ide->redirect(WEBSITE."/index.php/guilds");
		if($player->getAccount()->getId() != $_SESSION['account_id']) $ide->redirect(WEBSITE."/index.php/guilds");
		require('system/application/libraries/POT/InvitesDriver.php');
		new InvitesDriver($guild);
		$invited_list = $guild->listInvites();
		if(!in_array($player->getName(), $invited_list)) $ide->redirect(WEBSITE."/index.php/guilds");
		$this->load->model("guilds_model");
		$tarkistus = $player_name;
		$online = $this->guilds_model->CanUpdate($tarkistus);
		if($online['online'] != 0) {
			error("".$online['name']." is logged in, please logout first.");
			return false;
		}
		else {
			$guild->acceptInvite($player);
			$ide->redirect(WEBSITE."/index.php/guilds/view/".$guild->getId()."/1");
		}
	}
	
	
	public function management($id) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data = array();
		$this->load->model("guilds_model");
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isViceLeader($id) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		if($this->guilds_model->isViceLeader($id)) {
			$data['id'] = $id;
			$this->load->view("guild_vice_menu", $data);
			$this->load->view("guild_management", $data);
		}
		elseif($this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) or $this->guilds_model->isLeader($id)) {
			$data['id'] = $id;
			$this->load->view("guild_menu", $data);
			$this->load->view("guild_management", $data);
		}
	}
	
	function _isInvitable($name) {
		$this->load->model("guilds_model");
		$player = $this->guilds_model->isInvitable($name);
			if(empty($player)) {
				$this->form_validation->set_message('_isInvitable', 'Could not find this player.');
				return false;
			}
			else if($player[0]['rank_id'] != 0) {
				$this->form_validation->set_message('_isInvitable', 'This player is already in guild.');
				return false;
			}
                        else if($player[0]['online'] != 0) {
                                $this->form_validation->set_message('_isInvitable', 'This player is online!');
                                return false;
                        }
			else
				return true;
	}
	
	public function invite($id) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data = array();
		$this->load->model("guilds_model");
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isViceLeader($id) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data['id'] = $id;
			if($_POST) {
				$_POST['name'] = decodeString($_POST['name']);
				$this->load->library("form_validation");
				$this->form_validation->set_rules('name', 'Player Name', 'required|nickname|callback__isInvitable');
				if($this->form_validation->run() == true) {
					$player_id = $this->guilds_model->getCharacterId($_POST['name']);
					$this->guilds_model->invite($id, $player_id[0]['id']);
					success($_POST['name']." has been invited to ".$data['guild'][0]['name']);
					$ide->redirect(WEBSITE."/index.php/guilds/management/".$id, 2);
				}
			}
		if($this->guilds_model->isViceLeader($id)) {
			$this->load->helper("form_helper");
			$this->load->view("guild_vice_menu", $data);
			$this->load->view("guild_invite", $data);
		}
		elseif($this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) or $this->guilds_model->isLeader($id)) {
			$this->load->helper("form_helper");
			$this->load->view("guild_menu", $data);
			$this->load->view("guild_invite", $data);
		}
	}
	
	public function members($id) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data = array();
		$this->load->model("guilds_model");
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data['id'] = $id;
		$data['members'] = $this->guilds_model->getMembers($id);
		$this->load->view("guild_menu", $data);
		$this->load->view("guild_members", $data);
	}
	
	public function changeDescription($id, $player) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		$player = (int)$player;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		if(empty($player)) $ide->redirect(WEBSITE."/index.php/guilds");
		$this->load->model("guilds_model");
		$data = array();
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildMember($id, $player)) $ide->redirect(WEBSITE."/index.php/guilds/members/".$id);
		$data['description'] = $this->guilds_model->getMemberDescription($player);
		$this->load->helper("form_helper");
		$data['player'] = $player;
		$data['id'] = $id;
			if($_POST) {
				$this->load->library("form_validation");
				$this->form_validation->set_rules('description', 'Description', 'alpha_space');
				if($this->form_validation->run() == true) {
					$this->guilds_model->changeDescription($player, $_POST['description']);
					success("Description has been changed.");
					$ide->redirect(WEBSITE."/index.php/guilds/members/".$id, 2);
				}
			}
		$this->load->view("guild_menu", $data);
		$this->load->view("guild_changeDescription", $data);
	}
	
	function _isValidRank($guild, $rank) {
		$this->load->model("guilds_model");
		$ranks = $this->guilds_model->getRanksID($guild);
			foreach($ranks as $ext) {
				$external[] = $ext['id'];
			}
		if(in_array($rank, $external)) {
			return true;
		}
		else
			return false;
	}
	
	public function changeRank($id, $player) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		$player = (int)$player;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		if(empty($player)) $ide->redirect(WEBSITE."/index.php/guilds");
		$this->load->model("guilds_model");
		$data = array();
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildMember($id, $player)) $ide->redirect(WEBSITE."/index.php/guilds/members/".$id);
		
		$this->load->helper("form_helper");
			if($_POST) {
				$_POST['new'] = (int)$_POST['new'];
				if(!is_int($_POST['new']))
					@$error .= "Rank must be an integer<br/>";
					
				if(empty($_POST['new']))
					@$error .= "Invalid Rank<br/>";
					
				if(!$this->_isValidRank($id, $_POST['new']))
					@$error .= "Invalid Rank Name</br>";
					
				if(!empty($error))
					error($error);
				else {
					$this->guilds_model->changeRank($player, $_POST['new']);
					success("Rank has been changed.");
					$ide->redirect(WEBSITE."/index.php/guilds/members/".$id, 2);
				}
					
			}
		$data['current'] = $this->guilds_model->getMemberRank($player);
		$data['ranks'] = $this->guilds_model->getRanks($id);
		$data['player'] = $player;
		$data['id'] = $id;
		$this->load->view("guild_menu", $data);
		$this->load->view("guild_changeRank", $data);
	}
	
	public function kick($id, $player) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		$player = (int)$player;
		if(empty($id)) $ide->goPrevious();
		if(empty($player)) $ide->goPrevious();
		$this->load->model("guilds_model");
		$data = array();
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->goPrevious();
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isLeader($id)) $ide->goPrevious();
		if(!$this->guilds_model->isGuildMember($id, $player)) $ide->goPrevious();
		$tarkistus = $player;
		$online = $this->guilds_model->CanUpdate($tarkistus);
		if($online['online'] != 0) {
			error("".$online['name']." is logged in, it needs to be logged out.");
			return false;
		}
		else {
			$this->guilds_model->kick($player);
			$ide->redirect(WEBSITE."/index.php/guilds/members/".$id);
		}
	}
	
	public function leave($id, $player) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		$player = (int)$player;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		if(empty($player)) $ide->redirect(WEBSITE."/index.php/guilds");
		$this->load->model("guilds_model");
		$data = array();
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildMember($id, $player)) $ide->redirect(WEBSITE."/index.php/guilds/view/".$id);
		$tarkistus = $player;
		$online = $this->guilds_model->CanUpdate($tarkistus);
		if($online['online'] != 0) {
			error("Character ".$online['name']." is logged in, please logout with it first.");
			return false;
		}
		else {
			$this->guilds_model->leave($player);
			$ide->redirect(WEBSITE."/index.php/guilds/view/".$id);
		}
	}
	
	public function motd($id) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data = array();
		$this->load->model("guilds_model");
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data['id'] = $id;
		$data['motd'] = $data['guild'][0]['motd'];
			if($_POST) {
				$_POST['motd'] = decodeString($_POST['motd']);
				$this->load->library("form_validation");
				$this->form_validation->set_rules('motd', 'MOTD', 'max_lenght[255]|alpha_space');
				if($this->form_validation->run() == true) {
					$this->guilds_model->changeMotd($id, $_POST['motd']);
					success("MOTD has been changed.");
					$ide->redirect(WEBSITE."/index.php/guilds/management/".$id, 2);
				}
				
			}
		$this->load->helper("form_helper");
		$this->load->view("guild_menu", $data);
		$this->load->view("guild_motd", $data);
	}
	
	public function logo($id) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		if(empty($id)) $ide->goPrevious();
		$data = array();
		$this->load->model("guilds_model");
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->goPrevious();
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data['id'] = $id;
		
				require("config.php");
				$cfg['upload_path'] = 'public/guild_logos';
				$cfg['allowed_types'] = 'gif';
				$cfg['max_size']	= '128';
				$cfg['max_width']  = '64';
				$cfg['max_height']  = '64';
				$cfg['file_name'] = $id;
				$cfg['overwrite'] = true;
				$this->load->library('upload', $cfg);
				if($this->upload->do_upload("logo"))
					success("Logo has been changed.");
				$data['error'] = $this->upload->display_errors();
		
			
		$this->load->helper("form_helper");
		$this->load->view("guild_menu", $data);
		$this->load->view("guild_logo", $data);
	}
	
	public function delete($id) {
		$ide = new IDE;
		$ide->requireLogin();
		$id = (int)$id;
		if(empty($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$data = array();
		$this->load->model("guilds_model");
		$data['guild'] = $this->guilds_model->getGuildInfo($id);
		if(empty($data['guild'])) $ide->redirect(WEBSITE."/index.php/guilds");
		if(!$this->guilds_model->isGuildLeader($data['guild'][0]['ownerid']) and !$this->guilds_model->isLeader($id)) $ide->redirect(WEBSITE."/index.php/guilds");
		$this->guilds_model->deleteGuild($id);
		
		$this->load->model("forum_model");		
		$this->forum_model->deleteBoardByGuild($id);
		
		$ide->redirect(WEBSITE."/index.php/guilds");
	}

}
?>


2. system/application/models/guilds_model.php
Code:
<?php
class Guilds_Model extends Model {
	public function getGuildsList($world_id = null) {
		$this->load->database();
		$ext = (!empty($world_id)) ? "WHERE `world_id` = '$world_id'": "";
		$guilds = array();
		$sql = $this->db->query("SELECT `id`, `world_id`, `name`, `motd` FROM `guilds` $ext")->result();
			foreach($sql as $cmd) {
				$guilds[] = array("id"=>$cmd->id, "world_id"=>$cmd->world_id, "name"=>$cmd->name, "motd"=>$cmd->motd);
			}
		return $guilds;
	}
	
	public function getCharactersAllowedToCreateGuild($level = 0) {
		$this->load->database();
		$characters = array();
		$sql = $this->db->query("SELECT `id`, `name`, `level` FROM `players` WHERE `rank_id` = '0' AND `online` = 0 AND `level` >= '{$level}' AND `account_id` = '{$_SESSION['account_id']}'")->result();
		foreach($sql as $cmd) {
			$characters[] = array('id'=>$cmd->id, 'name'=>$cmd->name,'level'=>$cmd->level);
		}
		return $characters;
	}
	
	public function checkPlayerCreatingGuild($id) {
		require_once("system/application/config/create_character.php");
		$this->load->database();
		$sql = $this->db->query("SELECT `id` FROM `players` WHERE `id` = '$id' AND `online` = 0 AND `level` >= '".LEVELTOCREATEGUILD."' AND `account_id` = '{$_SESSION['account_id']}'")->row_array();
		if(count($sql) == 0) return false; else return true;
	}
	
	public function checkGuildName($name) {
		$this->load->database();
		$name = $this->db->escape($name);
		$sql = $this->db->query('SELECT `id` FROM `guilds` WHERE `name` = "'.$name.'"')->row_array();
		if(count($sql) == 0) return true; else return false;
	
	}
	
	public function createGuild($name, $character) {
		$ots = POT::getInstance();
		$ots->connect(POT::DB_MYSQL, connection());
		$player = new OTS_Player();
		$player->load($character);
		$new_guild = new OTS_Guild();
		$new_guild->setCreationData(time());
		$new_guild->setName($name);
		$new_guild->setOwner($player);
		$new_guild->save();
		$new_guild->setCustomField('motd', 'New guild. Leader must edit this text :)');
		$new_guild->setCustomField('creationdata', time());
		$new_guild->setCustomField('world_id', $player->getWorld());
		$ranks = $new_guild->getGuildRanksList();
		$ranks->orderBy('level', POT::ORDER_DESC);
		foreach($ranks as $rank)
			if($rank->getLevel() == 3)
			{
				$player->setRank($rank);
				$player->save();
			}
		return $new_guild->getId();
	}
	
	public function getGuildInfo($id) {
		$this->load->database();
		return $this->db->query("SELECT `world_id`, `name`, `ownerid`, `creationdata`, `motd` FROM `guilds` WHERE `id` = '".$id."'")->result_array();
	}
	
	public function isGuildLeader($id) {
		$this->load->database();
		return ($this->db->query("SELECT `id` FROM `players` WHERE `id` = '".$id."' AND `account_id` = '".$_SESSION['account_id']."' ")->num_rows == 0) ? false: true;
	}

	public function isViceLeader($id) {
        	$this->load->database();
        	$viceRank = 2;
	        return ($this->db->query("SELECT `p`.`id`, `p`.`name` FROM `guild_ranks` AS `r` LEFT JOIN `players` AS `p` ON `p`.`rank_id` = `r`.`id` WHERE `r`.`guild_id` = '".$id."' AND `r`.`level` = '".$viceRank."' AND `p`.`account_id` = '".$_SESSION['account_id']."' ")->num_rows == 0) ? false: true;
    	}
		
	public function isLeader($id) {
        	$this->load->database();
        	$Rank = 3;
	        return ($this->db->query("SELECT `p`.`id`, `p`.`name` FROM `guild_ranks` AS `r` LEFT JOIN `players` AS `p` ON `p`.`rank_id` = `r`.`id` WHERE `r`.`guild_id` = '".$id."' AND `r`.`level` = '".$Rank."' AND `p`.`account_id` = '".$_SESSION['account_id']."' ")->num_rows == 0) ? false: true;
    	}  
	
	public function isInvitable($name) {
		$this->load->database();
		return $this->db->query("SELECT `rank_id`, `online` FROM `players` WHERE `name` = \"".$name."\"")->result_array();
	}
	
	public function getCharacterId($name) {
		$this->load->database();
		return $this->db->query("SELECT `id` FROM `players` WHERE `name` = \"".$name."\"")->result_array();
	}
	
	public function invite($id, $player) {
		$this->load->database();
		$this->db->query("INSERT INTO `guild_invites` VALUES('".$player."', '".$id."')");
	}
	
	public function getMembers($id) {
		$this->load->database();
		return $this->db->query("SELECT players.id, players.name, guild_ranks.name AS guild_rank FROM guild_ranks LEFT JOIN players ON rank_id = guild_ranks.id WHERE guild_ranks.guild_id = '".$id."' ORDER BY guild_ranks.level DESC")->result_array();
	}
	
	public function isGuildMember($id, $player) {
		$this->load->database();
		return ($this->db->query("SELECT players.rank_id FROM players, guild_ranks WHERE players.rank_id = guild_ranks.id AND players.id = '".$player."' AND guild_ranks.guild_id = '".$id."'")->num_rows == 0) ? false: true;
	}
	
	public function getMemberDescription($id) {
		$this->load->database();
		return $this->db->query("SELECT `guildnick` FROM `players` WHERE `id` = '".$id."'")->result_array();
	}
	
	public function changeDescription($player, $desc) {
		$this->load->database();
		$this->db->query("UPDATE players SET guildnick = \"".$desc."\" WHERE id = '".$player."'");
	}
	
	public function getMemberRank($id) {
		$this->load->database();
		return $this->db->query("SELECT rank_id FROM players WHERE id = '".$id."'")->result_array();
	}
	
	public function getRanks($id) {
		$this->load->database();
		return $this->db->query("SELECT `name`, `id` FROM guild_ranks WHERE guild_id = '".$id."'")->result_array();
	}
	
	public function getRanksID($id) {
		$this->load->database();
		return $this->db->query("SELECT `id` FROM guild_ranks WHERE guild_id = '".$id."'")->result_array();
	}
	
	public function changeRank($player, $rank) {
		$this->load->database();
		$this->db->query("UPDATE `players` SET `rank_id` = '".$rank."' WHERE `id` = '".$player."'");
	}
	
	public function kick($id) {
		$this->load->database();
		$this->db->query("UPDATE `players` SET `guildnick` = '', `rank_id` = '0' WHERE `id` = '".$id."'");
	}
	
	public function leave($id) {
		$this->load->database();
		$this->db->query("UPDATE `players` SET `guildnick` = '', `rank_id` = '0' WHERE `id` = '".$id."'");
	}
	
	public function changeMotd($id, $motd) {
		$this->load->database();
		$this->db->query("UPDATE `guilds` SET `motd` = \"".$motd."\" WHERE `id` = '".$id."'");
	}
	
	public function deleteGuild($id) {
		$this->load->database();
		$this->db->query("DELETE FROM `guilds` WHERE `id` = '".$id."'");
		//Triggers should do rest of the job.
			if(file_exists("public/guild_logos/".$id.".gif"))
				unlink("public/guild_logos/".$id.".gif");
	}
	public function canUpdate($tarkistus) {
		$this->load->database();
		$sql = $this->db->query("SELECT `online`, `name` FROM `players` WHERE `id` = ".$tarkistus."")->row_array();
		return $sql;	
	}
	
}
?>


----------------------------------------------------------------
3.In "system/application/views/view_guild.php" replace this code part
Code:
        if($ide->isLogged() && in_array($guild->getOwner(), $account_players)) {
                echo "<br/><div class='toolbar'>";
                echo "<a href='".WEBSITE."/index.php/guilds/management/".$guild->getId()."'>Guild Management</a>";     
                echo "</div>";
        }
with this
Code:
	if($ide->isLogged() && in_array($guild->getOwner(), $account_players) || $leaders) {
		echo "<table style='text-align: center; margin-top: 10px;'><tr class='first'><td>Guild Management</td></tr><tr><td>";
		echo "<a href='".WEBSITE."/index.php/guilds/management/".$guild->getId()."'>Guild Management</a>";	
		echo "</td></tr></table>";
	}
	
	if(($ide->isLogged() && $viceleaders)) {
		echo "<table style='text-align: center; margin-top: 10px;'><tr class='first'><td>Guild Management</td></tr><tr><td>";
		echo "<a href='".WEBSITE."/index.php/guilds/management/".$guild->getId()."'>Guild Management</a>";	
		echo "</td></tr></table>";
	}

----------------------------------------------------------------
4.Make new php file at "system/application/views/" and name it as "guild_vice_menu"
Code:
<div class="toolbar" style="margin-bottom: 10px; text-align: center;">
	<a href='<?php echo WEBSITE;?>/index.php/guilds/invite/<?php echo $id; ?>'>Invite Player</a>
</div>

----------------------------------------------------------------
Thats it, your done :D!

I'll also include the files as attachment if your too lazy to copy paste those codes.
View attachment guild fix by mipo91.rar

Rep++ if you use this fix.
 
Last edited:
elK4ld
 
Well I thought those were the only guild bugs there even were in modern aac. Oh forgot to mention that I also fixed the kicking problem too(white page).
 
which rev are you using? I can't even make a guild, I'm using 244.

All your characters are already in guild or they don't have required level. (1)
My CM character is level two.

btw. thanks for the files
 
didnt work for m e:S

Then you did something wrong, because it works for me and others too...
Remember that you cant be logged in game if you want to leave from guild or do any other options which is related to players.
 
hey i get the same errors as venn :(, when i try to acces the guilds page
what did i do wrong?
 
They are notices, not errors. You can disable them in php.ini file.
 
Depends on Operating System, also I've heard google has some info.
 
oh yes he told me.. /etc/php5/apache2/php.ini
but now.. what should i edit :S i dont want to mess something up!
thanks
 
Back
Top