Mys 1.3.1 Group sort

Forum
Last Post
Threads / Messages
Link

When I click the create group link, it brings me to a page that says resource requested was not found on this server.

I'm wondering if it's an issue with the link. Because Stargirl's site was about ponies and the link had stable.php...
 
:(

Mmm, I'm just wondering if this is the link it's supposed to be. As soon as I get the answer everything will work. Maybe someone else knows...
 
Anyone that can revive this mod or remake it altogether? It would be really great.
 
Has anyone made any progress with this..? :3 It's a feature I've been trying to implement but have been failing badly at... XD
 
I managed to convert the main part of the script, which involves creating groups and sorting pets on the myadopts index.
5136285479206912.png

That's the table setup for adopts_pet_groups. You need new column in owned_adoptables called "pet_group". (Not "group! "group" is a reserved name in phpMyAdmin.) Also make sure that "default as defined" is set to 0.
I did the entire thing in blank.php/blankview.php for testing purposes, so that's why it looks the way it does.
PHP:
<?php
class BlankView 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='blank'>
    					<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='blank/creategroup'>Create a new group</a> | <a href='blank/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("<center>Sort Testing!</center>");
          		$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
        		if($groupCount >= 5) {
        			$document->setTitle("<center>Sorry!</center>");
        			$document->add(new Comment("You can only have 5 groups. <br><br> <a href='myadopts'>Go back?</a>"));
        		}
        		else{
 				$document->setTitle("<center>Create a new group</center>");
 				$document->add(new Comment("
 					<form method='post' action='creategroup'>
						<b>Group Name:</b> <br>
						Max length is 15.<br>
						<input type='text' name='groupname' id='groupname' maxlength='15' /><br>
						<input type='submit' name='submit'>
					</form>
					<a href='/blank'>Go back</a>"));
			}
			if ($_SERVER['REQUEST_METHOD'] == 'POST') {
				$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
        			if($groupCount >= 5) {
        				$document->setTitle("<center>Sorry!</center>");
        				$document->add(new Comment("You can only have 5 groups. <br><br> <a href='myadopts'>Go back?</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("
 						You created a new group called '{$groupname}'.<br><br>
						<a href='/blank'>Go back</a>"));
        			}
			}
	}
	
	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("<center>Sort Testing!</center>");
          		$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
        		if($groupCount = 0) {
        			$document->setTitle("<center>Sorry!</center>");
        			$document->add(new Comment("You don't have any groups. <br><br> <a href='/blank'>Go back?</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>
    					<input type='submit' value='Go'>
    					</form>
    					<a href='/blank'>Go back</a>"));
			}
			
			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("
 						'{$group_info->name}' has been deleted. All pets organized under it are now ''ungrouped''.<br><br>
						<a href='/blank'>Go back</a>"));
					$mysidia->db->update("owned_adoptables", array("pet_group" => 0), "pet_group = '{$group}'");
       					$mysidia->db->delete("pet_groups", "uid='{$uid}' AND id = '{$group}'");	
			}
	}
	
}
?>
PHP:
<?php

class BlankController extends AppController{

	
	public function index(){		
	$mysidia = Registry::get("mysidia");
	
	}
	
	public function creategroup(){		
	$mysidia = Registry::get("mysidia");
	
	}
	
	public function deletegroup(){		
	$mysidia = Registry::get("mysidia");
	
	}
}
?>

This version doesn't use AJAX, but it basically works the same. It just handles the variables internally instead of passing it to the URL.
 
YAAAAS! :D Thanks Dinocanid! :D Makes me want to make a new site now that people can group their pets...I've wanted this kind of feature for sooo long! x'3
 
I'll definitely be adding it to my site too! Thank you! It'll make it so much easier to sort pets. I might now replace the faulty sort option with groups because then people can custom group all their pets together! :D
 
Yeah, the sort mod didn't work out so well ^^; hopefully a fix is found soon. This one works better imo though. I didn't include a function to actually add pets to those groups yet, but I'm planning to. It's also possible to do it yourself in the meantime with a form that updates the pet's group to whatever the user selected.
 
and here come's the part, which allows you, to assign a group (from the existing groups) to your adopt.

I hope, it works indeed for all :wutno:

in myadopts.php ... after the closing tag ( } ) for the freeze-function


PHP:
public function changegroup(){        
    $mysidia = Registry::get("mysidia");
	$this->setField("adopt", $this->adopt);  
	}

and in myadoptsview.php after the closing tag ( } ) for the freeze-function

PHP:
public function changegroup(){
    $mysidia = Registry::get("mysidia");
    $document = $this->document;
	$document->setTitle(" Change group ");
	$adopt = $this->getField("adopt");  
    $username = $mysidia->user->username;
    $uid = $mysidia->user->uid;
	 
	
	$stmt20 = $mysidia->db->select("pet_groups", array(), "uid='{$uid}'");
            
            $document->add(new Comment("
                <b>Choose a group:</b><br>
                 
				 <form method='post' action=''>
                        <select name='groups' id='groups'>
						^<option value='0'>choose</option>"));
            
            while($row = $stmt20->fetchObject()) {
                  $id = $row->id;
                  $name = $row->name;
                  $document->add(new Comment("
					<option value='{$id}'>{$name}</option>"));
            }
            $document->add(new Comment("
                        </select>  
                        <input type='submit' value='go'>
                    </form>
					  
                    ", FALSE));
					
			if($mysidia->input->post("groups")){
			$wahl = $mysidia->input->post("groups");
			$new = $mysidia->db->select("pet_groups", array("name"), "id='{$wahl}'")->fetchcolumn();   
			$mysidia->db->update("owned_adoptables", array("pet_groups" => $new), "aid ='{$adopt->getAdoptID()} ' and owner='{$mysidia->user->username}'");  
			 $document->add(new Comment("  Your adopt is now grouped to :{$new} <br>
						<a href='/myadopts/manage/{$adopt->getAdoptID()}'>back to the adopt</a>   ")); 
		  }		
		 		   
		
		  
	}

and somewhere by the list of name, type etc.

PHP:
 <a href='/myadopts/changegroup/{$aid}'>(changegroup)</a>


have fun :wutno:
 
@draugluin, so what I'm getting (from looking at that briefly) is that it allows you to assign your pet to a group via that pet's manage page? That is very handy!

EDIT:
Made some fixes to it so that it works properly, just replace the database update line with;
PHP:
$mysidia->db->update("owned_adoptables", array("pet_group" => $wahl), "aid ='{$adopt->getAdoptID()} ' and owner='{$mysidia->user->username}'");
 
Last edited:
@ Abronsyth

right... it should be the continuation of Dinocanids script.

but ... $wahl is just the id-number of the pet-groups ... $new is the name.

edit:

w33.jpg
 
Last edited:
Aye, the pet-group's ID is what needs to be added to the database for the pet to be "assigned" to it, though, hence replacing with $wahl :)
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,115
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top