Author: david
Date: Tue Sep  8 15:08:10 2009
New Revision: 3195

Log:
Add ACL i18n tables. --force

Added:
   trunk/plugins/qbAclPlugin/lib/model/QubitAclActionI18n.php   (contents, 
props changed)
   trunk/plugins/qbAclPlugin/lib/model/QubitAclGroupI18n.php   (contents, props 
changed)
   trunk/plugins/qbAclPlugin/lib/model/map/AclActionI18nMapBuilder.php   
(contents, props changed)
   trunk/plugins/qbAclPlugin/lib/model/map/AclGroupI18nMapBuilder.php   
(contents, props changed)
   trunk/plugins/qbAclPlugin/lib/model/om/BaseAclActionI18n.php   (contents, 
props changed)
   trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroupI18n.php   (contents, 
props changed)
Modified:
   trunk/data/sql/plugins.qbAclPlugin.lib.model.schema.sql
   trunk/plugins/qbAclPlugin/config/schema.yml
   trunk/plugins/qbAclPlugin/lib/model/map/AclActionMapBuilder.php
   trunk/plugins/qbAclPlugin/lib/model/map/AclGroupMapBuilder.php
   trunk/plugins/qbAclPlugin/lib/model/om/BaseAclAction.php
   trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php

Modified: trunk/data/sql/plugins.qbAclPlugin.lib.model.schema.sql
==============================================================================
--- trunk/data/sql/plugins.qbAclPlugin.lib.model.schema.sql     Tue Sep  8 
14:51:55 2009        (r3194)
+++ trunk/data/sql/plugins.qbAclPlugin.lib.model.schema.sql     Tue Sep  8 
15:08:10 2009        (r3195)
@@ -13,10 +13,29 @@
 CREATE TABLE `q_acl_action`
 (
        `id` INTEGER  NOT NULL AUTO_INCREMENT,
+       `source_culture` VARCHAR(7)  NOT NULL,
+       PRIMARY KEY (`id`)
+)Type=InnoDB;
+
+#-----------------------------------------------------------------------------
+#-- q_acl_action_i18n
+#-----------------------------------------------------------------------------
+
+DROP TABLE IF EXISTS `q_acl_action_i18n`;
+
+
+CREATE TABLE `q_acl_action_i18n`
+(
        `name` VARCHAR(255)  NOT NULL,
        `description` TEXT,
-       PRIMARY KEY (`id`),
-       UNIQUE KEY `q_acl_action_U_1` (`name`)
+       `id` INTEGER  NOT NULL,
+       `culture` VARCHAR(7)  NOT NULL,
+       PRIMARY KEY (`id`,`culture`),
+       UNIQUE KEY `q_acl_action_i18n_U_1` (`name`),
+       CONSTRAINT `q_acl_action_i18n_FK_1`
+               FOREIGN KEY (`id`)
+               REFERENCES `q_acl_action` (`id`)
+               ON DELETE CASCADE
 )Type=InnoDB;
 
 #-----------------------------------------------------------------------------
@@ -30,10 +49,10 @@
 (
        `id` INTEGER  NOT NULL AUTO_INCREMENT,
        `parent_id` INTEGER,
-       `name` VARCHAR(255)  NOT NULL,
-       `description` TEXT,
+       `lft` INTEGER  NOT NULL,
+       `rgt` INTEGER  NOT NULL,
+       `source_culture` VARCHAR(7)  NOT NULL,
        PRIMARY KEY (`id`),
-       UNIQUE KEY `q_acl_group_U_1` (`name`),
        INDEX `q_acl_group_FI_1` (`parent_id`),
        CONSTRAINT `q_acl_group_FK_1`
                FOREIGN KEY (`parent_id`)
@@ -42,6 +61,27 @@
 )Type=InnoDB;
 
 #-----------------------------------------------------------------------------
+#-- q_acl_group_i18n
+#-----------------------------------------------------------------------------
+
+DROP TABLE IF EXISTS `q_acl_group_i18n`;
+
+
+CREATE TABLE `q_acl_group_i18n`
+(
+       `name` VARCHAR(255)  NOT NULL,
+       `description` TEXT,
+       `id` INTEGER  NOT NULL,
+       `culture` VARCHAR(7)  NOT NULL,
+       PRIMARY KEY (`id`,`culture`),
+       UNIQUE KEY `q_acl_group_i18n_U_1` (`name`),
+       CONSTRAINT `q_acl_group_i18n_FK_1`
+               FOREIGN KEY (`id`)
+               REFERENCES `q_acl_group` (`id`)
+               ON DELETE CASCADE
+)Type=InnoDB;
+
+#-----------------------------------------------------------------------------
 #-- q_acl_permission
 #-----------------------------------------------------------------------------
 

Modified: trunk/plugins/qbAclPlugin/config/schema.yml
==============================================================================
--- trunk/plugins/qbAclPlugin/config/schema.yml Tue Sep  8 14:51:55 2009        
(r3194)
+++ trunk/plugins/qbAclPlugin/config/schema.yml Tue Sep  8 15:08:10 2009        
(r3195)
@@ -4,6 +4,9 @@
   acl_action:
     _attributes:    { phpName: aclAction }
     id:             ~
+    
+  acl_action_i18n:
+    _attributes:    { phpName: aclActionI18n }
     name:           { type: varchar, size: 255, required: true, index: unique }
     description:    { type: longvarchar }
 
@@ -11,6 +14,11 @@
     _attributes:    { phpName: aclGroup }
     id:             ~
     parent_id:      { type: integer, foreignTable: acl_group, 
foreignReference: id, onDelete: cascade }
+    lft: { type: integer, required: true, nestedSetLeftKey: true }
+    rgt: { type: integer, required: true, nestedSetRightKey: true }
+    
+  acl_group_i18n:
+    _attributes:    { phpName: aclGroupI18n }
     name:           { type: varchar, size: 255, required: true, index: unique }
     description:    { type: longvarchar }
 

Added: trunk/plugins/qbAclPlugin/lib/model/QubitAclActionI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/plugins/qbAclPlugin/lib/model/QubitAclActionI18n.php  Tue Sep  8 
15:08:10 2009        (r3195)
@@ -0,0 +1,5 @@
+<?php
+
+class QubitAclActionI18n extends BaseAclActionI18n
+{
+}

Added: trunk/plugins/qbAclPlugin/lib/model/QubitAclGroupI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/plugins/qbAclPlugin/lib/model/QubitAclGroupI18n.php   Tue Sep  8 
15:08:10 2009        (r3195)
@@ -0,0 +1,5 @@
+<?php
+
+class QubitAclGroupI18n extends BaseAclGroupI18n
+{
+}

Added: trunk/plugins/qbAclPlugin/lib/model/map/AclActionI18nMapBuilder.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/plugins/qbAclPlugin/lib/model/map/AclActionI18nMapBuilder.php Tue Sep 
 8 15:08:10 2009        (r3195)
