deleting the user withouth images delete resulted in image deletion too: the DB entriy gets removed but the image stays on the Hard drive.
this is fixed. also the Foreign key needs to be manually updated in images table. named the foreign keys in install.php for easier altering in the future.
This commit is contained in:
parent
023384149f
commit
ddd3f99835
@ -487,6 +487,11 @@ class UserPage extends SimpleExtension {
|
||||
"You need to specify the account number to edit"));
|
||||
}
|
||||
else{
|
||||
$rows = $database->get_all("SELECT * FROM images WHERE owner_id = :owner_id", array("owner_id" => $_POST['id']));
|
||||
foreach ($rows as $key => $value)
|
||||
{
|
||||
$database->Execute("UPDATE images SET owner_id = :owner_id WHERE id = :id;", array("owner_id" => 1, "id" => $value['id']));
|
||||
}
|
||||
$database->execute("DELETE FROM users
|
||||
WHERE id = :id"
|
||||
, array("id"=>$_POST['id']));
|
||||
|
@ -149,47 +149,50 @@ class UserPageTheme extends Themelet {
|
||||
|
||||
protected function build_options(User $duser) {
|
||||
global $config, $database, $user;
|
||||
|
||||
$html = "
|
||||
".make_form(make_link("user_admin/change_pass"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Password</th></tr>
|
||||
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
|
||||
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<p>".make_form(make_link("user_admin/change_email"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Email</th></tr>
|
||||
<tr><td>Address</td><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
if($user->is_admin()) {
|
||||
$i_user_id = int_escape($duser->id);
|
||||
$h_is_admin = $duser->is_admin() ? " checked" : "";
|
||||
$html = "";
|
||||
if($duser->id != 1){ //justa fool-admin protection so they dont mess around with anon users.
|
||||
|
||||
$html .= "
|
||||
<p>".make_form(make_link("user_admin/set_more"))."
|
||||
".make_form(make_link("user_admin/change_pass"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Password</th></tr>
|
||||
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
|
||||
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<p>".make_form(make_link("user_admin/change_email"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Email</th></tr>
|
||||
<tr><td>Address</td><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
if($user->is_admin()) {
|
||||
$i_user_id = int_escape($duser->id);
|
||||
$h_is_admin = $duser->is_admin() ? " checked" : "";
|
||||
$html .= "
|
||||
<p>".make_form(make_link("user_admin/set_more"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
Admin: <input name='admin' type='checkbox'$h_is_admin>
|
||||
<input type='submit' value='Set'>
|
||||
</form>
|
||||
|
||||
".make_form(make_link("user_admin/delete_user"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
Admin: <input name='admin' type='checkbox'$h_is_admin>
|
||||
<input type='submit' value='Set'>
|
||||
</form>
|
||||
|
||||
".make_form(make_link("user_admin/delete_user"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
<input type='submit' value='Delete User' onclick='confirm(\"Delete the user?\");' />
|
||||
</form>
|
||||
|
||||
".make_form(make_link("user_admin/delete_user_with_images"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
<input type='submit' value='Delete User with images' onclick='confirm(\"Delete the user with his uploaded images?\");' />
|
||||
</form>";
|
||||
<input type='submit' value='Delete User' onclick='confirm(\"Delete the user?\");' />
|
||||
</form>
|
||||
|
||||
".make_form(make_link("user_admin/delete_user_with_images"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
<input type='submit' value='Delete User with images' onclick='confirm(\"Delete the user with his uploaded images?\");' />
|
||||
</form>";
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ function create_tables() { // {{{
|
||||
INDEX(owner_id),
|
||||
INDEX(width),
|
||||
INDEX(height),
|
||||
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
|
||||
");
|
||||
$db->create_table("tags", "
|
||||
id SCORE_AIPK,
|
||||
@ -298,8 +298,8 @@ function create_tables() { // {{{
|
||||
INDEX(image_id),
|
||||
INDEX(tag_id),
|
||||
UNIQUE(image_id, tag_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
||||
CONSTRAINT foreign_images_tags_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
CONSTRAINT foreign_images_tags_tag_id FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
||||
");
|
||||
$db->execute("INSERT INTO config(name, value) VALUES('db_version', 8)");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user