Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/02/2017 07:25:42 AM (7 years ago)
Author:
johnjamesjacoby
Message:

Moderation: Implement theme-side edit-lock interface.

  • Edits to defaut theme javascript to interact with alert UI
  • Add alert-topic-lock.php template part
  • Add topic functions relating to edit-lock functionality
  • Modify single-topic and topic-edit template parts to include the alert part
  • Add CSS to Default template pack to stylize edit-lock alert like a modal (could be pretty much anything)

Props pippin for inspiration. See #3074.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/template.php

    r6320 r6344  
    42464246    return false;
    42474247}
     4248
     4249/** Warning *******************************************************************/
     4250
     4251/**
     4252 * Should the topic-lock alert appear?
     4253 *
     4254 * @since 2.6.0 bbPress (r6342)
     4255 *
     4256 * @return bool
     4257 */
     4258function bbp_show_topic_lock_alert() {
     4259
     4260    // Default to not showing the alert
     4261    $retval = false;
     4262
     4263    // Get the current topic ID
     4264    $topic_id = bbp_get_topic_id();
     4265
     4266    // Only show on single topic pages
     4267    if ( bbp_is_topic_edit() || bbp_is_single_topic() ) {
     4268
     4269        // Only show to moderators
     4270        if ( current_user_can( 'moderate', $topic_id ) ) {
     4271
     4272            // Locked?
     4273            $user_id = bbp_check_post_lock( $topic_id );
     4274
     4275            // Only show if not locked by the current user
     4276            if ( ! empty( $user_id ) && ( bbp_get_current_user_id() !== $user_id ) ) {
     4277                $retval = true;
     4278            }
     4279        }
     4280    }
     4281
     4282    return (bool) apply_filters( 'bbp_show_topic_lock_alert', $retval, $topic_id );
     4283}
     4284
     4285/**
     4286 * Output the topic lock description
     4287 *
     4288 * @since 2.6.0 bbPress (r6343)
     4289 *
     4290 * @param int $topic_id Optional. Topic id
     4291 */
     4292function bbp_topic_lock_description( $topic_id = 0 ) {
     4293    echo bbp_get_topic_lock_description( $topic_id );
     4294}
     4295    /**
     4296     * Return the topic lock description
     4297     *
     4298     * @since 2.6.0 bbPress (r6343)
     4299     *
     4300     * @param int $topic_id Optional. Topic id
     4301     */
     4302    function bbp_get_topic_lock_description( $topic_id = 0 ) {
     4303
     4304        // Check if topic is edit locked
     4305        $topic_id = bbp_get_topic_id( $topic_id );
     4306        $user_id  = bbp_check_post_lock( $topic_id );
     4307        $person   = empty( $user_id )
     4308            ? esc_html__( 'Nobody', 'bbpress' )
     4309            : bbp_get_user_profile_link( $user_id );
     4310
     4311        // Get the text
     4312        $text = sprintf( esc_html__( '%1$s is currently editing this topic.', 'bbpress' ), $person );
     4313
     4314        return apply_filters( 'bbp_get_topic_lock_description', $text, $user_id, $topic_id );
     4315    }
Note: See TracChangeset for help on using the changeset viewer.