DROP TABLE IF EXISTS poll_manager_poll_comments;
CREATE TABLE poll_manager_poll_comments (
  comment_id int(11) NOT NULL auto_increment,
  poll_id int(11) default '0',
  comment_status char(1) default '0',
  customer_id int(11) NOT NULL default '0',
  date datetime default NULL,
  name varchar(60) NOT NULL default '',
  host_name varchar(60) default NULL,
  poll_comment text NOT NULL,
  language_id int(11) NOT NULL default '1',
  PRIMARY KEY  (comment_id)
) TYPE=MyISAM;

DROP TABLE IF EXISTS poll_manager_poll_check;
CREATE TABLE poll_manager_poll_check (
  ip varchar(20) NOT NULL default '',
  time varchar(14) NOT NULL default '',
  poll_id int(10) NOT NULL default '0'
) TYPE=MyISAM;

DROP TABLE IF EXISTS poll_manager_poll_config;
CREATE TABLE poll_manager_poll_config (
  configuration_id int(5) NOT NULL auto_increment,
  configuration_title varchar(64) NOT NULL default '',
  configuration_key varchar(64) NOT NULL default '',
  configuration_value varchar(255) NOT NULL default '',
  configuration_description varchar(255) NOT NULL default '',
  last_modified datetime default NULL,
  date_added datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (configuration_id)
) TYPE=MyISAM;

DROP TABLE IF EXISTS poll_manager_poll_data;
CREATE TABLE poll_manager_poll_data (
  poll_id int(11) NOT NULL default '0',
  poll_title varchar(255) NOT NULL default '',
  option_count int(11) NOT NULL default '0',
  vote_id int(11) NOT NULL default '0',
  language_id int(11) NOT NULL default '1'
) TYPE=MyISAM;

DROP TABLE IF EXISTS poll_manager_poll_desc;
CREATE TABLE poll_manager_poll_desc (
  poll_id int(11) NOT NULL auto_increment,
  poll_date_added datetime default NULL,
  poll_last_modified datetime NOT NULL default '0000-00-00 00:00:00',
  voters mediumint(9) NOT NULL default '0',
  poll_type char(1) NOT NULL default '0',
  poll_status char(1) NOT NULL default '0',
  poll_viewable char(1) NOT NULL default '1',
  category_id int(11) NOT NULL default '0',
  product_id int(11) NOT NULL default '0',
  PRIMARY KEY  (poll_id)
) TYPE=MyISAM;

SET @t4=0;
SELECT (@t4:=configuration_group_id) as t4 
FROM configuration_group
WHERE configuration_group_title= 'Poll Manager - Side Box';
DELETE FROM configuration WHERE configuration_group_id = @t4;
DELETE FROM configuration_group WHERE configuration_group_id = @t4;
        
INSERT INTO configuration_group VALUES ('', 'Poll Manager - Side Box', 'Poll Manager Side Box Settings', '1' , '0');
UPDATE configuration_group SET sort_order = last_insert_id() WHERE configuration_group_id = last_insert_id();
SET @t4=0;
SELECT (@t4:=configuration_group_id) as t4
FROM configuration_group
WHERE configuration_group_title= 'Poll Manager - Side Box';
INSERT INTO configuration VALUES ('', 'Display Poll', 'POLL_MANAGER_DISPLAY_POLL_HOW', '0', 'Decides how the poll shown in the side box is chosen.<br>0 = Random<br>1 = Latest<br>2 = Most Popular<br>3 = Specific Poll ID', @t4, 5, NULL, now(), NULL, 'zen_cfg_select_option(array(''0'', ''1'', ''2'', ''3''),');
INSERT INTO configuration VALUES ('', 'Poll ID', 'POLL_MANAGER_DISPLAY_POLL_ID', '', 'If you chose above to display a specific poll enter the pollid here', @t4, 10, NULL, now(), NULL, NULL);
INSERT INTO configuration VALUES ('', 'Display Other Polls Link', 'POLL_MANAGER_BOX_OTHER_POLLS_LINKS', 'true', 'Display other polls links<br>(in box title and under submit', @t4, 15, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''), ');
INSERT INTO configuration VALUES ('', 'Display Results Link', 'POLL_MANAGER_BOX_RESULT_LINK', 'true', 'Display poll result link', @t4, 20, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Display Votes Count', 'POLL_MANAGER_BOX_VOTES', 'true', 'Display Vote Count', @t4, 25, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Display Comments Count', 'POLL_MANAGER_BOX_COMMENTS', 'true', 'Display comments count', @t4, 30, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Poll Alignment', 'POLL_MANAGER_BOX_ALIGN', 'center', 'Set alignment for the sidebox', @t4, 35, NULL, now(), NULL, 'zen_cfg_select_option(array(''left'', ''center'', ''right''),');
INSERT INTO configuration VALUES ('', 'View Results', 'POLL_MANAGER_BOX_REDIRECT_RESULTS', 'true', 'View results page after voting', @t4, 40, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');

INSERT INTO configuration_group VALUES ('', 'Poll Manager - General Configuration', 'Poll Manager General Configuration Settings', '1' , '0');
UPDATE configuration_group SET sort_order = last_insert_id() WHERE configuration_group_id = last_insert_id();
SET @t4=0;
SELECT (@t4:=configuration_group_id) as t4
FROM configuration_group
WHERE configuration_group_title= 'Poll Manager - General Configuration';
INSERT INTO configuration VALUES ('', 'Allow User Multiple Votes In The Same Day', 'POLL_MANAGER_ALLOW_MULTIPLE_VOTES', 'false', 'Allow the person voting more than one vote on the same poll in a day', @t4, 5, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''), ');
INSERT INTO configuration VALUES ('', 'Allow Poll Comments', 'POLL_MANAGER_ALLOW_COMMENTS', 'true', 'Allow comments on polls', @t4, 10, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Show customers IP address', 'POLL_MANAGER_SHOW_IP_ADDRESS', 'true', 'Show customers IP address', @t4, 10, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Show customers name', 'POLL_MANAGER_SHOW_CUSTOMERS_NAME', 'true', 'Show customers name', @t4, 10, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Show customers date added', 'POLL_MANAGER_SHOW_DATE_ADDED', 'true', 'Show date added', @t4, 10, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Allow Unregistered Users Comment', 'POLL_MANAGER_UNREGISTERED_COMMENTS', 'true', 'Allow unregistered users comment on polls', @t4, 15, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Poll Comments Require Approval', 'POLL_MANAGER_COMMENT_APPROVE', 'false', 'Poll comments require approval', @t4, 32, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
INSERT INTO configuration VALUES ('', 'Number Of Poll Comments To Display', 'POLL_MANAGER_DISPLAY_POLL_COMMENTS', '10', 'Maximum number of comments to display on the poll information page', @t4, 35, NULL, now(), NULL, NULL);

INSERT INTO configuration_group VALUES ('', 'Poll Manager - Poll Listing', 'Poll Manager Poll Listing Settings', '1' , '0');
UPDATE configuration_group SET sort_order = last_insert_id() WHERE configuration_group_id = last_insert_id();
SET @t4=0;
SELECT (@t4:=configuration_group_id) as t4
FROM configuration_group
WHERE configuration_group_title= 'Poll Manager - Poll Listing';
INSERT INTO configuration VALUES ('', 'Display Private Polls To Unregistered Users', 'POLL_MANAGER_VIEW_PRIVATE', 'false', 'Display private polls to unregistered users', @t4, 5, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''), ');
INSERT INTO configuration VALUES ('', 'Display Closed Polls', 'POLL_MANAGER_VIEW_CLOSED', 'true', 'Display closed polls', @t4, 10, NULL, now(), NULL, 'zen_cfg_select_option(array(''true'', ''false''),');
