Added database tables for advertisements, controller is still missing.

Added IP columns to dmails, forum_posts, comments.
This commit is contained in:
Parziphal 2013-11-19 10:54:12 -05:00
parent ee3b6c37ac
commit 0ab3ef62b8
13 changed files with 122 additions and 6 deletions

View File

@ -25,7 +25,7 @@ class CommentController extends ApplicationController
{
$comment = Comment::find($this->params()->id);
if (current_user()->has_permission($comment)) {
$comment->updateAttributes($this->params()->comment);
$comment->updateAttributes(array_merge($this->params()->comment, ['updater_ip_addr' => $this->request()->remoteIp()]));
$this->respond_to_success("Comment updated", '#index');
} else {
$this->access_denied();
@ -52,7 +52,7 @@ class CommentController extends ApplicationController
}
$user_id = current_user()->id;
Rails::log($this->params()->comment);
$comment = new Comment(array_merge($this->params()->comment, array('ip_addr' => $this->request()->remoteIp(), 'user_id' => $user_id)));
if ($this->params()->commit == "Post without bumping") {
$comment->do_not_bump_post = true;

View File

@ -36,7 +36,7 @@ class DmailController extends ApplicationController
$dmail = $this->params()->dmail;
if (empty($dmail['parent_id']))
$dmail['parent_id'] = null;
$this->dmail = Dmail::create(array_merge($dmail, ['from_id' => $this->current_user->id]));
$this->dmail = Dmail::create(array_merge($dmail, ['from_id' => $this->current_user->id, 'ip_addr' => $this->request()->remoteIp()]));
if ($this->dmail->errors()->none()) {
$this->notice("Message sent to ".$dmail['to_name']);

View File

@ -65,7 +65,7 @@ class ForumController extends ApplicationController
if (empty($params['parent_id']) || !ctype_digit($params['parent_id']))
$params['parent_id'] = null;
$this->forum_post = ForumPost::create(array_merge($params, ['creator_id' => $this->current_user->id]));
$this->forum_post = ForumPost::create(array_merge($params, ['creator_id' => $this->current_user->id, 'ip_addr' => $this->request()->remoteIp()]));
if ($this->forum_post->errors()->blank()) {
if (!$this->params()->forum_post['parent_id']) {
@ -120,7 +120,7 @@ class ForumController extends ApplicationController
return;
}
$this->forum_post->assignAttributes($this->params()->forum_post);
$this->forum_post->assignAttributes(array_merge($this->params()->forum_post, ['updater_ip_addr' => $this->request()->remoteIp()]);
if ($this->forum_post->save()) {
$this->notice("Post updated");

View File

@ -1,7 +1,7 @@
<?php
class CreateAdvertisements extends Rails\ActiveRecord\Migration\Base
{
public function change()
public function up()
{
$this->createTable('advertisements', function($t) {
$t->column('image_url', 'string', ['null' => false]);

View File

@ -0,0 +1,8 @@
<?php
class AddIpAddrToDmails extends Rails\ActiveRecord\Migration\Base
{
public function up()
{
$this->addColumn('dmails', 'ip_addr', 'string', ['length' => 46]);
}
}

View File

@ -0,0 +1,9 @@
<?php
class AddIpAddrToForumPosts extends Rails\ActiveRecord\Migration\Base
{
public function up()
{
$this->addColumn('forum_posts', 'ip_addr', 'string', ['length' => 46]);
$this->addColumn('forum_posts', 'updater_ip_addr', 'string', ['length' => 46]);
}
}

View File

@ -0,0 +1,8 @@
<?php
class AddUpdaterIpAddrToComments extends Rails\ActiveRecord\Migration\Base
{
public function up()
{
$this->addColumn('comments', 'updater_ip_addr', 'string', ['limit' => 46]);
}
}

2
db/seeds.php Executable file
View File

@ -0,0 +1,2 @@
<?php

View File

@ -0,0 +1,54 @@
<?php
return array (
0 =>
array (
'id' =>
array (
'type' => 'int(11)',
'default' => NULL,
),
'image_url' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
'referral_url' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
'ad_type' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
'status' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
'hit_count' =>
array (
'type' => 'int(11)',
'default' => '0',
),
'width' =>
array (
'type' => 'int(11)',
'default' => NULL,
),
'height' =>
array (
'type' => 'int(11)',
'default' => NULL,
),
),
1 =>
array (
'pri' =>
array (
0 => 'id',
),
),
)
;

View File

@ -42,6 +42,11 @@ return array (
'type' => 'tinyint(1)',
'default' => '0',
),
'updater_ip_addr' =>
array (
'type' => 'varchar(46)',
'default' => NULL,
),
),
1 =>
array (

View File

@ -42,6 +42,11 @@ return array (
'type' => 'int(11)',
'default' => NULL,
),
'ip_addr' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
),
1 =>
array (

View File

@ -62,6 +62,16 @@ return array (
'type' => 'text',
'default' => NULL,
),
'ip_addr' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
'updater_ip_addr' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
),
1 =>
array (

View File

@ -0,0 +1,15 @@
<?php
return array (
0 =>
array (
'version' =>
array (
'type' => 'varchar(255)',
'default' => NULL,
),
),
1 =>
array (
),
)
;