Skip to content

Commit

Permalink
minor fix for deleting a file and a few messages
Browse files Browse the repository at this point in the history
added a message in the list if you haven't entered any voting sites yet.
  • Loading branch information
Keinstah committed Mar 16, 2013
1 parent dd2df0d commit 2494bbe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions lang/en_us.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"FailedToUpdate" => "Failed to update the value of %s.",
"VotingSiteUpdated" => "Voting Site has been updated.",
"NoChangesMade" => "No changes has been made to the voting site.",
"NoVotingSiteYet" => "You haven't submitted any voting site yet.",
);

?>
15 changes: 11 additions & 4 deletions modules/voteforpoints/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@
$this->loginRequired();
$vfp_sites = Flux::config('FluxTables.vfp_sites');
$vfp_logs = Flux::config('FluxTables.vfp_logs');
$errorMessage = NULL;

// delete voting site
if (isset($_POST['id']))
{
$id = (int) $params->get('id');

$sql = "DELETE FROM $server->loginDatabase.$vfp_sites WHERE id = ? UNION
DELETE FROM $server->loginDAtabase.$vfp_logs WHERE sites_id = ?";
$sql = "DELETE FROM $server->loginDatabase.$vfp_sites WHERE id = ?";
$sth = $server->connection->getStatement($sql);
$sth->execute(array($id, $id));
$sth->execute(array($id));

if ($sth->rowCount() === 0)
{
$errorMessage = Flux::message("VoteSiteDeleteFailed");
} else {
}

$sql = "DELETE FROM $server->loginDatabase.$vfp_logs WHERE sites_id = ?";
$sth = $server->connection->getStatement($sql);
$sth->execute(array($id));

if (is_null($errorMessage))
{
$successMessage = Flux::message("VoteSiteDeleteSuccess");
}
}
Expand Down
8 changes: 6 additions & 2 deletions themes/default/voteforpoints/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<?php elseif (!empty($successMessage)): ?>
<p class="green"><?php echo htmlspecialchars($successMessage) ?></p>
<?php endif ?>
<?php if (count($votesites_res) === 0): ?>
<p class='message'><?= Flux::message('NoVotingSiteYet') ?></p>
<?php else: ?>
<form action="<?php echo $this->urlWithQs ?>" method="post" class="generic-form">
<table class="horizontal-table vote-table">
<tr>
Expand All @@ -22,7 +25,7 @@
<td style="text-align:center"><?= number_format($row->votepoints) ?></td>
<td style="text-align:center"><?php echo $row->voteinterval." ".((int) $row->voteinterval > 1 ? "Hours" : "Hour") ?></td>
<td style="text-align:center"><?= date(Flux::config("DateFormat"), strtotime($row->datetime_created)) ?></td>
<td style="text-align:center"><button type="submit" name="id" value="<?= (int) $row->id ?>">Delete</button> | <button type='button' onclick="window.open('<?php echo $this->url('voteforpoints', 'edit').(Flux::config('UseCleanUrls') ? "?id=".$row->id : "&id=".$row->id) ?>');">Edit</button></td>
<td style="text-align:center"><button type="submit" name="id" value="<?= (int) $row->id ?>" onclick="if(!confirm('Are you sure about this?')) return false;">Delete</button> | <button type='button' onclick="window.open('<?php echo $this->url('voteforpoints', 'edit').(Flux::config('UseCleanUrls') ? "?id=".$row->id : "&id=".$row->id) ?>');">Edit</button></td>
</tr>
<?php endforeach ?>
</table>
Expand All @@ -40,4 +43,5 @@
window.open(vote_sites[id]);
});
});
</script>
</script>
<?php endif ?>

0 comments on commit 2494bbe

Please sign in to comment.