View Single Post
  #1  
Old 01-21-2011, 12:01 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 381,030
Hall of Famer is on a distinguished road
Default Create/Edit/Delete user's owned adoptables through acp!

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:

PHP Code:
    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:

PHP Code:
  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:

PHP Code:
</p></form><b><a href='admin.php?set=users&do=groups'><img src='templates/icons/fr.gif' border=0Manage 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:

PHP Code:
   </p></form><b><a href='admin.php?set=users&do=adoptables'><img src='templates/icons/fr.gif' border=0Manage 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:



Screenshot2: The subpage of Create/Edit/Delete user's individual pets:


Screenshot3: Creating new owned adoptables


Screenshot4: Editing existing owned adoptables


Screenshot5: Deleted an owned adoptable successfully
Attached Files
File Type: php cadopt.php (6.2 KB, 11 views)
File Type: php eadopt.php (7.0 KB, 11 views)
File Type: php admin.php (86.7 KB, 4 views)
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote