diff options
Diffstat (limited to 'lib/model/om/BaseDomain.php')
-rw-r--r-- | lib/model/om/BaseDomain.php | 926 |
1 files changed, 926 insertions, 0 deletions
diff --git a/lib/model/om/BaseDomain.php b/lib/model/om/BaseDomain.php new file mode 100644 index 0000000..0c8317c --- /dev/null +++ b/lib/model/om/BaseDomain.php @@ -0,0 +1,926 @@ +<?php + + +abstract class BaseDomain extends BaseObject implements Persistent { + + + + protected static $peer; + + + + protected $id; + + + + protected $name; + + + + protected $creator_id; + + + + protected $mailbox_prefix; + + + + protected $max_mailbox_count; + + + + protected $quota; + + + + protected $default_mailbox_quota; + + + protected $aUser; + + + protected $collDomainPermissions; + + + protected $lastDomainPermissionCriteria = null; + + + protected $collMailboxs; + + + protected $lastMailboxCriteria = null; + + + protected $collAddresss; + + + protected $lastAddressCriteria = null; + + + protected $alreadyInSave = false; + + + protected $alreadyInValidation = false; + + + public function getId() + { + + return $this->id; + } + + + public function getName() + { + + return $this->name; + } + + + public function getCreatorId() + { + + return $this->creator_id; + } + + + public function getMailboxPrefix() + { + + return $this->mailbox_prefix; + } + + + public function getMaxMailboxCount() + { + + return $this->max_mailbox_count; + } + + + public function getQuota() + { + + return $this->quota; + } + + + public function getDefaultMailboxQuota() + { + + return $this->default_mailbox_quota; + } + + + 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[] = DomainPeer::ID; + } + + } + + public function setName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = DomainPeer::NAME; + } + + } + + public function setCreatorId($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->creator_id !== $v) { + $this->creator_id = $v; + $this->modifiedColumns[] = DomainPeer::CREATOR_ID; + } + + if ($this->aUser !== null && $this->aUser->getId() !== $v) { + $this->aUser = null; + } + + } + + public function setMailboxPrefix($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->mailbox_prefix !== $v) { + $this->mailbox_prefix = $v; + $this->modifiedColumns[] = DomainPeer::MAILBOX_PREFIX; + } + + } + + public function setMaxMailboxCount($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->max_mailbox_count !== $v) { + $this->max_mailbox_count = $v; + $this->modifiedColumns[] = DomainPeer::MAX_MAILBOX_COUNT; + } + + } + + public function setQuota($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->quota !== $v) { + $this->quota = $v; + $this->modifiedColumns[] = DomainPeer::QUOTA; + } + + } + + public function setDefaultMailboxQuota($v) + { + + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->default_mailbox_quota !== $v) { + $this->default_mailbox_quota = $v; + $this->modifiedColumns[] = DomainPeer::DEFAULT_MAILBOX_QUOTA; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->name = $rs->getString($startcol + 1); + + $this->creator_id = $rs->getInt($startcol + 2); + + $this->mailbox_prefix = $rs->getString($startcol + 3); + + $this->max_mailbox_count = $rs->getInt($startcol + 4); + + $this->quota = $rs->getInt($startcol + 5); + + $this->default_mailbox_quota = $rs->getInt($startcol + 6); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 7; + } catch (Exception $e) { + throw new PropelException("Error populating Domain 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(DomainPeer::DATABASE_NAME); + } + + try { + $con->begin(); + DomainPeer::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(DomainPeer::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->aUser !== null) { + if ($this->aUser->isModified()) { + $affectedRows += $this->aUser->save($con); + } + $this->setUser($this->aUser); + } + + + if ($this->isModified()) { + if ($this->isNew()) { + $pk = DomainPeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += DomainPeer::doUpdate($this, $con); + } + $this->resetModified(); } + + if ($this->collDomainPermissions !== null) { + foreach($this->collDomainPermissions as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->collMailboxs !== null) { + foreach($this->collMailboxs as $referrerFK) { + if (!$referrerFK->isDeleted()) { + $affectedRows += $referrerFK->save($con); + } + } + } + + 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->aUser !== null) { + if (!$this->aUser->validate($columns)) { + $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); + } + } + + + if (($retval = DomainPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collDomainPermissions !== null) { + foreach($this->collDomainPermissions as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + if ($this->collMailboxs !== null) { + foreach($this->collMailboxs as $referrerFK) { + if (!$referrerFK->validate($columns)) { + $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); + } + } + } + + 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 = DomainPeer::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->getName(); + break; + case 2: + return $this->getCreatorId(); + break; + case 3: + return $this->getMailboxPrefix(); + break; + case 4: + return $this->getMaxMailboxCount(); + break; + case 5: + return $this->getQuota(); + break; + case 6: + return $this->getDefaultMailboxQuota(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = DomainPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getName(), + $keys[2] => $this->getCreatorId(), + $keys[3] => $this->getMailboxPrefix(), + $keys[4] => $this->getMaxMailboxCount(), + $keys[5] => $this->getQuota(), + $keys[6] => $this->getDefaultMailboxQuota(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = DomainPeer::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->setName($value); + break; + case 2: + $this->setCreatorId($value); + break; + case 3: + $this->setMailboxPrefix($value); + break; + case 4: + $this->setMaxMailboxCount($value); + break; + case 5: + $this->setQuota($value); + break; + case 6: + $this->setDefaultMailboxQuota($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = DomainPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatorId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setMailboxPrefix($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setMaxMailboxCount($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setQuota($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setDefaultMailboxQuota($arr[$keys[6]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(DomainPeer::DATABASE_NAME); + + if ($this->isColumnModified(DomainPeer::ID)) $criteria->add(DomainPeer::ID, $this->id); + if ($this->isColumnModified(DomainPeer::NAME)) $criteria->add(DomainPeer::NAME, $this->name); + if ($this->isColumnModified(DomainPeer::CREATOR_ID)) $criteria->add(DomainPeer::CREATOR_ID, $this->creator_id); + if ($this->isColumnModified(DomainPeer::MAILBOX_PREFIX)) $criteria->add(DomainPeer::MAILBOX_PREFIX, $this->mailbox_prefix); + if ($this->isColumnModified(DomainPeer::MAX_MAILBOX_COUNT)) $criteria->add(DomainPeer::MAX_MAILBOX_COUNT, $this->max_mailbox_count); + if ($this->isColumnModified(DomainPeer::QUOTA)) $criteria->add(DomainPeer::QUOTA, $this->quota); + if ($this->isColumnModified(DomainPeer::DEFAULT_MAILBOX_QUOTA)) $criteria->add(DomainPeer::DEFAULT_MAILBOX_QUOTA, $this->default_mailbox_quota); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(DomainPeer::DATABASE_NAME); + + $criteria->add(DomainPeer::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->setName($this->name); + + $copyObj->setCreatorId($this->creator_id); + + $copyObj->setMailboxPrefix($this->mailbox_prefix); + + $copyObj->setMaxMailboxCount($this->max_mailbox_count); + + $copyObj->setQuota($this->quota); + + $copyObj->setDefaultMailboxQuota($this->default_mailbox_quota); + + + if ($deepCopy) { + $copyObj->setNew(false); + + foreach($this->getDomainPermissions() as $relObj) { + $copyObj->addDomainPermission($relObj->copy($deepCopy)); + } + + foreach($this->getMailboxs() as $relObj) { + $copyObj->addMailbox($relObj->copy($deepCopy)); + } + + 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 DomainPeer(); + } + return self::$peer; + } + + + public function setUser($v) + { + + + if ($v === null) { + $this->setCreatorId(NULL); + } else { + $this->setCreatorId($v->getId()); + } + + + $this->aUser = $v; + } + + + + public function getUser($con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + + if ($this->aUser === null && ($this->creator_id !== null)) { + + $this->aUser = UserPeer::retrieveByPK($this->creator_id, $con); + + + } + return $this->aUser; + } + + + public function initDomainPermissions() + { + if ($this->collDomainPermissions === null) { + $this->collDomainPermissions = array(); + } + } + + + public function getDomainPermissions($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collDomainPermissions === null) { + if ($this->isNew()) { + $this->collDomainPermissions = array(); + } else { + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + DomainPermissionPeer::addSelectColumns($criteria); + $this->collDomainPermissions = DomainPermissionPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + DomainPermissionPeer::addSelectColumns($criteria); + if (!isset($this->lastDomainPermissionCriteria) || !$this->lastDomainPermissionCriteria->equals($criteria)) { + $this->collDomainPermissions = DomainPermissionPeer::doSelect($criteria, $con); + } + } + } + $this->lastDomainPermissionCriteria = $criteria; + return $this->collDomainPermissions; + } + + + public function countDomainPermissions($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + return DomainPermissionPeer::doCount($criteria, $distinct, $con); + } + + + public function addDomainPermission(DomainPermission $l) + { + $this->collDomainPermissions[] = $l; + $l->setDomain($this); + } + + + + public function getDomainPermissionsJoinUser($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseDomainPermissionPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collDomainPermissions === null) { + if ($this->isNew()) { + $this->collDomainPermissions = array(); + } else { + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + $this->collDomainPermissions = DomainPermissionPeer::doSelectJoinUser($criteria, $con); + } + } else { + + $criteria->add(DomainPermissionPeer::DOMAIN_ID, $this->getId()); + + if (!isset($this->lastDomainPermissionCriteria) || !$this->lastDomainPermissionCriteria->equals($criteria)) { + $this->collDomainPermissions = DomainPermissionPeer::doSelectJoinUser($criteria, $con); + } + } + $this->lastDomainPermissionCriteria = $criteria; + + return $this->collDomainPermissions; + } + + + public function initMailboxs() + { + if ($this->collMailboxs === null) { + $this->collMailboxs = array(); + } + } + + + public function getMailboxs($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseMailboxPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collMailboxs === null) { + if ($this->isNew()) { + $this->collMailboxs = array(); + } else { + + $criteria->add(MailboxPeer::DOMAIN_ID, $this->getId()); + + MailboxPeer::addSelectColumns($criteria); + $this->collMailboxs = MailboxPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(MailboxPeer::DOMAIN_ID, $this->getId()); + + MailboxPeer::addSelectColumns($criteria); + if (!isset($this->lastMailboxCriteria) || !$this->lastMailboxCriteria->equals($criteria)) { + $this->collMailboxs = MailboxPeer::doSelect($criteria, $con); + } + } + } + $this->lastMailboxCriteria = $criteria; + return $this->collMailboxs; + } + + + public function countMailboxs($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseMailboxPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(MailboxPeer::DOMAIN_ID, $this->getId()); + + return MailboxPeer::doCount($criteria, $distinct, $con); + } + + + public function addMailbox(Mailbox $l) + { + $this->collMailboxs[] = $l; + $l->setDomain($this); + } + + + 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::DOMAIN_ID, $this->getId()); + + AddressPeer::addSelectColumns($criteria); + $this->collAddresss = AddressPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(AddressPeer::DOMAIN_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::DOMAIN_ID, $this->getId()); + + return AddressPeer::doCount($criteria, $distinct, $con); + } + + + public function addAddress(Address $l) + { + $this->collAddresss[] = $l; + $l->setDomain($this); + } + + + + public function getAddresssJoinMailbox($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::DOMAIN_ID, $this->getId()); + + $this->collAddresss = AddressPeer::doSelectJoinMailbox($criteria, $con); + } + } else { + + $criteria->add(AddressPeer::DOMAIN_ID, $this->getId()); + + if (!isset($this->lastAddressCriteria) || !$this->lastAddressCriteria->equals($criteria)) { + $this->collAddresss = AddressPeer::doSelectJoinMailbox($criteria, $con); + } + } + $this->lastAddressCriteria = $criteria; + + return $this->collAddresss; + } + +}
\ No newline at end of file |