Location: PHPKode > projects > Club video list website > animelists/extended_list.php
<?php
/*
Animelists website
Copyright (C) 2002 Jeff Wartes

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

-------------------------------------------------

This page is similar to the primary list, however it has been designed more
with the administrator in mind. Not all users will have full access to the
functionality of this page, but it provides ways to edit or delete entries,
as well as see the contact information of the people who added items to the
list.

$Id: extended_list.php,v 1.4 2002/10/20 21:28:56 pyreforge Exp $
*/

if (!isset($COMMONINCLUDED)){
    include("common.php");
}
setcookie("lastview", "extended_list.php", time()+COOKIELIFE);
?>

<html>
<head>
<title>Edit Anime listings</title>
<style> <!-- @import url(animelists.css); --> </style>

<script language="JavaScript">
function showUserInfo(username, email){
    userInfo.rows[0].cells[0].innerHTML = '<b>Owner:</b> ' + username
        + ' <br> <b>Contact info:</b> <a href="mailto:' + email + '">' + email + '</a>';
}
</script>

</head>


<?php

if (!isset($USERINCLUDED)){
    include("userclass.php");
}
dieIfNoLogin();

$userData = new UserList(USERDATAFILE);
//validate user login info before making changes
$thisUser = $userData->getByName($username);
if (!$thisUser->validateUser($username, $userpass)){
    dieWithInvalidUser();
}

if ($thisUser->rank >= ADMIN){
    echo "Since you have admin rights, this is the entire list.<br>";
    echo "Most users are only able to edit entries that they made.<br><br>";
}
elseif ($thisUser->rank >= VIEWER){
    echo "This is similar to what users with Admin rights see. <br>";
    echo "As you can tell, this means they can get your contact information, as well as edit your entries.<br>";
    echo "However, you are not a full admin, so although you can get anyone's contact info, you cannot edit listings you haven't added yourself.<br>";
}
else {
    echo "This is what users with Admin rights see. <br>";
    echo "As you can tell, this means they can get your contact information, as well as edit your entries.<br>";
    echo "However, your access level only permits you to see and edit items you added to the list yourself.<br><br>";
}

?>

<script language="JavaScript">
function initialize(){
    if (animeTable.rows.length <= 1){
        userInfo.rows[0].cells[0].innerHTML = "Since you have not added anything to the list, this page is empty.";
    }
}
</script>


<body onload="initialize();">

<table class="listtable" id="animeTable" rules="groups" cols=8 hlcolor="#BEC5DE" slcolor="#33CC99">
  <caption><b>
    <h2>Edit anime listings</h2><small><small><a href="help" onclick="window.open('./table_help.htm#modify_list', '', 'menubar=no,directories=no,location=no,status=no,toolbar=no,scrollbars=yes,height=400,width=400'); return false;">explanation</a></small></small>
  </b></caption>
  <thead>
    <tr class="listheaderrow">
      <td class="listheader">Title</td>
      <td class="listheader">Votes</td>
      <td class="listheader">User</td>
      <td class="listheader">Format</td>
      <td class="listheader">English Sub/Dub</td>
      <td class="listheader">Collection Type</td>
      <td class="listheader">Time</td>
      <td class="listheader">Owned</td>
    </tr>
  </thead>
  <tbody>

<?php

//first load the list data into a PHP variable
include("showclass.php");
$listData = new ShowList(SHOWDATAFILE);

if ($listData){
    foreach($listData->shows as $aShow){

        //list all entries if user has Viewer rights or higher, otherwise just the ones entered by this user
        if ($thisUser->rank >= VIEWER || (strcasecmp($aShow->owner, $username) == 0)){
            //going to do some hyperlink stuff for the fields in the table since this is the admin list
            //TODO, find some escape functions, this manual backslashing is a pain

            //For each title, give it a hyperlink that allows you to modify it (if admin)
            if ($thisUser->rank >= ADMIN || (strcasecmp($aShow->owner, $username) == 0)){
                $showSelector = $aShow->title . " ";
                $showSelector .= printAddShowLink("<img src='" . IMAGESDIR . "edit.gif' alt='Edit this entry' border=0 height=12 width=12>", "?key=" . $aShow->key);
            }
            else {
                $showSelector = $aShow->title;
            }

            //For each user/owner, include a hyperlink that shows their contact info
            $userInfo = $userData->getByName($aShow->owner);
            $ownerSelector = $aShow->owner . " ";
            $ownerSelector .=   "<a ";
            $ownerSelector .=      "href='#userInfo' ";
            $ownerSelector .=      "onclick=\"showUserInfo('$aShow->owner','$userInfo->email');\" ";
//            $ownerSelector .=      "onclick=\"userInfo.rows[0].cells[0].innerHTML = '<b>Owner:</b> $aShow->owner <br> <b>Contact info:</b>" . (isEmail($userInfo->email) ? addslashes(addslashes(wrapEmail($userInfo->email))) : $userInfo->email) . "'; return true;\" ";
            $ownerSelector .=      "onmouseover=\"status = 'Show contact info for this person'; return true;\" ";
            $ownerSelector .=      "onmouseout=\"status = ' '; return true;\" ";
            $ownerSelector .=   "> <img src='" . IMAGESDIR . "question.gif' alt='Show contact info for this person' align=bottom border=0 height=14 width=14> </a>";

            echo "    <tr class='listrow'>\n";
            echo "      <td class='listitem'>" . $showSelector . "</td>\n";
            echo "      <td class='listitem'>" . $aShow->countVotes() . "</td>\n";
            echo "      <td class='listitem'>" . $ownerSelector . "</td>\n";
            echo "      <td class='listitem'>" . $aShow->format . "</td>\n";
            echo "      <td class='listitem'>" . $aShow->language . "</td>\n";
            echo "      <td class='listitem'>" . $aShow->collection . "</td>\n";
            echo "      <td class='listitem'>" . $aShow->time . "</td>\n";
            echo "      <td class='listitem'>" . $aShow->owned . "</td>\n";
            echo "    </tr>\n";
        }
    }
}
?>

  </tbody>
</table>

<hr>
<table id="userInfo">
  <tr>
    <td>No owner currently selected.</td>
  </tr>
</table>


<hr>
<?php echo printLinkFooter(); ?>

</body>

Return current item: Club video list website