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 update() { $auth_user = User::getAuthenticated(); if (!$auth_user) { throw new PermissionException(); } send_json(array('hasUpdates' => Follow::getUpdates($auth_user) ? true : false)); }
echo readable_text($comment->body); ?> </div> </div> <?php } ?> </div> <div class="row"> <?php print_pagination($pagination, $pages); ?> </div> <div class="row"> <?php if (User::getAuthenticated()) { ?> <form action="<?php eh(url(POST_COMMENT_URL)); ?> " class="well" method="post"> <label for="body">Comment</label> <textarea class='u-full-width' id='body' name="body" placeholder='Wrap URL in [img]...[/img] to embed an image.'><?php eh(Param::get('body')); ?> </textarea> <input type="hidden" name="thread_id" value="<?php eh($thread->id); ?> "> <input type="hidden" name="page_next" value="create_end">
function redirect_guest_user($url = APP_URL) { if (!User::getAuthenticated()) { redirect($url); } }
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()); }
">Thread</option> <option value="<?php eh(SearchController::TYPE_COMMENT); ?> ">Comment</option> <option value="<?php eh(SearchController::TYPE_USER); ?> ">User</option> </select> <input type="text" name="query" id="query" placeholder="search"> <button type="submit">Search</button> </form> <ul class="user-panel u-pull-right"> <?php if ($auth_u = User::getAuthenticated()) { ?> <li><a id='follow' href="<?php eh(url(VIEW_FOLLOWS_URL)); ?> ">follows</a></li> <li><a href="<?php eh(url(CREATE_THREAD_URL)); ?> ">create_thread</a></li> <li><a href="<?php eh(url(VIEW_USER_URL)); ?> "><?php eh($auth_u->username); ?>
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); }