From 9f108dd1a969473375341d92a7b1252fa2cedc9a Mon Sep 17 00:00:00 2001 From: mszulecki Date: Thu, 14 Jun 2007 17:09:01 +0000 Subject: Initial import. git-svn-id: http://svn.sukimashita.com/repos/mailadmin/trunk@2 4281df72-ff29-0410-8fee-2d9ac0c5f5a7 --- lib/model/om/BaseMailbox.php | 751 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 751 insertions(+) create mode 100644 lib/model/om/BaseMailbox.php (limited to 'lib/model/om/BaseMailbox.php') diff --git a/lib/model/om/BaseMailbox.php b/lib/model/om/BaseMailbox.php new file mode 100644 index 0000000..cda4d2f --- /dev/null +++ b/lib/model/om/BaseMailbox.php @@ -0,0 +1,751 @@ +id; + } + + + public function getDomainId() + { + + return $this->domain_id; + } + + + public function getName() + { + + return $this->name; + } + + + public function getPassword() + { + + return $this->password; + } + + + public function getMaxQuota() + { + + return $this->max_quota; + } + + + public function getMaxAddressCount() + { + + return $this->max_address_count; + } + + + public function getLastLogin($format = 'Y-m-d H:i:s') + { + + if ($this->last_login === null || $this->last_login === '') { + return null; + } elseif (!is_int($this->last_login)) { + $ts = strtotime($this->last_login); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse value of [last_login] as date/time value: " . var_export($this->last_login, true)); + } + } else { + $ts = $this->last_login; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + + public function getActive() + { + + return $this->active; + } + + + 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[] = MailboxPeer::ID; + } + + } + + public function setDomainId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->domain_id !== $v) { + $this->domain_id = $v; + $this->modifiedColumns[] = MailboxPeer::DOMAIN_ID; + } + + if ($this->aDomain !== null && $this->aDomain->getId() !== $v) { + $this->aDomain = null; + } + + } + + public function setName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = MailboxPeer::NAME; + } + + } + + public function setPassword($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->password !== $v) { + $this->password = $v; + $this->modifiedColumns[] = MailboxPeer::PASSWORD; + } + + } + + public function setMaxQuota($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->max_quota !== $v) { + $this->max_quota = $v; + $this->modifiedColumns[] = MailboxPeer::MAX_QUOTA; + } + + } + + public function setMaxAddressCount($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->max_address_count !== $v) { + $this->max_address_count = $v; + $this->modifiedColumns[] = MailboxPeer::MAX_ADDRESS_COUNT; + } + + } + + public function setLastLogin($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { throw new PropelException("Unable to parse date/time value for [last_login] from input: " . var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->last_login !== $ts) { + $this->last_login = $ts; + $this->modifiedColumns[] = MailboxPeer::LAST_LOGIN; + } + + } + + public function setActive($v) + { + + if ($this->active !== $v || $v === true) { + $this->active = $v; + $this->modifiedColumns[] = MailboxPeer::ACTIVE; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->domain_id = $rs->getInt($startcol + 1); + + $this->name = $rs->getString($startcol + 2); + + $this->password = $rs->getString($startcol + 3); + + $this->max_quota = $rs->getInt($startcol + 4); + + $this->max_address_count = $rs->getInt($startcol + 5); + + $this->last_login = $rs->getTimestamp($startcol + 6, null); + + $this->active = $rs->getBoolean($startcol + 7); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 8; + } catch (Exception $e) { + throw new PropelException("Error populating Mailbox object", $e); + } + } + + + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MailboxPeer::DATABASE_NAME); + } + + try { + $con->begin(); + MailboxPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MailboxPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + + protected function doSave($con) + { + $affectedRows = 0; if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + + if ($this->aDomain !== null) { + if ($this->aDomain->isModified()) { + $affectedRows += $this->aDomain->save($con); + } + $this->setDomain($this->aDomain); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MailboxPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += MailboxPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + if ($this->collAddresss !== null) { + foreach($this->collAddresss as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } + + protected $validationFailures = array(); + + + public function getValidationFailures() + { + return $this->validationFailures; + } + + + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + + if ($this->aDomain !== null) { + if (!$this->aDomain->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aDomain->getValidationFailures()); + } + } + + + if (($retval = MailboxPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collAddresss !== null) { + foreach($this->collAddresss as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MailboxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getDomainId(); + break; + case 2: + return $this->getName(); + break; + case 3: + return $this->getPassword(); + break; + case 4: + return $this->getMaxQuota(); + break; + case 5: + return $this->getMaxAddressCount(); + break; + case 6: + return $this->getLastLogin(); + break; + case 7: + return $this->getActive(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MailboxPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getDomainId(), + $keys[2] => $this->getName(), + $keys[3] => $this->getPassword(), + $keys[4] => $this->getMaxQuota(), + $keys[5] => $this->getMaxAddressCount(), + $keys[6] => $this->getLastLogin(), + $keys[7] => $this->getActive(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MailboxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setDomainId($value); + break; + case 2: + $this->setName($value); + break; + case 3: + $this->setPassword($value); + break; + case 4: + $this->setMaxQuota($value); + break; + case 5: + $this->setMaxAddressCount($value); + break; + case 6: + $this->setLastLogin($value); + break; + case 7: + $this->setActive($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MailboxPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDomainId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPassword($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setMaxQuota($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setMaxAddressCount($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setLastLogin($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setActive($arr[$keys[7]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(MailboxPeer::DATABASE_NAME); + + if ($this->isColumnModified(MailboxPeer::ID)) $criteria->add(MailboxPeer::ID, $this->id); + if ($this->isColumnModified(MailboxPeer::DOMAIN_ID)) $criteria->add(MailboxPeer::DOMAIN_ID, $this->domain_id); + if ($this->isColumnModified(MailboxPeer::NAME)) $criteria->add(MailboxPeer::NAME, $this->name); + if ($this->isColumnModified(MailboxPeer::PASSWORD)) $criteria->add(MailboxPeer::PASSWORD, $this->password); + if ($this->isColumnModified(MailboxPeer::MAX_QUOTA)) $criteria->add(MailboxPeer::MAX_QUOTA, $this->max_quota); + if ($this->isColumnModified(MailboxPeer::MAX_ADDRESS_COUNT)) $criteria->add(MailboxPeer::MAX_ADDRESS_COUNT, $this->max_address_count); + if ($this->isColumnModified(MailboxPeer::LAST_LOGIN)) $criteria->add(MailboxPeer::LAST_LOGIN, $this->last_login); + if ($this->isColumnModified(MailboxPeer::ACTIVE)) $criteria->add(MailboxPeer::ACTIVE, $this->active); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(MailboxPeer::DATABASE_NAME); + + $criteria->add(MailboxPeer::ID, $this->id); + + return $criteria; + } + + + public function getPrimaryKey() + { + return $this->getId(); + } + + + public function setPrimaryKey($key) + { + $this->setId($key); + } + + + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setDomainId($this->domain_id); + + $copyObj->setName($this->name); + + $copyObj->setPassword($this->password); + + $copyObj->setMaxQuota($this->max_quota); + + $copyObj->setMaxAddressCount($this->max_address_count); + + $copyObj->setLastLogin($this->last_login); + + $copyObj->setActive($this->active); + + + if ($deepCopy) { + $copyObj->setNew(false); + + foreach($this->getAddresss() as $relObj) { + $copyObj->addAddress($relObj->copy($deepCopy)); + } + + } + + $copyObj->setNew(true); + + $copyObj->setId(NULL); + } + + + public function copy($deepCopy = false) + { + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MailboxPeer(); + } + return self::$peer; + } + + + public function setDomain($v) + { + + + if ($v === null) { + $this->setDomainId(NULL); + } else { + $this->setDomainId($v->getId()); + } + + + $this->aDomain = $v; + } + + + + public function getDomain($con = null) + { + include_once 'lib/model/om/BaseDomainPeer.php'; + + if ($this->aDomain === null && ($this->domain_id !== null)) { + + $this->aDomain = DomainPeer::retrieveByPK($this->domain_id, $con); + + + } + return $this->aDomain; + } + + + public function initAddresss() + { + if ($this->collAddresss === null) { + $this->collAddresss = array(); + } + } + + + public function getAddresss($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAddresss === null) { + if ($this->isNew()) { + $this->collAddresss = array(); + } else { + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + AddressPeer::addSelectColumns($criteria); + $this->collAddresss = AddressPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + AddressPeer::addSelectColumns($criteria); + if (!isset($this->lastAddressCriteria) || !$this->lastAddressCriteria->equals($criteria)) { + $this->collAddresss = AddressPeer::doSelect($criteria, $con); + } + } + } + $this->lastAddressCriteria = $criteria; + return $this->collAddresss; + } + + + public function countAddresss($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + return AddressPeer::doCount($criteria, $distinct, $con); + } + + + public function addAddress(Address $l) + { + $this->collAddresss[] = $l; + $l->setMailbox($this); + } + + + + public function getAddresssJoinDomain($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseAddressPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collAddresss === null) { + if ($this->isNew()) { + $this->collAddresss = array(); + } else { + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + $this->collAddresss = AddressPeer::doSelectJoinDomain($criteria, $con); + } + } else { + + $criteria->add(AddressPeer::MAILBOX_ID, $this->getId()); + + if (!isset($this->lastAddressCriteria) || !$this->lastAddressCriteria->equals($criteria)) { + $this->collAddresss = AddressPeer::doSelectJoinDomain($criteria, $con); + } + } + $this->lastAddressCriteria = $criteria; + + return $this->collAddresss; + } + +} \ No newline at end of file -- cgit v1.1-32-gdbae