/** * Retrieve the URL of the current post * * @param Fishpig_Wordpress_Model_Post_Comment $comment * @return string */ public function getPostUrl(Fishpig_Wordpress_Model_Post_Comment $comment) { if ($post = $comment->getPost()) { return sprintf('%s#comment-%d', $post->getPermalink(), $comment->getId()); } return '#'; }
/** * Notify the user from oldComment about newComment * * @param Fishpig_Wordpress_Model_Post_Comment $oldComment * @param Fishpig_Wordpress_Model_Post_Comment $newComment * @return bool */ protected function _notify(Fishpig_Wordpress_Model_Post_Comment $oldComment, Fishpig_Wordpress_Model_Post_Comment $newComment) { $subject = $this->getPluginOption('mail_subject'); $body = $this->getPluginOption('mail_message'); if ($body) { $mailVars = array('blogname' => Mage::helper('wordpress')->getWpOption('blogname'), 'blogurl' => Mage::helper('wordpress')->getUrl(), 'postname' => $newComment->getPost()->getPostTitle(), 'pc_content' => trim($oldComment->getCommentContent()), 'pc_author' => $oldComment->getCommentAuthor(), 'pc_date' => $oldComment->getCommentDate(), 'cc_content' => trim($newComment->getCommentContent()), 'cc_author' => $newComment->getCommentAuthor(), 'cc_date' => $newComment->getCommentDate(), 'cc_url' => $newComment->getCommentAuthorUrl(), 'commentlink' => $newComment->getUrl()); foreach ($mailVars as $mailVar => $value) { $subject = preg_replace('/(\\[' . $mailVar . '\\])/i', $value, $subject); $body = preg_replace('/(\\[' . $mailVar . '\\])/i', $value, $body); } $mail = new Zend_Mail(); $mail->setBodyHtml($body); $mail->setFrom(Mage::getStoreConfig('trans_email/ident_general/email'), Mage::getStoreConfig('trans_email/ident_general/name')); $mail->addTo($oldComment->getCommentAuthorEmail()); $mail->setSubject($subject); try { $mail->send(); return true; } catch (Exception $e) { Mage::helper('wordpress')->log($e->getMessage()); } } return false; }