# Polls Plugin

Polls used to be an integral part of the Geeklog core code, but have been moved to a plugin as of Geeklog 1.4.0.

## Configuration

The Polls plugin's configuration can be changed from the Configuration admin panel:

### General Polls Settings

Variable | Default Value | Description
--- | --- | ---
pollsloginrequired | 0 | When set to 1, only registered users can access the list of recent polls. Please note that `$_CONF['loginrequired']` in Geeklog's main configuration takes precedence over this setting. So when `'loginrequired'` is set to 1, anonymous users can not access the recent polls even when `'pollsloginrequired'` is set to 0.
hidepollsmenu | 0 | Whether to hide the "Polls" entry from Geeklog's menu bar (when set to 1) or to show it (when set to 0).
maxquestions | 10 | Maximum number of questions in a poll.
maxanswers | 10 | Maximum number of options per question.
answerorder | submitorder | Sort answers by the number of results ('voteorder') or keep the order in which they were entered ('submitorder').
pollcookietime | 86400 | Number of seconds to set a poll answer cookie to time out on.
polladdresstime | 604800 | Number of seconds to set a poll answer IP address to time out on.
delete_polls | 0 | Defines what to do when a user is deleted that is the owner of a poll. When set to 0, all polls owned by the deleted user will be assigned to a user of the "Root" group (e.g. the site admin). When set to 1, the polls are deleted, including all the comments posted on that poll.

aftersave

'list'

Which page to go to after a poll has been saved:

- 'item': display the poll
- 'list': show admin's list of polls (default)
- 'plugin': display the public list of polls
- 'home': display the site's homepage
- 'admin': go to the "Admin Home" page, i.e. Command & Control

meta_tags | false | Whether to include the meta tags of the poll when it is displayed.
likes_polls | 1 | Disable (0) the Likes System for polls or enable it with Likes and Dislikes (1) or just Likes (2). The Geeklog config option likes_enabled also must be set if you wish to enable the Likes System for polls.

### What's New Block

Variable | Default Value | Description
--- | --- | ---
newpollsinterval | 1209600 | Polls are "new" if they are this many seconds old.
hidenewpolls | 'hide' | Set to 'modified' date or 'created' date to display new polls in the What's New block.
title_trim_length | 20 | Max. length of the title of items listed in the What's New block.

### Default Permissions

Variable | Default Value | Description
--- | --- | ---
default_permissions[0] | Read-Write | Default permission for Owner of new poll.
default_permissions[1] | Read-Only | Default permission for Group of new poll.
default_permissions[2] | Read-Only | Default permission for all logged in users of new poll.
default_permissions[3] | Read-Only | Default permission for all anonymous visitors of new poll.

### Autotag Usage Permissions

Variable | Default Value | Description
--- | --- | ---
autotag_permissions_poll[0] | Use | Usage permission for autotag by autotag Owner (Default Root User).
autotag_permissions_poll[1] | Use | Usage permission for autotag by Polls Admin Group.
autotag_permissions_poll[2] | Use | Usage permission for autotag by all logged in users.
autotag_permissions_poll[3] | Use | Usage permission for autotag by anonymous users.
autotag_permissions_poll_vote[0] | Use | Usage permission for autotag by autotag Owner (Default Root User).
autotag_permissions_poll_vote[1] | Use | Usage permission for autotag by Polls Admin Group.
autotag_permissions_poll_vote[2] | No Access | Usage permission for autotag by all logged in users.
autotag_permissions_poll_vote[3] | No Access | Usage permission for autotag by anonymous users.
autotag_permissions_poll_result[0] | Use | Usage permission for autotag by autotag Owner (Default Root User).
autotag_permissions_poll_result[1] | Use | Usage permission for autotag by Polls Admin Group.
autotag_permissions_poll_result[2] | No Access | Usage permission for autotag by all logged in users.
autotag_permissions_poll_result[3] | No Access | Usage permission for autotag by anonymous users.

### Poll Block

Variable | Default Value | Description
--- | --- | ---
block_enable | true | Enable block.
block_isleft | 0 | Whether to display the block on the left (when set to 1) or right (when set to 0).
block_order | 100 | The order the block appears in the column.
block_topic_option | 'all' | Set to 'All' for block to appear on all pages. Set to 'Homepage Only' for block to appear on just the homepage. Set to 'Selected Topics' for block to appear only in Topics selected in the Topic setting.
block_topic |  | The topics the block will appear for if the Topic Options is set to 'Select Topics'.
block_group_id | Polls Admin | The group used by permissions.
block_permissions[0] | Read-Only | View permission for dynamic block by block Owner (Root User).
block_permissions[1] | Read-Only | View permission for dynamic block by assigned Admin Group (see config option block_group_id).
block_permissions[2] | Read-Only | View permission for dynamic block by all logged in users.
block_permissions[3] | Read-Only | View permission for dynamic block by anonymous users.

## How do the polls work?

(Taken from the Geeklog FAQ)

In order to prevent manipulation of polls (or at least make it harder), Geeklog does two things when you vote:

1. It stores a cookie
2. It stores your IP address

Both the cookie and the IP are valid for a certain amount of time (see below) and during that time, you can't vote again on the same poll.

The amount of time your cookie and IP are stored can be changed in the polls plugin's configuration (see above):

    $_PO_CONF['pollcookietime']    = 86400;
    $_PO_CONF['polladdresstime']   = 604800;

Both times are in seconds, i.e. the cookie is valid for 24 hours and the IP is stored for a week.

In setups where more than one person uses the same computer or the same IP address, you can set one (or both) of them to 1.

Please keep in mind that any poll can be manipulated, so you shouldn't take the results too seriously.

## Autotags

The Polls Plugin provides 3 autotags, `[poll:]`, `[poll_result:]`, and `[poll_vote:]`.

- The `[poll:]` autotag will provide a link to a poll. Simply add the poll's ID after the colon. By default, the poll's title will be used as the link text. You can provide your own link text after the poll ID (but before the closing bracket).
- The `[poll_result:]` autotag lets you embed the results from a poll in a story (or anywhere else where autotags are allowed).
- The `[poll_vote:]` autotag can be used to embed a poll into an article (or anywhere else where autotags are allowed) so that users don't need to go to the polls block to vote.