Example #1
0
 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());
 }
Example #2
0
File: User.php Project: rayku/rayku
 /**
  * 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;
 }