diff --git a/DesignSurvey/Prototype_sent.php b/DesignSurvey/Prototype_sent.php index 883b0a99685e86a5d5cc37fd49f093659720459e..db3fc186b97d6535e16a2ca18913dd9199dc59fe 100644 --- a/DesignSurvey/Prototype_sent.php +++ b/DesignSurvey/Prototype_sent.php @@ -13,6 +13,7 @@ class DesignSurvey_Prototype_sent extends DB_DataObject var $id; // int(11) not_null primary_key auto_increment var $voter_id; // int(11) not_null multiple_key var $prototype_id; // int(11) not_null + var $viewed_alt; // int(1) not_null /* ZE2 compatibility trick*/ function __clone() { return $this;} diff --git a/DesignSurvey/designsurvey.ini b/DesignSurvey/designsurvey.ini index 53e475951be6843316cfdb9f315d1abbcf938001..b839068c7ece59b9c17cee56de40cbf261d19263 100644 --- a/DesignSurvey/designsurvey.ini +++ b/DesignSurvey/designsurvey.ini @@ -48,6 +48,7 @@ id = N id = 129 voter_id = 129 prototype_id = 129 +viewed_alt = 17 [prototype_sent__keys] id = N diff --git a/database/designsurvey.sql b/database/designsurvey.sql index 686a820f76c933a4ac1b319ca07f7b480c870b2e..04e1e5563fc61366dee49cecbacfd13a506636e1 100644 --- a/database/designsurvey.sql +++ b/database/designsurvey.sql @@ -122,10 +122,12 @@ CREATE TABLE IF NOT EXISTS `prototype_sent` ( `id` int(11) NOT NULL auto_increment, `voter_id` int(11) NOT NULL default '0', `prototype_id` int(11) NOT NULL default '0', + `viewed_alt` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `voter_id` (`voter_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -- -------------------------------------------------------- -- diff --git a/prototype_server.php b/prototype_server.php index 8f2bc156d0a37d714136998d0d08b00569f16f4e..055cab9ae209407e26ebc60e5eaacb692f26ecf8 100644 --- a/prototype_server.php +++ b/prototype_server.php @@ -27,11 +27,12 @@ if ($prototype->get($_GET['id'])) { break; case 'alt': $format = 'alt_image'; + $voter = new Voting_System(); break; } - header('Content-type: image/png'); + header('Content-type: image/png'); echo file_get_contents($image_path.$prototype->$format); - if ($format=='splash_image') { + if ($format=='splash_image' || $format == 'alt_image') { flush(); $prototype_sent = DB_DataObject::factory('prototype_sent'); $prototype_sent->voter_id = $voter->getVoterId(); @@ -40,6 +41,12 @@ if ($prototype->get($_GET['id'])) { $prototype_sent->voter_id = $voter->getVoterId(); $prototype_sent->prototype_id = $prototype->id; $prototype_sent->insert(); + } else { + $prototype_sent->fetch(); + } + if ($format == 'alt_image') { + $prototype_sent->viewed_alt = 1; + $prototype_sent->update(); } } } \ No newline at end of file