Log in

View Full Version : Adoptable ID 0


Dinocanid
11-05-2016, 05:45 PM
Whenever I go to a member's profile, I get:
Adoptable ID 0 does not exist or does not belong to the owner specified...
I think the problem is with the adoptables tab, since a user doesn't have any when they sign up. I don't exactly know what to do in those cases since isn't the ID 0 by default if there isn't a pet?

Hall of Famer
11-05-2016, 07:40 PM
If there isn't a pet on the user profile, you should be able to view it properly as it will just say the user currently has no adoptable so. The issue you described happens most likely when a favorite pet is pounded, traded or deleted, resulting in an invalid id for the favorite adoptable on this user profile. To fix it, go to PHPmyadmin, find table adopts_users_profiles, and locate the user profile that ain't available. Remove the data field for favorite pet on this user profile and it should work again normally.

Dinocanid
11-05-2016, 08:10 PM
Just tried that, and I got:
Catchable fatal error: Argument 1 passed to GUIContainer::add() must be an instance of GUIComponent, string given, called in /home/adopttes/public_html/classes/class_userprofile.php on line 143 and defined in /home/adopttes/public_html/classes/class_guicontainer.php on line 361

Hall of Famer
11-05-2016, 08:48 PM
My mistake, the owned adoptable ID needs to be 0 if favorite pet is unspecified, not empty/NULL value. So you need to change the empty values back to 0.

But strangely, it works on my demo site and everyone else's site when the favpet ID is 0, only on yours it does not work. Did you modify the script somewhere? I am sure for a fresh installation there is no such problem.

Dinocanid
11-05-2016, 09:00 PM
I haven't modified the profiles at all. The only thing I can think of is putting the favpet in the sidebar. Here's my code for that if it helps:
<style>
.speechbubble {
position: relative;
padding: 5px;
text-align: center;
background: #FFFFFF;
-webkit-border-radius: 53px;
-moz-border-radius: 53px;
border-radius: 13px;
border: #7F7F7F solid 2px;
}

.speechbubble:after {
content: '';
position: absolute;
border-style: solid;
border-width:0 15px 15px;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
margin-left: -15px;
top: -15px;
left: 50%;
}

.speechbubble:before {
content: '';
position: absolute;
border-style: solid;
border-width:0 16px 16px;
border-color: #7F7F7F transparent;
display: block;
width: 0;
z-index: 0;
margin-left: -16px;
top: -18px;
left: 50%;
}
</style>
<?php

/**
* The Sidebar Class, defines a standard HTML Sidebar component.
* It extends from the Widget class, while adding its own implementation.
* @category Resource
* @package Widget
* @author Hall of Famer
* @copyright Mysidia Adoptables Script
* @link http://www.mysidiaadoptables.com
* @since 1.3.3
* @todo Not much at this point.
*
*/