@@ -0,0 +1,45 @@
+<?php
+
+
+
+class AclActionI18nMapBuilder implements MapBuilder {
+
+       
+       const CLASS_NAME = 
'plugins.qbAclPlugin.lib.model.map.AclActionI18nMapBuilder';
+
+       
+       private $dbMap;
+
+       
+       public function isBuilt()
+       {
+               return ($this->dbMap !== null);
+       }
+
+       
+       public function getDatabaseMap()
+       {
+               return $this->dbMap;
+       }
+
+       
+       public function doBuild()
+       {
+               $this->dbMap = 
Propel::getDatabaseMap(QubitAclActionI18n::DATABASE_NAME);
+
+               $tMap = $this->dbMap->addTable(QubitAclActionI18n::TABLE_NAME);
+               $tMap->setPhpName('aclActionI18n');
+               $tMap->setClassname('QubitAclActionI18n');
+
+               $tMap->setUseIdGenerator(false);
+
+               $tMap->addColumn('NAME', 'name', 'VARCHAR', true, 255);
+
+               $tMap->addColumn('DESCRIPTION', 'description', 'LONGVARCHAR', 
false, null);
+
+               $tMap->addForeignPrimaryKey('ID', 'id', 'INTEGER' , 
'q_acl_action', 'ID', true, null);
+
+               $tMap->addPrimaryKey('CULTURE', 'culture', 'VARCHAR', true, 7);
+
+       } 
+} 
\ No newline at end of file

Modified: trunk/plugins/qbAclPlugin/lib/model/map/AclActionMapBuilder.php
==============================================================================
--- trunk/plugins/qbAclPlugin/lib/model/map/AclActionMapBuilder.php     Tue Sep 
 8 14:51:55 2009        (r3194)
+++ trunk/plugins/qbAclPlugin/lib/model/map/AclActionMapBuilder.php     Tue Sep 
 8 15:08:10 2009        (r3195)
@@ -35,9 +35,7 @@
 
                $tMap->addPrimaryKey('ID', 'id', 'INTEGER', true, null);
 
-               $tMap->addColumn('NAME', 'name', 'VARCHAR', true, 255);
-
-               $tMap->addColumn('DESCRIPTION', 'description', 'LONGVARCHAR', 
false, null);
+               $tMap->addColumn('SOURCE_CULTURE', 'sourceCulture', 'VARCHAR', 
true, 7);
 
        } 
 } 
\ No newline at end of file

Added: trunk/plugins/qbAclPlugin/lib/model/map/AclGroupI18nMapBuilder.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/plugins/qbAclPlugin/lib/model/map/AclGroupI18nMapBuilder.php  Tue Sep 
 8 15:08:10 2009        (r3195)
@@ -0,0 +1,45 @@
+<?php
+
+
+
+class AclGroupI18nMapBuilder implements MapBuilder {
+
+       
+       const CLASS_NAME = 
'plugins.qbAclPlugin.lib.model.map.AclGroupI18nMapBuilder';
+
+       
+       private $dbMap;
+
+       
+       public function isBuilt()
+       {
+               return ($this->dbMap !== null);
+       }
+
+       
+       public function getDatabaseMap()
+       {
+               return $this->dbMap;
+       }
+
+       
+       public function doBuild()
+       {
+               $this->dbMap = 
Propel::getDatabaseMap(QubitAclGroupI18n::DATABASE_NAME);
+
+               $tMap = $this->dbMap->addTable(QubitAclGroupI18n::TABLE_NAME);
+               $tMap->setPhpName('aclGroupI18n');
+               $tMap->setClassname('QubitAclGroupI18n');
+
+               $tMap->setUseIdGenerator(false);
+
+               $tMap->addColumn('NAME', 'name', 'VARCHAR', true, 255);
+
+               $tMap->addColumn('DESCRIPTION', 'description', 'LONGVARCHAR', 
false, null);
+
+               $tMap->addForeignPrimaryKey('ID', 'id', 'INTEGER' , 
'q_acl_group', 'ID', true, null);
+
+               $tMap->addPrimaryKey('CULTURE', 'culture', 'VARCHAR', true, 7);
+
+       } 
+} 
\ No newline at end of file

Modified: trunk/plugins/qbAclPlugin/lib/model/map/AclGroupMapBuilder.php
==============================================================================
--- trunk/plugins/qbAclPlugin/lib/model/map/AclGroupMapBuilder.php      Tue Sep 
 8 14:51:55 2009        (r3194)
+++ trunk/plugins/qbAclPlugin/lib/model/map/AclGroupMapBuilder.php      Tue Sep 
 8 15:08:10 2009        (r3195)
@@ -37,9 +37,11 @@
 
                $tMap->addForeignKey('PARENT_ID', 'parentId', 'INTEGER', 
'q_acl_group', 'ID', false, null);
 
-               $tMap->addColumn('NAME', 'name', 'VARCHAR', true, 255);
+               $tMap->addColumn('LFT', 'lft', 'INTEGER', true, null);
 
-               $tMap->addColumn('DESCRIPTION', 'description', 'LONGVARCHAR', 
false, null);
+               $tMap->addColumn('RGT', 'rgt', 'INTEGER', true, null);
+
+               $tMap->addColumn('SOURCE_CULTURE', 'sourceCulture', 'VARCHAR', 
true, 7);
 
        } 
 } 
\ No newline at end of file

Modified: trunk/plugins/qbAclPlugin/lib/model/om/BaseAclAction.php
==============================================================================
--- trunk/plugins/qbAclPlugin/lib/model/om/BaseAclAction.php    Tue Sep  8 
14:51:55 2009        (r3194)
+++ trunk/plugins/qbAclPlugin/lib/model/om/BaseAclAction.php    Tue Sep  8 
15:08:10 2009        (r3195)
@@ -8,14 +8,12 @@
     TABLE_NAME = 'q_acl_action',
 
     ID = 'q_acl_action.ID',
-    NAME = 'q_acl_action.NAME',
-    DESCRIPTION = 'q_acl_action.DESCRIPTION';
+    SOURCE_CULTURE = 'q_acl_action.SOURCE_CULTURE';
 
   public static function addSelectColumns(Criteria $criteria)
   {
     $criteria->addSelectColumn(QubitAclAction::ID);
-    $criteria->addSelectColumn(QubitAclAction::NAME);
-    $criteria->addSelectColumn(QubitAclAction::DESCRIPTION);
+    $criteria->addSelectColumn(QubitAclAction::SOURCE_CULTURE);
 
     return $criteria;
   }
@@ -150,11 +148,29 @@
       }
     }
 
+    if ('aclActionI18ns' == $name)
+    {
+      return true;
+    }
+
     if ('aclPermissions' == $name)
     {
       return true;
     }
 
+    try
+    {
+      if (!$value = 
call_user_func_array(array($this->getCurrentaclActionI18n($options), 
'__isset'), $args) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentaclActionI18n(array('sourceCulture' 
=> true) + $options), '__isset'), $args);
+      }
+
+      return $value;
+    }
+    catch (sfException $e)
+    {
+    }
+
     throw new sfException;
   }
 
@@ -196,6 +212,23 @@
       }
     }
 
+    if ('aclActionI18ns' == $name)
+    {
+      if (!isset($this->refFkValues['aclActionI18ns']))
+      {
+        if (!isset($this->id))
+        {
+          $this->refFkValues['aclActionI18ns'] = QubitQuery::create();
+        }
+        else
+        {
+          $this->refFkValues['aclActionI18ns'] = 
self::getaclActionI18nsById($this->id, array('self' => $this) + $options);
+        }
+      }
+
+      return $this->refFkValues['aclActionI18ns'];
+    }
+
     if ('aclPermissions' == $name)
     {
       if (!isset($this->refFkValues['aclPermissions']))
@@ -213,6 +246,19 @@
       return $this->refFkValues['aclPermissions'];
     }
 
+    try
+    {
+      if (1 > strlen($value = 
call_user_func_array(array($this->getCurrentaclActionI18n($options), '__get'), 
$args)) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentaclActionI18n(array('sourceCulture' 
=> true) + $options), '__get'), $args);
+      }
+
+      return $value;
+    }
+    catch (sfException $e)
+    {
+    }
+
     throw new sfException;
   }
 
@@ -254,6 +300,8 @@
       }
     }
 
+    call_user_func_array(array($this->getCurrentaclActionI18n($options), 
'__set'), $args);
+
     return $this;
   }
 
@@ -266,6 +314,14 @@
 
   public function __unset($name)
   {
+    $args = func_get_args();
+
+    $options = array();
+    if (1 < count($args))
+    {
+      $options = $args[1];
+    }
+
     $offset = 0;
     foreach ($this->tables as $table)
     {
@@ -285,6 +341,8 @@
       }
     }
 
+    call_user_func_array(array($this->getCurrentaclActionI18n($options), 
'__unset'), $args);
+
     return $this;
   }
 
@@ -354,6 +412,13 @@
     $this->new = false;
     $this->values = array();
 
+    foreach ($this->aclActionI18ns as $aclActionI18n)
+    {
+      $aclActionI18n->id = $this->id;
+
+      $affectedRows += $aclActionI18n->save($connection);
+    }
+
     return $affectedRows;
   }
 
@@ -485,6 +550,26 @@
                $this->setid($key);
        }
 
+  public static function addaclActionI18nsCriteriaById(Criteria $criteria, $id)
+  {
+    $criteria->add(QubitAclActionI18n::ID, $id);
+
+    return $criteria;
+  }
+
+  public static function getaclActionI18nsById($id, array $options = array())
+  {
+    $criteria = new Criteria;
+    self::addaclActionI18nsCriteriaById($criteria, $id);
+
+    return QubitAclActionI18n::get($criteria, $options);
+  }
+
+  public function addaclActionI18nsCriteria(Criteria $criteria)
+  {
+    return self::addaclActionI18nsCriteriaById($criteria, $this->id);
+  }
+
   public static function addaclPermissionsCriteriaById(Criteria $criteria, $id)
   {
     $criteria->add(QubitAclPermission::ACTION_ID, $id);
@@ -505,6 +590,27 @@
     return self::addaclPermissionsCriteriaById($criteria, $this->id);
   }
 
+  public function getCurrentaclActionI18n(array $options = array())
+  {
+    if (!empty($options['sourceCulture']))
+    {
+      $options['culture'] = $this->sourceCulture;
+    }
+
+    if (!isset($options['culture']))
+    {
+      $options['culture'] = sfPropel::getDefaultCulture();
+    }
+
+    $aclActionI18ns = $this->aclActionI18ns->indexBy('culture');
+    if (!isset($aclActionI18ns[$options['culture']]))
+    {
+      $aclActionI18ns[$options['culture']] = new QubitAclActionI18n;
+    }
+
+    return $aclActionI18ns[$options['culture']];
+  }
+
   public function __call($name, $args)
   {
     if ('get' == substr($name, 0, 3) || 'set' == substr($name, 0, 3))

Added: trunk/plugins/qbAclPlugin/lib/model/om/BaseAclActionI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/plugins/qbAclPlugin/lib/model/om/BaseAclActionI18n.php        Tue Sep 
 8 15:08:10 2009        (r3195)
@@ -0,0 +1,499 @@
+<?php
+
+abstract class BaseAclActionI18n implements ArrayAccess
+{
+  const
+    DATABASE_NAME = 'propel',
+
+    TABLE_NAME = 'q_acl_action_i18n',
+
+    NAME = 'q_acl_action_i18n.NAME',
+    DESCRIPTION = 'q_acl_action_i18n.DESCRIPTION',
+    ID = 'q_acl_action_i18n.ID',
+    CULTURE = 'q_acl_action_i18n.CULTURE';
+
+  public static function addSelectColumns(Criteria $criteria)
+  {
+    $criteria->addSelectColumn(QubitAclActionI18n::NAME);
+    $criteria->addSelectColumn(QubitAclActionI18n::DESCRIPTION);
+    $criteria->addSelectColumn(QubitAclActionI18n::ID);
+    $criteria->addSelectColumn(QubitAclActionI18n::CULTURE);
+
+    return $criteria;
+  }
+
+  protected static
+    $aclActionI18ns = array();
+
+  protected
+    $row = array();
+
+  public static function getFromRow(array $row)
+  {
+    if (!isset(self::$aclActionI18ns[$key = serialize(array((int) $row[2], 
(string) $row[3]))]))
+    {
+      $aclActionI18n = new QubitAclActionI18n;
+      $aclActionI18n->new = false;
+      $aclActionI18n->row = $row;
+
+      self::$aclActionI18ns[$key] = $aclActionI18n;
+    }
+
+    return self::$aclActionI18ns[$key];
+  }
+
+  public static function get(Criteria $criteria, array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitAclActionI18n::DATABASE_NAME);
+    }
+
+    self::addSelectColumns($criteria);
+
+    return QubitQuery::createFromCriteria($criteria, 'QubitAclActionI18n', 
$options);
+  }
+
+  public static function getAll(array $options = array())
+  {
+    return self::get(new Criteria, $options);
+  }
+
+  public static function getOne(Criteria $criteria, array $options = array())
+  {
+    $criteria->setLimit(1);
+
+    return self::get($criteria, $options)->__get(0, array('defaultValue' => 
null));
+  }
+
+  public static function getByIdAndCulture($id, $culture, array $options = 
array())
+  {
+    $criteria = new Criteria;
+    $criteria->add(QubitAclActionI18n::ID, $id);
+    $criteria->add(QubitAclActionI18n::CULTURE, $culture);
+
+    if (1 == count($query = self::get($criteria, $options)))
+    {
+      return $query[0];
+    }
+  }
+
+  public static function doDelete(Criteria $criteria, $connection = null)
+  {
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclActionI18n::DATABASE_NAME);
+    }
+
+    $affectedRows = 0;
+
+    $affectedRows += BasePeer::doDelete($criteria, $connection);
+
+    return $affectedRows;
+  }
+
+  protected
+    $tables = array();
+
+  public function __construct()
+  {
+    $this->tables[] = 
Propel::getDatabaseMap(QubitAclActionI18n::DATABASE_NAME)->getTable(QubitAclActionI18n::TABLE_NAME);
+  }
+
+  protected
+    $values = array(),
+    $refFkValues = array();
+
+  protected function rowOffsetGet($name, $offset, $options)
+  {
+    if (empty($options['clean']) && array_key_exists($name, $this->values))
+    {
+      return $this->values[$name];
+    }
+
+    if (!array_key_exists($offset, $this->row))
+    {
+      if ($this->new)
+      {
+        return;
+      }
+
+      $this->refresh();
+    }
+
+    return $this->row[$offset];
+  }
+
+  public function __isset($name)
+  {
+    $args = func_get_args();
+
+    $options = array();
+    if (1 < count($args))
+    {
+      $options = $args[1];
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          return null !== $this->rowOffsetGet($name, $offset, $options);
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          return null !== $this->rowOffsetGet($name.'Id', $offset, $options);
+        }
+
+        $offset++;
+      }
+    }
+
+    throw new sfException;
+  }
+
+  public function offsetExists($offset)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__isset'), $args);
+  }
+
+  public function __get($name)
+  {
+    $args = func_get_args();
+
+    $options = array();
+    if (1 < count($args))
+    {
+      $options = $args[1];
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          return $this->rowOffsetGet($name, $offset, $options);
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          $relatedTable = 
$column->getTable()->getDatabaseMap()->getTable($column->getRelatedTableName());
+
+          return call_user_func(array($relatedTable->getClassName(), 
'getBy'.ucfirst($relatedTable->getColumn($column->getRelatedColumnName())->getPhpName())),
 $this->rowOffsetGet($name.'Id', $offset, $options));
+        }
+
+        $offset++;
+      }
+    }
+
+    throw new sfException;
+  }
+
+  public function offsetGet($offset)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__get'), $args);
+  }
+
+  public function __set($name, $value)
+  {
+    $args = func_get_args();
+
+    $options = array();
+    if (2 < count($args))
+    {
+      $options = $args[2];
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          $this->values[$name] = $value;
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          $relatedTable = 
$column->getTable()->getDatabaseMap()->getTable($column->getRelatedTableName());
+
+          $this->values[$name.'Id'] = 
$value->__get($relatedTable->getColumn($column->getRelatedColumnName())->getPhpName(),
 $options);
+        }
+
+        $offset++;
+      }
+    }
+
+    return $this;
+  }
+
+  public function offsetSet($offset, $value)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__set'), $args);
+  }
+
+  public function __unset($name)
+  {
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          $this->values[$name] = null;
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          $this->values[$name.'Id'] = null;
+        }
+
+        $offset++;
+      }
+    }
+
+    return $this;
+  }
+
+  public function offsetUnset($offset)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__unset'), $args);
+  }
+
+  protected
+    $new = true;
+
+  protected
+    $deleted = false;
+
+  public function refresh(array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitAclActionI18n::DATABASE_NAME);
+    }
+
+    $criteria = new Criteria;
+    $criteria->add(QubitAclActionI18n::ID, $this->id);
+    $criteria->add(QubitAclActionI18n::CULTURE, $this->culture);
+
+    call_user_func(array(get_class($this), 'addSelectColumns'), $criteria);
+
+    $statement = BasePeer::doSelect($criteria, $options['connection']);
+    $this->row = $statement->fetch();
+
+    return $this;
+  }
+
+  public function save($connection = null)
+  {
+    if ($this->deleted)
+    {
+      throw new PropelException('You cannot save an object that has been 
deleted.');
+    }
+
+    $affectedRows = 0;
+
+    if ($this->new)
+    {
+      $affectedRows += $this->insert($connection);
+    }
+    else
+    {
+      $affectedRows += $this->update($connection);
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if (array_key_exists($column->getPhpName(), $this->values))
+        {
+          $this->row[$offset] = $this->values[$column->getPhpName()];
+        }
+
+        $offset++;
+      }
+    }
+
+    $this->new = false;
+    $this->values = array();
+
+    return $affectedRows;
+  }
+
+  protected function insert($connection = null)
+  {
+    $affectedRows = 0;
+
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclActionI18n::DATABASE_NAME);
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      $criteria = new Criteria;
+      foreach ($table->getColumns() as $column)
+      {
+        if (!array_key_exists($column->getPhpName(), $this->values))
+        {
+          if ('createdAt' == $column->getPhpName() || 'updatedAt' == 
$column->getPhpName())
+          {
+            $this->values[$column->getPhpName()] = new DateTime;
+          }
+
+          if ('sourceCulture' == $column->getPhpName())
+          {
+            $this->values['sourceCulture'] = sfPropel::getDefaultCulture();
+          }
+        }
+
+        if (array_key_exists($column->getPhpName(), $this->values))
+        {
+          $criteria->add($column->getFullyQualifiedName(), 
$this->values[$column->getPhpName()]);
+        }
+
+        $offset++;
+      }
+
+      if (null !== $id = BasePeer::doInsert($criteria, $connection))
+      {
+                if ($this->tables[0] == $table)
+        {
+          $columns = $table->getPrimaryKeyColumns();
+          $this->values[$columns[0]->getPhpName()] = $id;
+        }
+      }
+
+      $affectedRows += 1;
+    }
+
+    return $affectedRows;
+  }
+
+  protected function update($connection = null)
+  {
+    $affectedRows = 0;
+
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclActionI18n::DATABASE_NAME);
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      $criteria = new Criteria;
+      $selectCriteria = new Criteria;
+      foreach ($table->getColumns() as $column)
+      {
+        if (!array_key_exists($column->getPhpName(), $this->values))
+        {
+          if ('updatedAt' == $column->getPhpName())
+          {
+            $this->values['updatedAt'] = new DateTime;
+          }
+        }
+
+        if (array_key_exists($column->getPhpName(), $this->values))
+        {
+          $criteria->add($column->getFullyQualifiedName(), 
$this->values[$column->getPhpName()]);
+        }
+
+        if ($column->isPrimaryKey())
+        {
+          $selectCriteria->add($column->getFullyQualifiedName(), 
$this->row[$offset]);
+        }
+
+        $offset++;
+      }
+
+      if ($criteria->size() > 0)
+      {
+        $affectedRows += BasePeer::doUpdate($selectCriteria, $criteria, 
$connection);
+      }
+    }
+
+    return $affectedRows;
+  }
+
+  public function delete($connection = null)
+  {
+    if ($this->deleted)
+    {
+      throw new PropelException('This object has already been deleted.');
+    }
+
+    $affectedRows = 0;
+
+    $criteria = new Criteria;
+    $criteria->add(QubitAclActionI18n::ID, $this->id);
+    $criteria->add(QubitAclActionI18n::CULTURE, $this->culture);
+
+    $affectedRows += self::doDelete($criteria, $connection);
+
+    $this->deleted = true;
+
+    return $affectedRows;
+  }
+
+       
+       public function getPrimaryKey()
+       {
+               $pks = array();
+
+               $pks[0] = $this->getid();
+
+               $pks[1] = $this->getculture();
+
+               return $pks;
+       }
+
+       
+       public function setPrimaryKey($keys)
+       {
+
+               $this->setid($keys[0]);
+
+               $this->setculture($keys[1]);
+
+       }
+
+  public static function addJoinaclActionCriteria(Criteria $criteria)
+  {
+    $criteria->addJoin(QubitAclActionI18n::ID, QubitAclAction::ID);
+
+    return $criteria;
+  }
+
+  public function __call($name, $args)
+  {
+    if ('get' == substr($name, 0, 3) || 'set' == substr($name, 0, 3))
+    {
+      $args = array_merge(array(strtolower(substr($name, 3, 1)).substr($name, 
4)), $args);
+
+      return call_user_func_array(array($this, '__'.substr($name, 0, 3)), 
$args);
+    }
+
+    throw new sfException('Call to undefined method 
'.get_class($this).'::'.$name);
+  }
+}

