Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/08/2013 08:57:41 PM (11 years ago)
Author:
boonebgorges
Message:

Inline doc improvements for bp-activity-akismet.php

See #5022

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-akismet.php

    r6825 r7395  
    11<?php
    22/**
    3  * Akismet support for BuddyPress' Activity Stream
     3 * Akismet support for BuddyPress' Activity Stream.
    44 *
    55 * @package BuddyPress
     
    1111if ( !defined( 'ABSPATH' ) ) exit;
    1212
     13/**
     14 * Akismet support for the Activity component.
     15 *
     16 * @since BuddyPress (1.6)
     17 */
    1318class BP_Akismet {
    1419    /**
    15      * The activity last marked as spam
     20     * The activity last marked as spam.
    1621     *
    1722     * @access protected
     
    2227
    2328    /**
    24      * Constructor
     29     * Constructor.
    2530     *
    2631     * @since BuddyPress (1.6)
     
    3136
    3237    /**
    33      * Hook Akismet into the activity stream
     38     * Hook Akismet into the activity stream.
    3439     *
    3540     * @since BuddyPress (1.6)
     
    6570     * akismet_comment_row_action() function. Thanks!
    6671     *
    67      * @param array $actions The hover links
    68      * @param array $activity The activity for the current row being processed
    69      * @return array The hover links
    70      * @since BuddyPress (1.6)
     72     * @since BuddyPress (1.6)
     73     *
     74     * @param array $actions The hover links.
     75     * @param array $activity The activity for the current row being processed.
     76     * @return array The hover links.
    7177     */
    7278    function comment_row_action( $actions, $activity ) {
     
    111117
    112118    /**
    113      * Adds a nonce to the member profile status form, and to the reply form of each activity stream item.
    114      * This is used by Akismet to help detect spam activity.
     119     * Generate nonces for activity forms.
     120     *
     121     * These nonces appear in the member profile status form, as well as in
     122     * the reply form of each activity item. The nonces are, in turn, used
     123     * by Akismet to help detect spam activity.
     124     *
     125     * @since BuddyPress (1.6)
    115126     *
    116127     * @see http://plugins.trac.wordpress.org/ticket/1232
    117      * @since BuddyPress (1.6)
    118128     */
    119129    public function add_activity_stream_nonce() {
     
    131141
    132142    /**
    133      * Check the member's latest (activity) update to see if it's the item that was (just) marked as spam.
    134      *
    135      * This can't be done in BP_Akismet::check_activity() due to BP-Default's AJAX implementation; see bp_dtheme_post_update().
    136      *
    137      * @param string $content Activity update text
    138      * @param int $user_id User ID
    139      * @param int $activity_id Activity ID
     143     * Clean up the bp_latest_update usermeta in case of spamming.
     144     *
     145     * Run just after an update is posted, this method check to see whether
     146     * the newly created update has been marked as spam by Akismet. If so,
     147     * the cached update is cleared from the user's 'bp_latest_update'
     148     * usermeta, ensuring that it won't appear in the member header and
     149     * elsewhere in the theme.
     150     *
     151     * This can't be done in BP_Akismet::check_activity() due to the
     152     * default AJAX implementation; see bp_dtheme_post_update().
     153     *
     154     * @since BuddyPress (1.6)
     155     *
    140156     * @see bp_dtheme_post_update()
    141      * @since BuddyPress (1.6)
     157     *
     158     * @param string $content Activity update text.
     159     * @param int $user_id User ID.
     160     * @param int $activity_id Activity ID.
    142161     */
    143162    public function check_member_activity_update( $content, $user_id, $activity_id ) {
     
    212231
    213232    /**
    214      * Get a list of filterable types of activity item that we want Akismet to automatically check for spam.
    215      *
    216      * @return array List of activity types
    217      * @since BuddyPress (1.6)
     233     * Get a filterable list of activity types that Akismet should automatically check for spam.
     234     *
     235     * @since BuddyPress (1.6)
     236     *
    218237     * @static
     238     *
     239     * @return array List of activity types.
    219240     */
    220241    public static function get_activity_types() {
     
    223244
    224245    /**
    225      * Mark activity item as spam
     246     * Mark activity item as spam.
     247     *
     248     * @since BuddyPress (1.6)
    226249     *
    227250     * @param BP_Activity_Activity $activity
    228251     * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as spam) or "by_akismet" (automatically spammed).
    229      * @since BuddyPress (1.6)
    230252     */
    231253    public function mark_as_spam( $activity, $source ) {
     
    237259
    238260    /**
    239      * Mark activity item as ham
     261     * Mark activity item as ham.
     262     *
     263     * @since BuddyPress (1.6)
    240264     *
    241265     * @param BP_Activity_Activity $activity
    242266     * @param string $source Either "by_a_person" (e.g. a person has manually marked the activity as ham) or "by_akismet" (automatically hammed).
    243      * @since BuddyPress (1.6)
    244267     */
    245268    public function mark_as_ham( $activity, $source ) {
     
    252275
    253276    /**
    254      * Build a data package for the Akismet service to inspect
    255      *
    256      * @param BP_Activity_Activity $activity
     277     * Build a data package for the Akismet service to inspect.
     278     *
     279     * @since BuddyPress (1.6)
     280     *
    257281     * @see http://akismet.com/development/api/#comment-check
    258      * @since BuddyPress (1.6)
    259282     * @static
     283     *
     284     * @param BP_Activity_Activity $activity Activity item data.
    260285     */
    261286    public static function build_akismet_data_package( $activity ) {
     
    291316
    292317    /**
    293      * Check if the activity item is spam or ham
    294      *
    295      * @param BP_Activity_Activity $activity The activity item to check
     318     * Check if the activity item is spam or ham.
     319     *
     320     * @since BuddyPress (1.6)
     321     *
    296322     * @see http://akismet.com/development/api/
    297      * @since BuddyPress (1.6)
    298323     * @todo Spam counter?
    299324     * @todo Auto-delete old spam?
     325     *
     326     * @param BP_Activity_Activity $activity The activity item to check.
    300327     */
    301328    public function check_activity( $activity ) {
     
    333360
    334361    /**
    335      * Update activity meta after a manual spam change (user initiated)
    336      *
    337      * @param BP_Activity_Activity $activity The activity to check
    338      * @since BuddyPress (1.6)
     362     * Update activity meta after a manual spam change (user-initiated).
     363     *
     364     * @since BuddyPress (1.6)
     365     *
     366     * @param BP_Activity_Activity $activity The activity to check.
    339367     */
    340368    public function update_activity_spam_meta( $activity ) {
     
    349377
    350378    /**
    351      * Update activity meta after a manual ham change (user initiated)
    352      *
    353      * @param BP_Activity_Activity $activity The activity to check
    354      * @since BuddyPress (1.6)
     379     * Update activity meta after a manual ham change (user-initiated).
     380     *
     381     * @since BuddyPress (1.6)
     382     *
     383     * @param BP_Activity_Activity $activity The activity to check.
    355384     */
    356385    public function update_activity_ham_meta( $activity ) {
     
    365394
    366395    /**
    367      * Update activity meta after an automatic spam check (not user initiated)
    368      *
    369      * @param BP_Activity_Activity $activity The activity to check
    370      * @since BuddyPress (1.6)
     396     * Update activity meta after an automatic spam check (not user-initiated).
     397     *
     398     * @since BuddyPress (1.6)
     399     *
     400     * @param BP_Activity_Activity $activity The activity to check.
    371401     */
    372402    public function update_activity_akismet_meta( $activity ) {
     
    400430
    401431    /**
    402      * Contact Akismet to check if this is spam or ham
    403      *
    404      * Props to WordPress core Akismet plugin for alot of this
     432     * Contact Akismet to check if this is spam or ham.
     433     *
     434     * Props to WordPress core Akismet plugin for alot of this.
     435     *
     436     * @since BuddyPress (1.6)
    405437     *
    406438     * @global string $akismet_api_host
    407439     * @global string $akismet_api_port
    408      * @param array $activity_data Packet of information to submit to Akismet
    409      * @param string $check "check" or "submit"
    410      * @param string $spam "spam" or "ham"
    411      * @since BuddyPress (1.6)
     440     *
     441     * @param array $activity_data Packet of information to submit to Akismet.
     442     * @param string $check "check" or "submit".
     443     * @param string $spam "spam" or "ham".
     444     * @return array $activity_data Activity data, with Akismet data added.
    412445     */
    413446    public function send_akismet_request( $activity_data, $check = 'check', $spam = 'spam' ) {
     
    478511
    479512    /**
    480      * Filters user agent when sending to Akismet.
    481      *
    482      * @param string $user_agent
    483      * @since BuddyPress (1.6)
     513     * Filters user agent when sending to Akismet to add BuddyPress info.
     514     *
     515     * @since BuddyPress (1.6)
     516     *
     517     * @param string $user_agent User agent string, as generated by Akismet.
     518     * @return string $user_agent Modified user agent string.
    484519     */
    485520    public function buddypress_ua( $user_agent ) {
     
    491526     * Adds a "History" meta box to the activity edit screen.
    492527     *
    493      * @param string $screen_action The type of screen that has been requested
    494      * @since BuddyPress (1.6)
     528     * @since BuddyPress (1.6)
     529     *
     530     * @param string $screen_action The type of screen that has been requested.
    495531     */
    496532    function add_history_metabox( $screen_action ) {
     
    504540
    505541    /**
    506      * History meta box for the Activity admin edit screen
    507      *
    508      * @param object $item Activity item
    509      * @since BuddyPress (1.6)
     542     * History meta box for the Activity admin edit screen.
     543     *
     544     * @since BuddyPress (1.6)
     545     *
     546     * @see http://buddypress.trac.wordpress.org/ticket/3907
    510547     * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
    511      * @see http://buddypress.trac.wordpress.org/ticket/3907
     548     *
     549     * @param object $item Activity item.
    512550     */
    513551    function history_metabox( $item ) {
     
    523561
    524562    /**
    525      * Update an activity item's Akismet history
    526      *
    527      * @param int $activity_id Activity item ID
    528      * @param string $message Human-readable description of what's changed
    529      * @param string $event The type of check we were carrying out
    530      * @since BuddyPress (1.6)
     563     * Update an activity item's Akismet history.
     564     *
     565     * @since BuddyPress (1.6)
     566     *
     567     * @param int $activity_id Activity item ID.
     568     * @param string $message Human-readable description of what's changed.
     569     * @param string $event The type of check we were carrying out.
    531570     */
    532571    public function update_activity_history( $activity_id = 0, $message = '', $event = '' ) {
     
    543582
    544583    /**
    545      * Get an activity item's Akismet history
    546      *
    547      * @param int $activity_id Activity item ID
    548      * @return array The activity item's Akismet history
    549      * @since BuddyPress (1.6)
     584     * Get an activity item's Akismet history.
     585     *
     586     * @since BuddyPress (1.6)
     587     *
     588     * @param int $activity_id Activity item ID.
     589     * @return array The activity item's Akismet history.
    550590     */
    551591    public function get_activity_history( $activity_id = 0 ) {
     
    562602
    563603/**
    564  * Deletes old spam activity meta data, as _bp_akismet_submission meta can be large.
     604 * Delete old spam activity meta data
    565605 *
    566  * @global object $bp BuddyPress global settings
    567  * @global wpdb $wpdb WordPress database object
     606 * This is done as a clean-up mechanism, as _bp_akismet_submission meta can
     607 * grow to be quite large.
     608 *
    568609 * @since BuddyPress (1.6)
     610 *
     611 * @global object $bp BuddyPress global settings.
     612 * @global wpdb $wpdb WordPress database object.
    569613 */
    570614function bp_activity_akismet_delete_old_metadata() {
Note: See TracChangeset for help on using the changeset viewer.