Beispiel #1
0
 public function executeAjaxSaveRoles(sfWebRequest $request)
 {
     $email_list = EmailListPeer::retrieveByPK($request->getParameter('email_list_id'));
     $this->forward404Unless($email_list);
     $roles = $request->getParameter('roles');
     $c = new Criteria();
     $c->add(EmailListRolePeer::LIST_ID, $email_list->getId());
     EmailListRolePeer::doDelete($c);
     foreach ($roles as $id) {
         $email_list_role = new EmailListRole();
         $email_list_role->setRoleId($id);
         $email_list_role->setListId($email_list->getId());
         $email_list_role->save();
     }
     $this->email_list = $email_list;
 }
Beispiel #2
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->person = PersonPeer::retrieveByPK($this->getUser()->getId());
     if ($pilot_id = $this->getUser()->getPilotId()) {
         $this->pilot = PilotPeer::retrieveByPK($pilot_id);
     } else {
         $this->pilot = null;
     }
     if ($member_id = $this->getUser()->getMemberId()) {
         $this->member = MemberPeer::retrieveByPK($member_id);
         // Farazi Renewal date calculation
         $date_now = strtotime("NOW");
         $date_ren = strtotime($this->member->getRenewalDate());
         $sub = $date_ren - $date_now;
         $preday = 0;
         if ($sub >= 86400) {
             $pday = $sub / 86400;
             $preday = explode('.', $pday);
         } else {
             $pday = $sub / 86400;
             $preday = explode('.', $pday);
         }
         $this->due_day = $preday[0];
         //End Farazi Renewal date calculation
     } else {
         $this->member = null;
     }
     if ($this->member !== null && $this->pilot !== null) {
         $this->availability = $this->member->getAvailability();
     }
     if (!$this->availability instanceof Availability) {
         $this->availability = new Availability();
     }
     $this->email_lists = EmailListPeer::doSelect(new Criteria());
     $this->subscribed_list = EmailListPersonPeer::getEmailListIdsByPersonId($this->person->getId());
 }
Beispiel #3
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = EmailListPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setDescription($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setIsPrivate($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setWingId($arr[$keys[3]]);
     }
 }
 /**
  * Selects a collection of EmailListRole objects pre-filled with all related objects except Role.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of EmailListRole objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptRole(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     EmailListRolePeer::addSelectColumns($c);
     $startcol2 = EmailListRolePeer::NUM_COLUMNS - EmailListRolePeer::NUM_LAZY_LOAD_COLUMNS;
     EmailListPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (EmailListPeer::NUM_COLUMNS - EmailListPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(EmailListRolePeer::LIST_ID), array(EmailListPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = EmailListRolePeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = EmailListRolePeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = EmailListRolePeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             EmailListRolePeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined EmailList rows
         $key2 = EmailListPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = EmailListPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = EmailListPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 EmailListPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (EmailListRole) to the collection in $obj2 (EmailList)
             $obj2->addEmailListRole($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Beispiel #5
0
 public function executeSubscribe(sfWebRequest $request)
 {
     # security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     # for navigation menu
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     slot('nav_menu', array('mission_coord', ''));
     $this->email_list = EmailListPeer::retrieveByPK($request->getParameter('id'));
     $this->forward404Unless($this->email_list);
     # filter
     $this->processFilter($request);
     $this->pager = PersonPeer::getPager($this->max, $this->page, $this->firstname, $this->lastname, $this->gender, $this->city, $this->state, $this->country, $this->county, $this->deceased, $this->deceased_until, $this->deceased_after, $this->email_list->getId());
     $this->persons = $this->pager->getResults();
     $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text'));
 }
Beispiel #6
0
 /**
  * Get the associated EmailList object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     EmailList The associated EmailList object.
  * @throws     PropelException
  */
 public function getEmailList(PropelPDO $con = null)
 {
     if ($this->aEmailList === null && $this->list_id !== null) {
         $c = new Criteria(EmailListPeer::DATABASE_NAME);
         $c->add(EmailListPeer::ID, $this->list_id);
         $this->aEmailList = EmailListPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aEmailList->addEmailListPersons($this);
         		 */
     }
     return $this->aEmailList;
 }
Beispiel #7
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(EmailListPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EmailListPeer::DATABASE_NAME);
         $criteria->add(EmailListPeer::ID, $pks, Criteria::IN);
         $objs = EmailListPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Beispiel #8
0
 public function executeWingslist(sfWebRequest $request)
 {
     $this->flight_statuses = sfConfig::get('app_flight_statuses', array());
     $this->email_lists = EmailListPeer::doSelect(new Criteria());
     $this->wings = WingPeer::doSelect(new Criteria());
     $this->states = sfConfig::get('app_states');
 }
Beispiel #9
0
 /**
  * Returns the number of related EmailList objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related EmailList objects.
  * @throws     PropelException
  */
 public function countEmailLists(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(WingPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collEmailLists === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(EmailListPeer::WING_ID, $this->id);
             $count = EmailListPeer::doCount($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(EmailListPeer::WING_ID, $this->id);
             if (!isset($this->lastEmailListCriteria) || !$this->lastEmailListCriteria->equals($criteria)) {
                 $count = EmailListPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collEmailLists);
             }
         } else {
             $count = count($this->collEmailLists);
         }
     }
     return $count;
 }