I am trying to create a basic user permissions system. users can upload photos into their private section and if one user wants to view these they request permission to the other user.
The bit i am working on at the moment is allowing the user to see that other users photos depending on their enum value being set either to '0' or '1' in the column 'privilege' within my database 'ptb_permissions'.
I am using a mysql table with three columns like so:
user_id | private_id | privilege
1 4 1
2 6 0
I want it to be user specific so if user one requests to see user 4's photos and user 1 says this is ok, they set user 4's privelege from '0' to '1'.
so if the user tries to view a private photo and they are not permitted to this will show a template image of a padlock which indicates tehy are not allowed to see this photo.
If they are allowed to see this photo then the photo will change from being a padlock image to the actual image.
Heres the code that i have so far, however it is bringing an error up saying called to undefined function.
can someone please show me how i can get this to work.
thank you.
i hope i have explained this well enough please ask if you need more information.
function:
function account_perms() {
global $connection;
global $_SESSION;
global $profile_id;
$query = "SELECT *
FROM ptb_permissions
WHERE ptb_permissions.private_id = \"$profile_id\"
AND ptb_permissions.user_id = ".$_SESSION['user_id']." ";
$account_perms = mysql_query($query, $connection);
confirm_query($query, $connection);
return $account_perms;
}
code:
<?php
$account_perms = account_perms();
while ($perms = mysql_fetch_array($account_perms)) {
if ($perms['privelege'] = '1') {
?>
<?php
$photo = "data/private_photos/$profile[1]/pic1.jpg";
$thumb = "data/private_photos/$profile[1]/thumb_pic1.jpg";
echo
"<li><a href=\"$photo\" rel=\"shadowbox\" title=\"<strong>$profile[2]'s Photo's</strong>\"><img src=\"$thumb\" width=\"90\" height=\"90\" alt=\"<strong>{$profile[2]}'s Photos</strong>\" /></a></li>";
}
}
else
$photo = "data/other/other/_default.jpg";
$thumb = "data/other/other/_default.jpg";
echo
"<li><a href=\"$photo\" rel=\"shadowbox\" title=\"<strong>$profile[2]'s Photo's</strong>\"><img src=\"$thumb\" width=\"90\" height=\"90\" alt=\"<strong>{$profile[2]}'s Photos</strong>\" /></a></li>";
}
}