# File core/lib/Thelia/Model/om/BaseGroup.php | thelia

       1: <?php
       2:
       3: namespace Thelia\Model\om;
       4:
       5: use \BaseObject;
       6: use \BasePeer;
       7: use \Criteria;
       8: use \DateTime;
       9: use \Exception;
      10: use \PDO;
      11: use \Persistent;
      12: use \Propel;
      13: use \PropelCollection;
      14: use \PropelDateTime;
      15: use \PropelException;
      16: use \PropelObjectCollection;
      17: use \PropelPDO;
      18: use Thelia\Model\AdminGroup;
      19: use Thelia\Model\AdminGroupQuery;
      20: use Thelia\Model\Group;
      21: use Thelia\Model\GroupI18n;
      22: use Thelia\Model\GroupI18nQuery;
      23: use Thelia\Model\GroupModule;
      24: use Thelia\Model\GroupModuleQuery;
      25: use Thelia\Model\GroupPeer;
      26: use Thelia\Model\GroupQuery;
      27: use Thelia\Model\GroupResource;
      28: use Thelia\Model\GroupResourceQuery;
      29:
      30: /**
      31:  * Base class that represents a row from the 'group' table.
      32:  *
      33:  *
      34:  *
      35:  * @package    propel.generator.Thelia.Model.om
      36:  */
      37: abstract class BaseGroup extends BaseObject implements Persistent
      38: {
      39:     /**
      40:      * Peer class name
      41:      */
      42:     const PEER = 'Thelia\\Model\\GroupPeer';
      43:
      44:     /**
      45:      * The Peer class.
      46:      * Instance provides a convenient way of calling static methods on a class
      47:      * that calling code may not be able to identify.
      48:      * @var        GroupPeer
      49:      */
      50:     protected static $peer;
      51:
      52:     /**
      53:      * The flag var to prevent infinit loop in deep copy
      54:      * @var       boolean
      55:      */
      56:     protected $startCopy = false;
      57:
      58:     /**
      59:      * The value for the id field.
      60:      * @var        int
      61:      */
      62:     protected $id;
      63:
      64:     /**
      65:      * The value for the code field.
      66:      * @var        string
      67:      */
      68:     protected $code;
      69:
      70:     /**
      71:      * The value for the created_at field.
      72:      * @var        string
      73:      */
      74:     protected $created_at;
      75:
      76:     /**
      77:      * The value for the updated_at field.
      78:      * @var        string
      79:      */
      80:     protected $updated_at;
      81:
      82:     /**
      83:      * @var        PropelObjectCollection|AdminGroup[] Collection to store aggregation of AdminGroup objects.
      84:      */
      85:     protected $collAdminGroups;
      86:     protected $collAdminGroupsPartial;
      87:
      88:     /**
      89:      * @var        PropelObjectCollection|GroupResource[] Collection to store aggregation of GroupResource objects.
      90:      */
      91:     protected $collGroupResources;
      92:     protected $collGroupResourcesPartial;
      93:
      94:     /**
      95:      * @var        PropelObjectCollection|GroupModule[] Collection to store aggregation of GroupModule objects.
      96:      */
      97:     protected $collGroupModules;
      98:     protected $collGroupModulesPartial;
      99:
     100:     /**
     101:      * @var        PropelObjectCollection|GroupI18n[] Collection to store aggregation of GroupI18n objects.
     102:      */
     103:     protected $collGroupI18ns;
     104:     protected $collGroupI18nsPartial;
     105:
     106:     /**
     107:      * Flag to prevent endless save loop, if this object is referenced
     108:      * by another object which falls in this transaction.
     109:      * @var        boolean
     110:      */
     111:     protected $alreadyInSave = false;
     112:
     113:     /**
     114:      * Flag to prevent endless validation loop, if this object is referenced
     115:      * by another object which falls in this transaction.
     116:      * @var        boolean
     117:      */
     118:     protected $alreadyInValidation = false;
     119:
     120:     // i18n behavior
     121:
     122:     /**
     123:      * Current locale
     124:      * @var        string
     125:      */
     126:     protected $currentLocale = 'en_EN';
     127:
     128:     /**
     129:      * Current translation objects
     130:      * @var        array[GroupI18n]
     131:      */
     132:     protected $currentTranslations;
     133:
     134:     /**
     135:      * An array of objects scheduled for deletion.
     136:      * @var     PropelObjectCollection
     137:      */
     138:     protected $adminGroupsScheduledForDeletion = null;
     139:
     140:     /**
     141:      * An array of objects scheduled for deletion.
     142:      * @var     PropelObjectCollection
     143:      */
     144:     protected $groupResourcesScheduledForDeletion = null;
     145:
     146:     /**
     147:      * An array of objects scheduled for deletion.
     148:      * @var     PropelObjectCollection
     149:      */
     150:     protected $groupModulesScheduledForDeletion = null;
     151:
     152:     /**
     153:      * An array of objects scheduled for deletion.
     154:      * @var     PropelObjectCollection
     155:      */
     156:     protected $groupI18nsScheduledForDeletion = null;
     157:
     158:     /**
     159:      * Get the [id] column value.
     160:      *
     161:      * @return int
     162:      */
     163:     public function getId()
     164:     {
     165:         return $this->id;
     166:     }
     167:
     168:     /**
     169:      * Get the [code] column value.
     170:      *
     171:      * @return string
     172:      */
     173:     public function getCode()
     174:     {
     175:         return $this->code;
     176:     }
     177:
     178:     /**
     179:      * Get the [optionally formatted] temporal [created_at] column value.
     180:      *
     181:      *
     182:      * @param string $format The date/time format string (either date()-style or strftime()-style).
     183:      *               If format is null, then the raw DateTime object will be returned.
     184:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
     185:      * @throws PropelException - if unable to parse/validate the date/time value.
     186:      */
     187:     public function getCreatedAt($format = 'Y-m-d H:i:s')
     188:     {
     189:         if ($this->created_at === null) {
     190:             return null;
     191:         }
     192:
     193:         if ($this->created_at === '0000-00-00 00:00:00') {
     194:             // while technically this is not a default value of null,
     195:             // this seems to be closest in meaning.
     196:             return null;
     197:         } else {
     198:             try {
     199:                 $dt = new DateTime($this->created_at);
     200:             } catch (Exception $x) {
     201:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
     202:             }
     203:         }
     204:
     205:         if ($format === null) {
     206:             // Because propel.useDateTimeClass is true, we return a DateTime object.
     207:             return $dt;
     208:         } elseif (strpos($format, '%') !== false) {
     209:             return strftime($format, $dt->format('U'));
     210:         } else {
     211:             return $dt->format($format);
     212:         }
     213:     }
     214:
     215:     /**
     216:      * Get the [optionally formatted] temporal [updated_at] column value.
     217:      *
     218:      *
     219:      * @param string $format The date/time format string (either date()-style or strftime()-style).
     220:      *               If format is null, then the raw DateTime object will be returned.
     221:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00
     222:      * @throws PropelException - if unable to parse/validate the date/time value.
     223:      */
     224:     public function getUpdatedAt($format = 'Y-m-d H:i:s')
     225:     {
     226:         if ($this->updated_at === null) {
     227:             return null;
     228:         }
     229:
     230:         if ($this->updated_at === '0000-00-00 00:00:00') {
     231:             // while technically this is not a default value of null,
     232:             // this seems to be closest in meaning.
     233:             return null;
     234:         } else {
     235:             try {
     236:                 $dt = new DateTime($this->updated_at);
     237:             } catch (Exception $x) {
     238:                 throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
     239:             }
     240:         }
     241:
     242:         if ($format === null) {
     243:             // Because propel.useDateTimeClass is true, we return a DateTime object.
     244:             return $dt;
     245:         } elseif (strpos($format, '%') !== false) {
     246:             return strftime($format, $dt->format('U'));
     247:         } else {
     248:             return $dt->format($format);
     249:         }
     250:     }
     251:
     252:     /**
     253:      * Set the value of [id] column.
     254:      *
     255:      * @param int $v new value
     256:      * @return Group The current object (for fluent API support)
     257:      */
     258:     public function setId($v)
     259:     {
     260:         if ($v !== null) {
     261:             $v = (int) $v;
     262:         }
     263:
     264:         if ($this->id !== $v) {
     265:             $this->id = $v;
     266:             $this->modifiedColumns[] = GroupPeer::ID;
     267:         }
     268:
     269:
     270:         return $this;
     271:     } // setId()
     272:
     273:     /**
     274:      * Set the value of [code] column.
     275:      *
     276:      * @param string $v new value
     277:      * @return Group The current object (for fluent API support)
     278:      */
     279:     public function setCode($v)
     280:     {
     281:         if ($v !== null) {
     282:             $v = (string) $v;
     283:         }
     284:
     285:         if ($this->code !== $v) {
     286:             $this->code = $v;
     287:             $this->modifiedColumns[] = GroupPeer::CODE;
     288:         }
     289:
     290:
     291:         return $this;
     292:     } // setCode()
     293:
     294:     /**
     295:      * Sets the value of [created_at] column to a normalized version of the date/time value specified.
     296:      *
     297:      * @param mixed $v string, integer (timestamp), or DateTime value.
     298:      *               Empty strings are treated as null.
     299:      * @return Group The current object (for fluent API support)
     300:      */
     301:     public function setCreatedAt($v)
     302:     {
     303:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
     304:         if ($this->created_at !== null || $dt !== null) {
     305:             $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
     306:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
     307:             if ($currentDateAsString !== $newDateAsString) {
     308:                 $this->created_at = $newDateAsString;
     309:                 $this->modifiedColumns[] = GroupPeer::CREATED_AT;
     310:             }
     311:         } // if either are not null
     312:
     313:
     314:         return $this;
     315:     } // setCreatedAt()
     316:
     317:     /**
     318:      * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
     319:      *
     320:      * @param mixed $v string, integer (timestamp), or DateTime value.
     321:      *               Empty strings are treated as null.
     322:      * @return Group The current object (for fluent API support)
     323:      */
     324:     public function setUpdatedAt($v)
     325:     {
     326:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
     327:         if ($this->updated_at !== null || $dt !== null) {
     328:             $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
     329:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
     330:             if ($currentDateAsString !== $newDateAsString) {
     331:                 $this->updated_at = $newDateAsString;
     332:                 $this->modifiedColumns[] = GroupPeer::UPDATED_AT;
     333:             }
     334:         } // if either are not null
     335:
     336:
     337:         return $this;
     338:     } // setUpdatedAt()
     339:
     340:     /**
     341:      * Indicates whether the columns in this object are only set to default values.
     342:      *
     343:      * This method can be used in conjunction with isModified() to indicate whether an object is both
     344:      * modified _and_ has some values set which are non-default.
     345:      *
     346:      * @return boolean Whether the columns in this object are only been set with default values.
     347:      */
     348:     public function hasOnlyDefaultValues()
     349:     {
     350:         // otherwise, everything was equal, so return true
     351:         return true;
     352:     } // hasOnlyDefaultValues()
     353:
     354:     /**
     355:      * Hydrates (populates) the object variables with values from the database resultset.
     356:      *
     357:      * An offset (0-based "start column") is specified so that objects can be hydrated
     358:      * with a subset of the columns in the resultset rows.  This is needed, for example,
     359:      * for results of JOIN queries where the resultset row includes columns from two or
     360:      * more tables.
     361:      *
     362:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
     363:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
     364:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
     365:      * @return int             next starting column
     366:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
     367:      */
     368:     public function hydrate($row, $startcol = 0, $rehydrate = false)
     369:     {
     370:         try {
     371:
     372:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
     373:             $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
     374:             $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
     375:             $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
     376:             $this->resetModified();
     377:
     378:             $this->setNew(false);
     379:
     380:             if ($rehydrate) {
     381:                 $this->ensureConsistency();
     382:             }
     383:
     384:             return $startcol + 4; // 4 = GroupPeer::NUM_HYDRATE_COLUMNS.
     385:
     386:         } catch (Exception $e) {
     387:             throw new PropelException("Error populating Group object", $e);
     388:         }
     389:     }
     390:
     391:     /**
     392:      * Checks and repairs the internal consistency of the object.
     393:      *
     394:      * This method is executed after an already-instantiated object is re-hydrated
     395:      * from the database.  It exists to check any foreign keys to make sure that
     396:      * the objects related to the current object are correct based on foreign key.
     397:      *
     398:      * You can override this method in the stub class, but you should always invoke
     399:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
     400:      * in case your model changes.
     401:      *
     402:      * @throws PropelException
     403:      */
     404:     public function ensureConsistency()
     405:     {
     406:
     407:     } // ensureConsistency
     408:
     409:     /**
     410:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
     411:      *
     412:      * This will only work if the object has been saved and has a valid primary key set.
     413:      *
     414:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
     415:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
     416:      * @return void
     417:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
     418:      */
     419:     public function reload($deep = false, PropelPDO $con = null)
     420:     {
     421:         if ($this->isDeleted()) {
     422:             throw new PropelException("Cannot reload a deleted object.");
     423:         }
     424:
     425:         if ($this->isNew()) {
     426:             throw new PropelException("Cannot reload an unsaved object.");
     427:         }
     428:
     429:         if ($con === null) {
     430:             $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     431:         }
     432:
     433:         // We don't need to alter the object instance pool; we're just modifying this instance
     434:         // already in the pool.
     435:
     436:         $stmt = GroupPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
     437:         $row = $stmt->fetch(PDO::FETCH_NUM);
     438:         $stmt->closeCursor();
     439:         if (!$row) {
     440:             throw new PropelException('Cannot find matching row in the database to reload object values.');
     441:         }
     442:         $this->hydrate($row, 0, true); // rehydrate
     443:
     444:         if ($deep) {  // also de-associate any related objects?
     445:
     446:             $this->collAdminGroups = null;
     447:
     448:             $this->collGroupResources = null;
     449:
     450:             $this->collGroupModules = null;
     451:
     452:             $this->collGroupI18ns = null;
     453:
     454:         } // if (deep)
     455:     }
     456:
     457:     /**
     458:      * Removes this object from datastore and sets delete attribute.
     459:      *
     460:      * @param PropelPDO $con
     461:      * @return void
     462:      * @throws PropelException
     463:      * @throws Exception
     464:      * @see        BaseObject::setDeleted()
     465:      * @see        BaseObject::isDeleted()
     466:      */
     467:     public function delete(PropelPDO $con = null)
     468:     {
     469:         if ($this->isDeleted()) {
     470:             throw new PropelException("This object has already been deleted.");
     471:         }
     472:
     473:         if ($con === null) {
     474:             $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     475:         }
     476:
     477:         $con->beginTransaction();
     478:         try {
     479:             $deleteQuery = GroupQuery::create()
     480:                 ->filterByPrimaryKey($this->getPrimaryKey());
     481:             $ret = $this->preDelete($con);
     482:             if ($ret) {
     483:                 $deleteQuery->delete($con);
     484:                 $this->postDelete($con);
     485:                 $con->commit();
     486:                 $this->setDeleted(true);
     487:             } else {
     488:                 $con->commit();
     489:             }
     490:         } catch (Exception $e) {
     491:             $con->rollBack();
     492:             throw $e;
     493:         }
     494:     }
     495:
     496:     /**
     497:      * Persists this object to the database.
     498:      *
     499:      * If the object is new, it inserts it; otherwise an update is performed.
     500:      * All modified related objects will also be persisted in the doSave()
     501:      * method.  This method wraps all precipitate database operations in a
     502:      * single transaction.
     503:      *
     504:      * @param PropelPDO $con
     505:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     506:      * @throws PropelException
     507:      * @throws Exception
     508:      * @see        doSave()
     509:      */
     510:     public function save(PropelPDO $con = null)
     511:     {
     512:         if ($this->isDeleted()) {
     513:             throw new PropelException("You cannot save an object that has been deleted.");
     514:         }
     515:
     516:         if ($con === null) {
     517:             $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     518:         }
     519:
     520:         $con->beginTransaction();
     521:         $isInsert = $this->isNew();
     522:         try {
     523:             $ret = $this->preSave($con);
     524:             if ($isInsert) {
     525:                 $ret = $ret && $this->preInsert($con);
     526:                 // timestampable behavior
     527:                 if (!$this->isColumnModified(GroupPeer::CREATED_AT)) {
     528:                     $this->setCreatedAt(time());
     529:                 }
     530:                 if (!$this->isColumnModified(GroupPeer::UPDATED_AT)) {
     531:                     $this->setUpdatedAt(time());
     532:                 }
     533:             } else {
     534:                 $ret = $ret && $this->preUpdate($con);
     535:                 // timestampable behavior
     536:                 if ($this->isModified() && !$this->isColumnModified(GroupPeer::UPDATED_AT)) {
     537:                     $this->setUpdatedAt(time());
     538:                 }
     539:             }
     540:             if ($ret) {
     541:                 $affectedRows = $this->doSave($con);
     542:                 if ($isInsert) {
     543:                     $this->postInsert($con);
     544:                 } else {
     545:                     $this->postUpdate($con);
     546:                 }
     547:                 $this->postSave($con);
     548:                 GroupPeer::addInstanceToPool($this);
     549:             } else {
     550:                 $affectedRows = 0;
     551:             }
     552:             $con->commit();
     553:
     554:             return $affectedRows;
     555:         } catch (Exception $e) {
     556:             $con->rollBack();
     557:             throw $e;
     558:         }
     559:     }
     560:
     561:     /**
     562:      * Performs the work of inserting or updating the row in the database.
     563:      *
     564:      * If the object is new, it inserts it; otherwise an update is performed.
     565:      * All related objects are also updated in this method.
     566:      *
     567:      * @param PropelPDO $con
     568:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
     569:      * @throws PropelException
     570:      * @see        save()
     571:      */
     572:     protected function doSave(PropelPDO $con)
     573:     {
     574:         $affectedRows = 0; // initialize var to track total num of affected rows
     575:         if (!$this->alreadyInSave) {
     576:             $this->alreadyInSave = true;
     577:
     578:             if ($this->isNew() || $this->isModified()) {
     579:                 // persist changes
     580:                 if ($this->isNew()) {
     581:                     $this->doInsert($con);
     582:                 } else {
     583:                     $this->doUpdate($con);
     584:                 }
     585:                 $affectedRows += 1;
     586:                 $this->resetModified();
     587:             }
     588:
     589:             if ($this->adminGroupsScheduledForDeletion !== null) {
     590:                 if (!$this->adminGroupsScheduledForDeletion->isEmpty()) {
     591:                     foreach ($this->adminGroupsScheduledForDeletion as $adminGroup) {
     592:                         // need to save related object because we set the relation to null
     593:                         $adminGroup->save($con);
     594:                     }
     595:                     $this->adminGroupsScheduledForDeletion = null;
     596:                 }
     597:             }
     598:
     599:             if ($this->collAdminGroups !== null) {
     600:                 foreach ($this->collAdminGroups as $referrerFK) {
     601:                     if (!$referrerFK->isDeleted()) {
     602:                         $affectedRows += $referrerFK->save($con);
     603:                     }
     604:                 }
     605:             }
     606:
     607:             if ($this->groupResourcesScheduledForDeletion !== null) {
     608:                 if (!$this->groupResourcesScheduledForDeletion->isEmpty()) {
     609:                     GroupResourceQuery::create()
     610:                         ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false))
     611:                         ->delete($con);
     612:                     $this->groupResourcesScheduledForDeletion = null;
     613:                 }
     614:             }
     615:
     616:             if ($this->collGroupResources !== null) {
     617:                 foreach ($this->collGroupResources as $referrerFK) {
     618:                     if (!$referrerFK->isDeleted()) {
     619:                         $affectedRows += $referrerFK->save($con);
     620:                     }
     621:                 }
     622:             }
     623:
     624:             if ($this->groupModulesScheduledForDeletion !== null) {
     625:                 if (!$this->groupModulesScheduledForDeletion->isEmpty()) {
     626:                     GroupModuleQuery::create()
     627:                         ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false))
     628:                         ->delete($con);
     629:                     $this->groupModulesScheduledForDeletion = null;
     630:                 }
     631:             }
     632:
     633:             if ($this->collGroupModules !== null) {
     634:                 foreach ($this->collGroupModules as $referrerFK) {
     635:                     if (!$referrerFK->isDeleted()) {
     636:                         $affectedRows += $referrerFK->save($con);
     637:                     }
     638:                 }
     639:             }
     640:
     641:             if ($this->groupI18nsScheduledForDeletion !== null) {
     642:                 if (!$this->groupI18nsScheduledForDeletion->isEmpty()) {
     643:                     GroupI18nQuery::create()
     644:                         ->filterByPrimaryKeys($this->groupI18nsScheduledForDeletion->getPrimaryKeys(false))
     645:                         ->delete($con);
     646:                     $this->groupI18nsScheduledForDeletion = null;
     647:                 }
     648:             }
     649:
     650:             if ($this->collGroupI18ns !== null) {
     651:                 foreach ($this->collGroupI18ns as $referrerFK) {
     652:                     if (!$referrerFK->isDeleted()) {
     653:                         $affectedRows += $referrerFK->save($con);
     654:                     }
     655:                 }
     656:             }
     657:
     658:             $this->alreadyInSave = false;
     659:
     660:         }
     661:
     662:         return $affectedRows;
     663:     } // doSave()
     664:
     665:     /**
     666:      * Insert the row in the database.
     667:      *
     668:      * @param PropelPDO $con
     669:      *
     670:      * @throws PropelException
     671:      * @see        doSave()
     672:      */
     673:     protected function doInsert(PropelPDO $con)
     674:     {
     675:         $modifiedColumns = array();
     676:         $index = 0;
     677:
     678:         $this->modifiedColumns[] = GroupPeer::ID;
     679:         if (null !== $this->id) {
     680:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupPeer::ID . ')');
     681:         }
     682:
     683:          // check the columns in natural order for more readable SQL queries
     684:         if ($this->isColumnModified(GroupPeer::ID)) {
     685:             $modifiedColumns[':p' . $index++]  = '`ID`';
     686:         }
     687:         if ($this->isColumnModified(GroupPeer::CODE)) {
     688:             $modifiedColumns[':p' . $index++]  = '`CODE`';
     689:         }
     690:         if ($this->isColumnModified(GroupPeer::CREATED_AT)) {
     691:             $modifiedColumns[':p' . $index++]  = '`CREATED_AT`';
     692:         }
     693:         if ($this->isColumnModified(GroupPeer::UPDATED_AT)) {
     694:             $modifiedColumns[':p' . $index++]  = '`UPDATED_AT`';
     695:         }
     696:
     697:         $sql = sprintf(
     698:             'INSERT INTO `group` (%s) VALUES (%s)',
     699:             implode(', ', $modifiedColumns),
     700:             implode(', ', array_keys($modifiedColumns))
     701:         );
     702:
     703:         try {
     704:             $stmt = $con->prepare($sql);
     705:             foreach ($modifiedColumns as $identifier => $columnName) {
     706:                 switch ($columnName) {
     707:                     case '`ID`':
     708:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
     709:                         break;
     710:                     case '`CODE`':
     711:                         $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
     712:                         break;
     713:                     case '`CREATED_AT`':
     714:                         $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR);
     715:                         break;
     716:                     case '`UPDATED_AT`':
     717:                         $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR);
     718:                         break;
     719:                 }
     720:             }
     721:             $stmt->execute();
     722:         } catch (Exception $e) {
     723:             Propel::log($e->getMessage(), Propel::LOG_ERR);
     724:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
     725:         }
     726:
     727:         try {
     728:             $pk = $con->lastInsertId();
     729:         } catch (Exception $e) {
     730:             throw new PropelException('Unable to get autoincrement id.', $e);
     731:         }
     732:         $this->setId($pk);
     733:
     734:         $this->setNew(false);
     735:     }
     736:
     737:     /**
     738:      * Update the row in the database.
     739:      *
     740:      * @param PropelPDO $con
     741:      *
     742:      * @see        doSave()
     743:      */
     744:     protected function doUpdate(PropelPDO $con)
     745:     {
     746:         $selectCriteria = $this->buildPkeyCriteria();
     747:         $valuesCriteria = $this->buildCriteria();
     748:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
     749:     }
     750:
     751:     /**
     752:      * Array of ValidationFailed objects.
     753:      * @var        array ValidationFailed[]
     754:      */
     755:     protected $validationFailures = array();
     756:
     757:     /**
     758:      * Gets any ValidationFailed objects that resulted from last call to validate().
     759:      *
     760:      *
     761:      * @return array ValidationFailed[]
     762:      * @see        validate()
     763:      */
     764:     public function getValidationFailures()
     765:     {
     766:         return $this->validationFailures;
     767:     }
     768:
     769:     /**
     770:      * Validates the objects modified field values and all objects related to this table.
     771:      *
     772:      * If $columns is either a column name or an array of column names
     773:      * only those columns are validated.
     774:      *
     775:      * @param mixed $columns Column name or an array of column names.
     776:      * @return boolean Whether all columns pass validation.
     777:      * @see        doValidate()
     778:      * @see        getValidationFailures()
     779:      */
     780:     public function validate($columns = null)
     781:     {
     782:         $res = $this->doValidate($columns);
     783:         if ($res === true) {
     784:             $this->validationFailures = array();
     785:
     786:             return true;
     787:         } else {
     788:             $this->validationFailures = $res;
     789:
     790:             return false;
     791:         }
     792:     }
     793:
     794:     /**
     795:      * This function performs the validation work for complex object models.
     796:      *
     797:      * In addition to checking the current object, all related objects will
     798:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
     799:      * an aggreagated array of ValidationFailed objects will be returned.
     800:      *
     801:      * @param array $columns Array of column names to validate.
     802:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
     803:      */
     804:     protected function doValidate($columns = null)
     805:     {
     806:         if (!$this->alreadyInValidation) {
     807:             $this->alreadyInValidation = true;
     808:             $retval = null;
     809:
     810:             $failureMap = array();
     811:
     812:
     813:             if (($retval = GroupPeer::doValidate($this, $columns)) !== true) {
     814:                 $failureMap = array_merge($failureMap, $retval);
     815:             }
     816:
     817:
     818:                 if ($this->collAdminGroups !== null) {
     819:                     foreach ($this->collAdminGroups as $referrerFK) {
     820:                         if (!$referrerFK->validate($columns)) {
     821:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     822:                         }
     823:                     }
     824:                 }
     825:
     826:                 if ($this->collGroupResources !== null) {
     827:                     foreach ($this->collGroupResources as $referrerFK) {
     828:                         if (!$referrerFK->validate($columns)) {
     829:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     830:                         }
     831:                     }
     832:                 }
     833:
     834:                 if ($this->collGroupModules !== null) {
     835:                     foreach ($this->collGroupModules as $referrerFK) {
     836:                         if (!$referrerFK->validate($columns)) {
     837:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     838:                         }
     839:                     }
     840:                 }
     841:
     842:                 if ($this->collGroupI18ns !== null) {
     843:                     foreach ($this->collGroupI18ns as $referrerFK) {
     844:                         if (!$referrerFK->validate($columns)) {
     845:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
     846:                         }
     847:                     }
     848:                 }
     849:
     850:
     851:             $this->alreadyInValidation = false;
     852:         }
     853:
     854:         return (!empty($failureMap) ? $failureMap : true);
     855:     }
     856:
     857:     /**
     858:      * Retrieves a field from the object by name passed in as a string.
     859:      *
     860:      * @param string $name name
     861:      * @param string $type The type of fieldname the $name is of:
     862:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     863:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     864:      *               Defaults to BasePeer::TYPE_PHPNAME
     865:      * @return mixed Value of field.
     866:      */
     867:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
     868:     {
     869:         $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     870:         $field = $this->getByPosition($pos);
     871:
     872:         return $field;
     873:     }
     874:
     875:     /**
     876:      * Retrieves a field from the object by Position as specified in the xml schema.
     877:      * Zero-based.
     878:      *
     879:      * @param int $pos position in xml schema
     880:      * @return mixed Value of field at $pos
     881:      */
     882:     public function getByPosition($pos)
     883:     {
     884:         switch ($pos) {
     885:             case 0:
     886:                 return $this->getId();
     887:                 break;
     888:             case 1:
     889:                 return $this->getCode();
     890:                 break;
     891:             case 2:
     892:                 return $this->getCreatedAt();
     893:                 break;
     894:             case 3:
     895:                 return $this->getUpdatedAt();
     896:                 break;
     897:             default:
     898:                 return null;
     899:                 break;
     900:         } // switch()
     901:     }
     902:
     903:     /**
     904:      * Exports the object as an array.
     905:      *
     906:      * You can specify the key type of the array by passing one of the class
     907:      * type constants.
     908:      *
     909:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
     910:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     911:      *                    Defaults to BasePeer::TYPE_PHPNAME.
     912:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
     913:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
     914:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
     915:      *
     916:      * @return array an associative array containing the field names (as keys) and field values
     917:      */
     918:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
     919:     {
     920:         if (isset($alreadyDumpedObjects['Group'][$this->getPrimaryKey()])) {
     921:             return '*RECURSION*';
     922:         }
     923:         $alreadyDumpedObjects['Group'][$this->getPrimaryKey()] = true;
     924:         $keys = GroupPeer::getFieldNames($keyType);
     925:         $result = array(
     926:             $keys[0] => $this->getId(),
     927:             $keys[1] => $this->getCode(),
     928:             $keys[2] => $this->getCreatedAt(),
     929:             $keys[3] => $this->getUpdatedAt(),
     930:         );
     931:         if ($includeForeignObjects) {
     932:             if (null !== $this->collAdminGroups) {
     933:                 $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
     934:             }
     935:             if (null !== $this->collGroupResources) {
     936:                 $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
     937:             }
     938:             if (null !== $this->collGroupModules) {
     939:                 $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
     940:             }
     941:             if (null !== $this->collGroupI18ns) {
     942:                 $result['GroupI18ns'] = $this->collGroupI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
     943:             }
     944:         }
     945:
     946:         return $result;
     947:     }
     948:
     949:     /**
     950:      * Sets a field from the object by name passed in as a string.
     951:      *
     952:      * @param string $name peer name
     953:      * @param mixed $value field value
     954:      * @param string $type The type of fieldname the $name is of:
     955:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     956:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
     957:      *                     Defaults to BasePeer::TYPE_PHPNAME
     958:      * @return void
     959:      */
     960:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
     961:     {
     962:         $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     963:
     964:         $this->setByPosition($pos, $value);
     965:     }
     966:
     967:     /**
     968:      * Sets a field from the object by Position as specified in the xml schema.
     969:      * Zero-based.
     970:      *
     971:      * @param int $pos position in xml schema
     972:      * @param mixed $value field value
     973:      * @return void
     974:      */
     975:     public function setByPosition($pos, $value)
     976:     {
     977:         switch ($pos) {
     978:             case 0:
     979:                 $this->setId($value);
     980:                 break;
     981:             case 1:
     982:                 $this->setCode($value);
     983:                 break;
     984:             case 2:
     985:                 $this->setCreatedAt($value);
     986:                 break;
     987:             case 3:
     988:                 $this->setUpdatedAt($value);
     989:                 break;
     990:         } // switch()
     991:     }
     992:
     993:     /**
     994:      * Populates the object using an array.
     995:      *
     996:      * This is particularly useful when populating an object from one of the
     997:      * request arrays (e.g. $_POST).  This method goes through the column
     998:      * names, checking to see whether a matching key exists in populated
     999:      * array. If so the setByName() method is called for that column.
    1000:      *
    1001:      * You can specify the key type of the array by additionally passing one
    1002:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
    1003:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
    1004:      * The default key type is the column's BasePeer::TYPE_PHPNAME
    1005:      *
    1006:      * @param array  $arr     An array to populate the object from.
    1007:      * @param string $keyType The type of keys the array uses.
    1008:      * @return void
    1009:      */
    1010:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
    1011:     {
    1012:         $keys = GroupPeer::getFieldNames($keyType);
    1013:
    1014:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
    1015:         if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
    1016:         if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
    1017:         if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
    1018:     }
    1019:
    1020:     /**
    1021:      * Build a Criteria object containing the values of all modified columns in this object.
    1022:      *
    1023:      * @return Criteria The Criteria object containing all modified values.
    1024:      */
    1025:     public function buildCriteria()
    1026:     {
    1027:         $criteria = new Criteria(GroupPeer::DATABASE_NAME);
    1028:
    1029:         if ($this->isColumnModified(GroupPeer::ID)) $criteria->add(GroupPeer::ID, $this->id);
    1030:         if ($this->isColumnModified(GroupPeer::CODE)) $criteria->add(GroupPeer::CODE, $this->code);
    1031:         if ($this->isColumnModified(GroupPeer::CREATED_AT)) $criteria->add(GroupPeer::CREATED_AT, $this->created_at);
    1032:         if ($this->isColumnModified(GroupPeer::UPDATED_AT)) $criteria->add(GroupPeer::UPDATED_AT, $this->updated_at);
    1033:
    1034:         return $criteria;
    1035:     }
    1036:
    1037:     /**
    1038:      * Builds a Criteria object containing the primary key for this object.
    1039:      *
    1040:      * Unlike buildCriteria() this method includes the primary key values regardless
    1041:      * of whether or not they have been modified.
    1042:      *
    1043:      * @return Criteria The Criteria object containing value(s) for primary key(s).
    1044:      */
    1045:     public function buildPkeyCriteria()
    1046:     {
    1047:         $criteria = new Criteria(GroupPeer::DATABASE_NAME);
    1048:         $criteria->add(GroupPeer::ID, $this->id);
    1049:
    1050:         return $criteria;
    1051:     }
    1052:
    1053:     /**
    1054:      * Returns the primary key for this object (row).
    1055:      * @return int
    1056:      */
    1057:     public function getPrimaryKey()
    1058:     {
    1059:         return $this->getId();
    1060:     }
    1061:
    1062:     /**
    1063:      * Generic method to set the primary key (id column).
    1064:      *
    1065:      * @param  int $key Primary key.
    1066:      * @return void
    1067:      */
    1068:     public function setPrimaryKey($key)
    1069:     {
    1070:         $this->setId($key);
    1071:     }
    1072:
    1073:     /**
    1074:      * Returns true if the primary key for this object is null.
    1075:      * @return boolean
    1076:      */
    1077:     public function isPrimaryKeyNull()
    1078:     {
    1079:
    1080:         return null === $this->getId();
    1081:     }
    1082:
    1083:     /**
    1084:      * Sets contents of passed object to values from current object.
    1085:      *
    1086:      * If desired, this method can also make copies of all associated (fkey referrers)
    1087:      * objects.
    1088:      *
    1089:      * @param object $copyObj An object of Group (or compatible) type.
    1090:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
    1091:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
    1092:      * @throws PropelException
    1093:      */
    1094:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
    1095:     {
    1096:         $copyObj->setCode($this->getCode());
    1097:         $copyObj->setCreatedAt($this->getCreatedAt());
    1098:         $copyObj->setUpdatedAt($this->getUpdatedAt());
    1099:
    1100:         if ($deepCopy && !$this->startCopy) {
    1101:             // important: temporarily setNew(false) because this affects the behavior of
    1102:             // the getter/setter methods for fkey referrer objects.
    1103:             $copyObj->setNew(false);
    1104:             // store object hash to prevent cycle
    1105:             $this->startCopy = true;
    1106:
    1107:             foreach ($this->getAdminGroups() as $relObj) {
    1108:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1109:                     $copyObj->addAdminGroup($relObj->copy($deepCopy));
    1110:                 }
    1111:             }
    1112:
    1113:             foreach ($this->getGroupResources() as $relObj) {
    1114:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1115:                     $copyObj->addGroupResource($relObj->copy($deepCopy));
    1116:                 }
    1117:             }
    1118:
    1119:             foreach ($this->getGroupModules() as $relObj) {
    1120:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1121:                     $copyObj->addGroupModule($relObj->copy($deepCopy));
    1122:                 }
    1123:             }
    1124:
    1125:             foreach ($this->getGroupI18ns() as $relObj) {
    1126:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
    1127:                     $copyObj->addGroupI18n($relObj->copy($deepCopy));
    1128:                 }
    1129:             }
    1130:
    1131:             //unflag object copy
    1132:             $this->startCopy = false;
    1133:         } // if ($deepCopy)
    1134:
    1135:         if ($makeNew) {
    1136:             $copyObj->setNew(true);
    1137:             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
    1138:         }
    1139:     }
    1140:
    1141:     /**
    1142:      * Makes a copy of this object that will be inserted as a new row in table when saved.
    1143:      * It creates a new object filling in the simple attributes, but skipping any primary
    1144:      * keys that are defined for the table.
    1145:      *
    1146:      * If desired, this method can also make copies of all associated (fkey referrers)
    1147:      * objects.
    1148:      *
    1149:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
    1150:      * @return Group Clone of current object.
    1151:      * @throws PropelException
    1152:      */
    1153:     public function copy($deepCopy = false)
    1154:     {
    1155:         // we use get_class(), because this might be a subclass
    1156:         $clazz = get_class($this);
    1157:         $copyObj = new $clazz();
    1158:         $this->copyInto($copyObj, $deepCopy);
    1159:
    1160:         return $copyObj;
    1161:     }
    1162:
    1163:     /**
    1164:      * Returns a peer instance associated with this om.
    1165:      *
    1166:      * Since Peer classes are not to have any instance attributes, this method returns the
    1167:      * same instance for all member of this class. The method could therefore
    1168:      * be static, but this would prevent one from overriding the behavior.
    1169:      *
    1170:      * @return GroupPeer
    1171:      */
    1172:     public function getPeer()
    1173:     {
    1174:         if (self::$peer === null) {
    1175:             self::$peer = new GroupPeer();
    1176:         }
    1177:
    1178:         return self::$peer;
    1179:     }
    1180:
    1181:
    1182:     /**
    1183:      * Initializes a collection based on the name of a relation.
    1184:      * Avoids crafting an 'init[$relationName]s' method name
    1185:      * that wouldn't work when StandardEnglishPluralizer is used.
    1186:      *
    1187:      * @param string $relationName The name of the relation to initialize
    1188:      * @return void
    1189:      */
    1190:     public function initRelation($relationName)
    1191:     {
    1192:         if ('AdminGroup' == $relationName) {
    1193:             $this->initAdminGroups();
    1194:         }
    1195:         if ('GroupResource' == $relationName) {
    1196:             $this->initGroupResources();
    1197:         }
    1198:         if ('GroupModule' == $relationName) {
    1199:             $this->initGroupModules();
    1200:         }
    1201:         if ('GroupI18n' == $relationName) {
    1202:             $this->initGroupI18ns();
    1203:         }
    1204:     }
    1205:
    1206:     /**
    1207:      * Clears out the collAdminGroups collection
    1208:      *
    1209:      * This does not modify the database; however, it will remove any associated objects, causing
    1210:      * them to be refetched by subsequent calls to accessor method.
    1211:      *
    1212:      * @return void
    1213:      * @see        addAdminGroups()
    1214:      */
    1215:     public function clearAdminGroups()
    1216:     {
    1217:         $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized
    1218:         $this->collAdminGroupsPartial = null;
    1219:     }
    1220:
    1221:     /**
    1222:      * reset is the collAdminGroups collection loaded partially
    1223:      *
    1224:      * @return void
    1225:      */
    1226:     public function resetPartialAdminGroups($v = true)
    1227:     {
    1228:         $this->collAdminGroupsPartial = $v;
    1229:     }
    1230:
    1231:     /**
    1232:      * Initializes the collAdminGroups collection.
    1233:      *
    1234:      * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups());
    1235:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1236:      * to your application -- for example, setting the initial array to the values stored in database.
    1237:      *
    1238:      * @param boolean $overrideExisting If set to true, the method call initializes
    1239:      *                                        the collection even if it is not empty
    1240:      *
    1241:      * @return void
    1242:      */
    1243:     public function initAdminGroups($overrideExisting = true)
    1244:     {
    1245:         if (null !== $this->collAdminGroups && !$overrideExisting) {
    1246:             return;
    1247:         }
    1248:         $this->collAdminGroups = new PropelObjectCollection();
    1249:         $this->collAdminGroups->setModel('AdminGroup');
    1250:     }
    1251:
    1252:     /**
    1253:      * Gets an array of AdminGroup objects which contain a foreign key that references this object.
    1254:      *
    1255:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1256:      * Otherwise the results are fetched from the database the first time, then cached.
    1257:      * Next time the same method is called without $criteria, the cached collection is returned.
    1258:      * If this Group is new, it will return
    1259:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1260:      *
    1261:      * @param Criteria $criteria optional Criteria object to narrow the query
    1262:      * @param PropelPDO $con optional connection object
    1263:      * @return PropelObjectCollection|AdminGroup[] List of AdminGroup objects
    1264:      * @throws PropelException
    1265:      */
    1266:     public function getAdminGroups($criteria = null, PropelPDO $con = null)
    1267:     {
    1268:         $partial = $this->collAdminGroupsPartial && !$this->isNew();
    1269:         if (null === $this->collAdminGroups || null !== $criteria  || $partial) {
    1270:             if ($this->isNew() && null === $this->collAdminGroups) {
    1271:                 // return empty collection
    1272:                 $this->initAdminGroups();
    1273:             } else {
    1274:                 $collAdminGroups = AdminGroupQuery::create(null, $criteria)
    1275:                     ->filterByGroup($this)
    1276:                     ->find($con);
    1277:                 if (null !== $criteria) {
    1278:                     if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) {
    1279:                       $this->initAdminGroups(false);
    1280:
    1281:                       foreach($collAdminGroups as $obj) {
    1282:                         if (false == $this->collAdminGroups->contains($obj)) {
    1283:                           $this->collAdminGroups->append($obj);
    1284:                         }
    1285:                       }
    1286:
    1287:                       $this->collAdminGroupsPartial = true;
    1288:                     }
    1289:
    1290:                     return $collAdminGroups;
    1291:                 }
    1292:
    1293:                 if($partial && $this->collAdminGroups) {
    1294:                     foreach($this->collAdminGroups as $obj) {
    1295:                         if($obj->isNew()) {
    1296:                             $collAdminGroups[] = $obj;
    1297:                         }
    1298:                     }
    1299:                 }
    1300:
    1301:                 $this->collAdminGroups = $collAdminGroups;
    1302:                 $this->collAdminGroupsPartial = false;
    1303:             }
    1304:         }
    1305:
    1306:         return $this->collAdminGroups;
    1307:     }
    1308:
    1309:     /**
    1310:      * Sets a collection of AdminGroup objects related by a one-to-many relationship
    1311:      * to the current object.
    1312:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    1313:      * and new objects from the given Propel collection.
    1314:      *
    1315:      * @param PropelCollection $adminGroups A Propel collection.
    1316:      * @param PropelPDO $con Optional connection object
    1317:      */
    1318:     public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null)
    1319:     {
    1320:         $this->adminGroupsScheduledForDeletion = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups);
    1321:
    1322:         foreach ($this->adminGroupsScheduledForDeletion as $adminGroupRemoved) {
    1323:             $adminGroupRemoved->setGroup(null);
    1324:         }
    1325:
    1326:         $this->collAdminGroups = null;
    1327:         foreach ($adminGroups as $adminGroup) {
    1328:             $this->addAdminGroup($adminGroup);
    1329:         }
    1330:
    1331:         $this->collAdminGroups = $adminGroups;
    1332:         $this->collAdminGroupsPartial = false;
    1333:     }
    1334:
    1335:     /**
    1336:      * Returns the number of related AdminGroup objects.
    1337:      *
    1338:      * @param Criteria $criteria
    1339:      * @param boolean $distinct
    1340:      * @param PropelPDO $con
    1341:      * @return int             Count of related AdminGroup objects.
    1342:      * @throws PropelException
    1343:      */
    1344:     public function countAdminGroups(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    1345:     {
    1346:         $partial = $this->collAdminGroupsPartial && !$this->isNew();
    1347:         if (null === $this->collAdminGroups || null !== $criteria || $partial) {
    1348:             if ($this->isNew() && null === $this->collAdminGroups) {
    1349:                 return 0;
    1350:             } else {
    1351:                 if($partial && !$criteria) {
    1352:                     return count($this->getAdminGroups());
    1353:                 }
    1354:                 $query = AdminGroupQuery::create(null, $criteria);
    1355:                 if ($distinct) {
    1356:                     $query->distinct();
    1357:                 }
    1358:
    1359:                 return $query
    1360:                     ->filterByGroup($this)
    1361:                     ->count($con);
    1362:             }
    1363:         } else {
    1364:             return count($this->collAdminGroups);
    1365:         }
    1366:     }
    1367:
    1368:     /**
    1369:      * Method called to associate a AdminGroup object to this object
    1370:      * through the AdminGroup foreign key attribute.
    1371:      *
    1372:      * @param    AdminGroup $l AdminGroup
    1373:      * @return Group The current object (for fluent API support)
    1374:      */
    1375:     public function addAdminGroup(AdminGroup $l)
    1376:     {
    1377:         if ($this->collAdminGroups === null) {
    1378:             $this->initAdminGroups();
    1379:             $this->collAdminGroupsPartial = true;
    1380:         }
    1381:         if (!$this->collAdminGroups->contains($l)) { // only add it if the **same** object is not already associated
    1382:             $this->doAddAdminGroup($l);
    1383:         }
    1384:
    1385:         return $this;
    1386:     }
    1387:
    1388:     /**
    1389:      * @param   AdminGroup $adminGroup The adminGroup object to add.
    1390:      */
    1391:     protected function doAddAdminGroup($adminGroup)
    1392:     {
    1393:         $this->collAdminGroups[]= $adminGroup;
    1394:         $adminGroup->setGroup($this);
    1395:     }
    1396:
    1397:     /**
    1398:      * @param   AdminGroup $adminGroup The adminGroup object to remove.
    1399:      */
    1400:     public function removeAdminGroup($adminGroup)
    1401:     {
    1402:         if ($this->getAdminGroups()->contains($adminGroup)) {
    1403:             $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup));
    1404:             if (null === $this->adminGroupsScheduledForDeletion) {
    1405:                 $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups;
    1406:                 $this->adminGroupsScheduledForDeletion->clear();
    1407:             }
    1408:             $this->adminGroupsScheduledForDeletion[]= $adminGroup;
    1409:             $adminGroup->setGroup(null);
    1410:         }
    1411:     }
    1412:
    1413:
    1414:     /**
    1415:      * If this collection has already been initialized with
    1416:      * an identical criteria, it returns the collection.
    1417:      * Otherwise if this Group is new, it will return
    1418:      * an empty collection; or if this Group has previously
    1419:      * been saved, it will retrieve related AdminGroups from storage.
    1420:      *
    1421:      * This method is protected by default in order to keep the public
    1422:      * api reasonable.  You can provide public methods for those you
    1423:      * actually need in Group.
    1424:      *
    1425:      * @param Criteria $criteria optional Criteria object to narrow the query
    1426:      * @param PropelPDO $con optional connection object
    1427:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
    1428:      * @return PropelObjectCollection|AdminGroup[] List of AdminGroup objects
    1429:      */
    1430:     public function getAdminGroupsJoinAdmin($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1431:     {
    1432:         $query = AdminGroupQuery::create(null, $criteria);
    1433:         $query->joinWith('Admin', $join_behavior);
    1434:
    1435:         return $this->getAdminGroups($query, $con);
    1436:     }
    1437:
    1438:     /**
    1439:      * Clears out the collGroupResources collection
    1440:      *
    1441:      * This does not modify the database; however, it will remove any associated objects, causing
    1442:      * them to be refetched by subsequent calls to accessor method.
    1443:      *
    1444:      * @return void
    1445:      * @see        addGroupResources()
    1446:      */
    1447:     public function clearGroupResources()
    1448:     {
    1449:         $this->collGroupResources = null; // important to set this to null since that means it is uninitialized
    1450:         $this->collGroupResourcesPartial = null;
    1451:     }
    1452:
    1453:     /**
    1454:      * reset is the collGroupResources collection loaded partially
    1455:      *
    1456:      * @return void
    1457:      */
    1458:     public function resetPartialGroupResources($v = true)
    1459:     {
    1460:         $this->collGroupResourcesPartial = $v;
    1461:     }
    1462:
    1463:     /**
    1464:      * Initializes the collGroupResources collection.
    1465:      *
    1466:      * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources());
    1467:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1468:      * to your application -- for example, setting the initial array to the values stored in database.
    1469:      *
    1470:      * @param boolean $overrideExisting If set to true, the method call initializes
    1471:      *                                        the collection even if it is not empty
    1472:      *
    1473:      * @return void
    1474:      */
    1475:     public function initGroupResources($overrideExisting = true)
    1476:     {
    1477:         if (null !== $this->collGroupResources && !$overrideExisting) {
    1478:             return;
    1479:         }
    1480:         $this->collGroupResources = new PropelObjectCollection();
    1481:         $this->collGroupResources->setModel('GroupResource');
    1482:     }
    1483:
    1484:     /**
    1485:      * Gets an array of GroupResource objects which contain a foreign key that references this object.
    1486:      *
    1487:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1488:      * Otherwise the results are fetched from the database the first time, then cached.
    1489:      * Next time the same method is called without $criteria, the cached collection is returned.
    1490:      * If this Group is new, it will return
    1491:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1492:      *
    1493:      * @param Criteria $criteria optional Criteria object to narrow the query
    1494:      * @param PropelPDO $con optional connection object
    1495:      * @return PropelObjectCollection|GroupResource[] List of GroupResource objects
    1496:      * @throws PropelException
    1497:      */
    1498:     public function getGroupResources($criteria = null, PropelPDO $con = null)
    1499:     {
    1500:         $partial = $this->collGroupResourcesPartial && !$this->isNew();
    1501:         if (null === $this->collGroupResources || null !== $criteria  || $partial) {
    1502:             if ($this->isNew() && null === $this->collGroupResources) {
    1503:                 // return empty collection
    1504:                 $this->initGroupResources();
    1505:             } else {
    1506:                 $collGroupResources = GroupResourceQuery::create(null, $criteria)
    1507:                     ->filterByGroup($this)
    1508:                     ->find($con);
    1509:                 if (null !== $criteria) {
    1510:                     if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) {
    1511:                       $this->initGroupResources(false);
    1512:
    1513:                       foreach($collGroupResources as $obj) {
    1514:                         if (false == $this->collGroupResources->contains($obj)) {
    1515:                           $this->collGroupResources->append($obj);
    1516:                         }
    1517:                       }
    1518:
    1519:                       $this->collGroupResourcesPartial = true;
    1520:                     }
    1521:
    1522:                     return $collGroupResources;
    1523:                 }
    1524:
    1525:                 if($partial && $this->collGroupResources) {
    1526:                     foreach($this->collGroupResources as $obj) {
    1527:                         if($obj->isNew()) {
    1528:                             $collGroupResources[] = $obj;
    1529:                         }
    1530:                     }
    1531:                 }
    1532:
    1533:                 $this->collGroupResources = $collGroupResources;
    1534:                 $this->collGroupResourcesPartial = false;
    1535:             }
    1536:         }
    1537:
    1538:         return $this->collGroupResources;
    1539:     }
    1540:
    1541:     /**
    1542:      * Sets a collection of GroupResource objects related by a one-to-many relationship
    1543:      * to the current object.
    1544:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    1545:      * and new objects from the given Propel collection.
    1546:      *
    1547:      * @param PropelCollection $groupResources A Propel collection.
    1548:      * @param PropelPDO $con Optional connection object
    1549:      */
    1550:     public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null)
    1551:     {
    1552:         $this->groupResourcesScheduledForDeletion = $this->getGroupResources(new Criteria(), $con)->diff($groupResources);
    1553:
    1554:         foreach ($this->groupResourcesScheduledForDeletion as $groupResourceRemoved) {
    1555:             $groupResourceRemoved->setGroup(null);
    1556:         }
    1557:
    1558:         $this->collGroupResources = null;
    1559:         foreach ($groupResources as $groupResource) {
    1560:             $this->addGroupResource($groupResource);
    1561:         }
    1562:
    1563:         $this->collGroupResources = $groupResources;
    1564:         $this->collGroupResourcesPartial = false;
    1565:     }
    1566:
    1567:     /**
    1568:      * Returns the number of related GroupResource objects.
    1569:      *
    1570:      * @param Criteria $criteria
    1571:      * @param boolean $distinct
    1572:      * @param PropelPDO $con
    1573:      * @return int             Count of related GroupResource objects.
    1574:      * @throws PropelException
    1575:      */
    1576:     public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    1577:     {
    1578:         $partial = $this->collGroupResourcesPartial && !$this->isNew();
    1579:         if (null === $this->collGroupResources || null !== $criteria || $partial) {
    1580:             if ($this->isNew() && null === $this->collGroupResources) {
    1581:                 return 0;
    1582:             } else {
    1583:                 if($partial && !$criteria) {
    1584:                     return count($this->getGroupResources());
    1585:                 }
    1586:                 $query = GroupResourceQuery::create(null, $criteria);
    1587:                 if ($distinct) {
    1588:                     $query->distinct();
    1589:                 }
    1590:
    1591:                 return $query
    1592:                     ->filterByGroup($this)
    1593:                     ->count($con);
    1594:             }
    1595:         } else {
    1596:             return count($this->collGroupResources);
    1597:         }
    1598:     }
    1599:
    1600:     /**
    1601:      * Method called to associate a GroupResource object to this object
    1602:      * through the GroupResource foreign key attribute.
    1603:      *
    1604:      * @param    GroupResource $l GroupResource
    1605:      * @return Group The current object (for fluent API support)
    1606:      */
    1607:     public function addGroupResource(GroupResource $l)
    1608:     {
    1609:         if ($this->collGroupResources === null) {
    1610:             $this->initGroupResources();
    1611:             $this->collGroupResourcesPartial = true;
    1612:         }
    1613:         if (!$this->collGroupResources->contains($l)) { // only add it if the **same** object is not already associated
    1614:             $this->doAddGroupResource($l);
    1615:         }
    1616:
    1617:         return $this;
    1618:     }
    1619:
    1620:     /**
    1621:      * @param   GroupResource $groupResource The groupResource object to add.
    1622:      */
    1623:     protected function doAddGroupResource($groupResource)
    1624:     {
    1625:         $this->collGroupResources[]= $groupResource;
    1626:         $groupResource->setGroup($this);
    1627:     }
    1628:
    1629:     /**
    1630:      * @param   GroupResource $groupResource The groupResource object to remove.
    1631:      */
    1632:     public function removeGroupResource($groupResource)
    1633:     {
    1634:         if ($this->getGroupResources()->contains($groupResource)) {
    1635:             $this->collGroupResources->remove($this->collGroupResources->search($groupResource));
    1636:             if (null === $this->groupResourcesScheduledForDeletion) {
    1637:                 $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources;
    1638:                 $this->groupResourcesScheduledForDeletion->clear();
    1639:             }
    1640:             $this->groupResourcesScheduledForDeletion[]= $groupResource;
    1641:             $groupResource->setGroup(null);
    1642:         }
    1643:     }
    1644:
    1645:
    1646:     /**
    1647:      * If this collection has already been initialized with
    1648:      * an identical criteria, it returns the collection.
    1649:      * Otherwise if this Group is new, it will return
    1650:      * an empty collection; or if this Group has previously
    1651:      * been saved, it will retrieve related GroupResources from storage.
    1652:      *
    1653:      * This method is protected by default in order to keep the public
    1654:      * api reasonable.  You can provide public methods for those you
    1655:      * actually need in Group.
    1656:      *
    1657:      * @param Criteria $criteria optional Criteria object to narrow the query
    1658:      * @param PropelPDO $con optional connection object
    1659:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
    1660:      * @return PropelObjectCollection|GroupResource[] List of GroupResource objects
    1661:      */
    1662:     public function getGroupResourcesJoinResource($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1663:     {
    1664:         $query = GroupResourceQuery::create(null, $criteria);
    1665:         $query->joinWith('Resource', $join_behavior);
    1666:
    1667:         return $this->getGroupResources($query, $con);
    1668:     }
    1669:
    1670:     /**
    1671:      * Clears out the collGroupModules collection
    1672:      *
    1673:      * This does not modify the database; however, it will remove any associated objects, causing
    1674:      * them to be refetched by subsequent calls to accessor method.
    1675:      *
    1676:      * @return void
    1677:      * @see        addGroupModules()
    1678:      */
    1679:     public function clearGroupModules()
    1680:     {
    1681:         $this->collGroupModules = null; // important to set this to null since that means it is uninitialized
    1682:         $this->collGroupModulesPartial = null;
    1683:     }
    1684:
    1685:     /**
    1686:      * reset is the collGroupModules collection loaded partially
    1687:      *
    1688:      * @return void
    1689:      */
    1690:     public function resetPartialGroupModules($v = true)
    1691:     {
    1692:         $this->collGroupModulesPartial = $v;
    1693:     }
    1694:
    1695:     /**
    1696:      * Initializes the collGroupModules collection.
    1697:      *
    1698:      * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules());
    1699:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1700:      * to your application -- for example, setting the initial array to the values stored in database.
    1701:      *
    1702:      * @param boolean $overrideExisting If set to true, the method call initializes
    1703:      *                                        the collection even if it is not empty
    1704:      *
    1705:      * @return void
    1706:      */
    1707:     public function initGroupModules($overrideExisting = true)
    1708:     {
    1709:         if (null !== $this->collGroupModules && !$overrideExisting) {
    1710:             return;
    1711:         }
    1712:         $this->collGroupModules = new PropelObjectCollection();
    1713:         $this->collGroupModules->setModel('GroupModule');
    1714:     }
    1715:
    1716:     /**
    1717:      * Gets an array of GroupModule objects which contain a foreign key that references this object.
    1718:      *
    1719:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1720:      * Otherwise the results are fetched from the database the first time, then cached.
    1721:      * Next time the same method is called without $criteria, the cached collection is returned.
    1722:      * If this Group is new, it will return
    1723:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1724:      *
    1725:      * @param Criteria $criteria optional Criteria object to narrow the query
    1726:      * @param PropelPDO $con optional connection object
    1727:      * @return PropelObjectCollection|GroupModule[] List of GroupModule objects
    1728:      * @throws PropelException
    1729:      */
    1730:     public function getGroupModules($criteria = null, PropelPDO $con = null)
    1731:     {
    1732:         $partial = $this->collGroupModulesPartial && !$this->isNew();
    1733:         if (null === $this->collGroupModules || null !== $criteria  || $partial) {
    1734:             if ($this->isNew() && null === $this->collGroupModules) {
    1735:                 // return empty collection
    1736:                 $this->initGroupModules();
    1737:             } else {
    1738:                 $collGroupModules = GroupModuleQuery::create(null, $criteria)
    1739:                     ->filterByGroup($this)
    1740:                     ->find($con);
    1741:                 if (null !== $criteria) {
    1742:                     if (false !== $this->collGroupModulesPartial && count($collGroupModules)) {
    1743:                       $this->initGroupModules(false);
    1744:
    1745:                       foreach($collGroupModules as $obj) {
    1746:                         if (false == $this->collGroupModules->contains($obj)) {
    1747:                           $this->collGroupModules->append($obj);
    1748:                         }
    1749:                       }
    1750:
    1751:                       $this->collGroupModulesPartial = true;
    1752:                     }
    1753:
    1754:                     return $collGroupModules;
    1755:                 }
    1756:
    1757:                 if($partial && $this->collGroupModules) {
    1758:                     foreach($this->collGroupModules as $obj) {
    1759:                         if($obj->isNew()) {
    1760:                             $collGroupModules[] = $obj;
    1761:                         }
    1762:                     }
    1763:                 }
    1764:
    1765:                 $this->collGroupModules = $collGroupModules;
    1766:                 $this->collGroupModulesPartial = false;
    1767:             }
    1768:         }
    1769:
    1770:         return $this->collGroupModules;
    1771:     }
    1772:
    1773:     /**
    1774:      * Sets a collection of GroupModule objects related by a one-to-many relationship
    1775:      * to the current object.
    1776:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    1777:      * and new objects from the given Propel collection.
    1778:      *
    1779:      * @param PropelCollection $groupModules A Propel collection.
    1780:      * @param PropelPDO $con Optional connection object
    1781:      */
    1782:     public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null)
    1783:     {
    1784:         $this->groupModulesScheduledForDeletion = $this->getGroupModules(new Criteria(), $con)->diff($groupModules);
    1785:
    1786:         foreach ($this->groupModulesScheduledForDeletion as $groupModuleRemoved) {
    1787:             $groupModuleRemoved->setGroup(null);
    1788:         }
    1789:
    1790:         $this->collGroupModules = null;
    1791:         foreach ($groupModules as $groupModule) {
    1792:             $this->addGroupModule($groupModule);
    1793:         }
    1794:
    1795:         $this->collGroupModules = $groupModules;
    1796:         $this->collGroupModulesPartial = false;
    1797:     }
    1798:
    1799:     /**
    1800:      * Returns the number of related GroupModule objects.
    1801:      *
    1802:      * @param Criteria $criteria
    1803:      * @param boolean $distinct
    1804:      * @param PropelPDO $con
    1805:      * @return int             Count of related GroupModule objects.
    1806:      * @throws PropelException
    1807:      */
    1808:     public function countGroupModules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    1809:     {
    1810:         $partial = $this->collGroupModulesPartial && !$this->isNew();
    1811:         if (null === $this->collGroupModules || null !== $criteria || $partial) {
    1812:             if ($this->isNew() && null === $this->collGroupModules) {
    1813:                 return 0;
    1814:             } else {
    1815:                 if($partial && !$criteria) {
    1816:                     return count($this->getGroupModules());
    1817:                 }
    1818:                 $query = GroupModuleQuery::create(null, $criteria);
    1819:                 if ($distinct) {
    1820:                     $query->distinct();
    1821:                 }
    1822:
    1823:                 return $query
    1824:                     ->filterByGroup($this)
    1825:                     ->count($con);
    1826:             }
    1827:         } else {
    1828:             return count($this->collGroupModules);
    1829:         }
    1830:     }
    1831:
    1832:     /**
    1833:      * Method called to associate a GroupModule object to this object
    1834:      * through the GroupModule foreign key attribute.
    1835:      *
    1836:      * @param    GroupModule $l GroupModule
    1837:      * @return Group The current object (for fluent API support)
    1838:      */
    1839:     public function addGroupModule(GroupModule $l)
    1840:     {
    1841:         if ($this->collGroupModules === null) {
    1842:             $this->initGroupModules();
    1843:             $this->collGroupModulesPartial = true;
    1844:         }
    1845:         if (!$this->collGroupModules->contains($l)) { // only add it if the **same** object is not already associated
    1846:             $this->doAddGroupModule($l);
    1847:         }
    1848:
    1849:         return $this;
    1850:     }
    1851:
    1852:     /**
    1853:      * @param   GroupModule $groupModule The groupModule object to add.
    1854:      */
    1855:     protected function doAddGroupModule($groupModule)
    1856:     {
    1857:         $this->collGroupModules[]= $groupModule;
    1858:         $groupModule->setGroup($this);
    1859:     }
    1860:
    1861:     /**
    1862:      * @param   GroupModule $groupModule The groupModule object to remove.
    1863:      */
    1864:     public function removeGroupModule($groupModule)
    1865:     {
    1866:         if ($this->getGroupModules()->contains($groupModule)) {
    1867:             $this->collGroupModules->remove($this->collGroupModules->search($groupModule));
    1868:             if (null === $this->groupModulesScheduledForDeletion) {
    1869:                 $this->groupModulesScheduledForDeletion = clone $this->collGroupModules;
    1870:                 $this->groupModulesScheduledForDeletion->clear();
    1871:             }
    1872:             $this->groupModulesScheduledForDeletion[]= $groupModule;
    1873:             $groupModule->setGroup(null);
    1874:         }
    1875:     }
    1876:
    1877:
    1878:     /**
    1879:      * If this collection has already been initialized with
    1880:      * an identical criteria, it returns the collection.
    1881:      * Otherwise if this Group is new, it will return
    1882:      * an empty collection; or if this Group has previously
    1883:      * been saved, it will retrieve related GroupModules from storage.
    1884:      *
    1885:      * This method is protected by default in order to keep the public
    1886:      * api reasonable.  You can provide public methods for those you
    1887:      * actually need in Group.
    1888:      *
    1889:      * @param Criteria $criteria optional Criteria object to narrow the query
    1890:      * @param PropelPDO $con optional connection object
    1891:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
    1892:      * @return PropelObjectCollection|GroupModule[] List of GroupModule objects
    1893:      */
    1894:     public function getGroupModulesJoinModule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
    1895:     {
    1896:         $query = GroupModuleQuery::create(null, $criteria);
    1897:         $query->joinWith('Module', $join_behavior);
    1898:
    1899:         return $this->getGroupModules($query, $con);
    1900:     }
    1901:
    1902:     /**
    1903:      * Clears out the collGroupI18ns collection
    1904:      *
    1905:      * This does not modify the database; however, it will remove any associated objects, causing
    1906:      * them to be refetched by subsequent calls to accessor method.
    1907:      *
    1908:      * @return void
    1909:      * @see        addGroupI18ns()
    1910:      */
    1911:     public function clearGroupI18ns()
    1912:     {
    1913:         $this->collGroupI18ns = null; // important to set this to null since that means it is uninitialized
    1914:         $this->collGroupI18nsPartial = null;
    1915:     }
    1916:
    1917:     /**
    1918:      * reset is the collGroupI18ns collection loaded partially
    1919:      *
    1920:      * @return void
    1921:      */
    1922:     public function resetPartialGroupI18ns($v = true)
    1923:     {
    1924:         $this->collGroupI18nsPartial = $v;
    1925:     }
    1926:
    1927:     /**
    1928:      * Initializes the collGroupI18ns collection.
    1929:      *
    1930:      * By default this just sets the collGroupI18ns collection to an empty array (like clearcollGroupI18ns());
    1931:      * however, you may wish to override this method in your stub class to provide setting appropriate
    1932:      * to your application -- for example, setting the initial array to the values stored in database.
    1933:      *
    1934:      * @param boolean $overrideExisting If set to true, the method call initializes
    1935:      *                                        the collection even if it is not empty
    1936:      *
    1937:      * @return void
    1938:      */
    1939:     public function initGroupI18ns($overrideExisting = true)
    1940:     {
    1941:         if (null !== $this->collGroupI18ns && !$overrideExisting) {
    1942:             return;
    1943:         }
    1944:         $this->collGroupI18ns = new PropelObjectCollection();
    1945:         $this->collGroupI18ns->setModel('GroupI18n');
    1946:     }
    1947:
    1948:     /**
    1949:      * Gets an array of GroupI18n objects which contain a foreign key that references this object.
    1950:      *
    1951:      * If the $criteria is not null, it is used to always fetch the results from the database.
    1952:      * Otherwise the results are fetched from the database the first time, then cached.
    1953:      * Next time the same method is called without $criteria, the cached collection is returned.
    1954:      * If this Group is new, it will return
    1955:      * an empty collection or the current collection; the criteria is ignored on a new object.
    1956:      *
    1957:      * @param Criteria $criteria optional Criteria object to narrow the query
    1958:      * @param PropelPDO $con optional connection object
    1959:      * @return PropelObjectCollection|GroupI18n[] List of GroupI18n objects
    1960:      * @throws PropelException
    1961:      */
    1962:     public function getGroupI18ns($criteria = null, PropelPDO $con = null)
    1963:     {
    1964:         $partial = $this->collGroupI18nsPartial && !$this->isNew();
    1965:         if (null === $this->collGroupI18ns || null !== $criteria  || $partial) {
    1966:             if ($this->isNew() && null === $this->collGroupI18ns) {
    1967:                 // return empty collection
    1968:                 $this->initGroupI18ns();
    1969:             } else {
    1970:                 $collGroupI18ns = GroupI18nQuery::create(null, $criteria)
    1971:                     ->filterByGroup($this)
    1972:                     ->find($con);
    1973:                 if (null !== $criteria) {
    1974:                     if (false !== $this->collGroupI18nsPartial && count($collGroupI18ns)) {
    1975:                       $this->initGroupI18ns(false);
    1976:
    1977:                       foreach($collGroupI18ns as $obj) {
    1978:                         if (false == $this->collGroupI18ns->contains($obj)) {
    1979:                           $this->collGroupI18ns->append($obj);
    1980:                         }
    1981:                       }
    1982:
    1983:                       $this->collGroupI18nsPartial = true;
    1984:                     }
    1985:
    1986:                     return $collGroupI18ns;
    1987:                 }
    1988:
    1989:                 if($partial && $this->collGroupI18ns) {
    1990:                     foreach($this->collGroupI18ns as $obj) {
    1991:                         if($obj->isNew()) {
    1992:                             $collGroupI18ns[] = $obj;
    1993:                         }
    1994:                     }
    1995:                 }
    1996:
    1997:                 $this->collGroupI18ns = $collGroupI18ns;
    1998:                 $this->collGroupI18nsPartial = false;
    1999:             }
    2000:         }
    2001:
    2002:         return $this->collGroupI18ns;
    2003:     }
    2004:
    2005:     /**
    2006:      * Sets a collection of GroupI18n objects related by a one-to-many relationship
    2007:      * to the current object.
    2008:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
    2009:      * and new objects from the given Propel collection.
    2010:      *
    2011:      * @param PropelCollection $groupI18ns A Propel collection.
    2012:      * @param PropelPDO $con Optional connection object
    2013:      */
    2014:     public function setGroupI18ns(PropelCollection $groupI18ns, PropelPDO $con = null)
    2015:     {
    2016:         $this->groupI18nsScheduledForDeletion = $this->getGroupI18ns(new Criteria(), $con)->diff($groupI18ns);
    2017:
    2018:         foreach ($this->groupI18nsScheduledForDeletion as $groupI18nRemoved) {
    2019:             $groupI18nRemoved->setGroup(null);
    2020:         }
    2021:
    2022:         $this->collGroupI18ns = null;
    2023:         foreach ($groupI18ns as $groupI18n) {
    2024:             $this->addGroupI18n($groupI18n);
    2025:         }
    2026:
    2027:         $this->collGroupI18ns = $groupI18ns;
    2028:         $this->collGroupI18nsPartial = false;
    2029:     }
    2030:
    2031:     /**
    2032:      * Returns the number of related GroupI18n objects.
    2033:      *
    2034:      * @param Criteria $criteria
    2035:      * @param boolean $distinct
    2036:      * @param PropelPDO $con
    2037:      * @return int             Count of related GroupI18n objects.
    2038:      * @throws PropelException
    2039:      */
    2040:     public function countGroupI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
    2041:     {
    2042:         $partial = $this->collGroupI18nsPartial && !$this->isNew();
    2043:         if (null === $this->collGroupI18ns || null !== $criteria || $partial) {
    2044:             if ($this->isNew() && null === $this->collGroupI18ns) {
    2045:                 return 0;
    2046:             } else {
    2047:                 if($partial && !$criteria) {
    2048:                     return count($this->getGroupI18ns());
    2049:                 }
    2050:                 $query = GroupI18nQuery::create(null, $criteria);
    2051:                 if ($distinct) {
    2052:                     $query->distinct();
    2053:                 }
    2054:
    2055:                 return $query
    2056:                     ->filterByGroup($this)
    2057:                     ->count($con);
    2058:             }
    2059:         } else {
    2060:             return count($this->collGroupI18ns);
    2061:         }
    2062:     }
    2063:
    2064:     /**
    2065:      * Method called to associate a GroupI18n object to this object
    2066:      * through the GroupI18n foreign key attribute.
    2067:      *
    2068:      * @param    GroupI18n $l GroupI18n
    2069:      * @return Group The current object (for fluent API support)
    2070:      */
    2071:     public function addGroupI18n(GroupI18n $l)
    2072:     {
    2073:         if ($l && $locale = $l->getLocale()) {
    2074:             $this->setLocale($locale);
    2075:             $this->currentTranslations[$locale] = $l;
    2076:         }
    2077:         if ($this->collGroupI18ns === null) {
    2078:             $this->initGroupI18ns();
    2079:             $this->collGroupI18nsPartial = true;
    2080:         }
    2081:         if (!$this->collGroupI18ns->contains($l)) { // only add it if the **same** object is not already associated
    2082:             $this->doAddGroupI18n($l);
    2083:         }
    2084:
    2085:         return $this;
    2086:     }
    2087:
    2088:     /**
    2089:      * @param   GroupI18n $groupI18n The groupI18n object to add.
    2090:      */
    2091:     protected function doAddGroupI18n($groupI18n)
    2092:     {
    2093:         $this->collGroupI18ns[]= $groupI18n;
    2094:         $groupI18n->setGroup($this);
    2095:     }
    2096:
    2097:     /**
    2098:      * @param   GroupI18n $groupI18n The groupI18n object to remove.
    2099:      */
    2100:     public function removeGroupI18n($groupI18n)
    2101:     {
    2102:         if ($this->getGroupI18ns()->contains($groupI18n)) {
    2103:             $this->collGroupI18ns->remove($this->collGroupI18ns->search($groupI18n));
    2104:             if (null === $this->groupI18nsScheduledForDeletion) {
    2105:                 $this->groupI18nsScheduledForDeletion = clone $this->collGroupI18ns;
    2106:                 $this->groupI18nsScheduledForDeletion->clear();
    2107:             }
    2108:             $this->groupI18nsScheduledForDeletion[]= $groupI18n;
    2109:             $groupI18n->setGroup(null);
    2110:         }
    2111:     }
    2112:
    2113:     /**
    2114:      * Clears the current object and sets all attributes to their default values
    2115:      */
    2116:     public function clear()
    2117:     {
    2118:         $this->id = null;
    2119:         $this->code = null;
    2120:         $this->created_at = null;
    2121:         $this->updated_at = null;
    2122:         $this->alreadyInSave = false;
    2123:         $this->alreadyInValidation = false;
    2124:         $this->clearAllReferences();
    2125:         $this->resetModified();
    2126:         $this->setNew(true);
    2127:         $this->setDeleted(false);
    2128:     }
    2129:
    2130:     /**
    2131:      * Resets all references to other model objects or collections of model objects.
    2132:      *
    2133:      * This method is a user-space workaround for PHP's inability to garbage collect
    2134:      * objects with circular references (even in PHP 5.3). This is currently necessary
    2135:      * when using Propel in certain daemon or large-volumne/high-memory operations.
    2136:      *
    2137:      * @param boolean $deep Whether to also clear the references on all referrer objects.
    2138:      */
    2139:     public function clearAllReferences($deep = false)
    2140:     {
    2141:         if ($deep) {
    2142:             if ($this->collAdminGroups) {
    2143:                 foreach ($this->collAdminGroups as $o) {
    2144:                     $o->clearAllReferences($deep);
    2145:                 }
    2146:             }
    2147:             if ($this->collGroupResources) {
    2148:                 foreach ($this->collGroupResources as $o) {
    2149:                     $o->clearAllReferences($deep);
    2150:                 }
    2151:             }
    2152:             if ($this->collGroupModules) {
    2153:                 foreach ($this->collGroupModules as $o) {
    2154:                     $o->clearAllReferences($deep);
    2155:                 }
    2156:             }
    2157:             if ($this->collGroupI18ns) {
    2158:                 foreach ($this->collGroupI18ns as $o) {
    2159:                     $o->clearAllReferences($deep);
    2160:                 }
    2161:             }
    2162:         } // if ($deep)
    2163:
    2164:         // i18n behavior
    2165:         $this->currentLocale = 'en_EN';
    2166:         $this->currentTranslations = null;
    2167:
    2168:         if ($this->collAdminGroups instanceof PropelCollection) {
    2169:             $this->collAdminGroups->clearIterator();
    2170:         }
    2171:         $this->collAdminGroups = null;
    2172:         if ($this->collGroupResources instanceof PropelCollection) {
    2173:             $this->collGroupResources->clearIterator();
    2174:         }
    2175:         $this->collGroupResources = null;
    2176:         if ($this->collGroupModules instanceof PropelCollection) {
    2177:             $this->collGroupModules->clearIterator();
    2178:         }
    2179:         $this->collGroupModules = null;
    2180:         if ($this->collGroupI18ns instanceof PropelCollection) {
    2181:             $this->collGroupI18ns->clearIterator();
    2182:         }
    2183:         $this->collGroupI18ns = null;
    2184:     }
    2185:
    2186:     /**
    2187:      * return the string representation of this object
    2188:      *
    2189:      * @return string
    2190:      */
    2191:     public function __toString()
    2192:     {
    2193:         return (string) $this->exportTo(GroupPeer::DEFAULT_STRING_FORMAT);
    2194:     }
    2195:
    2196:     /**
    2197:      * return true is the object is in saving state
    2198:      *
    2199:      * @return boolean
    2200:      */
    2201:     public function isAlreadyInSave()
    2202:     {
    2203:         return $this->alreadyInSave;
    2204:     }
    2205:
    2206:     // timestampable behavior
    2207:
    2208:     /**
    2209:      * Mark the current object so that the update date doesn't get updated during next save
    2210:      *
    2211:      * @return     Group The current object (for fluent API support)
    2212:      */
    2213:     public function keepUpdateDateUnchanged()
    2214:     {
    2215:         $this->modifiedColumns[] = GroupPeer::UPDATED_AT;
    2216:
    2217:         return $this;
    2218:     }
    2219:
    2220:     // i18n behavior
    2221:
    2222:     /**
    2223:      * Sets the locale for translations
    2224:      *
    2225:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    2226:      *
    2227:      * @return    Group The current object (for fluent API support)
    2228:      */
    2229:     public function setLocale($locale = 'en_EN')
    2230:     {
    2231:         $this->currentLocale = $locale;
    2232:
    2233:         return $this;
    2234:     }
    2235:
    2236:     /**
    2237:      * Gets the locale for translations
    2238:      *
    2239:      * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
    2240:      */
    2241:     public function getLocale()
    2242:     {
    2243:         return $this->currentLocale;
    2244:     }
    2245:
    2246:     /**
    2247:      * Returns the current translation for a given locale
    2248:      *
    2249:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    2250:      * @param     PropelPDO $con an optional connection object
    2251:      *
    2252:      * @return GroupI18n */
    2253:     public function getTranslation($locale = 'en_EN', PropelPDO $con = null)
    2254:     {
    2255:         if (!isset($this->currentTranslations[$locale])) {
    2256:             if (null !== $this->collGroupI18ns) {
    2257:                 foreach ($this->collGroupI18ns as $translation) {
    2258:                     if ($translation->getLocale() == $locale) {
    2259:                         $this->currentTranslations[$locale] = $translation;
    2260:
    2261:                         return $translation;
    2262:                     }
    2263:                 }
    2264:             }
    2265:             if ($this->isNew()) {
    2266:                 $translation = new GroupI18n();
    2267:                 $translation->setLocale($locale);
    2268:             } else {
    2269:                 $translation = GroupI18nQuery::create()
    2270:                     ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
    2271:                     ->findOneOrCreate($con);
    2272:                 $this->currentTranslations[$locale] = $translation;
    2273:             }
    2274:             $this->addGroupI18n($translation);
    2275:         }
    2276:
    2277:         return $this->currentTranslations[$locale];
    2278:     }
    2279:
    2280:     /**
    2281:      * Remove the translation for a given locale
    2282:      *
    2283:      * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
    2284:      * @param     PropelPDO $con an optional connection object
    2285:      *
    2286:      * @return    Group The current object (for fluent API support)
    2287:      */
    2288:     public function removeTranslation($locale = 'en_EN', PropelPDO $con = null)
    2289:     {
    2290:         if (!$this->isNew()) {
    2291:             GroupI18nQuery::create()
    2292:                 ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
    2293:                 ->delete($con);
    2294:         }
    2295:         if (isset($this->currentTranslations[$locale])) {
    2296:             unset($this->currentTranslations[$locale]);
    2297:         }
    2298:         foreach ($this->collGroupI18ns as $key => $translation) {
    2299:             if ($translation->getLocale() == $locale) {
    2300:                 unset($this->collGroupI18ns[$key]);
    2301:                 break;
    2302:             }
    2303:         }
    2304:
    2305:         return $this;
    2306:     }
    2307:
    2308:     /**
    2309:      * Returns the current translation
    2310:      *
    2311:      * @param     PropelPDO $con an optional connection object
    2312:      *
    2313:      * @return GroupI18n */
    2314:     public function getCurrentTranslation(PropelPDO $con = null)
    2315:     {
    2316:         return $this->getTranslation($this->getLocale(), $con);
    2317:     }
    2318:
    2319:
    2320:         /**
    2321:          * Get the [title] column value.
    2322:          *
    2323:          * @return string
    2324:          */
    2325:         public function getTitle()
    2326:         {
    2327:         return $this->getCurrentTranslation()->getTitle();
    2328:     }
    2329:
    2330:
    2331:         /**
    2332:          * Set the value of [title] column.
    2333:          *
    2334:          * @param string $v new value
    2335:          * @return GroupI18n The current object (for fluent API support)
    2336:          */
    2337:         public function setTitle($v)
    2338:         {    $this->getCurrentTranslation()->setTitle($v);
    2339:
    2340:         return $this;
    2341:     }
    2342:
    2343:
    2344:         /**
    2345:          * Get the [description] column value.
    2346:          *
    2347:          * @return string
    2348:          */
    2349:         public function getDescription()
    2350:         {
    2351:         return $this->getCurrentTranslation()->getDescription();
    2352:     }
    2353:
    2354:
    2355:         /**
    2356:          * Set the value of [description] column.
    2357:          *
    2358:          * @param string $v new value
    2359:          * @return GroupI18n The current object (for fluent API support)
    2360:          */
    2361:         public function setDescription($v)
    2362:         {    $this->getCurrentTranslation()->setDescription($v);
    2363:
    2364:         return $this;
    2365:     }
    2366:
    2367:
    2368:         /**
    2369:          * Get the [chapo] column value.
    2370:          *
    2371:          * @return string
    2372:          */
    2373:         public function getChapo()
    2374:         {
    2375:         return $this->getCurrentTranslation()->getChapo();
    2376:     }
    2377:
    2378:
    2379:         /**
    2380:          * Set the value of [chapo] column.
    2381:          *
    2382:          * @param string $v new value
    2383:          * @return GroupI18n The current object (for fluent API support)
    2384:          */
    2385:         public function setChapo($v)
    2386:         {    $this->getCurrentTranslation()->setChapo($v);
    2387:
    2388:         return $this;
    2389:     }
    2390:
    2391:
    2392:         /**
    2393:          * Get the [postscriptum] column value.
    2394:          *
    2395:          * @return string
    2396:          */
    2397:         public function getPostscriptum()
    2398:         {
    2399:         return $this->getCurrentTranslation()->getPostscriptum();
    2400:     }
    2401:
    2402:
    2403:         /**
    2404:          * Set the value of [postscriptum] column.
    2405:          *
    2406:          * @param string $v new value
    2407:          * @return GroupI18n The current object (for fluent API support)
    2408:          */
    2409:         public function setPostscriptum($v)
    2410:         {    $this->getCurrentTranslation()->setPostscriptum($v);
    2411:
    2412:         return $this;
    2413:     }
    2414:
    2415: }
    2416: