public
Last active

Story deletion procedure with error

  • Download Gist
storydelete.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?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();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.