first commit
This commit is contained in:
38
plugins/sfGuardPlugin/lib/helper/sfGuardUserHelper.php
Normal file
38
plugins/sfGuardPlugin/lib/helper/sfGuardUserHelper.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
function sf_guard_user_admin_select_tag($name, $value, $params = array())
|
||||
{
|
||||
|
||||
$fc = stFunctionCache::getInstance('sfGuardUser');
|
||||
|
||||
$options = $fc->cacheCall(function() {
|
||||
$group = sfGuardGroupPeer::retrieveByName('admin');
|
||||
|
||||
$c = new Criteria();
|
||||
$c->addJoin(sfGuardUserPeer::ID, sfGuardUserGroupPeer::USER_ID, Criteria::LEFT_JOIN);
|
||||
$cc = $c->getNewCriterion(sfGuardUserPeer::IS_SUPER_ADMIN, true);
|
||||
$cc->addOr($c->getNewCriterion(sfGuardUserGroupPeer::GROUP_ID, $group->getId()));
|
||||
$c->add($cc);
|
||||
$c->addAscendingOrderByColumn(sfGuardUserPeer::USERNAME);
|
||||
|
||||
$results = array();
|
||||
|
||||
foreach (sfGuardUserPeer::doSelect($c) as $user)
|
||||
{
|
||||
if ($user->getIsSuperAdmin() || in_array('backend', $user->getAllPermissionNames()) && $user->hasModulePermission('stOrder.access') && $user->hasModulePermission('stOrder.modification'))
|
||||
{
|
||||
$results[$user->getId()] = $user->getUsername();
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}, array(), array('id' => 'sf_guard_user_admin_select_tag'));
|
||||
|
||||
if (isset($params['include_custom']) && is_array($params['include_custom']))
|
||||
{
|
||||
$options = array_replace($params['include_custom'], $options);
|
||||
unset($params['include_custom']);
|
||||
}
|
||||
|
||||
return select_tag($name, options_for_select($options, $value, $params));
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_group' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardGroupMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardGroupMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_group');
|
||||
$tMap->setPhpName('sfGuardGroup');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 48);
|
||||
|
||||
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 48);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardGroupMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_group_module_permission' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardGroupModulePermissionMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardGroupModulePermissionMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_group_module_permission');
|
||||
$tMap->setPhpName('sfGuardGroupModulePermission');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('ID', 'Id', 'int' , CreoleTypes::INTEGER, 'sf_guard_group', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('PERMISSIONS', 'Permissions', 'array', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardGroupModulePermissionMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_group_permission' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardGroupPermissionMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardGroupPermissionMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_group_permission');
|
||||
$tMap->setPhpName('sfGuardGroupPermission');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('GROUP_ID', 'GroupId', 'int' , CreoleTypes::INTEGER, 'sf_guard_group', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('PERMISSION_ID', 'PermissionId', 'int' , CreoleTypes::INTEGER, 'sf_guard_permission', 'ID', true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardGroupPermissionMapBuilder
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_permission' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardPermissionMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardPermissionMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_permission');
|
||||
$tMap->setPhpName('sfGuardPermission');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 48);
|
||||
|
||||
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 48);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardPermissionMapBuilder
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_remember_key' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardRememberKeyMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardRememberKeyMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_remember_key');
|
||||
$tMap->setPhpName('sfGuardRememberKey');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('USER_ID', 'UserId', 'int' , CreoleTypes::INTEGER, 'sf_guard_user', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('REMEMBER_KEY', 'RememberKey', 'string', CreoleTypes::VARCHAR, false, 32);
|
||||
|
||||
$tMap->addPrimaryKey('IP_ADDRESS', 'IpAddress', 'string', CreoleTypes::VARCHAR, true, 50);
|
||||
|
||||
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardRememberKeyMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_user_group' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardUserGroupMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardUserGroupMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_user_group');
|
||||
$tMap->setPhpName('sfGuardUserGroup');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('USER_ID', 'UserId', 'int' , CreoleTypes::INTEGER, 'sf_guard_user', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('GROUP_ID', 'GroupId', 'int' , CreoleTypes::INTEGER, 'sf_guard_group', 'ID', true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardUserGroupMapBuilder
|
||||
106
plugins/sfGuardPlugin/lib/model/map/sfGuardUserMapBuilder.php
Normal file
106
plugins/sfGuardPlugin/lib/model/map/sfGuardUserMapBuilder.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_user' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardUserMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardUserMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_user');
|
||||
$tMap->setPhpName('sfGuardUser');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('USERNAME', 'Username', 'string', CreoleTypes::VARCHAR, true, 128);
|
||||
|
||||
$tMap->addColumn('ALGORITHM', 'Algorithm', 'string', CreoleTypes::VARCHAR, true, 128);
|
||||
|
||||
$tMap->addColumn('SALT', 'Salt', 'string', CreoleTypes::VARCHAR, true, 128);
|
||||
|
||||
$tMap->addColumn('PASSWORD', 'Password', 'string', CreoleTypes::VARCHAR, true, 128);
|
||||
|
||||
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('LAST_LOGIN', 'LastLogin', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('LAST_PASSWORD_CHANGE', 'LastPasswordChange', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('IS_ACTIVE', 'IsActive', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('IS_SUPER_ADMIN', 'IsSuperAdmin', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('IS_CONFIRM', 'IsConfirm', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('IS_ADMIN_CONFIRM', 'IsAdminConfirm', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('HASH_CODE', 'HashCode', 'string', CreoleTypes::VARCHAR, false, 128);
|
||||
|
||||
$tMap->addColumn('LANGUAGE', 'Language', 'string', CreoleTypes::VARCHAR, false, 10);
|
||||
|
||||
$tMap->addColumn('EXTERNAL_ACCOUNT', 'ExternalAccount', 'string', CreoleTypes::VARCHAR, false, 128);
|
||||
|
||||
$tMap->addColumn('POINTS', 'Points', 'int', CreoleTypes::INTEGER, false, null);
|
||||
|
||||
$tMap->addColumn('POINTS_AVAILABLE', 'PointsAvailable', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('POINTS_RELEASE', 'PointsRelease', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('OPT_ALLEGRO_USER_ID', 'OptAllegroUserId', 'int', CreoleTypes::INTEGER, false, null);
|
||||
|
||||
$tMap->addColumn('WHOLESALE', 'Wholesale', 'string', CreoleTypes::CHAR, true, 1);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardUserMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_user_module_permission' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardUserModulePermissionMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardUserModulePermissionMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_user_module_permission');
|
||||
$tMap->setPhpName('sfGuardUserModulePermission');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('ID', 'Id', 'int' , CreoleTypes::INTEGER, 'sf_guard_user', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('PERMISSIONS', 'Permissions', 'array', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardUserModulePermissionMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'sf_guard_user_permission' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.map
|
||||
*/
|
||||
class sfGuardUserPermissionMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.sfGuardPlugin.lib.model.map.sfGuardUserPermissionMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('sf_guard_user_permission');
|
||||
$tMap->setPhpName('sfGuardUserPermission');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('USER_ID', 'UserId', 'int' , CreoleTypes::INTEGER, 'sf_guard_user', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('PERMISSION_ID', 'PermissionId', 'int' , CreoleTypes::INTEGER, 'sf_guard_permission', 'ID', true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // sfGuardUserPermissionMapBuilder
|
||||
1212
plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroup.php
Normal file
1212
plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroup.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,715 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'sf_guard_group_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardGroupModulePermission extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the permissions field.
|
||||
* @var array
|
||||
*/
|
||||
protected $permissions;
|
||||
|
||||
/**
|
||||
* @var sfGuardGroup
|
||||
*/
|
||||
protected $asfGuardGroup;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [permissions] column value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissions()
|
||||
{
|
||||
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = sfGuardGroupModulePermissionPeer::ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardGroup !== null && $this->asfGuardGroup->getId() !== $v) {
|
||||
$this->asfGuardGroup = null;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [permissions] column.
|
||||
*
|
||||
* @param array $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setPermissions($v)
|
||||
{
|
||||
|
||||
if ($this->permissions !== $v) {
|
||||
$this->permissions = $v;
|
||||
$this->modifiedColumns[] = sfGuardGroupModulePermissionPeer::PERMISSIONS;
|
||||
}
|
||||
|
||||
} // setPermissions()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupModulePermission.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupModulePermission.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->permissions = $rs->getString($startcol + 1) ? unserialize($rs->getString($startcol + 1)) : null;
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupModulePermission.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupModulePermission.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = sfGuardGroupModulePermissionPeer::NUM_COLUMNS - sfGuardGroupModulePermissionPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating sfGuardGroupModulePermission object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupModulePermission.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupModulePermission.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardGroupModulePermission:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermission:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardGroupModulePermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
sfGuardGroupModulePermissionPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupModulePermission.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupModulePermission.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardGroupModulePermission:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermission:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupModulePermission.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupModulePermission.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermission:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardGroupModulePermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupModulePermission.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupModulePermission.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermission:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardGroup !== null) {
|
||||
if ($this->asfGuardGroup->isModified()) {
|
||||
$affectedRows += $this->asfGuardGroup->save($con);
|
||||
}
|
||||
$this->setsfGuardGroup($this->asfGuardGroup);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = sfGuardGroupModulePermissionPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += sfGuardGroupModulePermissionPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardGroup !== null) {
|
||||
if (!$this->asfGuardGroup->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardGroup->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = sfGuardGroupModulePermissionPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardGroupModulePermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getPermissions();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardGroupModulePermissionPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getPermissions(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardGroupModulePermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setPermissions($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardGroupModulePermissionPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setPermissions($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardGroupModulePermissionPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(sfGuardGroupModulePermissionPeer::ID)) $criteria->add(sfGuardGroupModulePermissionPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(sfGuardGroupModulePermissionPeer::PERMISSIONS)) $criteria->add(sfGuardGroupModulePermissionPeer::PERMISSIONS, null !== $this->permissions && (is_array($this->permissions) || is_object($this->permissions)) ? serialize($this->permissions) : $this->permissions);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardGroupModulePermissionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardGroupModulePermissionPeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(sfGuardGroupModulePermissionPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of sfGuardGroupModulePermission (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setPermissions($this->permissions);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return sfGuardGroupModulePermission Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'sfGuardGroupModulePermissionPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardGroup object.
|
||||
*
|
||||
* @param sfGuardGroup $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardGroup($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setId(NULL);
|
||||
} else {
|
||||
$this->setId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardGroup = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardGroup object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardGroup The associated sfGuardGroup object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardGroup($con = null)
|
||||
{
|
||||
if ($this->asfGuardGroup === null && ($this->id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardGroup = sfGuardGroupPeer::retrieveByPK($this->id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardGroupPeer::retrieveByPK($this->id, $con);
|
||||
$obj->addsfGuardGroups($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardGroup;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'sfGuardGroupModulePermission.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BasesfGuardGroupModulePermission:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BasesfGuardGroupModulePermission::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BasesfGuardGroupModulePermission
|
||||
@@ -0,0 +1,839 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'sf_guard_group_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardGroupModulePermissionPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'sf_guard_group_module_permission';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.sfGuardPlugin.lib.model.sfGuardGroupModulePermission';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 2;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'sf_guard_group_module_permission.ID';
|
||||
|
||||
/** the column name for the PERMISSIONS field */
|
||||
const PERMISSIONS = 'sf_guard_group_module_permission.PERMISSIONS';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'Permissions', ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardGroupModulePermissionPeer::ID, sfGuardGroupModulePermissionPeer::PERMISSIONS, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'permissions', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Permissions' => 1, ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardGroupModulePermissionPeer::ID => 0, sfGuardGroupModulePermissionPeer::PERMISSIONS => 1, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'permissions' => 1, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardGroupModulePermissionMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = sfGuardGroupModulePermissionPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. sfGuardGroupModulePermissionPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(sfGuardGroupModulePermissionPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::PERMISSIONS);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('sfGuardGroupModulePermissionPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'sfGuardGroupModulePermissionPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(sf_guard_group_module_permission.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT sf_guard_group_module_permission.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = sfGuardGroupModulePermissionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardGroupModulePermission
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = sfGuardGroupModulePermissionPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardGroupModulePermission[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return sfGuardGroupModulePermissionPeer::populateObjects(sfGuardGroupModulePermissionPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
sfGuardGroupModulePermissionPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = sfGuardGroupModulePermissionPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related sfGuardGroup table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinsfGuardGroup(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(sfGuardGroupModulePermissionPeer::ID, sfGuardGroupPeer::ID);
|
||||
|
||||
$rs = sfGuardGroupModulePermissionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of sfGuardGroupModulePermission objects pre-filled with their sfGuardGroup objects.
|
||||
*
|
||||
* @return sfGuardGroupModulePermission[] Array of sfGuardGroupModulePermission objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinsfGuardGroup(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
sfGuardGroupModulePermissionPeer::addSelectColumns($c);
|
||||
|
||||
sfGuardGroupPeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(sfGuardGroupModulePermissionPeer::ID, sfGuardGroupPeer::ID);
|
||||
$rs = sfGuardGroupModulePermissionPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new sfGuardGroupModulePermission();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getId())
|
||||
{
|
||||
|
||||
$obj2 = new sfGuardGroup();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addsfGuardGroupModulePermission($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardGroupModulePermissionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(sfGuardGroupModulePermissionPeer::ID, sfGuardGroupPeer::ID);
|
||||
|
||||
$rs = sfGuardGroupModulePermissionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of sfGuardGroupModulePermission objects pre-filled with all related objects.
|
||||
*
|
||||
* @return sfGuardGroupModulePermission[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
sfGuardGroupModulePermissionPeer::addSelectColumns($c);
|
||||
$startcol2 = (sfGuardGroupModulePermissionPeer::NUM_COLUMNS - sfGuardGroupModulePermissionPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
sfGuardGroupPeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + sfGuardGroupPeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(sfGuardGroupModulePermissionPeer::ID, sfGuardGroupPeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = sfGuardGroupModulePermissionPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined sfGuardGroup rows
|
||||
|
||||
$omClass = sfGuardGroupPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getsfGuardGroup(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addsfGuardGroupModulePermission($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initsfGuardGroupModulePermissions();
|
||||
$obj2->addsfGuardGroupModulePermission($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return sfGuardGroupModulePermissionPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a sfGuardGroupModulePermission or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardGroupModulePermission object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermissionPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardGroupModulePermissionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from sfGuardGroupModulePermission object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermissionPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardGroupModulePermissionPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a sfGuardGroupModulePermission or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardGroupModulePermission object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermissionPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardGroupModulePermissionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(sfGuardGroupModulePermissionPeer::ID);
|
||||
$selectCriteria->add(sfGuardGroupModulePermissionPeer::ID, $criteria->remove(sfGuardGroupModulePermissionPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is sfGuardGroupModulePermission object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupModulePermissionPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardGroupModulePermissionPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the sf_guard_group_module_permission table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(sfGuardGroupModulePermissionPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a sfGuardGroupModulePermission or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardGroupModulePermission object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardGroupModulePermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof sfGuardGroupModulePermission) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(sfGuardGroupModulePermissionPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given sfGuardGroupModulePermission object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param sfGuardGroupModulePermission $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(sfGuardGroupModulePermission $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(sfGuardGroupModulePermissionPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(sfGuardGroupModulePermissionPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(sfGuardGroupModulePermissionPeer::DATABASE_NAME, sfGuardGroupModulePermissionPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = sfGuardGroupModulePermissionPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return sfGuardGroupModulePermission
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(sfGuardGroupModulePermissionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardGroupModulePermissionPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = sfGuardGroupModulePermissionPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return sfGuardGroupModulePermission[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(sfGuardGroupModulePermissionPeer::ID, $pks, Criteria::IN);
|
||||
$objs = sfGuardGroupModulePermissionPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BasesfGuardGroupModulePermissionPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BasesfGuardGroupModulePermissionPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardGroupModulePermissionMapBuilder');
|
||||
}
|
||||
694
plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroupPeer.php
Normal file
694
plugins/sfGuardPlugin/lib/model/om/BasesfGuardGroupPeer.php
Normal file
@@ -0,0 +1,694 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'sf_guard_group' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardGroupPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'sf_guard_group';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.sfGuardPlugin.lib.model.sfGuardGroup';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 3;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'sf_guard_group.ID';
|
||||
|
||||
/** the column name for the NAME field */
|
||||
const NAME = 'sf_guard_group.NAME';
|
||||
|
||||
/** the column name for the DESCRIPTION field */
|
||||
const DESCRIPTION = 'sf_guard_group.DESCRIPTION';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Description', ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardGroupPeer::ID, sfGuardGroupPeer::NAME, sfGuardGroupPeer::DESCRIPTION, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'description', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Description' => 2, ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardGroupPeer::ID => 0, sfGuardGroupPeer::NAME => 1, sfGuardGroupPeer::DESCRIPTION => 2, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'description' => 2, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardGroupMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = sfGuardGroupPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. sfGuardGroupPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(sfGuardGroupPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(sfGuardGroupPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardGroupPeer::NAME);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardGroupPeer::DESCRIPTION);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('sfGuardGroupPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'sfGuardGroupPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(sf_guard_group.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT sf_guard_group.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardGroupPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardGroupPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = sfGuardGroupPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardGroup
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = sfGuardGroupPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardGroup[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return sfGuardGroupPeer::populateObjects(sfGuardGroupPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
sfGuardGroupPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = sfGuardGroupPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return sfGuardGroupPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a sfGuardGroup or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardGroup object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardGroupPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from sfGuardGroup object
|
||||
}
|
||||
|
||||
$criteria->remove(sfGuardGroupPeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardGroupPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a sfGuardGroup or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardGroup object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardGroupPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(sfGuardGroupPeer::ID);
|
||||
$selectCriteria->add(sfGuardGroupPeer::ID, $criteria->remove(sfGuardGroupPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is sfGuardGroup object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardGroupPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the sf_guard_group table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += sfGuardGroupPeer::doOnDeleteCascade(new Criteria(), $con);
|
||||
$affectedRows += BasePeer::doDeleteAll(sfGuardGroupPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a sfGuardGroup or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardGroup object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof sfGuardGroup) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(sfGuardGroupPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += sfGuardGroupPeer::doOnDeleteCascade($criteria, $con);
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
|
||||
{
|
||||
// initialize var to track total num of affected rows
|
||||
$affectedRows = 0;
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = sfGuardGroupPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
|
||||
// delete related sfGuardGroupPermission objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardGroupPermissionPeer::GROUP_ID, $obj->getId());
|
||||
$affectedRows += sfGuardGroupPermissionPeer::doDelete($c, $con);
|
||||
|
||||
// delete related sfGuardUserGroup objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardUserGroupPeer::GROUP_ID, $obj->getId());
|
||||
$affectedRows += sfGuardUserGroupPeer::doDelete($c, $con);
|
||||
|
||||
// delete related sfGuardGroupModulePermission objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardGroupModulePermissionPeer::ID, $obj->getId());
|
||||
$affectedRows += sfGuardGroupModulePermissionPeer::doDelete($c, $con);
|
||||
}
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given sfGuardGroup object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param sfGuardGroup $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(sfGuardGroup $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(sfGuardGroupPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(sfGuardGroupPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(sfGuardGroupPeer::DATABASE_NAME, sfGuardGroupPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = sfGuardGroupPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return sfGuardGroup
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(sfGuardGroupPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardGroupPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = sfGuardGroupPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return sfGuardGroup[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(sfGuardGroupPeer::ID, $pks, Criteria::IN);
|
||||
$objs = sfGuardGroupPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BasesfGuardGroupPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BasesfGuardGroupPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardGroupMapBuilder');
|
||||
}
|
||||
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'sf_guard_group_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardGroupPermission extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the group_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $group_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the permission_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $permission_id;
|
||||
|
||||
/**
|
||||
* @var sfGuardGroup
|
||||
*/
|
||||
protected $asfGuardGroup;
|
||||
|
||||
/**
|
||||
* @var sfGuardPermission
|
||||
*/
|
||||
protected $asfGuardPermission;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [group_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getGroupId()
|
||||
{
|
||||
|
||||
return $this->group_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [permission_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPermissionId()
|
||||
{
|
||||
|
||||
return $this->permission_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [group_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setGroupId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->group_id !== $v) {
|
||||
$this->group_id = $v;
|
||||
$this->modifiedColumns[] = sfGuardGroupPermissionPeer::GROUP_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardGroup !== null && $this->asfGuardGroup->getId() !== $v) {
|
||||
$this->asfGuardGroup = null;
|
||||
}
|
||||
|
||||
} // setGroupId()
|
||||
|
||||
/**
|
||||
* Set the value of [permission_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setPermissionId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->permission_id !== $v) {
|
||||
$this->permission_id = $v;
|
||||
$this->modifiedColumns[] = sfGuardGroupPermissionPeer::PERMISSION_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardPermission !== null && $this->asfGuardPermission->getId() !== $v) {
|
||||
$this->asfGuardPermission = null;
|
||||
}
|
||||
|
||||
} // setPermissionId()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupPermission.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupPermission.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->group_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->permission_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupPermission.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupPermission.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = sfGuardGroupPermissionPeer::NUM_COLUMNS - sfGuardGroupPermissionPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating sfGuardGroupPermission object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupPermission.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupPermission.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardGroupPermission:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPermission:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardGroupPermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
sfGuardGroupPermissionPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupPermission.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupPermission.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardGroupPermission:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPermission:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupPermission.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupPermission.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPermission:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardGroupPermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardGroupPermission.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardGroupPermission.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardGroupPermission:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardGroup !== null) {
|
||||
if ($this->asfGuardGroup->isModified()) {
|
||||
$affectedRows += $this->asfGuardGroup->save($con);
|
||||
}
|
||||
$this->setsfGuardGroup($this->asfGuardGroup);
|
||||
}
|
||||
|
||||
if ($this->asfGuardPermission !== null) {
|
||||
if ($this->asfGuardPermission->isModified()) {
|
||||
$affectedRows += $this->asfGuardPermission->save($con);
|
||||
}
|
||||
$this->setsfGuardPermission($this->asfGuardPermission);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = sfGuardGroupPermissionPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += sfGuardGroupPermissionPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardGroup !== null) {
|
||||
if (!$this->asfGuardGroup->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardGroup->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->asfGuardPermission !== null) {
|
||||
if (!$this->asfGuardPermission->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardPermission->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = sfGuardGroupPermissionPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardGroupPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getGroupId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getPermissionId();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardGroupPermissionPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getGroupId(),
|
||||
$keys[1] => $this->getPermissionId(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardGroupPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setGroupId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setPermissionId($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardGroupPermissionPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setGroupId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setPermissionId($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardGroupPermissionPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(sfGuardGroupPermissionPeer::GROUP_ID)) $criteria->add(sfGuardGroupPermissionPeer::GROUP_ID, $this->group_id);
|
||||
if ($this->isColumnModified(sfGuardGroupPermissionPeer::PERMISSION_ID)) $criteria->add(sfGuardGroupPermissionPeer::PERMISSION_ID, $this->permission_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardGroupPermissionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardGroupPermissionPeer::GROUP_ID, $this->group_id);
|
||||
$criteria->add(sfGuardGroupPermissionPeer::PERMISSION_ID, $this->permission_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composite primary key for this object.
|
||||
* The array elements will be in same order as specified in XML.
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return array($this->getGroupId(), $this->getPermissionId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(sfGuardGroupPermissionPeer::translateFieldName('group_id', BasePeer::TYPE_FIELDNAME, $keyType), sfGuardGroupPermissionPeer::translateFieldName('permission_id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [composite] primary key.
|
||||
*
|
||||
* @param array $keys The elements of the composite key (order must match the order in XML file).
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($keys)
|
||||
{
|
||||
|
||||
$this->setGroupId($keys[0]);
|
||||
|
||||
$this->setPermissionId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of sfGuardGroupPermission (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setGroupId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setPermissionId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return sfGuardGroupPermission Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'sfGuardGroupPermissionPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardGroup object.
|
||||
*
|
||||
* @param sfGuardGroup $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardGroup($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setGroupId(NULL);
|
||||
} else {
|
||||
$this->setGroupId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardGroup = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardGroup object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardGroup The associated sfGuardGroup object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardGroup($con = null)
|
||||
{
|
||||
if ($this->asfGuardGroup === null && ($this->group_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardGroup = sfGuardGroupPeer::retrieveByPK($this->group_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardGroupPeer::retrieveByPK($this->group_id, $con);
|
||||
$obj->addsfGuardGroups($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardPermission object.
|
||||
*
|
||||
* @param sfGuardPermission $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardPermission($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setPermissionId(NULL);
|
||||
} else {
|
||||
$this->setPermissionId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardPermission = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardPermission object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardPermission The associated sfGuardPermission object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardPermission($con = null)
|
||||
{
|
||||
if ($this->asfGuardPermission === null && ($this->permission_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardPermission = sfGuardPermissionPeer::retrieveByPK($this->permission_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardPermissionPeer::retrieveByPK($this->permission_id, $con);
|
||||
$obj->addsfGuardPermissions($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardPermission;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'sfGuardGroupPermission.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BasesfGuardGroupPermission:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BasesfGuardGroupPermission::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BasesfGuardGroupPermission
|
||||
File diff suppressed because it is too large
Load Diff
1074
plugins/sfGuardPlugin/lib/model/om/BasesfGuardPermission.php
Normal file
1074
plugins/sfGuardPlugin/lib/model/om/BasesfGuardPermission.php
Normal file
File diff suppressed because it is too large
Load Diff
688
plugins/sfGuardPlugin/lib/model/om/BasesfGuardPermissionPeer.php
Normal file
688
plugins/sfGuardPlugin/lib/model/om/BasesfGuardPermissionPeer.php
Normal file
@@ -0,0 +1,688 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'sf_guard_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardPermissionPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'sf_guard_permission';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.sfGuardPlugin.lib.model.sfGuardPermission';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 3;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'sf_guard_permission.ID';
|
||||
|
||||
/** the column name for the NAME field */
|
||||
const NAME = 'sf_guard_permission.NAME';
|
||||
|
||||
/** the column name for the DESCRIPTION field */
|
||||
const DESCRIPTION = 'sf_guard_permission.DESCRIPTION';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Description', ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardPermissionPeer::ID, sfGuardPermissionPeer::NAME, sfGuardPermissionPeer::DESCRIPTION, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'description', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Description' => 2, ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardPermissionPeer::ID => 0, sfGuardPermissionPeer::NAME => 1, sfGuardPermissionPeer::DESCRIPTION => 2, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'description' => 2, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardPermissionMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = sfGuardPermissionPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. sfGuardPermissionPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(sfGuardPermissionPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(sfGuardPermissionPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardPermissionPeer::NAME);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardPermissionPeer::DESCRIPTION);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('sfGuardPermissionPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'sfGuardPermissionPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(sf_guard_permission.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT sf_guard_permission.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardPermissionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardPermissionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = sfGuardPermissionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardPermission
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = sfGuardPermissionPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardPermission[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return sfGuardPermissionPeer::populateObjects(sfGuardPermissionPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
sfGuardPermissionPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = sfGuardPermissionPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return sfGuardPermissionPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a sfGuardPermission or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardPermission object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardPermissionPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardPermissionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from sfGuardPermission object
|
||||
}
|
||||
|
||||
$criteria->remove(sfGuardPermissionPeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardPermissionPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardPermissionPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a sfGuardPermission or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardPermission object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardPermissionPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardPermissionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(sfGuardPermissionPeer::ID);
|
||||
$selectCriteria->add(sfGuardPermissionPeer::ID, $criteria->remove(sfGuardPermissionPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is sfGuardPermission object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardPermissionPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardPermissionPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the sf_guard_permission table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += sfGuardPermissionPeer::doOnDeleteCascade(new Criteria(), $con);
|
||||
$affectedRows += BasePeer::doDeleteAll(sfGuardPermissionPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a sfGuardPermission or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardPermission object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardPermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof sfGuardPermission) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(sfGuardPermissionPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += sfGuardPermissionPeer::doOnDeleteCascade($criteria, $con);
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
|
||||
{
|
||||
// initialize var to track total num of affected rows
|
||||
$affectedRows = 0;
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = sfGuardPermissionPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
|
||||
// delete related sfGuardGroupPermission objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardGroupPermissionPeer::PERMISSION_ID, $obj->getId());
|
||||
$affectedRows += sfGuardGroupPermissionPeer::doDelete($c, $con);
|
||||
|
||||
// delete related sfGuardUserPermission objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardUserPermissionPeer::PERMISSION_ID, $obj->getId());
|
||||
$affectedRows += sfGuardUserPermissionPeer::doDelete($c, $con);
|
||||
}
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given sfGuardPermission object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param sfGuardPermission $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(sfGuardPermission $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(sfGuardPermissionPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(sfGuardPermissionPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(sfGuardPermissionPeer::DATABASE_NAME, sfGuardPermissionPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = sfGuardPermissionPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return sfGuardPermission
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(sfGuardPermissionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardPermissionPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = sfGuardPermissionPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return sfGuardPermission[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(sfGuardPermissionPeer::ID, $pks, Criteria::IN);
|
||||
$objs = sfGuardPermissionPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BasesfGuardPermissionPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BasesfGuardPermissionPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardPermissionMapBuilder');
|
||||
}
|
||||
856
plugins/sfGuardPlugin/lib/model/om/BasesfGuardRememberKey.php
Normal file
856
plugins/sfGuardPlugin/lib/model/om/BasesfGuardRememberKey.php
Normal file
@@ -0,0 +1,856 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'sf_guard_remember_key' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardRememberKey extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the user_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $user_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the remember_key field.
|
||||
* @var string
|
||||
*/
|
||||
protected $remember_key;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the ip_address field.
|
||||
* @var string
|
||||
*/
|
||||
protected $ip_address;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var int
|
||||
*/
|
||||
protected $created_at;
|
||||
|
||||
/**
|
||||
* @var sfGuardUser
|
||||
*/
|
||||
protected $asfGuardUser;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [user_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [remember_key] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberKey()
|
||||
{
|
||||
|
||||
return $this->remember_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [ip_address] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIpAddress()
|
||||
{
|
||||
|
||||
return $this->ip_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] [created_at] column value.
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the integer unix timestamp will be returned.
|
||||
* @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
|
||||
* @throws PropelException - if unable to convert the date/time to timestamp.
|
||||
*/
|
||||
public function getCreatedAt($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
|
||||
if ($this->created_at === null || $this->created_at === '') {
|
||||
return null;
|
||||
} elseif (!is_int($this->created_at)) {
|
||||
// a non-timestamp value was set externally, so we convert it
|
||||
$ts = strtotime($this->created_at);
|
||||
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
||||
throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
|
||||
}
|
||||
} else {
|
||||
$ts = $this->created_at;
|
||||
}
|
||||
if ($format === null) {
|
||||
return $ts;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $ts);
|
||||
} else {
|
||||
return date($format, $ts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [user_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setUserId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->user_id !== $v) {
|
||||
$this->user_id = $v;
|
||||
$this->modifiedColumns[] = sfGuardRememberKeyPeer::USER_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
|
||||
$this->asfGuardUser = null;
|
||||
}
|
||||
|
||||
} // setUserId()
|
||||
|
||||
/**
|
||||
* Set the value of [remember_key] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setRememberKey($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->remember_key !== $v) {
|
||||
$this->remember_key = $v;
|
||||
$this->modifiedColumns[] = sfGuardRememberKeyPeer::REMEMBER_KEY;
|
||||
}
|
||||
|
||||
} // setRememberKey()
|
||||
|
||||
/**
|
||||
* Set the value of [ip_address] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setIpAddress($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->ip_address !== $v) {
|
||||
$this->ip_address = $v;
|
||||
$this->modifiedColumns[] = sfGuardRememberKeyPeer::IP_ADDRESS;
|
||||
}
|
||||
|
||||
} // setIpAddress()
|
||||
|
||||
/**
|
||||
* Set the value of [created_at] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setCreatedAt($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v)) {
|
||||
$ts = strtotime($v);
|
||||
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
||||
throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
|
||||
}
|
||||
} else {
|
||||
$ts = $v;
|
||||
}
|
||||
if ($this->created_at !== $ts) {
|
||||
$this->created_at = $ts;
|
||||
$this->modifiedColumns[] = sfGuardRememberKeyPeer::CREATED_AT;
|
||||
}
|
||||
|
||||
} // setCreatedAt()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardRememberKey.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardRememberKey.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->user_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->remember_key = $rs->getString($startcol + 1);
|
||||
|
||||
$this->ip_address = $rs->getString($startcol + 2);
|
||||
|
||||
$this->created_at = $rs->getTimestamp($startcol + 3, null);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('sfGuardRememberKey.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardRememberKey.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 4)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 4; // 4 = sfGuardRememberKeyPeer::NUM_COLUMNS - sfGuardRememberKeyPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating sfGuardRememberKey object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardRememberKey.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardRememberKey.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardRememberKey:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKey:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardRememberKeyPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
sfGuardRememberKeyPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardRememberKey.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardRememberKey.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardRememberKey:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKey:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardRememberKey.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardRememberKey.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKey:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->isNew() && !$this->isColumnModified(sfGuardRememberKeyPeer::CREATED_AT))
|
||||
{
|
||||
$this->setCreatedAt(time());
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardRememberKeyPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardRememberKey.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardRememberKey.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKey:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if ($this->asfGuardUser->isModified()) {
|
||||
$affectedRows += $this->asfGuardUser->save($con);
|
||||
}
|
||||
$this->setsfGuardUser($this->asfGuardUser);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = sfGuardRememberKeyPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += sfGuardRememberKeyPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if (!$this->asfGuardUser->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = sfGuardRememberKeyPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardRememberKeyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getUserId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getRememberKey();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getIpAddress();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardRememberKeyPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getUserId(),
|
||||
$keys[1] => $this->getRememberKey(),
|
||||
$keys[2] => $this->getIpAddress(),
|
||||
$keys[3] => $this->getCreatedAt(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardRememberKeyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setUserId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setRememberKey($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setIpAddress($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardRememberKeyPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setRememberKey($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setIpAddress($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardRememberKeyPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(sfGuardRememberKeyPeer::USER_ID)) $criteria->add(sfGuardRememberKeyPeer::USER_ID, $this->user_id);
|
||||
if ($this->isColumnModified(sfGuardRememberKeyPeer::REMEMBER_KEY)) $criteria->add(sfGuardRememberKeyPeer::REMEMBER_KEY, $this->remember_key);
|
||||
if ($this->isColumnModified(sfGuardRememberKeyPeer::IP_ADDRESS)) $criteria->add(sfGuardRememberKeyPeer::IP_ADDRESS, $this->ip_address);
|
||||
if ($this->isColumnModified(sfGuardRememberKeyPeer::CREATED_AT)) $criteria->add(sfGuardRememberKeyPeer::CREATED_AT, $this->created_at);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardRememberKeyPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardRememberKeyPeer::USER_ID, $this->user_id);
|
||||
$criteria->add(sfGuardRememberKeyPeer::IP_ADDRESS, $this->ip_address);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composite primary key for this object.
|
||||
* The array elements will be in same order as specified in XML.
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return array($this->getUserId(), $this->getIpAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(sfGuardRememberKeyPeer::translateFieldName('user_id', BasePeer::TYPE_FIELDNAME, $keyType), sfGuardRememberKeyPeer::translateFieldName('ip_address', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [composite] primary key.
|
||||
*
|
||||
* @param array $keys The elements of the composite key (order must match the order in XML file).
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($keys)
|
||||
{
|
||||
|
||||
$this->setUserId($keys[0]);
|
||||
|
||||
$this->setIpAddress($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of sfGuardRememberKey (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setRememberKey($this->remember_key);
|
||||
|
||||
$copyObj->setCreatedAt($this->created_at);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setUserId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setIpAddress(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return sfGuardRememberKey Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'sfGuardRememberKeyPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardUser object.
|
||||
*
|
||||
* @param sfGuardUser $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardUser($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setUserId(NULL);
|
||||
} else {
|
||||
$this->setUserId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardUser = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardUser object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardUser The associated sfGuardUser object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardUser($con = null)
|
||||
{
|
||||
if ($this->asfGuardUser === null && ($this->user_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->user_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardUserPeer::retrieveByPK($this->user_id, $con);
|
||||
$obj->addsfGuardUsers($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardUser;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'sfGuardRememberKey.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BasesfGuardRememberKey:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BasesfGuardRememberKey::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BasesfGuardRememberKey
|
||||
@@ -0,0 +1,839 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'sf_guard_remember_key' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardRememberKeyPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'sf_guard_remember_key';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.sfGuardPlugin.lib.model.sfGuardRememberKey';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 4;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the USER_ID field */
|
||||
const USER_ID = 'sf_guard_remember_key.USER_ID';
|
||||
|
||||
/** the column name for the REMEMBER_KEY field */
|
||||
const REMEMBER_KEY = 'sf_guard_remember_key.REMEMBER_KEY';
|
||||
|
||||
/** the column name for the IP_ADDRESS field */
|
||||
const IP_ADDRESS = 'sf_guard_remember_key.IP_ADDRESS';
|
||||
|
||||
/** the column name for the CREATED_AT field */
|
||||
const CREATED_AT = 'sf_guard_remember_key.CREATED_AT';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('UserId', 'RememberKey', 'IpAddress', 'CreatedAt', ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardRememberKeyPeer::USER_ID, sfGuardRememberKeyPeer::REMEMBER_KEY, sfGuardRememberKeyPeer::IP_ADDRESS, sfGuardRememberKeyPeer::CREATED_AT, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('user_id', 'remember_key', 'ip_address', 'created_at', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('UserId' => 0, 'RememberKey' => 1, 'IpAddress' => 2, 'CreatedAt' => 3, ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardRememberKeyPeer::USER_ID => 0, sfGuardRememberKeyPeer::REMEMBER_KEY => 1, sfGuardRememberKeyPeer::IP_ADDRESS => 2, sfGuardRememberKeyPeer::CREATED_AT => 3, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('user_id' => 0, 'remember_key' => 1, 'ip_address' => 2, 'created_at' => 3, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardRememberKeyMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = sfGuardRememberKeyPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. sfGuardRememberKeyPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(sfGuardRememberKeyPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::USER_ID);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::REMEMBER_KEY);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::IP_ADDRESS);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::CREATED_AT);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('sfGuardRememberKeyPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'sfGuardRememberKeyPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(sf_guard_remember_key.USER_ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT sf_guard_remember_key.USER_ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = sfGuardRememberKeyPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardRememberKey
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = sfGuardRememberKeyPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardRememberKey[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return sfGuardRememberKeyPeer::populateObjects(sfGuardRememberKeyPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
sfGuardRememberKeyPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = sfGuardRememberKeyPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related sfGuardUser table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinsfGuardUser(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(sfGuardRememberKeyPeer::USER_ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = sfGuardRememberKeyPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of sfGuardRememberKey objects pre-filled with their sfGuardUser objects.
|
||||
*
|
||||
* @return sfGuardRememberKey[] Array of sfGuardRememberKey objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinsfGuardUser(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
sfGuardRememberKeyPeer::addSelectColumns($c);
|
||||
|
||||
sfGuardUserPeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(sfGuardRememberKeyPeer::USER_ID, sfGuardUserPeer::ID);
|
||||
$rs = sfGuardRememberKeyPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new sfGuardRememberKey();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getUserId())
|
||||
{
|
||||
|
||||
$obj2 = new sfGuardUser();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addsfGuardRememberKey($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardRememberKeyPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(sfGuardRememberKeyPeer::USER_ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = sfGuardRememberKeyPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of sfGuardRememberKey objects pre-filled with all related objects.
|
||||
*
|
||||
* @return sfGuardRememberKey[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
sfGuardRememberKeyPeer::addSelectColumns($c);
|
||||
$startcol2 = (sfGuardRememberKeyPeer::NUM_COLUMNS - sfGuardRememberKeyPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
sfGuardUserPeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + sfGuardUserPeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(sfGuardRememberKeyPeer::USER_ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = sfGuardRememberKeyPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined sfGuardUser rows
|
||||
|
||||
$omClass = sfGuardUserPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getsfGuardUser(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addsfGuardRememberKey($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initsfGuardRememberKeys();
|
||||
$obj2->addsfGuardRememberKey($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return sfGuardRememberKeyPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a sfGuardRememberKey or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardRememberKey object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKeyPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardRememberKeyPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from sfGuardRememberKey object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKeyPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardRememberKeyPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a sfGuardRememberKey or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardRememberKey object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKeyPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardRememberKeyPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(sfGuardRememberKeyPeer::USER_ID);
|
||||
$selectCriteria->add(sfGuardRememberKeyPeer::USER_ID, $criteria->remove(sfGuardRememberKeyPeer::USER_ID), $comparison);
|
||||
|
||||
$comparison = $criteria->getComparison(sfGuardRememberKeyPeer::IP_ADDRESS);
|
||||
$selectCriteria->add(sfGuardRememberKeyPeer::IP_ADDRESS, $criteria->remove(sfGuardRememberKeyPeer::IP_ADDRESS), $comparison);
|
||||
|
||||
} else { // $values is sfGuardRememberKey object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardRememberKeyPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardRememberKeyPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the sf_guard_remember_key table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(sfGuardRememberKeyPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a sfGuardRememberKey or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardRememberKey object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardRememberKeyPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof sfGuardRememberKey) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
// primary key is composite; we therefore, expect
|
||||
// the primary key passed to be an array of pkey
|
||||
// values
|
||||
if(count($values) == count($values, COUNT_RECURSIVE))
|
||||
{
|
||||
// array is not multi-dimensional
|
||||
$values = array($values);
|
||||
}
|
||||
$vals = array();
|
||||
foreach($values as $value)
|
||||
{
|
||||
|
||||
$vals[0][] = $value[0];
|
||||
$vals[1][] = $value[1];
|
||||
}
|
||||
|
||||
$criteria->add(sfGuardRememberKeyPeer::USER_ID, $vals[0], Criteria::IN);
|
||||
$criteria->add(sfGuardRememberKeyPeer::IP_ADDRESS, $vals[1], Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given sfGuardRememberKey object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param sfGuardRememberKey $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(sfGuardRememberKey $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(sfGuardRememberKeyPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(sfGuardRememberKeyPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(sfGuardRememberKeyPeer::DATABASE_NAME, sfGuardRememberKeyPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = sfGuardRememberKeyPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve object using using composite pkey values.
|
||||
* @param int $user_id
|
||||
@param string $ip_address
|
||||
|
||||
* @param Connection $con
|
||||
* @return sfGuardRememberKey
|
||||
*/
|
||||
public static function retrieveByPK( $user_id, $ip_address, $con = null) {
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(sfGuardRememberKeyPeer::USER_ID, $user_id);
|
||||
$criteria->add(sfGuardRememberKeyPeer::IP_ADDRESS, $ip_address);
|
||||
$v = sfGuardRememberKeyPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) ? $v[0] : null;
|
||||
}
|
||||
} // BasesfGuardRememberKeyPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BasesfGuardRememberKeyPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardRememberKeyMapBuilder');
|
||||
}
|
||||
6842
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUser.php
Normal file
6842
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUser.php
Normal file
File diff suppressed because it is too large
Load Diff
795
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserGroup.php
Normal file
795
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserGroup.php
Normal file
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'sf_guard_user_group' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardUserGroup extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the user_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $user_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the group_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $group_id;
|
||||
|
||||
/**
|
||||
* @var sfGuardUser
|
||||
*/
|
||||
protected $asfGuardUser;
|
||||
|
||||
/**
|
||||
* @var sfGuardGroup
|
||||
*/
|
||||
protected $asfGuardGroup;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [user_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [group_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getGroupId()
|
||||
{
|
||||
|
||||
return $this->group_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [user_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setUserId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->user_id !== $v) {
|
||||
$this->user_id = $v;
|
||||
$this->modifiedColumns[] = sfGuardUserGroupPeer::USER_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
|
||||
$this->asfGuardUser = null;
|
||||
}
|
||||
|
||||
} // setUserId()
|
||||
|
||||
/**
|
||||
* Set the value of [group_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setGroupId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->group_id !== $v) {
|
||||
$this->group_id = $v;
|
||||
$this->modifiedColumns[] = sfGuardUserGroupPeer::GROUP_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardGroup !== null && $this->asfGuardGroup->getId() !== $v) {
|
||||
$this->asfGuardGroup = null;
|
||||
}
|
||||
|
||||
} // setGroupId()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserGroup.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserGroup.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->user_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->group_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserGroup.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserGroup.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = sfGuardUserGroupPeer::NUM_COLUMNS - sfGuardUserGroupPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating sfGuardUserGroup object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserGroup.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserGroup.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardUserGroup:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserGroup:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserGroupPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
sfGuardUserGroupPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserGroup.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserGroup.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardUserGroup:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserGroup:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserGroup.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserGroup.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserGroup:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserGroupPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserGroup.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserGroup.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserGroup:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if ($this->asfGuardUser->isModified()) {
|
||||
$affectedRows += $this->asfGuardUser->save($con);
|
||||
}
|
||||
$this->setsfGuardUser($this->asfGuardUser);
|
||||
}
|
||||
|
||||
if ($this->asfGuardGroup !== null) {
|
||||
if ($this->asfGuardGroup->isModified()) {
|
||||
$affectedRows += $this->asfGuardGroup->save($con);
|
||||
}
|
||||
$this->setsfGuardGroup($this->asfGuardGroup);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = sfGuardUserGroupPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += sfGuardUserGroupPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if (!$this->asfGuardUser->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->asfGuardGroup !== null) {
|
||||
if (!$this->asfGuardGroup->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardGroup->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = sfGuardUserGroupPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardUserGroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getUserId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getGroupId();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardUserGroupPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getUserId(),
|
||||
$keys[1] => $this->getGroupId(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardUserGroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setUserId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setGroupId($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardUserGroupPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardUserGroupPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(sfGuardUserGroupPeer::USER_ID)) $criteria->add(sfGuardUserGroupPeer::USER_ID, $this->user_id);
|
||||
if ($this->isColumnModified(sfGuardUserGroupPeer::GROUP_ID)) $criteria->add(sfGuardUserGroupPeer::GROUP_ID, $this->group_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardUserGroupPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardUserGroupPeer::USER_ID, $this->user_id);
|
||||
$criteria->add(sfGuardUserGroupPeer::GROUP_ID, $this->group_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composite primary key for this object.
|
||||
* The array elements will be in same order as specified in XML.
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return array($this->getUserId(), $this->getGroupId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(sfGuardUserGroupPeer::translateFieldName('user_id', BasePeer::TYPE_FIELDNAME, $keyType), sfGuardUserGroupPeer::translateFieldName('group_id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [composite] primary key.
|
||||
*
|
||||
* @param array $keys The elements of the composite key (order must match the order in XML file).
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($keys)
|
||||
{
|
||||
|
||||
$this->setUserId($keys[0]);
|
||||
|
||||
$this->setGroupId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of sfGuardUserGroup (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setUserId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setGroupId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return sfGuardUserGroup Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'sfGuardUserGroupPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardUser object.
|
||||
*
|
||||
* @param sfGuardUser $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardUser($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setUserId(NULL);
|
||||
} else {
|
||||
$this->setUserId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardUser = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardUser object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardUser The associated sfGuardUser object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardUser($con = null)
|
||||
{
|
||||
if ($this->asfGuardUser === null && ($this->user_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->user_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardUserPeer::retrieveByPK($this->user_id, $con);
|
||||
$obj->addsfGuardUsers($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardGroup object.
|
||||
*
|
||||
* @param sfGuardGroup $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardGroup($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setGroupId(NULL);
|
||||
} else {
|
||||
$this->setGroupId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardGroup = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardGroup object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardGroup The associated sfGuardGroup object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardGroup($con = null)
|
||||
{
|
||||
if ($this->asfGuardGroup === null && ($this->group_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardGroup = sfGuardGroupPeer::retrieveByPK($this->group_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardGroupPeer::retrieveByPK($this->group_id, $con);
|
||||
$obj->addsfGuardGroups($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardGroup;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'sfGuardUserGroup.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BasesfGuardUserGroup:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BasesfGuardUserGroup::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BasesfGuardUserGroup
|
||||
1170
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserGroupPeer.php
Normal file
1170
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserGroupPeer.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,715 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'sf_guard_user_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardUserModulePermission extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the permissions field.
|
||||
* @var array
|
||||
*/
|
||||
protected $permissions;
|
||||
|
||||
/**
|
||||
* @var sfGuardUser
|
||||
*/
|
||||
protected $asfGuardUser;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [permissions] column value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissions()
|
||||
{
|
||||
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = sfGuardUserModulePermissionPeer::ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
|
||||
$this->asfGuardUser = null;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [permissions] column.
|
||||
*
|
||||
* @param array $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setPermissions($v)
|
||||
{
|
||||
|
||||
if ($this->permissions !== $v) {
|
||||
$this->permissions = $v;
|
||||
$this->modifiedColumns[] = sfGuardUserModulePermissionPeer::PERMISSIONS;
|
||||
}
|
||||
|
||||
} // setPermissions()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserModulePermission.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserModulePermission.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->permissions = $rs->getString($startcol + 1) ? unserialize($rs->getString($startcol + 1)) : null;
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserModulePermission.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserModulePermission.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = sfGuardUserModulePermissionPeer::NUM_COLUMNS - sfGuardUserModulePermissionPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating sfGuardUserModulePermission object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserModulePermission.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserModulePermission.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardUserModulePermission:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermission:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserModulePermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
sfGuardUserModulePermissionPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserModulePermission.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserModulePermission.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardUserModulePermission:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermission:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserModulePermission.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserModulePermission.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermission:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserModulePermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserModulePermission.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserModulePermission.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermission:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if ($this->asfGuardUser->isModified()) {
|
||||
$affectedRows += $this->asfGuardUser->save($con);
|
||||
}
|
||||
$this->setsfGuardUser($this->asfGuardUser);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = sfGuardUserModulePermissionPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += sfGuardUserModulePermissionPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if (!$this->asfGuardUser->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = sfGuardUserModulePermissionPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardUserModulePermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getPermissions();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardUserModulePermissionPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getPermissions(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardUserModulePermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setPermissions($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardUserModulePermissionPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setPermissions($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardUserModulePermissionPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(sfGuardUserModulePermissionPeer::ID)) $criteria->add(sfGuardUserModulePermissionPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(sfGuardUserModulePermissionPeer::PERMISSIONS)) $criteria->add(sfGuardUserModulePermissionPeer::PERMISSIONS, null !== $this->permissions && (is_array($this->permissions) || is_object($this->permissions)) ? serialize($this->permissions) : $this->permissions);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardUserModulePermissionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardUserModulePermissionPeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(sfGuardUserModulePermissionPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of sfGuardUserModulePermission (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setPermissions($this->permissions);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return sfGuardUserModulePermission Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'sfGuardUserModulePermissionPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardUser object.
|
||||
*
|
||||
* @param sfGuardUser $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardUser($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setId(NULL);
|
||||
} else {
|
||||
$this->setId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardUser = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardUser object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardUser The associated sfGuardUser object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardUser($con = null)
|
||||
{
|
||||
if ($this->asfGuardUser === null && ($this->id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardUserPeer::retrieveByPK($this->id, $con);
|
||||
$obj->addsfGuardUsers($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardUser;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'sfGuardUserModulePermission.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BasesfGuardUserModulePermission:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BasesfGuardUserModulePermission::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BasesfGuardUserModulePermission
|
||||
@@ -0,0 +1,839 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'sf_guard_user_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardUserModulePermissionPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'sf_guard_user_module_permission';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.sfGuardPlugin.lib.model.sfGuardUserModulePermission';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 2;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'sf_guard_user_module_permission.ID';
|
||||
|
||||
/** the column name for the PERMISSIONS field */
|
||||
const PERMISSIONS = 'sf_guard_user_module_permission.PERMISSIONS';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'Permissions', ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardUserModulePermissionPeer::ID, sfGuardUserModulePermissionPeer::PERMISSIONS, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'permissions', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Permissions' => 1, ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardUserModulePermissionPeer::ID => 0, sfGuardUserModulePermissionPeer::PERMISSIONS => 1, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'permissions' => 1, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardUserModulePermissionMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = sfGuardUserModulePermissionPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. sfGuardUserModulePermissionPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(sfGuardUserModulePermissionPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::PERMISSIONS);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('sfGuardUserModulePermissionPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'sfGuardUserModulePermissionPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(sf_guard_user_module_permission.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT sf_guard_user_module_permission.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = sfGuardUserModulePermissionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardUserModulePermission
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = sfGuardUserModulePermissionPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardUserModulePermission[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return sfGuardUserModulePermissionPeer::populateObjects(sfGuardUserModulePermissionPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
sfGuardUserModulePermissionPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = sfGuardUserModulePermissionPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related sfGuardUser table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinsfGuardUser(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(sfGuardUserModulePermissionPeer::ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = sfGuardUserModulePermissionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of sfGuardUserModulePermission objects pre-filled with their sfGuardUser objects.
|
||||
*
|
||||
* @return sfGuardUserModulePermission[] Array of sfGuardUserModulePermission objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinsfGuardUser(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
sfGuardUserModulePermissionPeer::addSelectColumns($c);
|
||||
|
||||
sfGuardUserPeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(sfGuardUserModulePermissionPeer::ID, sfGuardUserPeer::ID);
|
||||
$rs = sfGuardUserModulePermissionPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new sfGuardUserModulePermission();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getId())
|
||||
{
|
||||
|
||||
$obj2 = new sfGuardUser();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addsfGuardUserModulePermission($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardUserModulePermissionPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(sfGuardUserModulePermissionPeer::ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = sfGuardUserModulePermissionPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of sfGuardUserModulePermission objects pre-filled with all related objects.
|
||||
*
|
||||
* @return sfGuardUserModulePermission[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
sfGuardUserModulePermissionPeer::addSelectColumns($c);
|
||||
$startcol2 = (sfGuardUserModulePermissionPeer::NUM_COLUMNS - sfGuardUserModulePermissionPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
sfGuardUserPeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + sfGuardUserPeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(sfGuardUserModulePermissionPeer::ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = sfGuardUserModulePermissionPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined sfGuardUser rows
|
||||
|
||||
$omClass = sfGuardUserPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getsfGuardUser(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addsfGuardUserModulePermission($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initsfGuardUserModulePermissions();
|
||||
$obj2->addsfGuardUserModulePermission($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return sfGuardUserModulePermissionPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a sfGuardUserModulePermission or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardUserModulePermission object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermissionPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardUserModulePermissionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from sfGuardUserModulePermission object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermissionPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardUserModulePermissionPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a sfGuardUserModulePermission or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardUserModulePermission object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermissionPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardUserModulePermissionPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(sfGuardUserModulePermissionPeer::ID);
|
||||
$selectCriteria->add(sfGuardUserModulePermissionPeer::ID, $criteria->remove(sfGuardUserModulePermissionPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is sfGuardUserModulePermission object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserModulePermissionPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardUserModulePermissionPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the sf_guard_user_module_permission table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(sfGuardUserModulePermissionPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a sfGuardUserModulePermission or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardUserModulePermission object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserModulePermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof sfGuardUserModulePermission) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(sfGuardUserModulePermissionPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given sfGuardUserModulePermission object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param sfGuardUserModulePermission $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(sfGuardUserModulePermission $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(sfGuardUserModulePermissionPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(sfGuardUserModulePermissionPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(sfGuardUserModulePermissionPeer::DATABASE_NAME, sfGuardUserModulePermissionPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = sfGuardUserModulePermissionPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return sfGuardUserModulePermission
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(sfGuardUserModulePermissionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardUserModulePermissionPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = sfGuardUserModulePermissionPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return sfGuardUserModulePermission[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(sfGuardUserModulePermissionPeer::ID, $pks, Criteria::IN);
|
||||
$objs = sfGuardUserModulePermissionPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BasesfGuardUserModulePermissionPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BasesfGuardUserModulePermissionPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardUserModulePermissionMapBuilder');
|
||||
}
|
||||
913
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPeer.php
Normal file
913
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPeer.php
Normal file
@@ -0,0 +1,913 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'sf_guard_user' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardUserPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'sf_guard_user';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.sfGuardPlugin.lib.model.sfGuardUser';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 20;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'sf_guard_user.ID';
|
||||
|
||||
/** the column name for the USERNAME field */
|
||||
const USERNAME = 'sf_guard_user.USERNAME';
|
||||
|
||||
/** the column name for the ALGORITHM field */
|
||||
const ALGORITHM = 'sf_guard_user.ALGORITHM';
|
||||
|
||||
/** the column name for the SALT field */
|
||||
const SALT = 'sf_guard_user.SALT';
|
||||
|
||||
/** the column name for the PASSWORD field */
|
||||
const PASSWORD = 'sf_guard_user.PASSWORD';
|
||||
|
||||
/** the column name for the CREATED_AT field */
|
||||
const CREATED_AT = 'sf_guard_user.CREATED_AT';
|
||||
|
||||
/** the column name for the LAST_LOGIN field */
|
||||
const LAST_LOGIN = 'sf_guard_user.LAST_LOGIN';
|
||||
|
||||
/** the column name for the LAST_PASSWORD_CHANGE field */
|
||||
const LAST_PASSWORD_CHANGE = 'sf_guard_user.LAST_PASSWORD_CHANGE';
|
||||
|
||||
/** the column name for the IS_ACTIVE field */
|
||||
const IS_ACTIVE = 'sf_guard_user.IS_ACTIVE';
|
||||
|
||||
/** the column name for the IS_SUPER_ADMIN field */
|
||||
const IS_SUPER_ADMIN = 'sf_guard_user.IS_SUPER_ADMIN';
|
||||
|
||||
/** the column name for the IS_CONFIRM field */
|
||||
const IS_CONFIRM = 'sf_guard_user.IS_CONFIRM';
|
||||
|
||||
/** the column name for the IS_ADMIN_CONFIRM field */
|
||||
const IS_ADMIN_CONFIRM = 'sf_guard_user.IS_ADMIN_CONFIRM';
|
||||
|
||||
/** the column name for the HASH_CODE field */
|
||||
const HASH_CODE = 'sf_guard_user.HASH_CODE';
|
||||
|
||||
/** the column name for the LANGUAGE field */
|
||||
const LANGUAGE = 'sf_guard_user.LANGUAGE';
|
||||
|
||||
/** the column name for the EXTERNAL_ACCOUNT field */
|
||||
const EXTERNAL_ACCOUNT = 'sf_guard_user.EXTERNAL_ACCOUNT';
|
||||
|
||||
/** the column name for the POINTS field */
|
||||
const POINTS = 'sf_guard_user.POINTS';
|
||||
|
||||
/** the column name for the POINTS_AVAILABLE field */
|
||||
const POINTS_AVAILABLE = 'sf_guard_user.POINTS_AVAILABLE';
|
||||
|
||||
/** the column name for the POINTS_RELEASE field */
|
||||
const POINTS_RELEASE = 'sf_guard_user.POINTS_RELEASE';
|
||||
|
||||
/** the column name for the OPT_ALLEGRO_USER_ID field */
|
||||
const OPT_ALLEGRO_USER_ID = 'sf_guard_user.OPT_ALLEGRO_USER_ID';
|
||||
|
||||
/** the column name for the WHOLESALE field */
|
||||
const WHOLESALE = 'sf_guard_user.WHOLESALE';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'Username', 'Algorithm', 'Salt', 'Password', 'CreatedAt', 'LastLogin', 'LastPasswordChange', 'IsActive', 'IsSuperAdmin', 'IsConfirm', 'IsAdminConfirm', 'HashCode', 'Language', 'ExternalAccount', 'Points', 'PointsAvailable', 'PointsRelease', 'OptAllegroUserId', 'Wholesale', ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardUserPeer::ID, sfGuardUserPeer::USERNAME, sfGuardUserPeer::ALGORITHM, sfGuardUserPeer::SALT, sfGuardUserPeer::PASSWORD, sfGuardUserPeer::CREATED_AT, sfGuardUserPeer::LAST_LOGIN, sfGuardUserPeer::LAST_PASSWORD_CHANGE, sfGuardUserPeer::IS_ACTIVE, sfGuardUserPeer::IS_SUPER_ADMIN, sfGuardUserPeer::IS_CONFIRM, sfGuardUserPeer::IS_ADMIN_CONFIRM, sfGuardUserPeer::HASH_CODE, sfGuardUserPeer::LANGUAGE, sfGuardUserPeer::EXTERNAL_ACCOUNT, sfGuardUserPeer::POINTS, sfGuardUserPeer::POINTS_AVAILABLE, sfGuardUserPeer::POINTS_RELEASE, sfGuardUserPeer::OPT_ALLEGRO_USER_ID, sfGuardUserPeer::WHOLESALE, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'username', 'algorithm', 'salt', 'password', 'created_at', 'last_login', 'last_password_change', 'is_active', 'is_super_admin', 'is_confirm', 'is_admin_confirm', 'hash_code', 'language', 'external_account', 'points', 'points_available', 'points_release', 'opt_allegro_user_id', 'wholesale', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Username' => 1, 'Algorithm' => 2, 'Salt' => 3, 'Password' => 4, 'CreatedAt' => 5, 'LastLogin' => 6, 'LastPasswordChange' => 7, 'IsActive' => 8, 'IsSuperAdmin' => 9, 'IsConfirm' => 10, 'IsAdminConfirm' => 11, 'HashCode' => 12, 'Language' => 13, 'ExternalAccount' => 14, 'Points' => 15, 'PointsAvailable' => 16, 'PointsRelease' => 17, 'OptAllegroUserId' => 18, 'Wholesale' => 19, ),
|
||||
BasePeer::TYPE_COLNAME => array (sfGuardUserPeer::ID => 0, sfGuardUserPeer::USERNAME => 1, sfGuardUserPeer::ALGORITHM => 2, sfGuardUserPeer::SALT => 3, sfGuardUserPeer::PASSWORD => 4, sfGuardUserPeer::CREATED_AT => 5, sfGuardUserPeer::LAST_LOGIN => 6, sfGuardUserPeer::LAST_PASSWORD_CHANGE => 7, sfGuardUserPeer::IS_ACTIVE => 8, sfGuardUserPeer::IS_SUPER_ADMIN => 9, sfGuardUserPeer::IS_CONFIRM => 10, sfGuardUserPeer::IS_ADMIN_CONFIRM => 11, sfGuardUserPeer::HASH_CODE => 12, sfGuardUserPeer::LANGUAGE => 13, sfGuardUserPeer::EXTERNAL_ACCOUNT => 14, sfGuardUserPeer::POINTS => 15, sfGuardUserPeer::POINTS_AVAILABLE => 16, sfGuardUserPeer::POINTS_RELEASE => 17, sfGuardUserPeer::OPT_ALLEGRO_USER_ID => 18, sfGuardUserPeer::WHOLESALE => 19, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'username' => 1, 'algorithm' => 2, 'salt' => 3, 'password' => 4, 'created_at' => 5, 'last_login' => 6, 'last_password_change' => 7, 'is_active' => 8, 'is_super_admin' => 9, 'is_confirm' => 10, 'is_admin_confirm' => 11, 'hash_code' => 12, 'language' => 13, 'external_account' => 14, 'points' => 15, 'points_available' => 16, 'points_release' => 17, 'opt_allegro_user_id' => 18, 'wholesale' => 19, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardUserMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = sfGuardUserPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. sfGuardUserPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(sfGuardUserPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::USERNAME);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::ALGORITHM);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::SALT);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::PASSWORD);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::CREATED_AT);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::LAST_LOGIN);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::LAST_PASSWORD_CHANGE);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::IS_ACTIVE);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::IS_SUPER_ADMIN);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::IS_CONFIRM);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::IS_ADMIN_CONFIRM);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::HASH_CODE);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::LANGUAGE);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::EXTERNAL_ACCOUNT);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::POINTS);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::POINTS_AVAILABLE);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::POINTS_RELEASE);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::OPT_ALLEGRO_USER_ID);
|
||||
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::WHOLESALE);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('sfGuardUserPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'sfGuardUserPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(sf_guard_user.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT sf_guard_user.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(sfGuardUserPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = sfGuardUserPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardUser
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = sfGuardUserPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return sfGuardUser[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return sfGuardUserPeer::populateObjects(sfGuardUserPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
sfGuardUserPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = sfGuardUserPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return sfGuardUserPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a sfGuardUser or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardUser object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardUserPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from sfGuardUser object
|
||||
}
|
||||
|
||||
$criteria->remove(sfGuardUserPeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardUserPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a sfGuardUser or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardUser object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasesfGuardUserPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(sfGuardUserPeer::ID);
|
||||
$selectCriteria->add(sfGuardUserPeer::ID, $criteria->remove(sfGuardUserPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is sfGuardUser object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasesfGuardUserPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the sf_guard_user table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += sfGuardUserPeer::doOnDeleteCascade(new Criteria(), $con);
|
||||
sfGuardUserPeer::doOnDeleteSetNull(new Criteria(), $con);
|
||||
$affectedRows += BasePeer::doDeleteAll(sfGuardUserPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a sfGuardUser or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or sfGuardUser object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof sfGuardUser) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(sfGuardUserPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += sfGuardUserPeer::doOnDeleteCascade($criteria, $con);sfGuardUserPeer::doOnDeleteSetNull($criteria, $con);
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
|
||||
{
|
||||
// initialize var to track total num of affected rows
|
||||
$affectedRows = 0;
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = sfGuardUserPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
|
||||
// delete related Review objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ReviewPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += ReviewPeer::doDelete($c, $con);
|
||||
|
||||
// delete related ReviewOrder objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ReviewOrderPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += ReviewOrderPeer::doDelete($c, $con);
|
||||
|
||||
// delete related Basket objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(BasketPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += BasketPeer::doDelete($c, $con);
|
||||
|
||||
// delete related UserPoints objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(UserPointsPeer::ADMIN_ID, $obj->getId());
|
||||
$affectedRows += UserPointsPeer::doDelete($c, $con);
|
||||
|
||||
// delete related Dashboard objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DashboardPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += DashboardPeer::doDelete($c, $con);
|
||||
|
||||
// delete related ThemeLayout objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeLayoutPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += ThemeLayoutPeer::doDelete($c, $con);
|
||||
|
||||
// delete related UserHasDiscount objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(UserHasDiscountPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += UserHasDiscountPeer::doDelete($c, $con);
|
||||
|
||||
// delete related DiscountUser objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DiscountUserPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += DiscountUserPeer::doDelete($c, $con);
|
||||
|
||||
// delete related DiscountCouponCode objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DiscountCouponCodePeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += DiscountCouponCodePeer::doDelete($c, $con);
|
||||
|
||||
// delete related AdminGeneratorFilter objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(AdminGeneratorFilterPeer::GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += AdminGeneratorFilterPeer::doDelete($c, $con);
|
||||
|
||||
// delete related AdminGeneratorUserConfiguration objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(AdminGeneratorUserConfigurationPeer::GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += AdminGeneratorUserConfigurationPeer::doDelete($c, $con);
|
||||
|
||||
// delete related UserData objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(UserDataPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$affectedRows += UserDataPeer::doDelete($c, $con);
|
||||
|
||||
// delete related sfGuardUserPermission objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardUserPermissionPeer::USER_ID, $obj->getId());
|
||||
$affectedRows += sfGuardUserPermissionPeer::doDelete($c, $con);
|
||||
|
||||
// delete related sfGuardUserGroup objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardUserGroupPeer::USER_ID, $obj->getId());
|
||||
$affectedRows += sfGuardUserGroupPeer::doDelete($c, $con);
|
||||
|
||||
// delete related sfGuardRememberKey objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardRememberKeyPeer::USER_ID, $obj->getId());
|
||||
$affectedRows += sfGuardRememberKeyPeer::doDelete($c, $con);
|
||||
|
||||
// delete related sfGuardUserModulePermission objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(sfGuardUserModulePermissionPeer::ID, $obj->getId());
|
||||
$affectedRows += sfGuardUserModulePermissionPeer::doDelete($c, $con);
|
||||
}
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE SET NULL DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
*/
|
||||
protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con)
|
||||
{
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = sfGuardUserPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
// set fkey col in related Order rows to NULL
|
||||
$selectCriteria = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$updateValues = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$selectCriteria->add(OrderPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$updateValues->add(OrderPeer::SF_GUARD_USER_ID, null);
|
||||
|
||||
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
|
||||
|
||||
// set fkey col in related Order rows to NULL
|
||||
$selectCriteria = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$updateValues = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$selectCriteria->add(OrderPeer::ASSIGNED_ID, $obj->getId());
|
||||
$updateValues->add(OrderPeer::ASSIGNED_ID, null);
|
||||
|
||||
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
|
||||
|
||||
// set fkey col in related stProductObserve rows to NULL
|
||||
$selectCriteria = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$updateValues = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$selectCriteria->add(stProductObservePeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$updateValues->add(stProductObservePeer::SF_GUARD_USER_ID, null);
|
||||
|
||||
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
|
||||
|
||||
// set fkey col in related NewsletterUser rows to NULL
|
||||
$selectCriteria = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$updateValues = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
$selectCriteria->add(NewsletterUserPeer::SF_GUARD_USER_ID, $obj->getId());
|
||||
$updateValues->add(NewsletterUserPeer::SF_GUARD_USER_ID, null);
|
||||
|
||||
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given sfGuardUser object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param sfGuardUser $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(sfGuardUser $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(sfGuardUserPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(sfGuardUserPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(sfGuardUserPeer::DATABASE_NAME, sfGuardUserPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = sfGuardUserPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return sfGuardUser
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(sfGuardUserPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardUserPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = sfGuardUserPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return sfGuardUser[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(sfGuardUserPeer::ID, $pks, Criteria::IN);
|
||||
$objs = sfGuardUserPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BasesfGuardUserPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BasesfGuardUserPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.sfGuardPlugin.lib.model.map.sfGuardUserMapBuilder');
|
||||
}
|
||||
795
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPermission.php
Normal file
795
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPermission.php
Normal file
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'sf_guard_user_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasesfGuardUserPermission extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the user_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $user_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the permission_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $permission_id;
|
||||
|
||||
/**
|
||||
* @var sfGuardUser
|
||||
*/
|
||||
protected $asfGuardUser;
|
||||
|
||||
/**
|
||||
* @var sfGuardPermission
|
||||
*/
|
||||
protected $asfGuardPermission;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [user_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [permission_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPermissionId()
|
||||
{
|
||||
|
||||
return $this->permission_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [user_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setUserId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->user_id !== $v) {
|
||||
$this->user_id = $v;
|
||||
$this->modifiedColumns[] = sfGuardUserPermissionPeer::USER_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
|
||||
$this->asfGuardUser = null;
|
||||
}
|
||||
|
||||
} // setUserId()
|
||||
|
||||
/**
|
||||
* Set the value of [permission_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setPermissionId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->permission_id !== $v) {
|
||||
$this->permission_id = $v;
|
||||
$this->modifiedColumns[] = sfGuardUserPermissionPeer::PERMISSION_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardPermission !== null && $this->asfGuardPermission->getId() !== $v) {
|
||||
$this->asfGuardPermission = null;
|
||||
}
|
||||
|
||||
} // setPermissionId()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserPermission.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserPermission.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->user_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->permission_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserPermission.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserPermission.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = sfGuardUserPermissionPeer::NUM_COLUMNS - sfGuardUserPermissionPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating sfGuardUserPermission object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserPermission.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserPermission.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardUserPermission:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPermission:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserPermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
sfGuardUserPermissionPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserPermission.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserPermission.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BasesfGuardUserPermission:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPermission:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserPermission.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserPermission.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPermission:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(sfGuardUserPermissionPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('sfGuardUserPermission.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'sfGuardUserPermission.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BasesfGuardUserPermission:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if ($this->asfGuardUser->isModified()) {
|
||||
$affectedRows += $this->asfGuardUser->save($con);
|
||||
}
|
||||
$this->setsfGuardUser($this->asfGuardUser);
|
||||
}
|
||||
|
||||
if ($this->asfGuardPermission !== null) {
|
||||
if ($this->asfGuardPermission->isModified()) {
|
||||
$affectedRows += $this->asfGuardPermission->save($con);
|
||||
}
|
||||
$this->setsfGuardPermission($this->asfGuardPermission);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = sfGuardUserPermissionPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += sfGuardUserPermissionPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if (!$this->asfGuardUser->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->asfGuardPermission !== null) {
|
||||
if (!$this->asfGuardPermission->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardPermission->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = sfGuardUserPermissionPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardUserPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getUserId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getPermissionId();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardUserPermissionPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getUserId(),
|
||||
$keys[1] => $this->getPermissionId(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = sfGuardUserPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setUserId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setPermissionId($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = sfGuardUserPermissionPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setPermissionId($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardUserPermissionPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(sfGuardUserPermissionPeer::USER_ID)) $criteria->add(sfGuardUserPermissionPeer::USER_ID, $this->user_id);
|
||||
if ($this->isColumnModified(sfGuardUserPermissionPeer::PERMISSION_ID)) $criteria->add(sfGuardUserPermissionPeer::PERMISSION_ID, $this->permission_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(sfGuardUserPermissionPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(sfGuardUserPermissionPeer::USER_ID, $this->user_id);
|
||||
$criteria->add(sfGuardUserPermissionPeer::PERMISSION_ID, $this->permission_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composite primary key for this object.
|
||||
* The array elements will be in same order as specified in XML.
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return array($this->getUserId(), $this->getPermissionId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(sfGuardUserPermissionPeer::translateFieldName('user_id', BasePeer::TYPE_FIELDNAME, $keyType), sfGuardUserPermissionPeer::translateFieldName('permission_id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [composite] primary key.
|
||||
*
|
||||
* @param array $keys The elements of the composite key (order must match the order in XML file).
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($keys)
|
||||
{
|
||||
|
||||
$this->setUserId($keys[0]);
|
||||
|
||||
$this->setPermissionId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of sfGuardUserPermission (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setUserId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setPermissionId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return sfGuardUserPermission Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'sfGuardUserPermissionPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardUser object.
|
||||
*
|
||||
* @param sfGuardUser $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardUser($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setUserId(NULL);
|
||||
} else {
|
||||
$this->setUserId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardUser = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardUser object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardUser The associated sfGuardUser object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardUser($con = null)
|
||||
{
|
||||
if ($this->asfGuardUser === null && ($this->user_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->user_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardUserPeer::retrieveByPK($this->user_id, $con);
|
||||
$obj->addsfGuardUsers($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardPermission object.
|
||||
*
|
||||
* @param sfGuardPermission $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardPermission($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setPermissionId(NULL);
|
||||
} else {
|
||||
$this->setPermissionId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardPermission = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardPermission object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardPermission The associated sfGuardPermission object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardPermission($con = null)
|
||||
{
|
||||
if ($this->asfGuardPermission === null && ($this->permission_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardPermission = sfGuardPermissionPeer::retrieveByPK($this->permission_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardPermissionPeer::retrieveByPK($this->permission_id, $con);
|
||||
$obj->addsfGuardPermissions($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardPermission;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'sfGuardUserPermission.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BasesfGuardUserPermission:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BasesfGuardUserPermission::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BasesfGuardUserPermission
|
||||
1170
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPermissionPeer.php
Normal file
1170
plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPermissionPeer.php
Normal file
File diff suppressed because it is too large
Load Diff
52
plugins/sfGuardPlugin/lib/model/sfGuardGroup.php
Normal file
52
plugins/sfGuardPlugin/lib/model/sfGuardGroup.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardGroup.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardGroup extends BasesfGuardGroup
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getDescription();
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isNew() && null === $this->name)
|
||||
{
|
||||
$this->setName(md5($this->description . uniqid()));
|
||||
}
|
||||
|
||||
$ret = parent::save($con);
|
||||
|
||||
sfGuardUser::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getAdminGeneratorTitle()
|
||||
{
|
||||
return $this->getDescription();
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$ret = parent::delete($con);
|
||||
|
||||
sfGuardUser::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'sf_guard_group_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model
|
||||
*/
|
||||
class sfGuardGroupModulePermission extends BasesfGuardGroupModulePermission
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'sf_guard_group_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model
|
||||
*/
|
||||
class sfGuardGroupModulePermissionPeer extends BasesfGuardGroupModulePermissionPeer
|
||||
{
|
||||
}
|
||||
41
plugins/sfGuardPlugin/lib/model/sfGuardGroupPeer.php
Normal file
41
plugins/sfGuardPlugin/lib/model/sfGuardGroupPeer.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardGroupPeer.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardGroupPeer extends BasesfGuardGroupPeer
|
||||
{
|
||||
protected static $groups = [];
|
||||
|
||||
/**
|
||||
* Zwraca grupę
|
||||
*
|
||||
* @param mixed $name Nazwa grupy
|
||||
* @return null|sfGuardGroup
|
||||
* @throws PropelException
|
||||
*/
|
||||
public static function retrieveByName($name)
|
||||
{
|
||||
if (!isset(self::$groups[$name]) && !array_key_exists($name, self::$groups))
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(self::NAME, $name);
|
||||
|
||||
self::$groups[$name] = self::doSelectOne($c);
|
||||
}
|
||||
|
||||
return self::$groups[$name];
|
||||
}
|
||||
}
|
||||
20
plugins/sfGuardPlugin/lib/model/sfGuardGroupPermission.php
Normal file
20
plugins/sfGuardPlugin/lib/model/sfGuardGroupPermission.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardGroupPermission.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardGroupPermission extends BasesfGuardGroupPermission
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardGroupPermissionPeer.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardGroupPermissionPeer extends BasesfGuardGroupPermissionPeer
|
||||
{
|
||||
}
|
||||
29
plugins/sfGuardPlugin/lib/model/sfGuardPermission.php
Normal file
29
plugins/sfGuardPlugin/lib/model/sfGuardPermission.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardPermission.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardPermission extends BasesfGuardPermission
|
||||
{
|
||||
public function getLabel()
|
||||
{
|
||||
return !$this->description ? $this->name : $this->description;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getName();
|
||||
}
|
||||
}
|
||||
27
plugins/sfGuardPlugin/lib/model/sfGuardPermissionPeer.php
Normal file
27
plugins/sfGuardPlugin/lib/model/sfGuardPermissionPeer.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardPermissionPeer.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardPermissionPeer extends BasesfGuardPermissionPeer
|
||||
{
|
||||
public static function retrieveByName($name)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(self::NAME, $name);
|
||||
|
||||
return self::doSelectOne($c);
|
||||
}
|
||||
}
|
||||
20
plugins/sfGuardPlugin/lib/model/sfGuardRememberKey.php
Normal file
20
plugins/sfGuardPlugin/lib/model/sfGuardRememberKey.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardRememberKey.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardRememberKey extends BasesfGuardRememberKey
|
||||
{
|
||||
}
|
||||
20
plugins/sfGuardPlugin/lib/model/sfGuardRememberKeyPeer.php
Normal file
20
plugins/sfGuardPlugin/lib/model/sfGuardRememberKeyPeer.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardRememberKeyPeer.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardRememberKeyPeer extends BasesfGuardRememberKeyPeer
|
||||
{
|
||||
}
|
||||
479
plugins/sfGuardPlugin/lib/model/sfGuardUser.php
Normal file
479
plugins/sfGuardPlugin/lib/model/sfGuardUser.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardUser.php 5064 2009-02-19 14:57:15Z bartek $
|
||||
*/
|
||||
class sfGuardUser extends BasesfGuardUser
|
||||
{
|
||||
protected
|
||||
$profile = null,
|
||||
$groups = null,
|
||||
$permissions = null,
|
||||
$allPermissions = null,
|
||||
$modulePermissions = null;
|
||||
|
||||
/**
|
||||
* Rabat ogólny
|
||||
*
|
||||
* @var DiscountUser
|
||||
*/
|
||||
protected $generalDiscount = null;
|
||||
|
||||
/**
|
||||
* Domyślne dane bilingowe
|
||||
*
|
||||
* @var UserData
|
||||
*/
|
||||
protected $defaultUserBillingData = null;
|
||||
|
||||
/**
|
||||
* Domyślne dane dostawy
|
||||
*
|
||||
* @var UserData
|
||||
*/
|
||||
protected $defaultUserDeliveryData = null;
|
||||
|
||||
|
||||
public function getAdminGeneratorTitle()
|
||||
{
|
||||
return $this->getUsername();
|
||||
}
|
||||
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getUsername();
|
||||
}
|
||||
|
||||
public function setPassword($password)
|
||||
{
|
||||
if (!$password && 0 == strlen($password))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$salt = $this->getSalt())
|
||||
{
|
||||
$salt = md5(rand(100000, 999999) . $this->getUsername());
|
||||
$this->setSalt($salt);
|
||||
}
|
||||
$algorithm = sfConfig::get('app_sf_guard_plugin_algorithm_callable', 'sha1');
|
||||
$algorithmAsStr = is_array($algorithm) ? $algorithm[0] . '::' . $algorithm[1] : $algorithm;
|
||||
if (!is_callable($algorithm))
|
||||
{
|
||||
throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithmAsStr));
|
||||
}
|
||||
$this->setAlgorithm($algorithmAsStr);
|
||||
|
||||
parent::setPassword(call_user_func_array($algorithm, array($salt . $password)));
|
||||
}
|
||||
|
||||
public function setPasswordBis($password)
|
||||
{
|
||||
}
|
||||
|
||||
public function checkPassword($password)
|
||||
{
|
||||
if ($callable = sfConfig::get('app_sf_guard_plugin_check_password_callable'))
|
||||
{
|
||||
return call_user_func_array($callable, array($this->getUsername(), $password, $this));
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->checkPasswordByGuard($password);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkPasswordByGuard($password)
|
||||
{
|
||||
$algorithm = $this->getAlgorithm();
|
||||
if (false !== $pos = strpos($algorithm, '::'))
|
||||
{
|
||||
$algorithm = array(substr($algorithm, 0, $pos), substr($algorithm, $pos + 2));
|
||||
}
|
||||
if (!is_callable($algorithm))
|
||||
{
|
||||
throw new sfException(sprintf('The algorithm callable "%s" is not callable.', $algorithm));
|
||||
}
|
||||
|
||||
return $this->getPassword() == call_user_func_array($algorithm, array($this->getSalt() . $password));
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
{
|
||||
if (!is_null($this->profile))
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
|
||||
$profileClass = sfConfig::get('app_sf_guard_plugin_profile_class', 'sfGuardUserProfile');
|
||||
if (!class_exists($profileClass))
|
||||
{
|
||||
throw new sfException(sprintf('The user profile class "%s" does not exist.', $profileClass));
|
||||
}
|
||||
|
||||
$fieldName = sfConfig::get('app_sf_guard_plugin_profile_field_name', 'user_id');
|
||||
$profilePeerClass = $profileClass . 'Peer';
|
||||
|
||||
// to avoid php segmentation fault
|
||||
class_exists($profilePeerClass);
|
||||
|
||||
$foreignKeyColumn = call_user_func_array(array($profilePeerClass, 'translateFieldName'), array($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME));
|
||||
|
||||
if (!$foreignKeyColumn)
|
||||
{
|
||||
throw new sfException(sprintf('The user profile class "%s" does not contain a "%s" column.', $profileClass, $fieldName));
|
||||
}
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add($foreignKeyColumn, $this->getId());
|
||||
|
||||
$this->profile = call_user_func_array(array($profileClass . 'Peer', 'doSelectOne'), array($c));
|
||||
|
||||
if (!$this->profile)
|
||||
{
|
||||
$this->profile = new $profileClass();
|
||||
if (method_exists($this->profile, 'setsfGuardUser'))
|
||||
{
|
||||
$this->profile->setsfGuardUser($this);
|
||||
}
|
||||
else
|
||||
{
|
||||
$method = 'set' . call_user_func_array(array($profilePeerClass, 'translateFieldName'), array($fieldName, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME));
|
||||
$this->profile->$method($this->getId());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->profile;
|
||||
}
|
||||
|
||||
public function addGroupByName($name, $con = null)
|
||||
{
|
||||
$group = sfGuardGroupPeer::retrieveByName($name);
|
||||
if (!$group)
|
||||
{
|
||||
throw new Exception(sprintf('The group "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
$ug = new sfGuardUserGroup();
|
||||
$ug->setsfGuardUser($this);
|
||||
$ug->setGroupId($group->getId());
|
||||
|
||||
$ug->save($con);
|
||||
}
|
||||
|
||||
public function addPermissionByName($name, $con = null)
|
||||
{
|
||||
$permission = sfGuardPermissionPeer::retrieveByName($name);
|
||||
if (!$permission)
|
||||
{
|
||||
throw new Exception(sprintf('The permission "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
$up = new sfGuardUserPermission();
|
||||
$up->setsfGuardUser($this);
|
||||
$up->setPermissionId($permission->getId());
|
||||
|
||||
$up->save($con);
|
||||
}
|
||||
|
||||
public function hasGroup($name)
|
||||
{
|
||||
if (!$this->groups)
|
||||
{
|
||||
$this->getGroups();
|
||||
}
|
||||
|
||||
return isset($this->groups[$name]);
|
||||
}
|
||||
|
||||
public function getGroups()
|
||||
{
|
||||
if (!$this->groups)
|
||||
{
|
||||
$this->groups = array();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(sfGuardUserGroupPeer::USER_ID, $this->getId());
|
||||
$ugs = sfGuardUserGroupPeer::doSelectJoinsfGuardGroup($c);
|
||||
|
||||
foreach ($ugs as $ug)
|
||||
{
|
||||
$group = $ug->getsfGuardGroup();
|
||||
$this->groups[$group->getName()] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->groups;
|
||||
}
|
||||
|
||||
public function getGroupNames()
|
||||
{
|
||||
return array_keys($this->getGroups());
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca rabat ogólny
|
||||
* @return DiscountUser|false
|
||||
*/
|
||||
public function getGeneralDiscount()
|
||||
{
|
||||
if (null === $this->generalDiscount)
|
||||
{
|
||||
$discounts = $this->getDiscountUsers();
|
||||
|
||||
$this->generalDiscount = $discounts ? $discounts[0] : false;
|
||||
}
|
||||
|
||||
return $this->generalDiscount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia wartość rabatu ogólnego
|
||||
*
|
||||
* @param float $v
|
||||
* @return void
|
||||
*/
|
||||
public function setGeneralDiscountValue($v)
|
||||
{
|
||||
$discount = $this->getGeneralDiscount();
|
||||
|
||||
if (!$discount)
|
||||
{
|
||||
$discount = new DiscountUser();
|
||||
$this->addDiscountUser($discount);
|
||||
$this->generalDiscount = $discount;
|
||||
}
|
||||
|
||||
$discount->setDiscount($v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca wartość rabatu ogólnego
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getGeneralDiscountValue()
|
||||
{
|
||||
return $this->getGeneralDiscount() ? $this->getGeneralDiscount()->getDiscount() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca domyślne dane bilingowe
|
||||
*
|
||||
* @return UserData|false
|
||||
*/
|
||||
public function getDefaultUserBillingData()
|
||||
{
|
||||
if (null === $this->defaultUserBillingData)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(UserDataPeer::IS_BILLING, true);
|
||||
$c->add(UserDataPeer::IS_DEFAULT, true);
|
||||
$c->setLimit(1);
|
||||
$data = $this->getUserDatas($c);
|
||||
|
||||
$this->defaultUserBillingData = $data ? $data[0] : false;
|
||||
}
|
||||
|
||||
return $this->defaultUserBillingData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca domyślne dane dostawy
|
||||
*
|
||||
* @return UserData|false
|
||||
*/
|
||||
public function getDefaultUserDeliveryData()
|
||||
{
|
||||
if (null === $this->defaultUserDeliveryData)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(UserDataPeer::IS_BILLING, false);
|
||||
$c->add(UserDataPeer::IS_DEFAULT, true);
|
||||
$c->setLimit(1);
|
||||
$data = $this->getUserDatas($c);
|
||||
|
||||
$this->defaultUserDeliveryData = $data ? $data[0] : false;
|
||||
}
|
||||
|
||||
return $this->defaultUserDeliveryData;
|
||||
}
|
||||
|
||||
public function hasPermission($name)
|
||||
{
|
||||
if (!$this->permissions)
|
||||
{
|
||||
$this->getPermissions();
|
||||
}
|
||||
|
||||
return isset($this->permissions[$name]);
|
||||
}
|
||||
|
||||
public function getPermissions()
|
||||
{
|
||||
if (!$this->permissions)
|
||||
{
|
||||
$this->permissions = array();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(sfGuardUserPermissionPeer::USER_ID, $this->getId());
|
||||
$ups = sfGuardUserPermissionPeer::doSelectJoinsfGuardPermission($c);
|
||||
|
||||
foreach ($ups as $up)
|
||||
{
|
||||
$permission = $up->getsfGuardPermission();
|
||||
$this->permissions[$permission->getName()] = $permission;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
public function getModulePermissionNames()
|
||||
{
|
||||
if (null === $this->modulePermissions)
|
||||
{
|
||||
$permission = sfGuardUserModulePermissionPeer::retrieveByPK($this->getId());
|
||||
|
||||
$permissions = $permission ? $permission->getPermissions() : array();
|
||||
|
||||
if (!$permissions)
|
||||
{
|
||||
$permissions = array();
|
||||
}
|
||||
|
||||
foreach (sfGuardUserGroupPeer::doSelectModulePermissionsByUser($this) as $permission)
|
||||
{
|
||||
$permissions = array_merge($permissions, $permission->getPermissions());
|
||||
}
|
||||
|
||||
$permissions[] = 'sfGuardUser.modification';
|
||||
|
||||
$this->modulePermissions = $permissions;
|
||||
}
|
||||
|
||||
|
||||
return $this->modulePermissions;
|
||||
}
|
||||
|
||||
public function hasModulePermission($name)
|
||||
{
|
||||
if (!$this->modulePermissions)
|
||||
{
|
||||
$this->getModulePermissionNames();
|
||||
}
|
||||
|
||||
return in_array($name, $this->modulePermissions);
|
||||
}
|
||||
|
||||
public function getPermissionNames()
|
||||
{
|
||||
return array_keys($this->getPermissions());
|
||||
}
|
||||
|
||||
// merge of permission in a group + permissions
|
||||
public function getAllPermissions()
|
||||
{
|
||||
if (!$this->allPermissions)
|
||||
{
|
||||
$this->allPermissions = $this->getPermissions();
|
||||
|
||||
foreach (sfGuardUserGroupPeer::doSelectPermissionsByUser($this) as $permission)
|
||||
{
|
||||
$this->allPermissions[$permission->getName()] = $permission;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->allPermissions;
|
||||
}
|
||||
|
||||
public function getAllPermissionNames()
|
||||
{
|
||||
return array_keys($this->getAllPermissions());
|
||||
}
|
||||
|
||||
public function reloadGroupsAndPermissions()
|
||||
{
|
||||
$this->groups = null;
|
||||
$this->permissions = null;
|
||||
$this->allPermissions = null;
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
// delete profile if available
|
||||
try
|
||||
{
|
||||
if ($profile = $this->getProfile())
|
||||
{
|
||||
$profile->delete();
|
||||
}
|
||||
}
|
||||
catch (sfException $e)
|
||||
{
|
||||
}
|
||||
|
||||
$ret = parent::delete();
|
||||
|
||||
self::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function setPasswordHash($v)
|
||||
{
|
||||
if (!is_null($v) && !is_string($v))
|
||||
{
|
||||
$v = (string)$v;
|
||||
}
|
||||
|
||||
if ($this->password !== $v)
|
||||
{
|
||||
$this->password = $v;
|
||||
$this->modifiedColumns[] = sfGuardUserPeer::PASSWORD;
|
||||
}
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isNew() && !$this->isColumnModified(sfGuardUserPeer::IS_CONFIRM))
|
||||
{
|
||||
$this->setIsConfirm(false);
|
||||
}
|
||||
|
||||
if ($this->getHashCode() == "")
|
||||
{
|
||||
$this->setHashCode(md5(microtime()));
|
||||
}
|
||||
|
||||
if ($this->isColumnModified(sfGuardUserPeer::PASSWORD))
|
||||
{
|
||||
$this->setLastPasswordChange(time());
|
||||
}
|
||||
|
||||
$ret = parent::save($con);
|
||||
|
||||
self::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function clearCache()
|
||||
{
|
||||
$fc = stFunctionCache::getInstance('sfGuardUser');
|
||||
$fc->removeAll();
|
||||
}
|
||||
}
|
||||
39
plugins/sfGuardPlugin/lib/model/sfGuardUserGroup.php
Normal file
39
plugins/sfGuardPlugin/lib/model/sfGuardUserGroup.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardUserGroup.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardUserGroup extends BasesfGuardUserGroup
|
||||
{
|
||||
public function save($con = null)
|
||||
{
|
||||
$ret = parent::save($con);
|
||||
|
||||
$this->getsfGuardUser($con)->reloadGroupsAndPermissions();
|
||||
|
||||
sfGuardUser::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$ret = parent::delete($con);
|
||||
|
||||
sfGuardUser::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
52
plugins/sfGuardPlugin/lib/model/sfGuardUserGroupPeer.php
Normal file
52
plugins/sfGuardPlugin/lib/model/sfGuardUserGroupPeer.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardUserGroupPeer.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardUserGroupPeer extends BasesfGuardUserGroupPeer
|
||||
{
|
||||
/**
|
||||
* Zwraca listę zezwoleń dla danego użytkownika
|
||||
*
|
||||
* @param sfGuardUser $user
|
||||
* @return sfGuardPermission[]
|
||||
* @throws PropelException
|
||||
*/
|
||||
public static function doSelectPermissionsByUser(sfGuardUser $user)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addJoin(sfGuardPermissionPeer::ID, sfGuardGroupPermissionPeer::PERMISSION_ID);
|
||||
$c->addJoin(sfGuardGroupPermissionPeer::GROUP_ID, self::GROUP_ID);
|
||||
$c->add(self::USER_ID, $user->getId());
|
||||
|
||||
return sfGuardPermissionPeer::doSelect($c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca listę zezwoleń modułów dla danego użytkownika
|
||||
*
|
||||
* @param sfGuardUser $user
|
||||
* @return sfGuardGroupModulePermission[]
|
||||
* @throws PropelException
|
||||
*/
|
||||
public static function doSelectModulePermissionsByUser(sfGuardUser $user)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addJoin(sfGuardGroupModulePermissionPeer::ID, self::GROUP_ID);
|
||||
$c->add(self::USER_ID, $user->getId());
|
||||
|
||||
return sfGuardGroupModulePermissionPeer::doSelect($c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'sf_guard_user_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model
|
||||
*/
|
||||
class sfGuardUserModulePermission extends BasesfGuardUserModulePermission
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'sf_guard_user_module_permission' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.sfGuardPlugin.lib.model
|
||||
*/
|
||||
class sfGuardUserModulePermissionPeer extends BasesfGuardUserModulePermissionPeer
|
||||
{
|
||||
}
|
||||
52
plugins/sfGuardPlugin/lib/model/sfGuardUserPeer.php
Normal file
52
plugins/sfGuardPlugin/lib/model/sfGuardUserPeer.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardUserPeer.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardUserPeer extends BasesfGuardUserPeer
|
||||
{
|
||||
public static function retrieveByUsername($username, $isActive = true)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(self::USERNAME, $username);
|
||||
$c->add(self::IS_ACTIVE, $isActive);
|
||||
|
||||
return self::doSelectOne($c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tworzy nową instancję modelu użytkownika i ustawia go jako anonymowego
|
||||
* Użytkownik nie jest zapisywany do bazy i wymaga wywołania sfGuardUser::save()
|
||||
*
|
||||
* @param string $username Nazwa użytkownika/email
|
||||
* @return sfGuardUser|null
|
||||
* @throws sfException
|
||||
* @throws sfException
|
||||
* @throws PropelException
|
||||
*/
|
||||
public static function createAnonymous($username)
|
||||
{
|
||||
$user = new sfGuardUser();
|
||||
$user->setUsername($username);
|
||||
$user->setPassword('anonymous');
|
||||
$user->setHashCode(md5(microtime()));
|
||||
$group = sfGuardGroupPeer::retrieveByName('user');
|
||||
$guardUserGroup = new sfGuardUserGroup();
|
||||
$guardUserGroup->setGroupId($group->getId());
|
||||
$user->addsfGuardUserGroup($guardUserGroup);
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
39
plugins/sfGuardPlugin/lib/model/sfGuardUserPermission.php
Normal file
39
plugins/sfGuardPlugin/lib/model/sfGuardUserPermission.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardUserPermission.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardUserPermission extends BasesfGuardUserPermission
|
||||
{
|
||||
public function save($con = null)
|
||||
{
|
||||
$ret = parent::save($con);
|
||||
|
||||
$this->getsfGuardUser($con)->reloadGroupsAndPermissions();
|
||||
|
||||
sfGuardUser::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$ret = parent::delete($con);
|
||||
|
||||
sfGuardUser::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardUserPermissionPeer.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardUserPermissionPeer extends BasesfGuardUserPermissionPeer
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardBasicSecurityFilter.class.php 4 2008-09-24 08:40:58Z marek $
|
||||
*/
|
||||
class sfGuardBasicSecurityFilter extends sfBasicSecurityFilter
|
||||
{
|
||||
public function execute ($filterChain)
|
||||
{
|
||||
if ($this->isFirstCall() and !$this->getContext()->getUser()->isAuthenticated())
|
||||
{
|
||||
if ($cookie = $this->getContext()->getRequest()->getCookie(sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember')))
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(sfGuardRememberKeyPeer::REMEMBER_KEY, $cookie);
|
||||
$rk = sfGuardRememberKeyPeer::doSelectOne($c);
|
||||
if ($rk && $rk->getSfGuardUser())
|
||||
{
|
||||
$this->getContext()->getUser()->signIn($rk->getSfGuardUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::execute($filterChain);
|
||||
}
|
||||
}
|
||||
291
plugins/sfGuardPlugin/lib/user/sfGuardSecurityUser.class.php
Normal file
291
plugins/sfGuardPlugin/lib/user/sfGuardSecurityUser.class.php
Normal file
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardSecurityUser.class.php 2310 2008-11-25 14:11:23Z michal $
|
||||
*/
|
||||
class sfGuardSecurityUser extends sfBasicSecurityUser
|
||||
{
|
||||
|
||||
private $user = null;
|
||||
|
||||
|
||||
public function isAuthenticated()
|
||||
{
|
||||
if ($this->authenticated && null !== $this->getGuardUser() && $this->getLastPasswordChange() < $this->getGuardUser()->getLastPasswordChange())
|
||||
{
|
||||
$this->signOut();
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->authenticated;
|
||||
}
|
||||
|
||||
public function hasCredential($credential, $useAnd = true)
|
||||
{
|
||||
if ($this->getAttribute('super_admin', false, 'sfGuardSecurityUser'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::hasCredential($credential, $useAnd);
|
||||
}
|
||||
|
||||
public function isSuperAdmin()
|
||||
{
|
||||
return $this->getAttribute('super_admin', false, 'sfGuardSecurityUser');
|
||||
}
|
||||
|
||||
public function isAnonymous()
|
||||
{
|
||||
return!$this->isAuthenticated();
|
||||
}
|
||||
|
||||
|
||||
public function getLastPasswordChange()
|
||||
{
|
||||
return $this->getAttribute('last_password_change', null, 'sfGuardSecurityUser');
|
||||
}
|
||||
|
||||
public function updateLastPasswordChange()
|
||||
{
|
||||
$this->setAttribute('last_password_change', null !== $this->getGuardUser() ? $this->getGuardUser()->getLastPasswordChange() : null, 'sfGuardSecurityUser');
|
||||
}
|
||||
|
||||
public function getLastLogin()
|
||||
{
|
||||
return $this->getAttribute('last_login', $this->getGuardUser() ? $this->getGuardUser()->getLastLogin() : null, 'sfGuardSecurityUser');
|
||||
}
|
||||
|
||||
public function getGuardUserId()
|
||||
{
|
||||
return $this->isAuthenticated() ? $this->getAttribute('id', null, 'sfGuardSecurityUser') : null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sfGuardUser $user
|
||||
* @param bool $remember
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function signIn($user, $remember = false, $con = null)
|
||||
{
|
||||
// disable Fast Cache for this session if user is authenticated
|
||||
if (SF_APP == 'frontend')
|
||||
{
|
||||
stFastCacheController::disable();
|
||||
}
|
||||
|
||||
$this->setAttribute('last_login', $user->getLastLogin(), 'sfGuardSecurityUser');
|
||||
|
||||
// signin
|
||||
$this->setAttribute('user_id', $user->getId(), 'sfGuardSecurityUser');
|
||||
$this->setAttribute('super_admin', $user->getIsSuperAdmin(), 'sfGuardSecurityUser');
|
||||
$this->setAttribute('username', $user->getUsername(), 'sfGuardSecurityUser');
|
||||
$this->setAttribute('last_password_change', $user->getLastPasswordChange(), 'sfGuardSecurityUser');
|
||||
$this->setAttribute('id', $user->getId(), 'sfGuardSecurityUser');
|
||||
$this->setAuthenticated(true);
|
||||
$this->clearCredentials();
|
||||
$this->addCredentials($user->getAllPermissionNames());
|
||||
$this->addCredentials($user->getModulePermissionNames());
|
||||
|
||||
// stLanguage
|
||||
$userLanguage = $user->getLanguage();
|
||||
|
||||
if (!empty($userLanguage))
|
||||
{
|
||||
// $language = LanguagePeer::retrieveByCulture($userLanguage);
|
||||
// if (is_object($language) && $language->getActive()) $this->setCulture($userLanguage);
|
||||
}
|
||||
else
|
||||
{
|
||||
$user->setLanguage($this->getCulture());
|
||||
$user->save($con);
|
||||
}
|
||||
|
||||
// save last login
|
||||
$user->setLastLogin(time());
|
||||
$user->save($con);
|
||||
|
||||
// remember?
|
||||
if ($remember)
|
||||
{
|
||||
// remove old keys
|
||||
$c = new Criteria();
|
||||
$expiration_age = sfConfig::get('app_sf_guard_plugin_remember_key_expiration_age', 15 * 24 * 3600);
|
||||
$c->add(sfGuardRememberKeyPeer::CREATED_AT, time() - $expiration_age, Criteria::LESS_THAN);
|
||||
sfGuardRememberKeyPeer::doDelete($c);
|
||||
|
||||
// remove other keys from this user
|
||||
$c = new Criteria();
|
||||
$c->add(sfGuardRememberKeyPeer::USER_ID, $user->getId());
|
||||
sfGuardRememberKeyPeer::doDelete($c);
|
||||
|
||||
// generate new keys
|
||||
$key = $this->generateRandomKey();
|
||||
|
||||
// save key
|
||||
$rk = new sfGuardRememberKey();
|
||||
$rk->setRememberKey($key);
|
||||
$rk->setSfGuardUser($user);
|
||||
$rk->setIpAddress($_SERVER['REMOTE_ADDR']);
|
||||
$rk->save($con);
|
||||
|
||||
// make key as a cookie
|
||||
$remember_cookie = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember');
|
||||
sfContext::getInstance()->getResponse()->setCookie($remember_cookie, $key, time() + $expiration_age);
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateRandomKey($len = 20)
|
||||
{
|
||||
$string = '';
|
||||
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
for ($i = 1; $i <= $len; $i++)
|
||||
{
|
||||
$string .= substr($pool, rand(0, 61), 1);
|
||||
}
|
||||
|
||||
return md5($string);
|
||||
}
|
||||
|
||||
public function signOut()
|
||||
{
|
||||
$this->getAttributeHolder()->removeNamespace('sfGuardSecurityUser');
|
||||
$this->user = null;
|
||||
$this->clearCredentials();
|
||||
$this->setAuthenticated(false);
|
||||
$expiration_age = sfConfig::get('app_sf_guard_plugin_remember_key_expiration_age', 15 * 24 * 3600);
|
||||
$remember_cookie = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember');
|
||||
sfContext::getInstance()->getResponse()->setCookie($remember_cookie, '', time() - $expiration_age);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return sfGuardUser
|
||||
* @throws PropelException
|
||||
* @throws sfException
|
||||
*/
|
||||
public function getGuardUser()
|
||||
{
|
||||
if (!$this->user && $id = $this->getAttribute('user_id', null, 'sfGuardSecurityUser'))
|
||||
{
|
||||
$this->user = sfGuardUserPeer::retrieveByPk($id);
|
||||
|
||||
if (!$this->user)
|
||||
{
|
||||
// the user does not exist anymore in the database
|
||||
$this->signOut();
|
||||
|
||||
throw new sfException('The user does not exist anymore in the database.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
// add some proxy method to the sfGuardUser instance
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getGuardUser()->__toString();
|
||||
}
|
||||
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->isAuthenticated() ? $this->getAttribute('username', null, 'sfGuardSecurityUser') : null;
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->getGuardUser()->getEmail();
|
||||
}
|
||||
|
||||
public function setPassword($password, $con = null)
|
||||
{
|
||||
$this->getGuardUser()->setPassword($password);
|
||||
$this->getGuardUser()->save($con);
|
||||
|
||||
$this->updateLastPasswordChange();
|
||||
}
|
||||
|
||||
public function setEmail($email, $con = null)
|
||||
{
|
||||
$this->getGuardUser()->setUsername($email);
|
||||
$this->getGuardUser()->save($con);
|
||||
}
|
||||
|
||||
public function checkPassword($password)
|
||||
{
|
||||
return $this->getGuardUser()->checkPassword($password);
|
||||
}
|
||||
|
||||
public function hasGroup($name)
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->hasGroup($name) : false;
|
||||
}
|
||||
|
||||
public function getGroups()
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->getGroups() : array();
|
||||
}
|
||||
|
||||
public function getGroupNames()
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->getGroupNames() : array();
|
||||
}
|
||||
|
||||
public function hasPermission($name)
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->hasPermission($name) : false;
|
||||
}
|
||||
|
||||
public function getPermissions()
|
||||
{
|
||||
return $this->getGuardUser()->getPermissions();
|
||||
}
|
||||
|
||||
public function getPermissionNames()
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->getPermissionNames() : array();
|
||||
}
|
||||
|
||||
public function getAllPermissions()
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->getAllPermissions() : array();
|
||||
}
|
||||
|
||||
public function getAllPermissionNames()
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->getAllPermissionNames() : array();
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->getGuardUser() ? $this->getGuardUser()->getProfile() : null;
|
||||
}
|
||||
|
||||
public function addGroupByName($name, $con = null)
|
||||
{
|
||||
return $this->getGuardUser()->addGroupByName($name, $con);
|
||||
}
|
||||
|
||||
public function addPermissionByName($name, $con = null)
|
||||
{
|
||||
return $this->getGuardUser()->addPermissionByName($name, $con);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package symfony
|
||||
* @subpackage plugin
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
* @version SVN: $Id: sfGuardUserValidator.class.php 4820 2009-02-10 10:47:45Z bartek $
|
||||
*/
|
||||
class sfGuardUserValidator extends sfValidator
|
||||
{
|
||||
public function initialize($context, $parameters = null)
|
||||
{
|
||||
// initialize parent
|
||||
parent::initialize($context);
|
||||
|
||||
// set defaults
|
||||
$this->getParameterHolder()->set('license_error', 'Wystąpił problem z licencją.');
|
||||
$this->getParameterHolder()->set('license_day_error', 'Licencja straciła ważność');
|
||||
$this->getParameterHolder()->set('username_error', 'Username or password is not valid.');
|
||||
$this->getParameterHolder()->set('password_field', 'password');
|
||||
$this->getParameterHolder()->set('remember_field', 'remember');
|
||||
|
||||
|
||||
$this->getParameterHolder()->add($parameters);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function execute(&$value, &$error)
|
||||
{
|
||||
$password_field = $this->getParameterHolder()->get('password_field');
|
||||
$password = $this->getContext()->getRequest()->getParameter($password_field);
|
||||
|
||||
$remember = false;
|
||||
$remember_field = $this->getParameterHolder()->get('remember_field');
|
||||
$remember = $this->getContext()->getRequest()->getParameter($remember_field);
|
||||
|
||||
$this->config = stConfig::getInstance($this->getContext(), "stRegister");
|
||||
|
||||
$register = $this->config->load();
|
||||
|
||||
if(empty($register['license']))
|
||||
{
|
||||
$error = $this->getParameterHolder()->get('license_error');
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$stLicense = new stLicense($register['license']);
|
||||
|
||||
if(!$stLicense->check())
|
||||
{
|
||||
$error = $this->getParameterHolder()->get('license_error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if($stLicense->checkLicenseDate()==0)
|
||||
{
|
||||
$error = $this->getParameterHolder()->get('license_day_error');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$username = $value;
|
||||
|
||||
$user = sfGuardUserPeer::retrieveByUsername($username);
|
||||
|
||||
// user exists?
|
||||
if ($user)
|
||||
{
|
||||
// password is ok?
|
||||
if ($user->checkPassword($password) && $user->hasGroup('admin'))
|
||||
{
|
||||
$this->getContext()->getUser()->signIn($user, $remember);
|
||||
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($user, 'sfGuardUser.signedIn'));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$error = $this->getParameterHolder()->get('username_error');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user