Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.2.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=38)
-   -   [Updated] AJAX Sortable Adoptables on "myadopts.php" Page (http://www.mysidiaadoptables.com/forum/showthread.php?t=2357)

fadillzzz 08-31-2011 04:55 PM

Oh and btw, I just noticed that when you click on 'Click here to sort your adoptables' the table somehow gets aligned to the left a little bit more.
If you're wondering how to fix that, I think the following code should do the trick
HTML Code:

    $(document).ready(function(){
       
        $('body').undelegate('click').delegate('p#activate_sort', 'click', function(){
            var realBg = $('table#sortable_adoptables').css('background-color');
            var submitForm = '<form name="submit_order" id="submit_order" action="" method="post"><fieldset><label for="submit">Submit Changes</label><input type="submit" id="submit" value="Submit"></fieldset></form>';
            $('table#sortable_adoptables').css({backgroundColor: '#FFFF66', paddingRight: '0'}).animate({ backgroundColor: realBg },  'slow' ).find('tbody').sortable({ cursor: 'pointer' });
            $(submitForm).insertAfter('p#activate_sort').hide().slideDown();
            $('p#activate_sort').attr('id', 'deactivate_sort');
        });
       
        $('body').undelegate('submit').delegate('form#submit_order', 'submit', function(event){
            event.preventDefault();
            var data = $('table#sortable_adoptables tbody').sortable('serialize');
            $.post('ajax_sort.php', data, function(result){
                $('form#submit_order').html(result).delay(5000).fadeOut('slow', function(){
                    $(this).remove();                   
                });
            });
            $('table#sortable_adoptables tbody').sortable('destroy');
            $('p#deactivate_sort').attr('id', 'activate_sort');
        });


SilverDragonTears 08-31-2011 05:43 PM

still did it...

Teshia 08-31-2011 09:27 PM

Sorting! Awesome!

fadillzzz 09-08-2011 09:57 AM

First post updated:
Fixed a bug where trading adoptables can cause duplicate entries in the sorting tables.
The table structure now only have 'adoptable_id' as the primary key.

PokePets 10-22-2011 03:56 AM

Thank you for this mod :)
Works perfect on my site!

SilverDragonTears 11-23-2011 01:25 AM

Why won't it save the sort anymore (After Maple added in a tabs feature for our adopts)?

PHP Code:

include("inc/functions.php");

//***************//
//  START SCRIPT //
//***************//

$id $_GET["id"];
$act $_GET["act"];
$more $_GET["more"];
$abilityid $_GET["abilityid"];
$tab $_GET['tab'];

if(
$isloggedin == "yes"){

if(
$act == ""){

$tabs gettabs();
$article_title .="{$loggedinname}'s Den";
        
$article_content .="


        <table width='60%' style='text-align:center;' class='shop'><center><tr><td><p class='sort' id='activate_sort'>
                         Sort Adopts - Currently NOT Working.
                    </p><center></td></tr></table></center>
        <table width='60%' style='text-align:center;' class='shop'><tr><td width='20%'><a href='trade.php'>Trade</a>-<a href='search.php'>Search</a></td>
        <td width='20%'><a href='breeding.php'>Breed</a></td>
        <td width='20%'><a href='embed.php'>Embed All</a></td>
        <td width='20%'><a href='inventory.php'>Kit Inventory</a></td><td width='20%'><a href='inventory2.php'>Adult Inventory</a></td></tr></table></center>
        <br>
         <table width='60%' style='text-align:center;' class='shop'><tr><td width='20%'><a href='tab.php'>Manage Dens</td></a>
        <td width='20%'>Select a den to go to: <select name='tab' id='tab' ONCHANGE='location = this.options[this.selectedIndex].value;'>
                                                <option value='#'>Please Select one below:</option><option value='myadopts.php'>Default</option>"
.$tabs."
                                                </select></td>
</tr></table></center>
        <br><div style='float:left;'>"
;
$query "SELECT * FROM ".$GLOBALS['prefix']."owned_collectables WHERE type = 'Halloween' AND owner = '".$loggedinname."'";
        
$result runquery($query);
    
$num mysql_numrows($result);
if(
$num 0){
$article_content .="<img src='images/candypumpkin.png' title='Trick or Treat 2011'>";
}else{
$article_content .="";
}
$query "SELECT * FROM ".$GLOBALS['prefix']."owned_adoptables WHERE type = '911 Silvfox' AND owner = '".$loggedinname."'";
        
$result runquery($query);
    
$num mysql_numrows($result);
if(
$num 0){
$article_content .="<img src='images/us.png' title='911 Event'>";
}else if(
$type == '911 Wolf'){
$article_content .="<img src='images/us.png' title='911 Event'>";
}else{
$article_content .="";
}
$query "SELECT * FROM ".$GLOBALS['prefix']."owned_adoptables LEFT JOIN ".$GLOBALS['prefix']."sort_adoptables 
                        ON "
.$GLOBALS['prefix']."owned_adoptables.aid = ".$GLOBALS['prefix']."sort_adoptables.adoptable_id WHERE owner = '".$loggedinname."' ORDER BY ".$GLOBALS['prefix']."sort_adoptables.sorting_id, ".$GLOBALS['prefix']."owned_adoptables.currentlevel ASC";
    
$result runquery($query);
    
$numpets mysql_numrows($result);

if(
$numpets >= 500){
        
$article_content .="<img src='/images/trophy-gold.png' title='Gold Trophy - Over 500 SilvAdopts'>";
} else if(
$numpets >= 200){
        
$article_content .="<img src='/images/silvertrophy.png' title='Silver Trophy - Over 200 SilvAdopts'>";
} else if(
$numpets >= 50){
        
$article_content .="<img src='/images/trophy-bronze.png' title='Bronze Trophy - Over 50 SilvAdopts'>";
}else{
        
$article_content .="";
}
$article_content .="</div><br><br>
        <br>Share this link with others to show them your Den<br>
        <input type='text' size='100' value='http://silvadopts.com/profile.php?user=
$loggedinname'><br>
        <a href='http://silvadopts.com/profile.php?user=
$loggedinname'>http://silvadopts.com/profile.php?user=$loggedinname</a><br>";

        
$article_content .= "<div style='height:100%;
        color: #fff;
    border: 1px solid #282828;
    border-top: 1px solid #363636;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    padding: 5px;'><table style='width: 100%;' class='madopt' id='sortable_adoptables' ><tbody>
    <tr><th>SilvAdopt</th><th>Name</th><th>Level</th><th>Manage</th><th>Get Codes</th><th>Clicks</th></tr><br>"
;


    
// We need to get all of the user's adoptables from the database and display them...
   /* $query = "SELECT * FROM ".$prefix."owned_adoptables, ".$prefix."levels WHERE ".$prefix."owned_adoptables.owner = '{$loggedinname}'" 
    ." AND ".$prefix."owned_adoptables.type = ".$prefix."owned_adoptables.type AND ".$prefix."levels.thisislevel = ".$prefix."owned_adoptables.currentlevel AND ".$prefix."levels.adoptiename = " 
    .$prefix."owned_adoptables.type ORDER BY ".$prefix."owned_adoptables.sort, ".$prefix."owned_adoptables.totalclicks";
*/
$query "    SELECT * 
                    FROM 
{$prefix}owned_adoptables 
                    LEFT JOIN 
{$prefix}sort_adoptables 
                        ON 
{$prefix}owned_adoptables.aid = {$prefix}sort_adoptables.adoptable_id
                    INNER JOIN 
{$prefix}levels 
                        ON 
{$prefix}levels.thisislevel = {$prefix}owned_adoptables.currentlevel
                    INNER JOIN 
{$prefix}adoptables
                        ON 
{$prefix}owned_adoptables.type = {$prefix}adoptables.type
                    WHERE 
{$prefix}owned_adoptables.owner = '{$loggedinname}' AND {$prefix}owned_adoptables.tab = '{$tab}'
                    AND 
{$prefix}levels.adoptiename = {$prefix}adoptables.type
                    ORDER BY 
{$prefix}sort_adoptables.sorting_id, {$prefix}owned_adoptables.currentlevel ASC";  

    
$result runquery($query);
    
$num mysql_numrows($result);
    
//Loop out code
    
$i=0;
    while (
$i $num) {
        
$aid=@mysql_result($result,$i$prefix."owned_adoptables.aid");
        
$currentlevel=@mysql_result($result,$i$prefix."owned_adoptables.currentlevel");
        
$gender=@mysql_result($result,$i$prefix."owned_adoptables.gender");
        
$isfrozen=@mysql_result($result,$i$prefix."owned_adoptables.isfrozen");
        
$type=@mysql_result($result,$i$prefix."owned_adoptables.type");
        
$name=@mysql_result($result,$i$prefix."owned_adoptables.name");
        
$eggimage=@mysql_result($result,$i$prefix."adoptables.eggimage");
        
$usealternates=@mysql_result($result,$i$prefix."owned_adoptables.usealternates");
        
$totalclicks=@mysql_result($result,$i$prefix."owned_adoptables.totalclicks");
        
$primaryimage=@mysql_result($result,$i$prefix."levels.primaryimage");
        
$alternateimage=@mysql_result($result,$i$prefix."levels.alternateimage");
        if (
$usealternates=='yes') { $image $alternateimage; }
        else { 
$image $primaryimage; }
        if (
$currentlevel==0) { $image $eggimage; }
        if (
$image=='') { $image $primaryimage; }
    
$article_content .= "<tr id='orderaid_{$aid}'><td width='20%'><a href='myadopts.php?act=stats&id=".$aid."'><img src='$image'></a></td><td width='20%'>";

if(
$isfrozen == 'no') {
    
$article_content .= '';
} else {
    
$article_content .= '<img src=\'images/snowflake.png\'>';
    



SilverDragonTears 03-23-2012 01:52 AM

Do you have a fix for this code for 1.3?

Code:


function secure($data, $key = NULL) {
    //This function performs security checks on all incoming form data
    if ($key === 'orderaid')
    {
            //var_dump($data);    var_dump($key); die;
        foreach($data as $dataKey => $dataVal)
        {
            $data[$dataKey] = abs(intval($dataVal));
        }
            //var_dump($data);die;
        return $data;
    }   
    if(is_array($data)) {
        die("Hacking Attempt!");
    } 
    $data = htmlentities($data);
    $data = mysql_real_escape_string($data);
    $data = strip_tags($data, ''); 
    if ($key === NULL)
    {
        return $data;
    }   
    $GLOBALS['_POST'][$key] = $data;
}

This does not work in 1.3

fadillzzz 03-23-2012 03:03 AM

That's odd. There isn't any big change to that function in Mys 1.3.
Perhaps you installed it incorrectly. But more importantly, what do you mean by "does not work"? Can you be more specific?

SilverDragonTears 03-23-2012 05:53 PM

I fixed it :) It was late last night so I don't even know how I did it :/

Kesstryl 03-23-2012 06:11 PM

If you do remember, can you post it? I'd like to get this working on 1.3 but I've been waiting for it to get updated to 1.3. This is too useful to not have.

SilverDragonTears 03-23-2012 06:20 PM

I'll just post what I have in my functions.php script

Code:

function secure($data, $key = NULL) {
    //This function performs security checks on all incoming form data
    if ($key === 'orderaid')
    {
            //var_dump($data);    var_dump($key); die;
        foreach($data as $dataKey => $dataVal)
        {
            $data[$dataKey] = abs(intval($dataVal));
        }
            //var_dump($data);die;
        return $data;
    }
        if(is_array($data)) {
                die("Hacking Attempt!");
        }
        $data = htmlentities($data); 
        $data = strip_tags($data, '');
        return $data;
}

And the ajax_sort file needs to be replaced also:
about line 23:
Code:

$adopts->query('REPLACE INTO ' . $prefix . 'sort_adoptables (`user_id`, `adoptable_id`, `sorting_id`)
                                                                        VALUES ("' . addslashes($userID) . '", "' . addslashes($aid) . '", "' . addslashes($orderID) . '")');


Hall of Famer 03-23-2012 06:45 PM

Well dude, just make a tiny bit of edit in your script and release the new Mod in Mys v1.3.x Addons/Mods subforum. That section needs some threads anyway.

Kesstryl 03-23-2012 07:06 PM

Something didn't work

Parse error: syntax error, unexpected '}' in /homepages/22/d355892482/htdocs/fabletopia/functions/functions.php on line 83

Kesstryl 03-23-2012 07:07 PM

Nevermind, just fixed an error, sometimes I just need to believe in myself :)

SilverDragonTears 03-23-2012 07:25 PM

I forgot to mention... if you do this with the newest script, when you click on someone's profile the tabs don't work :/

fadillzzz 03-24-2012 12:16 AM

I'll see what I can do about creating this mod for Mys 1.3

Hall of Famer 03-24-2012 09:30 AM

Well Id say you take a look into it and see how difficult it is to convert the Mod to Mys v1.3.x compatible version. If it is too hard and will take days, then wait till you have more time.

Alaric 05-29-2012 02:16 AM

This script look's and sounds awsome, I would like to use it in v.1.3.1
I hope you modify the script.. so i can use it in v.1.3


All times are GMT -5. The time now is 09:51 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.