class Sidebar extends Widget{

/**
* The moneyBar property, specifies the money/donation bar for members.
* @access protected
* @var Paragraph
*/
protected $moneyBar;

/**
* The linksBar property, stores all useful links for members.
* @access protected
* @var Paragraph
*/
protected $linksBar;

/**
* The wolBar property, determines the who's online url in the sidebar.
* @access protected
* @var Link
*/
protected $wolBar;

/**
* The loginBar property, specifies the loginBar for guests.
* @access protected
* @var FormBuilder
*/
protected $loginBar;

/**
* Constructor of Sidebar Class, it initializes basic sidebar properties
* @access public
* @return Void
*/
public function __construct(){
parent::__construct(4, "sidebar");
}

/**
* The setDivision method, setter method for property $division.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @param GUIComponent $module
* @access protected
* @return Void
*/
protected function setDivision(GUIComponent $module){
if(!$this->division){
$this->division = new Division;
$this->division->setClass("sidebar");
}
$this->division->add($module);
}

/**
* The getMoneyBar method, getter method for property $moneyBar.
* @access public
* @return Paragraph
*/
public function getMoneyBar(){
return $this->moneyBar;
}

/**
* The setMoneyBar method, setter method for property $moneyBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setMoneyBar(){
$mysidia = Registry::get("mysidia");
$this->moneyBar = new Paragraph;
$this->moneyBar->add(new Comment("You have <span id='cashonhand'>{$mysidia->user->money}</span> {$mysidia->settings->cost}."));

$donate = new Link("donate");
$donate->setText("Donate Money to Friends");
$this->moneyBar->add($donate);
$this->setDivision($this->moneyBar);
}

/**
* The getLinksBar method, getter method for property $linksBar.
* @access public
* @return Paragraph
*/
public function getLinksBar(){
return $this->linksBar;
}

/**
* The setLinksBar method, setter method for property $linksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinksBar(){
$mysidia = Registry::get("mysidia");
$this->linksBar = new Paragraph;
$linkTitle = new Comment("<center>-{$mysidia->user->username}'s Links-</center>");
$linkTitle->setBold();
$this->linksBar->add($linkTitle);

$linksList = new LinksList("ul");
$this->setLinks($linksList);

$this->linksBar->add($linksList);
$this->setDivision($this->linksBar);
}

/**
* The setLinks method, append all links to the LinksBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLinks(LinksList $linksList){
$mysidia = Registry::get("mysidia");
$stmt = $mysidia->db->select("links", array("id", "linktext", "linkurl"), "linktype = 'sidelink' ORDER BY linkorder");
if($stmt->rowCount() == 0) Throw new Exception("There is an error with sidebar links, please contact the admin immediately for help.");

while($sideLink = $stmt->fetchObject()){
$link = new Link($sideLink->linkurl);
$link->setText($sideLink->linktext);
if($sideLink->linkurl == "messages"){
$num = $mysidia->db->select("messages", array("touser"), "touser='{$mysidia->user->username}' and status='unread'")->rowCount();
if($num > 0) $link->setText("<b>{$link->getText()} ({$num})</b>");
}
$link->setListed(TRUE);
$linksList->add($link);
}

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
}
}

/**
* The getWolBar method, getter method for property $wolBar.
* @access public
* @return LinksList
*/
public function getWolBar(){
return $this->wolBar;
}

/**
* The setWolBar method, setter method for property $wolBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setWolBar(){
$mysidia = Registry::get("mysidia");
$this->wolBar = new Link("online");
$online = $mysidia->db->select("online", array(), "username != 'Visitor'")->rowCount();
$offline = $mysidia->db->select("online", array(), "username = 'Visitor'")->rowCount();
$this->wolBar->setText("This site has {$online} members and {$offline} guests online.");
$this->setDivision($this->wolBar);
}

/**
* The getLoginBar method, getter method for property $loginBar.
* @access public
* @return FormBuilder
*/
public function getLoginBar(){
return $this->loginBar;
}

/**
* The setLoginBar method, setter method for property $loginBar.
* It is set internally upon object instantiation, cannot be accessed in client code.
* @access protected
* @return Void
*/
protected function setLoginBar(){
$this->loginBar = new FormBuilder("login", "login", "post");
$loginTitle = new Comment("Member Login:");
$loginTitle->setBold();
$loginTitle->setUnderlined();
$this->loginBar->add($loginTitle);

$this->loginBar->buildComment("username: ", FALSE)
->buildTextField("username")
->buildComment("password: ", FALSE)
->buildPasswordField("password", "password", "", TRUE)
->buildButton("Log In", "submit", "submit")
->buildComment("Don't have an account?");

$register = new Link("register");
$register->setText("Register New Account");
$register->setLineBreak(TRUE);
$forgot = new Link("forgotpass");
$forgot->setText("Forgot Password?");

$this->loginBar->add($register);
$this->loginBar->add($forgot);
$this->setDivision($this->loginBar);
}

public function getFavPetSB(){
return $this->FavPetSB;
}

protected function setFavPetSB(){
$mysidia = Registry::get("mysidia");
$profile = $mysidia->user->getprofile();
if ($profile->getFavpetID() == "0"){
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>"));
}
if ($profile->getFavpetID() != "0"){
$favpet = new OwnedAdoptable($profile->getFavpetID());
$message = "<div class='speechbubble'>";

$status_chance = mt_rand(1, 100);
if ($status_chance <= 1){ # One percent chance the pet will obtain a status effect.

/* We would apply a status effect here...*/
$message .= "<center>WHOOHOO! " . $favpet->getName() . " is having a great day!</center>";
#### We'll do this later!!!

} else { # Ninety-nine percent chance the pet will not get a status effect. Will something else happen?
$something_chance = mt_rand(1, 100);
if ($something_chance <= 30){ # Twenty-five percent chance something will happen.
$gift_chance = mt_rand(1, 100);
if ($gift_chance <= 5){ # Five percent chance the user will receive a gift from their pet.
$item_chance = mt_rand(1, 100);
if ($item_chance <= 25){ # Fifty percent chance the gift from their pet will be an item.

/* The pet has found an item for you! */
$num = mt_rand(1,5); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $item = "asda"; break;
case 2: $item = "asda"; break;
case 3: $item = "asda"; break;
case 4: $item = "asda"; break;
case 5: $item = "asda"; break;
}
$message .= "I found a {$item} for you!";
$newitem = new StockItem($item);
$newitem->append(1, $mysidia->user->username);

} else { # Fifty percent chance the gift from their pet will be money.

/* The pet has found some money for you! */
$currency = $mysidia->settings->cost;
$amount = mt_rand(100, 1000); # Between 100 and 1000
$message .= "Found {$amount} {$tyleans}!";
$mysidia->user->changecash($amount);

}
} else { # Twenty percent chance the pet will talk but have no gift.
/* No gift will be given but a neat species-specific phrase can still be said! */

$species = trim($favpet->getType());

switch ($species){
case "Wind Raptor": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Who, who!"; break;
case 2: $message .= "I like to soar through the sky."; break;
case 3: $message .= "Wanna share a berry?"; break;
case 4: $message .= "Don't worry! Anything shiny and I'll get it!"; break;
case 5: $message .= "Do you feel that breeze?"; break;
case 6: $message .= "Nocturnal? Nah, I'm awake when you're awake!"; break;
case 7: $message .= "Look what I can do!"; break;
}
break;

case "Black Forest Dog": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Woof!"; break;
case 2: $message .= "Bark bark!!!"; break;
case 3: $message .= "I'm the only friend you'll ever need."; break;
case 4: $message .= "I will protect you!"; break;
case 5: $message .= "Where do ya wanna to explore today?"; break;
case 6: $message .= "I always knew I was favorite material!"; break;
case 7: $message .= "Yeah, I'm pretty hot stuff."; break;
}
break;

case "Water Selkie": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Ort, ort, ort!"; break;
case 2: $message .= "Let's go swimming!"; break;
case 3: $message .= "My favorite place is the Ice Flows."; break;
case 4: $message .= "OH! Something shiny! Awww, it melted."; break;
case 5: $message .= "Know what my favorite food is? Fish!"; break;
case 6: $message .= "The water is my natural element, but I'll go anywhere you go."; break;
case 7: $message .= "Cool as a cucumber, slick as a ice patch!"; break;
}
break;

case "Flame Bison": # If the species name is "Cat" it will choose one these:
$num = mt_rand(1,7); # Chooses a number between 1 and 4. See how there are four cases below? Increase this number if you add more!!
switch ($num){
case 1: $message .= "Chaaaaaaaarrrrrge!"; break;
case 2: $message .= "Don't mind me, I'm just grazing."; break;
case 3: $message .= "I'm blazing fast!"; break;
case 4: $message .= "Do you have any carrots?"; break;
case 5: $message .= "My favorite place is the Hills."; break;
case 6: $message .= "No need to fear when I'm around!"; break;
case 7: $message .= "Yeah, I'm pretty hot stuff."; break;
}
break;

default: # If the species isn't defined above, it'll choose one of these default phrases instead.
$num = mt_rand(1,6);
switch ($num){
case 1: $message .= "It's a beautiful day! I love to explore!"; break;
case 2: $message .= "I always knew I was favorite material!"; break;
case 3: $message .= "I'm a little hungry. Think we could get a bite to eat?"; break;
case 4: $message .= "You're the only friend I'll ever need."; break;
case 5: $message .= "I found something! I foun- Oh, no. False alarm."; break;
case 6: $message .= "Don't worry! I'm on the look out for anything shine"; break;
}
break;
}

}
} else { # Seventy-five percent chance nothing will happen whatsoever.
/* Nothing will happen with the pet at all. */
$message = "";
}
}

if ($message == "") { $message = ""; } else { $message .= "</div>"; }
$this->FavPetSB = new Paragraph;
$this->FavPetSB->add(new Comment("<center><b>-Active Pet-</b></center>"));
$this->FavPetSB->add(new Comment("<img src='{$favpet->getImage()}'></a>"));
$this->FavPetSB->add(new Comment("<p>" . $message . "</p>"));
$this->FavPetSB->add(new Comment("<center>{$favpet->getName()}</center>"));
}
$this->setDivision($this->FavPetSB);
}
}
?>

Bump because I still haven't found a fix for this and users can't see their profiles because of it.

Hall of Famer
11-11-2016, 11:42 PM
Did you try removing the favorite pet block on the sidebar? If not, try this and see if it works afterwards.

Dinocanid
11-12-2016, 01:01 PM
Just tried removing it and the error still shows up, so I put it back. I do know that the problem is related to the user not having a favpet though, since the problem goes away when I assign one to a user.