Skip to content

Instantly share code, notes, and snippets.

@saltybeagle
Created June 10, 2011 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saltybeagle/1018042 to your computer and use it in GitHub Desktop.
Save saltybeagle/1018042 to your computer and use it in GitHub Desktop.
Story deletion procedure with error
<?php
if (!isset($_POST['delete'])) {
return false;
}
if (UNL_ENews_Controller::getUser()->uid !== $story->uid_created) {
throw new Exception('You did not create that story - you can not delete it', 403);
}
foreach ($story->getNewsrooms() as $newsroom) {
if (UNL_ENews_Newsroom_Story::getById($newsroom->id, $story->id)->status !== 'pending') {
throw new Exception('A story you attempted to delete has already been approved for use by a newsroom', 403);
}
}
return $story->delete();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment