Diem + CKEditor + KCFinder + session

Si vous utilisez Diem.
Et que vous utilisez CKEditor pour l’édition WYSIWYG.
Et que vous avez ajouté KCFinder pour la gestion des fichiers (images, pdf, upload divers).
Alors pour configurer une authentification automatique sur KCFinder via l’authentification dans le projet Diem :

  1. ajouter dans kcfinder/core/uploader.php, avant le session_start() : session_name(‘symfony’);
  2. créer une action dmUserActions (cf documentation Diem) avec dans la méthode redirectSignedInUser les 2 lignes suivantes :
  • $_SESSION[‘KCFINDER’] = array();
  • $_SESSION[‘KCFINDER’][‘disabled’] = false;

Add simple behavior with Propel / Symfony

Add your behavior in a new file in :

lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/behavior/SfPropelBehaviorMyBehavior.php

Edit SfPropelBehaviorSymfony.php and add a loader for your new Behavior. Example :

public function modifyDatabase()
{
foreach ($this->getDatabase()->getTables() as $table)
{
$behaviors = $table->getBehaviors();

[…………]

// MyBehavior
if (!isset($behaviors[‘symfony_mybehavior’]))
{

$class = Propel::importClass($this->getBuildProperty(‘propel.behavior.symfony_mybehavior.class’));
$behavior = new $class();
$behavior->setName(‘symfony_mybehavior’);
$behavior->setParameters($parameters);
$table->addBehavior($behavior);

}

Edit config/propel.ini and add a new line with your new behavior

Rebuild your full models and enjoy !

sfDataGridPlugin : filter onkeydown issue

If you encounter an issue with onkeydown event on filter fields, there is a bug in sfDataGridPlugin.

Edit sfDAtaGridFormatterPropel.class.php and add the missing “&” in url building :

$url = $object->_get(‘moduleAction’) . ‘?’ . $this->P_PAGE . ‘=1&‘ . $suffix . ‘&’ . $this->P_SORT . ‘=’ . $object->_get(‘sortBy’) . ‘&’ . $this->P_ORDER . ‘=’ . $object->_get(‘sortOrder’);

How to pass request data to symfony form

Use option during sfForm construction.

for example in your action:

$form = new myForm(null, 
                   array('attributeFoo' => 
                         $this->getUser()->getAttribute('attributeFoo'));

and then retrieve the value inside the form class:

$this->getOption(‘attributeFoo’);

More information here : http://stackoverflow.com/questions/627585/how-to-get-user-data-in-form-in-symfony-1-2#2920785

Symfony ProjectConfiguration.class.php lib path

In need to tweak config/ProjectConfiguration.class.php file in order to import a project to a sandbox symfony workspace.

The path to sfCoreAutoload was never good between web and cli symfony.

Here is the trick :

if (!@include_once ‘./lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php’) {
include_once ‘../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php’;
}
sfCoreAutoload::register();

Bug dans admin sfGuardUser

Un bug semble s’être glissé dans le formulaire d’administration du plugin symfony sfGuardUser.

“The item has not been saved due to some errors.” (when you try to save the form)

The fix :

It would seem the cause of the issue is on line 44 of the sfGuardUserAdmin form class.

Removing that solves the problem.