sfPropelActAsStarredBehaviorPlugin - 0.0.1

sfPropelActAsStarredBehaviorPlugin plugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Dependencies Releases Changelog Contribute
Show source | Show as Markdown

sfPropelActAsStarredBehaviorPlugin

Introduction

This behavior allows to star (or bookmark, like Gmail star) Propel objects per user.

Features

  • add/remove star(s) on an object (behaves as a switch button)
  • multi-models selection
  • ajax and non ajax support, unobstrusive javascript (use jquery if you do not have it)
  • helper available link_to_star()
  • configuration in app.yml

Requirements

  • starrable objects must have a primary key
  • user authentication system, by default use sfGuardUser plugin

Installation

  • go to your project's root

  • Install the plugin:

     ./symfony plugin-install http://plugins.symfony-project.com/sfPropelActAsStarredBehaviorPlugin
    
  • if not already done, enabled behaviors in config/propel.ini:

     propel.builder.addBehaviors = true
    
  • edit the classes that you want to make taggable. For instance, for lib/model/Article.php:

    [php] save(); $article->setStar(); ### Un-starring an object [php] clearStar(); ### Helper use [php]

API

The behavior implement the following methods: * setStar() - Adds a star to the object for the current user. * isStarred() - Returns true/false if the object is/is not starred for the current user. * countStars() - Returns the total number of stars on the object (define the popularity of the object). * clearStar() - Removes a star from the object for the current user.

  • StarPeer::getUserStars($user_id = null,$options = array()) -
  • StarPeer::countUserStars($user_id = null,$options = array()) -
  • sfPropelActAsStarredBehaviorToolkit::isStarred(model) -
  • sfPropelActAsStarredBehaviorToolkit::retrieveStarredObject(model,model_id) -

License and credits

This plugin has been developed by Gerald Estadieu and is licensed under the MIT license.

To do

  • unit tests
  • allow propel criteria to be added
  • add more static method to retrieve stars
  • cookie to allow non-authenticated user to use stars (is it a good idea?)

Changelog

version 0.1 - 2008-02-18

Initial public release.