/**
  * Selects a collection of EmailTracking objects pre-filled with all related objects.
  *
  * @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 EmailTracking objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BaseEmailTrackingPeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BaseEmailTrackingPeer', $c, $con);
     }
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     EmailTrackingPeer::addSelectColumns($c);
     $startcol2 = EmailTrackingPeer::NUM_COLUMNS - EmailTrackingPeer::NUM_LAZY_LOAD_COLUMNS;
     EmailLetterPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (EmailLetterPeer::NUM_COLUMNS - EmailLetterPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(EmailTrackingPeer::LETTER_ID), array(EmailLetterPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = EmailTrackingPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = EmailTrackingPeer::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 = EmailTrackingPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             EmailTrackingPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined EmailLetter rows
         $key2 = EmailLetterPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = EmailLetterPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = EmailLetterPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 EmailLetterPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (EmailTracking) to the collection in $obj2 (EmailLetter)
             $obj2->addEmailTracking($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Exemple #2
0
 /**
  * Get the associated EmailLetter object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     EmailLetter The associated EmailLetter object.
  * @throws     PropelException
  */
 public function getEmailLetter(PropelPDO $con = null)
 {
     if ($this->aEmailLetter === null && $this->letter_id !== null) {
         $c = new Criteria(EmailLetterPeer::DATABASE_NAME);
         $c->add(EmailLetterPeer::ID, $this->letter_id);
         $this->aEmailLetter = EmailLetterPeer::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->aEmailLetter->addEmailTrackings($this);
         		 */
     }
     return $this->aEmailLetter;
 }
Exemple #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 = EmailLetterPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setSubject($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setSenderName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setSenderEmail($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setBody($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setAttachFilePath($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setRecipients($arr[$keys[6]]);
     }
 }
Exemple #4
0
 public function executeListEditBulkSentEmail(sfWebRequest $request)
 {
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri());
         $this->redirect('dashboard/index');
     }
     $this->max_array = array(5, 10, 20, 30);
     $this->max = $this->getMaxBulkQueuedEmailValuePerPage($request, $this->max_array);
     $this->page = $request->getParameter('page', 1);
     $c = new Criteria();
     $c->add(EmailQueuePeer::SEND_STATUS, 'SENT');
     $c->addJoin(EmailQueuePeer::LETTER_ID, EmailLetterPeer::ID, Criteria::LEFT_JOIN);
     $c->setOffset(($this->page - 1) * $this->max);
     $c->setLimit($this->max);
     $this->email_letters = EmailLetterPeer::doSelect($c);
     $this->email_sents = EmailQueuePeer::doSelect($c);
     $this->pager = EmailQueuePeer::getPager($this->max, $this->page, $c);
     $this->sent_email_lists = array();
     foreach ($this->email_letters as $key => $item) {
         $this->sent_email_lists[$key]['send_date'] = $this->email_sents[$key]->getSendDate();
         $this->sent_email_lists[$key]['subject'] = $item->getSubject();
         $this->sent_email_lists[$key]['sender_name'] = $item->getSenderName();
         $this->sent_email_lists[$key]['sender_email'] = $item->getSenderEmail();
         $this->sent_email_lists[$key]['body'] = $item->getBody();
         $this->sent_email_lists[$key]['attach_file_path'] = $item->getAttachFilePath();
         $this->sent_email_lists[$key]['recipients'] = explode(',', $item->getRecipients());
         if ($key >= $this->max - 1) {
             break;
         }
     }
 }
 /**
  * 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(EmailLetterPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EmailLetterPeer::DATABASE_NAME);
         $criteria->add(EmailLetterPeer::ID, $pks, Criteria::IN);
         $objs = EmailLetterPeer::doSelect($criteria, $con);
     }
     return $objs;
 }