updating
This commit is contained in:
parent
c9027c3dca
commit
0545bde1a0
@ -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);
|
||||
|
@ -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)) {
|
||||
|
@ -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']]
|
||||
]
|
||||
|
@ -69,6 +69,7 @@ class WikiController extends ApplicationController
|
||||
|
||||
public function preview()
|
||||
{
|
||||
$this->setLayout(false);
|
||||
$this->render(['inline' => '<?= $this->format_text($this->params()->body) ?>']);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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());
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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'];
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
<?php $this->provide('title', $this->t('.title')) ?>
|
||||
<?= $this->partial("comment/comments", array('comments' => array($this->comment), 'post_id' => $this->comment->post_id, 'hide' => false)) ?>
|
||||
|
||||
<div style="clear: both;">
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?php $this->provide('title', $this->forum_post->title) ?>
|
||||
<?php if ($this->forum_post->is_locked) : ?>
|
||||
<div class="status-notice">
|
||||
<p><?= $this->t('.locked') ?></p>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<!-- <td><?= $post->flag_detail->is_resolved ? 'Yes' : 'No' ?></td> -->
|
||||
<td><?= $this->linkTo($post->id, ['action' => 'show', 'id' => $post->id]) ?></td>
|
||||
<td><?= $this->linkTo($this->h($post->author()), ['user#show', 'id' => $post->user_id]) ?></td>
|
||||
<td><?= $this->h($post->tags()) ?></td>
|
||||
<td><?= $this->h($post->cached_tags) ?></td>
|
||||
<td><?= $this->h($post->flag_detail->reason) ?></td>
|
||||
<?php if (current_user()->is_mod_or_higher()) : ?>
|
||||
<td><?= $this->linkTo($this->h($post->flag_detail->author()), ['user#show', 'id' => $post->flag_detail->user_id]) ?></td>
|
||||
|
@ -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 .= '<ul>';
|
||||
} else {
|
||||
$n = substr_count(preg_match('/^\*+\s+/', $str) ? $str : '', '*');
|
||||
$n = substr_count((preg_match('/^\*+\s+/', $str, $m) ? $m[0] : ''), '*');
|
||||
$last = (int)end($state);
|
||||
if ($n < $last) {
|
||||
$html .= str_repeat('</ul>', $last - $n);
|
||||
@ -135,7 +137,7 @@ class DText
|
||||
} elseif ($n > $last) {
|
||||
$html .= '<ul>';
|
||||
array_pop($state);
|
||||
$state[] = (string)(end($state) + 1);
|
||||
$state[] = (string)($last + 1);
|
||||
}
|
||||
if (!preg_match('/^\*+\s+/', $str)) {
|
||||
array_pop($state);
|
||||
|
@ -140,7 +140,7 @@ trait VersioningTrait
|
||||
self::connection()->executeSql($sql, static::tableName(), $this->id);
|
||||
}
|
||||
|
||||
public function versioning_callbacks()
|
||||
public function moeVersioningCallbacks()
|
||||
{
|
||||
return [
|
||||
'after_save' => [
|
||||
|
Reference in New Issue
Block a user