private function sendBestResponseMessage($post) { $user = UserPeer::retrieveByPK($post->getPosterId()); $thread = ThreadPeer::retrieveByPK($post->getThreadId()); $cats = CategoryPeer::getForExpertCategoryUserId($user->getId()); $cat_tab = array(); foreach ($cats as $cat) { $cat_tab[] = $cat->getName(); } $cat_list = join(', ', $cat_tab); if ($user->getType() == UserPeer::getTypeFromValue('expert')) { $subject = 'Best Response Selected'; $body = 'Hi ' . $user->getName() . ',<br><br> Your reply to the question, "' . $thread->getTitle() . '" on the question boards, was just selected as the best response.<br><br> Rayku SYS'; //Grab the user object $currentuser = UserPeer::retrieveByPK($this->getUser()->getRaykuUserId()); //Send the messages $currentuser->sendMessage($user->getId(), $subject, $body); } else { $subject = 'Best Response Selected'; $body = 'Hi ' . $user->getName() . ',<br><br> Congratulations! Your reply to the question, "' . $thread->getTitle() . '" on the question boards, was just selected as the best response.<br><br> Your expert score has been increased accordingly.<br><br> Thanks!<br> Rayku SYS'; //Grab the user object $currentuser = UserPeer::retrieveByPK($this->getUser()->getRaykuUserId()); //Send the messages $currentuser->sendMessage($user->getId(), $subject, $body); } $sub1 = 'You have selected an Expert Best Response'; $body1 = 'Hi ' . $this->getUser()->getRaykuUser()->getName() . ',<br><br> Thank you for selecting a best response for your question. The author of the response is ' . $user->getName() . ', who is an expert in the following subjects: <br> ' . $cat_list . '<br><br> ' . $user->getName() . ' has been teaching avid learners with Rayku since ' . $user->getCreatedAt('Y-m-d') . '. Take a look at the following link, for information on spending an 1-on-1 session with ' . $user->getName() . ':<br><br> <a href="' . sfConfig::get('app_rayku_url') . '/expertmanager/portfolio/' . $user->getUsername() . '">http://www.rayku.com/expertmanager/portfolio/' . $user->getUsername() . '</a><br><br> Rayku SYS'; //Grab the user object $expertuser = UserPeer::retrieveByPK($user->getId()); //Send the messages $expertuser->sendMessage($this->getUser()->getRaykuUserId(), $sub1, $body1); }