So this mod is one I got working thanks to reading posts by: Dinocanid, draugluin, and Abronsyth on an old post here: 1.3.1 Group Sorting Mod
This mod will work for 1.3.4, 1.3.5, and with tweaking it might work for 1.3.6 but I'm not sure.
It works by placing a sorting drop-down on your myadopts page and you can go through the groups that you made and hit "Go" to go to that specified group you selected in the drop-down. You can also create a group or delete a group from the myadopts page. To assign your pets to a group you have created you need to go to their manage page. You can also set how many groups a user can make, I have mine set to 8 but the original was 5.
So let's set up the database since it's the easiest.
You want to make a new database table called: adopts_pet_groups and include this info:
id INT 11 Auto Increment
name VARCHAR 15
username VARCHAR 20
uid INT 11
and it's done after you hit submit. Then you want to go to adopts_owned_adopts table and add a new structure with this info:
pet_group INT 11 As Defined 0
then submit. We're done with the database now.
__________________________________________
So the easier files to make is what we'll start with. We need to make two new PHP pages, a regular and a view.
First let's create: petgroup.php in your root folder where all the regular php pages are and inside paste this:
This mod will work for 1.3.4, 1.3.5, and with tweaking it might work for 1.3.6 but I'm not sure.
It works by placing a sorting drop-down on your myadopts page and you can go through the groups that you made and hit "Go" to go to that specified group you selected in the drop-down. You can also create a group or delete a group from the myadopts page. To assign your pets to a group you have created you need to go to their manage page. You can also set how many groups a user can make, I have mine set to 8 but the original was 5.
So let's set up the database since it's the easiest.
You want to make a new database table called: adopts_pet_groups and include this info:
id INT 11 Auto Increment
name VARCHAR 15
username VARCHAR 20
uid INT 11
and it's done after you hit submit. Then you want to go to adopts_owned_adopts table and add a new structure with this info:
pet_group INT 11 As Defined 0
then submit. We're done with the database now.
__________________________________________
So the easier files to make is what we'll start with. We need to make two new PHP pages, a regular and a view.
First let's create: petgroup.php in your root folder where all the regular php pages are and inside paste this:
<?php
class PetgroupController extends AppController{
public function __construct(){
parent::__construct("member");
}
public function index(){
$mysidia = Registry::get("mysidia");
}
public function creategroup(){
$mysidia = Registry::get("mysidia");
}
public function deletegroup(){
$mysidia = Registry::get("mysidia");
}
}
?>
Then it's done. Next, we'll need to go to the view files in the root folder and create: petgroupview.php and inside paste this:
<?php
class PetgroupView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("<center>Sort Testing!</center>");
//pet group variables? I think?
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$group = $_REQUEST["group"];
}
//var end
//convenient vars
$username = $mysidia->user->username;
$uid = $mysidia->user->uid;
//var end
//Pet sorting!
if(!$group == ""){
if(!is_numeric($group)){
$document->setTitle("No group");
$document->add(new Comment("Group does not exist."));
return;
}
else{
$row = $mysidia->db->select("pet_groups", array(), "uid='{$uid}' and id='{$group}'")->fetchObject();
if($row->id == $group and $row->uid == $uid){
$groupquery = "AND pet_group = '{$group}'";
}
else{ // Invalid group
$article_title = "No group";
$article_content = "Group does not exist.";
}
}
}
else{
$groupquery = "AND pet_group = '0'";
}
// We need to get all of the user's adoptables from the database and display them...
$rowsperpage = 10;
//$pagination = new Pagination($adopts, $query, $rowsperpage, "http://".constant("DOMAIN").constant("SCRIPTPATH")."/stable.php?group={$group}");
//$pagination->setPage($_GET[page]);
$pagination = new Pagination($total, 10, "myadopts");
$pagination->setPage($mysidia->input->get("page"));
//$stmt = $mysidia->db->query($query);
$stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' {$groupquery} ORDER BY totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}");
$groups = ""; // Get groups
$stmt2 = $mysidia->db->select("pet_groups", array(), "uid='{$uid}'");
$document->add(new Comment("
<b>Group:</b><br>
<form method='post' action='petgroup'>
<select name='group' id='group'>
<option value='0'>Ungrouped</option>"));
while($row = $stmt2->fetchObject()) {
$id = $row->id;
$name = $row->name;
$document->add(new Comment("<option value='{$id}'>{$name}</option>"));
}
$document->add(new Comment("
</select><br>
<input type='submit' value='Go'>
</form>
<a href='petgroup/creategroup'>Create a new group</a> | <a href='petgroup/deletegroup'>Delete a group</a>
<br><br>
<table class='table table-bordered table-dark'>
<thead>
<tr>
<th>Image</th>
<th>Info</th>
<th>Action</th>
</tr>
</thead>
<tbody>", FALSE));
while($row = $stmt->fetchObject()){
$adopt = new OwnedAdoptable($row->aid);
$image = $adopt->getImage();
$document->add(new Comment("
<tr>
<td><img src='{$adopt->getImage()}'></td>
<td><b><em>{$adopt->getName()}</b></em><br></br> Level {$adopt->getCurrentLevel()}<br></br> {$Gender}</td>
<td><a href='/myadopts/manage/{$row->aid}' class='btn btn-primary' style='width:200px; height:auto;'>Manage</a></td>
</tr>
", FALSE));
}
$document->add(new Comment("</table><br /><br />{$pagination->showPage()}"));
//Sorting end
}
public function creategroup(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$username = $mysidia->user->username;
$uid = $mysidia->user->uid;
$document->setTitle("Group Sorting");
$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
if($groupCount >= 5) {
$document->setTitle("Sorry!");
$document->add(new Comment("You can only have 5 groups. <br><br> <a href='myadopts'>Go back?</a>"));
}
else{
$document->setTitle("Create a new group");
$document->add(new Comment("
<form method='post' action='creategroup'>
Here is where you can create a group type for your dinosaurs or pets.
<br><br>Recommended groups are:
<br>
<br><b>Dinosaurs
<br>Canines
<br>Felines
<br>Fowl
<br>Equine
<br>Bovine
<br>Fish</b>
<br>____________________<br>
<br><b>Group Name:</b><br>
<b>Note:</b> <i>Max length is 15 characters and you can have a total of 8 groups.</i>
<br><br>
<input type='text' name='groupname' id='groupname' maxlength='15' /><br><br>
<input id='sortbutton' type='submit' name='submit'>
</form>
<a href='https://dinotracks.mysidiahost.com/myadopts'>Go back to View Pets & Dinosaurs</a>
<style>
input#sortbutton {
font-size: 14px;
padding: 0px 0px;
width: 70px;
}
input#sortbutton {
font-size: 14px;
border-radius: 30px;
box-shadow: 0px 2px #828282;
background-color: #31c458;
cursor: pointer;
display: inline-block;
}
input#sortbutton:hover {
background-color: #000000;
color: #ffffff;
transform: translateY(1px);
}
</style>"));
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
if($groupCount >= 5) {
$document->setTitle("Sorry!");
$document->add(new Comment("You can only have 8 groups. <br><br> <a href='https://dinotracks.mysidiahost.com/myadopts'>Go back to View Pets & Dinosaurs</a>"));
}
else{
$groupname = $_REQUEST["groupname"];
$mysidia->db->insert("pet_groups", array("username" => $username, "uid" => $uid, "name" => $groupname));
$group = $mysidia->db->select("pet_groups", array(), "name='{$groupname}' and uid='{$uid}'")->fetchObject();
$id = $group->id;
$document->setTitle("Created group ''{$groupname}''");
$document->add(new Comment("<br><b>
You created a new group called '{$groupname}'.</b><br><br>"));
}
}
}
public function deletegroup(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$username = $mysidia->user->username;
$uid = $mysidia->user->uid;
$stmt2 = $mysidia->db->select("pet_groups", array(), "uid='{$uid}'");
$document->setTitle("Delete a Group");
$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
if($groupCount = 0) {
$document->setTitle("Sorry!");
$document->add(new Comment("You don't have any groups. <br><br> <a href='https://dinotracks.mysidiahost.com/myadopts'>Go back to View Pets & Dinosaurs</a>"));
}
else{
$document->setTitle("<center>Delete a group</center>");
$document->add(new Comment("
<b>Group:</b><br>
<form method='post' action='deletegroup'>
<select name='group' id='group'>
<option value='0' {$selected}>Ungrouped</option>"));
while($row = $stmt2->fetchObject()) {
$id = $row->id;
$name = $row->name;
$document->add(new Comment("<option value='{$id}'>{$name}</option>"));
}
$document->add(new Comment("
</select><br><br>
<input id='sortbutton' type='submit' value='Go'>
</form>
<a href='https://dinotracks.mysidiahost.com/myadopts'>Go back to View Pets & Dinosaurs</a>
<style>
input#sortbutton {
font-size: 14px;
padding: 0px 0px;
width: 70px;
}
input#sortbutton {
font-size: 14px;
border-radius: 30px;
box-shadow: 0px 2px #828282;
background-color: #31c458;
cursor: pointer;
display: inline-block;
}
input#sortbutton:hover {
background-color: #000000;
color: #ffffff;
transform: translateY(1px);
}
</style>"));
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$group = $_REQUEST["group"];
$group_info = $mysidia->db->select("pet_groups", array(), "id='{$group}' and uid='{$uid}'")->fetchObject();
$document->setTitle("Deleted ''{$group_info->name}''");
$document->add(new Comment("<br><b>
'{$group_info->name}' has been deleted. All pets and dinosaurs that were in this group are now organized under: ''ungrouped''.</b><br><br>"));
$mysidia->db->update("owned_adoptables", array("pet_group" => 0), "pet_group = '{$group}'");
$mysidia->db->delete("pet_groups", "uid='{$uid}' AND id = '{$group}'");
}
}
}
?>