first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
<?php
/**
* SOTESHOP/stMailPlugin
*
* Ten plik należy do aplikacji stMailPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stMailPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: MailAccount.php 2947 2010-01-08 15:11:27Z marcin $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
* Klasa MailAccount
*
* @package stMailPlugin
* @subpackage libs
*/
class MailAccount extends BaseMailAccount
{
public function hydrate(\ResultSet $rs, $startcol = 1)
{
$result = parent::hydrate($rs, $startcol);
$crypt = Crypt::getInstance();
if ($this->version >= 2 || $crypt->isEncrypted($this->crypt))
{
$this->password = $crypt->Decrypt($this->password, $this->crypt);
}
return $result;
}
public function save($con = null)
{
$updateNotification = $this->isModified();
if ($this->getIsDefault() && $this->isColumnModified(MailAccountPeer::IS_DEFAULT))
{
$sc = new Criteria();
$sc->add(MailAccountPeer::ID, $this->getId(), Criteria::NOT_EQUAL);
$uc = new Criteria();
$uc->add(MailAccountPeer::IS_DEFAULT, false);
$con = Propel::getConnection();
BasePeer::doUpdate($sc, $uc, $con);
}
if ($this->getIsNewsletter() && $this->isColumnModified(MailAccountPeer::IS_DEFAULT))
{
$sc = new Criteria();
$sc->add(MailAccountPeer::ID, $this->getId(), Criteria::NOT_EQUAL);
$uc = new Criteria();
$uc->add(MailAccountPeer::IS_NEWSLETTER, false);
$con = Propel::getConnection();
BasePeer::doUpdate($sc, $uc, $con);
}
$crypt = Crypt::getInstance();
if ($this->isModified(MailAccountPeer::PASSWORD) || $this->version < 2 || !$crypt->isEncrypted($this->crypt))
{
$this->setPassword($crypt->Encrypt($this->getPassword()));
$this->setCrypt(Crypt::VERSION);
$this->setVersion(2);
}
$result = parent::save($con);
if ($updateNotification)
{
stMailer::getInstance()->validateAccountConfiguration();
}
return $result;
}
public function delete($con = null)
{
$result = parent::delete($con);
stMailer::getInstance()->validateAccountConfiguration();
return $result;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* SOTESHOP/stMailPlugin
*
* Ten plik należy do aplikacji stMailPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stMailPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: MailAccountPeer.php 1209 2009-10-07 12:35:55Z marcin $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
* Klasa MailAccountPeer
*
* @package stMailPlugin
* @subpackage libs
*/
class MailAccountPeer extends BaseMailAccountPeer
{
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* Subclass for representing a row from the 'st_mail_description' table.
*
*
*
* @package plugins.stMailPlugin.lib.model
*/
class MailDescription extends BaseMailDescription
{
/**
* Przeciążenie hydrate
*
* @param ResultSet $rs
* @param int $startcol
* @return object
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
$this->setCulture(stLanguage::getHydrateCulture());
return parent::hydrate($rs, $startcol);
}
/**
* Przeciążenie getDescription
*
* @return string
*/
public function getDescription()
{
if ($this->getCulture() == stLanguage::getOptLanguage()) return stLanguage::getDefaultValue($this, __METHOD__);
$v = parent::getDescription();
if (is_null($v)) $v = stLanguage::getDefaultValue($this, __METHOD__);
return $v;
}
/**
* Przeciążenie setName
*
* @param string $v
*/
public function setDescription($v)
{
if ($this->getCulture() == stLanguage::getOptLanguage()) stLanguage::setDefaultValue($this, __METHOD__, $v);
parent::setDescription($v);
}
/**
* Przeciążenie getName
*
* @return string
*/
public function getName()
{
if ($this->getCulture() == stLanguage::getOptLanguage()) return stLanguage::getDefaultValue($this, __METHOD__);
$v = parent::getName();
if (is_null($v)) $v = stLanguage::getDefaultValue($this, __METHOD__);
return $v;
}
/**
* Przeciążenie setName
*
* @param string $v
*/
public function setName($v)
{
if ($this->getCulture() == stLanguage::getOptLanguage()) stLanguage::setDefaultValue($this, __METHOD__, $v);
parent::setName($v);
}
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for representing a row from the 'st_mail_description_i18n' table.
*
*
*
* @package plugins.stMailPlugin.lib.model
*/
class MailDescriptionI18n extends BaseMailDescriptionI18n
{
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_mail_description_i18n' table.
*
*
*
* @package plugins.stMailPlugin.lib.model
*/
class MailDescriptionI18nPeer extends BaseMailDescriptionI18nPeer
{
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_mail_description' table.
*
*
*
* @package plugins.stMailPlugin.lib.model
*/
class MailDescriptionPeer extends BaseMailDescriptionPeer
{
/**
* Przeciążenie metody pobierającej tekstów w odpowiedniej wersji jezykowej
*
* @param Criteria $c Kryteria
* @param mixed $culture Wersja językowa
* @param CreoleConnection $con Połączenie z bazą danych
* @return array Produkty
*/
public static function doSelectWithI18n(Criteria $c, $culture = null, $con = null)
{
if ($culture === null)
{
$culture = sfContext::getInstance()->getUser()->getCulture();
}
if ($c->getDbName() == Propel::getDefaultDB())
{
$c->setDbName(self::DATABASE_NAME);
}
MailDescriptionPeer::addSelectColumns($c);
$startcol = (MailDescriptionPeer::NUM_COLUMNS - MailDescriptionPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
MailDescriptionI18nPeer::addSelectColumns($c);
$c->addJoin(MailDescriptionPeer::ID, sprintf("%s AND %s = '%s'", MailDescriptionI18nPeer::ID, MailDescriptionI18nPeer::CULTURE, $culture), Criteria::LEFT_JOIN);
$rs = BasePeer::doSelect($c, $con);
$results = array();
while($rs->next())
{
$omClass = MailDescriptionPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
$obj1->setCulture($culture);
$omClass = MailDescriptionI18nPeer::getOMClass($rs, $startcol);
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol);
$obj1->setMailDescriptionI18nForCulture($obj2, $culture);
$obj2->setMailDescription($obj1);
$results[] = $obj1;
}
return $results;
}
public static function doCountWithI18n(Criteria $c, $con = null)
{
$c->addJoin(MailDescriptionI18nPeer::ID, MailDescriptionPeer::ID);
$c->add(MailDescriptionI18nPeer::CULTURE, sfContext::getInstance()->getUser()->getCulture());
return self::doCount($c, $con);
}
}

View File

@@ -0,0 +1,62 @@
<?php
/**
* SOTESHOP/stMailPlugin
*
* Ten plik należy do aplikacji stMailPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stMailPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: MailSmtpProfile.php 12178 2011-04-13 09:56:05Z marcin $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
* Klasa MailSmtpProfile
*
* @package stMailPlugin
* @subpackage libs
*/
class MailSmtpProfile extends BaseMailSmtpProfile
{
/**
* Zamienia id na nazwę
*
* @return string nazwa
*/
public function __toString()
{
return $this->getName();
}
/**
* Ustawia typ select'a
*
* @param string $v
*/
public function setEncTypeSelect($v)
{
$this->setEncType($v);
}
/**
* Pobiera typ select'a
*
* @return string
*/
public function getEncType()
{
$type = parent::getEncType();
$backward_type = array(2 => 'tls', 4 => 'ssl', 8 => null);
return array_key_exists($type, $backward_type) ? $backward_type[$type] : $type;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* SOTESHOP/stMailPlugin
*
* Ten plik należy do aplikacji stMailPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stMailPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: MailSmtpProfilePeer.php 1209 2009-10-07 12:35:55Z marcin $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
* Klasa MailSmtpProfilePeer
*
* @package stMailPlugin
* @subpackage libs
*/
class MailSmtpProfilePeer extends BaseMailSmtpProfilePeer
{
}

View File

@@ -0,0 +1,90 @@
<?php
/**
* This class adds structure of 'st_mail_account' 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.stMailPlugin.lib.model.map
*/
class MailAccountMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stMailPlugin.lib.model.map.MailAccountMapBuilder';
/**
* 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('st_mail_account');
$tMap->setPhpName('MailAccount');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('MAIL_SMTP_PROFILE_ID', 'MailSmtpProfileId', 'int', CreoleTypes::INTEGER, 'st_mail_smtp_profile', 'ID', true, null);
$tMap->addColumn('VERSION', 'Version', 'int', CreoleTypes::INTEGER, false, null);
$tMap->addColumn('USERNAME', 'Username', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addColumn('PASSWORD', 'Password', 'string', CreoleTypes::VARCHAR, false, 1024);
$tMap->addColumn('EMAIL', 'Email', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addColumn('IS_DEFAULT', 'IsDefault', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('IS_NEWSLETTER', 'IsNewsletter', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('CRYPT', 'Crypt', 'int', CreoleTypes::INTEGER, false, null);
} // doBuild()
} // MailAccountMapBuilder

View File

@@ -0,0 +1,74 @@
<?php
/**
* This class adds structure of 'st_mail_description_i18n' 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.stMailPlugin.lib.model.map
*/
class MailDescriptionI18nMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stMailPlugin.lib.model.map.MailDescriptionI18nMapBuilder';
/**
* 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('st_mail_description_i18n');
$tMap->setPhpName('MailDescriptionI18n');
$tMap->setUseIdGenerator(false);
$tMap->addForeignPrimaryKey('ID', 'Id', 'int' , CreoleTypes::INTEGER, 'st_mail_description', 'ID', true, null);
$tMap->addPrimaryKey('CULTURE', 'Culture', 'string', CreoleTypes::VARCHAR, true, 7);
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::LONGVARCHAR, false, null);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
} // doBuild()
} // MailDescriptionI18nMapBuilder

View File

@@ -0,0 +1,80 @@
<?php
/**
* This class adds structure of 'st_mail_description' 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.stMailPlugin.lib.model.map
*/
class MailDescriptionMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stMailPlugin.lib.model.map.MailDescriptionMapBuilder';
/**
* 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('st_mail_description');
$tMap->setPhpName('MailDescription');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('SYSTEM_NAME', 'SystemName', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('OPT_NAME', 'OptName', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('OPT_DESCRIPTION', 'OptDescription', 'string', CreoleTypes::LONGVARCHAR, false, null);
$tMap->addColumn('IS_ACTIVE', 'IsActive', 'boolean', CreoleTypes::BOOLEAN, false, null);
} // doBuild()
} // MailDescriptionMapBuilder

View File

@@ -0,0 +1,80 @@
<?php
/**
* This class adds structure of 'st_mail_smtp_profile' 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.stMailPlugin.lib.model.map
*/
class MailSmtpProfileMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stMailPlugin.lib.model.map.MailSmtpProfileMapBuilder';
/**
* 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('st_mail_smtp_profile');
$tMap->setPhpName('MailSmtpProfile');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addColumn('HOST', 'Host', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addColumn('PORT', 'Port', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('ENC_TYPE', 'EncType', 'string', CreoleTypes::VARCHAR, false, 7);
} // doBuild()
} // MailSmtpProfileMapBuilder

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,891 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_mail_account' table.
*
*
*
* @package plugins.stMailPlugin.lib.model.om
*/
abstract class BaseMailAccountPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_mail_account';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stMailPlugin.lib.model.MailAccount';
/** The total number of columns. */
const NUM_COLUMNS = 12;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the CREATED_AT field */
const CREATED_AT = 'st_mail_account.CREATED_AT';
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'st_mail_account.UPDATED_AT';
/** the column name for the ID field */
const ID = 'st_mail_account.ID';
/** the column name for the MAIL_SMTP_PROFILE_ID field */
const MAIL_SMTP_PROFILE_ID = 'st_mail_account.MAIL_SMTP_PROFILE_ID';
/** the column name for the VERSION field */
const VERSION = 'st_mail_account.VERSION';
/** the column name for the USERNAME field */
const USERNAME = 'st_mail_account.USERNAME';
/** the column name for the PASSWORD field */
const PASSWORD = 'st_mail_account.PASSWORD';
/** the column name for the EMAIL field */
const EMAIL = 'st_mail_account.EMAIL';
/** the column name for the IS_DEFAULT field */
const IS_DEFAULT = 'st_mail_account.IS_DEFAULT';
/** the column name for the IS_NEWSLETTER field */
const IS_NEWSLETTER = 'st_mail_account.IS_NEWSLETTER';
/** the column name for the NAME field */
const NAME = 'st_mail_account.NAME';
/** the column name for the CRYPT field */
const CRYPT = 'st_mail_account.CRYPT';
/** 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 ('CreatedAt', 'UpdatedAt', 'Id', 'MailSmtpProfileId', 'Version', 'Username', 'Password', 'Email', 'IsDefault', 'IsNewsletter', 'Name', 'Crypt', ),
BasePeer::TYPE_COLNAME => array (MailAccountPeer::CREATED_AT, MailAccountPeer::UPDATED_AT, MailAccountPeer::ID, MailAccountPeer::MAIL_SMTP_PROFILE_ID, MailAccountPeer::VERSION, MailAccountPeer::USERNAME, MailAccountPeer::PASSWORD, MailAccountPeer::EMAIL, MailAccountPeer::IS_DEFAULT, MailAccountPeer::IS_NEWSLETTER, MailAccountPeer::NAME, MailAccountPeer::CRYPT, ),
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'mail_smtp_profile_id', 'version', 'username', 'password', 'email', 'is_default', 'is_newsletter', 'name', 'crypt', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
/**
* 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 ('CreatedAt' => 0, 'UpdatedAt' => 1, 'Id' => 2, 'MailSmtpProfileId' => 3, 'Version' => 4, 'Username' => 5, 'Password' => 6, 'Email' => 7, 'IsDefault' => 8, 'IsNewsletter' => 9, 'Name' => 10, 'Crypt' => 11, ),
BasePeer::TYPE_COLNAME => array (MailAccountPeer::CREATED_AT => 0, MailAccountPeer::UPDATED_AT => 1, MailAccountPeer::ID => 2, MailAccountPeer::MAIL_SMTP_PROFILE_ID => 3, MailAccountPeer::VERSION => 4, MailAccountPeer::USERNAME => 5, MailAccountPeer::PASSWORD => 6, MailAccountPeer::EMAIL => 7, MailAccountPeer::IS_DEFAULT => 8, MailAccountPeer::IS_NEWSLETTER => 9, MailAccountPeer::NAME => 10, MailAccountPeer::CRYPT => 11, ),
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'mail_smtp_profile_id' => 3, 'version' => 4, 'username' => 5, 'password' => 6, 'email' => 7, 'is_default' => 8, 'is_newsletter' => 9, 'name' => 10, 'crypt' => 11, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
);
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.stMailPlugin.lib.model.map.MailAccountMapBuilder');
}
/**
* 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 = MailAccountPeer::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. MailAccountPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(MailAccountPeer::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(MailAccountPeer::CREATED_AT);
$criteria->addSelectColumn(MailAccountPeer::UPDATED_AT);
$criteria->addSelectColumn(MailAccountPeer::ID);
$criteria->addSelectColumn(MailAccountPeer::MAIL_SMTP_PROFILE_ID);
$criteria->addSelectColumn(MailAccountPeer::VERSION);
$criteria->addSelectColumn(MailAccountPeer::USERNAME);
$criteria->addSelectColumn(MailAccountPeer::PASSWORD);
$criteria->addSelectColumn(MailAccountPeer::EMAIL);
$criteria->addSelectColumn(MailAccountPeer::IS_DEFAULT);
$criteria->addSelectColumn(MailAccountPeer::IS_NEWSLETTER);
$criteria->addSelectColumn(MailAccountPeer::NAME);
$criteria->addSelectColumn(MailAccountPeer::CRYPT);
if (stEventDispatcher::getInstance()->getListeners('MailAccountPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'MailAccountPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_mail_account.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_mail_account.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(MailAccountPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailAccountPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = MailAccountPeer::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 MailAccount
* @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 = MailAccountPeer::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 MailAccount[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return MailAccountPeer::populateObjects(MailAccountPeer::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;
MailAccountPeer::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 = MailAccountPeer::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 MailSmtpProfile 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 doCountJoinMailSmtpProfile(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(MailAccountPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailAccountPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(MailAccountPeer::MAIL_SMTP_PROFILE_ID, MailSmtpProfilePeer::ID);
$rs = MailAccountPeer::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 MailAccount objects pre-filled with their MailSmtpProfile objects.
*
* @return MailAccount[] Array of MailAccount objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinMailSmtpProfile(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);
}
MailAccountPeer::addSelectColumns($c);
MailSmtpProfilePeer::addSelectColumns($c);
$c->addJoin(MailAccountPeer::MAIL_SMTP_PROFILE_ID, MailSmtpProfilePeer::ID);
$rs = MailAccountPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new MailAccount();
$startcol = $obj1->hydrate($rs);
if ($obj1->getMailSmtpProfileId())
{
$obj2 = new MailSmtpProfile();
$obj2->hydrate($rs, $startcol);
$obj2->addMailAccount($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(MailAccountPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailAccountPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(MailAccountPeer::MAIL_SMTP_PROFILE_ID, MailSmtpProfilePeer::ID);
$rs = MailAccountPeer::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 MailAccount objects pre-filled with all related objects.
*
* @return MailAccount[]
* @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);
}
MailAccountPeer::addSelectColumns($c);
$startcol2 = (MailAccountPeer::NUM_COLUMNS - MailAccountPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
MailSmtpProfilePeer::addSelectColumns($c);
$startcol3 = $startcol2 + MailSmtpProfilePeer::NUM_COLUMNS;
$c->addJoin(MailAccountPeer::MAIL_SMTP_PROFILE_ID, MailSmtpProfilePeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = MailAccountPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined MailSmtpProfile rows
$omClass = MailSmtpProfilePeer::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->getMailSmtpProfile(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addMailAccount($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initMailAccounts();
$obj2->addMailAccount($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 MailAccountPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a MailAccount or Criteria object.
*
* @param mixed $values Criteria or MailAccount 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('BaseMailAccountPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailAccountPeer', $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 MailAccount object
}
$criteria->remove(MailAccountPeer::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('BaseMailAccountPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseMailAccountPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a MailAccount or Criteria object.
*
* @param mixed $values Criteria or MailAccount 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('BaseMailAccountPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailAccountPeer', $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(MailAccountPeer::ID);
$selectCriteria->add(MailAccountPeer::ID, $criteria->remove(MailAccountPeer::ID), $comparison);
} else { // $values is MailAccount 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('BaseMailAccountPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseMailAccountPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_mail_account 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(MailAccountPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a MailAccount or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or MailAccount 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(MailAccountPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof MailAccount) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(MailAccountPeer::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 MailAccount 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 MailAccount $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(MailAccount $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(MailAccountPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(MailAccountPeer::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(MailAccountPeer::DATABASE_NAME, MailAccountPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = MailAccountPeer::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 MailAccount
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(MailAccountPeer::DATABASE_NAME);
$criteria->add(MailAccountPeer::ID, $pk);
$v = MailAccountPeer::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 MailAccount[]
*/
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(MailAccountPeer::ID, $pks, Criteria::IN);
$objs = MailAccountPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseMailAccountPeer
// 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 {
BaseMailAccountPeer::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.stMailPlugin.lib.model.map.MailAccountMapBuilder');
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,827 @@
<?php
/**
* Base class that represents a row from the 'st_mail_description_i18n' table.
*
*
*
* @package plugins.stMailPlugin.lib.model.om
*/
abstract class BaseMailDescriptionI18n extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the id field.
* @var int
*/
protected $id;
/**
* The value for the culture field.
* @var string
*/
protected $culture;
/**
* The value for the description field.
* @var string
*/
protected $description;
/**
* The value for the name field.
* @var string
*/
protected $name;
/**
* @var MailDescription
*/
protected $aMailDescription;
/**
* 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 [culture] column value.
*
* @return string
*/
public function getCulture()
{
return $this->culture;
}
/**
* Get the [description] column value.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Get the [name] column value.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* 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[] = MailDescriptionI18nPeer::ID;
}
if ($this->aMailDescription !== null && $this->aMailDescription->getId() !== $v) {
$this->aMailDescription = null;
}
} // setId()
/**
* Set the value of [culture] column.
*
* @param string $v new value
* @return void
*/
public function setCulture($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->culture !== $v) {
$this->culture = $v;
$this->modifiedColumns[] = MailDescriptionI18nPeer::CULTURE;
}
} // setCulture()
/**
* Set the value of [description] column.
*
* @param string $v new value
* @return void
*/
public function setDescription($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->description !== $v) {
$this->description = $v;
$this->modifiedColumns[] = MailDescriptionI18nPeer::DESCRIPTION;
}
} // setDescription()
/**
* Set the value of [name] column.
*
* @param string $v new value
* @return void
*/
public function setName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = MailDescriptionI18nPeer::NAME;
}
} // setName()
/**
* 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('MailDescriptionI18n.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'MailDescriptionI18n.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->id = $rs->getInt($startcol + 0);
$this->culture = $rs->getString($startcol + 1);
$this->description = $rs->getString($startcol + 2);
$this->name = $rs->getString($startcol + 3);
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('MailDescriptionI18n.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'MailDescriptionI18n.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 4)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 4; // 4 = MailDescriptionI18nPeer::NUM_COLUMNS - MailDescriptionI18nPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating MailDescriptionI18n 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('MailDescriptionI18n.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'MailDescriptionI18n.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseMailDescriptionI18n:delete:pre'))
{
foreach (sfMixer::getCallables('BaseMailDescriptionI18n:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(MailDescriptionI18nPeer::DATABASE_NAME);
}
try {
$con->begin();
MailDescriptionI18nPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('MailDescriptionI18n.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'MailDescriptionI18n.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseMailDescriptionI18n:delete:post'))
{
foreach (sfMixer::getCallables('BaseMailDescriptionI18n: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('MailDescriptionI18n.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'MailDescriptionI18n.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseMailDescriptionI18n:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($con === null) {
$con = Propel::getConnection(MailDescriptionI18nPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('MailDescriptionI18n.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'MailDescriptionI18n.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseMailDescriptionI18n: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->aMailDescription !== null) {
if ($this->aMailDescription->isModified() || $this->aMailDescription->getCurrentMailDescriptionI18n()->isModified()) {
$affectedRows += $this->aMailDescription->save($con);
}
$this->setMailDescription($this->aMailDescription);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = MailDescriptionI18nPeer::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 += MailDescriptionI18nPeer::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->aMailDescription !== null) {
if (!$this->aMailDescription->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aMailDescription->getValidationFailures());
}
}
if (($retval = MailDescriptionI18nPeer::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 = MailDescriptionI18nPeer::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->getCulture();
break;
case 2:
return $this->getDescription();
break;
case 3:
return $this->getName();
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 = MailDescriptionI18nPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getCulture(),
$keys[2] => $this->getDescription(),
$keys[3] => $this->getName(),
);
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 = MailDescriptionI18nPeer::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->setCulture($value);
break;
case 2:
$this->setDescription($value);
break;
case 3:
$this->setName($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 = MailDescriptionI18nPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCulture($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDescription($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setName($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(MailDescriptionI18nPeer::DATABASE_NAME);
if ($this->isColumnModified(MailDescriptionI18nPeer::ID)) $criteria->add(MailDescriptionI18nPeer::ID, $this->id);
if ($this->isColumnModified(MailDescriptionI18nPeer::CULTURE)) $criteria->add(MailDescriptionI18nPeer::CULTURE, $this->culture);
if ($this->isColumnModified(MailDescriptionI18nPeer::DESCRIPTION)) $criteria->add(MailDescriptionI18nPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(MailDescriptionI18nPeer::NAME)) $criteria->add(MailDescriptionI18nPeer::NAME, $this->name);
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(MailDescriptionI18nPeer::DATABASE_NAME);
$criteria->add(MailDescriptionI18nPeer::ID, $this->id);
$criteria->add(MailDescriptionI18nPeer::CULTURE, $this->culture);
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->getId(), $this->getCulture());
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(MailDescriptionI18nPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType), MailDescriptionI18nPeer::translateFieldName('culture', 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->setId($keys[0]);
$this->setCulture($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 MailDescriptionI18n (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->setDescription($this->description);
$copyObj->setName($this->name);
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a pkey column, so set to default value
$copyObj->setCulture(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 MailDescriptionI18n 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 'MailDescriptionI18nPeer';
}
/**
* Declares an association between this object and a MailDescription object.
*
* @param MailDescription $v
* @return void
* @throws PropelException
*/
public function setMailDescription($v)
{
if ($v === null) {
$this->setId(NULL);
} else {
$this->setId($v->getId());
}
$this->aMailDescription = $v;
}
/**
* Get the associated MailDescription object
*
* @param Connection Optional Connection object.
* @return MailDescription The associated MailDescription object.
* @throws PropelException
*/
public function getMailDescription($con = null)
{
if ($this->aMailDescription === null && ($this->id !== null)) {
// include the related Peer class
$this->aMailDescription = MailDescriptionPeer::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 = MailDescriptionPeer::retrieveByPK($this->id, $con);
$obj->addMailDescriptions($this);
*/
}
return $this->aMailDescription;
}
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, 'MailDescriptionI18n.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BaseMailDescriptionI18n:'.$method))
{
throw new sfException(sprintf('Call to undefined method BaseMailDescriptionI18n::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BaseMailDescriptionI18n

View File

@@ -0,0 +1,839 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_mail_description_i18n' table.
*
*
*
* @package plugins.stMailPlugin.lib.model.om
*/
abstract class BaseMailDescriptionI18nPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_mail_description_i18n';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stMailPlugin.lib.model.MailDescriptionI18n';
/** 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 ID field */
const ID = 'st_mail_description_i18n.ID';
/** the column name for the CULTURE field */
const CULTURE = 'st_mail_description_i18n.CULTURE';
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'st_mail_description_i18n.DESCRIPTION';
/** the column name for the NAME field */
const NAME = 'st_mail_description_i18n.NAME';
/** 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', 'Culture', 'Description', 'Name', ),
BasePeer::TYPE_COLNAME => array (MailDescriptionI18nPeer::ID, MailDescriptionI18nPeer::CULTURE, MailDescriptionI18nPeer::DESCRIPTION, MailDescriptionI18nPeer::NAME, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'culture', 'description', 'name', ),
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 ('Id' => 0, 'Culture' => 1, 'Description' => 2, 'Name' => 3, ),
BasePeer::TYPE_COLNAME => array (MailDescriptionI18nPeer::ID => 0, MailDescriptionI18nPeer::CULTURE => 1, MailDescriptionI18nPeer::DESCRIPTION => 2, MailDescriptionI18nPeer::NAME => 3, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'culture' => 1, 'description' => 2, 'name' => 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.stMailPlugin.lib.model.map.MailDescriptionI18nMapBuilder');
}
/**
* 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 = MailDescriptionI18nPeer::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. MailDescriptionI18nPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(MailDescriptionI18nPeer::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(MailDescriptionI18nPeer::ID);
$criteria->addSelectColumn(MailDescriptionI18nPeer::CULTURE);
$criteria->addSelectColumn(MailDescriptionI18nPeer::DESCRIPTION);
$criteria->addSelectColumn(MailDescriptionI18nPeer::NAME);
if (stEventDispatcher::getInstance()->getListeners('MailDescriptionI18nPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'MailDescriptionI18nPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_mail_description_i18n.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_mail_description_i18n.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(MailDescriptionI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailDescriptionI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = MailDescriptionI18nPeer::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 MailDescriptionI18n
* @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 = MailDescriptionI18nPeer::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 MailDescriptionI18n[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return MailDescriptionI18nPeer::populateObjects(MailDescriptionI18nPeer::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;
MailDescriptionI18nPeer::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 = MailDescriptionI18nPeer::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 MailDescription 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 doCountJoinMailDescription(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(MailDescriptionI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailDescriptionI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(MailDescriptionI18nPeer::ID, MailDescriptionPeer::ID);
$rs = MailDescriptionI18nPeer::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 MailDescriptionI18n objects pre-filled with their MailDescription objects.
*
* @return MailDescriptionI18n[] Array of MailDescriptionI18n objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinMailDescription(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);
}
MailDescriptionI18nPeer::addSelectColumns($c);
MailDescriptionPeer::addSelectColumns($c);
$c->addJoin(MailDescriptionI18nPeer::ID, MailDescriptionPeer::ID);
$rs = MailDescriptionI18nPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new MailDescriptionI18n();
$startcol = $obj1->hydrate($rs);
if ($obj1->getId())
{
$obj2 = new MailDescription();
$obj2->hydrate($rs, $startcol);
$obj2->addMailDescriptionI18n($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(MailDescriptionI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailDescriptionI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(MailDescriptionI18nPeer::ID, MailDescriptionPeer::ID);
$rs = MailDescriptionI18nPeer::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 MailDescriptionI18n objects pre-filled with all related objects.
*
* @return MailDescriptionI18n[]
* @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);
}
MailDescriptionI18nPeer::addSelectColumns($c);
$startcol2 = (MailDescriptionI18nPeer::NUM_COLUMNS - MailDescriptionI18nPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
MailDescriptionPeer::addSelectColumns($c);
$startcol3 = $startcol2 + MailDescriptionPeer::NUM_COLUMNS;
$c->addJoin(MailDescriptionI18nPeer::ID, MailDescriptionPeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = MailDescriptionI18nPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined MailDescription rows
$omClass = MailDescriptionPeer::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->getMailDescription(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addMailDescriptionI18n($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initMailDescriptionI18ns();
$obj2->addMailDescriptionI18n($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 MailDescriptionI18nPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a MailDescriptionI18n or Criteria object.
*
* @param mixed $values Criteria or MailDescriptionI18n 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('BaseMailDescriptionI18nPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailDescriptionI18nPeer', $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 MailDescriptionI18n 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('BaseMailDescriptionI18nPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseMailDescriptionI18nPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a MailDescriptionI18n or Criteria object.
*
* @param mixed $values Criteria or MailDescriptionI18n 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('BaseMailDescriptionI18nPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailDescriptionI18nPeer', $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(MailDescriptionI18nPeer::ID);
$selectCriteria->add(MailDescriptionI18nPeer::ID, $criteria->remove(MailDescriptionI18nPeer::ID), $comparison);
$comparison = $criteria->getComparison(MailDescriptionI18nPeer::CULTURE);
$selectCriteria->add(MailDescriptionI18nPeer::CULTURE, $criteria->remove(MailDescriptionI18nPeer::CULTURE), $comparison);
} else { // $values is MailDescriptionI18n 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('BaseMailDescriptionI18nPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseMailDescriptionI18nPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_mail_description_i18n 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(MailDescriptionI18nPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a MailDescriptionI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or MailDescriptionI18n 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(MailDescriptionI18nPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof MailDescriptionI18n) {
$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(MailDescriptionI18nPeer::ID, $vals[0], Criteria::IN);
$criteria->add(MailDescriptionI18nPeer::CULTURE, $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 MailDescriptionI18n 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 MailDescriptionI18n $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(MailDescriptionI18n $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(MailDescriptionI18nPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(MailDescriptionI18nPeer::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(MailDescriptionI18nPeer::DATABASE_NAME, MailDescriptionI18nPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = MailDescriptionI18nPeer::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 $id
@param string $culture
* @param Connection $con
* @return MailDescriptionI18n
*/
public static function retrieveByPK( $id, $culture, $con = null) {
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria();
$criteria->add(MailDescriptionI18nPeer::ID, $id);
$criteria->add(MailDescriptionI18nPeer::CULTURE, $culture);
$v = MailDescriptionI18nPeer::doSelect($criteria, $con);
return !empty($v) ? $v[0] : null;
}
} // BaseMailDescriptionI18nPeer
// 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 {
BaseMailDescriptionI18nPeer::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.stMailPlugin.lib.model.map.MailDescriptionI18nMapBuilder');
}

View File

@@ -0,0 +1,759 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_mail_description' table.
*
*
*
* @package plugins.stMailPlugin.lib.model.om
*/
abstract class BaseMailDescriptionPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_mail_description';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stMailPlugin.lib.model.MailDescription';
/** The total number of columns. */
const NUM_COLUMNS = 7;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the CREATED_AT field */
const CREATED_AT = 'st_mail_description.CREATED_AT';
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'st_mail_description.UPDATED_AT';
/** the column name for the ID field */
const ID = 'st_mail_description.ID';
/** the column name for the SYSTEM_NAME field */
const SYSTEM_NAME = 'st_mail_description.SYSTEM_NAME';
/** the column name for the OPT_NAME field */
const OPT_NAME = 'st_mail_description.OPT_NAME';
/** the column name for the OPT_DESCRIPTION field */
const OPT_DESCRIPTION = 'st_mail_description.OPT_DESCRIPTION';
/** the column name for the IS_ACTIVE field */
const IS_ACTIVE = 'st_mail_description.IS_ACTIVE';
/** 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 ('CreatedAt', 'UpdatedAt', 'Id', 'SystemName', 'OptName', 'OptDescription', 'IsActive', ),
BasePeer::TYPE_COLNAME => array (MailDescriptionPeer::CREATED_AT, MailDescriptionPeer::UPDATED_AT, MailDescriptionPeer::ID, MailDescriptionPeer::SYSTEM_NAME, MailDescriptionPeer::OPT_NAME, MailDescriptionPeer::OPT_DESCRIPTION, MailDescriptionPeer::IS_ACTIVE, ),
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'system_name', 'opt_name', 'opt_description', 'is_active', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
/**
* 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 ('CreatedAt' => 0, 'UpdatedAt' => 1, 'Id' => 2, 'SystemName' => 3, 'OptName' => 4, 'OptDescription' => 5, 'IsActive' => 6, ),
BasePeer::TYPE_COLNAME => array (MailDescriptionPeer::CREATED_AT => 0, MailDescriptionPeer::UPDATED_AT => 1, MailDescriptionPeer::ID => 2, MailDescriptionPeer::SYSTEM_NAME => 3, MailDescriptionPeer::OPT_NAME => 4, MailDescriptionPeer::OPT_DESCRIPTION => 5, MailDescriptionPeer::IS_ACTIVE => 6, ),
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'system_name' => 3, 'opt_name' => 4, 'opt_description' => 5, 'is_active' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
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.stMailPlugin.lib.model.map.MailDescriptionMapBuilder');
}
/**
* 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 = MailDescriptionPeer::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. MailDescriptionPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(MailDescriptionPeer::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(MailDescriptionPeer::CREATED_AT);
$criteria->addSelectColumn(MailDescriptionPeer::UPDATED_AT);
$criteria->addSelectColumn(MailDescriptionPeer::ID);
$criteria->addSelectColumn(MailDescriptionPeer::SYSTEM_NAME);
$criteria->addSelectColumn(MailDescriptionPeer::OPT_NAME);
$criteria->addSelectColumn(MailDescriptionPeer::OPT_DESCRIPTION);
$criteria->addSelectColumn(MailDescriptionPeer::IS_ACTIVE);
if (stEventDispatcher::getInstance()->getListeners('MailDescriptionPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'MailDescriptionPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_mail_description.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_mail_description.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(MailDescriptionPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailDescriptionPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = MailDescriptionPeer::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 MailDescription
* @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 = MailDescriptionPeer::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 MailDescription[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return MailDescriptionPeer::populateObjects(MailDescriptionPeer::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;
MailDescriptionPeer::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 = MailDescriptionPeer::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;
}
/**
* Selects a collection of MailDescription objects pre-filled with their i18n objects.
*
* @return array Array of MailDescription objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectWithI18n(Criteria $c, $culture = null, $con = null)
{
$c = clone $c;
if ($culture === null)
{
$culture = sfContext::getInstance()->getUser()->getCulture();
}
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB())
{
$c->setDbName(self::DATABASE_NAME);
}
if (!$c->getSelectColumns())
{
MailDescriptionPeer::addSelectColumns($c);
MailDescriptionI18nPeer::addSelectColumns($c);
}
$c->addJoin(MailDescriptionPeer::ID, sprintf('%s AND %s = \'%s\'', MailDescriptionI18nPeer::ID, MailDescriptionI18nPeer::CULTURE, $culture), Criteria::LEFT_JOIN);
$rs = MailDescriptionPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new MailDescription();
$startcol = $obj1->hydrate($rs);
$obj1->setCulture($culture);
$obj2 = new MailDescriptionI18n();
$obj2->hydrate($rs, $startcol);
$obj1->setMailDescriptionI18nForCulture($obj2, $culture);
$obj2->setMailDescription($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 MailDescriptionPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a MailDescription or Criteria object.
*
* @param mixed $values Criteria or MailDescription 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('BaseMailDescriptionPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailDescriptionPeer', $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 MailDescription object
}
$criteria->remove(MailDescriptionPeer::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('BaseMailDescriptionPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseMailDescriptionPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a MailDescription or Criteria object.
*
* @param mixed $values Criteria or MailDescription 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('BaseMailDescriptionPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailDescriptionPeer', $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(MailDescriptionPeer::ID);
$selectCriteria->add(MailDescriptionPeer::ID, $criteria->remove(MailDescriptionPeer::ID), $comparison);
} else { // $values is MailDescription 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('BaseMailDescriptionPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseMailDescriptionPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_mail_description 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 += MailDescriptionPeer::doOnDeleteCascade(new Criteria(), $con);
$affectedRows += BasePeer::doDeleteAll(MailDescriptionPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a MailDescription or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or MailDescription 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(MailDescriptionPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof MailDescription) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(MailDescriptionPeer::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 += MailDescriptionPeer::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 = MailDescriptionPeer::doSelect($criteria, $con);
foreach($objects as $obj) {
// delete related MailDescriptionI18n objects
$c = new Criteria();
$c->add(MailDescriptionI18nPeer::ID, $obj->getId());
$affectedRows += MailDescriptionI18nPeer::doDelete($c, $con);
}
return $affectedRows;
}
/**
* Validates all modified columns of given MailDescription 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 MailDescription $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(MailDescription $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(MailDescriptionPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(MailDescriptionPeer::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(MailDescriptionPeer::DATABASE_NAME, MailDescriptionPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = MailDescriptionPeer::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 MailDescription
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(MailDescriptionPeer::DATABASE_NAME);
$criteria->add(MailDescriptionPeer::ID, $pk);
$v = MailDescriptionPeer::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 MailDescription[]
*/
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(MailDescriptionPeer::ID, $pks, Criteria::IN);
$objs = MailDescriptionPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseMailDescriptionPeer
// 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 {
BaseMailDescriptionPeer::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.stMailPlugin.lib.model.map.MailDescriptionMapBuilder');
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,669 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_mail_smtp_profile' table.
*
*
*
* @package plugins.stMailPlugin.lib.model.om
*/
abstract class BaseMailSmtpProfilePeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_mail_smtp_profile';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stMailPlugin.lib.model.MailSmtpProfile';
/** The total number of columns. */
const NUM_COLUMNS = 7;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the CREATED_AT field */
const CREATED_AT = 'st_mail_smtp_profile.CREATED_AT';
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'st_mail_smtp_profile.UPDATED_AT';
/** the column name for the ID field */
const ID = 'st_mail_smtp_profile.ID';
/** the column name for the NAME field */
const NAME = 'st_mail_smtp_profile.NAME';
/** the column name for the HOST field */
const HOST = 'st_mail_smtp_profile.HOST';
/** the column name for the PORT field */
const PORT = 'st_mail_smtp_profile.PORT';
/** the column name for the ENC_TYPE field */
const ENC_TYPE = 'st_mail_smtp_profile.ENC_TYPE';
/** 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 ('CreatedAt', 'UpdatedAt', 'Id', 'Name', 'Host', 'Port', 'EncType', ),
BasePeer::TYPE_COLNAME => array (MailSmtpProfilePeer::CREATED_AT, MailSmtpProfilePeer::UPDATED_AT, MailSmtpProfilePeer::ID, MailSmtpProfilePeer::NAME, MailSmtpProfilePeer::HOST, MailSmtpProfilePeer::PORT, MailSmtpProfilePeer::ENC_TYPE, ),
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'name', 'host', 'port', 'enc_type', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
/**
* 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 ('CreatedAt' => 0, 'UpdatedAt' => 1, 'Id' => 2, 'Name' => 3, 'Host' => 4, 'Port' => 5, 'EncType' => 6, ),
BasePeer::TYPE_COLNAME => array (MailSmtpProfilePeer::CREATED_AT => 0, MailSmtpProfilePeer::UPDATED_AT => 1, MailSmtpProfilePeer::ID => 2, MailSmtpProfilePeer::NAME => 3, MailSmtpProfilePeer::HOST => 4, MailSmtpProfilePeer::PORT => 5, MailSmtpProfilePeer::ENC_TYPE => 6, ),
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'name' => 3, 'host' => 4, 'port' => 5, 'enc_type' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
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.stMailPlugin.lib.model.map.MailSmtpProfileMapBuilder');
}
/**
* 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 = MailSmtpProfilePeer::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. MailSmtpProfilePeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(MailSmtpProfilePeer::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(MailSmtpProfilePeer::CREATED_AT);
$criteria->addSelectColumn(MailSmtpProfilePeer::UPDATED_AT);
$criteria->addSelectColumn(MailSmtpProfilePeer::ID);
$criteria->addSelectColumn(MailSmtpProfilePeer::NAME);
$criteria->addSelectColumn(MailSmtpProfilePeer::HOST);
$criteria->addSelectColumn(MailSmtpProfilePeer::PORT);
$criteria->addSelectColumn(MailSmtpProfilePeer::ENC_TYPE);
if (stEventDispatcher::getInstance()->getListeners('MailSmtpProfilePeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'MailSmtpProfilePeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_mail_smtp_profile.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_mail_smtp_profile.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(MailSmtpProfilePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(MailSmtpProfilePeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = MailSmtpProfilePeer::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 MailSmtpProfile
* @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 = MailSmtpProfilePeer::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 MailSmtpProfile[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return MailSmtpProfilePeer::populateObjects(MailSmtpProfilePeer::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;
MailSmtpProfilePeer::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 = MailSmtpProfilePeer::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 MailSmtpProfilePeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a MailSmtpProfile or Criteria object.
*
* @param mixed $values Criteria or MailSmtpProfile 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('BaseMailSmtpProfilePeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailSmtpProfilePeer', $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 MailSmtpProfile object
}
$criteria->remove(MailSmtpProfilePeer::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('BaseMailSmtpProfilePeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseMailSmtpProfilePeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a MailSmtpProfile or Criteria object.
*
* @param mixed $values Criteria or MailSmtpProfile 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('BaseMailSmtpProfilePeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseMailSmtpProfilePeer', $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(MailSmtpProfilePeer::ID);
$selectCriteria->add(MailSmtpProfilePeer::ID, $criteria->remove(MailSmtpProfilePeer::ID), $comparison);
} else { // $values is MailSmtpProfile 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('BaseMailSmtpProfilePeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseMailSmtpProfilePeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_mail_smtp_profile 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(MailSmtpProfilePeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a MailSmtpProfile or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or MailSmtpProfile 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(MailSmtpProfilePeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof MailSmtpProfile) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(MailSmtpProfilePeer::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 MailSmtpProfile 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 MailSmtpProfile $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(MailSmtpProfile $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(MailSmtpProfilePeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(MailSmtpProfilePeer::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(MailSmtpProfilePeer::DATABASE_NAME, MailSmtpProfilePeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = MailSmtpProfilePeer::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 MailSmtpProfile
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(MailSmtpProfilePeer::DATABASE_NAME);
$criteria->add(MailSmtpProfilePeer::ID, $pk);
$v = MailSmtpProfilePeer::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 MailSmtpProfile[]
*/
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(MailSmtpProfilePeer::ID, $pks, Criteria::IN);
$objs = MailSmtpProfilePeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseMailSmtpProfilePeer
// 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 {
BaseMailSmtpProfilePeer::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.stMailPlugin.lib.model.map.MailSmtpProfileMapBuilder');
}

View File

@@ -0,0 +1,286 @@
<?php
/* * ****************************************************************************
* Copyright (c) 2010 Jevon Wright and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Jevon Wright - initial API and implementation
* ************************************************************************** */
class stHtml2Text
{
/**
* Tries to convert the given HTML into a plain text format - best suited for
* e-mail display, etc.
*
* <p>In particular, it tries to maintain the following features:
* <ul>
* <li>Links are maintained, with the 'href' copied over
* <li>Information in the &lt;head&gt; is lost
* </ul>
*
* @param html the input HTML
* @return the HTML converted, as best as possible, to text
*/
public static function convert($html)
{
$html = self::fixNewLines($html);
$doc = new DOMDocument();
$html = '<?xml encoding="UTF-8">'.$html;
if (!$doc->loadHTML($html))
{
throw new sfException("Could not load HTML - badly formed?");
}
foreach ($doc->childNodes as $item)
{
if ($item->nodeType == XML_PI_NODE)
{
$doc->removeChild($item); // remove hack
}
}
$output = self::iterateOverNode($doc);
// remove leading and trailing spaces on each line
$output = preg_replace("/[ \t]*\n[ \t]*/im", "\n", $output);
// remove leading and trailing whitespace
$output = trim($output);
return $output;
}
/**
* Unify newlines; in particular, \r\n becomes \n, and
* then \r becomes \n. This means that all newlines (Unix, Windows, Mac)
* all become \ns.
*
* @param text text with any number of \r, \r\n and \n combinations
* @return the fixed text
*/
protected static function fixNewLines($text)
{
// replace \r\n to \n
$text = str_replace("\r\n", "\n", $text);
// remove \rs
$text = str_replace("\r", "\n", $text);
return $text;
}
protected static function nextChildName($node)
{
// get the next child
$nextNode = $node->nextSibling;
while ($nextNode != null)
{
if ($nextNode instanceof DOMElement)
{
break;
}
$nextNode = $nextNode->nextSibling;
}
$nextName = null;
if ($nextNode instanceof DOMElement && $nextNode != null)
{
$nextName = strtolower($nextNode->nodeName);
}
return $nextName;
}
protected static function getHasParentNodeName(DomElement $node, $name)
{
return $node->parentNode ? $node->parentNode->nodeName == $name : null;
}
protected static function getHasChildNodeName(DomElement $node, $name)
{
if ($node->childNodes)
{
foreach ($node->childNodes as $child_node)
{
if ($child_node->nodeName == $name)
{
return true;
}
}
}
return false;
}
protected static function prevChildName($node)
{
// get the previous child
$nextNode = $node->previousSibling;
while ($nextNode != null)
{
if ($nextNode instanceof DOMElement)
{
break;
}
$nextNode = $nextNode->previousSibling;
}
$nextName = null;
if ($nextNode instanceof DOMElement && $nextNode != null)
{
$nextName = strtolower($nextNode->nodeName);
}
return $nextName;
}
protected static function iterateOverNode($node)
{
if ($node instanceof DOMText)
{
return preg_replace("/\\s+/im", " ", $node->wholeText);
}
if ($node instanceof DOMDocumentType)
{
// ignore
return "";
}
$nextName = self::nextChildName($node);
$prevName = self::prevChildName($node);
$name = strtolower($node->nodeName);
// start whitespace
switch ($name)
{
case "hr":
return "------\n";
case "style":
case "head":
case "title":
case "meta":
case "script":
// ignore these tags
return "";
case "h1":
case "h2":
case "h3":
case "h4":
case "h5":
case "h6":
// add two newlines
$output = "\n";
break;
case "li":
$output = "\n - ";
break;
case "p":
case "div":
// add one line
$output = "\n";
break;
default:
// print out contents of unknown tags
$output = "";
break;
}
// debug
//$output .= "[$name,$nextName]";
for ($i = 0; $i < $node->childNodes->length; $i++)
{
$n = $node->childNodes->item($i);
$text = self::iterateOverNode($n);
$output .= $text;
}
// end whitespace
switch ($name)
{
case "style":
case "head":
case "title":
case "meta":
case "script":
// ignore these tags
return "";
case "h1":
case "h2":
case "h3":
case "h4":
case "h5":
case "h6":
case "li":
$output .= "\n";
break;
case "p":
case "br":
// add one line
if ($nextName != "div")
$output .= "\n";
break;
case "div":
// add one line only if the next child isn't a div
if ($nextName != "div" && $nextName != null)
$output .= "\n";
break;
case "a":
// links are returned in [text](link) format
$href = $node->getAttribute("href");
if ($href == null)
{
// it doesn't link anywhere
if ($node->getAttribute("name") != null)
{
$output = "[$output]";
}
}
else
{
if ($href == $output)
{
// link to the same address: just use link
$output;
}
else
{
// replace it
$output = "[$output]($href)";
}
}
// does the next node require additional whitespace?
switch ($nextName)
{
case "h1": case "h2": case "h3": case "h4": case "h5": case "h6":
$output .= "\n";
break;
}
default:
// do nothing
}
return $output;
}
}

View File

@@ -0,0 +1,560 @@
<?php
/**
* SOTESHOP/stMailPlugin
*
* Ten plik należy do aplikacji stMailPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stMailPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: stMail.class.php 12185 2011-04-13 11:31:16Z marcin $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
* Klasa stMailTemplate
*
* @author Marcin Butlak <marcin.butlak@sote.pl>
*
* @package stMailPlugin
* @subpackage libs
*/
class stMailTemplate
{
/**
* Zwraca zawartosc szablonu dla maili
*
* @param string $templateName Nazwa szablonu
* @param array $templateVars zmienne przekazywane do szablonu
* @return string zawartosc szablonu
*/
static public function render($templateName, $templateVars = array())
{
$context = sfContext::getInstance();
$actionName = $templateName."Mail";
if (($pos = strpos($templateName, '/')) !== false)
{
$moduleName = substr($templateName, 0, $pos);
$templateFile = substr($templateName, $pos + 1);
}
else
{
$moduleName = $context->getModuleName();
$templateFile = $templateName;
}
$actionName = $templateFile.'Mail';
$view = new sfPartialView();
$view->initialize($context, $moduleName, $actionName, '');
return $view->render($templateVars);
}
}
/**
* A wrapper class which implements most of the Swift mailer functionality
*
* This class only purpose is to maintain the compatibility between Swift mailer versions
*
* @author Marcin Butlak <marcin.butlak@sote.pl>
*
* @package stMailPlugin
* @subpackage libs
*/
class stMail
{
protected static $instance = array();
protected static $port = array('tls' => 25, 'ssl' => 465, null => 25);
/**
* @var stMailLogger
*/
protected $logger = null;
/**
* @var Swift_Message
*/
protected $message = null;
/**
* @var Swift_Mailer
*/
public $mailer = null;
protected $attachments = array();
const TIMEOUT = 30;
/**
* Adres email wysyłającego wiadomość
*
* @var string
*/
protected $sender = null;
/**
* Singleton
*
* @return static
*/
public static function getInstance($class = null)
{
if (!isset(self::$instance[$class]))
{
if (null === $class)
{
$class = __CLASS__;
}
self::$instance[$class] = new $class();
self::$instance[$class]->initialize();
}
return self::$instance[$class];
}
/**
*
* Initialize
*
*/
public function initialize()
{
require_once sfConfig::get('sf_plugins_dir').'/stSwiftPlugin/vendor/autoload.php';
if (sfConfig::get('sf_logging_enabled'))
{
$this->logger = new stMailLogger();
}
$this->setConnection(new Swift_SmtpTransport());
$this->createNewMessage();
}
/**
*
* Validate the current connection
*
* @return bool Return true if everything is ok, false otherwise
*/
public function validateConnection()
{
$transport = $this->mailer->getTransport();
try
{
$transport->start();
}
catch (Exception $e)
{
return false;
}
return $transport->isStarted();
}
/**
*
* Return Swift Mailer instance
*
* @return Swift_Mailer instance
*/
public function getSwiftMailer()
{
return $this->mailer;
}
public function createNewMessage($subject = null, $body = null)
{
$this->message = new Swift_Message($subject, $body);
return $this;
}
/**
* @deprecated use setSmtpConnection
*/
public function addSmtpConnection($email, $host = 'localhost', $port = null, $username = null, $password = null, $security = null)
{
return $this->setSmtpConnection($email, $host, $port, $username, $password, $security);
}
/**
* Set a new smtp connection
* @param string $sender
* @param string $host
* @param int $port
* @param string $username
* @param string $password
* @param int $security
* @return static
*/
public function setSmtpConnection($sender, $host = 'localhost', $port = null, $username = null, $password = null, $security = null)
{
$transport = new Swift_SmtpTransport($host, $port, $security);
if (isset($username))
{
$transport->setUsername($username);
}
if (isset($password))
{
$transport->setPassword($password);
}
$transport->setTimeout(self::TIMEOUT);
$this->setConnection($transport);
$this->sender = $sender;
return $this;
}
/**
* Set swift connection
*
* @param Swift_Transport $transport
*
* @return static
*/
public function setConnection($transport)
{
$this->mailer = new Swift_Mailer($transport);
if ($this->logger)
{
$this->mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($this->logger));
}
return $this;
}
/**
* Set the html body content of this message
* @param string $content
*
* @return static
*/
public function setHtmlMessage($content)
{
$this->message->setBody(self::addHost($content), 'text/html');
return $this;
}
/**
* Set the alternative plain text body content of this message
* @param string $content
*
* @return static
*/
public function setPlainMessage($content)
{
$this->message->addPart(self::addHost($content), 'text/plain');
return $this;
}
/**
* Set the From address
*
* It is permissible for multiple From addresses to be set using an array.
*
* If multiple From addresses are used, you SHOULD set the Sender address and
* according to RFC 2822, MUST set the sender address.
*
* An array can be used if display names are to be provided: i.e.
* array('email@address.com' => 'Real Name').
*
* If the second parameter is provided and the first is a string, then $name
* is associated with the address.
*
* @param mixed $addresses
* @param string $name optional
*/
public function setFrom($addresses, $name = null)
{
$this->message->setFrom($addresses, $name);
return $this;
}
/**
* Set the sender of this message.
*
* If multiple addresses are present in the From field, this SHOULD be set.
*
* According to RFC 2822 it is a requirement when there are multiple From
* addresses, but Swift itself does not require it directly.
*
* An associative array (with one element!) can be used to provide a display-
* name: i.e. array('email@address' => 'Real Name').
*
* If the second parameter is provided and the first is a string, then $name
* is associated with the address.
*
* @param mixed $address
* @param string $name optional
* @return static
*/
public function setSender($address, $name = null)
{
$this->message->setSender($address, $name);
return $this;
}
/**
* Set the To address(es).
*
* Recipients set in this field will receive a copy of this message.
*
* This method has the same synopsis as {@link setFrom()} and {@link setCc()}.
*
* If the second parameter is provided and the first is a string, then $name
* is associated with the address.
*
* @param mixed $addresses
* @param string $name optional
* @return static
*/
public function setTo($addresses, $name = null)
{
$this->message->setTo($addresses, $name);
return $this;
}
/**
* Set the Bcc address(es).
*
* Recipients set in this field will receive a 'blind-carbon-copy' of this
* message.
*
* In other words, they will get the message, but any other recipients of the
* message will have no such knowledge of their receipt of it.
*
* This method has the same synopsis as {@link setFrom()} and {@link setTo()}.
*
* @param mixed $addresses
* @param string $name optional
*/
public function setBcc($addresses, $name = null)
{
$this->message->setBcc($addresses, $name);
return $this;
}
/**
* Add a Bcc: address
*
* If $name is passed this name will be associated with the address.
*
* @param string $address
* @param string $name optional
*/
public function addBcc($address, $name = null)
{
$this->message->addBcc($address, $name);
}
/**
* Set the Reply-To address(es).
*
* Any replies from the receiver will be sent to this address.
*
* It is permissible for multiple reply-to addresses to be set using an array.
*
* This method has the same synopsis as {@link setFrom()} and {@link setTo()}.
*
* If the second parameter is provided and the first is a string, then $name
* is associated with the address.
*
* @param mixed $addresses
* @param string $name optional
* @return static
*/
public function setReplyTo($addresses, $name = null)
{
$this->message->setReplyTo($addresses, $name);
return $this;
}
/**
* Set subject of this message
*
* @param string $subject
* @return static
*/
public function setSubject($subject)
{
$this->message->setSubject($subject);
return $this;
}
public function getSubject()
{
return $this->message->getSubject();
}
/**
* Set the charaset of this message
*
* @param string $charset
* @return static
*/
public function setCharset($charset = 'utf-8')
{
$this->message->setCharset($charset);
return $this;
}
/**
* Add a new Attachment from a filesystem path
*
* @param string $filename optional
* @param string $path
* @param string $content_type optional
* @return static
*/
public function addAttachment($filename = null, $path, $content_type = null)
{
$attachment = Swift_Attachment::fromPath($path, $content_type);
if ($filename)
{
$attachment->setFilename($filename);
}
$this->message->attach($attachment);
$this->attachments[] = $attachment;
return $this;
}
public function addAttachmentData($filename, $data, $content_type)
{
$attachment = Swift_Attachment::newInstance($data, $filename, $content_type);
$this->message->attach($attachment);
$this->attachments[] = $attachment;
return $this;
}
public function removeAttachments()
{
foreach ($this->attachments as $attachment)
{
$this->message->detach($attachment);
}
$this->attachments = array();
return $this;
}
/**
* Send the given Message like it would be sent in a mail client.
*
* All recipients (with the exception of Bcc) will be able to see the other
* recipients this message was sent to.
*
* If you need to send to each recipient without disclosing details about the
* other recipients see {@link batchSend()}.
*
* The return value is the number of recipients who were accepted for
* delivery.
*
* @param array &$failed_recipients, optional
* @return int
* @see batchSend()
*/
public function send(&$failed_recipients = null)
{
try
{
if (!$this->message->getSender())
{
$this->message->setSender($this->sender);
}
if (!$this->message->getFrom())
{
$this->message->setFrom($this->sender);
}
$ret = $this->mailer->send($this->message, $failed_recipients);
$this->createNewMessage();
}
catch (Exception $e)
{
$ret = false;
}
return $ret;
}
/**
* Send the given Message to all recipients individually.
*
* This differs from {@link send()} in the way headers are presented to the
* recipient. The only recipient in the "To:" field will be the individual
* recipient it was sent to.
*
* The return value is the number of recipients who were accepted for
* delivery.
*
* @param array &$failedRecipients, optional
* @return int
* @see send()
*/
public function sendBatch(&$failed_recipients = null)
{
try
{
$ret = $this->mailer->send($this->message, $failed_recipients);
$this->createNewMessage();
}
catch (Exception $e)
{
$ret = false;
}
return $ret;
}
public static function defaultPort($security = null)
{
return isset(self::$port[$security]) ? self::$port[$security] : self::$port[null];
}
public static function getDefaultPorts()
{
return self::$port;
}
public static function addHost($content)
{
return sfContext::getInstance()->getRequest()->addHost($content);
}
}

View File

@@ -0,0 +1,5 @@
<?php
class stMailListener
{
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* SOTESHOP/stSwiftPlugin
*
* Ten plik należy do aplikacji stSwiftPlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stSwiftPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
* @version $Id: actions.class.php 617 2009-04-09 13:02:31Z michal $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
* actions.
*
* @package stSwiftPlugin
* @subpackage libs
*/
class stMailLogger implements Swift_Plugins_Logger
{
protected $logger = null;
/**
* Create a new logger.
*
* @param boolean $isHtml
*/
public function __construct($isHtml = true)
{
$this->logger = sfLogger::getInstance();
}
/**
* Add a log entry.
* @param string $entry
*/
public function add($entry)
{
$this->logger->log('{stMail} '.$entry, strpos($entry, '!! ') === 0 ? SF_LOG_ERR : SF_LOG_INFO);
}
/**
* Not implemented.
*/
public function clear()
{
}
/**
* Not implemented.
*/
public function dump()
{
}
}

View File

@@ -0,0 +1,212 @@
<?php
/**
* SOTESHOP/stMailPlugin
*
* Ten plik należy do aplikacji stMailPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stMailPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: stMailer.class.php 12274 2011-04-18 11:54:02Z michal $
* @author Marcin Butlak <marcin.butlak@sote.pl>
*/
/**
* Klasa stMailer
*
* @package stMailPlugin
* @subpackage libs
*/
class stMailer extends stMail
{
protected $merchantAddress = '';
protected $account = null;
protected $accountInitialized = null;
/**
* Pobiera instancję
*
* @return stMailer
*/
public static function getInstance($class = null)
{
if (null === $class)
{
$class = __CLASS__;
}
return parent::getInstance($class);
}
public function setAccount($email)
{
$this->account = $email;
$this->accountInitialized = null;
return $this;
}
public function setMerchantAddress($address = '') {
$this->merchantAddress = $address ;
}
public function initializeAccount()
{
if (null === $this->accountInitialized)
{
$c = new Criteria();
if ($this->account)
{
$c->add(MailAccountPeer::EMAIL, $this->account);
}
else
{
$c->add(MailAccountPeer::IS_DEFAULT, true);
}
stEventDispatcher::getInstance()->notify(new sfEvent($this, 'stMailPlugin.beforeInitialize', array('mailCriteria'=>$c)));
$c->setLimit(1);
$mail_accounts = MailAccountPeer::doSelectJoinMailSmtpProfile($c);
if ($mail_accounts)
{
$mail_account = $mail_accounts[0];
if (!$this->merchantAddress)
{
$this->merchantAddress = $mail_account->getEmail();
}
if ($mail_account->getName())
{
$sender = array($mail_account->getEmail() => $mail_account->getName());
}
else
{
$sender = $mail_account->getEmail();
}
$this->setSmtpConnection($sender, $mail_account->getMailSmtpProfile()->getHost(), $mail_account->getMailSmtpProfile()->getPort(), $mail_account->getUsername(), $mail_account->getPassword(), $mail_account->getMailSmtpProfile()->getEncType());
$this->accountInitialized = true;
}
else
{
$this->accountInitialized = false;
}
}
return $this->accountInitialized;
}
public function validateAccountConfiguration()
{
if (!$this->initializeAccount())
{
stNotification::getInstance()->addAlert('stMailPlugin', 'mail.conf.required', array(
'i18n_catalogue' => 'stMailAccountBackend',
'action' => '@stMailPlugin?action=list',
'singular' => true,
));
}
else
{
stNotification::getInstance()->markAllAsRead('stMailPlugin');
}
}
public function send(&$failed_recipients = null)
{
if (!$this->initializeAccount())
{
$this->validateAccountConfiguration();
return false;
}
return parent::send($failed_recipients);
}
/**
* Wysyła e-mail do klienta
*
* @return bool
*/
public function sendToClient()
{
return $this->send();
}
/**
* Wysyła e-mail na konto główne sklepu
*
* @return bool
*/
public function sendToMerchant()
{
$this->initializeAccount();
return $this->merchantAddress ? $this->setTo($this->merchantAddress)->send() : false;
}
/**
* Zawartośći opisów maila Html
*
* @return string
*/
public static function getHtmlMailDescription($system_name)
{
$c = new Criteria();
$c->add(MailDescriptionPeer::IS_ACTIVE, 1);
$c->add(MailDescriptionPeer::SYSTEM_NAME, $system_name);
$mailDescription = MailDescriptionPeer::doSelectOne($c);
if (!$mailDescription)
{
$content = "";
return $content;
}
else
{
if (SF_APP == 'backend') $mailDescription->setCulture(sfContext::getInstance()->getUser()->getCulture());
$content = $mailDescription->getDescription();
return $content;
}
}
/**
* Zawartośći opisów maila
*
* @return string
*/
public static function getPlainMailDescription($system_name)
{
$c = new Criteria();
$c->add(MailDescriptionPeer::IS_ACTIVE, 1);
$c->add(MailDescriptionPeer::SYSTEM_NAME, $system_name);
$mailDescription = MailDescriptionPeer::doSelectOne($c);
if (!$mailDescription)
{
$content = "";
return $content;
}
else
{
if (SF_APP == 'backend') $mailDescription->setCulture(sfContext::getInstance()->getUser()->getCulture());
$content = $mailDescription->getDescription();
return $content;
}
}
}