Figured I would attempt to break guilds tab.
Had to tweak it a little to fit the new button and I think its kind of ugly but not sure if its really something useful so making it pretty can come later.

Grabs the next ID for you, just need to input the guild name and the name of the character that is to be the leader.
Not sure if guild names can contain characters that require escaping for sql so did not attempt to check for that in the query. So "Dan's party guild" would probably fail to insert.
Code:
Index: css/peq.css
===================================================================
--- css/peq.css (revision 376)
+++ css/peq.css (working copy)
@@ -242,4 +242,10 @@
.indented {
margin: 5px 0px 0px 10px;
+}
+
+.newgid {
+ color: darkred;
+ font-size: 12px;
+ font-weight: bold;
}
\ No newline at end of file
Index: lib/guild.php
===================================================================
--- lib/guild.php (revision 376)
+++ lib/guild.php (working copy)
@@ -70,6 +70,16 @@
delete_guild();
header("Location: index.php?editor=guild");
exit;
+ case 6: // Add new guild template
+ check_admin_authorization();
+ $body = new Template("templates/guild/guild.addnew.tmpl.php");
+ $body->set('new_guild_id', getNextGuildID());
+ break;
+ case 7: // Add new guild submission
+ check_admin_authorization();
+ add_new_guild();
+ header("Location: index.php?editor=guild");
+ exit;
}
function guild_info () {
@@ -116,4 +126,26 @@
global $mysql, $playerid;
//Delete guild info here
}
+
+function getNextGuildID () {
+global $mysql;
+$query = "SELECT MAX(id) as id FROM guilds";
+$result = $mysql->query_assoc($query);
+return ($result['id'] + 1);
+}
+
+function add_new_guild () {
+ global $mysql;
+ $guild_name = $_POST['guild_name'];
+ $new_guild_id = $_POST['new_guild_id'];
+ $leader_name = $_POST['leader_name'];
+ $query = "SELECT id FROM character_ AS id WHERE name=\"$leader_name\"";
+ $result = $mysql->query_assoc($query);
+ $char_id = $result['id'];
+ $query = "INSERT INTO guilds SET id=$new_guild_id, name=\"$guild_name\", leader=$char_id";
+ $mysql->query_no_result($query);
+ $query = "INSERT INTO guild_members SET char_id=$char_id, guild_id=$new_guild_id, rank=1";
+ $mysql->query_no_result($query);
+}
+
?>
\ No newline at end of file
Index: templates/guild/guild.addnew.tmpl.php
===================================================================
--- templates/guild/guild.addnew.tmpl.php (revision 0)
+++ templates/guild/guild.addnew.tmpl.php (working copy)
@@ -0,0 +1,27 @@
+<div style="width: 275px; margin: auto;">
+ <div style="border: 1px solid black;">
+ <div class="edit_form_header">Create a new guild</div>
+ <div class="edit_form_content">
+ <form name="guild" method="post" action="index.php?editor=guild&action=7">
+
+<table width="100%">
+ <tr>
+ <td><strong>Guild Name:</strong></td>
+ <td><strong>Leader Name:</strong></td>
+ <td><strong>New Guild ID:</strong></td>
+ </tr>
+ <tr>
+ <td><input size="8" type="text" name="guild_name" value="<?=$guild_name?>"></td>
+ <td><input size="8" type="text" name="leader_name" value="<?=$leader_name?>"></td>
+ <td align="center" class="newgid"><input type="hidden" name="new_guild_id" value="<?=$new_guild_id?>"><?=$new_guild_id?></td>
+ </tr>
+</table>
+<br>
+<center>
+ <input type="submit" value="Submit"> <input type="button" value="Cancel" onclick="history.back()">
+</center>
+
+ </form>
+ </div>
+ </div>
+</div>
\ No newline at end of file
Index: templates/searchbar/searchbar.guild.tmpl.php
===================================================================
--- templates/searchbar/searchbar.guild.tmpl.php (revision 376)
+++ templates/searchbar/searchbar.guild.tmpl.php (working copy)
@@ -1,5 +1,11 @@
<div id="searchbar">
<table width="100%">
+ <tr>
+ <th align="center">Select by menu</th>
+ <th align="center">Select by guild id or name</th>
+ <th align="center">Select by char id or name</th>
+ <th align="center">Add new</th>
+ </tr>
<tr>
<td>
<strong>1.</strong>
@@ -21,7 +27,7 @@
?>
</select>
</td>
- <td> or <strong> 2.</strong>
+ <td><strong> 2.</strong>
<form action="index.php" method="GET">
<input type="hidden" name="editor" value="guild">
<input type="hidden" name="action" value="2">
@@ -29,7 +35,7 @@
<input type="submit" value=" GO ">
</form>
</td>
- <td> or <strong> 3.</strong>
+ <td><strong> 3.</strong>
<form action="index.php" method="GET">
<input type="hidden" name="editor" value="guild">
<input type="hidden" name="action" value="3">
@@ -37,6 +43,13 @@
<input type="submit" value=" GO ">
</form>
</td>
+ <td><strong> 4.</strong>
+ <form action="index.php" method="GET">
+ <input type="hidden" name="editor" value="guild">
+ <input type="hidden" name="action" value="6">
+ <input type="submit" value=" Create ">
+ </form>
+ </td>
</tr>
</table>
</div>