/** * inserts a new guild to database * * we always add guilds with an id greater than zero. this way, the guild with id=zero is the "guildless" guild * the zero guild is added by default in a new install. * do not delete the zero record in the guild table or you will see that guildless members * become invisible in the roster and in the memberlist or in any list member selection that makes * an inner join with the guild table. */ public function MakeGuild() { global $cache, $user, $db, $phpEx, $phpbb_root_path; if ($this->name == null || $this->realm == null) { trigger_error($user->lang['ERROR_GUILDEMPTY'], E_USER_WARNING); } $cache->destroy('sql', GUILD_TABLE); // check existing guild-realmname $result = $db->sql_query("SELECT count(*) as evcount from " . GUILD_TABLE . "\n\t\t\tWHERE id !=0 AND UPPER(name) = '" . strtoupper($db->sql_escape($this->name)) . "'\n\t\t\tAND UPPER(realm) = '" . strtoupper($db->sql_escape($this->realm)) . "'"); $grow = $db->sql_fetchrow($result); if ($grow['evcount'] != 0) { trigger_error($user->lang['ERROR_GUILDTAKEN'], E_USER_WARNING); } $result = $db->sql_query("SELECT MAX(id) as id FROM " . GUILD_TABLE . ";"); $row = $db->sql_fetchrow($result); $this->guildid = (int) $row['id'] + 1; //@todo complete this $this->aionlegionid = 0; $this->aionserverid = 0; $query = $db->sql_build_array('INSERT', array('game_id' => $this->game_id, 'id' => $this->guildid, 'name' => $this->name, 'realm' => $this->realm, 'region' => $this->region, 'roster' => $this->showroster, 'aion_legion_id' => $this->aionlegionid, 'aion_server_id' => $this->aionserverid, 'min_armory' => $this->min_armory, 'guilddefault' => $this->guilddefault, 'armory_enabled' => $this->armory_enabled, 'rec_status' => $this->recstatus, 'recruitforum' => $this->recruitforum, 'members' => 0)); $db->sql_query('INSERT INTO ' . GUILD_TABLE . $query); //add a default rank if (!class_exists('\\bbdkp\\controller\\guilds\\Ranks')) { require "{$phpbb_root_path}includes/bbdkp/controller/guilds/Ranks.{$phpEx}"; } $newrank = new Ranks($this->guildid); // add guildleader rank $newrank->RankName = $user->lang['GUILDLEADER']; $newrank->RankId = 0; $newrank->RankHide = 0; $newrank->RankPrefix = ''; $newrank->RankSuffix = ''; $newrank->Makerank(); $log_action = array('header' => 'L_ACTION_GUILD_ADDED', 'id' => $this->guildid, 'L_USER' => $user->data['user_id'], 'L_USERCOLOUR' => $user->data['user_colour'], 'L_NAME' => $this->name, 'L_REALM' => $this->realm, 'L_ADDED_BY' => $user->data['username']); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action)); $this->ApiUpdateBattleNet($this->GetApiInfo(array()), array()); return true; }