Jump to content
MakeWebGames

Copy + Paste Clan Update


Uridium

Recommended Posts

this is just a copy and paste for clans it will allow those who have asked to join a clan the chance to Cancel their own request incase Clan owner doesn't respond..

clans/content.php

 

<?php
global $clanName,$memberOf,$clanRole;
$memberOf = 0;
$clanRole = 0;

if ($memberOf == 0 && isset($_GET["cmd"]) && $_GET["cmd"] == "create_clan")
{
   if (isset($_POST["name"]) && isset($_POST["desc"]))
   {
       if ($userStats["!Currency"]->value < intval(GetConfigValue("clansCreationCost")))
       {
           ErrorMessage("You don't have enough !Currency.");
       }
       else
       {
           $allOk = true;
           $result = $db->Execute("select id from clans where name = ? limit 0,1", $_POST["name"]);
           if (! $result->EOF)
           {
               $allOk = false;
               ErrorMessage("This clan name is already used. Choose another one.");
           }
           $result->Close();

           if ($allOk)
           {
               $db->Execute("insert into clans(name,description) values(?,?)", $_POST["name"], $_POST["desc"]);
               $clanId = $db->LastId();
               $db->Execute("insert into clans_roles(user_id,clan_id,role_id) values(?,?,?)", $userId, $clanId, 1000);
               $userStats["!Currency"]->value -= intval(GetConfigValue("clansCreationCost"));

               ResultMessage("Your clan has been created. Please wait for the reload.");
               echo "<script>setTimeout(\"document.location='index.php?p=clans';\",1000);</script>";
               return;
           }
       }
   }

   TableHeader("Create new clan");
   echo "<form method='post' name='frmCreateClan'>";
   echo Translate("Creation of a clan costs %d !Currency.", GetConfigValue("clansCreationCost"));
   echo "<table class='plainTable'>";
   echo "<tr><td width='1%'><b>" . str_replace(" ", " ", Translate("Clan name")) . ":</b></td>";
   echo "<td><input type='text' name='name' value='" . (isset($_POST["name"]) ? htmlentities($_POST["name"]) : "") . "'></td></tr>";
   echo "<tr><td width='1%' valign='top'><b>" . str_replace(" ", " ", Translate("Description")) . ":</b></td>";
   echo "<td><textarea type='text' name='desc' rows='5'>" . (isset($_POST["desc"]) ? htmlentities($_POST["desc"]) : "") . "</textarea></td></tr>";
   echo "</table>";
   echo "</form>";
   TableFooter();

   ButtonArea();
   if ($userStats["!Currency"]->value >= intval(GetConfigValue("clansCreationCost")))
       SubmitButton("Pay", "frmCreateClan");
   LinkButton("Cancel", "index.php?p=clans");
   EndButtonArea();
   return;
}

$result = $db->Execute("select clan_id, role_id from clans_roles where user_id = ?", $userId);
if (! $result->EOF)
{
   $memberOf = $result->fields[0] + 0;
   $clanRole = $result->fields[1] + 0;
}
$result->Close();
if ($clanRole == 0 && isset($_GET["cmd"]) && $_GET["cmd"] == "canceljoin")

{

  global $db, $userId;
   $db->Execute("select user_id from clans_roles where user_id = ?", $userId);
//$db->Execute("update clans set memb_count=memb_count - 1 where id = ?", $memberOf);
	 $db->Execute("delete from clans_roles where user_id = ? limit 1", $userId);
   if (function_exists("SendMessage"))
       Translate("Clan Request Cancelled"); 
	Translate("You chose to cancel your clan request..");
   ResultMessage("Your request to cancel from this clan has been granted.");
 echo "<script>setTimeout(\"document.location='index.php?';\",3000);</script>";
 return;

}
// Ask to join
if ($memberOf == 0 && isset($_GET["cmd"]) && $_GET["cmd"] == "join")
{
   $result = $db->Execute("select name from clans where id = ?", $_GET["id"] + 0);
   if ($result->EOF)
   {
       header("Location: index.php?p=clans");
       $result->Close();
       return;
   }

   $clanName = $result->fields[0];
   $result->Close();

   $db->Execute("insert into clans_roles(clan_id,role_id,user_id) values(?,?,?)", $_GET["id"], 0, $userId);
   $memberOf = $_GET["id"] + 0;
   $clanRole = 0;

   // Send message to all clans masters
   if (function_exists("SendMessage"))
   {
       $result = $db->Execute("select user_id from clans_roles where clan_id = ? and role_id = 1000", $_GET["id"]);
       while (! $result->EOF)
       {
           SendMessage($result->fields[0], Translate("%s asked to join %s", $username, $clanName), 
                   Translate("%s asked if he could join the clan %s. If you want to accept they or refuse they, please head to the clans admin panel.", $username, $clanName));
           $result->MoveNext();
       }
       $result->Close();
   }
}