Modified: trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php
==============================================================================
--- trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php     Tue Sep  8 
14:51:55 2009        (r3194)
+++ trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroup.php     Tue Sep  8 
15:08:10 2009        (r3195)
@@ -9,15 +9,17 @@
 
     ID = 'q_acl_group.ID',
     PARENT_ID = 'q_acl_group.PARENT_ID',
-    NAME = 'q_acl_group.NAME',
-    DESCRIPTION = 'q_acl_group.DESCRIPTION';
+    LFT = 'q_acl_group.LFT',
+    RGT = 'q_acl_group.RGT',
+    SOURCE_CULTURE = 'q_acl_group.SOURCE_CULTURE';
 
   public static function addSelectColumns(Criteria $criteria)
   {
     $criteria->addSelectColumn(QubitAclGroup::ID);
     $criteria->addSelectColumn(QubitAclGroup::PARENT_ID);
-    $criteria->addSelectColumn(QubitAclGroup::NAME);
-    $criteria->addSelectColumn(QubitAclGroup::DESCRIPTION);
+    $criteria->addSelectColumn(QubitAclGroup::LFT);
+    $criteria->addSelectColumn(QubitAclGroup::RGT);
+    $criteria->addSelectColumn(QubitAclGroup::SOURCE_CULTURE);
 
     return $criteria;
   }
@@ -91,6 +93,23 @@
     return $affectedRows;
   }
 
+  public static function addOrderByPreorder(Criteria $criteria, $order = 
Criteria::ASC)
+  {
+    if ($order == Criteria::DESC)
+    {
+      return $criteria->addDescendingOrderByColumn(QubitAclGroup::LFT);
+    }
+
+    return $criteria->addAscendingOrderByColumn(QubitAclGroup::LFT);
+  }
+
+  public static function addRootsCriteria(Criteria $criteria)
+  {
+    $criteria->add(QubitAclGroup::PARENT_ID);
+
+    return $criteria;
+  }
+
   protected
     $tables = array();
 
@@ -157,6 +176,11 @@
       return true;
     }
 
+    if ('aclGroupI18ns' == $name)
+    {
+      return true;
+    }
+
     if ('aclPermissions' == $name)
     {
       return true;
@@ -167,6 +191,29 @@
       return true;
     }
 
+    try
+    {
+      if (!$value = 
call_user_func_array(array($this->getCurrentaclGroupI18n($options), '__isset'), 
$args) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentaclGroupI18n(array('sourceCulture' 
=> true) + $options), '__isset'), $args);
+      }
+
+      return $value;
+    }
+    catch (sfException $e)
+    {
+    }
+
+    if ('ancestors' == $name)
+    {
+      return true;
+    }
+
+    if ('descendants' == $name)
+    {
+      return true;
+    }
+
     throw new sfException;
   }
 
@@ -225,6 +272,23 @@
       return $this->refFkValues['aclGroupsRelatedByparentId'];
     }
 
+    if ('aclGroupI18ns' == $name)
+    {
+      if (!isset($this->refFkValues['aclGroupI18ns']))
+      {
+        if (!isset($this->id))
+        {
+          $this->refFkValues['aclGroupI18ns'] = QubitQuery::create();
+        }
+        else
+        {
+          $this->refFkValues['aclGroupI18ns'] = 
self::getaclGroupI18nsById($this->id, array('self' => $this) + $options);
+        }
+      }
+
+      return $this->refFkValues['aclGroupI18ns'];
+    }
+
     if ('aclPermissions' == $name)
     {
       if (!isset($this->refFkValues['aclPermissions']))
@@ -259,6 +323,59 @@
       return $this->refFkValues['aclUserGroups'];
     }
 
+    try
+    {
+      if (1 > strlen($value = 
call_user_func_array(array($this->getCurrentaclGroupI18n($options), '__get'), 
$args)) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentaclGroupI18n(array('sourceCulture' 
=> true) + $options), '__get'), $args);
+      }
+
+      return $value;
+    }
+    catch (sfException $e)
+    {
+    }
+
+    if ('ancestors' == $name)
+    {
+      if (!isset($this->values['ancestors']))
+      {
+        if ($this->new)
+        {
+          $this->values['ancestors'] = QubitQuery::create(array('self' => 
$this) + $options);
+        }
+        else
+        {
+          $criteria = new Criteria;
+          $this->addAncestorsCriteria($criteria);
+          $this->addOrderByPreorder($criteria);
+          $this->values['ancestors'] = self::get($criteria, array('self' => 
$this) + $options);
+        }
+      }
+
+      return $this->values['ancestors'];
+    }
+
+    if ('descendants' == $name)
+    {
+      if (!isset($this->values['descendants']))
+      {
+        if ($this->new)
+        {
+          $this->values['descendants'] = QubitQuery::create(array('self' => 
$this) + $options);
+        }
+        else
+        {
+          $criteria = new Criteria;
+          $this->addDescendantsCriteria($criteria);
+          $this->addOrderByPreorder($criteria);
+          $this->values['descendants'] = self::get($criteria, array('self' => 
$this) + $options);
+        }
+      }
+
+      return $this->values['descendants'];
+    }
+
     throw new sfException;
   }
 
