<commit_before><?php

/**
 * Subclass for representing a row from the 'sf_simple_forum_post' table.
 *
 * 
 *
 * @package plugins.sfSimpleForumPlugin.lib.model
 */ 
class sfSimpleForumPost extends PluginsfSimpleForumPost
{
    public function delete(PropelPDO $con = null, $preserveTopic = true)
    {
        $postDir = $this->getId();
        $uploadDir = sfConfig::get('sf_upload_dir').'/forum/'.$postDir;

        if(file_exists($uploadDir)) {
            sfSimpleForumTools::unlinkRecursive($uploadDir);
        }

        parent::delete($con, $preserveTopic);
    }
    
    public function sendEmailNotifications() 
    {
    	$user_emails = array();
    	$user_emails[] = sfConfig::get('app_appflower_forum_notification_email');
    	
    	$c = new Criteria();
    	$c->add(sfSimpleForumPostPeer::TOPIC_ID, $this->getTopicId());
    	$posts = sfSimpleForumPostPeer::doSelect($c);
    	
    	foreach ($posts as $post) 
    	{
    		if ($post->getUserId())
    		{
    			$user_emails[] = $post->getUser()->getUsername();
    		} else if ($post->getAuthorEmail()!='') {
    			$user_emails[] = $post->getAuthorEmail();
    		}
    	}
    	
    	$user_emails = array_unique($user_emails);
    	
    	$configuration = sfProjectConfiguration::getActive();
    	$configuration->loadHelpers('Partial'); 
    	foreach ($user_emails as $email)
    	{
    		$myValidator = new sfEmailValidator(sfContext::getInstance());
	      	$errorMsg = "error";
	      	if ($myValidator->execute($email, $errorMsg)) 
	      	{
			    $body = get_partial('mail/forumNotification', array('post'=>$this));
				$configuration->sendMail('Appflower.com forum notification', $email, $body);
	      	}
    	}
    	
    }
}<commit_msg>#908 - new email template implemented to forum, blog notification and news leter subscription<commit_after><?php

/**
 * Subclass for representing a row from the 'sf_simple_forum_post' table.
 *
 * 
 *
 * @package plugins.sfSimpleForumPlugin.lib.model
 */ 
class sfSimpleForumPost extends PluginsfSimpleForumPost
{
    public function delete(PropelPDO $con = null, $preserveTopic = true)
    {
        $postDir = $this->getId();
        $uploadDir = sfConfig::get('sf_upload_dir').'/forum/'.$postDir;

        if(file_exists($uploadDir)) {
            sfSimpleForumTools::unlinkRecursive($uploadDir);
        }

        parent::delete($con, $preserveTopic);
    }
    
    public function sendEmailNotifications() 
    {
    	$user_emails = array();
    	$user_emails[] = sfConfig::get('app_appflower_forum_notification_email');
    	
    	$c = new Criteria();
    	$c->add(sfSimpleForumPostPeer::TOPIC_ID, $this->getTopicId());
    	$posts = sfSimpleForumPostPeer::doSelect($c);
    	
    	foreach ($posts as $post) 
    	{
    		if ($post->getUserId())
    		{
    			$user_emails[] = $post->getUser()->getUsername();
    		} else if ($post->getAuthorEmail()!='') {
    			$user_emails[] = $post->getAuthorEmail();
    		}
    	}
    	
    	$user_emails = array_unique($user_emails);
    	
    	$configuration = sfProjectConfiguration::getActive();
    	$configuration->loadHelpers('Partial'); 
    	foreach ($user_emails as $email)
    	{
    		$myValidator = new sfEmailValidator(sfContext::getInstance());
	      	$errorMsg = "error";
	      	if ($myValidator->execute($email, $errorMsg)) 
	      	{
	      		$subject = 'Forum notification';
				$rand = md5(time());
			    $body = get_partial('mail/forumNotification', array('post'=>$this, 'title'=>$subject, 'rand'=>$rand));
				$configuration->sendMail('Forum notification', $email, $body, null, $rand);
	      	}
    	}
    	
    }
}
{'fraction_non_alphanumeric': 0.15177580466148724, 'fraction_numerical': 0.0011098779134295228, 'mean_word_length': 3.036954087346025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4128416', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1175, 'n_words': 186}