poll Allows you to create custom polls for both anonymous and authenticated users to vote on.

  1. Requirements
  2. Configuration
  3. Usage
  4. Changes
  5. Resources

The Poll extension for the Yii framework allows you to create custom polls for both anonymous and authenticated users to vote on.

Features include:

  • Basic Gii-created CRUD functionality
  • Portlet to load on additional pages, which displays either the latest or a user-specified poll
  • Polls can be either open or closed to voting
  • IP restricted voting for anonymous users (enabled by default)
  • Authenticated users can cancel their votes on open polls
  • If IP restriction is enabled, you can also configure the ability for anonymous users to cancel their votes (disabled by default)
  • Users must vote on a poll in order to see the results (enabled by default)

Requirements

This has been tested with 1.1.8, but should work with any version.

You must also:

  • Setup a User active record with an integer ID returned by Yii::app()->user->id.*
  • Add an anonymous user in the database with ID 0 (and either set the User ID to default to 0 in the database, or in your UserIdentity file)

*An example of this type of setup is explained here: Building a Blog System using Yii

The next step is to install the database schema located in '/data/poll.sql', modifying the table prefixes as needed, as well as the foreign key constraint referencing the user's ID.

Configuration

return array(
   ...
   'import' => array(
     'application.modules.poll.models.*',
     'application.modules.poll.components.*',
   ),
   'modules' => array(
     'poll' => array(
       // Force users to vote before seeing results
       'forceVote' => TRUE,
       // Restrict anonymous votes by IP address,
       // otherwise it's tied only to user_id 
       'ipRestrict' => TRUE,
       // Allow guests to cancel their votes
       // if ipRestrict is enabled
       'allowGuestCancel' => FALSE,
     ),
   ),
);

Usage

The Poll extension has the basic Gii-created CRUD functionality, as well as a portlet to load elsewhere.

To load the latest poll:

$this->widget('EPoll');

To load a specific poll:

$this->widget('EPoll', array('poll_id' => 1));

Changes

February 9, 2012

  • 0.9.2b
    • Duplicate widget submission bug fix
  • 0.9.2
    • Added ability to export poll results
    • Rewrote URLs

October 18, 2011

  • 0.9.1b
    • Bug fixes, renamed controllers to lowercase for URL mapping
  • 0.9.1
    • Moved configuration from app to module

October 17, 2011

  • 0.9.0
    • Initial release

Resources

14 0
29 followers
2 978 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Matt Kelliher
Created on: Oct 17, 2011
Last updated: 12 years ago

Downloads

show all

Related Extensions