public function delete() { redirect_guest_user(LOGIN_URL); $id = Param::get('id'); $comment = Comment::get($id); $auth_user = User::getAuthenticated(); $page = Param::get('page_next', 'delete'); if (!$comment->isAuthor($auth_user)) { throw new PermissionException(); } if ($comment->isThreadBody()) { redirect(DELETE_THREAD_URL, array('id' => $comment->thread_id)); } switch ($page) { case 'delete': break; case 'delete_end': $comment->delete(); redirect(VIEW_THREAD_URL, array('id' => $comment->thread_id)); break; default: throw new PageNotFoundException(); break; } $title = 'Delete comment'; $this->set(get_defined_vars()); }
public function listAll() { redirect_guest_user(LOGIN_URL); $auth_user = User::getAuthenticated(); $follows = Follow::getAll($auth_user); $updates = Follow::getUpdates($auth_user); $threads = array(); $updated_threads = array(); foreach ($follows as $follow) { $threads[] = Thread::get($follow->thread_id); } foreach ($updates as $update) { $thread = Thread::get($update->thread_id); $thread->update_count = $update->count; $thread->follow_id = $update->id; $updated_threads[] = $thread; } $title = 'Follows'; $this->set(get_defined_vars()); }
public function delete() { redirect_guest_user(LOGIN_URL); $page = Param::get('page_next', 'delete'); $thread = Thread::get(Param::get('id')); $auth_user = User::getAuthenticated(); if (!$thread->isAuthor($auth_user)) { throw new PermissionException(); } switch ($page) { case 'delete': break; case 'delete_end': $thread->delete(); redirect(LIST_THREADS_URL); break; default: break; } $title = 'Delete thread'; $this->set(get_defined_vars()); }
public function edit() { redirect_guest_user(LOGIN_URL); $page = Param::get('page_next', 'edit'); $auth_user = User::getAuthenticated(); switch ($page) { case 'edit': break; case 'edit_end': $auth_user->first_name = trim_collapse(Param::get('first_name')); $auth_user->last_name = trim_collapse(Param::get('last_name')); $auth_user->current_password = Param::get('password'); $auth_user->new_password = Param::get('new_password'); try { $auth_user->update(); } catch (ValidationException $e) { $page = 'edit'; break; } break; default: throw new PageNotFoundException(); break; } $title = 'Edit Profile'; $this->set(get_defined_vars()); $this->render($page); }