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/BaseRole.php | 493 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 493 insertions(+) create mode 100644 lib/model/om/BaseRole.php (limited to 'lib/model/om/BaseRole.php') diff --git a/lib/model/om/BaseRole.php b/lib/model/om/BaseRole.php new file mode 100644 index 0000000..7936e1e --- /dev/null +++ b/lib/model/om/BaseRole.php @@ -0,0 +1,493 @@ +id; + } + + + public function getName() + { + + return $this->name; + } + + + public function getCredentials() + { + + return $this->credentials; + } + + + 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[] = RolePeer::ID; + } + + } + + public function setName($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = RolePeer::NAME; + } + + } + + public function setCredentials($v) + { + + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->credentials !== $v) { + $this->credentials = $v; + $this->modifiedColumns[] = RolePeer::CREDENTIALS; + } + + } + + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->id = $rs->getInt($startcol + 0); + + $this->name = $rs->getString($startcol + 1); + + $this->credentials = $rs->getString($startcol + 2); + + $this->resetModified(); + + $this->setNew(false); + + return $startcol + 3; + } catch (Exception $e) { + throw new PropelException("Error populating Role 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(RolePeer::DATABASE_NAME); + } + + try { + $con->begin(); + RolePeer::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(RolePeer::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->isModified()) { + if ($this->isNew()) { + $pk = RolePeer::doInsert($this, $con); + $affectedRows += 1; + $this->setId($pk); + $this->setNew(false); + } else { + $affectedRows += RolePeer::doUpdate($this, $con); + } + $this->resetModified(); } + + if ($this->collUsers !== null) { + foreach($this->collUsers 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 (($retval = RolePeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + if ($this->collUsers !== null) { + foreach($this->collUsers 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 = RolePeer::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->getCredentials(); + break; + default: + return null; + break; + } } + + + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RolePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getName(), + $keys[2] => $this->getCredentials(), + ); + return $result; + } + + + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = RolePeer::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->setCredentials($value); + break; + } } + + + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = RolePeer::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->setCredentials($arr[$keys[2]]); + } + + + public function buildCriteria() + { + $criteria = new Criteria(RolePeer::DATABASE_NAME); + + if ($this->isColumnModified(RolePeer::ID)) $criteria->add(RolePeer::ID, $this->id); + if ($this->isColumnModified(RolePeer::NAME)) $criteria->add(RolePeer::NAME, $this->name); + if ($this->isColumnModified(RolePeer::CREDENTIALS)) $criteria->add(RolePeer::CREDENTIALS, $this->credentials); + + return $criteria; + } + + + public function buildPkeyCriteria() + { + $criteria = new Criteria(RolePeer::DATABASE_NAME); + + $criteria->add(RolePeer::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->setCredentials($this->credentials); + + + if ($deepCopy) { + $copyObj->setNew(false); + + foreach($this->getUsers() as $relObj) { + $copyObj->addUser($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 RolePeer(); + } + return self::$peer; + } + + + public function initUsers() + { + if ($this->collUsers === null) { + $this->collUsers = array(); + } + } + + + public function getUsers($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collUsers === null) { + if ($this->isNew()) { + $this->collUsers = array(); + } else { + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + UserPeer::addSelectColumns($criteria); + $this->collUsers = UserPeer::doSelect($criteria, $con); + } + } else { + if (!$this->isNew()) { + + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + UserPeer::addSelectColumns($criteria); + if (!isset($this->lastUserCriteria) || !$this->lastUserCriteria->equals($criteria)) { + $this->collUsers = UserPeer::doSelect($criteria, $con); + } + } + } + $this->lastUserCriteria = $criteria; + return $this->collUsers; + } + + + public function countUsers($criteria = null, $distinct = false, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + return UserPeer::doCount($criteria, $distinct, $con); + } + + + public function addUser(User $l) + { + $this->collUsers[] = $l; + $l->setRole($this); + } + + + + public function getUsersJoinUserRelatedByParentUserId($criteria = null, $con = null) + { + include_once 'lib/model/om/BaseUserPeer.php'; + if ($criteria === null) { + $criteria = new Criteria(); + } + elseif ($criteria instanceof Criteria) + { + $criteria = clone $criteria; + } + + if ($this->collUsers === null) { + if ($this->isNew()) { + $this->collUsers = array(); + } else { + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + $this->collUsers = UserPeer::doSelectJoinUserRelatedByParentUserId($criteria, $con); + } + } else { + + $criteria->add(UserPeer::ROLE_ID, $this->getId()); + + if (!isset($this->lastUserCriteria) || !$this->lastUserCriteria->equals($criteria)) { + $this->collUsers = UserPeer::doSelectJoinUserRelatedByParentUserId($criteria, $con); + } + } + $this->lastUserCriteria = $criteria; + + return $this->collUsers; + } + +} \ No newline at end of file -- cgit v1.1-32-gdbae