upPropelLockTableBehaviorPlugin - 1.0.0

The upPropelLockTableBehaviorPlugin add methods on Propel objects to set locks.

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 Releases Changelog Contribute
upPropelLockTableBehaviorPlugin 1.0.0stable for sf 1.2 and Propel MIT
Plugin image
0
user
Sign-in
to change
your status

The upPropelLockTableBehaviorPlugin add methods on Propel objects to set locks.

upPropelLockTableBehaviorPlugin

Features

  • Any Propel object can be locked

Installation

  • Install the plugin :
php symfony plugin:install upPropelLockTableBehaviorPlugin
  • You must have a field into the session to identify an user

  • Enable the plugin for each Propel object you want. For example, at the end of lib/model/User.php, add this line :

sfPropelBehavior::add('User', array('locktable'=>array('session'=>'id')));
  • The session parameter is the name of the session field used to identify the user

Usage

Lock an object with the current user :

$object->lock();

Check if an object is locked :

$object->getLocks();

Remove every lock for an user :

upPropelLockTableBehavior::removeAllLocks($user_id);

You can use this plugin with the form framework, for example, by editing BaseFormPropel :

public function setup()
{
  $class = get_class($this->getObject());

  if ($class) {
    // Since getLocks is a dynamic method, we can't use
    // get_class_methods to check if it does exist.
    // Instead, we can use a try/catch.
    try {
      if ($this->getObject()->getLocks()) {
        foreach ($this->widgetSchema->getFields() as $field) {
          $field->setAttribute('disabled', true);
        }
      } else {
        $this->getObject()->lock();
      }
    } catch (sfException $e) {}
  }
}

Copyright

upPropelLockTableBehaviorPlugin has been developped by Leo Cacheux for Devoteam/Uperto. It has been released under the MIT license.

Developers

Name Status Email
gravatar Leo Cacheux lead moc.otrepu <<ta>> xuehcacl

License

Show source

Copyright (c) Devoteam/Uperto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.