/** * 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 = NotificationEmailsPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setUserId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setOnOff($arr[$keys[2]]); } }
/** * Sends a private message from this user to $recipientID * * @param int $recipientID * @param string $subject * @param string $message * @return bool */ public function sendMessage($recipientID, $subject, $message, $stripTags = true) { //If the user is banned, they can't send a message if ($this->getHidden()) { return false; } $recipient = UserPeer::retrieveByPK($recipientID); if (!$recipient) { return false; } $pm = new PrivateMessage(); $pm->setSenderId($this->getId()); $pm->setRecipientID($recipientID); // $subject = $stripTags ? strip_tags($subject, sfConfig::get('app_general_allowed_html_tags')) : $subject; $pm->setSubject($subject); // $message = $stripTags ? strip_tags($message, sfConfig::get('app_general_allowed_html_tags')) : $message; $pm->setBody($message); $saveStatus = $pm->save(); $c = new Criteria(); $c->add(NotificationEmailsPeer::USER_ID, $recipientID); $notifies = NotificationEmailsPeer::doSelectOne($c); if ($notifies != NULL) { if ($notifies->getOnOff() == 0) { if ($saveStatus) { $mailer = Mailman::createMailer(); $mailer->setContentType('text/html'); $mailer->addAddress($recipient->getEmail()); $mailer->setSubject('New Private Message from Rayku.com'); sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Partial')); $mailer->setBody(get_partial('global/mail/newPMNotification', array('pm' => $pm))); //Send the e-mail off $mailer->send(); } } } else { if ($saveStatus) { $mailer = Mailman::createMailer(); $mailer->setContentType('text/html'); $mailer->addAddress($recipient->getEmail()); $mailer->setSubject('New Private Message from Rayku.com'); sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Partial')); $mailer->setBody(get_partial('global/mail/newPMNotification', array('pm' => $pm))); //Send the e-mail off $mailer->send(); } } return $saveStatus; }
public function executeEmailNotify() { $c = new Criteria(); $c->add(NotificationEmailsPeer::USER_ID, $this->getRequestParameter('user_id')); $notifies = NotificationEmailsPeer::doSelectOne($c); if ($notifies != NULL) { $notifies->setOnOff($this->getRequestParameter('st')); $notifies->save(); } else { $c = new NotificationEmails(); $c->setUserId($this->getRequestParameter('user_id')); $c->setOnOff($this->getRequestParameter('st')); $c->save(); } $c = new Criteria(); $c->add(UserPeer::ID, $this->getRequestParameter('user_id')); $user = UserPeer::doSelectOne($c); $this->redirect('@profile?username=' . $user->getUsername()); }
/** * 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(NotificationEmailsPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(NotificationEmailsPeer::DATABASE_NAME); $criteria->add(NotificationEmailsPeer::ID, $pks, Criteria::IN); $objs = NotificationEmailsPeer::doSelect($criteria, $con); } return $objs; }