@@ -300,6 +417,8 @@
       }
     }
 
+    call_user_func_array(array($this->getCurrentaclGroupI18n($options), 
'__set'), $args);
+
     return $this;
   }
 
@@ -312,6 +431,14 @@
 
   public function __unset($name)
   {
+    $args = func_get_args();
+
+    $options = array();
+    if (1 < count($args))
+    {
+      $options = $args[1];
+    }
+
     $offset = 0;
     foreach ($this->tables as $table)
     {
@@ -331,6 +458,8 @@
       }
     }
 
+    call_user_func_array(array($this->getCurrentaclGroupI18n($options), 
'__unset'), $args);
+
     return $this;
   }
 
@@ -400,6 +529,13 @@
     $this->new = false;
     $this->values = array();
 
+    foreach ($this->aclGroupI18ns as $aclGroupI18n)
+    {
+      $aclGroupI18n->id = $this->id;
+
+      $affectedRows += $aclGroupI18n->save($connection);
+    }
+
     return $affectedRows;
   }
 
@@ -407,6 +543,8 @@
   {
     $affectedRows = 0;
 
+    $this->updateNestedSet($connection);
+
     if (!isset($connection))
     {
       $connection = 
QubitTransactionFilter::getConnection(QubitAclGroup::DATABASE_NAME);
@@ -458,6 +596,33 @@
   {
     $affectedRows = 0;
 
+    // Update nested set keys only if parent id has changed
+    if (isset($this->values['parentId']))
+    {
+      // Get the "original" parentId before any updates
+      $offset = 0; 
+      $originalParentId = null;
+      foreach ($this->tables as $table)
+      {
+        foreach ($table->getColumns() as $column)
+        {
+          if ('parentId' == $column->getPhpName())
+          {
+            $originalParentId = $this->row[$offset];
+            break;
+          }
+          $offset++;
+        }
+      }
+      
+      // If updated value of parentId is different then original value,
+      // update the nested set
+      if ($originalParentId != $this->values['parentId'])
+      {
+        $this->updateNestedSet($connection);
+      }
+    }
+
     if (!isset($connection))
     {
       $connection = 
QubitTransactionFilter::getConnection(QubitAclGroup::DATABASE_NAME);
@@ -509,6 +674,9 @@
 
     $affectedRows = 0;
 
+    $this->refresh(array('connection' => $connection));
+    $this->deleteFromNestedSet($connection);
+
     $criteria = new Criteria;
     $criteria->add(QubitAclGroup::ID, $this->id);
 
@@ -558,6 +726,26 @@
     return self::addaclGroupsRelatedByparentIdCriteriaById($criteria, 
$this->id);
   }
 
+  public static function addaclGroupI18nsCriteriaById(Criteria $criteria, $id)
+  {
+    $criteria->add(QubitAclGroupI18n::ID, $id);
+
+    return $criteria;
+  }
+
+  public static function getaclGroupI18nsById($id, array $options = array())
+  {
+    $criteria = new Criteria;
+    self::addaclGroupI18nsCriteriaById($criteria, $id);
+
+    return QubitAclGroupI18n::get($criteria, $options);
+  }
+
+  public function addaclGroupI18nsCriteria(Criteria $criteria)
+  {
+    return self::addaclGroupI18nsCriteriaById($criteria, $this->id);
+  }
+
   public static function addaclPermissionsCriteriaById(Criteria $criteria, $id)
   {
     $criteria->add(QubitAclPermission::GROUP_ID, $id);
@@ -598,6 +786,157 @@
     return self::addaclUserGroupsCriteriaById($criteria, $this->id);
   }
 
+  public function getCurrentaclGroupI18n(array $options = array())
+  {
+    if (!empty($options['sourceCulture']))
+    {
+      $options['culture'] = $this->sourceCulture;
+    }
+
+    if (!isset($options['culture']))
+    {
+      $options['culture'] = sfPropel::getDefaultCulture();
+    }
+
+    $aclGroupI18ns = $this->aclGroupI18ns->indexBy('culture');
+    if (!isset($aclGroupI18ns[$options['culture']]))
+    {
+      $aclGroupI18ns[$options['culture']] = new QubitAclGroupI18n;
+    }
+
+    return $aclGroupI18ns[$options['culture']];
+  }
+
+  public function addAncestorsCriteria(Criteria $criteria)
+  {
+    return $criteria->add(QubitAclGroup::LFT, $this->lft, 
Criteria::LESS_THAN)->add(QubitAclGroup::RGT, $this->rgt, 
Criteria::GREATER_THAN);
+  }
+
+  public function addDescendantsCriteria(Criteria $criteria)
+  {
+    return $criteria->add(QubitAclGroup::LFT, $this->lft, 
Criteria::GREATER_THAN)->add(QubitAclGroup::RGT, $this->rgt, 
Criteria::LESS_THAN);
+  }
+
+  protected function updateNestedSet($connection = null)
+  {
+unset($this->values['lft']);
+unset($this->values['rgt']);
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclGroup::DATABASE_NAME);
+    }
+
+    if (!isset($this->lft) || !isset($this->rgt))
+    {
+      $delta = 2;
+    }
+    else
+    {
+      $delta = $this->rgt - $this->lft + 1;
+    }
+
+    if (null === $parent = $this->__get('parent', array('connection' => 
$connection)))
+    {
+      $statement = $connection->prepare('
+        SELECT MAX('.QubitAclGroup::RGT.')
+        FROM '.QubitAclGroup::TABLE_NAME);
+      $statement->execute();
+      $row = $statement->fetch();
+      $max = $row[0];
+
+      if (!isset($this->lft) || !isset($this->rgt))
+      {
+        $this->lft = $max + 1;
+        $this->rgt = $max + 2;
+
+        return $this;
+      }
+
+      $shift = $max + 1 - $this->lft;
+    }
+    else
+    {
+      $parent->refresh(array('connection' => $connection));
+
+      if (isset($this->lft) && isset($this->rgt) && $this->lft <= $parent->lft 
&& $this->rgt >= $parent->rgt)
+      {
+        throw new PropelException('An object cannot be a descendant of 
itself.');
+      }
+
+      $statement = $connection->prepare('
+        UPDATE '.QubitAclGroup::TABLE_NAME.'
+        SET '.QubitAclGroup::LFT.' = '.QubitAclGroup::LFT.' + ?
+        WHERE '.QubitAclGroup::LFT.' >= ?');
+      $statement->execute(array($delta, $parent->rgt));
+
+      $statement = $connection->prepare('
+        UPDATE '.QubitAclGroup::TABLE_NAME.'
+        SET '.QubitAclGroup::RGT.' = '.QubitAclGroup::RGT.' + ?
+        WHERE '.QubitAclGroup::RGT.' >= ?');
+      $statement->execute(array($delta, $parent->rgt));
+
+      if (!isset($this->lft) || !isset($this->rgt))
+      {
+        $this->lft = $parent->rgt;
+        $this->rgt = $parent->rgt + 1;
+
+        return $this;
+      }
+
+      if ($this->lft > $parent->rgt)
+      {
+        $this->lft += $delta;
+        $this->rgt += $delta;
+      }
+
+      $shift = $parent->rgt - $this->lft;
+    }
+
+    $statement = $connection->prepare('
+      UPDATE '.QubitAclGroup::TABLE_NAME.'
+      SET '.QubitAclGroup::LFT.' = '.QubitAclGroup::LFT.' + ?, 
'.QubitAclGroup::RGT.' = '.QubitAclGroup::RGT.' + ?
+      WHERE '.QubitAclGroup::LFT.' >= ?
+      AND '.QubitAclGroup::RGT.' <= ?');
+    $statement->execute(array($shift, $shift, $this->lft, $this->rgt));
+
+    $this->deleteFromNestedSet($connection);
+
+    if ($shift > 0)
+    {
+      $this->lft -= $delta;
+      $this->rgt -= $delta;
+    }
+
+    $this->lft += $shift;
+    $this->rgt += $shift;
+
+    return $this;
+  }
+
+  protected function deleteFromNestedSet($connection = null)
+  {
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclGroup::DATABASE_NAME);
+    }
+
+    $delta = $this->rgt - $this->lft + 1;
+
+    $statement = $connection->prepare('
+      UPDATE '.QubitAclGroup::TABLE_NAME.'
+      SET '.QubitAclGroup::LFT.' = '.QubitAclGroup::LFT.' - ?
+      WHERE '.QubitAclGroup::LFT.' >= ?');
+    $statement->execute(array($delta, $this->rgt));
+
+    $statement = $connection->prepare('
+      UPDATE '.QubitAclGroup::TABLE_NAME.'
+      SET '.QubitAclGroup::RGT.' = '.QubitAclGroup::RGT.' - ?
+      WHERE '.QubitAclGroup::RGT.' >= ?');
+    $statement->execute(array($delta, $this->rgt));
+
+    return $this;
+  }
+
   public function __call($name, $args)
   {
     if ('get' == substr($name, 0, 3) || 'set' == substr($name, 0, 3))

Added: trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroupI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/plugins/qbAclPlugin/lib/model/om/BaseAclGroupI18n.php Tue Sep  8 
15:08:10 2009        (r3195)
@@ -0,0 +1,499 @@
+<?php
+
+abstract class BaseAclGroupI18n implements ArrayAccess
+{
+  const
+    DATABASE_NAME = 'propel',
+
+    TABLE_NAME = 'q_acl_group_i18n',
+
+    NAME = 'q_acl_group_i18n.NAME',
+    DESCRIPTION = 'q_acl_group_i18n.DESCRIPTION',
+    ID = 'q_acl_group_i18n.ID',
+    CULTURE = 'q_acl_group_i18n.CULTURE';
+
+  public static function addSelectColumns(Criteria $criteria)
+  {
+    $criteria->addSelectColumn(QubitAclGroupI18n::NAME);
+    $criteria->addSelectColumn(QubitAclGroupI18n::DESCRIPTION);
+    $criteria->addSelectColumn(QubitAclGroupI18n::ID);
+    $criteria->addSelectColumn(QubitAclGroupI18n::CULTURE);
+
+    return $criteria;
+  }
+
+  protected static
+    $aclGroupI18ns = array();
+
+  protected
+    $row = array();
+
+  public static function getFromRow(array $row)
+  {
+    if (!isset(self::$aclGroupI18ns[$key = serialize(array((int) $row[2], 
(string) $row[3]))]))
+    {
+      $aclGroupI18n = new QubitAclGroupI18n;
+      $aclGroupI18n->new = false;
+      $aclGroupI18n->row = $row;
+
+      self::$aclGroupI18ns[$key] = $aclGroupI18n;
+    }
+
+    return self::$aclGroupI18ns[$key];
+  }
+
+  public static function get(Criteria $criteria, array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitAclGroupI18n::DATABASE_NAME);
+    }
+
+    self::addSelectColumns($criteria);
+
+    return QubitQuery::createFromCriteria($criteria, 'QubitAclGroupI18n', 
$options);
+  }
+
+  public static function getAll(array $options = array())
+  {
+    return self::get(new Criteria, $options);
+  }
+
+  public static function getOne(Criteria $criteria, array $options = array())
+  {
+    $criteria->setLimit(1);
+
+    return self::get($criteria, $options)->__get(0, array('defaultValue' => 
null));
+  }
+
+  public static function getByIdAndCulture($id, $culture, array $options = 
array())
+  {
+    $criteria = new Criteria;
+    $criteria->add(QubitAclGroupI18n::ID, $id);
+    $criteria->add(QubitAclGroupI18n::CULTURE, $culture);
+
+    if (1 == count($query = self::get($criteria, $options)))
+    {
+      return $query[0];
+    }
+  }
+
+  public static function doDelete(Criteria $criteria, $connection = null)
+  {
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclGroupI18n::DATABASE_NAME);
+    }
+
+    $affectedRows = 0;
+
+    $affectedRows += BasePeer::doDelete($criteria, $connection);
+
+    return $affectedRows;
+  }
+
+  protected
+    $tables = array();
+
+  public function __construct()
+  {
+    $this->tables[] = 
Propel::getDatabaseMap(QubitAclGroupI18n::DATABASE_NAME)->getTable(QubitAclGroupI18n::TABLE_NAME);
+  }
+
+  protected
+    $values = array(),
+    $refFkValues = array();
+
+  protected function rowOffsetGet($name, $offset, $options)
+  {
+    if (empty($options['clean']) && array_key_exists($name, $this->values))
+    {
+      return $this->values[$name];
+    }
+
+    if (!array_key_exists($offset, $this->row))
+    {
+      if ($this->new)
+      {
+        return;
+      }
+
+      $this->refresh();
+    }
+
+    return $this->row[$offset];
+  }
+
+  public function __isset($name)
+  {
+    $args = func_get_args();
+
+    $options = array();
+    if (1 < count($args))
+    {
+      $options = $args[1];
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          return null !== $this->rowOffsetGet($name, $offset, $options);
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          return null !== $this->rowOffsetGet($name.'Id', $offset, $options);
+        }
+
+        $offset++;
+      }
+    }
+
+    throw new sfException;
+  }
+
+  public function offsetExists($offset)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__isset'), $args);
+  }
+
+  public function __get($name)
+  {
+    $args = func_get_args();
+
+    $options = array();
+    if (1 < count($args))
+    {
+      $options = $args[1];
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          return $this->rowOffsetGet($name, $offset, $options);
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          $relatedTable = 
$column->getTable()->getDatabaseMap()->getTable($column->getRelatedTableName());
+
+          return call_user_func(array($relatedTable->getClassName(), 
'getBy'.ucfirst($relatedTable->getColumn($column->getRelatedColumnName())->getPhpName())),
 $this->rowOffsetGet($name.'Id', $offset, $options));
+        }
+
+        $offset++;
+      }
+    }
+
+    throw new sfException;
+  }
+
+  public function offsetGet($offset)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__get'), $args);
+  }
+
+  public function __set($name, $value)
+  {
+    $args = func_get_args();
+
+    $options = array();
+    if (2 < count($args))
+    {
+      $options = $args[2];
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          $this->values[$name] = $value;
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          $relatedTable = 
$column->getTable()->getDatabaseMap()->getTable($column->getRelatedTableName());
+
+          $this->values[$name.'Id'] = 
$value->__get($relatedTable->getColumn($column->getRelatedColumnName())->getPhpName(),
 $options);
+        }
+
+        $offset++;
+      }
+    }
+
+    return $this;
+  }
+
+  public function offsetSet($offset, $value)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__set'), $args);
+  }
+
+  public function __unset($name)
+  {
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if ($name == $column->getPhpName())
+        {
+          $this->values[$name] = null;
+        }
+
+        if ($name.'Id' == $column->getPhpName())
+        {
+          $this->values[$name.'Id'] = null;
+        }
+
+        $offset++;
+      }
+    }
+
+    return $this;
+  }
+
+  public function offsetUnset($offset)
+  {
+    $args = func_get_args();
+
+    return call_user_func_array(array($this, '__unset'), $args);
+  }
+
+  protected
+    $new = true;
+
+  protected
+    $deleted = false;
+
+  public function refresh(array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitAclGroupI18n::DATABASE_NAME);
+    }
+
+    $criteria = new Criteria;
+    $criteria->add(QubitAclGroupI18n::ID, $this->id);
+    $criteria->add(QubitAclGroupI18n::CULTURE, $this->culture);
+
+    call_user_func(array(get_class($this), 'addSelectColumns'), $criteria);
+
+    $statement = BasePeer::doSelect($criteria, $options['connection']);
+    $this->row = $statement->fetch();
+
+    return $this;
+  }
+
+  public function save($connection = null)
+  {
+    if ($this->deleted)
+    {
+      throw new PropelException('You cannot save an object that has been 
deleted.');
+    }
+
+    $affectedRows = 0;
+
+    if ($this->new)
+    {
+      $affectedRows += $this->insert($connection);
+    }
+    else
+    {
+      $affectedRows += $this->update($connection);
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      foreach ($table->getColumns() as $column)
+      {
+        if (array_key_exists($column->getPhpName(), $this->values))
+        {
+          $this->row[$offset] = $this->values[$column->getPhpName()];
+        }
+
+        $offset++;
+      }
+    }
+
+    $this->new = false;
+    $this->values = array();
+
+    return $affectedRows;
+  }
+
+  protected function insert($connection = null)
+  {
+    $affectedRows = 0;
+
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclGroupI18n::DATABASE_NAME);
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      $criteria = new Criteria;
+      foreach ($table->getColumns() as $column)
+      {
+        if (!array_key_exists($column->getPhpName(), $this->values))
+        {
+          if ('createdAt' == $column->getPhpName() || 'updatedAt' == 
$column->getPhpName())
+          {
+            $this->values[$column->getPhpName()] = new DateTime;
+          }
+
+          if ('sourceCulture' == $column->getPhpName())
+          {
+            $this->values['sourceCulture'] = sfPropel::getDefaultCulture();
+          }
+        }
+
+        if (array_key_exists($column->getPhpName(), $this->values))
+        {
+          $criteria->add($column->getFullyQualifiedName(), 
$this->values[$column->getPhpName()]);
+        }
+
+        $offset++;
+      }
+
+      if (null !== $id = BasePeer::doInsert($criteria, $connection))
+      {
+                if ($this->tables[0] == $table)
+        {
+          $columns = $table->getPrimaryKeyColumns();
+          $this->values[$columns[0]->getPhpName()] = $id;
+        }
+      }
+
+      $affectedRows += 1;
+    }
+
+    return $affectedRows;
+  }
+
+  protected function update($connection = null)
+  {
+    $affectedRows = 0;
+
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitAclGroupI18n::DATABASE_NAME);
+    }
+
+    $offset = 0;
+    foreach ($this->tables as $table)
+    {
+      $criteria = new Criteria;
+      $selectCriteria = new Criteria;
+      foreach ($table->getColumns() as $column)
+      {
+        if (!array_key_exists($column->getPhpName(), $this->values))
+        {
+          if ('updatedAt' == $column->getPhpName())
+          {
+            $this->values['updatedAt'] = new DateTime;
+          }
+        }
+
+        if (array_key_exists($column->getPhpName(), $this->values))
+        {
+          $criteria->add($column->getFullyQualifiedName(), 
$this->values[$column->getPhpName()]);
+        }
+
+        if ($column->isPrimaryKey())
+        {
+          $selectCriteria->add($column->getFullyQualifiedName(), 
$this->row[$offset]);
+        }
+
+        $offset++;
+      }
+
+      if ($criteria->size() > 0)
+      {
+        $affectedRows += BasePeer::doUpdate($selectCriteria, $criteria, 
$connection);
+      }
+    }
+
+    return $affectedRows;
+  }
+
+  public function delete($connection = null)
+  {
+    if ($this->deleted)
+    {
+      throw new PropelException('This object has already been deleted.');
+    }
+
+    $affectedRows = 0;
+
+    $criteria = new Criteria;
+    $criteria->add(QubitAclGroupI18n::ID, $this->id);
+    $criteria->add(QubitAclGroupI18n::CULTURE, $this->culture);
+
+    $affectedRows += self::doDelete($criteria, $connection);
+
+    $this->deleted = true;
+
+    return $affectedRows;
+  }
+
+       
+       public function getPrimaryKey()
+       {
+               $pks = array();
+
+               $pks[0] = $this->getid();
+
+               $pks[1] = $this->getculture();
+
+               return $pks;
+       }
+
+       
+       public function setPrimaryKey($keys)
+       {
+
+               $this->setid($keys[0]);
+
+               $this->setculture($keys[1]);
+
+       }
+
+  public static function addJoinaclGroupCriteria(Criteria $criteria)
+  {
+    $criteria->addJoin(QubitAclGroupI18n::ID, QubitAclGroup::ID);
+
+    return $criteria;
+  }
+
+  public function __call($name, $args)
+  {
+    if ('get' == substr($name, 0, 3) || 'set' == substr($name, 0, 3))
+    {
+      $args = array_merge(array(strtolower(substr($name, 3, 1)).substr($name, 
4)), $args);
+
+      return call_user_func_array(array($this, '__'.substr($name, 0, 3)), 
$args);
+    }
+
+    throw new sfException('Call to undefined method 
'.get_class($this).'::'.$name);
+  }
+}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to