// Waiting approval
if ($memberOf != 0 && $clanRole == 0)

{

   TableHeader("Waiting approval");

   echo Translate("Your request has been sent to the clan masters, you now need to wait.");
TableHeader("status");
$result = $db->Execute(
       "select users.id, users.username, clans_role_types.name
       from clans_roles left join users on clans_roles.user_id = users.id
       left join clans_role_types on clans_roles.role_id = clans_role_types.id
       where clans_roles.clan_id = ? order by clans_roles.role_id desc, users.username LIMIT 1", $memberOf);

	echo "<table class='plainTable'>";
	 echo "<tr class='titleLine'><td>" . str_replace(" ", " ", Translate("Clan Owner")) . "</td><td>" . str_replace(" ", " ", Translate("Status")) . "</td><td>" . str_replace(" ", " ", Translate("Option")) . "</td></tr>";
$row = 0;
while (! $result->EOF)
{
   if($row%2 == 0)
       echo "<tr class='evenLine'>";
   else
       echo "<tr class='oddLine'>";
   if(in_array("view_player",$modules))
       echo "<td><a href='index.php?p=view_player&id={$result->fields[0]}'>{$result->fields[1]}</a></td>";
   else
       echo "<td>{$result->fields[1]}</td>";
   echo "<td>{$result->fields[2]} </td>";


           echo "<td width='2%'>";
          LinkButton("Cancel Request", "index.php?p=clans&cmd=canceljoin");
           echo "</td>";

   echo "</tr>";
   $result->MoveNext();
   $row ++;
}
echo "</table>";
TableFooter();
}

// Not member, may join?
if ($memberOf == 0)
{
   TableHeader("List of available clans");
   echo "<table class='plainTable'>";
   $result = $db->Execute("select id,name,description from clans order by name");
   $row = 0;
   while (! $result->EOF)
   {
       if ($row % 2 == 0)
           echo "<tr class='evenLine' valign='top'>";
       else
           echo "<tr class='oddLine' valign='top'>";
       echo "<td width='1%'>";
       LinkButton("Join", "index.php?p=clans&cmd=join&id={$result->fields[0]}");
       echo "</td>";
       echo "<td>" . htmlentities($result->fields[1]) . "</td>";
       echo "<td>" . PrettyMessage($result->fields[2]) . "</td>";
       echo "</tr>";
       $row ++;
       $result->MoveNext();
   }
   $result->Close();
   echo "</table>";
   TableFooter();

   ButtonArea();
   LinkButton("Create your own clan", "index.php?p=clans&cmd=create_clan");
   EndButtonArea();
   return;
}

if ($memberOf != 0 && $clanRole != 0)
{
   $result = $db->Execute("select name from clans where id = ?", $memberOf);
   $clanName = $result->fields[0];
   $result->Close();

   global $menuEntries;
   $menuEntries = array();
   RunHook("clans_menu.php", "menuEntries");
   MenuEntry::Sort($menuEntries);

       echo "<table class='plainTable'>";
   echo "<tr valign='top'><td width='1%'>";
   TableHeader("Clan Menu");
   foreach ($menuEntries as $entry)
   {
       if (strncmp($entry->link, "index.php", 9) == 0)
           echo "<a href='{$entry->link}'>" . Translate($entry->label) . "</a><br>";
       else
           echo "<a href='index.php?p=clans&c={$entry->link}'>" . Translate($entry->label) . "</a><br>";
   }
   TableFooter();
   echo "<img src='{$webBaseDir}images/separator.gif' width='180' height='1'>";
   echo "</td>";
   echo "<td>";
   if (isset($_GET["c"]) && in_array($_GET["c"], $modules) && file_exists("$baseDir/modules/" . $_GET["c"] . "/in_clans.php"))
   {
       include "$baseDir/modules/" . $_GET["c"] . "/in_clans.php";
   }
   else
   {
       echo "<div class='box'>";
       RunHook("clan_home.php",array("clanName","memberOf","clanRole"));
       echo "</div>";

       RunHook("clan_home_special.php",array("clanName","memberOf","clanRole"));
   }
   echo "</td></tr>";
   echo "</table>";
}

 

Preview image is available...

** FOOTNOTE ** this version of the clans script is that of version 1.0.3

request.thumb.jpg.b1414b55b44d6886a4ca8345bf3baf4c.jpg

Edited by illusions
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...