/** * Create a wall activity for this user after posting an answer. * * @param CMA_Thread $instance * @param CMA_Answer $answer */ static function answer_posted_activity(CMA_Thread $instance, CMA_Answer $answer) { if (!$instance->isPublished()) { return; } else { if (!$answer->isApproved() or $answer->isPrivate()) { return; } } $post = $instance->getPost(); $user_id = $answer->getAuthorId(); $permalink = $answer->getPermalink(); $action = sprintf(CMA::__('%s answered to the question "%s"'), bp_core_get_userlink($user_id), sprintf('<a href="%s">%s</a>', esc_attr($permalink), esc_html($instance->getTitle()))); $content = CMA_Thread::lightContent($answer->getContent()); if (function_exists('bp_activity_add')) { bp_activity_add(array('action' => $action, 'content' => $content, 'component' => self::COMPONENT, 'type' => 'answer_posted', 'primary_link' => $permalink, 'user_id' => $user_id, 'item_id' => $answer->getId())); } if ($category = $instance->getCategory()) { $groups = self::getRelatedGroups(array($category->getId(), $category->getParentId())); if ($groups) { foreach ($groups as $groupId) { if (function_exists('groups_record_activity')) { groups_record_activity(array('action' => $action, 'content' => $content, 'type' => 'new_groupblog_post', 'primary_link' => $permalink, 'item_id' => $groupId, 'secondary_item_id' => $answer->getAuthorId(), 'hide_sitewide' => 0)); } } } } }
protected static function _processReportSpam() { if (self::$query->is_single()) { $post = self::$query->post; if (!empty($post)) { $response = array('success' => 0, 'message' => CMA::__('An error occurred.')); if (empty($_POST['nonce']) or !wp_verify_nonce($_POST['nonce'], 'cma_report_spam')) { $response['message'] = CMA::__('Invalid nonce.'); } else { if (CMA_Settings::canReportSpam()) { $thread = CMA_Thread::getInstance($post->ID); $answerId = self::_getParam('answerId'); if ($userId = CMA::getPostingUserId()) { $user = apply_filters('cma_filter_author', get_user_by('id', $userId), array('thread' => $thread)); $user = $user->display_name; } else { $user = CMA::__('Guest'); } if ($answerId and $answer = CMA_Answer::getById($answerId)) { $answer->markAsSpam(true); $url = $answer->getPermalink(); $author = $answer->getAuthorLink(true); $content = CMA_Thread::lightContent($answer->getContent()); $datetime = $answer->getDate(); $trashLink = get_admin_url(null, sprintf('comment.php?c=%d&action=trashcomment', $answerId)); $spamLink = get_admin_url(null, sprintf('comment.php?c=%d&action=spamcomment', $answerId)); } else { $thread->markAsSpam(true); $url = get_permalink($post->ID); $author = $thread->getAuthorLink(true); $content = $thread->getLightContent(); $datetime = $post->post_date; $trashLink = get_admin_url(null, sprintf('post.php?post=%d&action=trash', $post->ID)); $spamLink = '--'; } $replace = array('[blogname]' => get_bloginfo('name'), '[url]' => $url, '[title]' => strip_tags($thread->getTitle()), '[author]' => strip_tags($author), '[content]' => $content, '[user]' => strip_tags($user), '[datetime]' => $datetime, '[trash]' => $trashLink, '[spam]' => $spamLink); $subject = strtr(CMA_Settings::getOption(CMA_Settings::OPTION_SPAM_REPORTING_EMAIL_SUBJECT), $replace); $template = strtr(CMA_Settings::getOption(CMA_Settings::OPTION_SPAM_REPORTING_EMAIL_TEMPLATE), $replace); $emails = explode(',', CMA_Settings::getOption(CMA_Settings::OPTION_SPAM_REPORTING_EMAIL_ADDR)); CMA_Email::send($emails, $subject, $template); /* $headers = array(); foreach($emails as $email) { $email = trim($email); if (is_email($email)) { $headers[] = ' Bcc: '. $email; } } if (!empty($headers)) wp_mail(null, $subject, $template, $headers); */ $response['success'] = 1; $response['message'] = CMA_Labels::getLocalized('spam_report_sent'); } } header('Content-type: application/json'); echo json_encode($response); exit; } } }