| | 307 | //delete an entry |
|---|
| | 308 | function deleteEntry($id) |
|---|
| | 309 | { |
|---|
| | 310 | $id = $this->blog->makeCleanString($id); |
|---|
| | 311 | if (!$id) { |
|---|
| | 312 | error(4,"If you dont give me a post how do you expect me to delete it"); |
|---|
| | 313 | } |
|---|
| | 314 | //no errors, so continue.. |
|---|
| | 315 | if (!$this->inputError) { |
|---|
| | 316 | //check to see this post exists |
|---|
| | 317 | $sql = db_query("SELECT id from entries where shortsubject = '".$id."' AND user_id='".$this->id."';"); |
|---|
| | 318 | $sqlNum = db_num_rows($sql); |
|---|
| | 319 | //yes?, we can delete it then.. |
|---|
| | 320 | if ($sqlNum == 1) { |
|---|
| | 321 | $sql = db_query("DELETE FROM entries WHERE shortsubject = '{$id}' AND user_id = '".$this->id."';"); |
|---|
| | 322 | if (!$sql) { |
|---|
| | 323 | error(2,"Entry deletion failed - ".db_error()); |
|---|
| | 324 | } |
|---|
| | 325 | else { |
|---|
| | 326 | $this->inputError = _("Entry deleted."); |
|---|
| | 327 | $this->updateForm($id); |
|---|
| | 328 | } |
|---|
| | 329 | } |
|---|
| | 330 | //cant update non-existant entrys |
|---|
| | 331 | else { |
|---|
| | 332 | error(2,_("Cannot delete entry, as it does not exist.".db_error())); |
|---|
| | 333 | } |
|---|
| | 334 | } |
|---|
| | 335 | //redisplay entry form if there are errors |
|---|
| | 336 | else { |
|---|
| | 337 | $this->updateForm($id); |
|---|
| | 338 | } |
|---|
| | 339 | } |
|---|
| | 340 | |
|---|