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
  #51  
Old 01-16-2017, 12:38 PM
SilverDragonTears's Avatar
SilverDragonTears SilverDragonTears is offline
I am your Nemesis.
 
Join Date: Jun 2011
Posts: 1,113
Gender: Female
Credits: 97,443
SilverDragonTears is on a distinguished road
Default

Ah makes sense :)
__________________

Check out SilvaTales
Reply With Quote
  #52  
Old 06-11-2017, 06:52 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 22,741
parayna is on a distinguished road
Default

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
__________________
It's been a long time. I had so much fun making a site back in 2016 that recently, when I started thinking about it again, I decided to come back and work on something small. It'll probably just be a personal project but who knows? We'll see, anyway.

Reply With Quote
  #53  
Old 12-16-2017, 09:59 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 79,320
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
  #54  
Old 12-17-2017, 03:07 PM
Pear's Avatar
Pear Pear is offline
Woah man.
 
Join Date: Dec 2013
Location: The Underworld
Posts: 169
Gender: Female
Credits: 48,284
Pear is on a distinguished road
Default

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
__________________
Noot noot! Gotta get a new signooture. >->
Reply With Quote
  #55  
Old 12-17-2017, 03:51 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 22,741
parayna is on a distinguished road
Default

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
__________________
It's been a long time. I had so much fun making a site back in 2016 that recently, when I started thinking about it again, I decided to come back and work on something small. It'll probably just be a personal project but who knows? We'll see, anyway.

Reply With Quote
  #56  
Old 12-17-2017, 04:51 PM
Dinocanid's Avatar
Dinocanid Dinocanid is offline
Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 516
Gender: Unknown/Other
Credits: 79,320
Dinocanid is on a distinguished road
Default

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.
__________________
Reply With Quote
  #57  
Old 08-31-2018, 10:38 AM
draugluin's Avatar
draugluin draugluin is offline
Member
 
Join Date: Oct 2011
Location: germany
Posts: 120
Gender: Unknown/Other
Credits: 12,568
draugluin is on a distinguished road
Default

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

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


PHP Code:
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 Code:
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 Code:
 <a href='/myadopts/changegroup/{$aid}'>(changegroup)</a

have fun
__________________
Reply With Quote
  #58  
Old 09-04-2018, 04:08 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,681
Abronsyth is on a distinguished road
Default

@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 Code:
$mysidia->db->update("owned_adoptables", array("pet_group" => $wahl), "aid ='{$adopt->getAdoptID()} ' and owner='{$mysidia->user->username}'"); 

Last edited by Abronsyth; 09-04-2018 at 04:53 PM.
Reply With Quote
  #59  
Old 09-10-2018, 05:01 AM
draugluin's Avatar
draugluin draugluin is offline
Member
 
Join Date: Oct 2011
Location: germany
Posts: 120
Gender: Unknown/Other
Credits: 12,568
draugluin is on a distinguished road
Default

@ 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:

__________________

Last edited by draugluin; 09-10-2018 at 05:10 AM.
Reply With Quote
  #60  
Old 09-10-2018, 11:03 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,681
Abronsyth is on a distinguished road
Default

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 :)
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 09:37 AM
1.3.4 - group sort draugluin Questions and Supports 6 01-16-2017 01:02 PM
sort adoptables Blackmagic Questions and Supports 3 12-01-2009 04:05 PM
group zhiichiro Questions and Supports 7 05-30-2009 08:21 PM
Adding new user group mugwumpr Questions and Supports 2 04-19-2009 08:02 PM


All times are GMT -5. The time now is 01:35 AM.

Currently Active Users: 1130 (0 members and 1130 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 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636