Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2017, 08:59 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 93,348
Dinocanid is on a distinguished road
Default

I managed to convert the main part of the script, which involves creating groups and sorting pets on the myadopts index.

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 Code:
<?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($total10"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 Code:
<?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.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What age group do you belong to? Hall of Famer Other Chat 19 09-28-2017 08:37 AM
1.3.4 - group sort draugluin Questions and Supports 6 01-16-2017 12:02 PM
sort adoptables Blackmagic Questions and Supports 3 12-01-2009 03:05 PM
group zhiichiro Questions and Supports 7 05-30-2009 07:21 PM
Adding new user group mugwumpr Questions and Supports 2 04-19-2009 07:02 PM


All times are GMT -5. The time now is 04:17 PM.

Currently Active Users: 3653 (0 members and 3653 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636