From ee34fe74dd28687a70dc044a13acfeb057b9e76a Mon Sep 17 00:00:00 2001 From: Mzhelskiy Maxim Date: Sat, 21 Apr 2012 11:04:16 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D1=87=D0=B5=D1=82=20IP=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=B3=D0=BE=D0=BB=D0=BE=D1=81=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/modules/vote/Vote.class.php | 3 +++ classes/modules/vote/entity/Vote.entity.class.php | 6 ++++++ classes/modules/vote/mapper/Vote.mapper.class.php | 7 ++++--- install/convert_0.5.1_to_1.0.sql | 5 ++++- install/sql.sql | 4 +++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/classes/modules/vote/Vote.class.php b/classes/modules/vote/Vote.class.php index 4240b9f8..a20ba228 100644 --- a/classes/modules/vote/Vote.class.php +++ b/classes/modules/vote/Vote.class.php @@ -37,6 +37,9 @@ class ModuleVote extends Module { * @return unknown */ public function AddVote(ModuleVote_EntityVote $oVote) { + if (!$oVote->getIp()) { + $oVote->setIp(func_getIp()); + } if ($this->oMapper->AddVote($oVote)) { $this->Cache_Delete("vote_{$oVote->getTargetType()}_{$oVote->getTargetId()}_{$oVote->getVoterId()}"); $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("vote_update_{$oVote->getTargetType()}_{$oVote->getVoterId()}")); diff --git a/classes/modules/vote/entity/Vote.entity.class.php b/classes/modules/vote/entity/Vote.entity.class.php index 0bcf97ac..a4ff4874 100644 --- a/classes/modules/vote/entity/Vote.entity.class.php +++ b/classes/modules/vote/entity/Vote.entity.class.php @@ -35,6 +35,9 @@ class ModuleVote_EntityVote extends Entity public function getDate() { return $this->_aData['vote_date']; } + public function getIp() { + return $this->_getDataOne('vote_ip'); + } @@ -56,5 +59,8 @@ class ModuleVote_EntityVote extends Entity public function setDate($data) { $this->_aData['vote_date']=$data; } + public function setIp($data) { + $this->_aData['vote_ip']=$data; + } } ?> \ No newline at end of file diff --git a/classes/modules/vote/mapper/Vote.mapper.class.php b/classes/modules/vote/mapper/Vote.mapper.class.php index d884ee2f..cbf9dcd5 100644 --- a/classes/modules/vote/mapper/Vote.mapper.class.php +++ b/classes/modules/vote/mapper/Vote.mapper.class.php @@ -25,11 +25,12 @@ class ModuleVote_MapperVote extends Mapper { user_voter_id, vote_direction, vote_value, - vote_date + vote_date, + vote_ip ) - VALUES(?d, ?, ?d, ?d, ?f, ?) + VALUES(?d, ?, ?d, ?d, ?f, ?, ?) "; - if ($this->oDb->query($sql,$oVote->getTargetId(),$oVote->getTargetType(),$oVote->getVoterId(),$oVote->getDirection(),$oVote->getValue(),$oVote->getDate())===0) + if ($this->oDb->query($sql,$oVote->getTargetId(),$oVote->getTargetType(),$oVote->getVoterId(),$oVote->getDirection(),$oVote->getValue(),$oVote->getDate(),$oVote->getIp())===0) { return true; } diff --git a/install/convert_0.5.1_to_1.0.sql b/install/convert_0.5.1_to_1.0.sql index 49bc60b9..11063aea 100644 --- a/install/convert_0.5.1_to_1.0.sql +++ b/install/convert_0.5.1_to_1.0.sql @@ -110,4 +110,7 @@ INSERT INTO `prefix_user_field` (`type`, `name`, `title`, `pattern`) VALUES ('social', 'vkontakte', 'ВКонтакте', '{*}'), ('social', 'odnoklassniki', 'Одноклассники', '{*}'); -ALTER TABLE `prefix_favourite_tag` ADD INDEX ( `text` ); \ No newline at end of file +ALTER TABLE `prefix_favourite_tag` ADD INDEX ( `text` ); + +ALTER TABLE `prefix_vote` ADD `vote_ip` VARCHAR( 15 ) NOT NULL DEFAULT '', +ADD INDEX ( `vote_ip` ); \ No newline at end of file diff --git a/install/sql.sql b/install/sql.sql index 73666de3..64d06b8b 100644 --- a/install/sql.sql +++ b/install/sql.sql @@ -769,8 +769,10 @@ CREATE TABLE IF NOT EXISTS `prefix_vote` ( `vote_direction` tinyint(2) DEFAULT '0', `vote_value` float(9,3) NOT NULL DEFAULT '0.000', `vote_date` datetime NOT NULL, + `vote_ip` varchar(15) NOT NULL DEFAULT '', PRIMARY KEY (`target_id`,`target_type`,`user_voter_id`), - KEY `user_voter_id` (`user_voter_id`) + KEY `user_voter_id` (`user_voter_id`), + KEY `vote_ip` (`vote_ip`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --