PDA

View Full Version : Create/Edit/Delete user's owned adoptables through acp!


Hall of Famer
01-21-2011, 12:01 PM
Well I've finished this modification after several hours of work last night. This version of Create/Edit/Delete user's individual pets does not have pagination when showing a list of adoptables to edit though, which will be added later. It is projected to be a new feature available in Mysidia Adoptables v1.2.0 too, incase you wonder.

This Mod is a lot easier to install and use than my previous custom scripts. All you have to do is to download the two files cadopt.php and eadopt.php, and then edit admin.php just a little bit. The script files are attached at the end of this post, just place them in the root folder of Mysidia Adoptables(the same directory as doadopt.php and myadopts.php). To edit admin.php, find the following lines below:

else if($do == "groups"){

//************************************************** ************************************************** **
// USERGROUP MANAGEMENT PAGE HERE >>>
//************************************************** ************************************************** **

if($more == ""){

// No action specified for the usergroups, so show some basic information...

$article_title = "Manage Usergroups";
$article_content = "This page allows you to manage the usergroups available to you and your site's users.
Usergroups are a powerful feature as they determine who can access what parts of the site and which functions they can use.
Here you can create and manage administrative user groups, artist user groups, donator user groups, custom user groups, and more.
Use the table below to edit existing usergroups, or click the link below to create a custom usergroup.<br><br>
<b><a href='admin.php?set=users&do=groups&more=new'><img src='templates/icons/add.gif' border=0> Create a New Usergroup</a></b><p></p><table width='680' border='1'><tr>
<td><strong>Group ID:</strong></td>
<td><strong>Group Name: </strong></td>
<td><strong>Can Adopt Pets: </strong></td>
<td><strong>Can Use PM System: </strong></td>
<td><strong>Can Access Admin CP: </strong></td>
<td><strong>Edit:</strong></td>
<td><strong>Delete:</strong></td>
</tr>";Add above:


else if($do == "adoptables"){
if($more == ""){
$article_title = "Manage Adoptables";
$article_content = "This page allows you to manage each adoptable owned by users registered on your site. Only admins who can edit users and usergroups can carry out this task.
Use the table below to edit existing adoptables, or click the link below to create a new adoptable for a user.<br><br>
<b><a href='admin.php?set=users&do=adoptables&more=new'><img src='templates/icons/add.gif' border=0> Create a New Owned Adoptables</a></b><p></p><table width='680' border='1'><tr>
<td><strong>Adoptables ID:</strong></td>
<td><strong>Adoptables Type: </strong></td>
<td><strong>Adoptables Name: </strong></td>
<td><strong>Adoptables Owner: </strong></td>
<td><strong>Adoptables Gender: </strong></td>
<td><strong>Edit:</strong></td>
<td><strong>Delete:</strong></td>
</tr>";

// Get the adoptables from the database...

$query = "SELECT * FROM ".$prefix."owned_adoptables";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < $num) {

$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
$gender=@mysql_result($result,$i,"gender");

$editimage = "<a href='admin.php?set=users&do=adoptables&more=edit&evenmore=".$aid."'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=users&do=adoptables&more=delete&evenmore=".$aid."'><img src='templates/icons/delete.gif' border=0></a>";


// Finally we can show this table to the user...

$article_content = $article_content."<tr>
<td>".$aid."</td>
<td>".$type."</td>
<td><div align='center'>".$name."</div></td>
<td><div align='center'>".$owner."</div></td>
<td><div align='center'>".$gender."</div></td>
<td><div align='center'>".$editimage."</div></td>
<td><div align='center'>".$deleteimage."</div></td>
</tr>";



$i++;
}

$article_content = $article_content."</table>";

}

else if($more == "new"){

// We are now creating a new adoptable
$article_title = "Create an adoptable for a user";
$article_content = "This page allows you to create a new adoptable for a given user on your site.
Please fill in the form below and hit the <i>Create Adoptable</i> button below when you're ready to create this adoptable.
<form name='form1' method='post' action='cadopt.php'>
<p><u><strong>Create A New Adoptable For a User:</strong></u></p>
<p><strong>Basic Information: </strong></p>
<p>Adoptable Type:
<input name='type' type='text' id='type'>
<br>
<p>Adoptable Name:
<input name='name' type='text' id='name'>
<br>
<p>Adoptable Owner:
<input name='owner' type='text' id='owner'>
<br>
<p>Adoptable Clicks:
<input name='clicks' type='text' id='clicks'>
<br>
<p>Adoptable Level:
<input name='level' type='text' id='level'>
<br>
<p>Use Alternative?
<input name='usealternates' type='text' id='usealternates'>
<br>
<p>Adoptable Gender
<input name='gender' type='text' id='gender'>
<br>
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p>&nbsp; </p>
</form>";
}

else if($more == "edit"){
// We are editing an existing owned adoptable.
// $evenmore is the adoptable ID...

$aid = $evenmore;

$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$aid'";
$result = mysql_query($query);
$num = mysql_numrows($result);

if($num > 0){
// This owned adoptable exists, so fetch some basic information...

$article_title = "Owned Adoptables Editor - Editing ".$aid."'s Data";
$article_content = "Here you can edit this owned adoptable using the form below.<br>";

//Loop out code
$i=0;
while ($i < 1) {

$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
$gender=@mysql_result($result,$i,"gender");

$i++;
}

$article_content = $article_content."<form name='form1' method='post' action='eadopt.php'>
<p>Change Adoptable's Type:
<input name='type' type='text' id='type' value='".$type."'>
</p>
<p>Change Adoptable's Name:
<input name='name' type='text' id='name' value='".$name."'>
</p>
<p>Change Adoptable's Owner:
<input name='owner' type='text' id='owner' value='".$owner."'>
</p>
<p>Change Adoptable's total clicks:
<input name='totalclicks' type='text' id='totalclicks' value='".$totalclicks."'>
</p>
<p>Change Adoptable's current level:
<input name='currentlevel' type='text' id='currentlevel' value='".$currentlevel."'>
</p>
<p>Change Adoptable's gender:
<input name='gender' type='text' id='gender' value='".$gender."'>
</p>
<input name='aid' type='hidden' id='aid' value='".$aid."'>
<p>
<input type='submit' name='Submit' value='Submit'>
</p>
</form>";
}
}

else if($more == "delete"){
$aid = $evenmore;

// We are deleting an owned adoptable...

$query = "DELETE FROM ".$prefix."owned_adoptables WHERE aid='".$evenmore."'";
mysql_query($query);

$article_title = "Adoptable Deleted";
$article_content = "This owned adoptable has been deleted successfully.";


}

}
Next, find the following codes a few lines after the last one:


</p></form><b><a href='admin.php?set=users&do=groups'><img src='templates/icons/fr.gif' border=0> Manage Usergroups and Permissions</a></b><br><table width='302' border='1'>
<tr>
<td width='100'><strong>Username:</strong></td>
<td width='60'><strong>Email:</strong></td>
<td width='60'><strong>Usergroup:</strong></td>
<td width='32'><strong>Edit:</strong></td>
<td width='50'><strong>Delete:</strong></td>
</tr>";
Add above:


</p></form><b><a href='admin.php?set=users&do=adoptables'><img src='templates/icons/fr.gif' border=0> Manage User's Owned Adoptables</a></b><br><table width='302' border='1'>
I also attached my version of admin.php, for those of you who havent edited that script on your own server. Report to me if it does not work out for you, and I will see what I can do to help you.

The create/edit/delete user's individual pets page can be accessed by clicking on Edit User's tab in acp. A few screenshots are attached below for reference:

Screenshot1: The Edit Users/Usergroups/OwnedAdoptables page:
http://oi56.tinypic.com/jqrnnm.jpg


Screenshot2: The subpage of Create/Edit/Delete user's individual pets:
http://oi53.tinypic.com/14vl9o6.jpg

Screenshot3: Creating new owned adoptables
http://oi51.tinypic.com/16i8oed.jpg

Screenshot4: Editing existing owned adoptables
http://oi53.tinypic.com/303gvv7.jpg

Screenshot5: Deleted an owned adoptable successfully
http://oi53.tinypic.com/bhemqb.jpg

Kaeliah
01-21-2011, 01:34 PM
Looks good Famer! :el:

Hall of Famer
01-21-2011, 01:55 PM
Thank you for your comments Kaeliah, this is my first script to be used by Mysidia Adoptables official releases. ^^ Too bad I still cant figure out the trick of pagination. XD

Kyris
01-21-2011, 08:50 PM
Have you been reading my mind?! XD I've been trying to look around for a feature to add a specific pet to an owner :)

Kyris
01-22-2011, 03:25 AM
Question ^^ When creating an adoptable for the user, how do you link the pet image in the form?

fadillzzz
01-23-2011, 09:16 PM
As far as I know, the mod supposed to add the image based on what adoptables type is given by the admin

Hall of Famer
01-23-2011, 11:03 PM
Well Kyris, the adoptables images should be pre-defined when you create an adoptable species an its levels. Remember this one is for admins to create/edit/delete user's individual pets, not species.

Hall of Famer
01-24-2011, 02:45 PM
Update: fadillzzz helped me add pagination to the script, it works pretty well. Thank you so much dude, the finalized version is ready to be released now. Just download this new admin.php file and replace your old one with it, keep in mind that you will have to manually change things back if you've made any other modifications in your admin.php file. Enjoy.