Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/06/2005 01:38:55 AM (21 years ago)
Author:
matt
Message:

Timeout edits for non-admins.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-includes/functions.php

    r25 r35  
    189189        return $bb->admin_email;
    190190        break;
     191    case 'edit_lock' :
     192        return $bb->edit_lock;
     193        break;
    191194    endswitch;
    192195}
     
    258261}
    259262
    260 function bb_current_time($type) {
     263function bb_current_time( $type = 'timestamp' ) {
    261264    switch ($type) {
    262265        case 'mysql':
     
    414417}
    415418
     419function can_delete( $user_id, $admin_id = 0) {
     420    global $bbdb, $current_user;
     421    if ( !$admin_id )
     422        $admin_id = $current_user->user_id;
     423    $admin = bb_get_user( $admin_id );
     424    $user  = bb_get_user( $user_id  );
     425
     426    if ( $user->user_type < $admin->user_type && $admin->user_type != 0 )
     427        return true;
     428    else
     429        return false;
     430}
     431
     432function can_edit_post( $post_id, $user_id = 0 ) {
     433    global $bbdb, $current_user;
     434    if ( !$user_id )
     435        $user_id = $current_user->user_id;
     436    $user = bb_get_user( $user_id );
     437    $post = bb_get_post( $post_id );
     438    $post_author = bb_get_user ( $post->poster_id );
     439
     440    if ( $user->user_type > $post_author->user_type )
     441        return true;
     442
     443    $post_time  = strtotime( $post->post_time );
     444    $curr_time  = time();
     445    $time_limit = bb_get_option('edit_lock') * 60;
     446    if ( ($curr_time - $post_time) > $time_limit )
     447        return false;
     448    else
     449        return true;
     450}
     451
    416452function bb_is_first( $post_id ) { // First post in thread
    417453    global $bbdb;
Note: See TracChangeset for help on using the changeset viewer.