/** * History updated after unselecting an answer. * @param integer $user_id User ID. * @param integer $question_id Question ID. * @param integer $answer_id Answer ID. */ public function unselect_answer($user_id, $question_id, $answer_id) { $activity_arr = array('user_id' => $user_id, 'type' => 'answer_unselected', 'question_id' => $question_id, 'answer_id' => $answer_id, 'permalink' => get_permalink($answer_id)); ap_new_activity($activity_arr); // Add question activity meta. update_post_meta($question_id, '__ap_activity', array('type' => 'answer_unselected', 'user_id' => $user_id, 'date' => current_time('mysql'))); // Add answer activity meta. update_post_meta($answer_id, '__ap_activity', array('type' => 'unselected_best_answer', 'user_id' => $user_id, 'date' => current_time('mysql'))); }
/** * @param string $title */ public function check_mentions($question_id, $contents, $title, $user_id, $type, $answer_id = 0) { $users = ap_find_mentioned_users($contents); if (false !== $users) { $user_title = ap_activity_user_name($user_id); foreach ($users as $user) { if ($user->id != $user_id) { $activity_arr = array('user_id' => $user_id, 'type' => 'mention', 'secondary_user' => $user->id, 'question_id' => $question_id, 'answer_id' => $answer_id, 'permalink' => wp_get_shortlink($question_id), 'content' => sprintf(__('%s mentioned you in %s %s', 'anspress-question-answer'), $user_title, $type, $title)); $activity_id = ap_new_activity($activity_arr); ap_new_notification($activity_id, $user->id); } } } }
/** * Add activitt for new reputation * @param integer $user_id User ID. * @param integer $action_id Action ID. * @param integer $reputation Points earned. * @param string $type Vote type. */ public function ap_added_reputation($user_id, $action_id, $reputation, $type) { $activity_arr = array('user_id' => $user_id, 'type' => 'reputation_gain', 'item_id' => $action_id, 'parent_type' => 'user', 'permalink' => get_permalink($action_id), 'reputation' => $reputation, 'reputation_type' => $type); $activity_id = ap_new_activity($activity_arr); // Insert a notification. // ap_new_notification( $activity_id, $user_id ); }