diff --git a/app/controllers/DmailController.php b/app/controllers/DmailController.php index 441788f..0d4b59a 100755 --- a/app/controllers/DmailController.php +++ b/app/controllers/DmailController.php @@ -73,7 +73,6 @@ class DmailController extends ApplicationController public function markAllRead() { - vpe('a'); if ($this->params()->commit == "Yes") { foreach (Dmail::where("to_id = ? and has_seen = false", $this->current_user->id)->take() as $dmail) $dmail->updateAttribute('has_seen', true); diff --git a/app/controllers/ForumController.php b/app/controllers/ForumController.php index 89cb240..b6793e3 100755 --- a/app/controllers/ForumController.php +++ b/app/controllers/ForumController.php @@ -132,7 +132,6 @@ class ForumController extends ApplicationController public function show() { $this->forum_post = ForumPost::find($this->params()->id); - $this->set_title($this->forum_post->title); $this->children = ForumPost::where("parent_id = ?", $this->params()->id)->order("id")->paginate($this->page_number(), 30); if (!$this->current_user->is_anonymous() && $this->current_user->last_forum_topic_read_at < $this->forum_post->updated_at && $this->forum_post->updated_at < (time() - 3)) { diff --git a/app/controllers/PostController.php b/app/controllers/PostController.php index e558788..6e89a9c 100755 --- a/app/controllers/PostController.php +++ b/app/controllers/PostController.php @@ -1139,7 +1139,7 @@ class PostController extends ApplicationController 'after' => [ 'save_tags_to_cookie' => ['only' => ['update', 'create']] ], - # iTODO: + # iTODO : 'around' => [ // 'cache_action' => ['only' => ['index', 'atom', 'piclens']] ] diff --git a/app/controllers/WikiController.php b/app/controllers/WikiController.php index 4b15266..1285aed 100755 --- a/app/controllers/WikiController.php +++ b/app/controllers/WikiController.php @@ -69,6 +69,7 @@ class WikiController extends ApplicationController public function preview() { + $this->setLayout(false); $this->render(['inline' => 'format_text($this->params()->body) ?>']); } diff --git a/app/models/Dmail.php b/app/models/Dmail.php index 1e378e6..a10d2e9 100755 --- a/app/models/Dmail.php +++ b/app/models/Dmail.php @@ -71,17 +71,17 @@ class Dmail extends Rails\ActiveRecord\Base } } - protected function setToName($name) + public function setToName($name) { if (!$user = User::where(['name' => $name])->first()) return; $this->to_id = $user->id; } - protected function setFromName($name) + public function setFromName($name) { if (!$user = User::where(['name' => $name])->first()) return; $this->from_id = $user->id; } -} \ No newline at end of file +} diff --git a/app/models/Note.php b/app/models/Note.php index 3b12b80..ba1f531 100755 --- a/app/models/Note.php +++ b/app/models/Note.php @@ -61,11 +61,11 @@ class Note extends Rails\ActiveRecord\Base protected function callbacks() { - return array_merge_recursive([ + return [ 'after_save' => [ 'update_post' ] - ], $this->versioning_callbacks(), $this->versioningCallbacks()); + ]; } protected function validations() diff --git a/app/models/Pool.php b/app/models/Pool.php index 70e74cc..f691341 100755 --- a/app/models/Pool.php +++ b/app/models/Pool.php @@ -362,11 +362,11 @@ class Pool extends Rails\ActiveRecord\Base protected function callbacks() { - return array_merge_recursive([ + return [ 'before_destroy' => ['destroy_pool_posts'], 'after_save' => ['expire_cache'], 'before_validation' => ['normalize_name'], 'after_undo' => ['update_pool_links'] - ], $this->versioning_callbacks()); + ]; } } diff --git a/app/models/PoolPost.php b/app/models/PoolPost.php index 7b0d57f..3f677ba 100755 --- a/app/models/PoolPost.php +++ b/app/models/PoolPost.php @@ -42,10 +42,10 @@ class PoolPost extends Rails\ActiveRecord\Base protected function callbacks() { - return array_merge_recursive([ + return [ 'before_create' => ['set_active_changed'], # MI 'after_save' => ['expire_cache'] - ], $this->versioning_callbacks()); + ]; } public function can_change(User $user, $attribute) diff --git a/app/models/Post.php b/app/models/Post.php index 3943c42..5f989eb 100755 --- a/app/models/Post.php +++ b/app/models/Post.php @@ -228,7 +228,7 @@ class Post extends Rails\ActiveRecord\Base protected function callbacks() { - return array_merge_recursive([ + return [ 'before_save' => ['commit_tags', 'filter_parent_id'], 'before_create' => ['set_index_timestamp'], 'after_create' => ['after_creation'], @@ -241,7 +241,7 @@ class Post extends Rails\ActiveRecord\Base 'validate_content_type', 'generate_hash', 'set_image_dimensions', 'set_image_status', 'check_pending_count', 'generate_sample', 'generate_jpeg', 'generate_preview', 'move_file'] - ], $this->versioning_callbacks()); + ]; } protected function associations() @@ -303,6 +303,7 @@ class Post extends Rails\ActiveRecord\Base $this->commit_tags(); $sql = "UPDATE posts SET cached_tags = ? WHERE id = ?"; self::connection()->executeSql($sql, $this->cached_tags, $this->id); + $this->save(); } } diff --git a/app/models/Post/SqlMethods.php b/app/models/Post/SqlMethods.php index 65bcc44..48406ae 100755 --- a/app/models/Post/SqlMethods.php +++ b/app/models/Post/SqlMethods.php @@ -199,6 +199,7 @@ trait PostSqlMethods } if (is_string($q['user'])) { + $joins[] = "JOIN users u ON p.user_id = u.id"; $conds[] = "lower(u.name) = lower(?)"; $cond_params[] = $q['user']; } diff --git a/app/models/Post/StatusMethods.php b/app/models/Post/StatusMethods.php index f675913..3abd30f 100755 --- a/app/models/Post/StatusMethods.php +++ b/app/models/Post/StatusMethods.php @@ -83,7 +83,7 @@ trait PostStatusMethods $this->set_flag_detail($this->status_reason, null); } - protected function setIsHeld($hold) + public function setIsHeld($hold) { # Hack because the data comes in as a string: if ($hold === "false") @@ -104,6 +104,8 @@ trait PostStatusMethods $was_held = $this->is_held; + $this->attributes['is_held'] = $hold; + # When a post is unheld, bump it. if ($was_held && !$hold) { $this->touch_index_timestamp(); diff --git a/app/models/Post/TagMethods.php b/app/models/Post/TagMethods.php index ee0a6c5..4c60029 100755 --- a/app/models/Post/TagMethods.php +++ b/app/models/Post/TagMethods.php @@ -313,6 +313,7 @@ trait PostTagMethods // $this->tags = implode(' ', array_unique(TagImplication::with_implied(TagAlias::to_aliased($this->new_tags)))); $this->new_tags = TagAlias::to_aliased($this->new_tags); $this->new_tags = array_unique(TagImplication::with_implied($this->new_tags)); + sort($this->new_tags); // $this->tags = implode(' ', $this->tags()); # TODO: be more selective in deleting from the join table diff --git a/app/models/Tag.php b/app/models/Tag.php index 76327b4..3aaebbf 100755 --- a/app/models/Tag.php +++ b/app/models/Tag.php @@ -571,9 +571,9 @@ class Tag extends Rails\ActiveRecord\Base static public function mass_edit($start_tags, $result_tags, $updater_id, $updater_ip_addr) { foreach (Post::find_by_tags($start_tags) as $p) { - $start = TagAlias::to_aliased(Tag::scan_tags($start_tags)); + $start = TagAlias::to_aliased(Tag::scan_tags($start_tags)); $result = TagAlias::to_aliased(Tag::scan_tags($result_tags)); - $tags = array_merge(array_diff(array_keys($p->tags()), $start), $result); + $tags = array_merge(array_diff($p->tags(), $start), $result); $tags = implode(' ', $tags); $p->updateAttributes(array('updater_user_id' => $updater_id, 'updater_ip_addr' => $updater_ip_addr, 'tags' => $tags)); } @@ -631,13 +631,13 @@ class Tag extends Rails\ActiveRecord\Base protected function callbacks() { - return array_merge_recursive([ + return [ 'after_save' => [ 'update_cache' ], 'after_create' => [ 'update_cache_on_create' ] - ], $this->versioning_callbacks()); + ]; } } diff --git a/app/models/Tag/CacheMethods.php b/app/models/Tag/CacheMethods.php index 90b10cc..6abddbe 100755 --- a/app/models/Tag/CacheMethods.php +++ b/app/models/Tag/CacheMethods.php @@ -9,7 +9,7 @@ trait CacheMethods protected function update_cache() { # iTODO: hash keys - Rails::cache()->write('tag_type_' . $this->name, self::type_name_from_value($this->tag_type)); + Rails::cache()->write('tag_type.' . $this->name, self::type_name_from_value($this->tag_type)); # Expire the tag cache if a tag's type changes. if ($this->tag_type != $this->tagTypeWas()) { diff --git a/app/models/WikiPage.php b/app/models/WikiPage.php index 6cb8402..123fde9 100755 --- a/app/models/WikiPage.php +++ b/app/models/WikiPage.php @@ -125,10 +125,10 @@ class WikiPage extends Rails\ActiveRecord\Base protected function callbacks() { - return array_merge_recursive([ + return [ 'before_save' => ['normalize_title'], 'before_validation_on_update' => ['ensure_changed'] - ], $this->versioningCallbacks()); + ]; } protected function associations() @@ -159,8 +159,8 @@ class WikiPage extends Rails\ActiveRecord\Base ]; } - protected function versioningRelation($relation) + protected function versioningRelation() { - return $relation->order("updated_at DESC"); + return self::order("updated_at DESC"); } } \ No newline at end of file diff --git a/app/views/comment/show.php b/app/views/comment/show.php index 6e3b4bc..43ffa63 100755 --- a/app/views/comment/show.php +++ b/app/views/comment/show.php @@ -1,3 +1,4 @@ +provide('title', $this->t('.title')) ?> partial("comment/comments", array('comments' => array($this->comment), 'post_id' => $this->comment->post_id, 'hide' => false)) ?>
diff --git a/app/views/forum/show.php b/app/views/forum/show.php index b57bf04..944294d 100755 --- a/app/views/forum/show.php +++ b/app/views/forum/show.php @@ -1,3 +1,4 @@ +provide('title', $this->forum_post->title) ?> forum_post->is_locked) : ?>

t('.locked') ?>

diff --git a/app/views/post/deleted_index.php b/app/views/post/deleted_index.php index 5e3ae94..93d1156 100755 --- a/app/views/post/deleted_index.php +++ b/app/views/post/deleted_index.php @@ -19,7 +19,7 @@ linkTo($post->id, ['action' => 'show', 'id' => $post->id]) ?> linkTo($this->h($post->author()), ['user#show', 'id' => $post->user_id]) ?> - h($post->tags()) ?> + h($post->cached_tags) ?> h($post->flag_detail->reason) ?> is_mod_or_higher()) : ?> linkTo($this->h($post->flag_detail->author()), ['user#show', 'id' => $post->flag_detail->user_id]) ?> diff --git a/lib/DText.php b/lib/DText.php index 2cb6c86..697c414 100755 --- a/lib/DText.php +++ b/lib/DText.php @@ -34,7 +34,9 @@ class DText # Parse inline tags as a whole. $result = self::parseinline($result); - return $result; + # htmLawed ensures valid html output. + require_once Rails::root() . '/vendor/htmLawed/htmLawed.php'; + return htmLawed($result); } static public function parseinline($str) @@ -126,7 +128,7 @@ class DText $state[] = "1"; $html .= '', $last - $n); @@ -135,7 +137,7 @@ class DText } elseif ($n > $last) { $html .= '